I am trying to activate/deactivate a mesh’s rendering on-top of others using UtilityLayerRenderer with version 3.3. The mesh is just a simple sphere : CreateSphere(“foo”, 16, 2, scene).
Here, I first render the mesh in the standard scene, but then want to change it to my UtilityLayerRenderer’s scene.
How can I achieve this ? I tried changing .scene and ._scene but this doesn’t seem to work.
Welcome to Babylon! Version 3.3 is quite old, but it looks like there’s still support for it in the Playground, so we’ll be able to use that if necessary. We might not need to, though. In general, if you want something in one scene, then another, I’d recommend just disposing it from the first scene and recreating it in the second; this will probably be the easiest way to be sure the state is clean under all circumstances. For your sphere rendering, just make the sphere as you do now when you want it in the first scene; then, when you want to “move” the sphere to the second scene, cache off the state you care about (position, etc.),
dispose() the old sphere, create a new sphere in the second scene, then set the important state on that. Will this approach work for your use case?