Hi,
I am facing raycast issue when the web application runs on landscape mode. Ray direction is incorrect.
mouse.x = ( e.touches[0].pageX / window.innerWidth ) * 2 - 1;
mouse.y = - ( e.touches[0].pageY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera);
Also tried the below methods,
-
mouse.x= ((e.touches[0].clientX - canvas.offsetLeft)/canvas.clientWidth) * 2 - 1;
mouse.y=-((e.touches[0].clientY - canvas.offsetTop)/canvas.clientHeight) * 2 + 1; -
var rect = renderer.domElement.getBoundingClientRect();
mouse.x = ( ( e.touches[0].clientX - rect.left ) / ( rect.right - rect.left ) ) * 2 - 1;
mouse.y = - ( ( e.touches[0].clientY - rect.top ) / ( rect.bottom - rect.top) ) * 2 + 1;
But in portrait mode the raycast works fine. Any suggestions/help is much appreciated.