How to change models for disappearing effects

Hi all,
I tried a disappearing object effect like Sword Art Online.

111

(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.

Thanks for your supporting.

The line mentioned in the error log is:
image

Have you checked the value of sps.pickedParticles?

Thanks for your comment.
I’m checking my code again. The two examples are just under construction but it may give me some hints.

Loaded basic sphere

Loaded other mesh (Loading result is wrong)

I’ll continue to search for the cause.

Hello @Limes2018 just checking in if you need any more help?

Hello @carolhmj

Thanks for your kind reply and deeply sorry for my delay.

I’m still having the issue but I can’t save my free time due to my main job’s burden and leading Babylon.js recipe book Vol.1 as an editing leader.

To tell the truth, I want to tackling the issue again ASAP. I’d be very happy if you can help me when I try it again.

I will be here once you’re able to :smiley:

1 Like

@carolhmj

Hello!
Sorry for my long absence. I finally re-try the issue.

I checked my past trial and found other issue.

Failed_Diminishing virtual objects as fragments | Babylon.js Playground (babylonjs.com)

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.

Thanks for your kindly cooperation.

1 Like

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.

4 Likes

Hi @carolhmj,

Thanks for rapid and very kind reply. I could understand clearly.

My short trial still failed but I guess my code in the PG " Failed_Diminishing virtual objects as fragments | Babylon.js Playground (babylonjs.com)" is so messy.

I’ll try it based on your PG tomorrow. (I should make me cool because now is midnight in Japan)

Thanks again!!

1 Like

@carolhmj

I finally could do it! Any other model is diminished with SAO effects!

111

I’ll try it based on your PG tomorrow. (I should make me cool because now is midnight in Japan)

As I said by myself, it is not difficult to make it after cooling down :slight_smile:

Let me share my updated PG. Thanks again and again!

SAO effect v2 | Babylon.js Playground (babylonjs.com)

4 Likes

It looks AWESOME! :heart_eyes:

1 Like

Thanks for sharing. This explosion fx is mind blowing :grinning: I luv it. :smiley:

2 Likes

Looks amazing !!!

1 Like

Let me share further update.

SciFi simple shooting and SAO effects | Babylon.js Playground (babylonjs.com)
222

3 Likes

Looking great!

1 Like