Physics - CCD Motion Clamping pinball with enable3d (three+ammo) - now a progressive web app!

Hello, I’m using enable3d (threejs +ammo.js) New Physics Plugin for three.js (using ammo.js) from @yannick to build a pinball but i’m facing a little issue.

As you can see in the video, the ball sometimes pass through the bat.
I’ve read about CCD Motion Clamping to allow a more accurate detection of the collision but it even does not work as expected.

  • Should I apply ccd to both the ball & the bat ?
  • I think the object that as the highest velocity is the bat, but what parameter should I apply for the
    object.body.setCcdMotionThreshold(xxx) and object.body.setCcdSweptSphereRadius(xxx) given that the bat does not have a sphere shape ?

Here is the code I’m using flipball/loader_throw.js at 0810783e880a48bfb56130ff25822172236756c4 · scenaristeur/flipball · GitHub

Any help would be welcome. Thxs

enable3d threejs pinball - YouTube

Try if a higher subStep and TimeStep work:

new Project({ maxSubSteps: 10, fixedTimeStep: 1 / 240 })

Docs: enable3d • documentation

I guess it would be more efficient if the bat would be a compound shape of 2 cylinders and 2 boxes.

super @yannick
that sounds better, i will go plus loin and come back if i need . thxs

1 Like

@yannick sounds better even if sometimes the ball don’t use the expected way.
With GLTFLoaderto add cool parts & tubegeometry to add ramps enable3d is cool !

1 Like

it is now a Progressive Web App that you can play and install on your mobile.
please try it at flipball

  • on a computer, use arrows : right/left and down to throw the ball
  • on a smartphone, tap on top to throw the ball, right bottom and left bottom to use the flips

it is fully configurable for creating new tables in a config.js file flipball/config.json at 9dad137b60eba6749bc81bf2752e0ea9de053874 · scenaristeur/flipball · GitHub

@yannick : i’ve use @yandeu/tap and @yandeu/keyboard, but how could I prevent defaut unexpected behaviour of the tap or keyboard, that move the canvas or select text ?

Nice.

You mean orbitControls?
See enable3d • documentation

this.warpSpeed('-orbitControls')

No orbitcontrol don’t bother me for now.
See in the demo, when i long tap to move a flip, the ‘about’ text is selected. This is the default behaviour of a long touch on mobile but it is not relevant for the pinball.
Same on a compter, hitting arrow moves the canvas inside the browser window, so i would like to disable this defaut behavior. Does something like e.preventDefault exist with your tap & keyboard libs ?

With /tap you should be able to get the event. It doesn’t look like it is possible in /keyboard. Feel free to make a PR.