Hi all,
I tried a disappearing object effect like Sword Art Online.
(Click the torusKnot)
I have one issue. I would like to change other model but failed. The following example is changing from “CreateTorusKnot” to “CreateSphere”.
var model = BABYLON.MeshBuilder.CreateTorusKnot('s', {radius: 20, tube: 6, tubularSegments: 64, radialSegments: 128}, scene);
// var model = BABYLON.MeshBuilder.CreateSphere("sp",{diameter:30},scene);
The log was showed when I selected “CreateSphere”.
Uncaught TypeError: Cannot read properties of undefined (reading 'idx')
at scene.onPointerDown (<anonymous>:153:51)
at e._processPointerDown (babylon.js?t=1660635362986:sourcemap:1:464103)
at e._onPointerDown (babylon.js?t=1660635362986:sourcemap:1:471505)
at c.callback (babylon.js?t=1660635362986:sourcemap:1:473882)
at e.notifyObservers (babylon.js?t=1660635362986:sourcemap:1:64010)
at e._onInputChanged (babylon.js?t=1660635362986:sourcemap:1:458405)
at e.o [as _onInputChanged] (babylon.js?t=1660635362986:sourcemap:1:456094)
at HTMLCanvasElement._pointerDownEvent
I’m new to Solid Particle System. If someone knows the tips, I’m glad to hear that.
In this PG, when “var model” is “CreateTorusKnot” or “CreateShpere” in L54 or L55, “sps.digest(model, {facetNb: 4, delta: 40});” in L82 works well.
On the other hand, when “var model” is changed as any other glb models, the PG stops with the following error.
TypeError: Cannot read properties of undefined (reading 'getVerticesData')
at e.digest (solidParticleSystem.ts:346:42)
at createScene (<anonymous>:82:9)
at window.initFunction (<anonymous>:225:16)
“SPS.digest” are only valid for basic figure of Babylon.js like “CreateTorusKnot” or “CreateShpere”?
If you know some tips, it would be great useful for me.
Hi there! Digest is valid for all meshes, the main issue in your code is that you were trying to run before the model was loaded. I recommend using await to wait on the model being imported before running the rest of the function: Exploding Lofi Sphere | Babylon.js Playground (babylonjs.com). Another important thing to check too is that you are running digest into a single mesh, which is always true on the CreateXXX results, but not always on imported models. In my example, you can see that I first did some cleanup steps on the imported mesh before running digest:
a) Baked all the parents’ transforms in the mesh with bakeTransformIntoVertices.
b) Unparented the mesh from its parents.
If your imported model contains a lot of meshes, you might also need to merge these meshes into a single one.