Hey,
I am using the model found in this link.
https://threejs.org/examples/#webgl_animation_skinning_additive_blending
const loader = new GLTFLoader();
loader.load( '../model/Xbot.glb', function ( gltf ) {
model = gltf.scene;
scene.add(model);
skeleton = new THREE.SkeletonHelper( model );
skeleton.visible = true;
scene.add(skeleton);
renderer.render(scene, camera);
animate();
} );
I am calling this model in my code by downloading it and rendering it.
The model displays fine. I am trying to get the location of the point where the user clicks the skinned mesh model and generate a sphere there. I have tried using raycasting but since the model is of type skinned mesh it’s hard to get the exact mouse location. Thanks!
EDIT:
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
const intersects = raycaster.intersectObjects(scene.children);
for ( let i = 0; i < intersects.length; i ++ ) {
console.log(intersects[i].object);
}
This is the code I used for raycasting. On clicking on the skeleton model, it returns the skeleton helper object (whose position is 0,0,0) but not the exact coordinates of the point clicked.
Thanks!