Comments (7)
Hi @danrossi. VRController has no raycasting routines—that’s an additional layer for you (the developer) to add, tuned to your own needs. The DAT GUI (Data Arts Team Graphic User Interface) is one such additional layer that can do this. But if there’s a big want for this functionality to be merged into VRController that might be a fun thing to add.
In the meantime, here’s an example that uses a ton of raycasting to target objects: Space Rocks. Check out the Space Rocks repo. The way it works is that the controller fires plasma bolts and those bolts raycast to see if they are hitting something. Bolt.js line 79
is where the raycaster test takes place. If that plasma bolt hits a button then that button’s action gets executed.
You might also be interested in player.js
which is what interacts directly with VRController:
Line 516
: Listen for VRController to provide a link to the controller instance.
Line 668
: Check to see if the primary button (trigger) is being pressed.
Line 630
: Request the firing of a plasma bolt from the cannon. (It will fail if a bolt has been fired too recently. Right now I maintain at least 130ms between bolts—that just felt about right.)
And in Bolt.js
:
Line 52
: Apply the controller’s matrix to this bolt so it’s in the correct position, orientation, and scale, ie. emerging from your plasma cannon (the controller).
Line 62
: Set the bolt’s velocity such that it shoots in the correct direction.
from three.vrcontroller.
Ok thanks for that I tried to decipher what its doing but can't.
It doesn't need to be built in but on the example. I guess what is needed is a laser line or reticle that moves with the controller object. Which can be used for the Raycaster ? Much like the native controller in GearVR.
from three.vrcontroller.
I guess what I am talking about is a demo integration like the original controller in three.js. It uses a laser object to use as the RayCaster. I am just a little not sure how to replicate this controller over.
https://threejs.org/examples/#webvr_daydream
from three.vrcontroller.
Possibly ok to close unless a second demo is needed. I kind of have something to work with now. This laser line can be used for intersect. And I guess it will only intersect if the button is pressed.
var gamepadHelper = new THREE.Line( new THREE.BufferGeometry(), new THREE.LineBasicMaterial( { linewidth: 4 } ) );
gamepadHelper.geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 0, - 10 ], 3 ) );
controller.add(gamepadHelper);
This adds a line that extends the controller model. The line needs to thin out like the native one does, and it needs to change position when hitting an intersect object.
from three.vrcontroller.
Here is something on the lines I mentioned. The raycast is hitting just under the object however. I can get it to change colour on button press.
https://github.com/danrossi/THREE.VRController/blob/master/raycast.html
from three.vrcontroller.
I've updated the example to reposition the line distance to the intersect object. However it detects an intersect at an offset underneath the box. Any ideas what could cause this in the controller ? Is there an offset that needs to apply to the raycaster ?
If I direct the line to a region underneath the box it will detect a click and hit properly.
from three.vrcontroller.
Closing and starting again. I have the raycaster partially working but there is a problem.
from three.vrcontroller.
Related Issues (15)
- threejs r89 not support? HOT 13
- Issue when using with RayCaster HOT 2
- Controller mesh not "moving" with controller
- npm HOT 9
- GearVR / Daydream Gamepad not updated when exiting and entering presentation mode HOT 3
- Xbox ONE controller does not work HOT 2
- Controllers are invisible when I hold them close to my body. HOT 1
- Oculus Go: Controller moves when rotate head/glass HOT 2
- Scale user controller
- Event for original isPressed flag
- GearVR Controller Support? HOT 13
- Daydream - Camera on the floor HOT 8
- Motion controller device ID HOT 1
- NOLO VR HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from three.vrcontroller.