# How to change models for disappearing effects

**URL:** <https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114>\
**Category:** Questions\
**Created:** [August 17, 2022, 5:31am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114 "2022-08-17T05:31:29Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [August 17, 2022, 5:31am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/1 "2022-08-17T05:31:30Z")

</div>

Hi all,  
I tried a disappearing object effect like [Sword Art Online](https://en.wikipedia.org/wiki/Sword_Art_Online).

![111](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/d/fd6f12facb11b2035a76ff5bab81445af698f11b.gif)

> **[Babylon.js Playground](https://playground.babylonjs.com/#XU5JER%2312)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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

```nohighlight
 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”.

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [August 17, 2022, 11:07am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/2 "2022-08-17T11:07:44Z")

</div>

The line mentioned in the error log is:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/5/256060bf607f5a3ffbfbd7d7e0b8197891db2a6a.png)

Have you checked the value of sps.pickedParticles?

---

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [August 17, 2022, 11:57am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/3 "2022-08-17T11:57:25Z")

</div>

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#XU5JER%2315)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Loaded other mesh (Loading result is wrong)

> **[Babylon.js Playground](https://playground.babylonjs.com/#XU5JER%2316)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

I’ll continue to search for the cause.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [September 15, 2022, 12:55pm UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/4 "2022-09-15T12:55:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [September 18, 2022, 7:22am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/5 "2022-09-18T07:22:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [September 19, 2022, 11:58am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/6 "2022-09-19T11:58:11Z")

</div>

I will be here once you’re able to 😃

---

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [November 3, 2022, 1:36am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/7 "2022-11-03T01:36:06Z")

</div>

@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)](https://playground.babylonjs.com/#XU5JER#18)

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.

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [November 3, 2022, 2:12pm UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/8 "2022-11-03T14:12:30Z")

</div>

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)](https://playground.babylonjs.com/#HDHQN#71). 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.

---

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [November 3, 2022, 2:41pm UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/9 "2022-11-03T14:41:50Z")

</div>

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)](https://playground.babylonjs.com/#XU5JER#18)" 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!!

---

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [November 6, 2022, 9:02am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/10 "2022-11-06T09:02:57Z")

</div>

@carolhmj

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

![111](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/d/cd706a86eee46c5b0c9b2f84cc4c93cae6f243bd.gif)

> 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 🙂

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

[SAO effect v2 | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#HDHQN#73)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [November 7, 2022, 10:27am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/11 "2022-11-07T10:27:30Z")

</div>

It looks AWESOME! 😍

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [November 7, 2022, 12:35pm UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/12 "2022-11-07T12:35:32Z")

</div>

Thanks for sharing. This explosion fx is mind blowing 😀 I luv it. 😃

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 7, 2022, 2:49pm UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/13 "2022-11-07T14:49:32Z")

</div>

Looks amazing !!!

---

<div class="post-metadata">

**Author:** ![Limes2018](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/limes2018/32/24184_2.png) [@Limes2018](https://forum.babylonjs.com/u/Limes2018)\
**Post date:** [November 13, 2022, 10:18pm UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/14 "2022-11-13T22:18:22Z")

</div>

Let me share further update.

[SciFi simple shooting and SAO effects | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#M9VSTJ#12)  
 ![222](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/1/d1d4c2284b050ad71f5b146a7a7595b6a0c99aa5.gif)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 1, 2022, 11:32am UTC](https://forum.babylonjs.com/t/how-to-change-models-for-disappearing-effects/33114/15 "2022-12-01T11:32:59Z")

</div>

Looking great!
