Postupdate callback engine-only

Hi all,

I would like to register a postUpdate function in app, just like it’s done with update in the gltf-viewer:

Now, app only has an update callback, so I register it like so:

app.on('update', this.update, this);
app.on('update', this.postUpdate, this);

Is this the correct way to do it?

Thanks!

I think as far as the Application is concerned ‘update’ can be considered ‘postUpdate’ since it execute last, after all update and post update systems/components have finished executing.

What are you trying to do if I may ask with this post update?

Here is the relevant piece:

1 Like

This manual page may be of help too, it explains the Application Lifecycle: Application Lifecycle | Learn PlayCanvas

1 Like

Thanks @Leonidas, this makes sense!

My postUpdate method updates screen positions and sets styleproperties for hotspots.
But I can integrate this code into the update method then.

1 Like

I think that will work for you!

1 Like

While we are talking about engine-only update method:

I am trying to understand how a specific update method is registered in the gltf-viewer:

Here, a camera is created and the orbitCamera class is instantiated:

The orbitCamera class in turn instantiates the SmoothedValue class, which has an update method:

I can’t figure out where app learns about SmoothedValue’s update method.

Thanks!

There’s an event listen for pc.Application update event: model-viewer/viewer.ts at main · playcanvas/model-viewer · GitHub

1 Like

Thanks @yaustar, sorry, I didn’t see that the viewer class runs all the other classes update methods in its own update method.
So only the viewer class needs app.on('update', this.update, this); :+1: