Hi everyone!
I’ve been trying to gauge the distance between two points. As I googled it first I come up with this link.
[https://threejs.org/docs/#api/en/core/Raycaster]
However, I can only get X and Y coordinates but I also need to get Z since I try to calculate distances between 2 points in 3d model
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;
}
I tried to create a Vector3D object but still can’t manage to get the Z value since the event object does not have a function for getting the Z
I’d be so grateful if anyone could help me with the issue
This was exactly what I’ve been looking for . I was also thinkig to add a mesh at the endpoints of the line. This is a brilliant solution. I was thinking of getting to coordinates of 2 points and calculate it by myself but thats much better! Thanks a lot!
yo anybody got anything on how to make a basic camera movement based on both the “Sprite” mesh item’s movement (which I also need help with making it move with WASD) and the position of the mouse. Just like reply w/ instructions on how to make a locked mouse that can move around the camera. Basically I just need like a first person engine or smthn