乐趣区

3d-中旋转摄像机

// 旋转相机

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
退出移动版