Unexpected behavior of collision with instance

Hi, I’m facing a problem that I couldn’t find an answer to in the documentation and on google, the problem is the operation of collision in instances. On my scene there are meshes exported from blender and there are primitive boxes, collision on instances in primitive boxes works correctly, but on meshes from blender is not, by wrong work I mean the possibility to fall into the object and get stuck there and other strange behavior (at the same time if I copy this object everything works fine). I’m sorry but I can’t move everything to PG but here is a link to the repository Repo, files to study: main.ts, DungeonGenerator.ts.

There is i create instances of glb models:

For launch the project:

npm i
npm start

Behavior with instances:

Hi and welcome to the Community,

Looks like the collision is not enabled on the original mesh. Though, I’m not sure I fully understand the issue from just your writing. Ideally, you would disable the original mesh when working with instances.
Else, you need to make sure your original mesh also checks for collisions. You can make sure through the inspector. The other thing I’m unable to figure here with just this extract of your script, but might be of importance, is that collision occurs only on the front side of mesh/normals. You should check on that too.

Probably your occlusion check makes most of your meshes not enabled for collisions?

1 Like

collision is enabled for source mesh as you can see and i enabled it for each instance,
also i have disabled all occlusion for test but issue still here.


in case with barrel collision works fine when i just ran into it, when i jumped on barrel camera just stuck in it

Next thing is to check your ellipsoid size as described here - I then use movewithcollisions to implement collision detection and movement, but I found that when there is an object above the move, I cannot move to the specified area - #4 by carolhmj

I have created sphere for each object and it looks good to me, torch example:
Screenshot from 2023-12-16 16-31-52

What worries me more is that the camera gets stuck in the mesh or even falls down to the floor

Nice dungeon, by the way :slight_smile:
When I put this snippet into your code:

scene.meshes.forEach((element: Mesh) => {
  if (!element.checkCollisions) {

I’ve got the next results:
Check if those meshes (which have checkCollisions = false) are responsible for falling down.
As for camera stuck my guess it is related to bounding boxes size but I need to check if that is true.

1 Like

Is your barrel a single mesh or an assembly? Could it be that normals are inverted on your top mesh of barrel? Or that you inverted the z-axis if it is an instance? I think without a PG we can only make assumptions. The boundingBox thingy mentioned by @labris could also be relevant. Hard to say without a PG.

There is the repo exist - GitHub - ZGltYQ/Dungeon

Sure, but you know I’m the lazy type :grin: not sure I have the time to dig into this :hourglass_flowing_sand:
I have an hour left to take a shower and move myself to this dinner I’ve been invited to :yum: :sweat_smile: So I guess I will let you just take over… You’re better than me at it anyways :wink: :grin:

Thanks :grinning:
I added an onCollide event for the camera and a logged a mesh of the barrel I jumped onto.

Screenshot from 2023-12-16 18-58-22

Screenshot from 2023-12-16 18-57-38

There are any properties i must takes into ?

  1. barrel is single mesh
  2. if the normals were inverted, then the barrel would behave incorrectly even during cloning, wouldn’t it?

I will try to create a PG :slight_smile:

You were right all my headache because of inverted normals, by the way, there is strange behavior, the normals become inverted after creating an instance. Therefore, I create the source mesh with inverted normals like this:

and after creating instance normals become in right direction

Seems the other way is to use negative scaling (I believe this is because you use right-handed system)

like here - so you will not stuck in barrels anymore :slight_smile:

          const decorMesh = decoration.mesh.createInstance(decoration?.name);

          if ((decorMesh.name = "barrel")) {
            decorMesh.scaling.set(1, -1, 1);