Rotate camera in Three.js with mouse

前端 未结 5 1725
心在旅途
心在旅途 2020-12-04 07:09

I have quite a few objects in my scene so rotating all of them could be a pain. So what is the most easy way to move camera around origin on mouse click and drag? This way a

5条回答
  •  盖世英雄少女心
    2020-12-04 07:49

    take a look at the following examples

    http://threejs.org/examples/#misc_controls_orbit

    http://threejs.org/examples/#misc_controls_trackball

    there are other examples for different mouse controls, but both of these allow the camera to rotate around a point and zoom in and out with the mouse wheel, the main difference is OrbitControls enforces the camera up direction, and TrackballControls allows the camera to rotate upside-down.

    All you have to do is include the controls in your html document

    
    

    and include this line in your source

    controls = new THREE.OrbitControls( camera, renderer.domElement );
    

提交回复
热议问题