Hi Guys,
saw this post from Michael on stackoverflow ,
html - How would I be able to get my GLTF object follow someone using touch on a phone? - Stack Overflow,
great with mouse move on canvas , i am trying to get the mouse move on the gltf object , and when it is on the gltf object not the canvas, translate rotate the object with mouse move
i followed the below document on raycasting on three with the gltf object , did not work ,
if i get this working i can get on with my application , any help an example would be greatly appreciated ,
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
function onMouseMove( event ) {
// calculate mouse position in normalized device coordinates
// (-1 to +1) for both components
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
}
function render() {
// update the picking ray with the camera and mouse position
raycaster.setFromCamera( mouse, camera );
// calculate objects intersecting the picking ray
const intersects = raycaster.intersectObjects( scene.children );
for ( let i = 0; i < intersects.length; i ++ ) {
intersects[ i ].object.material.color.set( 0xff0000 );
}
renderer.render( scene, camera );
}
window.addEventListener( 'mousemove', onMouseMove, false );
window.requestAnimationFrame(render);