Previously I had created the raycasters like so:
raycaster = new THREE.Raycaster( new THREE.Vector3(), new THREE.Vector3( 0, - 1, 0 ), 0, 20 );
forwardRaycaster = new THREE.Raycaster( new THREE.Vector3(), new THREE.Vector3( 0, 0, -1 ), 0, 5 );
backwardRaycaster = new THREE.Raycaster( new THREE.Vector3(), new THREE.Vector3( 0, 0, 1 ), 0, 5 );
horizontalRaycaster = new THREE.Raycaster( new THREE.Vector3(), new THREE.Vector3( -1, 0, 0 ), 0, 5 );
rightHorizontalRaycaster = new THREE.Raycaster( new THREE.Vector3(), new THREE.Vector3( 1, 0, 0 ), 0, 5 );
One pointing in each direction and then doing this in my animate:
raycaster.ray.origin.copy( camera.position );
raycaster.ray.origin.y -= 10;
as my use case is camera collision (first person) i am getting a bit confused by the mouse input. I understand this is a x,y coord so I tried using x:0. y:0
to just use the center of the cameras view. Is “mouse” just named this way because it’s intended use case is raycasting to simulate mouse clicking/picking?
I changed my animate to do this instead:
forwardRaycaster.setFromCamera({x:0,y:0},camera);
forwardRaycaster.ray.origin.y -= 10;
But all four rays are facing the same direction. The direction input from when I created the raycasters is overwritten i guess?