I am implementing rotation functionality to models added to the scene in ar (webxr) , currently I implement it only on the recently added model but I want to let user do it with any model present so I need to select the tapped model(I use touchstart event for this) , I use raycaster and check if intersection to object but it not works , do I need to update camera ? or what , here is the code:
// loc is vec2d , I add rotation to model in rotatemodel
renderer.domElement.addEventListener('touchstart',function(e){
e.preventDefault();
touchDown=true;
touchX = e.touches[0].pageX;
touchY = e.touches[0].pageY;
loc.x = touchX ;
loc.y = - touchY;
raycaster.setFromCamera( loc , camera );
const intersects = raycaster.intersectObjects( scene.children );
if ( intersects.length > 0 ) {
if ( rotatemodel != intersects[ 0 ].object ) {
rotatemodel = intersects[ 0 ].object;
}
}
},false)