stewdio / THREE.VRController

Support hand controllers for Oculus, Vive, Windows Mixed Reality, Daydream, GearVR, and more by adding VRController to your existing Three.js-based WebVR project.
https://stewdio.github.io/THREE.VRController/
MIT License
230 stars 33 forks source link

Issue when using with RayCaster #12

Closed danrossi closed 6 years ago

danrossi commented 6 years ago

I have setup a basic example of using the controller with a RayCaster with a laser line pointer to click on intersected objects.

The intersect point is either above or below the object depending what version of three.js is used. I have integrated the standing matrix fix in r90. The intersect point is now above the object.

When testing against the daydream controller example in three.js the intersect is exact. There seems to be some offsetting and not sure how to remove it perhaps ?

http://dev.electroteque.org/vrcontroller/raycast.html http://dev.electroteque.org/vrcontroller/daydream.html

danrossi commented 6 years ago

I can confirm with both Daydream View and Occulus in Firefox and Chrome Canary doesn't support Occulus yet. The intersect is above. The controller movement and button press is working for both however.

Not sure how to go about getting controller models for them though ?

danrossi commented 6 years ago

After some back and forth with the vive example code. I needed to treat the raycaster differently using a world matrix instead. So has to be converted on each frame. Is there a better way at all ?

The intersect is correct now so not a problem with your code.

http://dev.electroteque.org/vrcontroller/raycast.html

The actual raycaster code required is

tempMatrix.identity().extractRotation( controller.matrixWorld );
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
raycaster.ray.direction.set( 0, 0, -1 ).applyMatrix4( tempMatrix );
return raycaster.intersectObjects( intersectedObjects );

instead of

raycaster.ray.origin.copy( controller.position );
raycaster.ray.direction.set( 0, 0, - 1 ).applyQuaternion( controller.quaternion );

Testing Daydream view and controller on S8 is unstable for now. sometimes the controller shows up and then other times it does not.