Repository navigation
Description
Follow-up to #965. That PR fixes how compat ParticleSystem / ParticleSystemSet billboards attach before engine startup registers the scene, under a single contract (see the PR's contract comment). This issue tracks the compat particle behaviors that need Lite runtime work rather than more compat startup sequencing. Please file further compat particle startup edge cases here instead of on #965.
1. Attach renderables after scene registration
Lite attaches a scene billboard (particles, sprites, depth sprites, text) only while registerScene builds the scene. _addSceneRenderable queues on _deferredBuilders (scene-renderable-collection.ts), and only buildScene drains it. A billboard added later is listed and pickable but never drawn. Compat consequences:
- A first or repeated standalone
start()after engine startup animates but adds no billboard. - A
set.start()after engine startup registers the set, which animates but is not drawn. - A set started after a member's startup snapshot: 2 listed, 1 drawn.
- A startup snapshot can outlive its system. A listener running during registration drains a standalone
disposeOnStopburst, readsscene.particleSystems(which evicts the disposed wrapper), then starts the owning set. The set's takeover no longer finds that wrapper, so the snapshot stays listed, drawn and pickable (#965 review).
With runtime attachment, compat can drop the startup queue (scene._beforeLiteRegistration) and attach at start() time, like Babylon.js, with each billboard's lifetime following its Lite system rather than a compat wrapper. Add the sequence above as a regression test.
2. Live particle texture swaps
createParticleBillboard builds its atlas from system.texture once, and the per-frame sync does not read the texture again. Assigning particleTexture after the billboard is built updates the Lite system, but the drawn billboard keeps its old texture.
3. Babylon.js draw order between sprites and particles
Babylon.js draws every sprite manager, then every particle system in scene.particleSystems order, without depth-sorting between systems (renderingGroup.ts). Lite depth-sorts transparent billboards (distance, then order, then insertion order on exact ties). Since #965, compat attaches particles after the sprite managers created before startup, so exact ties match Babylon.js's sprites-first order. Particle-vs-particle ties follow start order, not construction order, and non-tied draws follow distance.
4. A set with a texture-less system
registerNodeParticleSet throws when one of the set's systems has no texture (native Lite and compat alike). Babylon.js simply does not draw that system.
5. A scene disposed by a listener while a set registers
registerNodeParticleSet (particle-scene.ts) does not check for scene disposal between systems. If a scene listener disposes the scene while one system's billboard is added, the loop keeps registering the remaining systems on the disposed scene, both in native Lite and through compat. Compat checks for a disposed scene before it calls the registrar but cannot stop it partway through. The fix is a per-system disposal check inside the Lite loop (a few bytes in every NPE scene).
6. set.start() starts members removed from systems
Babylon.js ParticleSystemSet.start() and dispose() act only on the members still in the public systems array (particleSystemSet.ts). Compat set.start() starts every system of the backing Lite set. A member removed from systems (for example with set.systems.shift()) therefore still emits and draws when the set starts, including after set.dispose() has disposed the remaining members. Master behaves the same. A likely fix is to start only the public-array members, since the registrar draws nothing for an unstarted system. Remaining work is to define what happens to a removed member that is still listed in the scene.
Activity