Click and drag to rotate object using controller?

Hi everyone, I have a project were I’d like to use my oculus controllers to press and drag to rotate an object I have. An example behavior would be this, but instead of a mouse click it would be a vr controller event. Mouses have a helpful ‘mousemove’ event, but I don’t see an equivalent event for the controllers. I haven’t had much luck working with the ‘selectstart’ controller event.

Does anyone know of similar projects or have any ideas to accomplish this? Thanks!

I think you have to calculate the distance the controller moved since it was clicked.
There is a selectstart and selectend event for vr controllers.
On selectstart, you have to store the controller position. You could use the animationFrame to check how much the controller moved since selectstart, if selectend was not triggered yet (while its still pressed).

If anyone in the future sees this post, this is essentially what worked for me

   function onSelectStart( event ) {

    start_x = controller1.rotation.x;
    start_y = controller1.rotation.y;
    rotate_canopy = 1;


function animate(){

    renderer.setAnimationLoop( () => {

        if(rotate_canopy > 0){
            start_x_r = start_x - controller1.rotation.x
            start_y_r = start_y - controller1.rotation.y
            myPivot.rotation.x += start_x_r * .4;   //the object I'm rotating
            myPivot.rotation.y += start_y_r * .4;
            start_x = controller1.rotation.x
            start_y = controller1.rotation.y
        renderer.render( scene, camera );

1 Like