UtilityLayerRenderer rendering sequence

Several UtilityLayerrenderers may be created in the program, and their execution order will affect the corresponding logic. And the order of execution can not be modified, follow the principle of coming from behind. Can I add an attribute similar to renderingGroupId to specify the priority of UtilityLayerRenderer?

I don’t think you can change the order the utility renderers are rendered this way because their render method is called on the onAfterRenderCameraObservable observer of their original scene. You would need to reorder the scenes themselves to change this order.

1 Like

I know, what I do now is to create all the required utilitylayerRenderers in order in advance. I would like to say that if UtilityLayerRenderer provides an attribute or method, it can easily modify _originalPointerObserver use makeObserverTopPriority and _afterRenderObserver Use makeObserverBottomPriority to easier from the external call adjust its priority, does it make sense?

Ok, so you want to be able to change the order in which the utility layer render observers appear in the onAfterRenderCameraObservable and onPrePointerObservable scene observables?

I don’t see how to do this currently, because observers don’t have a priority. Even if they did, it wouldn’t be enough because we would need to differentiate between observers coming from a utility layer renderer and other observers, to reorder only those.

Perhaps we could have a payload that we could attach to an observer when we add it to the observable. That way, a utility layer renderer would be able to loop through all the observers, remove the ones that are tied to a utility layer renderer, sort them out, and reinsert them in order…

cc @RaananW to see if this is something possible / valid.

1 Like

When adding an observer you can decide if you want to push it as the first or last object, this can be added as a parameter to the utility layer configuration options (or the constructor?), but that’s the highest level of order manipulation we currently provide.
It’s always possible to add a utility-layer-manager that will manage the order internally and register itself (and only itself) to the onAfterRender observable, but this is nothing we have planned. We do accept PRs? :slight_smile:

1 Like