Giter Club home page Giter Club logo

Comments (7)

stewdio avatar stewdio commented on May 21, 2024

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.

danrossi avatar danrossi commented on May 21, 2024

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.

danrossi avatar danrossi commented on May 21, 2024

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.

danrossi avatar danrossi commented on May 21, 2024

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.

danrossi avatar danrossi commented on May 21, 2024

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.

danrossi avatar danrossi commented on May 21, 2024

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.

danrossi avatar danrossi commented on May 21, 2024

Closing and starting again. I have the raycaster partially working but there is a problem.

from three.vrcontroller.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.