详细步骤都在注释里,不过多赘述了。
/*** @param {Object} position - Cartesian3坐标* @return {Boolean} 是否在视口中*/
function isPositionInViewport(position) {// 获取当前视口范围let viewport = viewer.camera.computeViewRectangle();// 2D模式下拾取不到坐标,viewport返回undefinedif (typeof viewport === 'undefined') {// 获取画布对象let canvas = viewer.scene.canvas;