Get TypeError when apply custom emitter to a sub-emitter

Here is a playground to test it:

An error occurs if apply customEmitter to subParticleSystem. But same apply customEmitter to a normal particleSystem, it would be fine.

The error:

math.vector.js:1723 Uncaught TypeError: Cannot read properties of undefined (reading '0')
    at Vector3.FromArrayToRef (math.vector.js:1723:1)
    at BoxParticleEmitter.parse (boxParticleEmitter.js:129:1)
    at ParticleSystem._Parse (particleSystem.js:2370:1)
    at ParticleSystem.Parse (particleSystem.js:2432:1)
    at ParticleSystem.clone (particleSystem.js:1846:1)
    at SubEmitter.clone (subEmitter.js:70:1)
    at index.tsx:309:1
    at Array.forEach (<anonymous>)
    at particleSystem.updateFunction (index.tsx:307:1)
    at ParticleSystem._update (particleSystem.js:1177:1)

I assume it’s because when parse the sub-emitter to clone it, use a default value, a box emitter, for custom emitter. And then parse failed.

                switch (parsedParticleSystem.particleEmitterType.type) {
                case "SphereParticleEmitter":
                    emitterType = new SphereParticleEmitter();
                // .......
                    emitterType = new BoxParticleEmitter();


What I want to achive is a custom shape of firework. So I want to define a shape in particleDestinationGenerator.

Or is there any good ways to achieve this? To make a sub-emitter’s particles to be a custom shape in the end time.(Or maintain the shape from the beginning, which is better). I have tried meshEmitter, but its effect is bad for non-sphere mesh, cause the particles would be divided from one surface to another. The shape of particle cannot maintain the mesh shape. Let’s say a box, the six surfaces’s particle are going to its own normal direction, and the size is not growing. So it would be like the box is divided into six faces and going far away. It’s not what I want: maintain the box shape.

Thans!!! Need help, plz!

Welcome aboard!

This PR will fix the bug:

1 Like