I built a SPS that is updatable and everything was fine. The resulting mesh included only my particles.
I then updated the code to make it immutable since I’m only moving the mesh and not the particles. So I did a pretty standard SPS build as below but now I’m stuck with the model mesh (theBox) included in the returned mesh from SPS.BuildMesh(). It’s easy to see since it’s sitting at coordinates 0,0,0 and white. When I move the returned mesh, check its bounding info or dispose of it, it’s quite clear that the model mesh is part of the returned mesh.
How can I get rid of that model mesh from the returned SPS.BuildMesh result?
// build the SPS
const SPS = new bjs.SolidParticleSystem(‘SPS’, scene, {updatable : false});
const theBox = bjs.MeshBuilder.CreateBox(“box”, { height: 1, width: 1, depth: 1 }, scene);
SPS.addShape(theBox, x, {positionFunction: myBuilder});
theBox.dispose()
const RowMesh = SPS.buildMesh(); // <- this return a mesh with my particles but also the model mesh
// builder function
const myBuilder = (particle: { color: bjs.Color4; position: { x: number; y: number; z: number }; scaling: bjs.Vector3; isVisible: boolean }, i: string | number, s: any) => {
particle.color = color;
particle.position.x = 50.5;
particle.position.y = intY;
particle.position.z = intZ;
particle.scaling = new bjs.Vector3(1, intHeight, 1);
}