Mesh intersection trigger accuracy

Hi folks,

I have created a disc primitive like so:

const s = new Mesh.CreateDisc(
  `Step_${step[2]}`, step[0], step[1], this._scene, false, true

I’m attempting to use the action manager of a moving mesh to collide (intersect) with the mesh like so:

  new ExecuteCodeAction(
      trigger: ActionManager.OnIntersectionEnterTrigger,
      parameter: {
        mesh: this._steps[i],
        usePreciseIntersection: true
    () => {
      console.log("IN", this._steps[i].name.split('_')[1]);

This works well however the moving mesh is triggered by the bounding box and not the mesh itself. I assumed that the usePreciseIntersection would solve this but that’s not the case.

What would be a more correct way of detecting this sort of collision? I don’t want to block collision movement using checkCollision. My interaction is more nuanced and I’m already using that form of detection for boundaries.


@dbase Can you try usePreciseIntersection: false and let me know ??? I can almost certainly see a bug here but would like confirmation… :frowning:

Nope neither true or false seem to work. I forgot to mention my dependency list btw. Here it is:

"dependencies": {
  "@babylonjs/core": "^5.0.0-alpha.31",
  "@babylonjs/gui": "^5.0.0-alpha.31",
  "@babylonjs/loaders": "^5.0.0-alpha.31",
  "@babylonjs/materials": "^5.0.0-alpha.31"

Could you create a repro in the playground? This would help a lot

Even if it only contains a disc and another mesh, at least it would speed up our investigation

Hey! Thanks for getting back so quick. I’m caught up in my day and started through the process of recreating something similar to my setup. In my case sphere is actually a base gltf mesh. I also had some errors setting it up in playground and ran out of time debugging/completing it. Here’s as far as I got:

Sorry for the half-assed nature of it. The idea was that I was going to animate the sphere moving into the bounding box of the disc and have it change its visibility or change the texture colour on the sphere. I’m not sure if this gets you any closer!

The playground is throwing an exception, would be great if you could isolate the disc and the sphere indeed :slight_smile:

Ok I double checked and precision is working correctly, basically precise means that the bounding box is not necessarily Axis Aligned: Mesh Intersections | Babylon.js Documentation

This will still not trigger mesh to mesh intersection which would cost a lot.

This could be of interest Precise mesh intersection detection - #4 by Raggar

1 Like

HI Sabavan, so sorry about that. I was under a great amount of stress to get a delivery out. Sorry I wasn’t more helpful. Here’s a link to our prototype: Boehringer Stage once loaded click “customize” and then “follow” you can then move the character around the mainland.

Screen Shot 2021-07-16 at 9.56.21 AM

If you angle the avatar to the edge of the floating white disc you’ll see it intersects at the edge. I suppose this is what you’re referring to as being axis aligned. I’ll have to investigate a different method.

Here’s a better question though: we were going to use these sort of primitive collisions to determine the avatars y coordinate. This ensures that they are scaling the grand. Both the mainland environment and avatar are both gLTF models.

Is there a better way to introduce ramps/stairs in this case?

We’re not using any scene gravity controls as I wan’t sure how that would play out with gltf models.

In your case, ray casting down to find the closest ground would be good I guess and for object collision you could have a look at this one: Camera Collisions | Babylon.js Documentation

and by the way I love the website :slight_smile: