Event for creating a new Entity

When a project is launched, there is a starting scene with existing entities.

Now, when a new scene is loaded with code, I need an event for when an entity is created in that scene.
For example:
this.app.on("sceneEntityCreated", (entity) => {}, this);

Additionally, I need an event for when a new entity is created somewhere in the scene using
new pc.Entity().
For example:
this.app.on("newEntityCreated", (entity) => {}, this);

How can I obtain information about newly created entities on the scene?

I don’t see the engine firing any events in this case.

When you load a scene with code, can you walk the created hierarchy to get all the entities? I’m not sure I have a better suggestion.

It seems that if there are no other options, I’ll have to iterate through all the objects after the scene is loaded.

It would be good to add such events to the engine.

It likely would be, but it’s not simple - often you’d want this to be called after all components are initialized and so on … not directly from the constructor, and that creates complexity.

Walking over the scene entities compared to that is easy. You could even keep a Set of known entities to filter those out.