Three.js rotating a 3D object using mouse movement

Viewed 30

I'm trying to get a use mouse movement in my scene to rotate around the object. I don't want to use orbit controls (I want to rotate the object not the camera)

I can't figure out is how to make the movement smooth. here's the approach I went with

 window.addEventListener('mousemove', (e) =>{
        if (e.buttons === 1) {
             if (e.pageY < mY) {
              group.rotation.x -= 0.1
          } else if (e.pageY > mY) {
            group.rotation.x += 0.1
          }    
          else if (e.pageX < mX) {
            group.rotation.y -= 0.1
        } else if (e.pageX > mX) {
          group.rotation.y += 0.1
        } 
          mY = e.pageY;
          mX = e.pageX 
        } else return
      })
    }
    ```
0 Answers
Related