Build a high tower made of balls / physics engine

Deltakosh Perfect! and what about dispose? I tried the same as clone but it didn’t work.

can you share your try?

@Deltakosh https://www.babylonjs-playground.com/#773IB4#2

You cannot dispose the source sphere but the clones. You have to store them and then dispose the one you want from the stored list

@Deltakosh Still the ‘dispose’ function doesn’t work https://www.babylonjs-playground.com/#W2LT9M (changment line 92). I am sure my mistake is how to store the clones, I have no idea about that! Could you please check it again, how to dispose the mesh by updating the value of the slider?

I won’t fix it for you because I’m under the impression that you need to learn JS a bit :slight_smile:
But here are some hints:

  • What is sphere.clones? who created it? are you sure that object really exists?
  • Your clones are already stored here: layer._index.push( _this.createSphere(x, y + _this._index.length + _this._yOffset, z) );
1 Like

hhehe, yea exactly what I am doing! anyway thank you. And it was already there the solution I just forgot to add “return” :frowning: now everything is working https://www.babylonjs-playground.com/#W2LT9M#2

1 Like

Congrats!!

In the accepted answer, how do you manage to keep the tower from falling over? The spheres don’t seem to slide on top of each other at all, despite the fact that physics is enabled.

Hi @azariel, welcome to the forum.

Let’s look at another playground.

https://www.babylonjs-playground.com/#ILMZVW#14 (bounce/restitution set at line 50 - as needed)

The reason they don’t slide/tip-over… is because they are mathematically PERFECTLY centered.

A “balanced” diet. heh.

After finished playing, activate line 47. It causes a VERY VERY TINY random re-position… slightly off-center. RUN again. As you can see, it falls apart quickly.

Amazing, eh? I agree. The authors of the physics engines… made them very precise… almost beyond our imagination/conception. Physics engines are cool, huh? HOT HOT HOT for the future of 3D.

I wish BJS team cared more about them, and put higher priority in physics demos and docs… but… not happening. Not much physics teaching/testing is being done… even from the third-party physics engine authors. Sad. Physics engines are actually feared… by beginner and intermediate-level webGL users. Not good. But teaching all aspects of physics engines… is a HUGE task. The same amount of fear is prevelant… for teaching or using.

Some of our very best physics Gods… have drifted-off… Temechon, SamG, RaananW, Raggar, others. I think they went insane from all the physics questions/problems. Thank goodness Cedric is still here… but I don’t know how long Cedric can maintain his physics sanity. :slight_smile: cedricImpostor.setMass(0) … keep him on Earth/floor, not moving/drifting. heh.

Wouldn’t it be nice… if the heavily-used physics engines/interfaces… got as much attention as the rarely-used node material editor? (ahem)

Warning: Folks, you should NOT try to stack real-life bowling balls… 20+ tall. Likely dangerous. :smiley:

2 Likes

It seems that someone tried/succeeded adding show physics impostors feature to BabylonJS Inspector app (available in playground by default). In a quick tour of the playground inspector for above playground… I couldn’t find it, and a ground1 HELPERS-tab slider-switch labeled “physics”… seemed to do nothing… when switched.

ShowImpostors is one thing… but showJoints would be completely marvelous! VERY difficult, though. It comes with showMotors and showSprings… it gets ugly… quickly. The method used for drawing the impostors and joints… has to be very fast, because at scene-start, a thousand physics movements can begin and continue… and the showImpostors and showJoints graphics-updating… would be intense.

Hardware level? OS-based? I dunno. I’m just yacking… trying to fig a better physics-learning system.