Hello there, I am experiencing something of an issue. You see my objects which I do not wish to render are exported on a “hidden” layer which includes meshes. UI and also particlesystems. However the issue is that once I want it to be rendered by switching layers the particlesystem will not show. Judging by the code this is most likely due to the fact that the method “updateLayers()” which moves the batches to the actual layer of the object doesnt run after start if the object is hidden (or I may be totally wrong :D). Is this an indended behaviour or am I doing something incorrectly?
Hi Martin, thanks for the question. What you’re encountering isn’t the intended behavior – the ParticleSystem’s updateLayers() method is designed to run during initialization, so if the object starts off hidden, its batched particle data doesn’t update automatically when you change the layer. This means the particle system remains associated with the hidden layer even after you switch layers.
A common workaround is to trigger the update manually after switching the layer. For example, once you make the object visible you could do something like this:
Calling updateLayers() in a lifecycle method (like onEnable) or after the layer change will force the particle system to update its batches and render correctly. Make sure you’re using the latest version of Needle Engine, as updates might address some of these issues. If you continue seeing the problem, it could be a bug and creating a minimal reproducible example on Needle-engine - Vite Template (duplicated) - StackBlitz or filing a bug report might be the best next step.
This recommendation is based on how ParticleSystem batching and layer management work in Needle Engine (see at ParticleSystem.d.ts.md for ParticleSystem details and at Layers.d.ts.md about layering). Let me know if you need any more help!
1 replies left - Become PRO for more replies. thread_Tb3S8k0ofOptnQGfsFj4Q55X Reply to this post directly if you need further help (bottom right button)
No worries, Martin! It’s good that you identified the root of the issue. The ParticleSystem in Needle Engine uses the layer set on the GameObject instead of the Object3D’s layerat ParticleSystem.d.ts.md. This distinction is crucial, especially when dealing with the visibility of particle systems and how layers affect rendering.
When switching layers, make sure to confirm that the GameObject’s layer is updated accordingly, as that will govern the rendered state of the particle system. If you need any further insights or have more questions about managing layers or particle systems, feel free to ask!
0 replies left - Become PRO for more replies. thread_Tb3S8k0ofOptnQGfsFj4Q55X Reply to this post directly if you need further help (bottom right button)