The center of rotation is thrice.

I have 1 object on the scene and you want to rotate it about its axis. I am using THREE.TrackballControls. But when my object is not in the center of the screen, the rotation is bad (it rotates relative to the center of the screen). I tried to reposition the camera before creating the controls. But that did not work.

var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000); camera.position.z = 3; camera.position.y = 10; controls = new THREE.TrackballControls( camera ); 

Can I specify the center of rotation of the camera in TrackballControls? (Thus, the object will not rotate relative to the center of the scene)

Thanks, Zhenya

+4
source share
1 answer

TrackballControls rotates the camera, not the object.

You can set controls.target like this:

 controls.target.set( x, y, z ); 

three.js r.58

+5
source

Source: https://habr.com/ru/post/1483316/


All Articles