Skip to content

Conversation

@lucaheft
Copy link
Contributor

Description

Adds 2 new generic events to AppBase

init -> Fired after AppBase.init
configure -> Fired after successfull AppBase.configure

I've noticed, that there are no jsdocs for events in AppBase, if desired I can add those as well

If this gets merged we also want to reflect these changes on the developer site Application Lifecycle

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How strange the events are not documented. I'll put on my list to document.

Please document yours though - see how these are done:

class Scene extends EventHandler {
/**
* Fired when the layer composition is set. Use this event to add callbacks or advanced
* properties to your layers. The handler is passed the old and the new
* {@link LayerComposition}.
*
* @event
* @example
* app.scene.on('set:layers', (oldComp, newComp) => {
* const list = newComp.layerList;
* for (let i = 0; i < list.length; i++) {
* const layer = list[i];
* switch (layer.name) {
* case 'MyLayer':
* layer.onEnable = myOnEnableFunction;
* layer.onDisable = myOnDisableFunction;
* break;
* case 'MyOtherLayer':
* layer.clearColorBuffer = true;
* break;
* }
* }
* });
*/
static EVENT_SETLAYERS = 'set:layers';
/**
* Fired when the skybox is set. The handler is passed the {@link Texture} that is the
* previously used skybox cubemap texture. The new skybox cubemap texture is in the
* {@link Scene#skybox} property.
*
* @event
* @example
* app.scene.on('set:skybox', (oldSkybox) => {
* console.log(`Skybox changed from ${oldSkybox.name} to ${app.scene.skybox.name}`);
* });
*/
static EVENT_SETSKYBOX = 'set:skybox';
/**
* Fired before the camera renders the scene. The handler is passed the {@link CameraComponent}
* that will render the scene.
*
* @event
* @example
* app.scene.on('prerender', (camera) => {
* console.log(`Camera ${camera.entity.name} will render the scene`);
* });
*/
static EVENT_PRERENDER = 'prerender';

@Maksims
Copy link
Collaborator

Maksims commented Nov 27, 2025

configure - seems generic in this context. Like application is configured, but with what and by whom?
Really it is something like: config:loaded because this is very specific to way Editor outputs the project and provides config.json with data in it. Engine only users usually don't use that approach. A bit more info in description of the event - will be useful.

@lucaheft
Copy link
Contributor Author

I see, not sure how to go forward with this. How about we only add init event for now?

@Maksims
Copy link
Collaborator

Maksims commented Nov 27, 2025

I see, not sure how to go forward with this. How about we only add init event for now?

I think if you name second event as config:loaded - should be fine.

@lucaheft lucaheft requested a review from mvaligursky November 28, 2025 08:27
@lucaheft
Copy link
Contributor Author

lucaheft commented Nov 28, 2025

I just tried this out and it seems like when launching in the editor (use_local_engine), these events are not called. However when downloading they work correctly.

I guess there is some custom editor startup which doesn't call init and configure of the AppBase?
This could be quite confusing for the user.
Can this be changed in the editor, so the behaviour is similiar to the exported editor project?

In my test I subscribed to the events in the loadingscreen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants