This problem bothered me for a long time. I used MergedMesh ThinInstance and Mesh ThinInstance to display the model information. The Mesh Thin Instance has no problem when picking, but the Merged Mesh Thin Instance always fails to pick up when picking. I know thinInstanceEnablePicking attributes, but it doesn’t work. I uploaded a PG, the basic logic is the same as the local code, the PG works.
Then, debugging Babylonjs source code locally, I discovered a mystery. The world is global. I don’t understand the origin coordinates of the ray generated according to the world. Then the ray is used for the intersection test with the mesh, but the origin of this ray is definitely disjoint with the mesh. I think this problem should cause the merged mesh ThinInstance to fail to pick up.
MergedMesh are at the world origin, and the coordinates in mergedMesh thinInstance matrix are world coordinates too.
Is there anything you can do to help me, or help me find out what the problem is?
I debug ThinInstanceMesh, world and ray.origin are fine. The MergedMesh gltf that doesn’t work is the GLTF I used in PG.
Do you mean you are using locally the same code than in the PG, and that it works in the PG but not locally?
I’m afraid it will be difficult to help if we don’t have a repro which does not work, as I’m not sure why the code of the PG would not work for you.
The other difference is that the local version is 6.24.0 and the PG version is 6.27.1. But I don’t see any updates for thinInstance.
Let me debug it again and see if I can figure out the problem.
It might also be related to the import setup? cc @RaananW in case it rings a bell
Probably not. I imported it using
import * as BABYLON from '@babylonjs/core'.
can you share the project itself? if the playground is working it’s (probably?) something in the way the project consumes babylon, but of course nothing is certain until we are able to debug this together with you
@Evgeni_Popov @RaananW @carolhmj Haha, after my investigation, I reproduced the local code problem on PG.
The MergedMesh is located at
(0,0,0) but the internal ThinInstance can’t be picked up if it’s located far away.
It seems like multimaterials (or multiple submeshes) is responsible for this:
植被散布和设备安装工具无法对MergedMesh进行操作 | Babylon.js Playground (babylonjs.com)
We will need to investigate this and see what happens.