Cesium 禁止相机进入地底下[转]

原文:https://blog.csdn.net/thor027/article/details/82455649 

viewer.clock.onTick.addEventListener(function () {        
        if(viewer.camera.pitch > 0){
            viewer.scene.screenSpaceCameraController.enableTilt = false;
        }
    }); 
    
    var mousePosition,startMousePosition;
    var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
    handler.setInputAction(function(movement) { 
        mousePosition=startMousePosition= Cesium.Cartesian3.clone(movement.position);
        handler.setInputAction(function(movement) {
            mousePosition = movement.endPosition;
            var y = mousePosition.y - startMousePosition.y;
            if(y>0){
                viewer.scene.screenSpaceCameraController.enableTilt = true;
            }
        }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
    }, Cesium.ScreenSpaceEventType.MIDDLE_DOWN);

posted on 2019-06-01 10:44  3D入魔  阅读(1415)  评论(0编辑  收藏  举报