简体   繁体   中英

How can I set/remove element's parent on gripup/gripdown Vive controller events in A-Frame?

Using the Vive controllers, I want to be able to trigger-click-and-hold on an object in my A-Frame scene, and be able to then move and rotate that object in the space of the VR scene, by moving the controller in space.

One way I can think of doing this is: on trigger pull, to make the object a child of the controller, so it inherits position and rotation from the controller.

In Three.js, I could use:

THREE.SceneUtils.detach( child, parent, scene ); THREE.SceneUtils.attach( child, scene, parent ) THREE.SceneUtils.detach( child, parent, scene ); THREE.SceneUtils.attach( child, scene, parent ) ;

How can I set/remove parent on gripup/gripdown events in A-Frame?

One of the A-Frame examples does what you describe, actually.

Here's the scene index.html , grab component , and a demo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM