How SubEmitter#inheritDirection works?

I have 2 questions about SubEmitter#inheritDirection :dizzy_face:


When subemitter.inheritDirection=true, its +y is determined, how to derive +x then?


“When subemitter.inheritDirection=true, subemitter’s +y is equal to the direction that particle was heading…” [Use Sub Emitters - Babylon.js Documentation]

Here’s a PG Babylon.js Playground proving that it does not.
Is it a bug ?


This is how it is used:

if (subEmitter.inheritDirection) {
                emitterMesh.position.subtractToRef(this.direction, TmpVectors.Vector3[0]);
                // Look at using Y as forward
                emitterMesh.lookAt(TmpVectors.Vector3[0], 0, Math.PI / 2);

In other words, the sub particle system emitter is aligned with the particle direction that will emit the new sub system

Does that make more sense?

I found that

emitterMesh.position.subtractToRef(this.direction, v)

where v always approach to v3(0,0,0), then

emitterMesh.lookAt(v, 0, Math.PI/2)

emitterMesh will always lookAt origin even if the particle is moving the opposite way…:dizzy_face:

Should L191 at Babylon.js/particle.ts at da661ef2153e10b0e424c6f93792159b53a0a47f · BabylonJS/Babylon.js · GitHub

if (..) {
  emitterMesh.setDirection(this.direction.normalize(), 0, Math.PI/2);



good catch! do you want to do a PR?

1 Like