@xeokit/xeokit-sdk 2.6.26 → 2.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +74 -83
- package/dist/xeokit-sdk.es.js +74 -83
- package/dist/xeokit-sdk.es5.js +39 -30
- package/dist/xeokit-sdk.min.cjs.js +3 -3
- package/dist/xeokit-sdk.min.es.js +3 -3
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +1 -1
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +10 -10
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +1 -1
- package/src/plugins/ZonesPlugin/index.js +3 -3
- package/src/plugins/lib/ui/index.js +1 -1
- package/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +2 -3
- package/src/viewer/scene/math/math.js +29 -34
- package/src/viewer/scene/mesh/Mesh.js +4 -4
- package/src/viewer/scene/scene/Scene.js +2 -18
- package/src/viewer/scene/webgl/Renderer.js +21 -8
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurement.d.ts +14 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +13 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.d.ts +15 -0
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -1417,13 +1417,14 @@ var precision=Math.pow(10,precisionPoints);var posi;var i;var j;var len;var a;va
|
|
|
1417
1417
|
@static
|
|
1418
1418
|
@param {Number[]} viewMatrix View matrix
|
|
1419
1419
|
@param {Number[]} projMatrix Projection matrix
|
|
1420
|
+
@param {String} projection Projection type (e.g. "ortho")
|
|
1420
1421
|
@param {Number[]} canvasPos The Canvas-space position.
|
|
1421
1422
|
@param {Number[]} worldRayOrigin The World-space ray origin.
|
|
1422
1423
|
@param {Number[]} worldRayDir The World-space ray direction.
|
|
1423
|
-
*/canvasPosToWorldRay:function(){var
|
|
1424
|
+
*/canvasPosToWorldRay:function(){var pvMatInv=new FloatArrayType(16);var vec4Near=new FloatArrayType(4);var vec4Far=new FloatArrayType(4);var clipToWorld=function clipToWorld(clipX,clipY,clipZ,isOrtho,outVec4){outVec4[0]=clipX;outVec4[1]=clipY;outVec4[2]=clipZ;outVec4[3]=1;math.transformVec4(pvMatInv,outVec4,outVec4);if(!isOrtho)math.mulVec4Scalar(outVec4,1/outVec4[3]);};return function(canvas,viewMatrix,projMatrix,projection,canvasPos,worldRayOrigin,worldRayDir){var isOrtho=projection==="ortho";math.mulMat4(projMatrix,viewMatrix,pvMatInv);math.inverseMat4(pvMatInv,pvMatInv);// Calculate clip space coordinates, which will be in range
|
|
1424
1425
|
// of x=[-1..1] and y=[-1..1], with y=(+1) at top
|
|
1425
|
-
var
|
|
1426
|
-
var clipY
|
|
1426
|
+
var clipX=2*canvasPos[0]/canvas.width-1;// Calculate clip space coordinates
|
|
1427
|
+
var clipY=1-2*canvasPos[1]/canvas.height;clipToWorld(clipX,clipY,-1,isOrtho,vec4Near);clipToWorld(clipX,clipY,1,isOrtho,vec4Far);worldRayOrigin[0]=vec4Near[0];worldRayOrigin[1]=vec4Near[1];worldRayOrigin[2]=vec4Near[2];math.subVec3(vec4Far,vec4Near,worldRayDir);math.normalizeVec3(worldRayDir);};}(),/**
|
|
1427
1428
|
Transforms a Canvas-space position to a Mesh's Local-space coordinate system, in the context of a Camera.
|
|
1428
1429
|
@method canvasPosToLocalRay
|
|
1429
1430
|
@static
|
|
@@ -1435,7 +1436,7 @@ var clipY=-(canvasPos[1]-canvasHeight/2)/(canvasHeight/2);tempVec4a[0]=clipX;tem
|
|
|
1435
1436
|
@param {Number[]} canvasPos The Canvas-space position.
|
|
1436
1437
|
@param {Number[]} localRayOrigin The Local-space ray origin.
|
|
1437
1438
|
@param {Number[]} localRayDir The Local-space ray direction.
|
|
1438
|
-
*/canvasPosToLocalRay:function(){var worldRayOrigin=new FloatArrayType(3);var worldRayDir=new FloatArrayType(3);return function(canvas,viewMatrix,projMatrix,worldMatrix,canvasPos,localRayOrigin,localRayDir){math.canvasPosToWorldRay(canvas,viewMatrix,projMatrix,canvasPos,worldRayOrigin,worldRayDir);math.worldRayToLocalRay(worldMatrix,worldRayOrigin,worldRayDir,localRayOrigin,localRayDir);};}(),/**
|
|
1439
|
+
*/canvasPosToLocalRay:function(){var worldRayOrigin=new FloatArrayType(3);var worldRayDir=new FloatArrayType(3);return function(canvas,viewMatrix,projMatrix,projection,worldMatrix,canvasPos,localRayOrigin,localRayDir){math.canvasPosToWorldRay(canvas,viewMatrix,projMatrix,projection,canvasPos,worldRayOrigin,worldRayDir);math.worldRayToLocalRay(worldMatrix,worldRayOrigin,worldRayDir,localRayOrigin,localRayDir);};}(),/**
|
|
1439
1440
|
Transforms a ray from World-space to a Mesh's Local-space coordinate system.
|
|
1440
1441
|
@method worldRayToLocalRay
|
|
1441
1442
|
@static
|
|
@@ -2756,7 +2757,7 @@ _this15._onEntityModelDestroyed=null;});}else{this._onEntityDestroyed=this._enti
|
|
|
2756
2757
|
* @final
|
|
2757
2758
|
*/},{key:"visible",get:function get(){return!!this._visible;}/**
|
|
2758
2759
|
* Destroys this Marker.
|
|
2759
|
-
*/},{key:"destroy",value:function destroy(){this.fire("destroyed",true);this.scene.camera.off(this._onCameraViewMatrix);this.scene.camera.off(this._onCameraProjMatrix);if(this._entity){if(this._onEntityDestroyed!==null){this._entity.model.off(this._onEntityDestroyed);}if(this._onEntityModelDestroyed!==null){this._entity.model.off(this._onEntityModelDestroyed);}}this._renderer.removeMarker(this);_get(_getPrototypeOf(Marker.prototype),"destroy",this).call(this);}}]);return Marker;}(Component);var nop=function nop(){};function transformToNode(from,to,vec){var fromRec=from.getBoundingClientRect();var toRec=to.getBoundingClientRect();vec[0]+=fromRec.left-toRec.left;vec[1]+=fromRec.top-toRec.top;}var Dot3D=/*#__PURE__*/function(_Marker){_inherits(Dot3D,_Marker);var _super5=_createSuper(Dot3D);function Dot3D(scene,markerCfg,parentElement){var _this16;var cfg=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};_classCallCheck(this,Dot3D);_this16=_super5.call(this,scene,markerCfg);var handler=function handler(cfgEvent,componentEvent){return function(event){if(cfgEvent){cfgEvent(event);}_this16.fire(componentEvent,event,true);};};_this16._dot=new Dot(parentElement,{fillColor:cfg.fillColor,zIndex:cfg.zIndex,onMouseOver:handler(cfg.onMouseOver,"mouseover"),onMouseLeave:handler(cfg.onMouseLeave,"mouseleave"),onMouseWheel:handler(cfg.onMouseWheel,"wheel"),onMouseDown:handler(cfg.onMouseDown,"mousedown"),onMouseUp:handler(cfg.onMouseUp,"mouseup"),onMouseMove:handler(cfg.onMouseMove,"mousemove"),onTouchstart:handler(cfg.onTouchstart,"touchstart"),onTouchmove:handler(cfg.onTouchmove,"touchmove"),onTouchend:handler(cfg.onTouchend,"touchend"),onContextMenu:handler(cfg.onContextMenu,"contextmenu")});var updateDotPos=function updateDotPos(){var pos=_this16.canvasPos.slice();transformToNode(scene.canvas.canvas,parentElement,pos);_this16._dot.setPos(pos[0],pos[1]);};_this16.on("worldPos",updateDotPos);var onViewMatrix=scene.camera.on("viewMatrix",updateDotPos);var onProjMatrix=scene.camera.on("projMatrix",updateDotPos);_this16._cleanup=function(){scene.camera.off(onViewMatrix);scene.camera.off(onProjMatrix);_this16._dot.destroy();};return _this16;}_createClass(Dot3D,[{key:"setClickable",value:function setClickable(value){this._dot.setClickable(value);}},{key:"setCulled",value:function setCulled(value){this._dot.setCulled(value);}},{key:"setFillColor",value:function setFillColor(value){this._dot.setFillColor(value);}},{key:"setHighlighted",value:function setHighlighted(value){this._dot.setHighlighted(value);}},{key:"setOpacity",value:function setOpacity(value){this._dot.setOpacity(value);}},{key:"setVisible",value:function setVisible(value){this._dot.setVisible(value);}},{key:"destroy",value:function destroy(){this._cleanup();_get(_getPrototypeOf(Dot3D.prototype),"destroy",this).call(this);}}]);return Dot3D;}(Marker);function activateDraggableDot(dot,cfg){var extractCFG=function extractCFG(propName,defaultValue){if(propName in cfg){return cfg[propName];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+propName;}};var viewer=extractCFG("viewer");var ray2WorldPos=extractCFG("ray2WorldPos");var handleMouseEvents=extractCFG("handleMouseEvents",false);var handleTouchEvents=extractCFG("handleTouchEvents",false);var onStart=extractCFG("onStart",nop);var onMove=extractCFG("onMove",nop);var onEnd=extractCFG("onEnd",nop);var scene=viewer.scene;var canvas=scene.canvas.canvas;var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,canvasPos,origin,direction);return ray2WorldPos(origin,direction,canvasPos);};var onChange=function onChange(event){var canvasPos=math.vec2([event.clientX,event.clientY]);transformToNode(canvas.ownerDocument.body,canvas,canvasPos);onMove(canvasPos,pickWorldPos(canvasPos));};var currentDrag=null;var onDragMove=function onDragMove(event){var e=currentDrag.matchesEvent(event);if(e){onChange(e);}};var onDragEnd=function onDragEnd(event){var e=currentDrag.matchesEvent(event);if(e){dot.setOpacity(idleOpacity);currentDrag.cleanup();onChange(e);onEnd();}};var startDrag=function startDrag(matchesEvent,cleanupHandlers){if(currentDrag){currentDrag.cleanup();}dot.setOpacity(1.0);dot.setClickable(false);viewer.cameraControl.active=false;currentDrag={matchesEvent:matchesEvent,cleanup:function cleanup(){currentDrag=null;dot.setClickable(true);viewer.cameraControl.active=true;cleanupHandlers();}};onStart();};var cleanupDotHandlers=[];var dot_on=function dot_on(event,callback){var id=dot.on(event,callback);cleanupDotHandlers.push(function(){return dot.off(id);});};if(handleMouseEvents){dot_on("mouseover",function(){return!currentDrag&&dot.setOpacity(1.0);});dot_on("mouseleave",function(){return!currentDrag&&dot.setOpacity(idleOpacity);});dot_on("mousedown",function(event){if(event.which===1){canvas.addEventListener("mousemove",onDragMove);canvas.addEventListener("mouseup",onDragEnd);startDrag(function(event){return event.which===1&&event;},function(){canvas.removeEventListener("mousemove",onDragMove);canvas.removeEventListener("mouseup",onDragEnd);});}});}if(handleTouchEvents){var touchStartId;dot_on("touchstart",function(event){event.preventDefault();if(event.touches.length===1){touchStartId=event.touches[0].identifier;startDrag(function(event){return _toConsumableArray(event.changedTouches).find(function(e){return e.identifier===touchStartId;});},function(){touchStartId=null;});}});dot_on("touchmove",function(event){event.preventDefault();onDragMove(event);});dot_on("touchend",function(event){event.preventDefault();onDragEnd(event);});}var idleOpacity=0.8;dot.setOpacity(idleOpacity);return function(){currentDrag&¤tDrag.cleanup();cleanupDotHandlers.forEach(function(c){return c();});dot.setOpacity(1.0);};}function activateDraggableDots(cfg){var extractCFG=function extractCFG(propName,defaultValue){if(propName in cfg){return cfg[propName];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+propName;}};var viewer=extractCFG("viewer");var handleMouseEvents=extractCFG("handleMouseEvents",false);var handleTouchEvents=extractCFG("handleTouchEvents",false);var pointerLens=extractCFG("pointerLens",null);var dots=extractCFG("dots");var _ray2WorldPos=extractCFG("ray2WorldPos");var _onEnd=extractCFG("onEnd",nop);var updatePointerLens=pointerLens?function(canvasPos){pointerLens.visible=!!canvasPos;if(canvasPos){pointerLens.canvasPos=canvasPos;}}:function(){};var cleanups=dots.map(function(dot){var initPos;return activateDraggableDot(dot,{handleMouseEvents:handleMouseEvents,handleTouchEvents:handleTouchEvents,viewer:viewer,ray2WorldPos:function ray2WorldPos(orig,dir,canvasPos){return _ray2WorldPos(orig,dir,canvasPos)||initPos;},onStart:function onStart(){initPos=dot.worldPos.slice();setOtherDotsActive(false,dot);},onMove:function onMove(canvasPos,worldPos){updatePointerLens(canvasPos);dot.worldPos=worldPos;},onEnd:function onEnd(){if(!_onEnd(initPos,dot)){dot.worldPos=initPos;}updatePointerLens(null);setOtherDotsActive(true,dot);}});});var setOtherDotsActive=function setOtherDotsActive(active,dot){return dots.forEach(function(d){return d!==dot&&d.setClickable(active);});};setOtherDotsActive(true);return function(){cleanups.forEach(function(c){return c();});updatePointerLens(null);};}/** @private */var Wire=/*#__PURE__*/function(){function Wire(parentElement){var _this17=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Wire);this._color=cfg.color||"black";this._highlightClass="viewer-ruler-wire-highlighted";this._wire=document.createElement('div');this._wire.className+=this._wire.className?' viewer-ruler-wire':'viewer-ruler-wire';this._wireClickable=document.createElement('div');this._wireClickable.className+=this._wireClickable.className?' viewer-ruler-wire-clickable':'viewer-ruler-wire-clickable';this._thickness=cfg.thickness||1.0;this._thicknessClickable=cfg.thicknessClickable||6.0;this._visible=true;this._culled=false;var wire=this._wire;var wireStyle=wire.style;wireStyle.border="solid "+this._thickness+"px "+this._color;wireStyle.position="absolute";wireStyle["z-index"]=cfg.zIndex===undefined?"2000001":cfg.zIndex;wireStyle.width=0+"px";wireStyle.height=0+"px";wireStyle.visibility="visible";wireStyle.top=0+"px";wireStyle.left=0+"px";wireStyle['-webkit-transform-origin']="0 0";wireStyle['-moz-transform-origin']="0 0";wireStyle['-ms-transform-origin']="0 0";wireStyle['-o-transform-origin']="0 0";wireStyle['transform-origin']="0 0";wireStyle['-webkit-transform']='rotate(0deg)';wireStyle['-moz-transform']='rotate(0deg)';wireStyle['-ms-transform']='rotate(0deg)';wireStyle['-o-transform']='rotate(0deg)';wireStyle['transform']='rotate(0deg)';wireStyle["opacity"]=1.0;wireStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wire);var wireClickable=this._wireClickable;var wireClickableStyle=wireClickable.style;wireClickableStyle.border="solid "+this._thicknessClickable+"px "+this._color;wireClickableStyle.position="absolute";wireClickableStyle["z-index"]=cfg.zIndex===undefined?"2000002":cfg.zIndex+1;wireClickableStyle.width=0+"px";wireClickableStyle.height=0+"px";wireClickableStyle.visibility="visible";wireClickableStyle.top=0+"px";wireClickableStyle.left=0+"px";// wireClickableStyle["pointer-events"] = "none";
|
|
2760
|
+
*/},{key:"destroy",value:function destroy(){this.fire("destroyed",true);this.scene.camera.off(this._onCameraViewMatrix);this.scene.camera.off(this._onCameraProjMatrix);if(this._entity){if(this._onEntityDestroyed!==null){this._entity.model.off(this._onEntityDestroyed);}if(this._onEntityModelDestroyed!==null){this._entity.model.off(this._onEntityModelDestroyed);}}this._renderer.removeMarker(this);_get(_getPrototypeOf(Marker.prototype),"destroy",this).call(this);}}]);return Marker;}(Component);var nop=function nop(){};function transformToNode(from,to,vec){var fromRec=from.getBoundingClientRect();var toRec=to.getBoundingClientRect();vec[0]+=fromRec.left-toRec.left;vec[1]+=fromRec.top-toRec.top;}var Dot3D=/*#__PURE__*/function(_Marker){_inherits(Dot3D,_Marker);var _super5=_createSuper(Dot3D);function Dot3D(scene,markerCfg,parentElement){var _this16;var cfg=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};_classCallCheck(this,Dot3D);_this16=_super5.call(this,scene,markerCfg);var handler=function handler(cfgEvent,componentEvent){return function(event){if(cfgEvent){cfgEvent(event);}_this16.fire(componentEvent,event,true);};};_this16._dot=new Dot(parentElement,{fillColor:cfg.fillColor,zIndex:cfg.zIndex,onMouseOver:handler(cfg.onMouseOver,"mouseover"),onMouseLeave:handler(cfg.onMouseLeave,"mouseleave"),onMouseWheel:handler(cfg.onMouseWheel,"wheel"),onMouseDown:handler(cfg.onMouseDown,"mousedown"),onMouseUp:handler(cfg.onMouseUp,"mouseup"),onMouseMove:handler(cfg.onMouseMove,"mousemove"),onTouchstart:handler(cfg.onTouchstart,"touchstart"),onTouchmove:handler(cfg.onTouchmove,"touchmove"),onTouchend:handler(cfg.onTouchend,"touchend"),onContextMenu:handler(cfg.onContextMenu,"contextmenu")});var updateDotPos=function updateDotPos(){var pos=_this16.canvasPos.slice();transformToNode(scene.canvas.canvas,parentElement,pos);_this16._dot.setPos(pos[0],pos[1]);};_this16.on("worldPos",updateDotPos);var onViewMatrix=scene.camera.on("viewMatrix",updateDotPos);var onProjMatrix=scene.camera.on("projMatrix",updateDotPos);_this16._cleanup=function(){scene.camera.off(onViewMatrix);scene.camera.off(onProjMatrix);_this16._dot.destroy();};return _this16;}_createClass(Dot3D,[{key:"setClickable",value:function setClickable(value){this._dot.setClickable(value);}},{key:"setCulled",value:function setCulled(value){this._dot.setCulled(value);}},{key:"setFillColor",value:function setFillColor(value){this._dot.setFillColor(value);}},{key:"setHighlighted",value:function setHighlighted(value){this._dot.setHighlighted(value);}},{key:"setOpacity",value:function setOpacity(value){this._dot.setOpacity(value);}},{key:"setVisible",value:function setVisible(value){this._dot.setVisible(value);}},{key:"destroy",value:function destroy(){this._cleanup();_get(_getPrototypeOf(Dot3D.prototype),"destroy",this).call(this);}}]);return Dot3D;}(Marker);function activateDraggableDot(dot,cfg){var extractCFG=function extractCFG(propName,defaultValue){if(propName in cfg){return cfg[propName];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+propName;}};var viewer=extractCFG("viewer");var ray2WorldPos=extractCFG("ray2WorldPos");var handleMouseEvents=extractCFG("handleMouseEvents",false);var handleTouchEvents=extractCFG("handleTouchEvents",false);var onStart=extractCFG("onStart",nop);var onMove=extractCFG("onMove",nop);var onEnd=extractCFG("onEnd",nop);var scene=viewer.scene;var canvas=scene.canvas.canvas;var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,scene.camera.projection,canvasPos,origin,direction);return ray2WorldPos(origin,direction,canvasPos);};var onChange=function onChange(event){var canvasPos=math.vec2([event.clientX,event.clientY]);transformToNode(canvas.ownerDocument.body,canvas,canvasPos);onMove(canvasPos,pickWorldPos(canvasPos));};var currentDrag=null;var onDragMove=function onDragMove(event){var e=currentDrag.matchesEvent(event);if(e){onChange(e);}};var onDragEnd=function onDragEnd(event){var e=currentDrag.matchesEvent(event);if(e){dot.setOpacity(idleOpacity);currentDrag.cleanup();onChange(e);onEnd();}};var startDrag=function startDrag(matchesEvent,cleanupHandlers){if(currentDrag){currentDrag.cleanup();}dot.setOpacity(1.0);dot.setClickable(false);viewer.cameraControl.active=false;currentDrag={matchesEvent:matchesEvent,cleanup:function cleanup(){currentDrag=null;dot.setClickable(true);viewer.cameraControl.active=true;cleanupHandlers();}};onStart();};var cleanupDotHandlers=[];var dot_on=function dot_on(event,callback){var id=dot.on(event,callback);cleanupDotHandlers.push(function(){return dot.off(id);});};if(handleMouseEvents){dot_on("mouseover",function(){return!currentDrag&&dot.setOpacity(1.0);});dot_on("mouseleave",function(){return!currentDrag&&dot.setOpacity(idleOpacity);});dot_on("mousedown",function(event){if(event.which===1){canvas.addEventListener("mousemove",onDragMove);canvas.addEventListener("mouseup",onDragEnd);startDrag(function(event){return event.which===1&&event;},function(){canvas.removeEventListener("mousemove",onDragMove);canvas.removeEventListener("mouseup",onDragEnd);});}});}if(handleTouchEvents){var touchStartId;dot_on("touchstart",function(event){event.preventDefault();if(event.touches.length===1){touchStartId=event.touches[0].identifier;startDrag(function(event){return _toConsumableArray(event.changedTouches).find(function(e){return e.identifier===touchStartId;});},function(){touchStartId=null;});}});dot_on("touchmove",function(event){event.preventDefault();onDragMove(event);});dot_on("touchend",function(event){event.preventDefault();onDragEnd(event);});}var idleOpacity=0.8;dot.setOpacity(idleOpacity);return function(){currentDrag&¤tDrag.cleanup();cleanupDotHandlers.forEach(function(c){return c();});dot.setOpacity(1.0);};}function activateDraggableDots(cfg){var extractCFG=function extractCFG(propName,defaultValue){if(propName in cfg){return cfg[propName];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+propName;}};var viewer=extractCFG("viewer");var handleMouseEvents=extractCFG("handleMouseEvents",false);var handleTouchEvents=extractCFG("handleTouchEvents",false);var pointerLens=extractCFG("pointerLens",null);var dots=extractCFG("dots");var _ray2WorldPos=extractCFG("ray2WorldPos");var _onEnd=extractCFG("onEnd",nop);var updatePointerLens=pointerLens?function(canvasPos){pointerLens.visible=!!canvasPos;if(canvasPos){pointerLens.canvasPos=canvasPos;}}:function(){};var cleanups=dots.map(function(dot){var initPos;return activateDraggableDot(dot,{handleMouseEvents:handleMouseEvents,handleTouchEvents:handleTouchEvents,viewer:viewer,ray2WorldPos:function ray2WorldPos(orig,dir,canvasPos){return _ray2WorldPos(orig,dir,canvasPos)||initPos;},onStart:function onStart(){initPos=dot.worldPos.slice();setOtherDotsActive(false,dot);},onMove:function onMove(canvasPos,worldPos){updatePointerLens(canvasPos);dot.worldPos=worldPos;},onEnd:function onEnd(){if(!_onEnd(initPos,dot)){dot.worldPos=initPos;}updatePointerLens(null);setOtherDotsActive(true,dot);}});});var setOtherDotsActive=function setOtherDotsActive(active,dot){return dots.forEach(function(d){return d!==dot&&d.setClickable(active);});};setOtherDotsActive(true);return function(){cleanups.forEach(function(c){return c();});updatePointerLens(null);};}/** @private */var Wire=/*#__PURE__*/function(){function Wire(parentElement){var _this17=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Wire);this._color=cfg.color||"black";this._highlightClass="viewer-ruler-wire-highlighted";this._wire=document.createElement('div');this._wire.className+=this._wire.className?' viewer-ruler-wire':'viewer-ruler-wire';this._wireClickable=document.createElement('div');this._wireClickable.className+=this._wireClickable.className?' viewer-ruler-wire-clickable':'viewer-ruler-wire-clickable';this._thickness=cfg.thickness||1.0;this._thicknessClickable=cfg.thicknessClickable||6.0;this._visible=true;this._culled=false;var wire=this._wire;var wireStyle=wire.style;wireStyle.border="solid "+this._thickness+"px "+this._color;wireStyle.position="absolute";wireStyle["z-index"]=cfg.zIndex===undefined?"2000001":cfg.zIndex;wireStyle.width=0+"px";wireStyle.height=0+"px";wireStyle.visibility="visible";wireStyle.top=0+"px";wireStyle.left=0+"px";wireStyle['-webkit-transform-origin']="0 0";wireStyle['-moz-transform-origin']="0 0";wireStyle['-ms-transform-origin']="0 0";wireStyle['-o-transform-origin']="0 0";wireStyle['transform-origin']="0 0";wireStyle['-webkit-transform']='rotate(0deg)';wireStyle['-moz-transform']='rotate(0deg)';wireStyle['-ms-transform']='rotate(0deg)';wireStyle['-o-transform']='rotate(0deg)';wireStyle['transform']='rotate(0deg)';wireStyle["opacity"]=1.0;wireStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wire);var wireClickable=this._wireClickable;var wireClickableStyle=wireClickable.style;wireClickableStyle.border="solid "+this._thicknessClickable+"px "+this._color;wireClickableStyle.position="absolute";wireClickableStyle["z-index"]=cfg.zIndex===undefined?"2000002":cfg.zIndex+1;wireClickableStyle.width=0+"px";wireClickableStyle.height=0+"px";wireClickableStyle.visibility="visible";wireClickableStyle.top=0+"px";wireClickableStyle.left=0+"px";// wireClickableStyle["pointer-events"] = "none";
|
|
2760
2761
|
wireClickableStyle['-webkit-transform-origin']="0 0";wireClickableStyle['-moz-transform-origin']="0 0";wireClickableStyle['-ms-transform-origin']="0 0";wireClickableStyle['-o-transform-origin']="0 0";wireClickableStyle['transform-origin']="0 0";wireClickableStyle['-webkit-transform']='rotate(0deg)';wireClickableStyle['-moz-transform']='rotate(0deg)';wireClickableStyle['-ms-transform']='rotate(0deg)';wireClickableStyle['-o-transform']='rotate(0deg)';wireClickableStyle['transform']='rotate(0deg)';wireClickableStyle["opacity"]=0.0;wireClickableStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wireClickable);if(cfg.onMouseOver){wireClickable.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this17);});}if(cfg.onMouseLeave){wireClickable.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this17);});}if(cfg.onMouseWheel){wireClickable.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this17);});}if(cfg.onMouseDown){wireClickable.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this17);});}if(cfg.onMouseUp){wireClickable.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this17);});}if(cfg.onMouseMove){wireClickable.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this17);});}if(cfg.onContextMenu){if(os.isIphoneSafari()){wireClickable.addEventListener('touchstart',function(event){event.preventDefault();if(_this17._timeout){clearTimeout(_this17._timeout);_this17._timeout=null;}_this17._timeout=setTimeout(function(){event.clientX=event.touches[0].clientX;event.clientY=event.touches[0].clientY;cfg.onContextMenu(event,_this17);clearTimeout(_this17._timeout);_this17._timeout=null;},500);});wireClickable.addEventListener('touchend',function(event){event.preventDefault();//stops short touches from calling the timeout
|
|
2761
2762
|
if(_this17._timeout){clearTimeout(_this17._timeout);_this17._timeout=null;}});}else{wireClickable.addEventListener('contextmenu',function(event){console.log(event);cfg.onContextMenu(event,_this17);event.preventDefault();event.stopPropagation();console.log("Label context menu");});}}this._x1=0;this._y1=0;this._x2=0;this._y2=0;this._update();}_createClass(Wire,[{key:"visible",get:function get(){return this._wire.style.visibility==="visible";}},{key:"_update",value:function _update(){var length=Math.abs(Math.sqrt((this._x1-this._x2)*(this._x1-this._x2)+(this._y1-this._y2)*(this._y1-this._y2)));var angle=Math.atan2(this._y2-this._y1,this._x2-this._x1)*180.0/Math.PI;var wireStyle=this._wire.style;wireStyle["width"]=Math.round(length)+'px';wireStyle["left"]=Math.round(this._x1)+'px';wireStyle["top"]=Math.round(this._y1)+'px';wireStyle['-webkit-transform']='rotate('+angle+'deg)';wireStyle['-moz-transform']='rotate('+angle+'deg)';wireStyle['-ms-transform']='rotate('+angle+'deg)';wireStyle['-o-transform']='rotate('+angle+'deg)';wireStyle['transform']='rotate('+angle+'deg)';var wireClickableStyle=this._wireClickable.style;wireClickableStyle["width"]=Math.round(length)+'px';wireClickableStyle["left"]=Math.round(this._x1)+'px';wireClickableStyle["top"]=Math.round(this._y1)+'px';wireClickableStyle['-webkit-transform']='rotate('+angle+'deg)';wireClickableStyle['-moz-transform']='rotate('+angle+'deg)';wireClickableStyle['-ms-transform']='rotate('+angle+'deg)';wireClickableStyle['-o-transform']='rotate('+angle+'deg)';wireClickableStyle['transform']='rotate('+angle+'deg)';}},{key:"setStartAndEnd",value:function setStartAndEnd(x1,y1,x2,y2){this._x1=x1;this._y1=y1;this._x2=x2;this._y2=y2;this._update();}},{key:"setColor",value:function setColor(color){this._color=color||"black";this._wire.style.border="solid "+this._thickness+"px "+this._color;}},{key:"setOpacity",value:function setOpacity(opacity){this._wire.style.opacity=opacity;}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._wire.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._wire.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setClickable",value:function setClickable(clickable){this._wireClickable.style["pointer-events"]=clickable?"all":"none";}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._wire.classList.add(this._highlightClass);}else{this._wire.classList.remove(this._highlightClass);}}},{key:"destroy",value:function destroy(visible){if(this._wire.parentElement){this._wire.parentElement.removeChild(this._wire);}if(this._wireClickable.parentElement){this._wireClickable.parentElement.removeChild(this._wireClickable);}}}]);return Wire;}();/** @private */var Label=/*#__PURE__*/function(){function Label(parentElement){var _this18=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Label);this._highlightClass="viewer-ruler-label-highlighted";this._prefix=cfg.prefix||"";this._x=0;this._y=0;this._visible=true;this._culled=false;this._label=document.createElement('div');this._label.className+=this._label.className?' viewer-ruler-label':'viewer-ruler-label';this._timeout=null;var label=this._label;var style=label.style;style["border-radius"]=5+"px";style.color="white";style.padding="4px";style.border="solid 1px";style.background="lightgreen";style.position="absolute";style["z-index"]=cfg.zIndex===undefined?"5000005":cfg.zIndex;style.width="auto";style.height="auto";style.visibility="visible";style.top=0+"px";style.left=0+"px";style["pointer-events"]="all";style["opacity"]=1.0;if(cfg.onContextMenu);label.innerText="";parentElement.appendChild(label);this.setPos(cfg.x||0,cfg.y||0);this.setFillColor(cfg.fillColor);this.setBorderColor(cfg.fillColor);this.setText(cfg.text);if(cfg.onMouseOver){label.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this18);event.preventDefault();});}if(cfg.onMouseLeave){label.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this18);event.preventDefault();});}if(cfg.onMouseWheel){label.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this18);});}if(cfg.onMouseDown){label.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this18);event.stopPropagation();});}if(cfg.onMouseUp){label.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this18);event.stopPropagation();});}if(cfg.onMouseMove){label.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this18);});}if(cfg.onContextMenu){if(os.isIphoneSafari()){label.addEventListener('touchstart',function(event){event.preventDefault();if(_this18._timeout){clearTimeout(_this18._timeout);_this18._timeout=null;}_this18._timeout=setTimeout(function(){event.clientX=event.touches[0].clientX;event.clientY=event.touches[0].clientY;cfg.onContextMenu(event,_this18);clearTimeout(_this18._timeout);_this18._timeout=null;},500);});label.addEventListener('touchend',function(event){event.preventDefault();//stops short touches from calling the timeout
|
|
2762
2763
|
if(_this18._timeout){clearTimeout(_this18._timeout);_this18._timeout=null;}});}else{label.addEventListener('contextmenu',function(event){console.log(event);cfg.onContextMenu(event,_this18);event.preventDefault();event.stopPropagation();console.log("Label context menu");});}}}_createClass(Label,[{key:"setPos",value:function setPos(x,y){this._x=x;this._y=y;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setPosOnWire",value:function setPosOnWire(x1,y1,x2,y2){var x=x1+(x2-x1)*0.5;var y=y1+(y2-y1)*0.5;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setPosBetweenWires",value:function setPosBetweenWires(x1,y1,x2,y2,x3,y3){var x=(x1+x2+x3)/3;var y=(y1+y2+y3)/3;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setText",value:function setText(text){this._label.innerHTML=this._prefix+(text||"");}},{key:"setFillColor",value:function setFillColor(color){this._fillColor=color||"lightgreen";this._label.style.background=this._fillColor;}},{key:"setBorderColor",value:function setBorderColor(color){this._borderColor=color||"black";this._label.style.border="solid 1px "+this._borderColor;}},{key:"setOpacity",value:function setOpacity(opacity){this._label.style.opacity=opacity;}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._label.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._label.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._label.classList.add(this._highlightClass);}else{this._label.classList.remove(this._highlightClass);}}},{key:"setClickable",value:function setClickable(clickable){this._label.style["pointer-events"]=clickable?"all":"none";}},{key:"setPrefix",value:function setPrefix(prefix){if(this._prefix===prefix){return;}this._prefix=prefix;}},{key:"destroy",value:function destroy(){if(this._label.parentElement){this._label.parentElement.removeChild(this._label);}}}]);return Label;}();var originVec=math.vec3();var targetVec=math.vec3();/**
|
|
@@ -4849,12 +4850,12 @@ if(selectedFillTransparentBinLen>0){for(i=0;i<selectedFillTransparentBinLen;i++)
|
|
|
4849
4850
|
for(var _ii=0;_ii<numVertexAttribs;_ii++){gl.disableVertexAttribArray(_ii);}}/**
|
|
4850
4851
|
* Picks an Entity.
|
|
4851
4852
|
* @private
|
|
4852
|
-
*/this.pick=function(){var tempVec3a=math.vec3();math.mat4();var tempMat4b=math.mat4();var randomVec3=math.vec3();var up=math.vec3([0,1,0]);var _pickResult=new PickResult();var nearAndFar=math.vec2();var canvasPos=math.vec3();var worldRayOrigin=math.vec3();var worldRayDir=math.vec3();math.vec3();math.vec3();return function(params){var pickResult=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_pickResult;pickResult.reset();updateDrawlist();var look;var pickViewMatrix=null;var pickProjMatrix=null;pickResult.pickSurface=params.pickSurface;if(params.canvasPos){canvasPos[0]=params.canvasPos[0];canvasPos[1]=params.canvasPos[1];pickViewMatrix=scene.camera.viewMatrix;pickProjMatrix=scene.camera.projMatrix;pickResult.canvasPos=params.canvasPos;}else{// Picking with arbitrary World-space ray
|
|
4853
|
+
*/this.pick=function(){var tempVec3a=math.vec3();math.mat4();var tempMat4b=math.mat4();var randomVec3=math.vec3();var up=math.vec3([0,1,0]);var _pickResult=new PickResult();var nearAndFar=math.vec2();var canvasPos=math.vec3();var worldRayOrigin=math.vec3();var worldRayDir=math.vec3();math.vec3();math.vec3();return function(params){var pickResult=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_pickResult;pickResult.reset();updateDrawlist();var look;var pickViewMatrix=null;var pickProjMatrix=null;var projection=null;pickResult.pickSurface=params.pickSurface;if(params.canvasPos){canvasPos[0]=params.canvasPos[0];canvasPos[1]=params.canvasPos[1];pickViewMatrix=scene.camera.viewMatrix;pickProjMatrix=scene.camera.projMatrix;projection=scene.camera.projection;pickResult.canvasPos=params.canvasPos;}else{// Picking with arbitrary World-space ray
|
|
4853
4854
|
// Align camera along ray and fire ray through center of canvas
|
|
4854
|
-
if(params.matrix){pickViewMatrix=params.matrix;pickProjMatrix=scene.camera.projMatrix;}else{worldRayOrigin.set(params.origin||[0,0,0]);worldRayDir.set(params.direction||[0,0,1]);look=math.addVec3(worldRayOrigin,worldRayDir,tempVec3a);randomVec3[0]=Math.random();randomVec3[1]=Math.random();randomVec3[2]=Math.random();math.normalizeVec3(randomVec3);math.cross3Vec3(worldRayDir,randomVec3,up);pickViewMatrix=math.lookAtMat4v(worldRayOrigin,look,up,tempMat4b);// pickProjMatrix = scene.camera.projMatrix;
|
|
4855
|
-
pickProjMatrix=scene.camera.ortho.matrix;pickResult.origin=worldRayOrigin;pickResult.direction=worldRayDir;}canvasPos[0]=canvas.clientWidth*0.5;canvasPos[1]=canvas.clientHeight*0.5;}for(var type in drawableTypeInfo){if(drawableTypeInfo.hasOwnProperty(type)){var drawableList=drawableTypeInfo[type].drawableList;for(var _i66=0,len=drawableList.length;_i66<len;_i66++){var drawable=drawableList[_i66];if(drawable.setPickMatrices){// Eg. SceneModel, which needs pre-loading into texture
|
|
4855
|
+
if(params.matrix){pickViewMatrix=params.matrix;pickProjMatrix=scene.camera.projMatrix;projection=scene.camera.projection;}else{worldRayOrigin.set(params.origin||[0,0,0]);worldRayDir.set(params.direction||[0,0,1]);look=math.addVec3(worldRayOrigin,worldRayDir,tempVec3a);randomVec3[0]=Math.random();randomVec3[1]=Math.random();randomVec3[2]=Math.random();math.normalizeVec3(randomVec3);math.cross3Vec3(worldRayDir,randomVec3,up);pickViewMatrix=math.lookAtMat4v(worldRayOrigin,look,up,tempMat4b);// pickProjMatrix = scene.camera.projMatrix;
|
|
4856
|
+
pickProjMatrix=scene.camera.ortho.matrix;projection="ortho";pickResult.origin=worldRayOrigin;pickResult.direction=worldRayDir;}canvasPos[0]=canvas.clientWidth*0.5;canvasPos[1]=canvas.clientHeight*0.5;}for(var type in drawableTypeInfo){if(drawableTypeInfo.hasOwnProperty(type)){var drawableList=drawableTypeInfo[type].drawableList;for(var _i66=0,len=drawableList.length;_i66<len;_i66++){var drawable=drawableList[_i66];if(drawable.setPickMatrices){// Eg. SceneModel, which needs pre-loading into texture
|
|
4856
4857
|
drawable.setPickMatrices(pickViewMatrix,pickProjMatrix);}}}}var pickBuffer=renderBufferManager.getRenderBuffer("pick",{size:[1,1]});pickBuffer.bind();var pickable=gpuPickPickable(pickBuffer,canvasPos,pickViewMatrix,pickProjMatrix,params,pickResult);if(!pickable){pickBuffer.unbind();return null;}var pickedEntity=pickable.delegatePickedEntity?pickable.delegatePickedEntity():pickable;if(!pickedEntity){pickBuffer.unbind();return null;}if(params.pickSurface){// GPU-based ray-picking
|
|
4857
|
-
if(pickable.canPickTriangle&&pickable.canPickTriangle()){gpuPickTriangle(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);pickable.pickTriangleSurface(pickViewMatrix,pickProjMatrix,pickResult);pickResult.pickSurfacePrecision=false;}else{if(pickable.canPickWorldPos&&pickable.canPickWorldPos()){nearAndFar[0]=scene.camera.project.near;nearAndFar[1]=scene.camera.project.far;gpuPickWorldPos(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,nearAndFar,pickResult);if(params.pickSurfaceNormal!==false){gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);}pickResult.pickSurfacePrecision=false;}}}pickBuffer.unbind();pickResult.entity=pickedEntity;return pickResult;};}();function gpuPickPickable(pickBuffer,canvasPos,pickViewMatrix,pickProjMatrix,params,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4858
|
+
if(pickable.canPickTriangle&&pickable.canPickTriangle()){gpuPickTriangle(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);pickable.pickTriangleSurface(pickViewMatrix,pickProjMatrix,projection,pickResult);pickResult.pickSurfacePrecision=false;}else{if(pickable.canPickWorldPos&&pickable.canPickWorldPos()){nearAndFar[0]=scene.camera.project.near;nearAndFar[1]=scene.camera.project.far;gpuPickWorldPos(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,nearAndFar,pickResult);if(params.pickSurfaceNormal!==false){gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);}pickResult.pickSurfacePrecision=false;}}}pickBuffer.unbind();pickResult.entity=pickedEntity;return pickResult;};}();function gpuPickPickable(pickBuffer,canvasPos,pickViewMatrix,pickProjMatrix,params,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4858
4859
|
frameCtx.pickOrigin=pickResult.origin;frameCtx.pickViewMatrix=pickViewMatrix;frameCtx.pickProjMatrix=pickProjMatrix;frameCtx.pickInvisible=!!params.pickInvisible;frameCtx.pickClipPos=[getClipPosX(canvasPos[0]*resolutionScale,gl.drawingBufferWidth),getClipPosY(canvasPos[1]*resolutionScale,gl.drawingBufferHeight)];gl.viewport(0,0,1,1);gl.depthMask(true);gl.enable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);var includeEntityIds=params.includeEntityIds;var excludeEntityIds=params.excludeEntityIds;for(var type in drawableTypeInfo){if(drawableTypeInfo.hasOwnProperty(type)){var drawableInfo=drawableTypeInfo[type];var drawableList=drawableInfo.drawableList;for(var _i67=0,len=drawableList.length;_i67<len;_i67++){var drawable=drawableList[_i67];if(!drawable.drawPickMesh||params.pickInvisible!==true&&drawable.visible===false||drawable.pickable===false){continue;}if(includeEntityIds&&!includeEntityIds[drawable.id]){// TODO: push this logic into drawable
|
|
4859
4860
|
continue;}if(excludeEntityIds&&excludeEntityIds[drawable.id]){continue;}drawable.drawPickMesh(frameCtx);}}}var pix=pickBuffer.read(0,0);var pickID=pix[0]+(pix[1]<<8)+(pix[2]<<16)+(pix[3]<<24);if(pickID<0){return;}var pickable=pickIDs.items[pickID];return pickable;}function gpuPickTriangle(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult){if(!pickable.drawPickTriangles){return;}var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4860
4861
|
frameCtx.pickOrigin=pickResult.origin;frameCtx.pickViewMatrix=pickViewMatrix;// Can be null
|
|
@@ -4872,20 +4873,20 @@ var x=(canvasPos[0]-canvas.clientWidth/2)/(canvas.clientWidth/2);var y=-(canvasP
|
|
|
4872
4873
|
* @param {boolean} [snapToEdge=true]
|
|
4873
4874
|
* @param pickResult
|
|
4874
4875
|
* @returns {PickResult}
|
|
4875
|
-
*/this.snapPick=function(){var _pickResult=new PickResult();return function(
|
|
4876
|
-
frameCtx.pickZNear=scene.camera.project.near;frameCtx.pickZFar=scene.camera.project.far;snapRadiusInPixels=
|
|
4876
|
+
*/this.snapPick=function(){var _pickResult=new PickResult();return function(params){var pickResult=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_pickResult;var canvasPos=params.canvasPos,origin=params.origin,direction=params.direction,snapRadius=params.snapRadius,snapToVertex=params.snapToVertex,snapToEdge=params.snapToEdge;if(!snapToVertex&&!snapToEdge){return this.pick({canvasPos:canvasPos,pickSurface:true});}var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4877
|
+
frameCtx.pickZNear=scene.camera.project.near;frameCtx.pickZFar=scene.camera.project.far;var snapRadiusInPixels=snapRadius||30;var vertexPickBuffer=renderBufferManager.getRenderBuffer("uniquePickColors-aabs",{depthTexture:true,size:[2*snapRadiusInPixels+1,2*snapRadiusInPixels+1]});frameCtx.snapVectorA=[canvasPos?getClipPosX(canvasPos[0]*resolutionScale,gl.drawingBufferWidth):0,canvasPos?getClipPosY(canvasPos[1]*resolutionScale,gl.drawingBufferHeight):0];frameCtx.snapInvVectorAB=[gl.drawingBufferWidth/(2*snapRadiusInPixels),gl.drawingBufferHeight/(2*snapRadiusInPixels)];// Bind and clear the snap render target
|
|
4877
4878
|
vertexPickBuffer.bind(gl.RGBA32I,gl.RGBA32I,gl.RGBA8UI);gl.viewport(0,0,vertexPickBuffer.size[0],vertexPickBuffer.size[1]);gl.enable(gl.DEPTH_TEST);gl.frontFace(gl.CCW);gl.disable(gl.CULL_FACE);gl.depthMask(true);gl.disable(gl.BLEND);gl.depthFunc(gl.LEQUAL);gl.clear(gl.DEPTH_BUFFER_BIT);gl.clearBufferiv(gl.COLOR,0,new Int32Array([0,0,0,0]));gl.clearBufferiv(gl.COLOR,1,new Int32Array([0,0,0,0]));gl.clearBufferuiv(gl.COLOR,2,new Uint32Array([0,0,0,0]));//////////////////////////////////
|
|
4878
4879
|
// Set view and proj mats for VBO renderers
|
|
4879
4880
|
///////////////////////////////////////
|
|
4880
|
-
|
|
4881
|
-
drawable.setPickMatrices(pickViewMatrix,pickProjMatrix);}}}}// a) init z-buffer
|
|
4881
|
+
frameCtx.pickViewMatrix=canvasPos?scene.camera.viewMatrix:math.lookAtMat4v(origin,math.addVec3(origin,direction,math.vec3()),math.vec3([0,1,0]),math.mat4());var pickProjMatrix=scene.camera.projMatrix;for(var type in drawableTypeInfo){if(drawableTypeInfo.hasOwnProperty(type)){var drawableList=drawableTypeInfo[type].drawableList;for(var _i70=0,len=drawableList.length;_i70<len;_i70++){var drawable=drawableList[_i70];if(drawable.setPickMatrices){// Eg. SceneModel, which needs pre-loading into texture
|
|
4882
|
+
drawable.setPickMatrices(frameCtx.pickViewMatrix,pickProjMatrix);}}}}// a) init z-buffer
|
|
4882
4883
|
gl.drawBuffers([gl.COLOR_ATTACHMENT0,gl.COLOR_ATTACHMENT1,gl.COLOR_ATTACHMENT2]);var layerParamsSurface=drawSnapInit(frameCtx);// b) snap-pick
|
|
4883
4884
|
var layerParamsSnap=[];frameCtx.snapPickLayerParams=layerParamsSnap;gl.depthMask(false);gl.drawBuffers([gl.COLOR_ATTACHMENT0]);if(snapToVertex&&snapToEdge){frameCtx.snapMode="edge";drawSnap(frameCtx);frameCtx.snapMode="vertex";frameCtx.snapPickLayerNumber++;drawSnap(frameCtx);}else{frameCtx.snapMode=snapToVertex?"vertex":"edge";drawSnap(frameCtx);}gl.depthMask(true);// Read and decode the snapped coordinates
|
|
4884
4885
|
var snapPickResultArray=vertexPickBuffer.readArray(gl.RGBA_INTEGER,gl.INT,Int32Array,4);var snapPickNormalResultArray=vertexPickBuffer.readArray(gl.RGBA_INTEGER,gl.INT,Int32Array,4,1);var snapPickIdResultArray=vertexPickBuffer.readArray(gl.RGBA_INTEGER,gl.UNSIGNED_INT,Uint32Array,4,2);vertexPickBuffer.unbind();// result 1) regular hi-precision world position
|
|
4885
|
-
var worldPos=null;var middleX=snapRadiusInPixels;var middleY=snapRadiusInPixels;var middleIndex=middleX*4+middleY*vertexPickBuffer.size[0]*4;var pickResultMiddleXY=snapPickResultArray.slice(middleIndex,middleIndex+4);var pickNormalResultMiddleXY=snapPickNormalResultArray.slice(middleIndex,middleIndex+4);var pickPickableResultMiddleXY=snapPickIdResultArray.slice(middleIndex,middleIndex+4);if(pickResultMiddleXY[3]!==0){var pickedLayerParmasSurface=layerParamsSurface[Math.abs(pickResultMiddleXY[3])%layerParamsSurface.length];var
|
|
4886
|
+
var worldPos=null;var middleX=snapRadiusInPixels;var middleY=snapRadiusInPixels;var middleIndex=middleX*4+middleY*vertexPickBuffer.size[0]*4;var pickResultMiddleXY=snapPickResultArray.slice(middleIndex,middleIndex+4);var pickNormalResultMiddleXY=snapPickNormalResultArray.slice(middleIndex,middleIndex+4);var pickPickableResultMiddleXY=snapPickIdResultArray.slice(middleIndex,middleIndex+4);if(pickResultMiddleXY[3]!==0){var pickedLayerParmasSurface=layerParamsSurface[Math.abs(pickResultMiddleXY[3])%layerParamsSurface.length];var _origin=pickedLayerParmasSurface.origin;var _scale=pickedLayerParmasSurface.coordinateScale;worldPos=[pickResultMiddleXY[0]*_scale[0]+_origin[0],pickResultMiddleXY[1]*_scale[1]+_origin[1],pickResultMiddleXY[2]*_scale[2]+_origin[2]];math.normalizeVec3([pickNormalResultMiddleXY[0]/math.MAX_INT,pickNormalResultMiddleXY[1]/math.MAX_INT,pickNormalResultMiddleXY[2]/math.MAX_INT]);var pickID=pickPickableResultMiddleXY[0]+(pickPickableResultMiddleXY[1]<<8)+(pickPickableResultMiddleXY[2]<<16)+(pickPickableResultMiddleXY[3]<<24);pickIDs.items[pickID];}// result 2) hi-precision snapped (to vertex/edge) world position
|
|
4886
4887
|
var snapPickResult=[];for(var _i71=0;_i71<snapPickResultArray.length;_i71+=4){if(snapPickResultArray[_i71+3]>0){var pixelNumber=Math.floor(_i71/4);var w=vertexPickBuffer.size[0];var x=pixelNumber%w-Math.floor(w/2);var y=Math.floor(pixelNumber/w)-Math.floor(w/2);var dist=Math.sqrt(Math.pow(x,2)+Math.pow(y,2));snapPickResult.push({x:x,y:y,dist:dist,isVertex:snapToVertex&&snapToEdge?snapPickResultArray[_i71+3]>layerParamsSnap.length/2:snapToVertex,result:[snapPickResultArray[_i71+0],snapPickResultArray[_i71+1],snapPickResultArray[_i71+2],snapPickResultArray[_i71+3]],normal:[snapPickNormalResultArray[_i71+0],snapPickNormalResultArray[_i71+1],snapPickNormalResultArray[_i71+2],snapPickNormalResultArray[_i71+3]],id:[snapPickIdResultArray[_i71+0],snapPickIdResultArray[_i71+1],snapPickIdResultArray[_i71+2],snapPickIdResultArray[_i71+3]]});}}var snappedWorldPos=null;var snappedWorldNormal=null;var snappedPickable=null;var snapType=null;if(snapPickResult.length>0){// vertex snap first, then edge snap
|
|
4887
|
-
snapPickResult.sort(function(a,b){if(a.isVertex!==b.isVertex){return a.isVertex?-1:1;}else{return a.dist-b.dist;}});snapType=snapPickResult[0].isVertex?"vertex":"edge";var snapPick=snapPickResult[0].result;var snapPickNormal=snapPickResult[0].normal;var snapPickId=snapPickResult[0].id;var pickedLayerParmas=layerParamsSnap[snapPick[3]];var
|
|
4888
|
-
return null;}var snappedCanvasPos=null;if(null!==snappedWorldPos){snappedCanvasPos=scene.camera.projectWorldPos(snappedWorldPos);}var snappedEntity=snappedPickable&&snappedPickable.delegatePickedEntity?snappedPickable.delegatePickedEntity():snappedPickable;pickResult.reset();pickResult.snappedToEdge=snapType==="edge";pickResult.snappedToVertex=snapType==="vertex";pickResult.worldPos=snappedWorldPos;pickResult.worldNormal=snappedWorldNormal;pickResult.entity=snappedEntity;pickResult.canvasPos=canvasPos;pickResult.snappedCanvasPos=snappedCanvasPos||canvasPos;return pickResult;};}();function unpackDepth(depthZ){var vec=[depthZ[0]/256.0,depthZ[1]/256.0,depthZ[2]/256.0,depthZ[3]/256.0];var bitShift=[1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0];return math.dotVec4(vec,bitShift);}function gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4888
|
+
snapPickResult.sort(function(a,b){if(a.isVertex!==b.isVertex){return a.isVertex?-1:1;}else{return a.dist-b.dist;}});snapType=snapPickResult[0].isVertex?"vertex":"edge";var snapPick=snapPickResult[0].result;var snapPickNormal=snapPickResult[0].normal;var snapPickId=snapPickResult[0].id;var pickedLayerParmas=layerParamsSnap[snapPick[3]];var _origin2=pickedLayerParmas.origin;var _scale2=pickedLayerParmas.coordinateScale;snappedWorldNormal=math.normalizeVec3([snapPickNormal[0]/math.MAX_INT,snapPickNormal[1]/math.MAX_INT,snapPickNormal[2]/math.MAX_INT]);snappedWorldPos=[snapPick[0]*_scale2[0]+_origin2[0],snapPick[1]*_scale2[1]+_origin2[1],snapPick[2]*_scale2[2]+_origin2[2]];snappedPickable=pickIDs.items[snapPickId[0]+(snapPickId[1]<<8)+(snapPickId[2]<<16)+(snapPickId[3]<<24)];}if(null===worldPos&&null==snappedWorldPos){// If neither regular pick or snap pick, return null
|
|
4889
|
+
return null;}var snappedCanvasPos=null;if(null!==snappedWorldPos){snappedCanvasPos=scene.camera.projectWorldPos(snappedWorldPos);}var snappedEntity=snappedPickable&&snappedPickable.delegatePickedEntity?snappedPickable.delegatePickedEntity():snappedPickable;pickResult.reset();pickResult.snappedToEdge=snapType==="edge";pickResult.snappedToVertex=snapType==="vertex";pickResult.worldPos=snappedWorldPos;pickResult.worldNormal=snappedWorldNormal;pickResult.entity=snappedEntity;pickResult.canvasPos=canvasPos||scene.camera.projectWorldPos(worldPos||snappedWorldPos);pickResult.snappedCanvasPos=snappedCanvasPos||canvasPos;return pickResult;};}();function unpackDepth(depthZ){var vec=[depthZ[0]/256.0,depthZ[1]/256.0,depthZ[2]/256.0,depthZ[3]/256.0];var bitShift=[1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0];return math.dotVec4(vec,bitShift);}function gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4889
4890
|
frameCtx.pickOrigin=pickResult.origin;frameCtx.pickViewMatrix=pickViewMatrix;frameCtx.pickProjMatrix=pickProjMatrix;frameCtx.pickClipPos=[getClipPosX(canvasPos[0]*resolutionScale,gl.drawingBufferWidth),getClipPosY(canvasPos[1]*resolutionScale,gl.drawingBufferHeight)];var pickNormalBuffer=renderBufferManager.getRenderBuffer("pick-normal",{size:[3,3]});pickNormalBuffer.bind(gl.RGBA32I);gl.viewport(0,0,pickNormalBuffer.size[0],pickNormalBuffer.size[1]);gl.enable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);gl.clear(gl.DEPTH_BUFFER_BIT);gl.clearBufferiv(gl.COLOR,0,new Int32Array([0,0,0,0]));pickable.drawPickNormals(frameCtx);// Draw color-encoded fragment World-space normals
|
|
4890
4891
|
var pix=pickNormalBuffer.read(1,1,gl.RGBA_INTEGER,gl.INT,Int32Array,4);pickNormalBuffer.unbind();var worldNormal=[pix[0]/math.MAX_INT,pix[1]/math.MAX_INT,pix[2]/math.MAX_INT];math.normalizeVec3(worldNormal);pickResult.worldNormal=worldNormal;}/**
|
|
4891
4892
|
* Adds a {@link Marker} for occlusion testing.
|
|
@@ -9843,10 +9844,10 @@ this._aabbDirty=true;this.fire("boundary");// }
|
|
|
9843
9844
|
* @param {boolean} [params.snapToEdge=true] Whether to snap to edge. Only works when `canvasPos` given.
|
|
9844
9845
|
* @param {PickResult} [pickResult] Holds the results of the pick attempt. Will use the Scene's singleton PickResult if you don't supply your own.
|
|
9845
9846
|
* @returns {PickResult} Holds results of the pick attempt, returned when an {@link Entity} is picked, else null. See method comments for description.
|
|
9846
|
-
*/},{key:"pick",value:function pick(params,pickResult){if(this.canvas.boundary[2]===0||this.canvas.boundary[3]===0){this.error("Picking not allowed while canvas has zero width or height");return null;}
|
|
9847
|
+
*/},{key:"pick",value:function pick(params,pickResult){if(this.canvas.boundary[2]===0||this.canvas.boundary[3]===0){this.error("Picking not allowed while canvas has zero width or height");return null;}params=params||{};params.pickSurface=params.pickSurface||params.rayPick;// Backwards compatibility
|
|
9847
9848
|
if(!params.canvasPos&&!params.matrix&&(!params.origin||!params.direction)){this.warn("picking without canvasPos, matrix, or ray origin and direction");}var includeEntities=params.includeEntities||params.include;// Backwards compat
|
|
9848
9849
|
if(includeEntities){params.includeEntityIds=getEntityIDMap(this,includeEntities);}var excludeEntities=params.excludeEntities||params.exclude;// Backwards compat
|
|
9849
|
-
if(excludeEntities){params.excludeEntityIds=getEntityIDMap(this,excludeEntities);}if(this._needRecompile){this._recompile();this._renderer.imageDirty();this._needRecompile=false;}if(params.snapToEdge||params.snapToVertex){pickResult=this._renderer.snapPick(params
|
|
9850
|
+
if(excludeEntities){params.excludeEntityIds=getEntityIDMap(this,excludeEntities);}if(this._needRecompile){this._recompile();this._renderer.imageDirty();this._needRecompile=false;}if(params.snapToEdge||params.snapToVertex){pickResult=this._renderer.snapPick(params,pickResult);}else{pickResult=this._renderer.pick(params,pickResult);}if(pickResult){if(pickResult.entity&&pickResult.entity.fire){pickResult.entity.fire("picked",pickResult);// TODO: SceneModelEntity doesn't fire events
|
|
9850
9851
|
}}return pickResult;}/**
|
|
9851
9852
|
* @param {Object} params Picking parameters.
|
|
9852
9853
|
* @param {Number[]} params.canvasPos Canvas-space coordinates.
|
|
@@ -9854,7 +9855,7 @@ if(excludeEntities){params.excludeEntityIds=getEntityIDMap(this,excludeEntities)
|
|
|
9854
9855
|
* @param {boolean} [params.snapToVertex=true] Whether to snap to vertex.
|
|
9855
9856
|
* @param {boolean} [params.snapToEdge=true] Whether to snap to edge.
|
|
9856
9857
|
* @deprecated
|
|
9857
|
-
*/},{key:"snapPick",value:function snapPick(params){if(undefined===this._warnSnapPickDeprecated){this._warnSnapPickDeprecated=true;this.warn("Scene.snapPick() is deprecated since v2.4.2 - use Scene.pick() instead");}if(!params.canvasPos){this.error("Scene.snapPick() canvasPos parameter expected");return;}return this._renderer.snapPick(params
|
|
9858
|
+
*/},{key:"snapPick",value:function snapPick(params){if(undefined===this._warnSnapPickDeprecated){this._warnSnapPickDeprecated=true;this.warn("Scene.snapPick() is deprecated since v2.4.2 - use Scene.pick() instead");}if(!params.canvasPos){this.error("Scene.snapPick() canvasPos parameter expected");return;}return this._renderer.snapPick(params);}/**
|
|
9858
9859
|
* Destroys all non-default {@link Component}s in this Scene.
|
|
9859
9860
|
*/},{key:"clear",value:function clear(){var component;for(var id in this.components){if(this.components.hasOwnProperty(id)){component=this.components[id];if(!component._dontClear){// Don't destroy components like Camera, Input, Viewport etc.
|
|
9860
9861
|
component.destroy();}}}}/**
|
|
@@ -11187,7 +11188,7 @@ return this;}/**
|
|
|
11187
11188
|
/** @private */},{key:"drawShadow",value:function drawShadow(frameCtx){if(this._shadowRenderer||(this._shadowRenderer=ShadowRenderer.get(this))){this._shadowRenderer.drawMesh(frameCtx,this);}}// ---------------------- PICKING RENDERING ----------------------------------
|
|
11188
11189
|
/** @private */},{key:"drawPickMesh",value:function drawPickMesh(frameCtx){if(this._pickMeshRenderer||(this._pickMeshRenderer=PickMeshRenderer.get(this))){this._pickMeshRenderer.drawMesh(frameCtx,this);}}/** @private
|
|
11189
11190
|
*/},{key:"canPickTriangle",value:function canPickTriangle(){return this._geometry.isReadableGeometry;// VBOGeometry does not support surface picking because it has no geometry data in browser memory
|
|
11190
|
-
}/** @private */},{key:"drawPickTriangles",value:function drawPickTriangles(frameCtx){if(this._pickTriangleRenderer||(this._pickTriangleRenderer=PickTriangleRenderer.get(this))){this._pickTriangleRenderer.drawMesh(frameCtx,this);}}/** @private */},{key:"pickTriangleSurface",value:function pickTriangleSurface(pickViewMatrix,pickProjMatrix,pickResult){_pickTriangleSurface(this,pickViewMatrix,pickProjMatrix,pickResult);}/** @private */},{key:"drawPickVertices",value:function drawPickVertices(frameCtx){}/**
|
|
11191
|
+
}/** @private */},{key:"drawPickTriangles",value:function drawPickTriangles(frameCtx){if(this._pickTriangleRenderer||(this._pickTriangleRenderer=PickTriangleRenderer.get(this))){this._pickTriangleRenderer.drawMesh(frameCtx,this);}}/** @private */},{key:"pickTriangleSurface",value:function pickTriangleSurface(pickViewMatrix,pickProjMatrix,projection,pickResult){_pickTriangleSurface(this,pickViewMatrix,pickProjMatrix,projection,pickResult);}/** @private */},{key:"drawPickVertices",value:function drawPickVertices(frameCtx){}/**
|
|
11191
11192
|
* @private
|
|
11192
11193
|
* @returns {PerformanceNode}
|
|
11193
11194
|
*/},{key:"delegatePickedEntity",value:function delegatePickedEntity(){return this;}//------------------------------------------------------------------------------------------------------------------
|
|
@@ -11198,14 +11199,14 @@ return this;}/**
|
|
|
11198
11199
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(Mesh.prototype),"destroy",this).call(this);// xeokit.Object
|
|
11199
11200
|
this._putDrawRenderers();this._putPickRenderers();this._putOcclusionRenderer();this.scene._renderer.putPickID(this._state.pickID);// TODO: somehow puch this down into xeokit framework?
|
|
11200
11201
|
if(this._isObject){this.scene._deregisterObject(this);if(this._visible){this.scene._objectVisibilityUpdated(this,false,false);}if(this._xrayed){this.scene._objectXRayedUpdated(this,false,false);}if(this._selected){this.scene._objectSelectedUpdated(this,false,false);}if(this._highlighted){this.scene._objectHighlightedUpdated(this,false,false);}this.scene._objectColorizeUpdated(this,false);this.scene._objectOpacityUpdated(this,false);if(this.offset.some(function(v){return v!==0;}))this.scene._objectOffsetUpdated(this,false);}if(this._isModel){this.scene._deregisterModel(this);}this.glRedraw();}}]);return Mesh;}(Component);var _pickTriangleSurface=function(){// Cached vars to avoid garbage collection
|
|
11201
|
-
var localRayOrigin=math.vec3();var localRayDir=math.vec3();var positionA=math.vec3();var positionB=math.vec3();var positionC=math.vec3();var triangleVertices=math.vec3();var position=math.vec4();var worldPos=math.vec3();var viewPos=math.vec3();var bary=math.vec3();var normalA=math.vec3();var normalB=math.vec3();var normalC=math.vec3();var uva=math.vec3();var uvb=math.vec3();var uvc=math.vec3();var tempVec4a=math.vec4();var tempVec4b=math.vec4();var tempVec4c=math.vec4();var tempVec3=math.vec3();var tempVec3b=math.vec3();var tempVec3c=math.vec3();var tempVec3d=math.vec3();var tempVec3e=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();var tempVec3h=math.vec3();var tempVec3i=math.vec3();var tempVec3j=math.vec3();var tempVec3k=math.vec3();return function(mesh,pickViewMatrix,pickProjMatrix,pickResult){var primIndex=pickResult.primIndex;if(primIndex!==undefined&&primIndex!==null&&primIndex>-1){var geometry=mesh.geometry._state;var scene=mesh.scene;var camera=scene.camera;var _canvas2=scene.canvas;if(geometry.primitiveName==="triangles"){// Triangle picked; this only happens when the
|
|
11202
|
+
var localRayOrigin=math.vec3();var localRayDir=math.vec3();var positionA=math.vec3();var positionB=math.vec3();var positionC=math.vec3();var triangleVertices=math.vec3();var position=math.vec4();var worldPos=math.vec3();var viewPos=math.vec3();var bary=math.vec3();var normalA=math.vec3();var normalB=math.vec3();var normalC=math.vec3();var uva=math.vec3();var uvb=math.vec3();var uvc=math.vec3();var tempVec4a=math.vec4();var tempVec4b=math.vec4();var tempVec4c=math.vec4();var tempVec3=math.vec3();var tempVec3b=math.vec3();var tempVec3c=math.vec3();var tempVec3d=math.vec3();var tempVec3e=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();var tempVec3h=math.vec3();var tempVec3i=math.vec3();var tempVec3j=math.vec3();var tempVec3k=math.vec3();return function(mesh,pickViewMatrix,pickProjMatrix,projection,pickResult){var primIndex=pickResult.primIndex;if(primIndex!==undefined&&primIndex!==null&&primIndex>-1){var geometry=mesh.geometry._state;var scene=mesh.scene;var camera=scene.camera;var _canvas2=scene.canvas;if(geometry.primitiveName==="triangles"){// Triangle picked; this only happens when the
|
|
11202
11203
|
// Mesh has a Geometry that has primitives of type "triangle"
|
|
11203
11204
|
pickResult.primitive="triangle";// Get the World-space positions of the triangle's vertices
|
|
11204
11205
|
var _i124=primIndex;// Indicates the first triangle index in the indices array
|
|
11205
11206
|
var indices=geometry.indices;// Indices into geometry arrays, not into shared VertexBufs
|
|
11206
11207
|
var positions=geometry.positions;var ia3;var ib3;var ic3;if(indices){var ia=indices[_i124+0];var ib=indices[_i124+1];var ic=indices[_i124+2];triangleVertices[0]=ia;triangleVertices[1]=ib;triangleVertices[2]=ic;pickResult.indices=triangleVertices;ia3=ia*3;ib3=ib*3;ic3=ic*3;}else{ia3=_i124*3;ib3=ia3+3;ic3=ib3+3;}positionA[0]=positions[ia3+0];positionA[1]=positions[ia3+1];positionA[2]=positions[ia3+2];positionB[0]=positions[ib3+0];positionB[1]=positions[ib3+1];positionB[2]=positions[ib3+2];positionC[0]=positions[ic3+0];positionC[1]=positions[ic3+1];positionC[2]=positions[ic3+2];if(geometry.compressGeometry){// Decompress vertex positions
|
|
11207
11208
|
var positionsDecodeMatrix=geometry.positionsDecodeMatrix;if(positionsDecodeMatrix){geometryCompressionUtils.decompressPosition(positionA,positionsDecodeMatrix,positionA);geometryCompressionUtils.decompressPosition(positionB,positionsDecodeMatrix,positionB);geometryCompressionUtils.decompressPosition(positionC,positionsDecodeMatrix,positionC);}}// Attempt to ray-pick the triangle in local space
|
|
11208
|
-
if(pickResult.canvasPos){math.canvasPosToLocalRay(_canvas2.canvas,mesh.origin?createRTCViewMat(pickViewMatrix,mesh.origin):pickViewMatrix,pickProjMatrix,mesh.worldMatrix,pickResult.canvasPos,localRayOrigin,localRayDir);}else if(pickResult.origin&&pickResult.direction){math.worldRayToLocalRay(mesh.worldMatrix,pickResult.origin,pickResult.direction,localRayOrigin,localRayDir);}math.normalizeVec3(localRayDir);math.rayPlaneIntersect(localRayOrigin,localRayDir,positionA,positionB,positionC,position);// Get Local-space cartesian coordinates of the ray-triangle intersection
|
|
11209
|
+
if(pickResult.canvasPos){math.canvasPosToLocalRay(_canvas2.canvas,mesh.origin?createRTCViewMat(pickViewMatrix,mesh.origin):pickViewMatrix,pickProjMatrix,projection,mesh.worldMatrix,pickResult.canvasPos,localRayOrigin,localRayDir);}else if(pickResult.origin&&pickResult.direction){math.worldRayToLocalRay(mesh.worldMatrix,pickResult.origin,pickResult.direction,localRayOrigin,localRayDir);}math.normalizeVec3(localRayDir);math.rayPlaneIntersect(localRayOrigin,localRayDir,positionA,positionB,positionC,position);// Get Local-space cartesian coordinates of the ray-triangle intersection
|
|
11209
11210
|
pickResult.localPos=position;pickResult.position=position;// Get interpolated World-space coordinates
|
|
11210
11211
|
// Need to transform homogeneous coords
|
|
11211
11212
|
tempVec4a[0]=position[0];tempVec4a[1]=position[1];tempVec4a[2]=position[2];tempVec4a[3]=1;// Get World-space cartesian coordinates of the ray-triangle intersection
|
|
@@ -19532,7 +19533,7 @@ _this86._xAxisLabelCulled=false;_this86._yAxisLabelCulled=false;_this86._zAxisLa
|
|
|
19532
19533
|
});_this86._onMetricsUnits=scene.metrics.on("units",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onMetricsScale=scene.metrics.on("scale",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onMetricsOrigin=scene.metrics.on("origin",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onSectionPlaneUpdated=scene.on("sectionPlaneUpdated",function(){_this86._sectionPlanesDirty=true;_this86._needUpdate();});_this86.approximate=cfg.approximate;_this86.visible=cfg.visible;_this86.originVisible=cfg.originVisible;_this86.targetVisible=cfg.targetVisible;_this86.wireVisible=cfg.wireVisible;_this86.axisVisible=cfg.axisVisible;_this86.xAxisVisible=cfg.xAxisVisible;_this86.yAxisVisible=cfg.yAxisVisible;_this86.zAxisVisible=cfg.zAxisVisible;_this86.xLabelEnabled=cfg.xLabelEnabled;_this86.yLabelEnabled=cfg.yLabelEnabled;_this86.zLabelEnabled=cfg.zLabelEnabled;_this86.lengthLabelEnabled=cfg.lengthLabelEnabled;_this86.labelsVisible=cfg.labelsVisible;_this86.labelsOnWires=cfg.labelsOnWires;_this86.useRotationAdjustment=cfg.useRotationAdjustment;return _this86;}_createClass(DistanceMeasurement,[{key:"_update",value:function _update(){if(!this._visible){return;}var scene=this.plugin.viewer.scene;if(this._wpDirty){this._measurementOrientation=determineMeasurementOrientation(this._originWorld,this._targetWorld,0);if(this._measurementOrientation==='Vertical'&&this.useRotationAdjustment){this._wp[0]=this._originWorld[0];this._wp[1]=this._originWorld[1];this._wp[2]=this._originWorld[2];this._wp[3]=1.0;this._wp[4]=this._originWorld[0];//x-axis
|
|
19533
19534
|
this._wp[5]=this._originWorld[1];this._wp[6]=this._originWorld[2];this._wp[7]=1.0;this._wp[8]=this._originWorld[0];//x-axis
|
|
19534
19535
|
this._wp[9]=this._targetWorld[1];//y-axis
|
|
19535
|
-
this._wp[10]=this._originWorld[2];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}else{this._wp[0]=this._originWorld[0];this._wp[1]=this._originWorld[1];this._wp[2]=this._originWorld[2];this._wp[3]=1.0;this._wp[4]=this._targetWorld[0];this._wp[5]=this._originWorld[1];this._wp[6]=this._originWorld[2];this._wp[7]=1.0;this._wp[8]=this._targetWorld[0];this._wp[9]=this._targetWorld[1];this._wp[10]=this._originWorld[2];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}this._wpDirty=false;this._vpDirty=true;}if(this._vpDirty){math.transformPositions4(scene.camera.viewMatrix,this._wp,this._vp);this._vp[3]=1.0;this._vp[7]=1.0;this._vp[11]=1.0;this._vp[15]=1.0;this._vpDirty=false;this._cpDirty=true;}if(this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld)){this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);this._lengthLabel.setCulled(true);this._xAxisWire.setCulled(true);this._yAxisWire.setCulled(true);this._zAxisWire.setCulled(true);this._lengthWire.setCulled(true);this._originDot.setCulled(true);this._targetDot.setCulled(true);return;}else{this._xAxisLabel.setCulled(false);this._yAxisLabel.setCulled(false);this._zAxisLabel.setCulled(false);this._lengthLabel.setCulled(false);this._xAxisWire.setCulled(false);this._yAxisWire.setCulled(false);this._zAxisWire.setCulled(false);this._lengthWire.setCulled(false);this._originDot.setCulled(false);this._targetDot.setCulled(false);}this._sectionPlanesDirty=true;}var near=-0.3;var vpz1=this._originDot.viewPos[2];var vpz2=this._targetDot.viewPos[2];if(vpz1>near||vpz2>near){this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);this._lengthLabel.setCulled(true);this._xAxisWire.setVisible(false);this._yAxisWire.setVisible(false);this._zAxisWire.setVisible(false);this._lengthWire.setVisible(false);this._originDot.setVisible(false);this._targetDot.setVisible(false);return;}if(this._cpDirty){math.transformPositions4(scene.camera.project.matrix,this._vp,this._pp);var pp=this._pp;var cp=this._cp;var canvas=scene.canvas.canvas;var offsets=canvas.getBoundingClientRect();var containerOffsets=this._container.getBoundingClientRect();var top=offsets.top-containerOffsets.top;var left=offsets.left-containerOffsets.left;var aabb=scene.canvas.boundary;var canvasWidth=aabb[2];var canvasHeight=aabb[3];var j=0;var metrics=this.plugin.viewer.scene.metrics;var _scale5=metrics.scale;var units=metrics.units;var unitInfo=metrics.unitsInfo[units];var unitAbbrev=unitInfo.abbrev;for(var i=0,len=pp.length;i<len;i+=4){cp[j]=left+Math.floor((1+pp[i+0]/pp[i+3])*canvasWidth/2);cp[j+1]=top+Math.floor((1-pp[i+1]/pp[i+3])*canvasHeight/2);j+=2;}this._lengthWire.setStartAndEnd(cp[0],cp[1],cp[6],cp[7]);this._xAxisWire.setStartAndEnd(cp[0],cp[1],cp[2],cp[3]);this._yAxisWire.setStartAndEnd(cp[2],cp[3],cp[4],cp[5]);this._zAxisWire.setStartAndEnd(cp[4],cp[5],cp[6],cp[7]);if(!this.labelsVisible){this._lengthLabel.setCulled(true);this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);}else{this._lengthLabel.setPosOnWire(cp[0],cp[1],cp[6],cp[7]);if(this.labelsOnWires){this._xAxisLabel.setPosOnWire(cp[0],cp[1],cp[2],cp[3]);this._yAxisLabel.setPosOnWire(cp[2],cp[3],cp[4],cp[5]);this._zAxisLabel.setPosOnWire(cp[4],cp[5],cp[6],cp[7]);}else{var labelOffset=35;var currentLabelOffset=labelOffset;this._xAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);currentLabelOffset+=labelOffset;this._yAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);currentLabelOffset+=labelOffset;this._zAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);}var tilde=this._approximate?" ~ ":" = ";this._length=Math.abs(math.lenVec3(math.subVec3(this._targetWorld,this._originWorld,distVec3)));this._lengthLabel.setText(tilde+(this._length*_scale5).toFixed(2)+unitAbbrev);var xAxisCanvasLength=Math.abs(lengthWire(cp[0],cp[1],cp[2],cp[3]));var yAxisCanvasLength=Math.abs(lengthWire(cp[2],cp[3],cp[4],cp[5]));var zAxisCanvasLength=Math.abs(lengthWire(cp[4],cp[5],cp[6],cp[7]));var labelMinAxisLength=this.plugin.labelMinAxisLength;if(this.labelsOnWires){this._xAxisLabelCulled=xAxisCanvasLength<labelMinAxisLength;this._yAxisLabelCulled=yAxisCanvasLength<labelMinAxisLength;this._zAxisLabelCulled=zAxisCanvasLength<labelMinAxisLength;}else{this._xAxisLabelCulled=false;this._yAxisLabelCulled=false;this._zAxisLabelCulled=false;}if(!this._xAxisLabelCulled){this._xAxisLabel.setText(tilde+Math.abs((this._targetWorld[0]-this._originWorld[0])*_scale5).toFixed(2)+unitAbbrev);this._xAxisLabel.setCulled(!this.axisVisible);}else{this._xAxisLabel.setCulled(true);}if(!this._yAxisLabelCulled){this._yAxisLabel.setText(tilde+Math.abs((this._targetWorld[1]-this._originWorld[1])*_scale5).toFixed(2)+unitAbbrev);this._yAxisLabel.setCulled(!this.axisVisible);}else{this._yAxisLabel.setCulled(true);}if(!this._zAxisLabelCulled){if(this._measurementOrientation==='Vertical'){this._zAxisLabel.setPrefix("");this._zAxisLabel.setText(tilde+Math.abs(math.lenVec3(math.subVec3(this._targetWorld,[this._originWorld[0],this._targetWorld[1],this._originWorld[2]],distVec3))*_scale5).toFixed(2)+unitAbbrev);}else{this._zAxisLabel.setPrefix("Z");this._zAxisLabel.setText(tilde+Math.abs((this._targetWorld[2]-this._originWorld[2])*_scale5).toFixed(2)+unitAbbrev);}this._zAxisLabel.setCulled(!this.axisVisible);}else{this._zAxisLabel.setCulled(true);}}// this._xAxisLabel.setVisible(this.axisVisible && this.xAxisVisible);
|
|
19536
|
+
this._wp[10]=this._originWorld[2];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}else{this._wp[0]=this._originWorld[0];this._wp[1]=this._originWorld[1];this._wp[2]=this._originWorld[2];this._wp[3]=1.0;this._wp[4]=this._targetWorld[0];this._wp[5]=this._originWorld[1];this._wp[6]=this._originWorld[2];this._wp[7]=1.0;this._wp[8]=this._targetWorld[0];this._wp[9]=this._targetWorld[1];this._wp[10]=this._originWorld[2];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}this._wpDirty=false;this._vpDirty=true;}if(this._vpDirty){math.transformPositions4(scene.camera.viewMatrix,this._wp,this._vp);this._vp[3]=1.0;this._vp[7]=1.0;this._vp[11]=1.0;this._vp[15]=1.0;this._vpDirty=false;this._cpDirty=true;}if(this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld)){this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);this._lengthLabel.setCulled(true);this._xAxisWire.setCulled(true);this._yAxisWire.setCulled(true);this._zAxisWire.setCulled(true);this._lengthWire.setCulled(true);this._originDot.setCulled(true);this._targetDot.setCulled(true);return;}else{this._xAxisLabel.setCulled(false);this._yAxisLabel.setCulled(false);this._zAxisLabel.setCulled(false);this._lengthLabel.setCulled(false);this._xAxisWire.setCulled(false);this._yAxisWire.setCulled(false);this._zAxisWire.setCulled(false);this._lengthWire.setCulled(false);this._originDot.setCulled(false);this._targetDot.setCulled(false);}this._sectionPlanesDirty=true;}var near=-0.3;var vpz1=this._originDot.viewPos[2];var vpz2=this._targetDot.viewPos[2];if(vpz1>near||vpz2>near){this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);this._lengthLabel.setCulled(true);this._xAxisWire.setVisible(false);this._yAxisWire.setVisible(false);this._zAxisWire.setVisible(false);this._lengthWire.setVisible(false);this._originDot.setVisible(false);this._targetDot.setVisible(false);return;}if(this._cpDirty){math.transformPositions4(scene.camera.project.matrix,this._vp,this._pp);var pp=this._pp;var cp=this._cp;var canvas=scene.canvas.canvas;var offsets=canvas.getBoundingClientRect();var containerOffsets=this._container.getBoundingClientRect();var top=offsets.top-containerOffsets.top;var left=offsets.left-containerOffsets.left;var aabb=scene.canvas.boundary;var canvasWidth=aabb[2];var canvasHeight=aabb[3];var j=0;var metrics=this.plugin.viewer.scene.metrics;var _scale5=metrics.scale;var units=metrics.units;var unitInfo=metrics.unitsInfo[units];var unitAbbrev=unitInfo.abbrev;for(var i=0,len=pp.length;i<len;i+=4){cp[j]=left+Math.floor((1+pp[i+0]/pp[i+3])*canvasWidth/2);cp[j+1]=top+Math.floor((1-pp[i+1]/pp[i+3])*canvasHeight/2);j+=2;}this._lengthWire.setStartAndEnd(cp[0],cp[1],cp[6],cp[7]);this._xAxisWire.setStartAndEnd(cp[0],cp[1],cp[2],cp[3]);this._yAxisWire.setStartAndEnd(cp[2],cp[3],cp[4],cp[5]);this._zAxisWire.setStartAndEnd(cp[4],cp[5],cp[6],cp[7]);if(!this.labelsVisible){this._lengthLabel.setCulled(true);this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);}else{this._lengthLabel.setPosOnWire(cp[0],cp[1],cp[6],cp[7]);if(this.labelsOnWires){this._xAxisLabel.setPosOnWire(cp[0],cp[1],cp[2],cp[3]);this._yAxisLabel.setPosOnWire(cp[2],cp[3],cp[4],cp[5]);this._zAxisLabel.setPosOnWire(cp[4],cp[5],cp[6],cp[7]);}else{var labelOffset=35;var currentLabelOffset=labelOffset;this._xAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);currentLabelOffset+=labelOffset;this._yAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);currentLabelOffset+=labelOffset;this._zAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);}var tilde=this._approximate?" ~ ":" = ";this._length=Math.abs(math.lenVec3(math.subVec3(this._targetWorld,this._originWorld,distVec3)));this._lengthLabel.setText(tilde+(this._length*_scale5).toFixed(2)+unitAbbrev);var xAxisCanvasLength=Math.abs(lengthWire(cp[0],cp[1],cp[2],cp[3]));var yAxisCanvasLength=Math.abs(lengthWire(cp[2],cp[3],cp[4],cp[5]));var zAxisCanvasLength=Math.abs(lengthWire(cp[4],cp[5],cp[6],cp[7]));var labelMinAxisLength=this.plugin.labelMinAxisLength;if(this.labelsOnWires){this._xAxisLabelCulled=xAxisCanvasLength<labelMinAxisLength;this._yAxisLabelCulled=yAxisCanvasLength<labelMinAxisLength;this._zAxisLabelCulled=zAxisCanvasLength<labelMinAxisLength;}else{this._xAxisLabelCulled=false;this._yAxisLabelCulled=false;this._zAxisLabelCulled=false;}if(!this._xAxisLabelCulled){this._xAxisLabel.setText(tilde+Math.abs((this._targetWorld[0]-this._originWorld[0])*_scale5).toFixed(2)+unitAbbrev);this._xAxisLabel.setCulled(!this.axisVisible);}else{this._xAxisLabel.setCulled(true);}if(!this._yAxisLabelCulled){this._yAxisLabel.setText(tilde+Math.abs((this._targetWorld[1]-this._originWorld[1])*_scale5).toFixed(2)+unitAbbrev);this._yAxisLabel.setCulled(!this.axisVisible);}else{this._yAxisLabel.setCulled(true);}if(!this._zAxisLabelCulled){if(this._measurementOrientation==='Vertical'&&this.useRotationAdjustment){this._zAxisLabel.setPrefix("");this._zAxisLabel.setText(tilde+Math.abs(math.lenVec3(math.subVec3(this._targetWorld,[this._originWorld[0],this._targetWorld[1],this._originWorld[2]],distVec3))*_scale5).toFixed(2)+unitAbbrev);}else{this._zAxisLabel.setPrefix("Z");this._zAxisLabel.setText(tilde+Math.abs((this._targetWorld[2]-this._originWorld[2])*_scale5).toFixed(2)+unitAbbrev);}this._zAxisLabel.setCulled(!this.axisVisible);}else{this._zAxisLabel.setCulled(true);}}// this._xAxisLabel.setVisible(this.axisVisible && this.xAxisVisible);
|
|
19536
19537
|
// this._yAxisLabel.setVisible(this.axisVisible && this.yAxisVisible);
|
|
19537
19538
|
// this._zAxisLabel.setVisible(this.axisVisible && this.zAxisVisible);
|
|
19538
19539
|
// this._lengthLabel.setVisible(false);
|
|
@@ -19843,7 +19844,16 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19843
19844
|
* Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
|
|
19844
19845
|
*
|
|
19845
19846
|
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
|
|
19846
|
-
*/},{key:"deactivate",value:function deactivate(){if(!this._active){return;}this.fire("activated",false);if(this.pointerLens){this.pointerLens.visible=false;}if(this._markerDiv)
|
|
19847
|
+
*/},{key:"deactivate",value:function deactivate(){if(!this._active){return;}this.fire("activated",false);if(this.pointerLens){this.pointerLens.visible=false;}// if (this._markerDiv) {
|
|
19848
|
+
// this._destroyMarkerDiv()
|
|
19849
|
+
// }
|
|
19850
|
+
// this.reset();
|
|
19851
|
+
var canvas=this.scene.canvas.canvas;canvas.removeEventListener("mousedown",this._onMouseDown);canvas.removeEventListener("mouseup",this._onMouseUp);var cameraControl=this.distanceMeasurementsPlugin.viewer.cameraControl;cameraControl.off(this._onCameraControlHoverSnapOrSurface);cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);// if (this._currentDistanceMeasurement) {
|
|
19852
|
+
// this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
|
|
19853
|
+
// this._currentDistanceMeasurement.destroy();
|
|
19854
|
+
// this._currentDistanceMeasurement = null;
|
|
19855
|
+
// }
|
|
19856
|
+
this._active=false;}/**
|
|
19847
19857
|
* Resets this DistanceMeasurementsMouseControl.
|
|
19848
19858
|
*
|
|
19849
19859
|
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
|
|
@@ -20206,7 +20216,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
20206
20216
|
* @param {string} [params.color] The color of the length dot, wire and label.
|
|
20207
20217
|
* @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
|
|
20208
20218
|
* @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
|
|
20209
|
-
*/,set:function set(_useRotationAdjustment){_useRotationAdjustment=_useRotationAdjustment!==undefined?Boolean(_useRotationAdjustment):false;this._useRotationAdjustment=_useRotationAdjustment;}},{key:"createMeasurement",value:function createMeasurement(){var _this90=this;var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(this.viewer.scene.components[params.id]){this.error("Viewer scene component with this ID already exists: "+params.id);delete params.id;}var origin=params.origin;var target=params.target;var measurement=new DistanceMeasurement(this,{id:params.id,plugin:this,container:this._container,origin:{entity:origin.entity,worldPos:origin.worldPos},target:{entity:target.entity,worldPos:target.worldPos},visible:params.visible,wireVisible:params.wireVisible,axisVisible:params.axisVisible!==false&&this.defaultAxisVisible!==false,xAxisVisible:params.xAxisVisible!==false&&this.defaultXAxisVisible!==false,yAxisVisible:params.yAxisVisible!==false&&this.defaultYAxisVisible!==false,
|
|
20219
|
+
*/,set:function set(_useRotationAdjustment){_useRotationAdjustment=_useRotationAdjustment!==undefined?Boolean(_useRotationAdjustment):false;this._useRotationAdjustment=_useRotationAdjustment;}},{key:"createMeasurement",value:function createMeasurement(){var _this90=this;var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(this.viewer.scene.components[params.id]){this.error("Viewer scene component with this ID already exists: "+params.id);delete params.id;}var origin=params.origin;var target=params.target;var measurement=new DistanceMeasurement(this,{id:params.id,plugin:this,container:this._container,origin:{entity:origin.entity,worldPos:origin.worldPos},target:{entity:target.entity,worldPos:target.worldPos},visible:params.visible,wireVisible:params.wireVisible,axisVisible:params.axisVisible!==false&&this.defaultAxisVisible!==false,xAxisVisible:params.xAxisVisible!==false&&this.defaultXAxisVisible!==false,yAxisVisible:params.yAxisVisible!==false&&this.defaultYAxisVisible!==false,zAxisVisible:params.zAxisVisible!==false&&this.defaultZAxisVisible!==false,xLabelEnabled:params.xLabelEnabled!==false&&this.defaultXLabelEnabled!==false,yLabelEnabled:params.yLabelEnabled!==false&&this.defaultYLabelEnabled!==false,zLabelEnabled:params.zLabelEnabled!==false&&this.defaultZLabelEnabled!==false,lengthLabelEnabled:params.lengthLabelEnabled!==false&&this.defaultLengthLabelEnabled!==false,labelsVisible:params.labelsVisible!==false&&this.defaultLabelsVisible!==false,useRotationAdjustment:this.useRotationAdjustment,originVisible:params.originVisible,targetVisible:params.targetVisible,color:params.color,labelsOnWires:params.labelsOnWires!==false&&this.defaultLabelsOnWires!==false,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});this._measurements[measurement.id]=measurement;measurement.clickable=true;measurement.on("destroyed",function(){delete _this90._measurements[measurement.id];});this.fire("measurementCreated",measurement);return measurement;}/**
|
|
20210
20220
|
* Destroys a {@link DistanceMeasurement}.
|
|
20211
20221
|
*
|
|
20212
20222
|
* @param {String} id ID of DistanceMeasurement to destroy.
|
|
@@ -22855,8 +22865,7 @@ var camera=scene.camera;math.subVec3(camera.eye,camera.look,[]);controllers.came
|
|
|
22855
22865
|
// up: camera.up,
|
|
22856
22866
|
aabb:aabb});// TODO: Option to back off to fit AABB in view
|
|
22857
22867
|
}else{// Fly to fit target boundary in view
|
|
22858
|
-
controllers.cameraFlight.flyTo({aabb:aabb});}};var tickifiedMouseMoveFn=scene.tickify(this._canvasMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(leftDown||rightDown){return;}if(cameraControl.hasSubs("rayMove")){var origin=math.vec3();var _direction2=math.vec3()
|
|
22859
|
-
math.canvasPosToWorldRay(scene.canvas.canvas,scene.camera.viewMatrix,scene.camera.projMatrix,states.pointerCanvasPos,origin,_direction2);cameraControl.fire("rayMove",{canvasPos:states.pointerCanvasPos,ray:{origin:origin,direction:_direction2,canvasPos:states.pointerCanvasPos}},true);}var hoverSubs=cameraControl.hasSubs("hover");var hoverEnterSubs=cameraControl.hasSubs("hoverEnter");var hoverOutSubs=cameraControl.hasSubs("hoverOut");var hoverOffSubs=cameraControl.hasSubs("hoverOff");var hoverSurfaceSubs=cameraControl.hasSubs("hoverSurface");var hoverSnapOrSurfaceSubs=cameraControl.hasSubs("hoverSnapOrSurface");if(hoverSubs||hoverEnterSubs||hoverOutSubs||hoverOffSubs||hoverSurfaceSubs||hoverSnapOrSurfaceSubs){pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=true;pickController.schedulePickSurface=hoverSurfaceSubs;pickController.scheduleSnapOrPick=hoverSnapOrSurfaceSubs;pickController.update();if(pickController.pickResult){if(pickController.pickResult.entity){var pickedEntityId=pickController.pickResult.entity.id;if(_this113._lastPickedEntityId!==pickedEntityId){if(_this113._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
22868
|
+
controllers.cameraFlight.flyTo({aabb:aabb});}};var tickifiedMouseMoveFn=scene.tickify(this._canvasMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(leftDown||rightDown){return;}if(cameraControl.hasSubs("rayMove")){var origin=math.vec3();var _direction2=math.vec3();math.canvasPosToWorldRay(scene.canvas.canvas,scene.camera.viewMatrix,scene.camera.projMatrix,scene.camera.projection,states.pointerCanvasPos,origin,_direction2);cameraControl.fire("rayMove",{canvasPos:states.pointerCanvasPos,ray:{origin:origin,direction:_direction2,canvasPos:states.pointerCanvasPos}},true);}var hoverSubs=cameraControl.hasSubs("hover");var hoverEnterSubs=cameraControl.hasSubs("hoverEnter");var hoverOutSubs=cameraControl.hasSubs("hoverOut");var hoverOffSubs=cameraControl.hasSubs("hoverOff");var hoverSurfaceSubs=cameraControl.hasSubs("hoverSurface");var hoverSnapOrSurfaceSubs=cameraControl.hasSubs("hoverSnapOrSurface");if(hoverSubs||hoverEnterSubs||hoverOutSubs||hoverOffSubs||hoverSurfaceSubs||hoverSnapOrSurfaceSubs){pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=true;pickController.schedulePickSurface=hoverSurfaceSubs;pickController.scheduleSnapOrPick=hoverSnapOrSurfaceSubs;pickController.update();if(pickController.pickResult){if(pickController.pickResult.entity){var pickedEntityId=pickController.pickResult.entity.id;if(_this113._lastPickedEntityId!==pickedEntityId){if(_this113._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
22860
22869
|
entity:scene.objects[_this113._lastPickedEntityId]},true);}cameraControl.fire("hoverEnter",pickController.pickResult,true);// Hovering over a new entity
|
|
22861
22870
|
_this113._lastPickedEntityId=pickedEntityId;}}cameraControl.fire("hover",pickController.pickResult,true);if(pickController.pickResult.worldPos||pickController.pickResult.snappedWorldPos){// Hovering the surface of an entity
|
|
22862
22871
|
cameraControl.fire("hoverSurface",pickController.pickResult,true);}}else{if(_this113._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
@@ -22866,7 +22875,7 @@ states.mouseDownClientX=e.clientX;states.mouseDownClientY=e.clientY;states.mouse
|
|
|
22866
22875
|
var pickResult=pickController.pickResult;if(pickResult&&pickResult.worldPos){pivotController.setPivotPos(pickResult.worldPos);pivotController.startPivot();}else{if(configs.smartPivot){pivotController.setCanvasPivotPos(states.pointerCanvasPos);}else{pivotController.setPivotPos(scene.camera.look);}pivotController.startPivot();}}}});document.addEventListener('mouseup',this._documentMouseUpHandler=function(e){if(e.which===1){leftDown=false;}if(e.which===3){rightDown=false;}if(pivotController.getPivoting()){pivotController.endPivot();}});canvas.addEventListener('mouseup',this._canvasMouseUpHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}var leftButtonUp=e.which===1;if(!leftButtonUp){return;}// Left mouse button up to possibly pick or double-pick
|
|
22867
22876
|
pivotController.hidePivot();if(Math.abs(e.clientX-states.mouseDownClientX)>3||Math.abs(e.clientY-states.mouseDownClientY)>3){return;}var pickedSubs=cameraControl.hasSubs("picked");var pickedNothingSubs=cameraControl.hasSubs("pickedNothing");var pickedSurfaceSubs=cameraControl.hasSubs("pickedSurface");var doublePickedSubs=cameraControl.hasSubs("doublePicked");var doublePickedSurfaceSubs=cameraControl.hasSubs("doublePickedSurface");var doublePickedNothingSubs=cameraControl.hasSubs("doublePickedNothing");if(!configs.doublePickFlyTo&&!doublePickedSubs&&!doublePickedSurfaceSubs&&!doublePickedNothingSubs){// Avoid the single/double click differentiation timeout
|
|
22868
22877
|
if(pickedSubs||pickedNothingSubs||pickedSurfaceSubs){pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){cameraControl.fire("picked",pickController.pickResult,true);if(pickController.pickedSurface){cameraControl.fire("pickedSurface",pickController.pickResult,true);}}else{cameraControl.fire("pickedNothing",{canvasPos:states.pointerCanvasPos},true);}}_this113._clicks=0;return;}_this113._clicks++;if(_this113._clicks===1){// First click
|
|
22869
|
-
pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=configs.doublePickFlyTo;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();var firstClickPickResult=pickController.pickResult;var firstClickPickSurface=pickController.pickedSurface;_this113._timeout=setTimeout(function(){if(firstClickPickResult){cameraControl.fire("picked",firstClickPickResult,true);if(firstClickPickSurface){cameraControl.fire("pickedSurface",firstClickPickResult,true);if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.setPivotPos(firstClickPickResult.worldPos);if(controllers.pivotController.startPivot()){controllers.pivotController.showPivot();}}}}else{cameraControl.fire("pickedNothing",{canvasPos:states.pointerCanvasPos},true);}_this113._clicks=0;},configs.doubleClickTimeFrame);}else{// Second click
|
|
22878
|
+
pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=configs.doublePickFlyTo;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();var firstClickPickResult=pickController.pickResult;var firstClickPickSurface=pickController.pickedSurface;_this113._timeout=setTimeout(function(){if(firstClickPickResult&&firstClickPickResult.worldPos){cameraControl.fire("picked",firstClickPickResult,true);if(firstClickPickSurface){cameraControl.fire("pickedSurface",firstClickPickResult,true);if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.setPivotPos(firstClickPickResult.worldPos);if(controllers.pivotController.startPivot()){controllers.pivotController.showPivot();}}}}else{cameraControl.fire("pickedNothing",{canvasPos:states.pointerCanvasPos},true);}_this113._clicks=0;},configs.doubleClickTimeFrame);}else{// Second click
|
|
22870
22879
|
if(_this113._timeout!==null){window.clearTimeout(_this113._timeout);_this113._timeout=null;}pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=configs.doublePickFlyTo||doublePickedSubs||doublePickedSurfaceSubs;pickController.schedulePickSurface=pickController.schedulePickEntity&&doublePickedSurfaceSubs;pickController.update();if(pickController.pickResult){cameraControl.fire("doublePicked",pickController.pickResult,true);if(pickController.pickedSurface){cameraControl.fire("doublePickedSurface",pickController.pickResult,true);}if(configs.doublePickFlyTo){flyCameraTo(pickController.pickResult);if(!configs.firstPerson&&configs.followPointer){var pickedEntityAABB=pickController.pickResult.entity.aabb;var pickedEntityCenterPos=math.getAABB3Center(pickedEntityAABB);controllers.pivotController.setPivotPos(pickedEntityCenterPos);if(controllers.pivotController.startPivot()){controllers.pivotController.showPivot();}}}}else{cameraControl.fire("doublePickedNothing",{canvasPos:states.pointerCanvasPos},true);if(configs.doublePickFlyTo){flyCameraTo();if(!configs.firstPerson&&configs.followPointer){var sceneAABB=scene.aabb;var sceneCenterPos=math.getAABB3Center(sceneAABB);controllers.pivotController.setPivotPos(sceneCenterPos);if(controllers.pivotController.startPivot()){controllers.pivotController.showPivot();}}}}_this113._clicks=0;}},false);}_createClass(MousePickHandler,[{key:"reset",value:function reset(){this._clicks=0;this._lastPickedEntityId=null;if(this._timeout){window.clearTimeout(this._timeout);this._timeout=null;}}},{key:"destroy",value:function destroy(){var canvas=this._scene.canvas.canvas;canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler);canvas.removeEventListener("mousedown",this._canvasMouseDownHandler);document.removeEventListener("mouseup",this._documentMouseUpHandler);canvas.removeEventListener("mouseup",this._canvasMouseUpHandler);if(this._timeout){window.clearTimeout(this._timeout);this._timeout=null;}}}]);return MousePickHandler;}();/**
|
|
22871
22880
|
* @private
|
|
22872
22881
|
*/var KeyboardPanRotateDollyHandler=/*#__PURE__*/function(){function KeyboardPanRotateDollyHandler(scene,controllers,configs,states,updates){_classCallCheck(this,KeyboardPanRotateDollyHandler);this._scene=scene;var input=scene.input;var keyDownMap=[];var canvas=scene.canvas.canvas;var mouseMovedSinceLastKeyboardDolly=true;this._onSceneMouseMove=input.on("mousemove",function(){mouseMovedSinceLastKeyboardDolly=true;});this._onSceneKeyDown=input.on("keydown",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(configs.keyboardEnabledOnlyIfMouseover&&!states.mouseover){return;}keyDownMap[keyCode]=true;if(keyCode===input.KEY_SHIFT){canvas.style.cursor="move";}});this._onSceneKeyUp=input.on("keyup",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}keyDownMap[keyCode]=false;if(keyCode===input.KEY_SHIFT){canvas.style.cursor=null;}if(controllers.pivotController.getPivoting()){controllers.pivotController.endPivot();}});this._onTick=scene.on("tick",function(e){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(configs.keyboardEnabledOnlyIfMouseover&&!states.mouseover){return;}var cameraControl=controllers.cameraControl;var elapsedSecs=e.deltaTime/1000.0;//-------------------------------------------------------------------------------------------------
|
|
@@ -30235,7 +30244,7 @@ var ind=(_ref23=[]).concat.apply(_ref23,_toConsumableArray(baseTriangles));mesh=
|
|
|
30235
30244
|
geometry:new ReadableGeometry(scene,{positions:positions,indices:ind,normals:math.buildNormals(positions,ind)}),material:new PhongMaterial(scene,{alpha:alpha!==undefined?alpha:0.5,backfaces:true,diffuse:hex2rgb(color)})});}catch(e){mesh=null;}}if(mesh){mesh.visible=!!points;}};updateBase(null);return{updateBase:updateBase,destroy:function destroy(){return mesh&&mesh.destroy();}};};var startAAZoneCreateUI=function startAAZoneCreateUI(scene,zoneAltitude,zoneHeight,zoneColor,zoneAlpha,pointerLens,zonesPlugin,select3dPoint,onZoneCreated){var marker1=marker3D(scene,zoneColor);var marker2=marker3D(scene,zoneColor);var basePolygon=basePolygon3D(scene,zoneColor,zoneAlpha);var updatePointerLens=pointerLens?function(canvasPos){pointerLens.visible=!!canvasPos;if(canvasPos){pointerLens.canvasPos=canvasPos;}}:function(){};var deactivatePointSelection=select3dPoint(function(){updatePointerLens(null);marker1.update(null);},function(canvasPos,worldPos){updatePointerLens(canvasPos);marker1.update(worldPos);},function(point1CanvasPos,point1WorldPos){marker1.update(point1WorldPos);deactivatePointSelection=select3dPoint(function(){updatePointerLens(null);marker2.update(null);basePolygon.updateBase(null);},function(canvasPos,point2WorldPos){updatePointerLens(canvasPos);marker2.update(point2WorldPos);if(math.distVec3(point1WorldPos,point2WorldPos)>0.01){var min=function min(idx){return Math.min(point1WorldPos[idx],point2WorldPos[idx]);};var max=function max(idx){return Math.max(point1WorldPos[idx],point2WorldPos[idx]);};var xmin=min(0);var ymin=min(1);var zmin=min(2);var xmax=max(0);max(1);var zmax=max(2);basePolygon.updateBase([[xmin,ymin,zmax],[xmax,ymin,zmax],[xmax,ymin,zmin],[xmin,ymin,zmin]]);}else basePolygon.updateBase(null);},function(point2CanvasPos,point2WorldPos){// `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
|
|
30236
30245
|
// This works around an unidentified bug somewhere around OcclusionLayer, that causes error
|
|
30237
30246
|
// [.WebGL-0x13400c47e00] GL_INVALID_OPERATION: Vertex buffer is not big enough for the draw call
|
|
30238
|
-
marker2.update(point2WorldPos);marker1.destroy();marker2.destroy();basePolygon.destroy();updatePointerLens(null);var min=function min(idx){return Math.min(point1WorldPos[idx],point2WorldPos[idx]);};var max=function max(idx){return Math.max(point1WorldPos[idx],point2WorldPos[idx]);};var xmin=min(0);var zmin=min(2);var xmax=max(0);var zmax=max(2);var zone=zonesPlugin.createZone({id:math.createUUID(),geometry:{planeCoordinates:[[xmin,zmax],[xmax,zmax],[xmax,zmin],[xmin,zmin]],altitude:zoneAltitude,height:zoneHeight},alpha:zoneAlpha,color:zoneColor});onZoneCreated(zone);});});return{deactivate:function deactivate(){deactivatePointSelection();marker1.destroy();marker2.destroy();basePolygon.destroy();updatePointerLens(null);}};};var mousePointSelector=function mousePointSelector(viewer,ray2WorldPos){return function(onCancel,onChange,onCommit){var scene=viewer.scene;var canvas=scene.canvas.canvas;var moveTolerance=20;var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.body,canvas,vec2);return vec2;};var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,canvasPos,origin,direction);return ray2WorldPos(origin,direction);};var buttonDown=false;var resetAction=function resetAction(){buttonDown=false;};var cleanup=function cleanup(){resetAction();canvas.removeEventListener("mousedown",onMouseDown);canvas.removeEventListener("mousemove",onMouseMove);viewer.cameraControl.off(onCameraControlRayMove);canvas.removeEventListener("mouseup",onMouseUp);};var startCanvasPos=math.vec2();var onMouseDown=function onMouseDown(event){if(event.which===1){copyCanvasPos(event,startCanvasPos);buttonDown=true;}};canvas.addEventListener("mousedown",onMouseDown);var onMouseMove=function onMouseMove(event){var canvasPos=copyCanvasPos(event,math.vec2());if(buttonDown&&math.distVec2(startCanvasPos,canvasPos)>moveTolerance){resetAction();onCancel();}};canvas.addEventListener("mousemove",onMouseMove);var onCameraControlRayMove=viewer.cameraControl.on("rayMove",function(event){var canvasPos=event.canvasPos;onChange(canvasPos,pickWorldPos(canvasPos));});var onMouseUp=function onMouseUp(event){if(event.which===1&&buttonDown){cleanup();var _canvasPos2=copyCanvasPos(event,math.vec2());onCommit(_canvasPos2,pickWorldPos(_canvasPos2));}};canvas.addEventListener("mouseup",onMouseUp);return cleanup;};};var touchPointSelector=function touchPointSelector(viewer,pointerCircle,ray2WorldPos){return function(onCancel,onChange,onCommit){var scene=viewer.scene;var canvas=scene.canvas.canvas;var longTouchTimeoutMs=300;var moveTolerance=20;var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.body,canvas,vec2);return vec2;};var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,canvasPos,origin,direction);return ray2WorldPos(origin,direction);};var longTouchTimeout=null;var nop=function nop(){};var onSingleTouchMove=nop;var startTouchIdentifier;var resetAction=function resetAction(){pointerCircle.stop();clearTimeout(longTouchTimeout);viewer.cameraControl.active=true;onSingleTouchMove=nop;startTouchIdentifier=null;};var cleanup=function cleanup(){resetAction();canvas.removeEventListener("touchstart",onCanvasTouchStart);canvas.removeEventListener("touchmove",onCanvasTouchMove);canvas.removeEventListener("touchend",onCanvasTouchEnd);};var onCanvasTouchStart=function onCanvasTouchStart(event){var touches=event.touches;if(touches.length!==1){resetAction();onCancel();}else{var startTouch=touches[0];var startCanvasPos=copyCanvasPos(startTouch,math.vec2());var startWorldPos=pickWorldPos(startCanvasPos);if(startWorldPos){startTouchIdentifier=startTouch.identifier;onSingleTouchMove=function onSingleTouchMove(canvasPos){if(math.distVec2(startCanvasPos,canvasPos)>moveTolerance){resetAction();}};longTouchTimeout=setTimeout(function(){pointerCircle.start(startCanvasPos);longTouchTimeout=setTimeout(function(){pointerCircle.stop();viewer.cameraControl.active=false;onSingleTouchMove=function onSingleTouchMove(canvasPos){onChange(canvasPos,pickWorldPos(canvasPos));};onSingleTouchMove(startCanvasPos);},longTouchTimeoutMs);},250);}}};canvas.addEventListener("touchstart",onCanvasTouchStart,{passive:true});// canvas.addEventListener("touchcancel", e => console.log("touchcancel", e), {passive: true});
|
|
30247
|
+
marker2.update(point2WorldPos);marker1.destroy();marker2.destroy();basePolygon.destroy();updatePointerLens(null);var min=function min(idx){return Math.min(point1WorldPos[idx],point2WorldPos[idx]);};var max=function max(idx){return Math.max(point1WorldPos[idx],point2WorldPos[idx]);};var xmin=min(0);var zmin=min(2);var xmax=max(0);var zmax=max(2);var zone=zonesPlugin.createZone({id:math.createUUID(),geometry:{planeCoordinates:[[xmin,zmax],[xmax,zmax],[xmax,zmin],[xmin,zmin]],altitude:zoneAltitude,height:zoneHeight},alpha:zoneAlpha,color:zoneColor});onZoneCreated(zone);});});return{deactivate:function deactivate(){deactivatePointSelection();marker1.destroy();marker2.destroy();basePolygon.destroy();updatePointerLens(null);}};};var mousePointSelector=function mousePointSelector(viewer,ray2WorldPos){return function(onCancel,onChange,onCommit){var scene=viewer.scene;var canvas=scene.canvas.canvas;var moveTolerance=20;var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.body,canvas,vec2);return vec2;};var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,scene.camera.projection,canvasPos,origin,direction);return ray2WorldPos(origin,direction);};var buttonDown=false;var resetAction=function resetAction(){buttonDown=false;};var cleanup=function cleanup(){resetAction();canvas.removeEventListener("mousedown",onMouseDown);canvas.removeEventListener("mousemove",onMouseMove);viewer.cameraControl.off(onCameraControlRayMove);canvas.removeEventListener("mouseup",onMouseUp);};var startCanvasPos=math.vec2();var onMouseDown=function onMouseDown(event){if(event.which===1){copyCanvasPos(event,startCanvasPos);buttonDown=true;}};canvas.addEventListener("mousedown",onMouseDown);var onMouseMove=function onMouseMove(event){var canvasPos=copyCanvasPos(event,math.vec2());if(buttonDown&&math.distVec2(startCanvasPos,canvasPos)>moveTolerance){resetAction();onCancel();}};canvas.addEventListener("mousemove",onMouseMove);var onCameraControlRayMove=viewer.cameraControl.on("rayMove",function(event){var canvasPos=event.canvasPos;onChange(canvasPos,pickWorldPos(canvasPos));});var onMouseUp=function onMouseUp(event){if(event.which===1&&buttonDown){cleanup();var _canvasPos2=copyCanvasPos(event,math.vec2());onCommit(_canvasPos2,pickWorldPos(_canvasPos2));}};canvas.addEventListener("mouseup",onMouseUp);return cleanup;};};var touchPointSelector=function touchPointSelector(viewer,pointerCircle,ray2WorldPos){return function(onCancel,onChange,onCommit){var scene=viewer.scene;var canvas=scene.canvas.canvas;var longTouchTimeoutMs=300;var moveTolerance=20;var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.body,canvas,vec2);return vec2;};var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,scene.camera.projection,canvasPos,origin,direction);return ray2WorldPos(origin,direction);};var longTouchTimeout=null;var nop=function nop(){};var onSingleTouchMove=nop;var startTouchIdentifier;var resetAction=function resetAction(){pointerCircle.stop();clearTimeout(longTouchTimeout);viewer.cameraControl.active=true;onSingleTouchMove=nop;startTouchIdentifier=null;};var cleanup=function cleanup(){resetAction();canvas.removeEventListener("touchstart",onCanvasTouchStart);canvas.removeEventListener("touchmove",onCanvasTouchMove);canvas.removeEventListener("touchend",onCanvasTouchEnd);};var onCanvasTouchStart=function onCanvasTouchStart(event){var touches=event.touches;if(touches.length!==1){resetAction();onCancel();}else{var startTouch=touches[0];var startCanvasPos=copyCanvasPos(startTouch,math.vec2());var startWorldPos=pickWorldPos(startCanvasPos);if(startWorldPos){startTouchIdentifier=startTouch.identifier;onSingleTouchMove=function onSingleTouchMove(canvasPos){if(math.distVec2(startCanvasPos,canvasPos)>moveTolerance){resetAction();}};longTouchTimeout=setTimeout(function(){pointerCircle.start(startCanvasPos);longTouchTimeout=setTimeout(function(){pointerCircle.stop();viewer.cameraControl.active=false;onSingleTouchMove=function onSingleTouchMove(canvasPos){onChange(canvasPos,pickWorldPos(canvasPos));};onSingleTouchMove(startCanvasPos);},longTouchTimeoutMs);},250);}}};canvas.addEventListener("touchstart",onCanvasTouchStart,{passive:true});// canvas.addEventListener("touchcancel", e => console.log("touchcancel", e), {passive: true});
|
|
30239
30248
|
var onCanvasTouchMove=function onCanvasTouchMove(event){var touch=_toConsumableArray(event.changedTouches).find(function(e){return e.identifier===startTouchIdentifier;});if(touch){onSingleTouchMove(copyCanvasPos(touch,math.vec2()));}};canvas.addEventListener("touchmove",onCanvasTouchMove,{passive:true});var onCanvasTouchEnd=function onCanvasTouchEnd(event){var touch=_toConsumableArray(event.changedTouches).find(function(e){return e.identifier===startTouchIdentifier;});if(touch){cleanup();var _canvasPos3=copyCanvasPos(touch,math.vec2());onCommit(_canvasPos3,pickWorldPos(_canvasPos3));}};canvas.addEventListener("touchend",onCanvasTouchEnd,{passive:true});return cleanup;};};var planeIntersect=function planeIntersect(p0,n,origin,direction){var t=-(math.dotVec3(origin,n)-p0)/math.dotVec3(direction,n);{var worldPos=math.vec3();math.mulVec3Scalar(direction,t,worldPos);math.addVec3(origin,worldPos,worldPos);return worldPos;}};/**
|
|
30240
30249
|
* @desc Renders a transparent box between two 3D points.
|
|
30241
30250
|
*
|
|
@@ -30350,4 +30359,4 @@ o4===0&&onSegment(c,b,d))// c, d and b are collinear and b lies on segment cd
|
|
|
30350
30359
|
{return true;}}return false;};}();deactivatePointSelection=select3dPoint(function(){updatePointerLens(null);marker.update(null);wire&&wire.update(null);basePolygon.updateBase(markers.length>2?markers.map(function(m){return m.getWorldPos();}):null);},function(canvasPos,worldPos){var snappedFirst=markers.length>2&&getSnappedFirst(canvasPos);firstMarker&&firstMarker.setHighlighted(!!snappedFirst);updatePointerLens(snappedFirst?snappedFirst.canvasPos:canvasPos);marker.update(!snappedFirst&&worldPos);wire&&wire.update(snappedFirst?snappedFirst.worldPos:worldPos);if(markers.length>=2){var pos=markers.map(function(m){return m.getWorldPos();}).concat(snappedFirst?[]:[worldPos]);var inter=lastSegmentIntersects(pos.map(function(p){return[p[0],p[2]];}),snappedFirst);basePolygon.updateBase(inter?null:pos);}else basePolygon.updateBase(null);},function(canvasPos,worldPos){var snappedFirst=markers.length>2&&getSnappedFirst(canvasPos);var pos=markers.map(function(m){return m.getWorldPos();}).concat(snappedFirst?[]:[worldPos]);basePolygon.updateBase(pos);var pos2D=pos.map(function(p){return[p[0],p[2]];});if(markers.length>2&&lastSegmentIntersects(pos2D,snappedFirst)){cleanups.pop()();selectNextPoint(markers);}else if(snappedFirst){// `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
|
|
30351
30360
|
// This works around an unidentified bug somewhere around OcclusionLayer, that causes error
|
|
30352
30361
|
// [.WebGL-0x13400c47e00] GL_INVALID_OPERATION: Vertex buffer is not big enough for the draw call
|
|
30353
|
-
marker.update(worldPos);cleanups.forEach(function(c){return c();});onZoneCreated(zonesPlugin.createZone({id:math.createUUID(),geometry:{planeCoordinates:pos2D,altitude:zoneAltitude,height:zoneHeight},alpha:zoneAlpha,color:zoneColor}));}else{marker.update(worldPos);wire&&wire.update(worldPos);selectNextPoint(markers.concat(marker));}});})([]);return{closeSurface:function closeSurface(){throw"TODO";},deactivate:function deactivate(){deactivatePointSelection();cleanups.forEach(function(c){return c();});}};};var ZonesPolysurfaceMouseControl=/*#__PURE__*/function(_Component45){_inherits(ZonesPolysurfaceMouseControl,_Component45);var _super178=_createSuper(ZonesPolysurfaceMouseControl);function ZonesPolysurfaceMouseControl(zonesPlugin){var _this183;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,ZonesPolysurfaceMouseControl);_this183=_super178.call(this,zonesPlugin.viewer.scene);_this183.zonesPlugin=zonesPlugin;_this183.pointerLens=cfg.pointerLens;_this183._action=null;return _this183;}_createClass(ZonesPolysurfaceMouseControl,[{key:"active",get:function get(){return!!this._action;}},{key:"activate",value:function activate(zoneAltitude,zoneHeight,zoneColor,zoneAlpha){if(_typeof(zoneAltitude)==="object"&&zoneAltitude!==null){var params=zoneAltitude;var param=function param(name,defaultValue){if(name in params){return params[name];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+name;}};zoneAltitude=param("altitude");zoneHeight=param("height");zoneColor=param("color","#008000");zoneAlpha=param("alpha",0.5);}if(this._action){return;}var zonesPlugin=this.zonesPlugin;var viewer=zonesPlugin.viewer;var scene=viewer.scene;var self=this;var select3dPoint=mousePointSelector(viewer,function(origin,direction){return planeIntersect(zoneAltitude,math.vec3([0,1,0]),origin,direction);});(function rec(){self._action=startPolysurfaceZoneCreateUI(scene,zoneAltitude,zoneHeight,zoneColor,zoneAlpha,self.pointerLens,zonesPlugin,select3dPoint,function(zone){var reactivate=true;self._action={deactivate:function deactivate(){reactivate=false;}};self.fire("zoneEnd",zone);if(reactivate){rec();}});})();}},{key:"deactivate",value:function deactivate(){if(this._action){this._action.deactivate();this._action=null;}}},{key:"destroy",value:function destroy(){this.deactivate();_get(_getPrototypeOf(ZonesPolysurfaceMouseControl.prototype),"destroy",this).call(this);}}]);return ZonesPolysurfaceMouseControl;}(Component);var ZonesPolysurfaceTouchControl=/*#__PURE__*/function(_Component46){_inherits(ZonesPolysurfaceTouchControl,_Component46);var _super179=_createSuper(ZonesPolysurfaceTouchControl);function ZonesPolysurfaceTouchControl(zonesPlugin){var _this184;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,ZonesPolysurfaceTouchControl);_this184=_super179.call(this,zonesPlugin.viewer.scene);_this184.zonesPlugin=zonesPlugin;_this184.pointerLens=cfg.pointerLens;_this184.pointerCircle=new PointerCircle(zonesPlugin.viewer);_this184._action=null;return _this184;}_createClass(ZonesPolysurfaceTouchControl,[{key:"active",get:function get(){return!!this._action;}},{key:"activate",value:function activate(zoneAltitude,zoneHeight,zoneColor,zoneAlpha){if(_typeof(zoneAltitude)==="object"&&zoneAltitude!==null){var params=zoneAltitude;var param=function param(name,defaultValue){if(name in params){return params[name];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+name;}};zoneAltitude=param("altitude");zoneHeight=param("height");zoneColor=param("color","#008000");zoneAlpha=param("alpha",0.5);}if(this._action){return;}var zonesPlugin=this.zonesPlugin;var viewer=zonesPlugin.viewer;var scene=viewer.scene;var self=this;var select3dPoint=touchPointSelector(viewer,this.pointerCircle,function(origin,direction){return planeIntersect(zoneAltitude,math.vec3([0,1,0]),origin,direction);});(function rec(){self._action=startPolysurfaceZoneCreateUI(scene,zoneAltitude,zoneHeight,zoneColor,zoneAlpha,self.pointerLens,zonesPlugin,select3dPoint,function(zone){var reactivate=true;self._action={deactivate:function deactivate(){reactivate=false;}};self.fire("zoneEnd",zone);if(reactivate){rec();}});})();}},{key:"deactivate",value:function deactivate(){if(this._action){this._action.deactivate();this._action=null;}}},{key:"destroy",value:function destroy(){this.deactivate();_get(_getPrototypeOf(ZonesPolysurfaceTouchControl.prototype),"destroy",this).call(this);}}]);return ZonesPolysurfaceTouchControl;}(Component);var ZoneEditControl=/*#__PURE__*/function(_Component47){_inherits(ZoneEditControl,_Component47);var _super180=_createSuper(ZoneEditControl);function ZoneEditControl(zone,cfg,handleMouseEvents,handleTouchEvents){var _this185;_classCallCheck(this,ZoneEditControl);var viewer=zone.plugin.viewer;var scene=viewer.scene;_this185=_super180.call(this,scene);var altitude=zone._geometry.altitude;var dots=zone._geometry.planeCoordinates.map(function(planeCoord){var dotParent=scene.canvas.canvas.ownerDocument.body;var dot=new Dot3D(scene,{},dotParent,{fillColor:zone._color});dot.worldPos=math.vec3([planeCoord[0],altitude,planeCoord[1]]);dot.on("worldPos",function(){planeCoord[0]=dot.worldPos[0];planeCoord[1]=dot.worldPos[2];try{zone._rebuildMesh();}catch(e){if(zone._zoneMesh){zone._zoneMesh.destroy();zone._zoneMesh=null;}}});return dot;});var cleanupDrag=activateDraggableDots({viewer:viewer,handleMouseEvents:handleMouseEvents,handleTouchEvents:handleTouchEvents,pointerLens:cfg&&cfg.pointerLens,dots:dots,ray2WorldPos:function ray2WorldPos(orig,dir){return planeIntersect(altitude,math.vec3([0,1,0]),orig,dir);},onEnd:function onEnd(initPos,dot){if(zone._zoneMesh){_this185.fire("edited");}return!!zone._zoneMesh;}});var cleanup=function cleanup(){cleanupDrag();dots.forEach(function(d){return d.destroy();});};var destroyCb=zone.on("destroyed",cleanup);_this185._deactivate=function(){zone.off("destroyed",destroyCb);cleanup();};return _this185;}_createClass(ZoneEditControl,[{key:"deactivate",value:function deactivate(){this._deactivate();_get(_getPrototypeOf(ZoneEditControl.prototype),"destroy",this).call(this);}}]);return ZoneEditControl;}(Component);var ZoneEditMouseControl=/*#__PURE__*/function(_ZoneEditControl){_inherits(ZoneEditMouseControl,_ZoneEditControl);var _super181=_createSuper(ZoneEditMouseControl);function ZoneEditMouseControl(zone,cfg){_classCallCheck(this,ZoneEditMouseControl);return _super181.call(this,zone,cfg,true,false);}return _createClass(ZoneEditMouseControl);}(ZoneEditControl);var ZoneEditTouchControl=/*#__PURE__*/function(_ZoneEditControl2){_inherits(ZoneEditTouchControl,_ZoneEditControl2);var _super182=_createSuper(ZoneEditTouchControl);function ZoneEditTouchControl(zone,cfg){_classCallCheck(this,ZoneEditTouchControl);return _super182.call(this,zone,cfg,false,true);}return _createClass(ZoneEditTouchControl);}(ZoneEditControl);var ZoneTranslateControl=/*#__PURE__*/function(_Component48){_inherits(ZoneTranslateControl,_Component48);var _super183=_createSuper(ZoneTranslateControl);function ZoneTranslateControl(zone,cfg,handleMouseEvents,handleTouchEvents){var _this186;_classCallCheck(this,ZoneTranslateControl);var viewer=zone.plugin.viewer;var scene=viewer.scene;var canvas=scene.canvas.canvas;_this186=_super183.call(this,scene);var self=_assertThisInitialized(_this186);var altitude=zone._geometry.altitude;var pointerLens=cfg&&cfg.pointerLens;var updatePointerLens=pointerLens?function(canvasPos){pointerLens.visible=!!canvasPos;if(canvasPos){pointerLens.canvasPos=canvasPos;}}:function(){};var ray2WorldPos=function ray2WorldPos(orig,dir){return planeIntersect(altitude,math.vec3([0,1,0]),orig,dir);};var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,canvasPos,origin,direction);return ray2WorldPos(origin,direction);};var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.body,canvas,vec2);return vec2;};var canvasHandle=function canvasHandle(type,cb){var callback=function callback(event){event.preventDefault();cb(event);};canvas.addEventListener(type,callback);return function(){return canvas.removeEventListener(type,callback);};};var _cleanupCurrentDrag=function cleanupCurrentDrag(){};var startDrag=function startDrag(event,onMoveType,onEndType,matchesEvent){var e=matchesEvent(event);var canvasPos=copyCanvasPos(e,math.vec2());var pickRecord=viewer.scene.pick({canvasPos:canvasPos,includeEntities:[zone._zoneMesh.id]});var pickZone=pickRecord&&pickRecord.entity&&pickRecord.entity.zone;if(pickZone===zone){_cleanupCurrentDrag();canvas.style.cursor="move";viewer.cameraControl.active=false;var onChange=function(){var initCoords=zone._geometry.planeCoordinates.map(function(c){return c.slice();});var initWorldPos=pickWorldPos(canvasPos);var initDragCoord=math.vec2([initWorldPos[0],initWorldPos[2]]);var dPos=math.vec2();return function(canvasPos){var worldPos=pickWorldPos(canvasPos);dPos[0]=worldPos[0];dPos[1]=worldPos[2];math.subVec2(initDragCoord,dPos,dPos);zone._geometry.planeCoordinates.forEach(function(planeCoord,idx){math.subVec2(initCoords[idx],dPos,planeCoord);});try{zone._rebuildMesh();}catch(e){if(zone._zoneMesh){zone._zoneMesh.destroy();zone._zoneMesh=null;}}};}();var cleanupMove=canvasHandle(onMoveType,function(event){var e=matchesEvent(event);if(e){var _canvasPos4=copyCanvasPos(e,math.vec2());onChange(_canvasPos4);updatePointerLens(_canvasPos4);}});var cleanupEnd=canvasHandle(onEndType,function(event){var e=matchesEvent(event);if(e){var _canvasPos5=copyCanvasPos(e,math.vec2());onChange(_canvasPos5);updatePointerLens(null);_cleanupCurrentDrag();self.fire("translated");}});_cleanupCurrentDrag=function cleanupCurrentDrag(){_cleanupCurrentDrag=function cleanupCurrentDrag(){};canvas.style.cursor="default";viewer.cameraControl.active=true;cleanupMove();cleanupEnd();};}};var startDragCbs=[];if(handleMouseEvents){startDragCbs.push(canvasHandle("mousedown",function(event){if(event.which===1){startDrag(event,"mousemove","mouseup",function(event){return event.which===1&&event;});}}));}if(handleTouchEvents){startDragCbs.push(canvasHandle("touchstart",function(event){if(event.touches.length===1){var touchStartId=event.touches[0].identifier;startDrag(event,"touchmove","touchend",function(event){return _toConsumableArray(event.changedTouches).find(function(e){return e.identifier===touchStartId;});});}}));}var cleanup=function cleanup(){_cleanupCurrentDrag();startDragCbs.forEach(function(cb){return cb();});updatePointerLens(null);};var destroyCb=zone.on("destroyed",cleanup);_this186._deactivate=function(){zone.off("destroyed",destroyCb);cleanup();};return _this186;}_createClass(ZoneTranslateControl,[{key:"deactivate",value:function deactivate(){this._deactivate();_get(_getPrototypeOf(ZoneTranslateControl.prototype),"destroy",this).call(this);}}]);return ZoneTranslateControl;}(Component);var ZoneTranslateMouseControl=/*#__PURE__*/function(_ZoneTranslateControl){_inherits(ZoneTranslateMouseControl,_ZoneTranslateControl);var _super184=_createSuper(ZoneTranslateMouseControl);function ZoneTranslateMouseControl(zone,cfg){_classCallCheck(this,ZoneTranslateMouseControl);return _super184.call(this,zone,cfg,true,false);}return _createClass(ZoneTranslateMouseControl);}(ZoneTranslateControl);var ZoneTranslateTouchControl=/*#__PURE__*/function(_ZoneTranslateControl2){_inherits(ZoneTranslateTouchControl,_ZoneTranslateControl2);var _super185=_createSuper(ZoneTranslateTouchControl);function ZoneTranslateTouchControl(zone,cfg){_classCallCheck(this,ZoneTranslateTouchControl);return _super185.call(this,zone,cfg,false,true);}return _createClass(ZoneTranslateTouchControl);}(ZoneTranslateControl);export{AlphaFormat,AmbientLight,AngleMeasurementEditMouseControl,AngleMeasurementEditTouchControl,AngleMeasurementsControl,AngleMeasurementsMouseControl,AngleMeasurementsPlugin,AngleMeasurementsTouchControl,AnnotationsPlugin,AxisGizmoPlugin,BCFViewpointsPlugin,Bitmap,ByteType,CameraMemento,CameraPath,CameraPathAnimation,CityJSONLoaderPlugin,ClampToEdgeWrapping,Component,CompressedMediaType,Configs,ContextMenu,CubicBezierCurve,Curve,DefaultLoadingManager,DepthFormat,DepthStencilFormat,DirLight,DistanceMeasurementEditMouseControl,DistanceMeasurementEditTouchControl,DistanceMeasurementsControl,DistanceMeasurementsMouseControl,DistanceMeasurementsPlugin,DistanceMeasurementsTouchControl,DotBIMDefaultDataSource,DotBIMLoaderPlugin,EdgeMaterial,EmphasisMaterial,FaceAlignedSectionPlanesPlugin,FastNavPlugin,FloatType,Fresnel,Frustum$1 as Frustum,FrustumPlane,GIFMediaType,GLTFDefaultDataSource,GLTFLoaderPlugin,HalfFloatType,ImagePlane,IntType,JPEGMediaType,KTX2TextureTranscoder,LASLoaderPlugin,LambertMaterial,LightMap,LineSet,LinearEncoding,LinearFilter,LinearMipMapLinearFilter,LinearMipMapNearestFilter,LinearMipmapLinearFilter,LinearMipmapNearestFilter,Loader,LoadingManager,LocaleService,LuminanceAlphaFormat,LuminanceFormat,Map$1 as Map,Marker,MarqueePicker,MarqueePickerMouseControl,Mesh,MetallicMaterial,MirroredRepeatWrapping,ModelMemento,NavCubePlugin,NearestFilter,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NearestMipmapLinearFilter,NearestMipmapNearestFilter,Node$2 as Node,OBJLoaderPlugin,ObjectsKdTree3,ObjectsMemento,PNGMediaType,Path,PerformanceModel,PhongMaterial,PickResult,Plugin,PointLight,PointerCircle,PointerLens,QuadraticBezierCurve,Queue,RGBAFormat,RGBAIntegerFormat,RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format,RGBA_BPTC_Format,RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format,RGBFormat,RGB_ETC1_Format,RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format,RGFormat,RGIntegerFormat,ReadableGeometry,RedFormat,RedIntegerFormat,ReflectionMap,RepeatWrapping,STLDefaultDataSource,STLLoaderPlugin,SceneModel,SceneModelMesh,SceneModelTransform,SectionPlane,SectionPlanesPlugin,ShortType,Skybox,SkyboxesPlugin,SpecularMaterial,SplineCurve,SpriteMarker,StoreyViewsPlugin,Texture,TextureTranscoder,TreeViewPlugin,UnsignedByteType,UnsignedInt248Type,UnsignedIntType,UnsignedShort4444Type,UnsignedShort5551Type,UnsignedShortType,VBOGeometry,ViewCullPlugin,Viewer,WebIFCLoaderPlugin,WorkerPool$1 as WorkerPool,XKTDefaultDataSource,XKTLoaderPlugin,XML3DLoaderPlugin,ZoneEditControl,ZoneEditMouseControl,ZoneEditTouchControl,ZoneTranslateControl,ZoneTranslateMouseControl,ZoneTranslateTouchControl,ZonesMouseControl,ZonesPlugin,ZonesPolysurfaceMouseControl,ZonesPolysurfaceTouchControl,ZonesTouchControl,buildBoxGeometry,buildBoxLinesGeometry,buildBoxLinesGeometryFromAABB,buildCylinderGeometry,buildGridGeometry,buildLineGeometry,buildPlaneGeometry,buildPolylineGeometry,buildPolylineGeometryFromCurve,buildSphereGeometry,buildTorusGeometry,buildVectorTextGeometry,createRTCViewMat,frustumIntersectsAABB3,getKTX2TextureTranscoder,getPlaneRTCPos,load3DSGeometry,loadOBJGeometry,math,rtcToWorldPos,sRGBEncoding,setFrustum,stats,utils,worldToRTCPos,worldToRTCPositions};
|
|
30362
|
+
marker.update(worldPos);cleanups.forEach(function(c){return c();});onZoneCreated(zonesPlugin.createZone({id:math.createUUID(),geometry:{planeCoordinates:pos2D,altitude:zoneAltitude,height:zoneHeight},alpha:zoneAlpha,color:zoneColor}));}else{marker.update(worldPos);wire&&wire.update(worldPos);selectNextPoint(markers.concat(marker));}});})([]);return{closeSurface:function closeSurface(){throw"TODO";},deactivate:function deactivate(){deactivatePointSelection();cleanups.forEach(function(c){return c();});}};};var ZonesPolysurfaceMouseControl=/*#__PURE__*/function(_Component45){_inherits(ZonesPolysurfaceMouseControl,_Component45);var _super178=_createSuper(ZonesPolysurfaceMouseControl);function ZonesPolysurfaceMouseControl(zonesPlugin){var _this183;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,ZonesPolysurfaceMouseControl);_this183=_super178.call(this,zonesPlugin.viewer.scene);_this183.zonesPlugin=zonesPlugin;_this183.pointerLens=cfg.pointerLens;_this183._action=null;return _this183;}_createClass(ZonesPolysurfaceMouseControl,[{key:"active",get:function get(){return!!this._action;}},{key:"activate",value:function activate(zoneAltitude,zoneHeight,zoneColor,zoneAlpha){if(_typeof(zoneAltitude)==="object"&&zoneAltitude!==null){var params=zoneAltitude;var param=function param(name,defaultValue){if(name in params){return params[name];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+name;}};zoneAltitude=param("altitude");zoneHeight=param("height");zoneColor=param("color","#008000");zoneAlpha=param("alpha",0.5);}if(this._action){return;}var zonesPlugin=this.zonesPlugin;var viewer=zonesPlugin.viewer;var scene=viewer.scene;var self=this;var select3dPoint=mousePointSelector(viewer,function(origin,direction){return planeIntersect(zoneAltitude,math.vec3([0,1,0]),origin,direction);});(function rec(){self._action=startPolysurfaceZoneCreateUI(scene,zoneAltitude,zoneHeight,zoneColor,zoneAlpha,self.pointerLens,zonesPlugin,select3dPoint,function(zone){var reactivate=true;self._action={deactivate:function deactivate(){reactivate=false;}};self.fire("zoneEnd",zone);if(reactivate){rec();}});})();}},{key:"deactivate",value:function deactivate(){if(this._action){this._action.deactivate();this._action=null;}}},{key:"destroy",value:function destroy(){this.deactivate();_get(_getPrototypeOf(ZonesPolysurfaceMouseControl.prototype),"destroy",this).call(this);}}]);return ZonesPolysurfaceMouseControl;}(Component);var ZonesPolysurfaceTouchControl=/*#__PURE__*/function(_Component46){_inherits(ZonesPolysurfaceTouchControl,_Component46);var _super179=_createSuper(ZonesPolysurfaceTouchControl);function ZonesPolysurfaceTouchControl(zonesPlugin){var _this184;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,ZonesPolysurfaceTouchControl);_this184=_super179.call(this,zonesPlugin.viewer.scene);_this184.zonesPlugin=zonesPlugin;_this184.pointerLens=cfg.pointerLens;_this184.pointerCircle=new PointerCircle(zonesPlugin.viewer);_this184._action=null;return _this184;}_createClass(ZonesPolysurfaceTouchControl,[{key:"active",get:function get(){return!!this._action;}},{key:"activate",value:function activate(zoneAltitude,zoneHeight,zoneColor,zoneAlpha){if(_typeof(zoneAltitude)==="object"&&zoneAltitude!==null){var params=zoneAltitude;var param=function param(name,defaultValue){if(name in params){return params[name];}else if(defaultValue!==undefined){return defaultValue;}else{throw"config missing: "+name;}};zoneAltitude=param("altitude");zoneHeight=param("height");zoneColor=param("color","#008000");zoneAlpha=param("alpha",0.5);}if(this._action){return;}var zonesPlugin=this.zonesPlugin;var viewer=zonesPlugin.viewer;var scene=viewer.scene;var self=this;var select3dPoint=touchPointSelector(viewer,this.pointerCircle,function(origin,direction){return planeIntersect(zoneAltitude,math.vec3([0,1,0]),origin,direction);});(function rec(){self._action=startPolysurfaceZoneCreateUI(scene,zoneAltitude,zoneHeight,zoneColor,zoneAlpha,self.pointerLens,zonesPlugin,select3dPoint,function(zone){var reactivate=true;self._action={deactivate:function deactivate(){reactivate=false;}};self.fire("zoneEnd",zone);if(reactivate){rec();}});})();}},{key:"deactivate",value:function deactivate(){if(this._action){this._action.deactivate();this._action=null;}}},{key:"destroy",value:function destroy(){this.deactivate();_get(_getPrototypeOf(ZonesPolysurfaceTouchControl.prototype),"destroy",this).call(this);}}]);return ZonesPolysurfaceTouchControl;}(Component);var ZoneEditControl=/*#__PURE__*/function(_Component47){_inherits(ZoneEditControl,_Component47);var _super180=_createSuper(ZoneEditControl);function ZoneEditControl(zone,cfg,handleMouseEvents,handleTouchEvents){var _this185;_classCallCheck(this,ZoneEditControl);var viewer=zone.plugin.viewer;var scene=viewer.scene;_this185=_super180.call(this,scene);var altitude=zone._geometry.altitude;var dots=zone._geometry.planeCoordinates.map(function(planeCoord){var dotParent=scene.canvas.canvas.ownerDocument.body;var dot=new Dot3D(scene,{},dotParent,{fillColor:zone._color});dot.worldPos=math.vec3([planeCoord[0],altitude,planeCoord[1]]);dot.on("worldPos",function(){planeCoord[0]=dot.worldPos[0];planeCoord[1]=dot.worldPos[2];try{zone._rebuildMesh();}catch(e){if(zone._zoneMesh){zone._zoneMesh.destroy();zone._zoneMesh=null;}}});return dot;});var cleanupDrag=activateDraggableDots({viewer:viewer,handleMouseEvents:handleMouseEvents,handleTouchEvents:handleTouchEvents,pointerLens:cfg&&cfg.pointerLens,dots:dots,ray2WorldPos:function ray2WorldPos(orig,dir){return planeIntersect(altitude,math.vec3([0,1,0]),orig,dir);},onEnd:function onEnd(initPos,dot){if(zone._zoneMesh){_this185.fire("edited");}return!!zone._zoneMesh;}});var cleanup=function cleanup(){cleanupDrag();dots.forEach(function(d){return d.destroy();});};var destroyCb=zone.on("destroyed",cleanup);_this185._deactivate=function(){zone.off("destroyed",destroyCb);cleanup();};return _this185;}_createClass(ZoneEditControl,[{key:"deactivate",value:function deactivate(){this._deactivate();_get(_getPrototypeOf(ZoneEditControl.prototype),"destroy",this).call(this);}}]);return ZoneEditControl;}(Component);var ZoneEditMouseControl=/*#__PURE__*/function(_ZoneEditControl){_inherits(ZoneEditMouseControl,_ZoneEditControl);var _super181=_createSuper(ZoneEditMouseControl);function ZoneEditMouseControl(zone,cfg){_classCallCheck(this,ZoneEditMouseControl);return _super181.call(this,zone,cfg,true,false);}return _createClass(ZoneEditMouseControl);}(ZoneEditControl);var ZoneEditTouchControl=/*#__PURE__*/function(_ZoneEditControl2){_inherits(ZoneEditTouchControl,_ZoneEditControl2);var _super182=_createSuper(ZoneEditTouchControl);function ZoneEditTouchControl(zone,cfg){_classCallCheck(this,ZoneEditTouchControl);return _super182.call(this,zone,cfg,false,true);}return _createClass(ZoneEditTouchControl);}(ZoneEditControl);var ZoneTranslateControl=/*#__PURE__*/function(_Component48){_inherits(ZoneTranslateControl,_Component48);var _super183=_createSuper(ZoneTranslateControl);function ZoneTranslateControl(zone,cfg,handleMouseEvents,handleTouchEvents){var _this186;_classCallCheck(this,ZoneTranslateControl);var viewer=zone.plugin.viewer;var scene=viewer.scene;var canvas=scene.canvas.canvas;_this186=_super183.call(this,scene);var self=_assertThisInitialized(_this186);var altitude=zone._geometry.altitude;var pointerLens=cfg&&cfg.pointerLens;var updatePointerLens=pointerLens?function(canvasPos){pointerLens.visible=!!canvasPos;if(canvasPos){pointerLens.canvasPos=canvasPos;}}:function(){};var ray2WorldPos=function ray2WorldPos(orig,dir){return planeIntersect(altitude,math.vec3([0,1,0]),orig,dir);};var pickWorldPos=function pickWorldPos(canvasPos){var origin=math.vec3();var direction=math.vec3();math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,scene.camera.projection,canvasPos,origin,direction);return ray2WorldPos(origin,direction);};var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.body,canvas,vec2);return vec2;};var canvasHandle=function canvasHandle(type,cb){var callback=function callback(event){event.preventDefault();cb(event);};canvas.addEventListener(type,callback);return function(){return canvas.removeEventListener(type,callback);};};var _cleanupCurrentDrag=function cleanupCurrentDrag(){};var startDrag=function startDrag(event,onMoveType,onEndType,matchesEvent){var e=matchesEvent(event);var canvasPos=copyCanvasPos(e,math.vec2());var pickRecord=viewer.scene.pick({canvasPos:canvasPos,includeEntities:[zone._zoneMesh.id]});var pickZone=pickRecord&&pickRecord.entity&&pickRecord.entity.zone;if(pickZone===zone){_cleanupCurrentDrag();canvas.style.cursor="move";viewer.cameraControl.active=false;var onChange=function(){var initCoords=zone._geometry.planeCoordinates.map(function(c){return c.slice();});var initWorldPos=pickWorldPos(canvasPos);var initDragCoord=math.vec2([initWorldPos[0],initWorldPos[2]]);var dPos=math.vec2();return function(canvasPos){var worldPos=pickWorldPos(canvasPos);dPos[0]=worldPos[0];dPos[1]=worldPos[2];math.subVec2(initDragCoord,dPos,dPos);zone._geometry.planeCoordinates.forEach(function(planeCoord,idx){math.subVec2(initCoords[idx],dPos,planeCoord);});try{zone._rebuildMesh();}catch(e){if(zone._zoneMesh){zone._zoneMesh.destroy();zone._zoneMesh=null;}}};}();var cleanupMove=canvasHandle(onMoveType,function(event){var e=matchesEvent(event);if(e){var _canvasPos4=copyCanvasPos(e,math.vec2());onChange(_canvasPos4);updatePointerLens(_canvasPos4);}});var cleanupEnd=canvasHandle(onEndType,function(event){var e=matchesEvent(event);if(e){var _canvasPos5=copyCanvasPos(e,math.vec2());onChange(_canvasPos5);updatePointerLens(null);_cleanupCurrentDrag();self.fire("translated");}});_cleanupCurrentDrag=function cleanupCurrentDrag(){_cleanupCurrentDrag=function cleanupCurrentDrag(){};canvas.style.cursor="default";viewer.cameraControl.active=true;cleanupMove();cleanupEnd();};}};var startDragCbs=[];if(handleMouseEvents){startDragCbs.push(canvasHandle("mousedown",function(event){if(event.which===1){startDrag(event,"mousemove","mouseup",function(event){return event.which===1&&event;});}}));}if(handleTouchEvents){startDragCbs.push(canvasHandle("touchstart",function(event){if(event.touches.length===1){var touchStartId=event.touches[0].identifier;startDrag(event,"touchmove","touchend",function(event){return _toConsumableArray(event.changedTouches).find(function(e){return e.identifier===touchStartId;});});}}));}var cleanup=function cleanup(){_cleanupCurrentDrag();startDragCbs.forEach(function(cb){return cb();});updatePointerLens(null);};var destroyCb=zone.on("destroyed",cleanup);_this186._deactivate=function(){zone.off("destroyed",destroyCb);cleanup();};return _this186;}_createClass(ZoneTranslateControl,[{key:"deactivate",value:function deactivate(){this._deactivate();_get(_getPrototypeOf(ZoneTranslateControl.prototype),"destroy",this).call(this);}}]);return ZoneTranslateControl;}(Component);var ZoneTranslateMouseControl=/*#__PURE__*/function(_ZoneTranslateControl){_inherits(ZoneTranslateMouseControl,_ZoneTranslateControl);var _super184=_createSuper(ZoneTranslateMouseControl);function ZoneTranslateMouseControl(zone,cfg){_classCallCheck(this,ZoneTranslateMouseControl);return _super184.call(this,zone,cfg,true,false);}return _createClass(ZoneTranslateMouseControl);}(ZoneTranslateControl);var ZoneTranslateTouchControl=/*#__PURE__*/function(_ZoneTranslateControl2){_inherits(ZoneTranslateTouchControl,_ZoneTranslateControl2);var _super185=_createSuper(ZoneTranslateTouchControl);function ZoneTranslateTouchControl(zone,cfg){_classCallCheck(this,ZoneTranslateTouchControl);return _super185.call(this,zone,cfg,false,true);}return _createClass(ZoneTranslateTouchControl);}(ZoneTranslateControl);export{AlphaFormat,AmbientLight,AngleMeasurementEditMouseControl,AngleMeasurementEditTouchControl,AngleMeasurementsControl,AngleMeasurementsMouseControl,AngleMeasurementsPlugin,AngleMeasurementsTouchControl,AnnotationsPlugin,AxisGizmoPlugin,BCFViewpointsPlugin,Bitmap,ByteType,CameraMemento,CameraPath,CameraPathAnimation,CityJSONLoaderPlugin,ClampToEdgeWrapping,Component,CompressedMediaType,Configs,ContextMenu,CubicBezierCurve,Curve,DefaultLoadingManager,DepthFormat,DepthStencilFormat,DirLight,DistanceMeasurementEditMouseControl,DistanceMeasurementEditTouchControl,DistanceMeasurementsControl,DistanceMeasurementsMouseControl,DistanceMeasurementsPlugin,DistanceMeasurementsTouchControl,DotBIMDefaultDataSource,DotBIMLoaderPlugin,EdgeMaterial,EmphasisMaterial,FaceAlignedSectionPlanesPlugin,FastNavPlugin,FloatType,Fresnel,Frustum$1 as Frustum,FrustumPlane,GIFMediaType,GLTFDefaultDataSource,GLTFLoaderPlugin,HalfFloatType,ImagePlane,IntType,JPEGMediaType,KTX2TextureTranscoder,LASLoaderPlugin,LambertMaterial,LightMap,LineSet,LinearEncoding,LinearFilter,LinearMipMapLinearFilter,LinearMipMapNearestFilter,LinearMipmapLinearFilter,LinearMipmapNearestFilter,Loader,LoadingManager,LocaleService,LuminanceAlphaFormat,LuminanceFormat,Map$1 as Map,Marker,MarqueePicker,MarqueePickerMouseControl,Mesh,MetallicMaterial,MirroredRepeatWrapping,ModelMemento,NavCubePlugin,NearestFilter,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NearestMipmapLinearFilter,NearestMipmapNearestFilter,Node$2 as Node,OBJLoaderPlugin,ObjectsKdTree3,ObjectsMemento,PNGMediaType,Path,PerformanceModel,PhongMaterial,PickResult,Plugin,PointLight,PointerCircle,PointerLens,QuadraticBezierCurve,Queue,RGBAFormat,RGBAIntegerFormat,RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format,RGBA_BPTC_Format,RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format,RGBFormat,RGB_ETC1_Format,RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format,RGFormat,RGIntegerFormat,ReadableGeometry,RedFormat,RedIntegerFormat,ReflectionMap,RepeatWrapping,STLDefaultDataSource,STLLoaderPlugin,SceneModel,SceneModelMesh,SceneModelTransform,SectionPlane,SectionPlanesPlugin,ShortType,Skybox,SkyboxesPlugin,SpecularMaterial,SplineCurve,SpriteMarker,StoreyViewsPlugin,Texture,TextureTranscoder,TreeViewPlugin,UnsignedByteType,UnsignedInt248Type,UnsignedIntType,UnsignedShort4444Type,UnsignedShort5551Type,UnsignedShortType,VBOGeometry,ViewCullPlugin,Viewer,WebIFCLoaderPlugin,WorkerPool$1 as WorkerPool,XKTDefaultDataSource,XKTLoaderPlugin,XML3DLoaderPlugin,ZoneEditControl,ZoneEditMouseControl,ZoneEditTouchControl,ZoneTranslateControl,ZoneTranslateMouseControl,ZoneTranslateTouchControl,ZonesMouseControl,ZonesPlugin,ZonesPolysurfaceMouseControl,ZonesPolysurfaceTouchControl,ZonesTouchControl,buildBoxGeometry,buildBoxLinesGeometry,buildBoxLinesGeometryFromAABB,buildCylinderGeometry,buildGridGeometry,buildLineGeometry,buildPlaneGeometry,buildPolylineGeometry,buildPolylineGeometryFromCurve,buildSphereGeometry,buildTorusGeometry,buildVectorTextGeometry,createRTCViewMat,frustumIntersectsAABB3,getKTX2TextureTranscoder,getPlaneRTCPos,load3DSGeometry,loadOBJGeometry,math,rtcToWorldPos,sRGBEncoding,setFrustum,stats,utils,worldToRTCPos,worldToRTCPositions};
|