OrbitControl or TrackballControl

前端 未结 2 1213
忘掉有多难
忘掉有多难 2020-12-09 11:25

I\'ve read a lot about these 2 controls and currently I\'m using TrackballControls.

I need to rotate an object along all three axis (Both controls already do that),

2条回答
  •  青春惊慌失措
    2020-12-09 12:14

    First of all, TrackballControls and OrbitControls rotate the camera, not the objects.

    Second, OrbitControls enforces the camera up direction, and TrackballControls allows the camera to rotate upside-down.

    TrackballControls has a reset() method, which restores the target (center of rotation), camera position, and camera up vector to their original settings.

    controls.reset();
    

    The above code will restore the original position, target, and up vector. You can change those too, if you want, before you call controls.reset().

    controls.position0.set( 0, 0, 10 ); // set a new desired position
    controls.target0.set( 0, 0, 0 ); // set a new target
    controls.up0.set( 0, 1, 0 ); // set a new up vector
    controls.reset();
    

    Read the reset() function source code so you understand what it is doing.

    EDIT: OrbitControls now has a reset() method, too. Check the source code.

    three.js r.82

提交回复
热议问题