3d-中旋转摄像机

50次阅读

共计 788 个字符,预计需要花费 2 分钟才能阅读完成。

// 旋转相机

rotateCamera (axis, speed, dt) {// var camera = viewer.getCamera()
    // var pivot = camera.pivot;
    // camera.target = pivot;
    // var target = camera.target
    // var dt = 1;
    // dt+=1;
    // var posx = target.x   +  1000*Math.cos(dt * 3.14 /180);
    // var posy = target.y   +  1000*Math.cos(1 * 3.14 /180);
    // camera.position.x = posx
    // camera.position.y = posy

    var nav = viewerAll.navigation;

    var up = nav.getCameraUpVector()

    var pos = nav.getPosition()

    var matrix = new THREE.Matrix4().makeRotationAxis(axis, speed * dt);
    // viewer.impl.invalidate (true)

    pos.applyMatrix4(matrix)
    up.applyMatrix4(matrix)

    nav.setView(pos, new THREE.Vector3(0,0,1))
    nav.setCameraUpVector(up)
}

runAnimation () {if(viewer.animateFlag){

        var dt = 0.01;
        dt+=0.01;
        var axis = new THREE.Vector3(0,0,1);
        viewer.vmethods.rotateCamera(axis, 10.0 * Math.PI/180, dt);
        window.requestAnimationFrame(viewer.vmethods.runAnimation);
    }

}1

正文完
 0