cesium鼠標事件


globe.js
實例化
function Globe() { } var viewer Globe.prototype.Init = function () { viewer = new Cesium.Viewer("cesiumContainer", { timeline: false,//時間軸 animation: false,//動畫控制器 allowDataSourcesToSuspendAnimation: true, resolutionScale: 2, infoBox: false, targetFrameRate: 120, shadows: true, shouldAnimate: true, }); }

helloworld.html

// 鼠標事件 var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas); //實例化對象的setInputAction方法 handler.setInputAction(function (event) { var earthPosition = viewer.camera.pickEllipsoid(event.position, viewer.scene.globe.ellipsoid); //可以拿到笛卡爾3d坐標系 console.log(earthPosition); //可以得到笛卡爾平面坐標系 }, Cesium.ScreenSpaceEventType.LEFT_CLICK); //鼠標左鍵
//鼠標右鍵 handler.setInputAction(function (event) { var earthPosition = viewer.camera.pickEllipsoid(event.position, viewer.scene.globe.ellipsoid); //可以拿到笛卡爾3d坐標系 console.log(earthPosition); //可以得到笛卡爾平面坐標系 }, Cesium.ScreenSpaceEventType.RIGHT_CLICK); //鼠標右鍵
其他鼠標事件

  • 鼠標左鍵雙擊事件 Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
  • 鼠標左鍵按下事件 Cesium.ScreenSpaceEventType.LEFT_DOWN
  • 鼠標左鍵抬起事件 Cesium.ScreenSpaceEventType.LEFT_UP
  • 鼠標中鍵單擊事件 Cesium.ScreenSpaceEventType.MIDDLE_CLICK
  • 鼠標中鍵按下事件 Cesium.ScreenSpaceEventType.MIDDLE_DOWN
  • 鼠標中鍵抬起事件 Cesium.ScreenSpaceEventType.MIDDLE_UP
  • 鼠標移動事件 Cesium.ScreenSpaceEventType.MOUSE_MOVE
  • 觸摸表面上的雙指事件的結束 Cesium.ScreenSpaceEventType.PINCH_END
  • 觸摸表面上雙指移動事件 Cesium.ScreenSpaceEventType.PINCH_MOVE
  • 觸摸表面上雙指事件的開始 Cesium.ScreenSpaceEventType.PINCH_START
  • 鼠標右鍵單擊事件 Cesium.ScreenSpaceEventType.RIGHT_CLICK
  • 鼠標右鍵按下事件 Cesium.ScreenSpaceEventType.RIGHT_DOWN
  • 鼠標滾輪事件 Cesium.ScreenSpaceEventType.WHEEL


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM