Hi folks,
I’m quite new to 3D stuff, and I’m having trouble on how to obtain the correct coordinates from a mouse click on the glb model my coworker gave me. (Here is my code on codesandbox)
The process I’ve done was:
- Load the model
- Add click event of getting the coordinates of the mouse click
- Get the click coordinates from
Raycaster.intersect()
. - Convert the coordinates through
intersectionPoint.applyMatrix4(object.matrixWorld)
But the coordinates I obtained in these small areas are the same, respectively. For example:
I obtained the same coordinates when clicking in Area A, and likewise, I obtained the same coordinates when clicking in Area B. The same applies to Area C.(But the coordinates I obtained from Area A/B/C are different).
I thought it was because I selected the wrong object to do the raycasting, but the situation didn’t change after I changed the
object
fromobject = gltf.scene
to
object = gltf.scene.getObjectByName('top_layer_t_fill') // or any other object name
Besides, regardless of the scale issue, the coordinates I obtained are totally different from the ones when the model in the simulation software(e.g HFSS)
Could anyone please give me some help?