@xtctwins/tctwins-core 1.0.38 → 1.0.39

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.
@@ -22515,31 +22515,9 @@ if(configs.followPointer){var _dolliedThroughSurface2=panController.dollyToCanva
22515
22515
  //因此暂时在此加判断
22516
22516
  if(this.canvas!=null){this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler);this.canvas.removeEventListener("mouseleave",this._mouseLeaveHandler);this.canvas.removeEventListener("mousedown",this._mouseDownHandler);this.canvas.removeEventListener("mouseup",this._mouseUpHandler);}document.removeEventListener("mousemove",this._mouseMoveHandler);}}]);}();function getCanvasPosFromEvent$2(event,canvas,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var _canvas$getBoundingCl=canvas.getBoundingClientRect(),x=_canvas$getBoundingCl.x,y=_canvas$getBoundingCl.y;canvasPos[0]=event.clientX-x;canvasPos[1]=event.clientY-y;}return canvasPos;}var getCanvasPosFromEvent$1=function getCanvasPosFromEvent$1(event,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}canvasPos[0]=event.pageX-totalOffsetLeft;canvasPos[1]=event.pageY-totalOffsetTop;}return canvasPos;};/**
22517
22517
  * @private
22518
- */var TouchPanRotateAndDollyHandler=/*#__PURE__*/function(){function TouchPanRotateAndDollyHandler(scene,controllers,configs,states,updates){_classCallCheck(this,TouchPanRotateAndDollyHandler);this._scene=scene;var pickController=controllers.pickController;var pivotController=controllers.pivotController;var tapStartCanvasPos=math.vec2();var tapCanvasPos0=math.vec2();var tapCanvasPos1=math.vec2();var touch0Vec=math.vec2();var lastCanvasTouchPosList=[];this.canvas=this._scene.canvas.canvas;var numTouches=0;var waitForTick=false;this._onTick=scene.on("tick",function(){waitForTick=false;});this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(event){if(!(configs.active&&configs.pointerEnabled)){return;}if(!event.isTrusted)return;event.preventDefault();var touches=event.touches;var changedTouches=event.changedTouches;states.touchStartTime=Date.now();if(touches.length===1&&changedTouches.length===1){states.touchStartTime;getCanvasPosFromEvent$1(touches[0],tapStartCanvasPos);if(configs.followPointer){pickController.pickCursorPos=tapStartCanvasPos;pickController.schedulePickSurface=true;pickController.update();pivotController.setPivotPos(scene.camera.look);// if (!configs.planView) {
22519
- // if (
22520
- // pickController.picked &&
22521
- // pickController.pickedSurface &&
22522
- // pickController.pickResult &&
22523
- // pickController.pickResult.worldPos
22524
- // ) {
22525
- // // pivotController.setPivotPos(pickController.pickResult.worldPos);
22526
- // pivotController.setPivotPos(scene.camera.look);
22527
- // if (!configs.firstPerson && pivotController.startPivot()) {
22528
- // // pivotController.showPivot();
22529
- // }
22530
- // } else {
22531
- // if (configs.smartPivot) {
22532
- // pivotController.setPivotPos(scene.camera.look);
22533
- // // pivotController.setCanvasPivotPos(states.pointerCanvasPos);
22534
- // } else {
22535
- // pivotController.setPivotPos(scene.camera.look);
22536
- // }
22537
- // if (!configs.firstPerson && pivotController.startPivot()) {
22538
- // // pivotController.showPivot();
22539
- // }
22540
- // }
22541
- // }
22542
- }}while(lastCanvasTouchPosList.length<touches.length){lastCanvasTouchPosList.push(math.vec2());}for(var _i471=0,len=touches.length;_i471<len;++_i471){getCanvasPosFromEvent$1(touches[_i471],lastCanvasTouchPosList[_i471]);}numTouches=touches.length;});this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(){if(pivotController.getPivoting()){pivotController.endPivot();pivotController.hidePivot();}});this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler);this.canvas.addEventListener("touchmove",this._canvasTouchMoveHandler=function(event){if(!(configs.active&&configs.pointerEnabled)){return;}event.stopPropagation();event.preventDefault();if(waitForTick){// Limit changes detection to one per frame
22518
+ */var TouchPanRotateAndDollyHandler=/*#__PURE__*/function(){function TouchPanRotateAndDollyHandler(scene,controllers,configs,states,updates){_classCallCheck(this,TouchPanRotateAndDollyHandler);this._scene=scene;var pickController=controllers.pickController;var pivotController=controllers.pivotController;var tapStartCanvasPos=math.vec2();var tapCanvasPos0=math.vec2();var tapCanvasPos1=math.vec2();var touch0Vec=math.vec2();var lastCanvasTouchPosList=[];this.canvas=this._scene.canvas.canvas;var numTouches=0;var waitForTick=false;this._onTick=scene.on("tick",function(){waitForTick=false;});this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(event){if(!(configs.active&&configs.pointerEnabled)){return;}if(!event.isTrusted)return;event.preventDefault();var touches=event.touches;var changedTouches=event.changedTouches;states.touchStartTime=Date.now();if(touches.length===1&&changedTouches.length===1){states.touchStartTime;getCanvasPosFromEvent$1(touches[0],tapStartCanvasPos);if(configs.followPointer){pickController.pickCursorPos=tapStartCanvasPos;pickController.schedulePickSurface=true;pickController.update();pivotController.setPivotPos(scene.camera.look);if(!configs.planView){if(pickController.picked&&pickController.pickedSurface&&pickController.pickResult&&pickController.pickResult.worldPos){// pivotController.setPivotPos(pickController.pickResult.worldPos);
22519
+ pivotController.setPivotPos(scene.camera.look);if(!configs.firstPerson&&pivotController.startPivot());}else{if(configs.smartPivot){pivotController.setPivotPos(scene.camera.look);// pivotController.setCanvasPivotPos(states.pointerCanvasPos);
22520
+ }else{pivotController.setPivotPos(scene.camera.look);}if(!configs.firstPerson&&pivotController.startPivot());}}}}while(lastCanvasTouchPosList.length<touches.length){lastCanvasTouchPosList.push(math.vec2());}for(var _i471=0,len=touches.length;_i471<len;++_i471){getCanvasPosFromEvent$1(touches[_i471],lastCanvasTouchPosList[_i471]);}numTouches=touches.length;});this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(){if(pivotController.getPivoting()){pivotController.endPivot();pivotController.hidePivot();}});this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler);this.canvas.addEventListener("touchmove",this._canvasTouchMoveHandler=function(event){if(!(configs.active&&configs.pointerEnabled)){return;}event.stopPropagation();event.preventDefault();if(waitForTick){// Limit changes detection to one per frame
22543
22521
  return;}waitForTick=true;// Scaling drag-rotate to canvas boundary
22544
22522
  var canvasBoundary=scene.canvas.boundary;var canvasWidth=canvasBoundary[2];var canvasHeight=canvasBoundary[3];var touches=event.touches;if(event.touches.length!==numTouches){// Two fingers were pressed, then one of them is removed
22545
22523
  // We don't want to rotate in this case (weird behavior)
@@ -22564,7 +22542,7 @@ updates.rotateDeltaX+=yPanDelta/canvasHeight*(configs.dragRotationRate*1.5);// H
22564
22542
  // }
22565
22543
  }}else if(numTouches===2){pivotController.hidePivot();var touch0=touches[0];var touch1=touches[1];getCanvasPosFromEvent$1(touch0,tapCanvasPos0);getCanvasPosFromEvent$1(touch1,tapCanvasPos1);var lastMiddleTouch=math.geometricMeanVec2(lastCanvasTouchPosList[0],lastCanvasTouchPosList[1]);var currentMiddleTouch=math.geometricMeanVec2(tapCanvasPos0,tapCanvasPos1);var touchDelta=math.vec2();math.subVec2(lastMiddleTouch,currentMiddleTouch,touchDelta);var _xPanDelta=touchDelta[0];var _yPanDelta=touchDelta[1];var _camera2=scene.camera;// Dollying
22566
22544
  var d1=math.distVec2([touch0.pageX,touch0.pageY],[touch1.pageX,touch1.pageY]);var d2=math.distVec2(lastCanvasTouchPosList[0],lastCanvasTouchPosList[1]);var dollyDelta=(d2-d1)*configs.touchDollyRate;updates.dollyDelta=dollyDelta;if(Math.abs(dollyDelta)<1.0){// We use only canvasHeight here so that aspect ratio does not distort speed
22567
- if(_camera2.projection==="perspective"){var pickedWorldPos=pickController.pickResult?pickController.pickResult.worldPos:scene.center;var _depth=Math.abs(math.lenVec3(math.subVec3(pickedWorldPos,scene.camera.eye,[])));var _targetDistance=_depth*Math.tan(_camera2.perspective.fov/2*Math.PI/180.0);updates.panDeltaX-=_xPanDelta*_targetDistance/canvasHeight*configs.touchPanRate;updates.panDeltaY-=_yPanDelta*_targetDistance/canvasHeight*configs.touchPanRate;}else{updates.panDeltaX-=0.5*_camera2.ortho.scale*(_xPanDelta/canvasHeight)*configs.touchPanRate;updates.panDeltaY-=0.5*_camera2.ortho.scale*(_yPanDelta/canvasHeight)*configs.touchPanRate;}}states.pointerCanvasPos=currentMiddleTouch;}for(var _i472=0;_i472<numTouches;++_i472){getCanvasPosFromEvent$1(touches[_i472],lastCanvasTouchPosList[_i472]);}});}return _createClass(TouchPanRotateAndDollyHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler);this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler);this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler);this.canvas.removeEventListener("touchmove",this._canvasTouchMoveHandler);}this._scene.off(this._onTick);}}]);}();var TAP_INTERVAL=150;var DBL_TAP_INTERVAL=325;var TAP_DISTANCE_THRESHOLD=4;var getCanvasPosFromEvent=function getCanvasPosFromEvent(event,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}canvasPos[0]=event.pageX-totalOffsetLeft;canvasPos[1]=event.pageY-totalOffsetTop;}return canvasPos;};/**
22545
+ if(_camera2.projection==="perspective"){var pickedWorldPos=pickController.pickResult?pickController.pickResult.worldPos:scene.center;var _depth=Math.abs(math.lenVec3(math.subVec3(pickedWorldPos,scene.camera.eye,[])));var _targetDistance=_depth*Math.tan(_camera2.perspective.fov/2*Math.PI/180.0);updates.panDeltaX-=_xPanDelta*_targetDistance/canvasHeight*configs.touchPanRate;updates.panDeltaY-=_yPanDelta*_targetDistance/canvasHeight*configs.touchPanRate;}else{updates.panDeltaX-=0.5*_camera2.ortho.scale*(_xPanDelta/canvasHeight)*configs.touchPanRate;updates.panDeltaY-=0.5*_camera2.ortho.scale*(_yPanDelta/canvasHeight)*configs.touchPanRate;}}states.pointerCanvasPos=currentMiddleTouch;}for(var _i472=0;_i472<numTouches;++_i472){getCanvasPosFromEvent$1(touches[_i472],lastCanvasTouchPosList[_i472]);}});}return _createClass(TouchPanRotateAndDollyHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler);this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler);this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler);this.canvas.removeEventListener("touchmove",this._canvasTouchMoveHandler);}this._scene.off(this._onTick);}}]);}();var TAP_INTERVAL=150;var DBL_TAP_INTERVAL=325;var TAP_DISTANCE_THRESHOLD=1000;var getCanvasPosFromEvent=function getCanvasPosFromEvent(event,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}canvasPos[0]=event.pageX-totalOffsetLeft;canvasPos[1]=event.pageY-totalOffsetTop;}return canvasPos;};/**
22568
22546
  * @private
22569
22547
  */var TouchPickHandler=/*#__PURE__*/function(){function TouchPickHandler(scene,controllers,configs,states,updates){_classCallCheck(this,TouchPickHandler);this._scene=scene;var pickController=controllers.pickController;var cameraControl=controllers.cameraControl;var touchStartTime;var activeTouches=[];var tapStartPos=new Float32Array(2);var tapStartTime=-1;var lastTapTime=-1;this.canvas=this._scene.canvas.canvas;var flyCameraTo=function flyCameraTo(pickResult){var pos;if(pickResult&&pickResult.worldPos){pos=pickResult.worldPos;}var aabb=pickResult?pickResult.entity.aabb:scene.aabb;if(pos){// Fly to look at point, don't change eye->look dist
22570
22548
  var camera=scene.camera;math.subVec3(camera.eye,camera.look,[]);controllers.cameraFlight.flyTo({aabb:aabb});// TODO: Option to back off to fit AABB in view
@@ -22572,13 +22550,11 @@ var camera=scene.camera;math.subVec3(camera.eye,camera.look,[]);controllers.came
22572
22550
  controllers.cameraFlight.flyTo({aabb:aabb});}};this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(!e.isTrusted)return;if(states.longTouchTimeout!==null){clearTimeout(states.longTouchTimeout);states.longTouchTimeout=null;}var touches=e.touches;var changedTouches=e.changedTouches;touchStartTime=Date.now();if(touches.length===1&&changedTouches.length===1){tapStartTime=touchStartTime;// getCanvasPosFromEvent(touches[0], tapStartPos);
22573
22551
  var rightClickClientX=tapStartPos[0];var rightClickClientY=tapStartPos[1];var rightClickPageX=touches[0].pageX;var rightClickPageY=touches[0].pageY;states.longTouchTimeout=setTimeout(function(){controllers.cameraControl.fire("rightClick",{// For context menus
22574
22552
  pagePos:[Math.round(rightClickPageX),Math.round(rightClickPageY)],canvasPos:[Math.round(rightClickClientX),Math.round(rightClickClientY)],event:e},true);states.longTouchTimeout=null;},configs.longTapTimeout);//////////
22575
- var pickedSurfaceSubs=cameraControl.hasSubs("pickedSurface");getCanvasPosFromEvent(touches[0],pickController.pickCursorPos);pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){cameraControl.fire("touchEntity",pickController.pickResult);if(pickController.pickedSurface){cameraControl.fire("touchSurface",pickController.pickResult);}}else{cameraControl.fire("touchNothing");}// lastTapTime = currentTime;
22576
- tapStartTime=-1;}else{tapStartTime=-1;}///////////
22553
+ var pickedSurfaceSubs=cameraControl.hasSubs("pickedSurface");getCanvasPosFromEvent(touches[0],pickController.pickCursorPos);pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){cameraControl.fire("touchEntity",pickController.pickResult);if(pickController.pickedSurface){cameraControl.fire("touchSurface",pickController.pickResult);}}else{cameraControl.fire("touchNothing");}}else{tapStartTime=-1;}///////////
22577
22554
  while(activeTouches.length<touches.length){activeTouches.push(new Float32Array(2));}for(var _i473=0,len=touches.length;_i473<len;++_i473){getCanvasPosFromEvent(touches[_i473],activeTouches[_i473]);}activeTouches.length=touches.length;},{passive:true});this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}var currentTime=Date.now();var touches=e.touches;var changedTouches=e.changedTouches;var pickedSurfaceSubs=cameraControl.hasSubs("pickedSurface");if(states.longTouchTimeout!==null){clearTimeout(states.longTouchTimeout);states.longTouchTimeout=null;}// process tap
22578
- if(touches.length===0&&changedTouches.length===1){if(tapStartTime>-1&&currentTime-tapStartTime<TAP_INTERVAL){if(lastTapTime>-1&&tapStartTime-lastTapTime<DBL_TAP_INTERVAL){// Double-tap
22579
- getCanvasPosFromEvent(changedTouches[0],pickController.pickCursorPos);pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){pickController.pickResult.touchInput=true;cameraControl.fire("doublePicked",pickController.pickResult);cameraControl.fire("touchDoublePicked",pickController.pickResult);if(pickController.pickedSurface){cameraControl.fire("doublePickedSurface",pickController.pickResult);cameraControl.fire("touchDoublePickedSurface",pickController.pickResult);}if(configs.doublePickFlyTo){flyCameraTo(pickController.pickResult);}}else{cameraControl.fire("doublePickedNothing");cameraControl.fire("touchDoublePickedNothing");if(configs.doublePickFlyTo){flyCameraTo();}}lastTapTime=-1;}else if(math.distVec2(activeTouches[0],tapStartPos)<TAP_DISTANCE_THRESHOLD){// Single-tap
22580
- getCanvasPosFromEvent(changedTouches[0],pickController.pickCursorPos);pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){pickController.pickResult.touchInput=true;cameraControl.fire("picked",pickController.pickResult);cameraControl.fire("touchPicked",pickController.pickResult);if(pickController.pickedSurface){cameraControl.fire("pickedSurface",pickController.pickResult);cameraControl.fire("touchPickedSurface",pickController.pickResult);}}else{cameraControl.fire("pickedNothing");cameraControl.fire("touchPickedNothing");}lastTapTime=currentTime;}tapStartTime=-1;}}activeTouches.length=touches.length;for(var _i474=0,len=touches.length;_i474<len;++_i474){activeTouches[_i474][0]=touches[_i474].pageX;activeTouches[_i474][1]=touches[_i474].pageY;}// e.stopPropagation();
22581
- },{passive:true});this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler);}return _createClass(TouchPickHandler,[{key:"reset",value:function reset(){// TODO
22555
+ if(touches.length===0&&changedTouches.length===1){if(tapStartTime>-1&&currentTime-tapStartTime<TAP_INTERVAL){// Double-tap
22556
+ if(lastTapTime>-1&&tapStartTime-lastTapTime<DBL_TAP_INTERVAL){getCanvasPosFromEvent(changedTouches[0],pickController.pickCursorPos);pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){pickController.pickResult.touchInput=true;cameraControl.fire("doublePicked",pickController.pickResult);cameraControl.fire("touchDoublePicked",pickController.pickResult);if(pickController.pickedSurface){cameraControl.fire("doublePickedSurface",pickController.pickResult);cameraControl.fire("touchDoublePickedSurface",pickController.pickResult);}if(configs.doublePickFlyTo){flyCameraTo(pickController.pickResult);}}else{cameraControl.fire("doublePickedNothing");cameraControl.fire("touchDoublePickedNothing");if(configs.doublePickFlyTo){flyCameraTo();}}lastTapTime=-1;}// Single-tap
22557
+ else if(math.distVec2(activeTouches[0],tapStartPos)<TAP_DISTANCE_THRESHOLD){getCanvasPosFromEvent(changedTouches[0],pickController.pickCursorPos);pickController.schedulePickEntity=true;pickController.schedulePickSurface=pickedSurfaceSubs;pickController.update();if(pickController.pickResult){pickController.pickResult.touchInput=true;cameraControl.fire("picked",pickController.pickResult);cameraControl.fire("touchPicked",pickController.pickResult);if(pickController.pickedSurface){cameraControl.fire("pickedSurface",pickController.pickResult);cameraControl.fire("touchPickedSurface",pickController.pickResult);}}else{cameraControl.fire("pickedNothing");cameraControl.fire("touchPickedNothing");}lastTapTime=currentTime;}tapStartTime=-1;}}activeTouches.length=touches.length;for(var _i474=0,len=touches.length;_i474<len;++_i474){activeTouches[_i474][0]=touches[_i474].pageX;activeTouches[_i474][1]=touches[_i474].pageY;}e.stopPropagation();},{passive:true});this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler);}return _createClass(TouchPickHandler,[{key:"reset",value:function reset(){// TODO
22582
22558
  // tapStartTime = -1;
22583
22559
  // lastTapTime = -1;
22584
22560
  }},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler);this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler);this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler);}}}]);}();var DEFAULT_SNAP_PICK_RADIUS=20;var DEFAULT_SNAP_VERTEX=true;var DEFAULT_SNAP_EDGE=true;/**
@@ -23120,11 +23096,11 @@ _this115._configs={// Private
23120
23096
  longTapTimeout:600,// Millisecs
23121
23097
  longTapRadius:5,// Pixels
23122
23098
  // General
23123
- active:true,keyboardLayout:"qwerty",navMode:"orbit",planView:false,firstPerson:false,followPointer:true,doublePickFlyTo:true,panRightClick:true,showPivot:false,pointerEnabled:true,constrainVertical:false,smartPivot:false,doubleClickTimeFrame:250,snapToVertex:DEFAULT_SNAP_VERTEX,snapToEdge:DEFAULT_SNAP_EDGE,snapRadius:cfg.snapRadius?cfg.snapRadius:DEFAULT_SNAP_PICK_RADIUS,// Rotation
23099
+ active:true,keyboardLayout:"qwerty",navMode:"orbit",planView:false,firstPerson:false,followPointer:true,doublePickFlyTo:false,panRightClick:true,showPivot:false,pointerEnabled:true,constrainVertical:false,smartPivot:false,doubleClickTimeFrame:250,snapToVertex:DEFAULT_SNAP_VERTEX,snapToEdge:DEFAULT_SNAP_EDGE,snapRadius:cfg.snapRadius?cfg.snapRadius:DEFAULT_SNAP_PICK_RADIUS,// Rotation
23124
23100
  dragRotationRate:360.0,keyboardRotationRate:90.0,rotationInertia:0.0,// Panning
23125
23101
  keyboardPanRate:1.0,touchPanRate:1.0,panInertia:0.5,// Dollying
23126
23102
  keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:0.2,dollyInertia:0,dollyProximityThreshold:30.0,dollyMinSpeed:0.04};// Current runtime state of the CameraControl
23127
- _this115._states={pointerCanvasPos:math.vec2(),mouseover:false,followPointerDirty:true,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:math.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null};// Updates for CameraUpdater to process on next Scene "tick" event
23103
+ _this115._states={pointerCanvasPos:math.vec2(),mouseover:false,followPointerDirty:true,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,touchEndTime:null,activeTouches:[],tapStartPos:math.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null};// Updates for CameraUpdater to process on next Scene "tick" event
23128
23104
  _this115._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};// Controllers to assist input event handlers with controlling the Camera
23129
23105
  var scene=_this115.scene;_this115._controllers={cameraControl:_this115,pickController:new PickController(_this115,_this115._configs),pivotController:new PivotController(scene,_this115._configs),panController:new PanController(scene),cameraFlight:new CameraFlightAnimation(_this115,{duration:0.5})};// Input event handlers
23130
23106
  _this115._handlers=[new MouseMiscHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates),new TouchPanRotateAndDollyHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates),new MousePanRotateDollyHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates),new KeyboardAxisViewHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates),new MousePickHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates),new TouchPickHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates),new KeyboardPanRotateDollyHandler(_this115.scene,_this115._controllers,_this115._configs,_this115._states,_this115._updates)];// Applies scheduled updates to the Camera on each Scene "tick" event
@@ -14,7 +14,7 @@ var e;function n(e){var t="function"==typeof Map?new Map:void 0;return n=functio
14
14
  /**
15
15
  * @author https://github.com/tmarti, with support from https://tribia.com/
16
16
  * @license MIT
17
- **/var Gf=8,kf=null;function Vf(e,n){var t,i,r,l,a,s,u=3*e,o=3*n,c=Math.min(t=kf[u],i=kf[u+1],r=kf[u+2]),f=Math.min(l=kf[o],a=kf[o+1],s=kf[o+2]);if(c!==f)return c-f;var p=Math.max(t,i,r),d=Math.max(l,a,s);return p!==d?p-d:0}var jf=null;function Qf(e,n){var t=jf[2*e]-jf[2*n];return 0!==t?t:jf[2*e+1]-jf[2*n+1]}function Wf(e,n){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.positionsCompressed||[],r=function(e,n){for(var t=new Int32Array(e.length/3),i=0,r=t.length;i<r;i++)t[i]=i;kf=new Int32Array(e.length);for(var l=0,a=e.length;l<a;l++)kf[l]=e[l]>>n;t.sort(Vf);for(var s=new Int32Array(e.length),u=0,o=t.length;u<o;u++)s[3*u+0]=e[3*t[u]+0],s[3*u+1]=e[3*t[u]+1],s[3*u+2]=e[3*t[u]+2];return s}(e.indices||[],n),l=function(e){if(0===(e||[]).length)return[];for(var n=new Int32Array(e.length/2),t=0,i=n.length;t<i;t++)n[t]=t;for(var r=0,l=e.length;r<l;r+=2)if(e[r]>e[r+1]){var a=e[r];e[r]=e[r+1],e[r+1]=a}jf=new Int32Array(e),n.sort(Qf);for(var s=new Int32Array(e.length),u=0,o=n.length;u<o;u++)s[2*u+0]=e[2*n[u]+0],s[2*u+1]=e[2*n[u]+1];return s}(e.edgeIndices||[]);function a(e,n){if(e>n){var t=e;e=n,n=t}function i(t,i){return t!==e?e-t:i!==n?n-i:0}for(var r=0,a=(l.length>>1)-1;r<=a;){var s=a+r>>1,u=i(l[2*s],l[2*s+1]);if(u>0)r=s+1;else{if(!(u<0))return s;a=s-1}}return-r-1}var s=new Int32Array(l.length/2);s.fill(0);var u=i.length/3;if(u>(1<<n)*Gf)return[e];var o=new Int32Array(u);o.fill(-1);var c=[];function f(){o.fill(-1);var e={positionsCompressed:[],indices:[],edgeIndices:[],maxNumPositions:(1<<n)-n,numPositions:0,bucketNumber:c.length};return c.push(e),e}for(var p=f(),d=0,v=r.length;d<v;d+=3){var A=0,h=r[d],I=r[d+1],y=r[d+2];if(-1===o[h]&&A++,-1===o[I]&&A++,-1===o[y]&&A++,A+p.numPositions>p.maxNumPositions&&(p=f()),p.bucketNumber>Gf)return[e];-1===o[h]&&(o[h]=p.numPositions++,p.positionsCompressed.push(i[3*h]),p.positionsCompressed.push(i[3*h+1]),p.positionsCompressed.push(i[3*h+2])),-1===o[I]&&(o[I]=p.numPositions++,p.positionsCompressed.push(i[3*I]),p.positionsCompressed.push(i[3*I+1]),p.positionsCompressed.push(i[3*I+2])),-1===o[y]&&(o[y]=p.numPositions++,p.positionsCompressed.push(i[3*y]),p.positionsCompressed.push(i[3*y+1]),p.positionsCompressed.push(i[3*y+2])),p.indices.push(o[h]),p.indices.push(o[I]),p.indices.push(o[y]);var m=void 0;(m=a(h,I))>=0&&0===s[m]&&(s[m]=1,p.edgeIndices.push(o[l[2*m]]),p.edgeIndices.push(o[l[2*m+1]])),(m=a(h,y))>=0&&0===s[m]&&(s[m]=1,p.edgeIndices.push(o[l[2*m]]),p.edgeIndices.push(o[l[2*m+1]])),(m=a(I,y))>=0&&0===s[m]&&(s[m]=1,p.edgeIndices.push(o[l[2*m]]),p.edgeIndices.push(o[l[2*m+1]]))}var w=n/8*2,g=n/8,E=2*i.length+(r.length+l.length)*w,T=0;i.length;return c.forEach((function(e){T+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*g,e.positionsCompressed.length/3})),T>E?[e]:(t&&function(e,n){var t={};e.forEach((function(e){for(var n=e.indices,i=e.edgeIndices,r=e.positionsCompressed,l=0,a=n.length;l<a;l+=3){var s=r[3*n[l]]+"_"+r[3*n[l]+1]+"_"+r[3*n[l]+2]+"/"+r[3*n[l+1]]+"_"+r[3*n[l+1]+1]+"_"+r[3*n[l+1]+2]+"/"+r[3*n[l+2]]+"_"+r[3*n[l+2]+1]+"_"+r[3*n[l+2]+2];t[s]=!0}e.edgeIndices.length/2;for(var u=0,o=i.length;u<o;u+=2)r[3*i[u]],r[3*i[u]+1],r[3*i[u]+2],r[3*i[u+1]],r[3*i[u+1]+1],r[3*i[u+1]+2]}));var i=n.indices;n.edgeIndices;for(var r=n.positionsCompressed,l=0,a=i.length;l<a;l+=3){var s=r[3*i[l]]+"_"+r[3*i[l]+1]+"_"+r[3*i[l]+2]+"/"+r[3*i[l+1]]+"_"+r[3*i[l+1]+1]+"_"+r[3*i[l+1]+2]+"/"+r[3*i[l+2]]+"_"+r[3*i[l+2]+1]+"_"+r[3*i[l+2]+2];if(!(s in t))throw console.log("Not found "+s),"Ohhhh!"}}(c,e),c)}var zf=$.vec4(4),Yf=$.vec4(),Kf=$.vec4(),Xf=$.vec3([1,0,0]),qf=$.vec3([0,1,0]),Jf=$.vec3([0,0,1]);$.vec3(3),$.vec3(3);var Zf=$.identityMat4(),$f=function(){return C((function e(n){T(this,e),this._model=n.model,this.id=n.id,this._parentTransform=n.parent,this._childTransforms=[],this._meshes=[],this._scale=new Float32Array([1,1,1]),this._quaternion=$.identityQuaternion(new Float32Array(4)),this._rotation=new Float32Array(3),this._position=new Float32Array(3),this._localMatrix=$.identityMat4(new Float32Array(16)),this._worldMatrix=$.identityMat4(new Float32Array(16)),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,n.matrix?this.matrix=n.matrix:(this.scale=n.scale,this.position=n.position,n.quaternion||(this.rotation=n.rotation)),n.parent&&n.parent._addChildTransform(this)}),[{key:"_addChildTransform",value:function(e){this._childTransforms.push(e),e._parentTransform=this,e._setWorldMatrixDirty(),e._setAABBDirty()}},{key:"_addMesh",value:function(e){this._meshes.push(e),e.transform=this}},{key:"parentTransform",get:function(){return this._parentTransform}},{key:"meshes",get:function(){return this._meshes}},{key:"position",get:function(){return this._position},set:function(e){this._position.set(e||[0,0,0]),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation.set(e||[0,0,0]),$.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"quaternion",get:function(){return this._quaternion},set:function(e){this._quaternion.set(e||[0,0,0,1]),$.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"scale",get:function(){return this._scale},set:function(e){this._scale.set(e||[1,1,1]),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"matrix",get:function(){return this._localMatrixDirty&&(this._localMatrix||(this._localMatrix=$.identityMat4()),$.composeMat4(this._position,this._quaternion,this._scale,this._localMatrix),this._localMatrixDirty=!1),this._localMatrix},set:function(e){this._localMatrix||(this._localMatrix=$.identityMat4()),this._localMatrix.set(e||Zf),$.decomposeMat4(this._localMatrix,this._position,this._quaternion,this._scale),this._localMatrixDirty=!1,this._transformDirty(),this._model.glRedraw()}},{key:"worldMatrix",get:function(){return this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldMatrix}},{key:"rotate",value:function(e,n){return zf[0]=e[0],zf[1]=e[1],zf[2]=e[2],zf[3]=n*$.DEGTORAD,$.angleAxisToQuaternion(zf,Yf),$.mulQuaternions(this.quaternion,Yf,Kf),this.quaternion=Kf,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"rotateOnWorldAxis",value:function(e,n){return zf[0]=e[0],zf[1]=e[1],zf[2]=e[2],zf[3]=n*$.DEGTORAD,$.angleAxisToQuaternion(zf,Yf),$.mulQuaternions(Yf,this.quaternion,Yf),this}},{key:"rotateX",value:function(e){return this.rotate(Xf,e)}},{key:"rotateY",value:function(e){return this.rotate(qf,e)}},{key:"rotateZ",value:function(e){return this.rotate(Jf,e)}},{key:"translate",value:function(e){return this._position[0]+=e[0],this._position[1]+=e[1],this._position[2]+=e[2],this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"translateX",value:function(e){return this._position[0]+=e,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"translateY",value:function(e){return this._position[1]+=e,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"translateZ",value:function(e){return this._position[2]+=e,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"_setLocalMatrixDirty",value:function(){this._localMatrixDirty=!0,this._transformDirty()}},{key:"_transformDirty",value:function(){this._worldMatrixDirty=!0;for(var e=0,n=this._childTransforms.length;e<n;e++){var t=this._childTransforms[e];if(t._transformDirty(),t._meshes&&t._meshes.length>0)for(var i=t._meshes,r=0,l=i.length;r<l;r++)i[r]._transformDirty()}if(this._meshes&&this._meshes.length>0)for(var a=this._meshes,s=0,u=a.length;s<u;s++)a[s]._transformDirty()}},{key:"_buildWorldMatrix",value:function(){var e=this.matrix;if(this._parentTransform)$.mulMat4(this._parentTransform.worldMatrix,e,this._worldMatrix);else for(var n=0,t=e.length;n<t;n++)this._worldMatrix[n]=e[n];this._worldMatrixDirty=!1}},{key:"_setSubtreeAABBsDirty",value:function(e){if(e._aabbDirty=!0,e._childTransforms)for(var n=0,t=e._childTransforms.length;n<t;n++)this._setSubtreeAABBsDirty(e._childTransforms[n])}}])}(),ep=$.vec3(),np=$.OBB3(),tp=$.vec3([1,1,1]),ip=$.vec3([0,0,0]),rp=$.vec3([0,0,0]),lp=$.identityQuaternion(),ap=$.identityMat4(),sp="defaultColorTexture",up="defaultMetalRoughTexture",op="defaultNormalsTexture",cp="defaultEmissiveTexture",fp="defaultOcclusionTexture",pp="defaultTextureSet",dp=new Uint8Array([255,255,255]),vp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._dtxEnabled=t.scene.dtxEnabled&&!1!==i.dtxEnabled,t._enableVertexWelding=!1,t._enableIndexBucketing=!1,t._vboBatchingLayerScratchMemory=(ta++,na),t._textureTranscoder=i.textureTranscoder||Mf(t.scene.viewer),t._maxGeometryBatchSize=i.maxGeometryBatchSize,t._aabb=$.collapseAABB3(),t._aabbDirty=!0,t._aabbUpdate=!1,t._exceptionIds=[],t._quantizationRanges={},t._vboInstancingLayers={},t._vboBatchingLayers={},t._dtxLayers={},t.layerList=[],t._entityList=[],t._geometries={},t._dtxBuckets={},t._textures={},t._textureSets={},t._transforms={},t._meshes={},t._entities={},t._scheduledMeshes={},t._meshesCfgsBeforeMeshCreation={},t.renderFlags=new Kr,t.numGeometries=0,t.numPortions=0,t.numVisibleLayerPortions=0,t.numTransparentLayerPortions=0,t.numXRayedLayerPortions=0,t.numHighlightedLayerPortions=0,t.numSelectedLayerPortions=0,t.numEdgesLayerPortions=0,t.numPickableLayerPortions=0,t.numClippableLayerPortions=0,t.numCulledLayerPortions=0,t.numEntities=0,t._numTriangles=0,t._numLines=0,t._numPoints=0,t._edgeThreshold=i.edgeThreshold||10,t._origin=$.vec3(i.origin||[0,0,0]),t._position=$.vec3(i.position||[0,0,0]),t._rotation=$.vec3(i.rotation||[0,0,0]),t._quaternion=$.vec4(i.quaternion||[0,0,0,1]),t._conjugateQuaternion=$.vec4(i.quaternion||[0,0,0,1]),i.rotation&&$.eulerToQuaternion(t._rotation,"XYZ",t._quaternion),t._scale=$.vec3(i.scale||[1,1,1]),t._worldRotationMatrix=$.mat4(),t._worldRotationMatrixConjugate=$.mat4(),t._matrix=$.mat4(),t._matrixDirty=!0,t._rebuildMatrices(),t._worldNormalMatrix=$.mat4(),$.inverseMat4(t._matrix,t._worldNormalMatrix),$.transposeMat4(t._worldNormalMatrix),(i.matrix||i.position||i.rotation||i.scale||i.quaternion)&&(t._viewMatrix=$.mat4(),t._viewNormalMatrix=$.mat4(),t._viewMatrixDirty=!0,t._matrixNonIdentity=!0),t._opacity=1,t._colorize=[1,1,1],t._saoEnabled=!1!==i.saoEnabled,t._pbrEnabled=!1!==i.pbrEnabled,t._colorTextureEnabled=!1!==i.colorTextureEnabled,t._isModel=i.isModel,t._isModel&&t.scene._registerModel(t),t._onCameraViewMatrix=t.scene.camera.on("matrix",(function(){t._viewMatrixDirty=!0})),t._meshesWithDirtyMatrices=[],t._numMeshesWithDirtyMatrices=0,t._onTick=t.scene.on("tick",(function(){for(;t._numMeshesWithDirtyMatrices>0;)t._meshesWithDirtyMatrices[--t._numMeshesWithDirtyMatrices]._updateMatrix()})),t._createDefaultTextureSet(),t.visible=i.visible,t.culled=i.culled,t.pickable=i.pickable,t.clippable=i.clippable,t.collidable=i.collidable,t.castsShadow=i.castsShadow,t.receivesShadow=i.receivesShadow,t.xrayed=i.xrayed,t.highlighted=i.highlighted,t.selected=i.selected,t.edges=i.edges,t.colorize=i.colorize,t.opacity=i.opacity,t.backfaces=i.backfaces,t}return m(n,me),C(n,[{key:"_meshMatrixDirty",value:function(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}},{key:"_createDefaultTextureSet",value:function(){var e=new bf({id:sp,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),n=new bf({id:up,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),t=new bf({id:op,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),i=new bf({id:cp,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new bf({id:fp,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures[sp]=e,this._textures[up]=n,this._textures[op]=t,this._textures[cp]=i,this._textures[fp]=r,this._textureSets[pp]=new Tf({id:pp,model:this,colorTexture:e,metallicRoughnessTexture:n,normalsTexture:t,emissiveTexture:i,occlusionTexture:r})}},{key:"isPerformanceModel",get:function(){return!0}},{key:"transforms",get:function(){return this._transforms}},{key:"textures",get:function(){return this._textures}},{key:"textureSets",get:function(){return this._textureSets}},{key:"meshes",get:function(){return this._meshes}},{key:"objects",get:function(){return this._entities}},{key:"origin",get:function(){return this._origin}},{key:"position",get:function(){return this._position},set:function(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation.set(e||[0,0,0]),$.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"quaternion",get:function(){return this._quaternion},set:function(e){this._quaternion.set(e||[0,0,0,1]),$.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"scale",get:function(){return this._scale},set:function(e){}},{key:"matrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix},set:function(e){this._matrix.set(e||ap),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotationMatrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}},{key:"_rebuildMatrices",value:function(){this._matrixDirty&&($.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}},{key:"rotationMatrixConjugate",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}},{key:"_setWorldMatrixDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0}},{key:"_transformDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}},{key:"_sceneModelDirty",value:function(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(var e=0,n=this._entityList.length;e<n;e++)this._entityList[e]._sceneModelDirty()}},{key:"worldMatrix",get:function(){return this.matrix}},{key:"worldNormalMatrix",get:function(){return this._worldNormalMatrix}},{key:"viewMatrix",get:function(){return this._viewMatrix?(this._matrixDirty&&(this._rebuildMatrices(),this._viewMatrixDirty=!0),this._viewMatrixDirty&&($.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),$.inverseMat4(this._viewMatrix,this._viewNormalMatrix),$.transposeMat4(this._viewNormalMatrix),this._viewMatrixDirty=!1),this._viewMatrix):this.scene.camera.viewMatrix}},{key:"viewNormalMatrix",get:function(){return this._viewNormalMatrix?(this._matrixDirty&&(this._rebuildMatrices(),this._viewMatrixDirty=!0),this._viewMatrixDirty&&($.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),$.inverseMat4(this._viewMatrix,this._viewNormalMatrix),$.transposeMat4(this._viewNormalMatrix),this._viewMatrixDirty=!1),$.inverseMat4(this._viewMatrix,this._viewNormalMatrix),$.transposeMat4(this._viewNormalMatrix),this._viewNormalMatrix):this.scene.camera.viewNormalMatrix}},{key:"backfaces",get:function(){return this._backfaces},set:function(e){e=!!e,this._backfaces=e,this.glRedraw()}},{key:"entityList",get:function(){return this._entityList}},{key:"isEntity",get:function(){return!0}},{key:"isModel",get:function(){return this._isModel}},{key:"isObject",get:function(){return!1}},{key:"aabb",get:function(){if(this._aabbDirty){if(this._aabbUpdate)return this._aabb;if(this._exceptionIds.length>0)this.updateAABBCullException(this._exceptionIds);else{$.collapseAABB3(this._aabb);for(var e=0,n=this._entityList.length;e<n;e++)$.expandAABB3(this._aabb,this._entityList[e].aabb)}this._aabbDirty=!1}return this._aabb}},{key:"exceptionIds",get:function(){return this._exceptionIds},set:function(e){this._exceptionIds=e,this._aabbDirty=!0,this._aabbUpdate=!1,this.scene._setAABBDirty()}},{key:"updateAABBCullException",value:function(e,n){function t(n){var t=!0;return e.forEach((function(e){e===n&&(t=!1)})),t}for(var i=$.collapseAABB3(),r=0,l=this._entityList.length;r<l;r++)t(this._entityList[r].id)&&$.expandAABB3(i,this._entityList[r].aabb);for(var a=0;a<i.length;a++)this._aabb[a]=i[a];this._aabbDirty=!1,this._aabbUpdate=!0,this.scene._setAABBDirty(),"function"==typeof n&&n()}},{key:"cancelCullException",value:function(e){this._exceptionIds=[],this._aabbDirty=!0,this._aabbUpdate=!1,this.aabb,this.scene._aabbUpdate=!1,this.scene._setAABBDirty(),"function"==typeof e&&e()}},{key:"aabbs",get:function(){for(var e=[],n=0,t=this._entityList.length;n<t;n++)e.push(this._entityList[n].aabb);return e}},{key:"numTriangles",get:function(){return this._numTriangles}},{key:"numLines",get:function(){return this._numLines}},{key:"numPoints",get:function(){return this._numPoints}},{key:"visible",get:function(){return this.numVisibleLayerPortions>0},set:function(e){e=!1!==e,this._visible=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].visible=e;this.glRedraw()}},{key:"xrayed",get:function(){return this.numXRayedLayerPortions>0},set:function(e){e=!!e,this._xrayed=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].xrayed=e;this.glRedraw()}},{key:"highlighted",get:function(){return this.numHighlightedLayerPortions>0},set:function(e){e=!!e,this._highlighted=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].highlighted=e;this.glRedraw()}},{key:"selected",get:function(){return this.numSelectedLayerPortions>0},set:function(e){e=!!e,this._selected=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].selected=e;this.glRedraw()}},{key:"edges",get:function(){return this.numEdgesLayerPortions>0},set:function(e){e=!!e,this._edges=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].edges=e;this.glRedraw()}},{key:"culled",get:function(){return this._culled},set:function(e){e=!!e,this._culled=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].culled=e;this.glRedraw()}},{key:"clippable",get:function(){return this._clippable},set:function(e){e=!1!==e,this._clippable=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].clippable=e;this.glRedraw()}},{key:"collidable",get:function(){return this._collidable},set:function(e){e=!1!==e,this._collidable=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].collidable=e}},{key:"pickable",get:function(){return this.numPickableLayerPortions>0},set:function(e){e=!1!==e,this._pickable=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].pickable=e}},{key:"colorize",get:function(){return this._colorize},set:function(e){this._colorize=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].colorize=e}},{key:"opacity",get:function(){return this._opacity},set:function(e){this._opacity=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].opacity=e}},{key:"castsShadow",get:function(){return this._castsShadow},set:function(e){(e=!1!==e)!==this._castsShadow&&(this._castsShadow=e,this.glRedraw())}},{key:"receivesShadow",get:function(){return this._receivesShadow},set:function(e){(e=!1!==e)!==this._receivesShadow&&(this._receivesShadow=e,this.glRedraw())}},{key:"saoEnabled",get:function(){return this._saoEnabled}},{key:"pbrEnabled",get:function(){return this._pbrEnabled}},{key:"colorTextureEnabled",get:function(){return this._colorTextureEnabled}},{key:"isDrawable",get:function(){return!0}},{key:"isStateSortable",get:function(){return!1}},{key:"xrayMaterial",get:function(){return this.scene.xrayMaterial}},{key:"highlightMaterial",get:function(){return this.scene.highlightMaterial}},{key:"selectedMaterial",get:function(){return this.scene.selectedMaterial}},{key:"edgeMaterial",get:function(){return this.scene.edgeMaterial}},{key:"getPickViewMatrix",value:function(e){return this._viewMatrix?this._viewMatrix:e}},{key:"createQuantizationRange",value:function(e){void 0!==e.id&&null!==e.id?e.aabb?this.error("[createQuantizationRange] Config missing: aabb"):this._quantizationRanges[e.id]?this.error("[createQuantizationRange] QuantizationRange already created: "+e.id):this._quantizationRanges[e.id]={id:e.id,aabb:e.aabb,matrix:qa(e.aabb,$.mat4())}:this.error("[createQuantizationRange] Config missing: id")}},{key:"createGeometry",value:function(e){if(void 0!==e.id&&null!==e.id)if(this._geometries[e.id])this.error("[createGeometry] Geometry already created: "+e.id);else if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"===e.primitive||"lines"===e.primitive||"triangles"===e.primitive||"solid"===e.primitive||"surface"===e.primitive){if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("[createGeometry] Param expected: `positions`, `positionsCompressed' or 'buckets"),null;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("[createGeometry] Param expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')"),null;if(e.positionsDecodeMatrix&&e.positionsDecodeBoundary)return this.error("[createGeometry] Only one of these params expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')"),null;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("[createGeometry] Param expected: `uvDecodeMatrix` (required for `uvCompressed')"),null;if(!e.buckets&&!e.indices&&"points"!==e.primitive)return this.error("[createGeometry] Param expected: indices (required for '".concat(e.primitive,"' primitive type)")),null;if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=qa(e.positionsDecodeBoundary,$.mat4())),e.positions){var n=$.collapseAABB3();e.positionsDecodeMatrix=$.mat4(),$.expandAABB3Points3(n,e.positions),e.positionsCompressed=Xa(e.positions,n,e.positionsDecodeMatrix),e.aabb=n}else if(e.positionsCompressed){var t=$.collapseAABB3();e.positionsDecodeMatrix=new Float64Array(e.positionsDecodeMatrix),e.positionsCompressed=new Uint16Array(e.positionsCompressed),$.expandAABB3Points3(t,e.positionsCompressed),Bt.decompressAABB(t,e.positionsDecodeMatrix),e.aabb=t}else if(e.buckets){var i=$.collapseAABB3();this._dtxBuckets[e.id]=e.buckets;for(var r=0,l=e.buckets.length;r<l;r++){var a=e.buckets[r];a.positions?$.expandAABB3Points3(i,a.positions):a.positionsCompressed&&$.expandAABB3Points3(i,a.positionsCompressed)}e.positionsDecodeMatrix&&Bt.decompressAABB(i,e.positionsDecodeMatrix),e.aabb=i}if(e.colorsCompressed&&e.colorsCompressed.length>0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){for(var s=e.colors,u=new Uint8Array(s.length),o=0,c=s.length;o<c;o++)u[o]=255*s[o];e.colorsCompressed=u}if(e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=bt(e.positions,e.indices,null,5):e.edgeIndices=bt(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.uv){var f=Bt.getUVBounds(e.uv),p=Bt.compressUVs(e.uv,f.min,f.max);e.uvCompressed=p.quantized,e.uvDecodeMatrix=p.decodeMatrix}else e.uvCompressed&&(e.uvCompressed=new Uint16Array(e.uvCompressed),e.uvDecodeMatrix=new Float64Array(e.uvDecodeMatrix));e.normals&&(e.normals=null),this._geometries[e.id]=e,this._numTriangles+=e.indices?Math.round(e.indices.length/3):0,this.numGeometries++}else this.error("[createGeometry] Unsupported value for 'primitive': '".concat(e.primitive,"' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'."));else this.error("[createGeometry] Config missing: id")}},{key:"createTexture",value:function(e){var n=this,t=e.id;if(null!=t)if(this._textures[t])this.error("[createTexture] Texture already created: "+t);else{if(!e.src&&!e.image&&!e.buffers)return this.error("[createTexture] Param expected: `src`, `image' or 'buffers'"),null;var i=e.minFilter||pi;i!==oi&&i!==fi&&i!==pi&&i!==ui&&i!==li&&(this.error("[createTexture] Unsupported value for 'minFilter' - \n supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, \n NearestMipMapLinearFilter and LinearMipmapLinearFilter. Defaulting to LinearMipmapLinearFilter."),i=pi);var r=e.magFilter||oi;r!==oi&&r!==ri&&(this.error("[createTexture] Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter."),r=oi);var l=e.wrapS||ni;l!==ti&&l!==ii&&l!==ni&&(this.error("[createTexture] Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),l=ni);var a=e.wrapT||ni;a!==ti&&a!==ii&&a!==ni&&(this.error("[createTexture] Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),a=ni);var s=e.wrapR||ni;s!==ti&&s!==ii&&s!==ni&&(this.error("[createTexture] Unsupported value for 'wrapR' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),s=ni);var u=e.encoding||or;u!==or&&u!==cr&&(this.error("[createTexture] Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),u=or);var o=new Nl({gl:this.scene.canvas.gl,minFilter:i,magFilter:r,wrapS:l,wrapT:a,wrapR:s,encoding:u});if(e.preloadColor&&o.setPreloadColor(e.preloadColor),e.image){var c=e.image;c.crossOrigin="Anonymous",o.setImage(c,{minFilter:i,magFilter:r,wrapS:l,wrapT:a,wrapR:s,flipY:e.flipY,encoding:u})}else if(e.src){var f=e.src.split(".").pop();switch(f){case"jpeg":case"jpg":case"png":case"gif":var p=new Image;p.onload=function(){o.setImage(p,{minFilter:i,magFilter:r,wrapS:l,wrapT:a,wrapR:s,flipY:e.flipY,encoding:u}),n.glRedraw()},p.src=e.src;break;default:this._textureTranscoder?ue.loadArraybuffer(e.src,(function(e){e.byteLength?n._textureTranscoder.transcode([e],o).then((function(){n.glRedraw()})):n.error("[createTexture] Can't create texture from 'src': file data is zero length")}),(function(e){this.error("[createTexture] Can't create texture from 'src': ".concat(e))})):this.error("[createTexture] Can't create texture from 'src' - SceneModel needs to be configured with a TextureTranscoder for this file type ('".concat(f,"')"))}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,o).then((function(){n.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[t]=new bf({id:t,texture:o})}else this.error("[createTexture] Config missing: id")}},{key:"createTextureSet",value:function(e){var n=e.id;if(null!=n){if(!this._textureSets[n]){var t,i,r,l,a;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(!(t=this._textures[e.colorTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.colorTextureId," - ensure that you create it first with createTexture()"))}else t=this._textures[sp];if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(!(i=this._textures[e.metallicRoughnessTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.metallicRoughnessTextureId," - ensure that you create it first with createTexture()"))}else i=this._textures[up];if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(!(r=this._textures[e.normalsTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.normalsTextureId," - ensure that you create it first with createTexture()"))}else r=this._textures[op];if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(!(l=this._textures[e.emissiveTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.emissiveTextureId," - ensure that you create it first with createTexture()"))}else l=this._textures[cp];if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(!(a=this._textures[e.occlusionTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.occlusionTextureId," - ensure that you create it first with createTexture()"))}else a=this._textures[fp];var s=new Tf({id:n,model:this,colorTexture:t,metallicRoughnessTexture:i,normalsTexture:r,emissiveTexture:l,occlusionTexture:a});return this._textureSets[n]=s,s}this.error("[createTextureSet] Texture set already created: ".concat(n))}else this.error("[createTextureSet] Config missing: id")}},{key:"createTransform",value:function(e){if(void 0!==e.id&&null!==e.id)if(this._transforms[e.id])this.error("[createTransform] SceneModel already has a transform with this ID: ".concat(e.id));else{var n;if(!this.parentTransformId||(n=this._transforms[e.parentTransformId])){var t=new $f({id:e.id,model:this,parentTransform:n,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[t.id]=t,t}this.error("[createTransform] SceneModel.createTransform() config missing: id")}else this.error("[createTransform] SceneModel.createTransform() config missing: id")}},{key:"createMesh",value:function(e){if(void 0===e.id||null===e.id)return this.error("[createMesh] SceneModel.createMesh() config missing: id"),!1;if(this._scheduledMeshes[e.id])return this.error("[createMesh] SceneModel already has a mesh with this ID: ".concat(e.id)),!1;if(!(void 0!==e.geometryId)){if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"!==e.primitive&&"lines"!==e.primitive&&"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)return this.error("Unsupported value for 'primitive': '".concat(primitive,"' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.")),!1;if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)"),!1;if(e.positions&&(e.positionsDecodeMatrix||e.positionsDecodeBoundary))return this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)"),!1;if(!e.buckets&&!e.indices&&"points"!==e.primitive)return this.error("Param expected: indices (required for '".concat(e.primitive,"' primitive type)")),!1;if((e.matrix||e.position||e.rotation||e.scale)&&(e.positionsCompressed||e.positionsDecodeBoundary))return this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'"),!1;var n=!!this._dtxEnabled&&("triangles"===e.primitive||"solid"===e.primitive||"surface"===e.primitive);if(e.origin=e.origin?$.addVec3(this._origin,e.origin,$.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position){var t=e.scale||tp,i=e.position||ip,r=e.rotation||rp;$.eulerToQuaternion(r,"XYZ",lp),e.meshMatrix=$.composeMat4(i,lp,t,$.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=qa(e.positionsDecodeBoundary,$.mat4())),n){if(e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):dp,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){var l=$.vec3(),a=[];Be(e.positions,a,l)&&(e.positions=a,e.origin=$.addVec3(e.origin,l,l))}if(e.positions){var s=$.collapseAABB3();e.positionsDecodeMatrix=$.mat4(),$.expandAABB3Points3(s,e.positions),e.positionsCompressed=Xa(e.positions,s,e.positionsDecodeMatrix),e.aabb=s}else if(e.positionsCompressed){var u=$.collapseAABB3();$.expandAABB3Points3(u,e.positionsCompressed),Bt.decompressAABB(u,e.positionsDecodeMatrix),e.aabb=u}if(e.buckets){for(var o=$.collapseAABB3(),c=0,f=e.buckets.length;c<f;c++){var p=e.buckets[c];p.positions?$.expandAABB3Points3(o,p.positions):p.positionsCompressed&&$.expandAABB3Points3(o,p.positionsCompressed)}e.positionsDecodeMatrix&&Bt.decompressAABB(o,e.positionsDecodeMatrix),e.aabb=o}e.meshMatrix&&($.AABB3ToOBB3(e.aabb,np),$.transformOBB3(e.meshMatrix,np),$.OBB3ToAABB3(np,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=bt(e.positions,e.indices,null,2):e.edgeIndices=bt(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.buckets||(e.buckets=Ap(e,this._enableVertexWelding&&this._enableIndexBucketing))}else{if(e.type=1,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):[255,255,255],e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.metallic=void 0!==e.metallic&&null!==e.metallic?Math.floor(255*e.metallic):0,e.roughness=void 0!==e.roughness&&null!==e.roughness?Math.floor(255*e.roughness):255,e.positions){var d=[];Be(e.positions,d,ep)&&(e.positions=d,e.origin=$.addVec3(e.origin,ep,$.vec3()))}if(e.positions){var v=$.collapseAABB3();e.meshMatrix&&($.transformPositions3(e.meshMatrix,e.positions,e.positions),e.meshMatrix=null),$.expandAABB3Points3(v,e.positions),e.aabb=v}else{var A=$.collapseAABB3();$.expandAABB3Points3(A,e.positionsCompressed),Bt.decompressAABB(A,e.positionsDecodeMatrix),e.aabb=A}if(e.meshMatrix&&($.AABB3ToOBB3(e.aabb,np),$.transformOBB3(e.meshMatrix,np),$.OBB3ToAABB3(np,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=bt(e.positions,e.indices,null,2):e.edgeIndices=bt(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.textureSetId&&(e.textureSet=this._textureSets[e.textureSetId],!e.textureSet))return this.error("[createMesh] Texture set not found: ".concat(e.textureSetId," - ensure that you create it first with createTextureSet()")),!1}}else{if(e.positions||e.positionsCompressed||e.indices||e.edgeIndices||e.normals||e.normalsCompressed||e.uv||e.uvCompressed||e.positionsDecodeMatrix)return this.error("Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)"),!1;if(e.geometry=this._geometries[e.geometryId],!e.geometry)return this.error("[createMesh] Geometry not found: ".concat(e.geometryId," - ensure that you create it first with createGeometry()")),!1;if(e.origin=e.origin?$.addVec3(this._origin,e.origin,$.vec3()):this._origin,e.positionsDecodeMatrix=e.geometry.positionsDecodeMatrix,e.transformId){if(e.transform=this._transforms[e.transformId],!e.transform)return this.error("[createMesh] Transform not found: ".concat(e.transformId," - ensure that you create it first with createTransform()")),!1;e.aabb=e.geometry.aabb}else{if(e.matrix)e.meshMatrix=e.matrix.slice();else{var h=e.scale||tp,I=e.position||ip,y=e.rotation||rp;$.eulerToQuaternion(y,"XYZ",lp),e.meshMatrix=$.composeMat4(I,lp,h,$.mat4())}$.AABB3ToOBB3(e.geometry.aabb,np),$.transformOBB3(e.meshMatrix,np),e.aabb=$.OBB3ToAABB3(np,$.AABB3())}if(!!this._dtxEnabled&&("triangles"===e.geometry.primitive||"solid"===e.geometry.primitive||"surface"===e.geometry.primitive)){e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):dp,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255;var m=this._dtxBuckets[e.geometryId];m||(m=Ap(e.geometry,this._enableVertexWelding,this._enableIndexBucketing),this._dtxBuckets[e.geometryId]=m),e.buckets=m}else e.type=0,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):dp,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.metallic=void 0!==e.metallic&&null!==e.metallic?Math.floor(255*e.metallic):0,e.roughness=void 0!==e.roughness&&null!==e.roughness?Math.floor(255*e.roughness):255,e.textureSetId&&(e.textureSet=this._textureSets[e.textureSetId])}return e.numPrimitives=this._getNumPrimitives(e),this._meshesCfgsBeforeMeshCreation[e.id]=e,!0}},{key:"_createMesh",value:function(e){var n=new ea(this,e.id,e.color,e.opacity,e.transform,e.textureSet);n.pickId=this.scene._renderer.getPickID(n);var t=n.pickId,i=t>>24&255,r=t>>16&255,l=t>>8&255,a=255&t;switch(e.pickColor=new Uint8Array([a,l,r,i]),e.solid="solid"===e.primitive,n.origin=$.vec3(e.origin),e.type){case 2:n.layer=this._getDTXLayer(e),n.aabb=e.aabb;break;case 1:n.layer=this._getVBOBatchingLayer(e),n.aabb=e.aabb;break;case 0:n.layer=this._getVBOInstancingLayer(e),n.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),n.portionId=n.layer.createPortion(n,e),n}},{key:"_getNumPrimitives",value:function(e){var n=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(var t=0,i=e.buckets.length;t<i;t++)n+=e.buckets[t].indices.length;break;case 1:n+=e.indices.length;break;case 0:n+=e.geometry.indices.length}return Math.round(n/3);case"points":switch(e.type){case 2:for(var r=0,l=e.buckets.length;r<l;r++)n+=e.buckets[r].positionsCompressed.length;break;case 1:n+=e.positions?e.positions.length:e.positionsCompressed.length;break;case 0:var a=e.geometry;n+=a.positions?a.positions.length:a.positionsCompressed.length}return Math.round(n);case"lines":case"line-strip":switch(e.type){case 2:for(var s=0,u=e.buckets.length;s<u;s++)n+=e.buckets[s].indices.length;break;case 1:n+=e.indices.length;break;case 0:n+=e.geometry.indices.length}return Math.round(n/2)}return 0}},{key:"_getDTXLayer",value:function(e){var n=e.origin,t=e.geometry?e.geometry.primitive:e.primitive,i=".".concat(t,".").concat(Math.round(n[0]),".").concat(Math.round(n[1]),".").concat(Math.round(n[2])),r=this._dtxLayers[i];if(r){if(r.canCreatePortion(e))return r;r.finalize(),delete this._dtxLayers[i],r=null}switch(t){case"triangles":case"solid":case"surface":r=new Ef(this,{layerIndex:0,origin:n});break;case"lines":r=new Zo(this,{layerIndex:0,origin:n});break;default:return}return this._dtxLayers[i]=r,this.layerList.push(r),r}},{key:"_getVBOBatchingLayer",value:function(e){var n=this,t=e.origin,i=e.positionsDecodeMatrix||e.positionsDecodeBoundary?this._createHashStringFromMatrix(e.positionsDecodeMatrix||e.positionsDecodeBoundary):"-",r=e.textureSetId||"-",l="".concat(Math.round(t[0]),".").concat(Math.round(t[1]),".").concat(Math.round(t[2]),".").concat(e.primitive,".").concat(i,".").concat(r),a=this._vboBatchingLayers[l];if(a)return a;for(var s=e.textureSet;!a;){switch(e.primitive){case"triangles":case"solid":case"surface":a=new os({model:n,textureSet:s,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:t,maxGeometryBatchSize:this._maxGeometryBatchSize,solid:"solid"===e.primitive,autoNormals:!0});break;case"lines":a=new mu({model:n,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:t,maxGeometryBatchSize:this._maxGeometryBatchSize});break;case"points":a=new so({model:n,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:t,maxGeometryBatchSize:this._maxGeometryBatchSize})}var u=e.positionsCompressed?e.positionsCompressed.length:e.positions.length;("points"===e.primitive?a.canCreatePortion(u):a.canCreatePortion(u,e.indices.length))||(a.finalize(),delete this._vboBatchingLayers[l],a=null)}return this._vboBatchingLayers[l]=a,this.layerList.push(a),a}},{key:"_createHashStringFromMatrix",value:function(e){for(var n=e.join(""),t=0,i=0;i<n.length;i++){t=(t<<5)-t+n.charCodeAt(i),t|=0}return(t>>>0).toString(16)}},{key:"_getVBOInstancingLayer",value:function(e){var n=this,t=e.origin,i=e.textureSetId||"-",r=e.geometryId,l="".concat(Math.round(t[0]),".").concat(Math.round(t[1]),".").concat(Math.round(t[2]),".").concat(i,".").concat(r),a=this._vboInstancingLayers[l];if(a)return a;for(var s=e.textureSet,u=e.geometry;!a;)switch(u.primitive){case"triangles":case"surface":a=new eu({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0,solid:!1});break;case"solid":a=new eu({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0,solid:!0});break;case"lines":a=new Uu({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0});break;case"points":a=new Bo({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0})}return this._vboInstancingLayers[l]=a,this.layerList.push(a),a}},{key:"createEntity",value:function(e){if(void 0===e.id?e.id=$.createUUID():this.scene.components[e.id]&&(this.error("Scene already has a Component with this ID: ".concat(e.id," - will assign random ID")),e.id=$.createUUID()),void 0!==e.meshIds){var n=0;this._visible&&!1!==e.visible&&(n|=Fe),this._pickable&&!1!==e.pickable&&(n|=He),this._culled&&!1!==e.culled&&(n|=xe),this._clippable&&!1!==e.clippable&&(n|=Ue),this._collidable&&!1!==e.collidable&&(n|=Ge),this._edges&&!1!==e.edges&&(n|=Qe),this._xrayed&&!1!==e.xrayed&&(n|=ke),this._highlighted&&!1!==e.highlighted&&(n|=Ve),this._selected&&!1!==e.selected&&(n|=je),e.flags=n,this._createEntity(e)}else this.error("Config missing: meshIds")}},{key:"_createEntity",value:function(e){for(var n=[],t=0,i=e.meshIds.length;t<i;t++){var r=e.meshIds[t],l=this._meshes[r];if(!l){var a=this._meshesCfgsBeforeMeshCreation[r];if(!a){this.error('Mesh with this ID not found: "'.concat(r,'" - ignoring this mesh'));continue}l=this._createMesh(a),this._meshes[e.id]=l}l.parent?this.error('Mesh with ID "'.concat(r,'" already belongs to object with ID "').concat(l.parent.id,'" - ignoring this mesh')):n.push(l)}var s=new Ye(this,e.isObject,e.id,n,e.flags,!0);this._entityList.push(s),this._entities[e.id]=s,this.numEntities++}},{key:"finalize",value:function(){if(!this.destroyed){for(var e=0,n=this.layerList.length;e<n;e++){this.layerList[e].finalize()}this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._dtxLayers={},this._vboInstancingLayers={},this._vboBatchingLayers={};for(var t=0,i=this._entityList.length;t<i;t++){this._entityList[t]._finalize()}for(var r=0,l=this._entityList.length;r<l;r++){this._entityList[r]._finalize2()}this.layerList.sort((function(e,n){return e.sortId<n.sortId?-1:e.sortId>n.sortId?1:0}));for(var a=0,s=this.layerList.length;a<s;a++){this.layerList[a].layerIndex=a}this.glRedraw(),this.scene._aabbDirty=!0,this._viewMatrixDirty=!0,this._matrixDirty=!0,this._aabbDirty=!0,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.position=this._position}}},{key:"stateSortCompare",value:function(e,n){}},{key:"rebuildRenderFlags",value:function(){this.renderFlags.reset(),this._updateRenderFlagsVisibleLayers(),this.renderFlags.numLayers>0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}},{key:"_updateRenderFlagsVisibleLayers",value:function(){var e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(var n=0,t=this.layerList.length;n<t;n++){var i=this.layerList[n];this._getActiveSectionPlanesForLayer(i)&&(e.visibleLayers[e.numVisibleLayers++]=n)}}},{key:"_getActiveSectionPlanesForLayer",value:function(e){var n=this.renderFlags,t=this.scene._sectionPlanesState.sectionPlanes,i=t.length,r=e.layerIndex*i;if(i>0)for(var l=0;l<i;l++){t[l].active?(n.sectionPlanesActivePerLayer[r+l]=!0,n.sectioned=!0):n.sectionPlanesActivePerLayer[r+l]=!1}return!0}},{key:"_updateRenderFlags",value:function(){if(0!==this.numVisibleLayerPortions&&this.numCulledLayerPortions!==this.numPortions){var e=this.renderFlags;if(e.colorOpaque=this.numTransparentLayerPortions<this.numPortions,this.numTransparentLayerPortions>0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){var n=this.scene.xrayMaterial._state;n.fill&&(n.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),n.edges&&(n.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0)this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions<this.numPortions,this.numTransparentLayerPortions>0&&(e.edgesTransparent=!0));if(this.numSelectedLayerPortions>0){var t=this.scene.selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){var i=this.scene.highlightMaterial._state;i.fill&&(i.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),i.edges&&(i.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}},{key:"drawColorOpaque",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawColorOpaque(n,e)}}},{key:"drawColorTransparent",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawColorTransparent(n,e)}}},{key:"drawDepth",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawDepth(n,e)}}},{key:"drawNormals",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawNormals(n,e)}}},{key:"drawSilhouetteXRayed",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawSilhouetteXRayed(n,e)}}},{key:"drawSilhouetteHighlighted",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawSilhouetteHighlighted(n,e)}}},{key:"drawSilhouetteSelected",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawSilhouetteSelected(n,e)}}},{key:"drawEdgesColorOpaque",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesColorOpaque(n,e)}}},{key:"drawEdgesColorTransparent",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesColorTransparent(n,e)}}},{key:"drawEdgesXRayed",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesXRayed(n,e)}}},{key:"drawEdgesHighlighted",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesHighlighted(n,e)}}},{key:"drawEdgesSelected",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesSelected(n,e)}}},{key:"drawOcclusion",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawOcclusion(n,e)}}},{key:"drawShadow",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawShadow(n,e)}}},{key:"setPickMatrices",value:function(e,n){if(0!==this._numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var l=t.visibleLayers[i],a=this.layerList[l];a.setPickMatrices&&a.setPickMatrices(e,n)}}},{key:"drawPickMesh",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawPickMesh(n,e)}}},{key:"drawPickDepths",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawPickDepths(n,e)}}},{key:"drawPickNormals",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawPickNormals(n,e)}}},{key:"drawSnapInit",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t],l=this.layerList[r];l.drawSnapInit&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,l.drawSnapInit(n,e),e.snapPickLayerParams[e.snapPickLayerNumber]={origin:e.snapPickOrigin.slice(),coordinateScale:e.snapPickCoordinateScale.slice()})}}},{key:"drawSnap",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t],l=this.layerList[r];l.drawSnap&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,l.drawSnap(n,e),e.snapPickLayerParams[e.snapPickLayerNumber]={origin:e.snapPickOrigin.slice(),coordinateScale:e.snapPickCoordinateScale.slice()})}}},{key:"destroy",value:function(){for(var e in this._vboBatchingLayers)this._vboBatchingLayers.hasOwnProperty(e)&&this._vboBatchingLayers[e].destroy();for(var t in this._vboBatchingLayers={},this._vboInstancingLayers)this._vboInstancingLayers.hasOwnProperty(t)&&this._vboInstancingLayers[t].destroy();this._vboInstancingLayers={},this.scene.camera.off(this._onCameraViewMatrix),this.scene.off(this._onTick);for(var i=0,r=this.layerList.length;i<r;i++)this.layerList[i].destroy();this.layerList=[];for(var l=0,a=this._entityList.length;l<a;l++)this._entityList[l]._destroy();this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._meshes={},this._entities={},this.scene._aabbDirty=!0,this._isModel&&this.scene._deregisterModel(this),0!==ta&&0==--ta&&na._clear(),I(y(n.prototype),"destroy",this).call(this)}}])}();function Ap(e,n,t){var i,r,l,a;if(n||t){var s=f(Uf({positionsCompressed:e.positionsCompressed,indices:e.indices,edgeIndices:e.edgeIndices}),3);i=s[0],r=s[1],l=s[2]}else i=e.positionsCompressed,r=e.indices,l=e.edgeIndices;t?a=Wf({positionsCompressed:i,indices:r,edgeIndices:l},i.length/3>65536?16:8):a=[{positionsCompressed:i,indices:r,edgeIndices:l}];return a}var hp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(T(this,n),(t=v(this,n,[e,i]))._positions=i.positions||[],i.indices)t._indices=i.indices;else{t._indices=[];for(var r=0,l=t._positions.length/3-1;r<l;r+=2)t._indices.push(r),t._indices.push(r+1)}return t._sceneModel=new vp(t,{isModel:!1}),t._sceneModel.createMesh({id:"linesMesh",primitive:"lines",positions:t._positions,indices:t._indices}),t._sceneModel.createEntity({meshIds:["linesMesh"],visible:i.visible,clippable:i.clippable,collidable:i.collidable}),t._sceneModel.finalize(),t.scene._lineSetCreated(t),t}return m(n,me),C(n,[{key:"visible",get:function(){return this._sceneModel.visible},set:function(e){this._sceneModel.visible=e}},{key:"positions",get:function(){return this._positions}},{key:"indices",get:function(){return this._indices}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene._lineSetDestroyed(this)}}])}(),Ip=$.vec3(),yp=$.vec3(),mp=$.vec3(),wp=$.vec3(),gp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,["BCFViewpoints",e,i])).originatingSystem=i.originatingSystem||"xeokit.io",t.authoringTool=i.authoringTool||"xeokit.io",t}return m(n,_e),C(n,[{key:"getViewpoint",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.viewer.scene,i=t.camera,r=t.realWorldOffset,l=!0===n.reverseClippingPlanes,a={},s=$.normalizeVec3($.subVec3(i.look,i.eye,$.vec3())),u=i.eye,o=i.up;i.yUp&&(s=bp(s),u=bp(u),o=bp(o));var c=Ep($.addVec3(u,r));"ortho"===i.projection?a.orthogonal_camera={camera_view_point:c,camera_direction:Ep(s),camera_up_vector:Ep(o),view_to_world_scale:i.ortho.scale}:a.perspective_camera={camera_view_point:c,camera_direction:Ep(s),camera_up_vector:Ep(o),field_of_view:i.perspective.fov};var p=t.sectionPlanes;for(var d in p)if(p.hasOwnProperty(d)){var v=p[d];if(!v.active)continue;var A=v.pos,h=void 0;h=l?$.negateVec3(v.dir,$.vec3()):v.dir,i.yUp&&(A=bp(A),h=bp(h)),$.addVec3(A,r),A=Ep(A),h=Ep(h),a.clipping_planes||(a.clipping_planes=[]),a.clipping_planes.push({location:A,direction:h})}var I=t.lineSets;for(var y in I)if(I.hasOwnProperty(y)){var m=I[y];a.lines||(a.lines=[]);for(var w=m.positions,g=m.indices,E=0,T=g.length/2;E<T;E++){var b=g[2*E],C=g[2*E+1];a.lines.push({start_point:{x:w[3*b+0],y:w[3*b+1],z:w[3*b+2]},end_point:{x:w[3*C+0],y:w[3*C+1],z:w[3*C+2]}})}}var D=t.bitmaps;for(var R in D)if(D.hasOwnProperty(R)){var P=D[R],_=P.pos,O=P.normal,S=P.up;i.yUp&&(_=bp(_),O=bp(O),S=bp(S)),$.addVec3(_,r),a.bitmaps||(a.bitmaps=[]),a.bitmaps.push({bitmap_type:P.type,bitmap_data:P.imageData,location:Ep(_),normal:Ep(O),up:Ep(S),height:P.height})}a.components={visibility:{view_setup_hints:{spaces_visible:!!n.spacesVisible,space_boundaries_visible:!!n.spaceBoundariesVisible,openings_visible:!!n.openingsVisible,spaces_translucent:!!n.spaces_translucent,space_boundaries_translucent:!!n.space_boundaries_translucent,openings_translucent:!!n.openings_translucent}}};var N=new Set(t.opacityObjectIds),B=new Set(t.xrayedObjectIds),L=new Set(t.colorizedObjectIds),M=Object.values(t.objects).filter((function(e){return N.has(e.id)||L.has(e.id)||B.has(e.id)})).reduce((function(n,i){var r,l=function(e){var n="";return n+=Math.round(255*e[0]).toString(16).padStart(2,"0"),n+=Math.round(255*e[1]).toString(16).padStart(2,"0"),n+=Math.round(255*e[2]).toString(16).padStart(2,"0"),n}(i.colorize);i.xrayed?(r=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,l=(r=Math.round(255*r).toString(16).padStart(2,"0"))+l):N.has(i.id)&&(l=(r=Math.round(255*i.opacity).toString(16).padStart(2,"0"))+l),n[l]||(n[l]=[]);var a=i.id,s=i.originalSystemId,u={ifc_guid:s,originating_system:e.originatingSystem};return s!==a&&(u.authoring_tool_id=a),n[l].push(u),n}),{}),F=Object.entries(M).map((function(e){var n=f(e,2);return{color:n[0],components:n[1]}}));a.components.coloring=F;var x=t.objectIds,H=t.visibleObjects,U=t.visibleObjectIds,G=x.filter((function(e){return!H[e]})),k=t.selectedObjectIds;return n.defaultInvisible||U.length<G.length?(a.components.visibility.exceptions=this._createBCFComponents(U),a.components.visibility.default_visibility=!1):(a.components.visibility.exceptions=this._createBCFComponents(G),a.components.visibility.default_visibility=!0),a.components.selection=this._createBCFComponents(k),a.components.translucency=this._createBCFComponents(t.xrayedObjectIds),!1!==n.snapshot&&(a.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})}),a}},{key:"_createBCFComponents",value:function(e){for(var n=this.viewer.scene,t=[],i=0,r=e.length;i<r;i++){var l=e[i],a=n.objects[l];if(a){var s={ifc_guid:a.originalSystemId,originating_system:this.originatingSystem};a.originalSystemId!==l&&(s.authoring_tool_id=l),t.push(s)}}return t}},{key:"setViewpoint",value:function(e){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var i=this.viewer,r=i.scene,l=r.camera,a=!1!==t.rayCast,s=!1!==t.immediate,u=!1!==t.reset,o=r.realWorldOffset,c=!0===t.reverseClippingPlanes;if(r.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){var n=Tp(e.location,Ip),t=Tp(e.direction,Ip);c&&$.negateVec3(t),$.subVec3(n,o),l.yUp&&(n=Cp(n),t=Cp(t)),new pl(r,{pos:n,dir:t})})),r.clearLines(),e.lines&&e.lines.length>0){var f=[],p=[],d=0;e.lines.forEach((function(e){e.start_point&&e.end_point&&(f.push(e.start_point.x),f.push(e.start_point.y),f.push(e.start_point.z),f.push(e.end_point.x),f.push(e.end_point.y),f.push(e.end_point.z),p.push(d++),p.push(d++))})),new hp(r,{positions:f,indices:p,clippable:!1,collidable:!0})}if(r.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){var n=e.bitmap_type||"jpg",t=e.bitmap_data,i=Tp(e.location,yp),a=Tp(e.normal,mp),s=Tp(e.up,wp),u=e.height||1;n&&t&&i&&a&&s&&(l.yUp&&(i=Cp(i),a=Cp(a),s=Cp(s)),new ql(r,{src:t,type:n,pos:i,normal:a,up:s,clippable:!1,collidable:!0,height:u}))})),u&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),r.setObjectsHighlighted(r.highlightedObjectIds,!1),r.setObjectsSelected(r.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(r.setObjectsVisible(r.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.visible=!1}))}))):(r.setObjectsVisible(r.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.visible=!0}))})));var v=e.components.visibility.view_setup_hints;v&&(!1===v.spaces_visible&&r.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==v.spaces_translucent&&r.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),v.space_boundaries_visible,!1===v.openings_visible&&r.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),v.space_boundaries_translucent,void 0!==v.openings_translucent&&r.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(r.setObjectsSelected(r.selectedObjectIds,!1),e.components.selection.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.selected=!0}))}))),e.components.translucency&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),e.components.translucency.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.xrayed=!0}))}))),e.components.coloring&&e.components.coloring.forEach((function(e){var i=e.color,r=0,l=!1;8===i.length&&((r=parseInt(i.substring(0,2),16)/256)<=1&&r>=.95&&(r=1),i=i.substring(2),l=!0);var a=[parseInt(i.substring(0,2),16)/256,parseInt(i.substring(2,4),16)/256,parseInt(i.substring(4,6),16)/256];e.components.map((function(e){return n._withBCFComponent(t,e,(function(e){e.colorize=a,l&&(e.opacity=r)}))}))}))}if(e.perspective_camera||e.orthogonal_camera){var A,h,I,y;if(e.perspective_camera?(A=Tp(e.perspective_camera.camera_view_point,Ip),h=Tp(e.perspective_camera.camera_direction,Ip),I=Tp(e.perspective_camera.camera_up_vector,Ip),l.perspective.fov=e.perspective_camera.field_of_view,y="perspective"):(A=Tp(e.orthogonal_camera.camera_view_point,Ip),h=Tp(e.orthogonal_camera.camera_direction,Ip),I=Tp(e.orthogonal_camera.camera_up_vector,Ip),l.ortho.scale=e.orthogonal_camera.view_to_world_scale,y="ortho"),$.subVec3(A,o),l.yUp&&(A=Cp(A),h=Cp(h),I=Cp(I)),a){var m=r.pick({pickSurface:!0,origin:A,direction:h});h=m?m.worldPos:$.addVec3(A,h,Ip)}else h=$.addVec3(A,h,Ip);s?(l.eye=A,l.look=h,l.up=I,l.projection=y):i.cameraFlight.flyTo({eye:A,look:h,up:I,duration:t.duration,projection:y})}}}},{key:"_withBCFComponent",value:function(e,n,t){var i=this.viewer,r=i.scene;if(n.authoring_tool_id&&n.originating_system===this.originatingSystem){var l=n.authoring_tool_id,a=r.objects[l];if(a)return void t(a);if(e.updateCompositeObjects)if(i.metaScene.metaObjects[l])return void r.withObjects(i.metaScene.getObjectIDsInSubtree(l),t)}if(n.ifc_guid){var s=n.ifc_guid,u=r.objects[s];if(u)return void t(u);if(e.updateCompositeObjects)if(i.metaScene.metaObjects[s])return void r.withObjects(i.metaScene.getObjectIDsInSubtree(s),t);Object.keys(r.models).forEach((function(n){var l=$.globalizeObjectId(n,s),a=r.objects[l];a?t(a):e.updateCompositeObjects&&i.metaScene.metaObjects[l]&&r.withObjects(i.metaScene.getObjectIDsInSubtree(l),t)}))}}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this)}}])}();function Ep(e){return{x:e[0],y:e[1],z:e[2]}}function Tp(e,n){return(n=new Float64Array(3))[0]=e.x,n[1]=e.y,n[2]=e.z,n}function bp(e){return new Float64Array([e[0],-e[2],e[1]])}function Cp(e){return new Float64Array([e[0],e[2],-e[1]])}var Dp=$.vec3(),Rp=function(e,n,t,i){var r=e-t,l=n-i;return Math.sqrt(r*r+l*l)},Pp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(T(this,n),(t=v(this,n,[e.viewer.scene,i])).plugin=e,t._container=i.container,!t._container)throw"config missing: container";t._eventSubs={},t._color=i.color?i.color:e.defaultColor,t._borderColor=e.defaultColor?e.defaultColor:"white";var r=t.plugin.viewer.scene;t._originMarker=new qe(r,i.origin),t._targetMarker=new qe(r,i.target),t._originWorld=$.vec3(),t._targetWorld=$.vec3(),t._wp=new Float64Array(24),t._vp=new Float64Array(24),t._pp=new Float64Array(24),t._cp=new Float64Array(8),t._xAxisLabelCulled=!1,t._yAxisLabelCulled=!1,t._zAxisLabelCulled=!1;var l=i.onMouseOver?function(e){i.onMouseOver(e,t),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,a=i.onMouseLeave?function(e){i.onMouseLeave(e,t),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,s=i.onMouseClick?function(e){i.onMouseClick(e,t),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("click",e))}:null,u=i.onTouchStart?function(e){i.onTouchStart(e,t),e.preventDefault(),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("touchstart",e))}:null,o=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},c=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},f=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},p=i.onContextMenu?function(e){i.onContextMenu(e,t)}:null,d=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};return t._originDot=new Ze(t._container,{fillColor:t._color,borderColor:t._borderColor,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._targetDot=new Ze(t._container,{fillColor:t._color,borderColor:t._borderColor,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._lengthWire=new Je(t._container,{color:t._color,thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._lengthLabel=new $e(t._container,{fillColor:t._color||"#0065FC",prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._xAxisWire=new Je(t._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._yAxisWire=new Je(t._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._zAxisWire=new Je(t._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._xAxisLabel=new $e(t._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._yAxisLabel=new $e(t._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._zAxisLabel=new $e(t._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._wpDirty=!1,t._vpDirty=!1,t._cpDirty=!1,t._sectionPlanesDirty=!0,t._visible=!1,t._originVisible=!1,t._targetVisible=!1,t._wireVisible=!1,t._axisVisible=!1,t._xAxisVisible=!1,t._yAxisVisible=!1,t._zAxisVisible=!1,t._axisEnabled=!0,t._labelsVisible=!1,t._labelsOnWires=!1,t._clickable=!1,t._originMarker.on("worldPos",(function(e){t._originWorld.set(e||[0,0,0]),t._wpDirty=!0,t._needUpdate(0)})),t._targetMarker.on("worldPos",(function(e){t._targetWorld.set(e||[0,0,0]),t._wpDirty=!0,t._needUpdate(0)})),t._onViewMatrix=r.camera.on("viewMatrix",(function(){t._vpDirty=!0,t._needUpdate(0)})),t._onProjMatrix=r.camera.on("projMatrix",(function(){t._cpDirty=!0,t._needUpdate()})),t._onCanvasBoundary=r.canvas.on("boundary",(function(){t._cpDirty=!0,t._needUpdate(0)})),t._onMetricsUnits=r.metrics.on("units",(function(){t._cpDirty=!0,t._needUpdate()})),t._onMetricsScale=r.metrics.on("scale",(function(){t._cpDirty=!0,t._needUpdate()})),t._onMetricsOrigin=r.metrics.on("origin",(function(){t._cpDirty=!0,t._needUpdate()})),t._onSectionPlaneUpdated=r.on("sectionPlaneUpdated",(function(){t._sectionPlanesDirty=!0,t._needUpdate()})),t.precision=void 0!==i.precision?i.precision:2,t.approximate=void 0===i.approximate||i.approximate,t.visible=i.visible,t.originVisible=i.originVisible,t.targetVisible=i.targetVisible,t.wireVisible=i.wireVisible,t.axisVisible=i.axisVisible,t.xAxisVisible=i.xAxisVisible,t.yAxisVisible=i.yAxisVisible,t.zAxisVisible=i.zAxisVisible,t.labelsVisible=i.labelsVisible,t.labelsOnWires=i.labelsOnWires,t}return m(n,me),C(n,[{key:"_update",value:function(){if(this._visible){var e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&($.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}var n=this._originMarker.viewPos[2],t=this._targetMarker.viewPos[2];if(n>-.3||t>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){$.transformPositions4(e.camera.project.matrix,this._vp,this._pp);for(var i=this._pp,r=this._cp,l=e.canvas.canvas.getBoundingClientRect(),a=this._container.getBoundingClientRect(),s=l.top-a.top,u=l.left-a.left,o=e.canvas.boundary,c=o[2],f=o[3],p=0,d=this.plugin.viewer.scene.metrics,v=d.scale,A=d.units,h=d.unitsInfo[A].abbrev,I=0,y=i.length;I<y;I+=4)r[p]=u+Math.floor((1+i[I+0]/i[I+3])*c/2),r[p+1]=s+Math.floor((1-i[I+1]/i[I+3])*f/2),p+=2;if(this._originDot.setPos(r[0],r[1]),this._targetDot.setPos(r[6],r[7]),this._lengthWire.setStartAndEnd(r[0],r[1],r[6],r[7]),this._xAxisWire.setStartAndEnd(r[0],r[1],r[2],r[3]),this._yAxisWire.setStartAndEnd(r[2],r[3],r[4],r[5]),this._zAxisWire.setStartAndEnd(r[4],r[5],r[6],r[7]),this.labelsVisible){if(this._lengthLabel.setPosOnWire(r[0],r[1],r[6],r[7]),this.labelsOnWires)this._xAxisLabel.setPosOnWire(r[0],r[1],r[2],r[3]),this._yAxisLabel.setPosOnWire(r[2],r[3],r[4],r[5]),this._zAxisLabel.setPosOnWire(r[4],r[5],r[6],r[7]);else{var m=35;this._xAxisLabel.setPosOnWire(r[0],r[1]+m,r[6],r[7]+m),m+=35,this._yAxisLabel.setPosOnWire(r[0],r[1]+m,r[6],r[7]+m),m+=35,this._zAxisLabel.setPosOnWire(r[0],r[1]+m,r[6],r[7]+m)}var w=this._approximate?" ":" = ";this._length=Math.abs($.lenVec3($.subVec3(this._targetWorld,this._originWorld,Dp))),this._lengthLabel.setText(w+(this._length*v).toFixed(this._precision)+h);var g=Math.abs(Rp(r[0],r[1],r[2],r[3])),E=Math.abs(Rp(r[2],r[3],r[4],r[5])),T=Math.abs(Rp(r[4],r[5],r[6],r[7])),b=this.plugin.labelMinAxisLength;this.labelsOnWires?(this._xAxisLabelCulled=g<b,this._yAxisLabelCulled=E<b,this._zAxisLabelCulled=T<b):(this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1),this._xAxisLabelCulled?this._xAxisLabel.setCulled(!0):(this._xAxisLabel.setText(w+Math.abs((this._targetWorld[0]-this._originWorld[0])*v).toFixed(this._precision)+h),this._xAxisLabel.setCulled(!this.axisVisible)),this._yAxisLabelCulled?this._yAxisLabel.setCulled(!0):(this._yAxisLabel.setText(w+Math.abs((this._targetWorld[1]-this._originWorld[1])*v).toFixed(this._precision)+h),this._yAxisLabel.setCulled(!this.axisVisible)),this._zAxisLabelCulled?this._zAxisLabel.setCulled(!0):(this._zAxisLabel.setText(w+Math.abs((this._targetWorld[2]-this._originWorld[2])*v).toFixed(this._precision)+h),this._zAxisLabel.setCulled(!this.axisVisible))}else this._lengthLabel.setCulled(!0),this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0);this._originDot.setVisible(this._visible&&this._originVisible),this._targetDot.setVisible(this._visible&&this._targetVisible),this._xAxisWire.setVisible(this.axisVisible&&this.xAxisVisible),this._yAxisWire.setVisible(this.axisVisible&&this.yAxisVisible),this._zAxisWire.setVisible(this.axisVisible&&this.zAxisVisible),this._lengthWire.setVisible(this.wireVisible),this._lengthLabel.setCulled(!this.wireVisible),this._cpDirty=!1}}}},{key:"_isSliced",value:function(e){for(var n=this.scene._sectionPlanesState.sectionPlanes,t=0,i=n.length;t<i;t++){var r=n[t];if($.planeClipsPositions3(r.pos,r.dir,e,4))return!0}return!1}},{key:"approximate",get:function(){return this._approximate},set:function(e){e=!1!==e,this._approximate!==e&&(this._approximate=e,this._cpDirty=!0,this._needUpdate(0))}},{key:"precision",get:function(){return this._precision},set:function(e){this._precision!==e&&(this._precision=e,this._cpDirty=!0,this._needUpdate(0))}},{key:"origin",get:function(){return this._originMarker}},{key:"target",get:function(){return this._targetMarker}},{key:"length",get:function(){this._update();var e=this.plugin.viewer.scene.metrics.scale;return this._length*e}},{key:"color",get:function(){return this._color},set:function(e){this._color=e,this._originDot.setFillColor(e),this._targetDot.setFillColor(e),this._lengthWire.setColor(e||"#0065FC"),this._lengthLabel.setFillColor(e||"#0065FC")}},{key:"visible",get:function(){return this._visible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultVisible,this._visible=e,this._originDot.setVisible(this._visible&&this._originVisible),this._targetDot.setVisible(this._visible&&this._targetVisible),this._lengthWire.setVisible(this._visible&&this._wireVisible),this._lengthLabel.setVisible(this._visible&&this._wireVisible);var n=this._visible&&this._axisVisible&&this._xAxisVisible,t=this._visible&&this._axisVisible&&this._yAxisVisible,i=this._visible&&this._axisVisible&&this._zAxisVisible;this._xAxisWire.setVisible(n),this._yAxisWire.setVisible(t),this._zAxisWire.setVisible(i),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled),this._zAxisLabel.setVisible(i&&!this._zAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"originVisible",get:function(){return this._originVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultOriginVisible,this._originVisible=e,this._originDot.setVisible(this._visible&&this._originVisible)}},{key:"targetVisible",get:function(){return this._targetVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultTargetVisible,this._targetVisible=e,this._targetDot.setVisible(this._visible&&this._targetVisible)}},{key:"axisEnabled",get:function(){return this._axisEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._axisEnabled=e;var n=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(n&&this._xAxisVisible),this._yAxisWire.setVisible(n&&this._yAxisVisible),this._zAxisWire.setVisible(n&&this._zAxisVisible),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled&&this._xAxisVisible),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled&&this._xAxisVisible),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled&&this._xAxisVisible),this._cpDirty=!0,this._needUpdate()}},{key:"axisVisible",get:function(){return this._axisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._axisVisible=e;var n=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(n&&this._xAxisVisible),this._yAxisWire.setVisible(n&&this._yAxisVisible),this._zAxisWire.setVisible(n&&this._zAxisVisible),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled&&this._xAxisVisible),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled&&this._yAxisVisible),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled&&this._zAxisVisible),this._cpDirty=!0,this._needUpdate()}},{key:"xAxisVisible",get:function(){return this._xAxisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._xAxisVisible=e;var n=this._visible&&this._axisVisible&&this._xAxisVisible&&this._axisEnabled;this._xAxisWire.setVisible(n),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"yAxisVisible",get:function(){return this._yAxisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._yAxisVisible=e;var n=this._visible&&this._axisVisible&&this._yAxisVisible&&this._axisEnabled;this._yAxisWire.setVisible(n),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"zAxisVisible",get:function(){return this._zAxisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._zAxisVisible=e;var n=this._visible&&this._axisVisible&&this._zAxisVisible&&this._axisEnabled;this._zAxisWire.setVisible(n),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"wireVisible",get:function(){return this._wireVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultWireVisible,this._wireVisible=e;var n=this._visible&&this._wireVisible;this._lengthLabel.setVisible(n),this._lengthWire.setVisible(n)}},{key:"labelsVisible",get:function(){return this._labelsVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLabelsVisible,this._labelsVisible=e;var n=this._visible&&this._labelsVisible;this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled&&this._clickable&&this._axisEnabled),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled&&this._clickable&&this._axisEnabled),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled&&this._clickable&&this._axisEnabled),this._lengthLabel.setVisible(n),this._cpDirty=!0,this._needUpdate()}},{key:"labelsOnWires",get:function(){return this._labelsOnWires},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLabelsOnWires,this._labelsOnWires=e}},{key:"setHighlighted",value:function(e){this._originDot.setHighlighted(e),this._targetDot.setHighlighted(e),this._xAxisWire.setHighlighted(e),this._yAxisWire.setHighlighted(e),this._zAxisWire.setHighlighted(e),this._xAxisLabel.setHighlighted(e),this._yAxisLabel.setHighlighted(e),this._zAxisLabel.setHighlighted(e),this._lengthWire.setHighlighted(e),this._lengthLabel.setHighlighted(e)}},{key:"clickable",get:function(){return this._clickable},set:function(e){e=!!e,this._clickable=e,this._originDot.setClickable(this._clickable),this._targetDot.setClickable(this._clickable),this._xAxisWire.setClickable(this._clickable),this._yAxisWire.setClickable(this._clickable),this._zAxisWire.setClickable(this._clickable),this._lengthWire.setClickable(this._clickable),this._xAxisLabel.setClickable(this._clickable),this._yAxisLabel.setClickable(this._clickable),this._zAxisLabel.setClickable(this._clickable),this._lengthLabel.setClickable(this._clickable)}},{key:"destroy",value:function(){var e=this.plugin.viewer.scene,t=e.metrics;this._onViewMatrix&&e.camera.off(this._onViewMatrix),this._onProjMatrix&&e.camera.off(this._onProjMatrix),this._onCanvasBoundary&&e.canvas.off(this._onCanvasBoundary),this._onMetricsUnits&&t.off(this._onMetricsUnits),this._onMetricsScale&&t.off(this._onMetricsScale),this._onMetricsOrigin&&t.off(this._onMetricsOrigin),this._onSectionPlaneUpdated&&e.off(this._onSectionPlaneUpdated),this._originDot.destroy(),this._targetDot.destroy(),this._xAxisWire.destroy(),this._yAxisWire.destroy(),this._zAxisWire.destroy(),this._lengthLabel.destroy(),this._xAxisLabel.destroy(),this._yAxisLabel.destroy(),this._zAxisLabel.destroy(),this._lengthWire.destroy(),I(y(n.prototype),"destroy",this).call(this)}}])}(),_p=function(e){function n(){return T(this,n),v(this,n,arguments)}return m(n,me),C(n,[{key:"active",get:function(){}},{key:"snapping",get:function(){return!0},set:function(e){}},{key:"activate",value:function(){}},{key:"deactivate",value:function(){}},{key:"reset",value:function(){}},{key:"destroy",value:function(){}}])}(),Op=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e.viewer.scene])).cfg=i,t.pointerLens=i.pointerLens,t._active=!1,t._currentDistanceMeasurement=null,t._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},t._initMarkerDiv(),t._onCameraControlHoverSnapOrSurface=null,t._onCameraControlHoverSnapOrSurfaceOff=null,t._onMouseDown=null,t._onMouseUp=null,t._onCanvasTouchStart=null,t._onCanvasTouchEnd=null,t._snapping=!1!==i.snapping,t._mouseState=0,t._attachPlugin(e,i),t._offsetX=0|i._offsetX,t._offsetY=0|i._offsetY,t}return m(n,_p),C(n,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myDistancePivotMarker");var n=this.scene.canvas.canvas;n.parentNode.insertBefore(e,n),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.margin="-200px -200px",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){this._markerDiv&&(this._markerDiv.parentNode.removeChild(this._markerDiv),this._markerDiv=null)}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"offsetX",get:function(){return this._offsetX},set:function(e){this._offsetX=e}},{key:"offsetY",get:function(){return this._offsetY},set:function(e){this._offsetY=e}},{key:"active",get:function(){return this._active}},{key:"snapping",get:function(){return this._snapping},set:function(e){e!==this._snapping?(this._snapping=e,this.deactivate(),this.activate()):this._snapping=e}},{key:"activate",value:function(){var e=this;if(!this._active){this._markerDiv||this._initMarkerDiv(),this.fire("activated",!0);var n=this.distanceMeasurementsPlugin,t=!1;n.on("mouseOver",(function(e){t=!0})),n.on("mouseLeave",(function(e){t=!1})),n.on("measureDelete",(function(e){t=!1}));var i=this.scene,r=n.viewer.cameraControl,l=i.canvas.canvas;i.input;var a,s,u=!1,o=$.vec3(),c=$.vec2(),f=null;this._mouseState=0,this._onCameraControlHoverSnapOrSurface=r.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(function(n){if(!t){var i=n.snappedCanvasPos||n.canvasPos;if(u=!0,o.set(n.worldPos),c.set(n.canvasPos),0===e._mouseState){l.getBoundingClientRect();var r=window.pageXOffset||document.documentElement.scrollLeft,a=window.pageYOffset||document.documentElement.scrollTop;e._markerDiv.style.marginLeft="".concat(e._offsetX+r+i[0]-5,"px"),e._markerDiv.style.marginTop="".concat(e._offsetY+a+i[1]-5,"px"),e._markerDiv.style.background="pink",n.snappedToVertex||n.snappedToEdge?(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=n.canvasPos,e.pointerLens.snappedCanvasPos=n.snappedCanvasPos||n.canvasPos,e.pointerLens.snapped=!0),e._markerDiv.style.background="greenyellow",e._markerDiv.style.border="2px solid green"):(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=n.canvasPos,e.pointerLens.snappedCanvasPos=n.canvasPos,e.pointerLens.snapped=!1),e._markerDiv.style.background="pink",e._markerDiv.style.border="2px solid red"),f=n.entity}else e._markerDiv.style.marginLeft="-10000px",e._markerDiv.style.marginTop="-10000px";l.style.cursor="pointer",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=e._currentDistanceMeasurementInitState.wireVisible,e._currentDistanceMeasurement.axisVisible=e._currentDistanceMeasurementInitState.axisVisible&&e.distanceMeasurementsPlugin.defaultAxisVisible,e._currentDistanceMeasurement.xAxisVisible=e._currentDistanceMeasurementInitState.xAxisVisible&&e.distanceMeasurementsPlugin.defaultXAxisVisible,e._currentDistanceMeasurement.yAxisVisible=e._currentDistanceMeasurementInitState.yAxisVisible&&e.distanceMeasurementsPlugin.defaultYAxisVisible,e._currentDistanceMeasurement.zAxisVisible=e._currentDistanceMeasurementInitState.zAxisVisible&&e.distanceMeasurementsPlugin.defaultZAxisVisible,e._currentDistanceMeasurement.targetVisible=e._currentDistanceMeasurementInitState.targetVisible,e._currentDistanceMeasurement.target.worldPos=o.slice(),e._markerDiv.style.marginLeft="-10000px",e._markerDiv.style.marginTop="-10000px")}})),l.addEventListener("mousedown",this._onMouseDown=function(e){1===e.which&&(a=e.clientX,s=e.clientY)}),l.addEventListener("mouseup",this._onMouseUp=function(i){t||1===i.which&&(i.clientX>a+20||i.clientX<a-20||i.clientY>s+20||i.clientY<s-20||(e._currentDistanceMeasurement?u?(e._currentDistanceMeasurement.target.entity=f,f=null,e._currentDistanceMeasurement.clickable=!0,e.distanceMeasurementsPlugin.fire("measurementEnd",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null):(e._currentDistanceMeasurement.destroy(),e.distanceMeasurementsPlugin.fire("measurementCancel",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null,f=null):u&&(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:o.slice()},target:{worldPos:o.slice()},precision:n.precision,approximate:!0}),e._currentDistanceMeasurementInitState.axisVisible=e._currentDistanceMeasurement.axisVisible&&e.distanceMeasurementsPlugin.defaultAxisVisible,e._currentDistanceMeasurementInitState.xAxisVisible=e._currentDistanceMeasurement.xAxisVisible&&e.distanceMeasurementsPlugin.defaultXAxisVisible,e._currentDistanceMeasurementInitState.yAxisVisible=e._currentDistanceMeasurement.yAxisVisible&&e.distanceMeasurementsPlugin.defaultYAxisVisible,e._currentDistanceMeasurementInitState.zAxisVisible=e._currentDistanceMeasurement.zAxisVisible&&e.distanceMeasurementsPlugin.defaultZAxisVisible,e._currentDistanceMeasurementInitState.wireVisible=e._currentDistanceMeasurement.wireVisible,e._currentDistanceMeasurementInitState.targetVisible=e._currentDistanceMeasurement.targetVisible,e._currentDistanceMeasurement.clickable=!1,e._currentDistanceMeasurement.origin.entity=f,f=null,e.fire("measurementStart",e._currentDistanceMeasurement))))}),this._onCameraControlHoverSnapOrSurfaceOff=r.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",(function(n){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=n.canvasPos,e.pointerLens.snappedCanvasPos=n.snappedCanvasPos||n.canvasPos),u=!1,e._markerDiv.style.marginLeft="-100px",e._markerDiv.style.marginTop="-100px",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.axisVisible=!1),l.style.cursor="default"})),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this.reset();var e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);var n=this.distanceMeasurementsPlugin.viewer.cameraControl;n.off(this._onCameraControlHoverSnapOrSurface),n.off(this._onCameraControlHoverSnapOrSurfaceOff),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1}}},{key:"reset",value:function(){this._active&&this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null)}},{key:"destroy",value:function(){this.deactivate(),this._destroyMarkerDiv(),this.pointerLens&&this.pointerLens.destroy(),I(y(n.prototype),"destroy",this).call(this)}}])}(),Sp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,["DistanceMeasurements",e]))._pointerLens=i.pointerLens,t._container=i.container||e.viewerElement||document.body,t._defaultControl=null,t._measurements={},t.labelMinAxisLength=i.labelMinAxisLength,t.defaultVisible=!1!==i.defaultVisible,t.defaultOriginVisible=!1!==i.defaultOriginVisible,t.defaultTargetVisible=!1!==i.defaultTargetVisible,t.defaultWireVisible=!1!==i.defaultWireVisible,t.defaultLabelsVisible=!1!==i.defaultLabelsVisible,t.defaultAxisVisible=!1!==i.defaultAxisVisible,t.defaultXAxisVisible=!1!==i.defaultXAxisVisible,t.defaultYAxisVisible=!1!==i.defaultYAxisVisible,t.defaultZAxisVisible=!1!==i.defaultZAxisVisible,t.defaultLabelsOnWires=!1!==i.defaultLabelsOnWires,t.defaultColor=void 0!==i.defaultColor?i.defaultColor:"#0065fc",t.zIndex=i.zIndex||1e4,t.precision=void 0!==i.precision?i.precision:2,t._onMouseOver=function(e,n){t.fire("mouseOver",{plugin:t,distanceMeasurement:n,measurement:n,event:e})},t._onMouseLeave=function(e,n){t.fire("mouseLeave",{plugin:t,distanceMeasurement:n,measurement:n,event:e})},t._onMouseClick=function(e,n){t.fire("clickMeasure",{plugin:t,angleMeasurement:n,measurement:n,event:e})},t._onTouchStart=function(e,n){t.fire("touchMeasure",{plugin:t,angleMeasurement:n,measurement:n,event:e})},t._onContextMenu=function(e,n){t.fire("contextMenu",{plugin:t,distanceMeasurement:n,measurement:n,event:e})},t}return m(n,_e),C(n,[{key:"precision",get:function(){return this._precision},set:function(e){if(this._precision!=e&&(this._precision=e,this.measureNum>0))for(var n in this.measurements)this.measurements[n].precision=e}},{key:"scale",get:function(){return this._scale},set:function(e){if(this._scale!=e&&(this._scale=e,this.measureNum>0))for(var n in this.measurements)this.measurements[n].scale=e}},{key:"measureNum",get:function(){return Object.keys(this.measurements).length}},{key:"getContainerElement",value:function(){return this._container}},{key:"send",value:function(e,n){}},{key:"pointerLens",get:function(){return this._pointerLens}},{key:"control",get:function(){return this._defaultControl||(this._defaultControl=new Op(this,{})),this._defaultControl}},{key:"measurements",get:function(){return this._measurements}},{key:"labelMinAxisLength",get:function(){return this._labelMinAxisLength},set:function(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}},{key:"createMeasurement",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.viewer.scene.components[n.id]&&(this.error("Viewer scene component with this ID already exists: "+n.id),delete n.id);var t=n.origin,i=n.target,r=new Pp(this,{id:n.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.worldPos},borderColor:n.borderColor,color:n.color,visible:n.visible,originVisible:n.originVisible,targetVisible:n.targetVisible,wireVisible:n.wireVisible,axisVisible:!1!==n.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==n.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==n.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==n.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==n.labelsVisible&&!1!==this.defaultLabelsVisible,labelsOnWires:!1!==n.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onMouseClick:this._onMouseClick,onTouchStart:this._onTouchStart,onContextMenu:this._onContextMenu,precision:this._precision});return this._measurements[r.id]=r,r.on("destroyed",(function(){delete e._measurements[r.id]})),this.fire("measurementCreated",r),r}},{key:"destroyMeasurement",value:function(e){var n=this._measurements[e];n?(n.destroy(),this.fire("measurementDestroyed",n)):this.log("DistanceMeasurement not found: "+e)}},{key:"setLabelsShown",value:function(e){for(var n=0,t=Object.entries(this.measurements);n<t.length;n++){var i=f(t[n],2);i[0];i[1].labelShown=e}}},{key:"setAxisVisible",value:function(e){for(var n=0,t=Object.entries(this.measurements);n<t.length;n++){var i=f(t[n],2);i[0];i[1].axisVisible=e}this.defaultAxisVisible=e}},{key:"getAxisVisible",value:function(){return this.defaultAxisVisible}},{key:"clear",value:function(){for(var e=Object.keys(this._measurements),n=0,t=e.length;n<t;n++)this.destroyMeasurement(e[n])}},{key:"destroy",value:function(){this.clear(),I(y(n.prototype),"destroy",this).call(this)}}])}(),Np=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e.viewer.scene])).pointerLens=i.pointerLens,t.pointerCircle=new sn(e.viewer,{id:"distanceMeasure_Circle"}),t._active=!1,t._initMarkerDiv(),t._currentDistanceMeasurement=null,t._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},t._onCanvasTouchStart=null,t._onCanvasTouchEnd=null,t._longTouchTimeoutMs=300,t._snapping=!1!==i.snapping,t._snapToEdge=!1!==i.snapping,t._snapToVertex=!1!==i.snapping,t._touchState=0,t._attachPlugin(e,i),t._offsetX=0|i._offsetX,t._offsetY=0|i._offsetY,t}return m(n,_p),C(n,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myDistanceMeasureTouchMarker");var n=this.scene.canvas.canvas;n.parentNode.insertBefore(e,n),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.margin="-200px -200px",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this.markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){this.markerDiv&&(this.markerDiv.parentNode.removeChild(this.markerDiv),this.markerDiv=null)}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"offsetX",get:function(){return this._offsetX},set:function(e){this._offsetX=e}},{key:"offsetY",get:function(){return this._offsetY},set:function(e){this._offsetY=e}},{key:"active",get:function(){return this._active}},{key:"snapping",get:function(){return this._snapping},set:function(e){e!==this._snapping?(this._snapping=e,this.deactivate(),this.activate()):this._snapping=e}},{key:"activate",value:function(){var e=this;if(!this._active){var n=this.plugin,t=this.scene,i=t.canvas.canvas;this.pointerLens;var r=$.vec3(),l=20,a=null;this._touchState=0;var s=$.vec2(),u=$.vec2(),o=$.vec2(),c=null,f=function(){e.plugin.viewer.cameraControl.active=!1},p=function(){e.plugin.viewer.cameraControl.active=!0};i.addEventListener("touchstart",this._onCanvasTouchStart=function(i){if(i.isTrusted){var o=i.touches.length;if(1===o){var d=i.touches[0],v=d.clientX,A=d.clientY;switch(s.set([v,A]),u.set([v,A]),e._touchState){case 0:if(1!==o&&null!==a)return a&&(clearTimeout(a),a=null),e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),p(),void(e._touchState=0);var h=t.pick({canvasPos:u,snapping:e._snapping,snapToEdge:e._snapping});if(h&&h.snapped)r.set(h.worldPos),e.pointerCircle.start(h.snappedCanvasPos);else{var I=t.pick({canvasPos:u,pickSurface:!0});if(!I||!I.worldPos)return;r.set(I.worldPos),e.pointerCircle.start(I.canvasPos)}a=setTimeout((function(){1!==o||u[0]>s[0]+l||u[0]<s[0]-l||u[1]>s[1]+l||u[1]<s[1]-l||(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=s,e.pointerLens.cursorPos=s),e.pointerLens&&(e.pointerLens.canvasPos=u,e.pointerLens.snapped=!1),e.pointerLens&&(e.pointerLens.cursorPos=h.canvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=r:(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:r,entity:h.entity},target:{worldPos:r,entity:h.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.clickable=!1),e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement),e._touchState=2,f())}),e._longTouchTimeoutMs),e._touchState=1,c=d.identifier;break;case 3:if(1!==o&&null!==a)return clearTimeout(a),void(a=null);1===o&&(a=setTimeout((function(){if(a=null,!(1!==o||u[0]>s[0]+l||u[0]<s[0]-l||u[1]>s[1]+l||u[1]<s[1]-l)){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=s,e.pointerLens.snapped=!1);var n=t.pick({canvasPos:u,snapToVertex:e._snapping,snapToEdge:e._snapping});if(n&&n.snapped)e.pointerLens&&(e.pointerLens.cursorPos=n.snappedCanvasPos,e.pointerLens.snapped=!0),e.pointerCircle.start(n.snappedCanvasPos),r.set(n.worldPos),e._currentDistanceMeasurement.target.worldPos=n.worldPos,e._currentDistanceMeasurement.target.entity=n.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement);else{var i=t.pick({canvasPos:u,pickSurface:!0});i&&i.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=i.canvasPos,e.pointerLens.snapped=!1),e.pointerCircle.start(i.canvasPos),r.set(i.worldPos),e._currentDistanceMeasurement.target.worldPos=i.worldPos,e._currentDistanceMeasurement.target.entity=i.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):e.pointerLens&&(e.pointerLens.cursorPos=null,e.pointerLens.snapped=!1)}e._touchState=5,f()}}),e._longTouchTimeoutMs),e._touchState=4),c=d.identifier;break;default:return null!==a&&(clearTimeout(a),a=null),void(e._touchState=7)}}else a&&(clearTimeout(a),a=null)}},{passive:!0}),i.addEventListener("touchmove",(function(i){e.pointerCircle.stop();var l=i.touches.length;if(1===l&&1===i.changedTouches.length){var s,o,f=i.touches[0],p=f.clientX,d=f.clientY;if(f.identifier===c)switch(u.set([p,d]),e._touchState){case 2:e.pointerLens&&(e.pointerLens.canvasPos=u),(s=t.pick({canvasPos:u,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&s.snapped?(e.pointerLens&&(e.pointerLens.snappedCanvasPos=s.snappedCanvasPos,e.pointerLens.snapped=!0),r.set(s.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=s.worldPos:(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:s.worldPos,entity:s.entity},target:{worldPos:s.worldPos,entity:s.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.clickable=!1),e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):(o=t.pick({canvasPos:u,pickSurface:!0}))&&o.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=o.canvasPos,e.pointerLens.snapped=!1),r.set(o.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=o.worldPos:(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:o.worldPos,entity:o.entity},target:{worldPos:o.worldPos,entity:o.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.clickable=!1),e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):e.pointerLens&&(e.pointerLens.cursorPos=null,e.pointerLens.snapped=!1),e._touchState=2;break;case 5:if(1!==l&&null!==a)return clearTimeout(a),a=null,e.pointerLens&&(e.pointerLens.visible=!1),void(e._touchState=7);e.pointerLens&&(e.pointerLens.canvasPos=u),(s=t.pick({canvasPos:u,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&s.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=s.snappedCanvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement.target.worldPos=s.worldPos,e._currentDistanceMeasurement.target.entity=s.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0):(o=t.pick({canvasPos:u,pickSurface:!0}))&&o.worldPos&&(e.pointerLens&&(e.pointerLens.cursorPos=o.canvasPos,e.pointerLens.snapped=!1),e._currentDistanceMeasurement.target.worldPos=o.worldPos,e._currentDistanceMeasurement.target.entity=o.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0),e._touchState=5}}else a&&(clearTimeout(a),a=null)}),{passive:!0}),i.addEventListener("touchend",this._onCanvasTouchEnd=function(i){e.pointerCircle.stop();var r=i.changedTouches.length;if(1===r){var f=i.changedTouches[0],d=f.clientX,v=f.clientY;if(f.identifier===c)switch(a&&(clearTimeout(a),a=null),o.set([d,v]),e._touchState){case 1:if(1!==r||d>s[0]+l||d<s[0]-l||v>s[1]+l||v<s[1]-l)return void(e._touchState=0);var A=t.pick({canvasPos:u,pickSurface:!0});A&&A.worldPos?(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:A.worldPos,entity:A.entity},target:{worldPos:A.worldPos,entity:A.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._touchState=3,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):(e._currentDistanceMeasurement&&e._currentDistanceMeasurement.destroy(),e._touchState=0),p();break;case 2:e.pointerLens&&(e.pointerLens.visible=!1),e._currentDistanceMeasurement?e._touchState=3:(e.pointerLens&&(e.pointerLens.snapped=!1,e.pointerLens.visible=!1),e._touchState=0),p();break;case 4:if(1!==r||d>s[0]+l||d<s[0]-l||v>s[1]+l||v<s[1]-l)return void(e._touchState=3);var h=t.pick({canvasPos:u,pickSurface:!0});h&&h.worldPos?(e._currentDistanceMeasurement.target.worldPos=h.worldPos,e._currentDistanceMeasurement.target.entity=h.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e._currentDistanceMeasurement.clickable=!0,e.distanceMeasurementsPlugin.fire("measurementEnd",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null):e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),e._touchState=0,p();break;case 5:e.pointerLens&&(e.pointerLens.visible=!1),e._currentDistanceMeasurement&&e._currentDistanceMeasurement.targetVisible?(e._currentDistanceMeasurement.clickable=!0,e.distanceMeasurementsPlugin.fire("measurementEnd",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null,e._touchState=0):(e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),e._touchState=0),p()}}},{passive:!0}),i.addEventListener("touchcancel",this._onCanvasTouchEnd),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.pointerLens&&(this.pointerLens.visible=!1),this.reset();var e=this.plugin.viewer.scene.canvas.canvas;e.removeEventListener("touchstart",this._onCanvasTouchStart),e.removeEventListener("touchend",this._onCanvasTouchEnd),e.removeEventListener("touchcancel",this._onCanvasTouchEnd),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1,this.plugin.viewer.cameraControl.active=!0}}},{key:"reset",value:function(){this._active&&this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null)}},{key:"destroy",value:function(){this.deactivate(),this._destroyMarkerDiv(),this.pointerLens&&this.pointerLens.destroy(),this.pointerCircle&&this.pointerCircle.destroy(),I(y(n.prototype),"destroy",this).call(this)}}])}(),Bp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n),(t=v(this,n,["FastNav",e]))._hideColorTexture=!1!==i.hideColorTexture,t._hidePBR=!1!==i.hidePBR,t._hideSAO=!1!==i.hideSAO,t._hideEdges=!1!==i.hideEdges,t._hideTransparentObjects=!!i.hideTransparentObjects,t._scaleCanvasResolution=!!i.scaleCanvasResolution,t._scaleCanvasResolutionFactor=i.scaleCanvasResolutionFactor||.6,t._delayBeforeRestore=!1!==i.delayBeforeRestore,t._delayBeforeRestoreSeconds=i.delayBeforeRestoreSeconds||.5;var r=1e3*t._delayBeforeRestoreSeconds,l=!1,a=function(){r=1e3*t._delayBeforeRestoreSeconds,l||(e.scene._renderer.setColorTextureEnabled(!t._hideColorTexture),e.scene._renderer.setPBREnabled(!t._hidePBR),e.scene._renderer.setSAOEnabled(!t._hideSAO),e.scene._renderer.setTransparentEnabled(!t._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!t._hideEdges),t._scaleCanvasResolution?e.scene.canvas.resolutionScale=t._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=1,l=!0)};t._onCanvasBoundary=e.scene.canvas.on("boundary",a),t._onCameraMatrix=e.scene.camera.on("matrix",a),t._onSceneTick=e.scene.on("tick",(function(n){l&&(r-=n.deltaTime,(!t._delayBeforeRestore||r<=0)&&(e.scene.canvas.resolutionScale=1,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),l=!1))}));var s=!1;return t._onSceneMouseDown=e.scene.input.on("mousedown",(function(){s=!0})),t._onSceneMouseUp=e.scene.input.on("mouseup",(function(){s=!1})),t._onSceneMouseMove=e.scene.input.on("mousemove",(function(){s&&a()})),t}return m(n,_e),C(n,[{key:"hideColorTexture",get:function(){return this._hideColorTexture},set:function(e){this._hideColorTexture=e}},{key:"hidePBR",get:function(){return this._hidePBR},set:function(e){this._hidePBR=e}},{key:"hideSAO",get:function(){return this._hideSAO},set:function(e){this._hideSAO=e}},{key:"hideEdges",get:function(){return this._hideEdges},set:function(e){this._hideEdges=e}},{key:"hideTransparentObjects",get:function(){return this._hideTransparentObjects},set:function(e){this._hideTransparentObjects=!1!==e}},{key:"scaleCanvasResolution",get:function(){return this._scaleCanvasResolution},set:function(e){this._scaleCanvasResolution=e}},{key:"scaleCanvasResolutionFactor",get:function(){return this._scaleCanvasResolutionFactor},set:function(e){this._scaleCanvasResolutionFactor=e||.6}},{key:"delayBeforeRestore",get:function(){return this._delayBeforeRestore},set:function(e){this._delayBeforeRestore=e}},{key:"delayBeforeRestoreSeconds",get:function(){return this._delayBeforeRestoreSeconds},set:function(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}},{key:"send",value:function(e,n){}},{key:"destroy",value:function(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),I(y(n.prototype),"destroy",this).call(this)}}])}(),Lp=function(){return C((function e(){T(this,e)}),[{key:"getMetaModel",value:function(e,n,t){ue.loadJSON(e,(function(e){n(e)}),(function(e){t(e)}))}},{key:"getGLTF",value:function(e,n,t){ue.loadArraybuffer(e,(function(e){n(e)}),(function(e){t(e)}))}},{key:"getGLB",value:function(e,n,t){ue.loadArraybuffer(e,(function(e){n(e)}),(function(e){t(e)}))}},{key:"getArrayBuffer",value:function(e,n,t,i){!function(e,n,t,i){var r=function(){};t=t||r,i=i||r;var l=/^data:(.*?)(;base64)?,(.*)$/,a=n.match(l);if(a){var s=!!a[2],u=a[3];u=window.decodeURIComponent(u),s&&(u=window.atob(u));try{for(var o=new ArrayBuffer(u.length),c=new Uint8Array(o),f=0;f<u.length;f++)c[f]=u.charCodeAt(f);he.scheduleTask((function(){t(o)}))}catch(e){he.scheduleTask((function(){i(e)}))}}else{var p=function(e){var n=e.lastIndexOf("/");return 0!==n?e.substring(0,n+1):""}(e),d=p+n,v=new XMLHttpRequest;v.open("GET",d,!0),v.responseType="arraybuffer",v.onreadystatechange=function(){4===v.readyState&&(200===v.status?t(v.response):i("loadArrayBuffer error : "+v.response))},v.send(null)}}(e,n,(function(e){t(e)}),(function(e){i(e)}))}}])}();var Mp=function(){return C((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};T(this,e),this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=n.messages,this.locale=n.locale}),[{key:"messages",set:function(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}},{key:"loadMessages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var n in e)this._messages[n]=e[n];this.messages=this._messages}},{key:"clearMessages",value:function(){this.messages={}}},{key:"locales",get:function(){return this._locales}},{key:"locale",get:function(){return this._locale},set:function(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}},{key:"translate",value:function(e,n){var t=this._messages[this._locale];if(!t)return null;var i=Fp(e,t);return i?n?xp(i,n):i:null}},{key:"translatePlurals",value:function(e,n,t){var i=this._messages[this._locale];if(!i)return null;var r=Fp(e,i);return(r=0===(n=parseInt(""+n,10))?r.zero:n>1?r.other:r.one)?(r=xp(r,[n]),t&&(r=xp(r,t)),r):null}},{key:"fire",value:function(e,n,t){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==t&&(this._events[e]=n||!0);var i=this._eventSubs[e];if(i)for(var r in i){if(i.hasOwnProperty(r))i[r].callback(n)}}},{key:"on",value:function(e,n){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new G),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});var t=this._eventSubs[e];t||(t={},this._eventSubs[e]=t);var i=this._eventSubIDMap.addItem();t[i]={callback:n},this._eventSubEvents[i]=e;var r=this._events[e];return void 0!==r&&n(r),i}},{key:"off",value:function(e){if(null!=e&&this._eventSubEvents){var n=this._eventSubEvents[e];if(n){delete this._eventSubEvents[e];var t=this._eventSubs[n];t&&delete t[e],this._eventSubIDMap.removeItem(e)}}}}])}();function Fp(e,n){if(n[e])return n[e];for(var t=e.split("."),i=n,r=0,l=t.length;i&&r<l;r++){i=i[t[r]]}return i}function xp(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,t){return"{{"===e?"{":"}}"===e?"}":n[t]}))}var Hp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).t=i.t,t}return m(n,me),C(n,[{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"tangent",get:function(){return this.getTangent(this._t)}},{key:"length",get:function(){var e=this._getLengths();return e[e.length-1]}},{key:"getTangent",value:function(e){var n=1e-4;void 0===e&&(e=this._t);var t=e-n,i=e+n;t<0&&(t=0),i>1&&(i=1);var r=this.getPoint(t),l=this.getPoint(i),a=$.subVec3(l,r,[]);return $.normalizeVec3(a,[])}},{key:"getPointAt",value:function(e){var n=this.getUToTMapping(e);return this.getPoint(n)}},{key:"getPoints",value:function(e){e||(e=5);var n,t=[];for(n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}},{key:"_getLengths",value:function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n,t,i=[],r=this.getPoint(0),l=0;for(i.push(0),t=1;t<=e;t++)n=this.getPoint(t/e),l+=$.lenVec3($.subVec3(n,r,[])),i.push(l),r=n;return this.cacheArcLengths=i,i}},{key:"_updateArcLengths",value:function(){this.needsUpdate=!0,this._getLengths()}},{key:"getUToTMapping",value:function(e,n){var t,i=this._getLengths(),r=0,l=i.length;t=n||e*i[l-1];for(var a,s=0,u=l-1;s<=u;)if((a=i[r=Math.floor(s+(u-s)/2)]-t)<0)s=r+1;else{if(!(a>0)){u=r;break}u=r-1}if(i[r=u]===t)return r/(l-1);var o=i[r];return(r+(t-o)/(i[r+1]-o))/(l-1)}}])}(),Up=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).points=i.points,t.t=i.t,t}return m(n,Hp),C(n,[{key:"points",get:function(){return this._points},set:function(e){this._points=e||[]}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var n=this.points;if(!(n.length<3)){var t=(n.length-1)*e,i=Math.floor(t),r=t-i,l=n[0===i?i:i-1],a=n[i],s=n[i>n.length-2?n.length-1:i+1],u=n[i>n.length-3?n.length-1:i+2],o=$.vec3();return o[0]=$.catmullRomInterpolate(l[0],a[0],s[0],u[0],r),o[1]=$.catmullRomInterpolate(l[1],a[1],s[1],u[1],r),o[2]=$.catmullRomInterpolate(l[2],a[2],s[2],u[2],r),o}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}},{key:"getJSON",value:function(){return{points:points,t:this._t}}}])}(),Gp=$.vec3(),kp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._frames=[],t._eyeCurve=new Up(t),t._lookCurve=new Up(t),t._upCurve=new Up(t),i.frames&&(t.addFrames(i.frames),t.smoothFrameTimes(1)),t}return m(n,me),C(n,[{key:"type",get:function(){return"CameraPath"}},{key:"frames",get:function(){return this._frames}},{key:"eyeCurve",get:function(){return this._eyeCurve}},{key:"lookCurve",get:function(){return this._lookCurve}},{key:"upCurve",get:function(){return this._upCurve}},{key:"saveFrame",value:function(e){var n=this.scene.camera;this.addFrame(e,n.eye,n.look,n.up)}},{key:"addFrame",value:function(e,n,t,i){var r={t:e,eye:n.slice(0),look:t.slice(0),up:i.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}},{key:"addFrames",value:function(e){for(var n,t=0,i=e.length;t<i;t++)n=e[t],this.addFrame(n.t||0,n.eye,n.look,n.up)}},{key:"loadFrame",value:function(e){var n=this.scene.camera;e=(e/=this._frames[this._frames.length-1].t-this._frames[0].t)<0?0:e>1?1:e,n.eye=this._eyeCurve.getPoint(e,Gp),n.look=this._lookCurve.getPoint(e,Gp),n.up=this._upCurve.getPoint(e,Gp)}},{key:"sampleFrame",value:function(e,n,t,i){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,n),this._lookCurve.getPoint(e,t),this._upCurve.getPoint(e,i)}},{key:"smoothFrameTimes",value:function(e){if(0!==this._frames.length){var n=$.vec3(),t=0;this._frames[0].t=0;for(var i=[],r=1,l=this._frames.length;r<l;r++){var a=$.lenVec3($.subVec3(this._frames[r].eye,this._frames[r-1].eye,n));i[r]=a,t+=a}for(var s=1,u=this._frames.length;s<u;s++){var o=i[s]/t*e;this._frames[s].t=this._frames[s-1].t+o}}}},{key:"clearFrames",value:function(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}}])}(),Vp=$.vec3(),jp=$.vec3(),Qp=$.vec3(),Wp=$.vec3(),zp=$.vec3(),Yp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._look1=$.vec3(),t._eye1=$.vec3(),t._up1=$.vec3(),t._look2=$.vec3(),t._eye2=$.vec3(),t._up2=$.vec3(),t._orthoScale1=1,t._orthoScale2=1,t._flying=!1,t._flyEyeLookUp=!1,t._flyingEye=!1,t._flyingLook=!1,t._callback=null,t._callbackScope=null,t._time1=null,t._time2=null,t.easing=!1!==i.easing,t.duration=i.duration,t.fit=i.fit,t.fitFOV=i.fitFOV,t.trail=i.trail,t}return m(n,me),C(n,[{key:"type",get:function(){return"CameraFlightAnimation"}},{key:"flyTo",value:function(e,n,t){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=n,this._callbackScope=t;var i,r,l,a,s,u=this.scene.camera,o=!!e.projection&&e.projection!==u.projection;if(this._eye1[0]=u.eye[0],this._eye1[1]=u.eye[1],this._eye1[2]=u.eye[2],this._look1[0]=u.look[0],this._look1[1]=u.look[1],this._look1[2]=u.look[2],this._up1[0]=u.up[0],this._up1[1]=u.up[1],this._up1[2]=u.up[2],this._orthoScale1=u.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)i=e.aabb;else if(6===e.length)i=e;else if(e.eye&&e.look||e.up)r=e.eye,l=e.look,a=e.up;else if(e.eye)r=e.eye;else if(e.look)l=e.look;else{var c=e;if((ue.isNumeric(c)||ue.isString(c))&&(s=c,!(c=this.scene.components[s])))return this.error("Component not found: "+ue.inQuotes(s)),void(n&&(t?n.call(t):n()));o||(i=c.aabb||this.scene.aabb)}var f=e.poi;if(i){if(i[3]<i[0]||i[4]<i[1]||i[5]<i[2])return;if(i[3]===i[0]&&i[4]===i[1]&&i[5]===i[2])return;i=i.slice();var p=$.getAABB3Center(i);this._look2=f||p;var d=$.subVec3(this._eye1,this._look1,Vp),v=$.normalizeVec3(d),A=f?$.getAABB3DiagPoint(i,f):$.getAABB3Diag(i),h=e.fitFOV||this._fitFOV,I=Math.abs(A/Math.tan(h*$.DEGTORAD));this._orthoScale2=1.1*A,this._eye2[0]=this._look2[0]+v[0]*I,this._eye2[1]=this._look2[1]+v[1]*I,this._eye2[2]=this._look2[2]+v[2]*I,this._up2[0]=this._up1[0],this._up2[1]=this._up1[1],this._up2[2]=this._up1[2],this._flyingEyeLookUp=!0}else(r||l||a)&&(this._flyingEyeLookUp=!!r&&!!l&&!!a,this._flyingEye=!!r&&!l,this._flyingLook=!!l&&!r,r&&(this._eye2[0]=r[0],this._eye2[1]=r[1],this._eye2[2]=r[2]),l&&(this._look2[0]=l[0],this._look2[1]=l[1],this._look2[2]=l[2]),a&&(this._up2[0]=a[0],this._up2[1]=a[1],this._up2[2]=a[2]));o?("ortho"===e.projection&&"ortho"!==u.projection&&(this._projection2="ortho",this._projMatrix1=u.projMatrix.slice(),this._projMatrix2=u.ortho.matrix.slice(),u.projection="customProjection"),"perspective"===e.projection&&"perspective"!==u.projection&&(this._projection2="perspective",this._projMatrix1=u.projMatrix.slice(),this._projMatrix2=u.perspective.matrix.slice(),u.projection="customProjection")):this._projection2=null,this.fire("started",e,!0),this._time1=Date.now(),this._time2=this._time1+(e.duration?1e3*e.duration:this._duration),this._flying=!0,he.scheduleTask(this._update,this)}},{key:"jumpTo",value:function(e){this._jumpTo(e)}},{key:"_jumpTo",value:function(e){this._flying&&this.stop();var n,t,i,r,l,a=this.scene.camera;if(e.aabb)n=e.aabb;else if(6===e.length)n=e;else if(e.eye||e.look||e.up)i=e.eye,r=e.look,l=e.up;else{var s=e;if((ue.isNumeric(s)||ue.isString(s))&&(t=s,!(s=this.scene.components[t])))return void this.error("Component not found: "+ue.inQuotes(t));n=s.aabb||this.scene.aabb}var u=e.poi;if(n){if(n[3]<=n[0]||n[4]<=n[1]||n[5]<=n[2])return;var o,c=u?$.getAABB3DiagPoint(n,u):$.getAABB3Diag(n);r=u||$.getAABB3Center(n,r),this._trail?$.subVec3(a.look,r,zp):$.subVec3(a.eye,a.look,zp),$.normalizeVec3(zp),o=(void 0!==e.fit?e.fit:this._fit)?Math.abs(c/Math.tan((e.fitFOV||this._fitFOV)*$.DEGTORAD)):$.lenVec3($.subVec3(a.eye,a.look,Vp)),$.mulVec3Scalar(zp,o),a.eye=$.addVec3(r,zp,Vp),a.look=r,this.scene.camera.ortho.scale=1.1*c}else(i||r||l)&&(i&&(a.eye=i),r&&(a.look=r),l&&(a.up=l));e.projection&&(a.projection=e.projection)}},{key:"_update",value:function(){if(this._flying){var e=(Date.now()-this._time1)/(this._time2-this._time1),t=e>=1;e>1&&(e=1);var i=this.easing?n._ease(e,0,1,1):e,r=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?($.subVec3(r.eye,r.look,zp),r.eye=$.lerpVec3(i,0,1,this._eye1,this._eye2,Qp),r.look=$.subVec3(Qp,zp,jp)):this._flyingLook&&(r.look=$.lerpVec3(i,0,1,this._look1,this._look2,jp),r.up=$.lerpVec3(i,0,1,this._up1,this._up2,Wp)):this._flyingEyeLookUp&&(r.eye=$.lerpVec3(i,0,1,this._eye1,this._eye2,Qp),r.look=$.lerpVec3(i,0,1,this._look1,this._look2,jp),r.up=$.lerpVec3(i,0,1,this._up1,this._up2,Wp)),this._projection2){var l="ortho"===this._projection2?n._easeOutExpo(e,0,1,1):n._easeInCubic(e,0,1,1);r.customProjection.matrix=$.lerpMat4(l,0,1,this._projMatrix1,this._projMatrix2)}else r.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return r.ortho.scale=this._orthoScale2,void this.stop();he.scheduleTask(this._update,this)}}},{key:"stop",value:function(){if(this._flying){this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);var e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}}},{key:"cancel",value:function(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}},{key:"duration",get:function(){return this._duration/1e3},set:function(e){this._duration=e?1e3*e:500,this.stop()}},{key:"fit",get:function(){return this._fit},set:function(e){this._fit=!1!==e}},{key:"fitFOV",get:function(){return this._fitFOV},set:function(e){this._fitFOV=e||45}},{key:"trail",get:function(){return this._trail},set:function(e){this._trail=!!e}},{key:"destroy",value:function(){this.stop(),I(y(n.prototype),"destroy",this).call(this)}}],[{key:"_ease",value:function(e,n,t,i){return-t*(e/=i)*(e-2)+n}},{key:"_easeInCubic",value:function(e,n,t,i){return t*(e/=i)*e*e+n}},{key:"_easeOutExpo",value:function(e,n,t,i){return t*(1-Math.pow(2,-10*e/i))+n}}])}(),Kp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._cameraFlightAnimation=new Yp(t),t._t=0,t.state=n.SCRUBBING,t._playingFromT=0,t._playingToT=0,t._playingRate=i.playingRate||1,t._playingDir=1,t._lastTime=null,t.cameraPath=i.cameraPath,t._tick=t.scene.on("tick",t._updateT,t),t}return m(n,me),C(n,[{key:"type",get:function(){return"CameraPathAnimation"}},{key:"_updateT",value:function(){var e=this._cameraPath;if(e){var t,i,r=performance.now(),l=this._lastTime?.001*(r-this._lastTime):0;if(this._lastTime=r,0!==l)switch(this.state){case n.SCRUBBING:return;case n.PLAYING:if(this._t+=this._playingRate*l,0===(t=this._cameraPath.frames.length)||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=n.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case n.PLAYING_TO:i=this._t+this._playingRate*l*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=n.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}}},{key:"_ease",value:function(e,n,t,i){return-t*(e/=i)*(e-2)+n}},{key:"cameraPath",get:function(){return this._cameraPath},set:function(e){this._cameraPath=e}},{key:"rate",get:function(){return this._playingRate},set:function(e){this._playingRate=e}},{key:"play",value:function(){this._cameraPath&&(this._lastTime=null,this.state=n.PLAYING)}},{key:"playToT",value:function(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=n.PLAYING_TO)}},{key:"playToFrame",value:function(e){var n=this._cameraPath;if(n){var t=n.frames[e];t?this.playToT(t.t):this.error("playToFrame - frame index out of range: "+e)}}},{key:"flyToFrame",value:function(e,t){var i=this._cameraPath;if(i){var r=i.frames[e];r?(this.state=n.SCRUBBING,this._cameraFlightAnimation.flyTo(r,t)):this.error("flyToFrame - frame index out of range: "+e)}}},{key:"scrubToT",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=n.SCRUBBING))}},{key:"scrubToFrame",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(t.frames[e]?(t.loadFrame(this._t),this.state=n.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)))}},{key:"stop",value:function(){this.state=n.SCRUBBING,this.fire("stopped")}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene.off(this._tick)}}])}();Kp.STOPPED=0,Kp.SCRUBBING=1,Kp.PLAYING=2,Kp.PLAYING_TO=3;var Xp=$.vec3(),qp=$.vec3();$.vec3();var Jp=$.vec3([0,-1,0]),Zp=$.vec4([0,0,0,1]),$p=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._src=null,t._image=null,t._pos=$.vec3(),t._origin=$.vec3(),t._rtcPos=$.vec3(),t._dir=$.vec3(),t._size=1,t._imageSize=$.vec2(),t._texture=new Hl(t),t._plane=new ll(t,{geometry:new Ft(t,Kl({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new kt(t,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:t._texture,emissiveMap:t._texture,backfaces:!0}),clippable:i.clippable}),t._grid=new ll(t,{geometry:new Ft(t,Yl({size:1,divisions:10})),material:new kt(t,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:i.clippable}),t._node=new El(t,{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[t._plane,t._grid]}),t._gridVisible=!1,t.visible=!0,t.gridVisible=i.gridVisible,t.position=i.position,t.rotation=i.rotation,t.dir=i.dir,t.size=i.size,t.collidable=i.collidable,t.clippable=i.clippable,t.pickable=i.pickable,t.opacity=i.opacity,i.image?t.image=i.image:t.src=i.src,t}return m(n,me),C(n,[{key:"visible",get:function(){return this._plane.visible},set:function(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}},{key:"gridVisible",get:function(){return this._gridVisible},set:function(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var n=this;if(this._src=e,this._src){this._image=null;var t=new Image;t.onload=function(){n._texture.image=t,n._imageSize[0]=t.width,n._imageSize[1]=t.height,n._updatePlaneSizeFromImage()},t.src=this._src}}},{key:"position",get:function(){return this._pos},set:function(e){this._pos.set(e||[0,0,0]),Ne(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}},{key:"rotation",get:function(){return this._node.rotation},set:function(e){this._node.rotation=e}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"dir",get:function(){return this._dir},set:function(e){if(this._dir.set(e||[0,0,-1]),e){var n=this.scene.center,t=[-this._dir[0],-this._dir[1],-this._dir[2]];$.subVec3(n,this.position,Xp);var i=-$.dotVec3(t,Xp);$.normalizeVec3(t),$.mulVec3Scalar(t,i,qp),$.vec3PairToQuaternion(Jp,e,Zp),this._node.quaternion=Zp}}},{key:"collidable",get:function(){return this._node.collidable},set:function(e){this._node.collidable=!1!==e}},{key:"clippable",get:function(){return this._node.clippable},set:function(e){this._node.clippable=!1!==e}},{key:"pickable",get:function(){return this._node.pickable},set:function(e){this._node.pickable=!1!==e}},{key:"opacity",get:function(){return this._node.opacity},set:function(e){this._node.opacity=e}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this)}},{key:"_updatePlaneSizeFromImage",value:function(){var e=this._size,n=this._imageSize[0],t=this._imageSize[1];if(n>t){var i=t/n;this._node.scale=[e,1,e*i]}else{var r=n/t;this._node.scale=[e*r,1,e]}}}])}(),ed=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n);var r=t=v(this,n,[e,i]);t._shadowRenderBuf=null,t._shadowViewMatrix=null,t._shadowProjMatrix=null,t._shadowViewMatrixDirty=!0,t._shadowProjMatrixDirty=!0;var l=t.scene.camera,a=t.scene.canvas;return t._onCameraViewMatrix=l.on("viewMatrix",(function(){t._shadowViewMatrixDirty=!0})),t._onCameraProjMatrix=l.on("projMatrix",(function(){t._shadowProjMatrixDirty=!0})),t._onCanvasBoundary=a.on("boundary",(function(){t._shadowProjMatrixDirty=!0})),t._state=new Zn({type:"point",pos:$.vec3([1,1,1]),color:$.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:i.space||"view",castsShadow:!1,getShadowViewMatrix:function(){if(r._shadowViewMatrixDirty){r._shadowViewMatrix||(r._shadowViewMatrix=$.identityMat4());var e=r._state.pos,n=l.look,t=l.up;$.lookAtMat4v(e,n,t,r._shadowViewMatrix),r._shadowViewMatrixDirty=!1}return r._shadowViewMatrix},getShadowProjMatrix:function(){if(r._shadowProjMatrixDirty){r._shadowProjMatrix||(r._shadowProjMatrix=$.identityMat4());var e=r.scene.canvas.canvas;$.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,r._shadowProjMatrix),r._shadowProjMatrixDirty=!1}return r._shadowProjMatrix},getShadowRenderBuf:function(){return r._shadowRenderBuf||(r._shadowRenderBuf=new zn(r.scene.canvas.canvas,r.scene.canvas.gl,{size:[1024,1024]})),r._shadowRenderBuf}}),t.pos=i.pos,t.color=i.color,t.intensity=i.intensity,t.constantAttenuation=i.constantAttenuation,t.linearAttenuation=i.linearAttenuation,t.quadraticAttenuation=i.quadraticAttenuation,t.castsShadow=i.castsShadow,t.scene._lightCreated(t),t}return m(n,wt),C(n,[{key:"type",get:function(){return"PointLight"}},{key:"pos",get:function(){return this._state.pos},set:function(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}},{key:"color",get:function(){return this._state.color},set:function(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}},{key:"intensity",get:function(){return this._state.intensity},set:function(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}},{key:"constantAttenuation",get:function(){return this._state.attenuation[0]},set:function(e){this._state.attenuation[0]=e||0,this.glRedraw()}},{key:"linearAttenuation",get:function(){return this._state.attenuation[1]},set:function(e){this._state.attenuation[1]=e||0,this.glRedraw()}},{key:"quadraticAttenuation",get:function(){return this._state.attenuation[2]},set:function(e){this._state.attenuation[2]=e||0,this.glRedraw()}},{key:"castsShadow",get:function(){return this._state.castsShadow},set:function(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}},{key:"destroy",value:function(){var e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),I(y(n.prototype),"destroy",this).call(this),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}])}();function nd(e){return 0==(e&e-1)}function td(e){--e;for(var n=1;n<32;n<<=1)e|=e>>n;return e+1}var id=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n);var r=(t=v(this,n,[e,i])).scene.canvas.gl;return t._state=new Zn({texture:new Nl({gl:r,target:r.TEXTURE_CUBE_MAP}),flipY:t._checkFlipY(i.minFilter),encoding:t._checkEncoding(i.encoding),minFilter:pi,magFilter:oi,wrapS:ti,wrapT:ti,mipmaps:!0}),t._src=i.src,t._images=[],t._loadSrc(i.src),ie.memory.textures++,t}return m(n,me),C(n,[{key:"type",get:function(){return"CubeTexture"}},{key:"_checkFlipY",value:function(e){return!!e}},{key:"_checkEncoding",value:function(e){return(e=e||or)!==or&&e!==cr&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=or),e}},{key:"_webglContextRestored",value:function(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}},{key:"_loadSrc",value:function(e){var n=this,t=this.scene.canvas.gl;this._images=[];for(var i=!1,r=0,l=function(l){var a,s,u=new Image;u.onload=(a=u,s=l,function(){if(!i&&(a=function(e){if(!nd(e.width)||!nd(e.height)){var n=document.createElement("canvas");n.width=td(e.width),n.height=td(e.height),n.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,n.width,n.height),e=n}return e}(a),n._images[s]=a,6==++r)){var e=n._state.texture;e||(e=new Nl({gl:t,target:t.TEXTURE_CUBE_MAP}),n._state.texture=e),e.setImage(n._images,n._state),n.fire("loaded",n._src,!1),n.glRedraw()}}),u.onerror=function(){i=!0},u.src=e[l]},a=0;a<e.length;a++)l(a)}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this._state.texture&&this._state.texture.destroy(),ie.memory.textures--,this._state.destroy()}}])}(),rd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).scene._lightsState.addReflectionMap(t._state),t.scene._reflectionMapCreated(t),t}return m(n,id),C(n,[{key:"type",get:function(){return"ReflectionMap"}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene._reflectionMapDestroyed(this)}}])}(),ld=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).scene._lightMapCreated(t),t}return m(n,id),C(n,[{key:"type",get:function(){return"LightMap"}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene._lightMapDestroyed(this)}}])}(),ad=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,{entity:i.entity,occludable:i.occludable,worldPos:i.worldPos}]))._occluded=!1,t._visible=!0,t._src=null,t._image=null,t._pos=$.vec3(),t._origin=$.vec3(),t._rtcPos=$.vec3(),t._dir=$.vec3(),t._size=1,t._imageSize=$.vec2(),t._texture=new Hl(t,{src:i.src}),t._geometry=new Ft(t,{primitive:"triangles",positions:[3,3,0,-3,3,0,-3,-3,0,3,-3,0],normals:[-1,0,0,-1,0,0,-1,0,0,-1,0,0],uv:[1,-1,0,-1,0,0,1,0],indices:[0,1,2,0,2,3]}),t._mesh=new ll(t,{geometry:t._geometry,material:new kt(t,{ambient:[.9,.3,.9],shininess:30,diffuseMap:t._texture,backfaces:!0}),scale:[1,1,1],position:i.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),t.visible=!0,t.collidable=i.collidable,t.clippable=i.clippable,t.pickable=i.pickable,t.opacity=i.opacity,t.size=i.size,i.image?t.image=i.image:t.src=i.src,t}return m(n,qe),C(n,[{key:"_setVisible",value:function(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,I(y(n.prototype),"_setVisible",this).call(this,e)}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=null==e||e,this._mesh.visible=this._visible&&!this._occluded}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var n=this;if(this._src=e,this._src){this._image=null;var t=new Image;t.onload=function(){n._texture.image=t,n._imageSize[0]=t.width,n._imageSize[1]=t.height,n._updatePlaneSizeFromImage()},t.src=this._src}}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"collidable",get:function(){return this._mesh.collidable},set:function(e){this._mesh.collidable=!1!==e}},{key:"clippable",get:function(){return this._mesh.clippable},set:function(e){this._mesh.clippable=!1!==e}},{key:"pickable",get:function(){return this._mesh.pickable},set:function(e){this._mesh.pickable=!1!==e}},{key:"opacity",get:function(){return this._mesh.opacity},set:function(e){this._mesh.opacity=e}},{key:"_updatePlaneSizeFromImage",value:function(){var e=.5*this._size,n=this._imageSize[0],t=this._imageSize[1],i=t/n;this._geometry.positions=n>t?[e,e*i,0,-e,e*i,0,-e,-e*i,0,e,-e*i,0]:[e/i,e,0,-e/i,e,0,-e/i,-e,0,e/i,-e,0]}}])}(),sd=function(){return C((function e(n){T(this,e),this._eye=$.vec3(),this._look=$.vec3(),this._up=$.vec3(),this._projection={},n&&this.saveCamera(n)}),[{key:"saveCamera",value:function(e){var n=e.camera,t=n.project;switch(this._eye.set(n.eye),this._look.set(n.look),this._up.set(n.up),n.projection){case"perspective":this._projection={projection:"perspective",fov:t.fov,fovAxis:t.fovAxis,near:t.near,far:t.far};break;case"ortho":this._projection={projection:"ortho",scale:t.scale,near:t.near,far:t.far};break;case"frustum":this._projection={projection:"frustum",left:t.left,right:t.right,top:t.top,bottom:t.bottom,near:t.near,far:t.far};break;case"custom":this._projection={projection:"custom",matrix:t.matrix.slice()}}}},{key:"restoreCamera",value:function(e,n){var t=e.camera,i=this._projection;function r(){switch(i.type){case"perspective":t.perspective.fov=i.fov,t.perspective.fovAxis=i.fovAxis,t.perspective.near=i.near,t.perspective.far=i.far;break;case"ortho":t.ortho.scale=i.scale,t.ortho.near=i.near,t.ortho.far=i.far;break;case"frustum":t.frustum.left=i.left,t.frustum.right=i.right,t.frustum.top=i.top,t.frustum.bottom=i.bottom,t.frustum.near=i.near,t.frustum.far=i.far;break;case"custom":t.customProjection.matrix=i.matrix}}n?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:i.scale,projection:i.projection},(function(){r(),n()})):(t.eye=this._eye,t.look=this._look,t.up=this._up,r(),t.projection=i.projection)}}])}(),ud=$.vec3(),od=function(){return C((function e(n){if(T(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,n){var t=n.metaScene.scene;this.saveObjects(t,n)}}),[{key:"saveObjects",value:function(e,n,t){this.numObjects=0,this._mask=t?ue.apply(t,{}):null;for(var i=!t||t.visible,r=!t||t.edges,l=!t||t.xrayed,a=!t||t.highlighted,s=!t||t.selected,u=!t||t.clippable,o=!t||t.pickable,c=!t||t.colorize,f=!t||t.opacity,p=n.metaObjects,d=e.objects,v=0,A=p.length;v<A;v++){var h=d[p[v].id];if(h){if(i&&(this.objectsVisible[v]=h.visible),r&&(this.objectsEdges[v]=h.edges),l&&(this.objectsXrayed[v]=h.xrayed),a&&(this.objectsHighlighted[v]=h.highlighted),s&&(this.objectsSelected[v]=h.selected),u&&(this.objectsClippable[v]=h.clippable),o&&(this.objectsPickable[v]=h.pickable),c){var I=h.colorize;this.objectsColorize[3*v+0]=I[0],this.objectsColorize[3*v+1]=I[1],this.objectsColorize[3*v+2]=I[2]}f&&(this.objectsOpacity[v]=h.opacity),this.numObjects++}}}},{key:"restoreObjects",value:function(e,n){for(var t=this._mask,i=!t||t.visible,r=!t||t.edges,l=!t||t.xrayed,a=!t||t.highlighted,s=!t||t.selected,u=!t||t.clippable,o=!t||t.pickable,c=!t||t.colorize,f=!t||t.opacity,p=n.metaObjects,d=e.objects,v=0,A=p.length;v<A;v++){var h=d[p[v].id];h&&(i&&(h.visible=this.objectsVisible[v]),r&&(h.edges=this.objectsEdges[v]),l&&(h.xrayed=this.objectsXrayed[v]),a&&(h.highlighted=this.objectsHighlighted[v]),s&&(h.selected=this.objectsSelected[v]),u&&(h.clippable=this.objectsClippable[v]),o&&(h.pickable=this.objectsPickable[v]),c&&(ud[0]=this.objectsColorize[3*v+0],ud[1]=this.objectsColorize[3*v+1],ud[2]=this.objectsColorize[3*v+2],h.colorize=ud),f&&(h.opacity=this.objectsOpacity[v]))}}}])}(),cd=$.vec3(),fd=function(){return C((function e(){T(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsHasColorize=[],this.objectsOpacity=[],this.numObjects=0}),[{key:"saveObjects",value:function(e,n){this.numObjects=0,this._mask=n?ue.apply(n,{}):null;var t=e.objects,i=!n||n.visible,r=!n||n.edges,l=!n||n.xrayed,a=!n||n.highlighted,s=!n||n.selected,u=!n||n.clippable,o=!n||n.pickable,c=!n||n.colorize,f=!n||n.opacity;for(var p in t)if(t.hasOwnProperty(p)){var d=t[p],v=this.numObjects;if(i&&(this.objectsVisible[v]=d.visible),r&&(this.objectsEdges[v]=d.edges),l&&(this.objectsXrayed[v]=d.xrayed),a&&(this.objectsHighlighted[v]=d.highlighted),s&&(this.objectsSelected[v]=d.selected),u&&(this.objectsClippable[v]=d.clippable),o&&(this.objectsPickable[v]=d.pickable),c){var A=d.colorize;A?(this.objectsColorize[3*v+0]=A[0],this.objectsColorize[3*v+1]=A[1],this.objectsColorize[3*v+2]=A[2],this.objectsHasColorize[v]=!0):this.objectsHasColorize[v]=!1}f&&(this.objectsOpacity[v]=d.opacity),this.numObjects++}}},{key:"restoreObjects",value:function(e){var n=this._mask,t=!n||n.visible,i=!n||n.edges,r=!n||n.xrayed,l=!n||n.highlighted,a=!n||n.selected,s=!n||n.clippable,u=!n||n.pickable,o=!n||n.colorize,c=!n||n.opacity,f=0,p=e.objects;for(var d in p)if(p.hasOwnProperty(d)){var v=p[d];t&&(v.visible=this.objectsVisible[f]),i&&(v.edges=this.objectsEdges[f]),r&&(v.xrayed=this.objectsXrayed[f]),l&&(v.highlighted=this.objectsHighlighted[f]),a&&(v.selected=this.objectsSelected[f]),s&&(v.clippable=this.objectsClippable[f]),u&&(v.pickable=this.objectsPickable[f]),o&&(this.objectsHasColorize[f]?(cd[0]=this.objectsColorize[3*f+0],cd[1]=this.objectsColorize[3*f+1],cd[2]=this.objectsColorize[3*f+2],v.colorize=cd):v.colorize=null),c&&(v.opacity=this.objectsOpacity[f]),f++}}}])}(),pd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).v0=i.v0,t.v1=i.v1,t.v2=i.v2,t.v3=i.v3,t.t=i.t,t}return m(n,Hp),C(n,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"v3",get:function(){return this._v3},set:function(e){this.fire("v3",this._v3=e||$.vec3([0,0,0]))}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var n=$.vec3();return n[0]=$.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),n[1]=$.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),n[2]=$.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),n}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}])}(),dd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._cachedLengths=[],t._dirty=!0,t._curves=[],t._t=0,t._dirtySubs=[],t._destroyedSubs=[],t.curves=i.curves||[],t.t=i.t,t}return m(n,Hp),C(n,[{key:"addCurve",value:function(e){this._curves.push(e),this._dirty=!0}},{key:"curves",get:function(){return this._curves},set:function(e){var n,t,i;for(e=e||[],t=0,i=this._curves.length;t<i;t++)(n=this._curves[t]).off(this._dirtySubs[t]),n.off(this._destroyedSubs[t]);this._curves=[],this._dirtySubs=[],this._destroyedSubs=[];var r=this;function l(){r._dirty=!0}function a(){var e=this.id;for(t=0,i=r._curves.length;t<i;t++)if(r._curves[t].id===e)return r._curves=r._curves.slice(t,t+1),r._dirtySubs=r._dirtySubs.slice(t,t+1),r._destroyedSubs=r._destroyedSubs.slice(t,t+1),void(r._dirty=!0)}for(t=0,i=e.length;t<i;t++){if(n=e[t],ue.isNumeric(n)||ue.isString(n)){var s=n;if(!(n=this.scene.components[s])){this.error("Component not found: "+_inQuotes(s));continue}}var u=n.type;"xeokit.SplineCurve"===u||"xeokit.Path"===u||"xeokit.CubicBezierCurve"===u||"xeokit.QuadraticBezierCurve"===u?(this._curves.push(n),this._dirtySubs.push(n.on("dirty",l)),this._destroyedSubs.push(n.once("destroyed",a))):this.error("Component "+_inQuotes(n.id)+" is not a xeokit.SplineCurve, xeokit.Path or xeokit.QuadraticBezierCurve")}this._dirty=!0}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"length",get:function(){var e=this._getCurveLengths();return e[e.length-1]}},{key:"getPoint",value:function(e){for(var n,t=e*this.length,i=this._getCurveLengths(),r=0;r<i.length;){if(i[r]>=t){var l=1-(i[r]-t)/(n=this._curves[r]).length;return n.getPointAt(l)}r++}return null}},{key:"_getCurveLengths",value:function(){if(!this._dirty)return this._cachedLengths;var e,n=[],t=0,i=this._curves.length;for(e=0;e<i;e++)t+=this._curves[e].length,n.push(t);return this._cachedLengths=n,this._dirty=!1,n}},{key:"_getJSON",value:function(){for(var e=[],n=0,t=this._curves.length;n<t;n++)e.push(this._curves[n].id);return{curves:e,t:this._t}}},{key:"destroy",value:function(){var e,t,i;for(I(y(n.prototype),"destroy",this).call(this),e=0,t=this._curves.length;e<t;e++)(i=this._curves[e]).off(this._dirtySubs[e]),i.off(this._destroyedSubs[e])}}])}(),vd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).v0=i.v0,t.v1=i.v1,t.v2=i.v2,t.t=i.t,t}return m(n,Hp),C(n,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var n=$.vec3();return n[0]=$.b2(e,this._v0[0],this._v1[0],this._v2[0]),n[1]=$.b2(e,this._v0[1],this._v1[1],this._v2[1]),n[2]=$.b2(e,this._v0[2],this._v1[2],this._v2[2]),n}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}])}(),Ad=function(e){function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),v(this,n,[e,t])}return m(n,vp),C(n)}();$.vec3();var hd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._state=new Zn({active:!0,pos:$.vec3(),dir:$.vec3(),dist:0}),t.active=i.active,t.pos=i.pos,t.dir=i.dir,t.scene._sectionBoxCreated(t),t}return m(n,me),C(n,[{key:"type",get:function(){return"SectionBox"}},{key:"control",get:function(){return this._control},set:function(e){this._control=e}},{key:"active",get:function(){return this._state.active},set:function(e){this._state.active=!1!==e,this.glRedraw(),this.fire("active",this._state.active)}},{key:"pos",get:function(){return this._state.pos},set:function(e){this._state.pos.set(e||[0,0,0]),this._state.dist=-$.dotVec3(this._state.pos,this._state.dir),this.fire("pos",this._state.pos),this.scene.fire("sectionBoxUpdated",this)}},{key:"dir",get:function(){return this._state.dir},set:function(e){this._state.dir.set(e||[0,0,-1]),this._state.dist=-$.dotVec3(this._state.pos,this._state.dir),this.glRedraw(),this.fire("dir",this._state.dir),this.scene.fire("sectionBoxUpdated",this)}},{key:"dist",get:function(){return this._state.dist}},{key:"flipDir",value:function(){var e=this._state.dir;e[0]*=-1,e[1]*=-1,e[2]*=-1,this._state.dist=-$.dotVec3(this._state.pos,this._state.dir),this.fire("dir",this._state.dir),this.glRedraw()}},{key:"destroy",value:function(){this._state.destroy(),this.scene._sectionBoxDestroyed(this),I(y(n.prototype),"destroy",this).call(this)}}])}(),Id=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._skyboxMesh=new ll(t,{geometry:new Ft(t,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new kt(t,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Hl(t,{scale:i.scale,src:i.src,flipY:!0,wrapS:1e3,wrapT:1e3,encoding:i.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),t.size=i.size,t.active=i.active,t}return m(n,me),C(n,[{key:"size",get:function(){return this._size},set:function(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}},{key:"active",get:function(){return this._skyboxMesh.visible},set:function(e){this._skyboxMesh.visible=e}}])}(),yd=function(){return C((function e(){T(this,e)}),[{key:"transcode",value:function(e,n){}},{key:"destroy",value:function(){}}])}(),md=$.vec4(),wd=$.vec4(),gd=$.vec3(),Ed=$.vec3(),Td=$.vec3(),bd=$.vec4(),Cd=$.vec4(),Dd=$.vec4(),Rd=function(){return C((function e(n){T(this,e),this._scene=n}),[{key:"dollyToCanvasPos",value:function(e,n,t){var i=!1,r=this._scene.camera;if(e){var l=$.subVec3(e,r.eye,gd);i=$.lenVec3(l)<t}if("perspective"===r.projection){r.ortho.scale=r.ortho.scale-t;var a=this._unproject(n,bd),s=$.subVec3(a,r.eye,Dd),u=$.mulVec3Scalar($.normalizeVec3(s),-t,[]);if(r.eye=[r.eye[0]-u[0],r.eye[1]-u[1],r.eye[2]-u[2]],r.look=[r.look[0]-u[0],r.look[1]-u[1],r.look[2]-u[2]],e){var o=$.subVec3(e,r.eye,gd),c=$.lenVec3(o),f=$.mulVec3Scalar($.normalizeVec3($.subVec3(r.look,r.eye,Ed)),c);r.look=[r.eye[0]+f[0],r.eye[1]+f[1],r.eye[2]+f[2]]}}else if("ortho"===r.projection){var p=this._unproject(n,bd);r.ortho.scale=r.ortho.scale-t,r.ortho._update();var d=this._unproject(n,Cd),v=$.subVec3(d,p,Dd),A=$.mulVec3Scalar($.normalizeVec3($.subVec3(r.look,r.eye,gd)),-t,Ed),h=$.addVec3(v,A,Td);r.eye=[r.eye[0]-h[0],r.eye[1]-h[1],r.eye[2]-h[2]],r.look=[r.look[0]-h[0],r.look[1]-h[1],r.look[2]-h[2]]}return i}},{key:"_unproject",value:function(e,n){var t=this._scene.camera,i=t.project.transposedMatrix,r=i.subarray(8,12),l=i.subarray(12),a=[0,0,-1,1],s=$.dotVec4(a,r)/$.dotVec4(a,l);return t.project.unproject(e,s,md,wd,n),n}},{key:"destroy",value:function(){}}])}(),Pd=$.vec3(),_d=$.vec3(),Od=$.vec3(),Sd=$.vec4(),Nd=$.vec4(),Bd=$.vec4(),Ld=function(){return C((function e(n,t){var i=this;T(this,e),this._scene=n,this._configs=t,this._pivotWorldPos=$.vec3(),this._cameraOffset=$.vec3(),this._azimuth=0,this._polar=0,this._radius=0,this._pivotPosSet=!1,this._pivoting=!1,this._shown=!1,this._pivotSphereEnabled=!1,this._pivotSphere=null,this._pivotSphereSize=1,this._pivotSphereGeometry=null,this._pivotSphereMaterial=null,this._rtcCenter=$.vec3(),this._rtcPos=$.vec3(),this._pivotViewPos=$.vec4(),this._pivotProjPos=$.vec4(),this._pivotCanvasPos=$.vec2(),this._cameraDirty=!0,this._onViewMatrix=this._scene.camera.on("viewMatrix",(function(){i._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(function(){i._cameraDirty=!0})),this._onTick=this._scene.on("tick",(function(){i.updatePivotElement(),i.updatePivotSphere()}))}),[{key:"createPivotSphere",value:function(){var e=this.getPivotPos(),n=$.vec3();$.decomposeMat4($.inverseMat4(this._scene.viewer.camera.viewMatrix,$.mat4()),n,$.vec4(),$.vec3());var t=$.distVec3(n,e),i=Math.tan(Math.PI/500)*t*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(i/=this._scene.camera.ortho.scale/2),Ne(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new Vl(this._scene,ul({radius:i})),this._pivotSphere=new ll(this._scene,{geometry:this._pivotSphereGeometry,material:this._pivotSphereMaterial,pickable:!1,position:this._rtcPos,rtcCenter:this._rtcCenter})}},{key:"destroyPivotSphere",value:function(){this._pivotSphere&&(this._pivotSphere.destroy(),this._pivotSphere=null),this._pivotSphereGeometry&&(this._pivotSphereGeometry.destroy(),this._pivotSphereGeometry=null)}},{key:"getPointScreenPos",value:function(e){var n=this._scene.camera,t=this._scene.canvas.boundary,i=t[2],r=t[3],l=$.vec4(),a=$.vec4(),s=$.vec2();return $.transformPoint3(n.viewMatrix,e,l),$.transformPoint4(n.projMatrix,e,a),s[0]=Math.floor((1+a[0]/a[3])*i/2),s[1]=Math.floor((1-a[1]/a[3])*r/2),s}},{key:"updatePivotElement",value:function(){var e=this._scene.camera,n=this._scene.canvas;if(this._pivoting&&this._cameraDirty){$.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,$.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);var t=n.boundary,i=t[2],r=t[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*i/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*r/2);var l=n._lastBoundingClientRect,a=n.canvas;l=n._lastBoundingClientRect=a.getBoundingClientRect(),this._pivotElement&&(this._pivotElement.style.left=Math.floor(l.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+n.offset[0],this._pivotElement.style.top=Math.floor(l.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+n.offset[1]),this._cameraDirty=!1}}},{key:"updatePivotSphere",value:function(){this._pivoting&&this._pivotSphere&&(Ne(this.getPivotPos(),this._rtcCenter,this._rtcPos),$.compareVec3(this._rtcPos,this._pivotSphere.position)||(this.destroyPivotSphere(),this.createPivotSphere()))}},{key:"setPivotElement",value:function(e){this._pivotElement=e}},{key:"enablePivotSphere",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);var n=e.color||[1,0,0];this._pivotSphereMaterial=new kt(this._scene,{emissive:n,ambient:n,specular:[0,0,0],diffuse:[0,0,0]})}},{key:"disablePivotSphere",value:function(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}},{key:"startPivot",value:function(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;var e=this._scene.camera,n=$.lookAtMat4v(e.eye,e.look,e.worldUp);$.transformPoint3(n,this.getPivotPos(),this._cameraOffset);var t=this.getPivotPos();this._cameraOffset[2]+=$.distVec3(e.eye,t),n=$.inverseMat4(n);var i=$.transformVec3(n,this._cameraOffset),r=$.vec3();if($.subVec3(e.eye,t,r),$.addVec3(r,i),e.zUp){var l=r[1];r[1]=r[2],r[2]=l}this._radius=$.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}},{key:"_cameraLookingDownwards",value:function(){var e=this._scene.camera,n=$.normalizeVec3($.subVec3(e.look,e.eye,Pd)),t=$.cross3Vec3(n,e.worldUp,_d);return $.sqLenVec3(t)<=1e-4}},{key:"getPivoting",value:function(){return this._pivoting}},{key:"setPivotPos",value:function(e){this._pivotWorldPos&&this._pivotWorldPos.set(e),this._pivotPosSet=!0}},{key:"setCanvasPivotPos",value:function(e){var n=this._scene.camera,t=Math.abs($.distVec3(this._scene.center,n.eye)),i=n.project.transposedMatrix,r=i.subarray(8,12),l=i.subarray(12),a=[0,0,-1,1],s=$.dotVec4(a,r)/$.dotVec4(a,l),u=Sd;n.project.unproject(e,s,Nd,Bd,u);var o=$.normalizeVec3($.subVec3(u,n.eye,Pd)),c=$.addVec3(n.eye,$.mulVec3Scalar(o,t,_d),Od);this.setPivotPos(c)}},{key:"getPivotPos",value:function(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}},{key:"continuePivot",value:function(e,n){if(this._pivoting&&(0!==e||0!==n)){var t=this._scene.camera,i=-e,r=-n;1===t.worldUp[2]&&(i=-i),this._azimuth+=.01*-i,this._polar+=.01*r,this._polar=$.clamp(this._polar,.001,Math.PI-.001);var l=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===t.worldUp[2]){var a=l[1];l[1]=l[2],l[2]=a}var s=$.lenVec3($.subVec3(t.look,t.eye,$.vec3())),u=this.getPivotPos();$.addVec3(l,u);var o=$.lookAtMat4v(l,u,t.worldUp);o=$.inverseMat4(o);var c=$.transformVec3(o,this._cameraOffset);o[12]-=c[0],o[13]-=c[1],o[14]-=c[2];var f=[o[8],o[9],o[10]];t.eye=[o[12],o[13],o[14]],$.subVec3(t.eye,$.mulVec3Scalar(f,s),t.look),t.up=[o[4],o[5],o[6]],this.showPivot()}}},{key:"showPivot",value:function(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}},{key:"hidePivot",value:function(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}},{key:"endPivot",value:function(){this._pivoting=!1}},{key:"destroy",value:function(){this._pivotElement&&this._pivotElement.parentNode.removeChild(this._pivotElement),this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}])}(),Md=function(){return C((function e(n,t){T(this,e),this._scene=n.scene,this._cameraControl=n,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=t,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=$.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}),[{key:"update",value:function(){if(this._configs.pointerEnabled&&(this.schedulePickEntity||this.schedulePickSurface)){var e="".concat(~~this.pickCursorPos[0],"-").concat(~~this.pickCursorPos[1],"-").concat(this.scheduleSnapOrPick,"-").concat(this.schedulePickSurface,"-").concat(this.schedulePickEntity);if(this._lastHash!==e){this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;var n=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var t=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});t&&(t.snappedToEdge||t.snappedToVertex)?(this.snapPickResult=t,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){var i=this.pickResult.canvasPos;if(i[0]===this.pickCursorPos[0]&&i[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=n?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){var r=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(r[0]===this.pickCursorPos[0]&&r[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}}}},{key:"fireEvents",value:function(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){var e=new bn;e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){var n=this.pickResult.entity.id;this._lastPickedEntityId!==n&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=n)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}])}(),Fd=$.vec2(),xd=function(){return C((function e(n,t,i,r,l){var a=this;T(this,e),this._scene=n;var s,u,o,c=t.pickController,f=0,p=0,d=0,v=0,A=!1,h=$.vec3(),I=!0;this.canvas=this._scene.canvas.canvas;var y=[];document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled){var t=e.keyCode;y[t]=!0}}),document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled){var t=e.keyCode;y[t]=!1}});var m=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];a.canvas.style.cursor="move",f=r.pointerCanvasPos[0],p=r.pointerCanvasPos[1],d=r.pointerCanvasPos[0],v=r.pointerCanvasPos[1],e&&(c.pickCursorPos=r.pointerCanvasPos,c.schedulePickSurface=!0,c.update(),c.picked&&c.pickedSurface&&c.pickResult&&c.pickResult.worldPos?(A=!0,h.set(c.pickResult.worldPos)):A=!1)};this.canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){if(i.active&&i.pointerEnabled)switch(e.which){case 1:y[n.input.KEY_SHIFT]||i.planView?(s=!0,m()):(s=!0,m(!1));break;case 2:u=!0,m();break;case 3:o=!0,i.panRightClick&&m()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=function(){if(i.active&&i.pointerEnabled&&(s||u||o)){var e=n.canvas.boundary,t=e[2],a=e[3],c=r.pointerCanvasPos[0],d=r.pointerCanvasPos[1];if(y[n.input.KEY_SHIFT]||i.planView||!i.panRightClick&&u||i.panRightClick&&o){var v=c-f,I=d-p,m=n.camera;if("perspective"===m.projection){var w=Math.abs(A?$.lenVec3($.subVec3(h,n.camera.eye,[])):n.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);l.panDeltaX+=1.5*v*w/a,l.panDeltaY+=1.5*I*w/a}else l.panDeltaX+=.5*m.ortho.scale*(v/a),l.panDeltaY+=.5*m.ortho.scale*(I/a)}else!s||u||o||i.planView||(i.firstPerson?(l.rotateDeltaY-=(c-f)/t*i.dragRotationRate/2,l.rotateDeltaX+=(d-p)/a*(i.dragRotationRate/4)):(l.rotateDeltaY-=(c-f)/t*(1.5*i.dragRotationRate),l.rotateDeltaX+=(d-p)/a*(1.5*i.dragRotationRate)));f=c,p=d}}),this.canvas.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){i.active&&i.pointerEnabled&&r.mouseover&&(I=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(i.active&&i.pointerEnabled)switch(e.which){case 1:case 2:case 3:s=!1,u=!1,o=!1}}),this.canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){if(i.active&&i.pointerEnabled){if(3===e.which){!function(e,n){if(e){for(var t=e.target,i=0,r=0,l=0,a=0;t.offsetParent;)i+=t.offsetLeft,r+=t.offsetTop,l+=t.scrollLeft,a+=t.scrollTop,t=t.offsetParent;n[0]=e.pageX+l-i,n[1]=e.pageY+a-r}else e=window.event,n[0]=e.x,n[1]=e.y}(e,Fd);var n=Fd[0],r=Fd[1];Math.abs(n-d)<3&&Math.abs(r-v)<3&&t.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Fd,event:e},!0)}a.canvas.style.removeProperty("cursor")}}),this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){i.active&&i.pointerEnabled});var w=1/60,g=null;this.canvas.addEventListener("wheel",this._mouseWheelHandler=function(e){if(e.preventDefault(),i.active&&i.pointerEnabled){var n=performance.now()/1e3,t=null!==g?n-g:0;g=n,t>.05&&(t=.05),t<w&&(t=w);var a=Math.max(-1,Math.min(1,40*-e.deltaY));if(0!==a){var s=a/Math.abs(a);l.dollyDelta+=-s*t*i.mouseWheelDollyRate,I&&(r.followPointerDirty=!0,I=!1)}}})}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("mousedown",this._mouseDownHandler),this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler),this.canvas.removeEventListener("mouseup",this._mouseUpHandler),this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler),this.canvas.removeEventListener("wheel",this._mouseWheelHandler)),document.removeEventListener("keydown",this._documentKeyDownHandler),document.removeEventListener("keyup",this._documentKeyUpHandler),document.removeEventListener("mousemove",this._documentMouseMoveHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler)}}])}(),Hd=$.vec3(),Ud=$.vec3(),Gd=$.vec3(),kd=$.vec3(),Vd=$.vec3(),jd={eye:$.vec3(),look:$.vec3(),up:$.vec3()},Qd=function(){return C((function e(n,t,i,r){T(this,e),this._scene=n,this.input=n.input;var l=t.cameraControl,a=n.camera;this._onSceneKeyDown=n.input.on("keydown",(function(){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&r.mouseover){var e=l._isKeyDownForAction(l.AXIS_VIEW_RIGHT),s=l._isKeyDownForAction(l.AXIS_VIEW_BACK),u=l._isKeyDownForAction(l.AXIS_VIEW_LEFT),o=l._isKeyDownForAction(l.AXIS_VIEW_FRONT),c=l._isKeyDownForAction(l.AXIS_VIEW_TOP),f=l._isKeyDownForAction(l.AXIS_VIEW_BOTTOM);if(e||s||u||o||c||f){var p=n.aabb,d=$.getAABB3Diag(p);$.getAABB3Center(p,Hd);var v=Math.abs(d/Math.tan(t.cameraFlight.fitFOV*$.DEGTORAD)),A=1.1*d;jd.orthoScale=A,e?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldRight,v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):s?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldForward,v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):u?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldRight,-v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):o?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldForward,-v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):c?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldUp,v,Ud),Vd)),jd.look.set(Hd),jd.up.set($.normalizeVec3($.mulVec3Scalar(a.worldForward,1,Gd),kd))):f&&(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldUp,-v,Ud),Vd)),jd.look.set(Hd),jd.up.set($.normalizeVec3($.mulVec3Scalar(a.worldForward,-1,Gd)))),!i.firstPerson&&i.followPointer&&t.pivotController.setPivotPos(Hd),t.cameraFlight.duration>0?t.cameraFlight.flyTo(jd,(function(){t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot()})):(t.cameraFlight.jumpTo(jd),t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot())}}}))}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){this.input.off(this._onSceneKeyDown)}}])}(),Wd=function(){return C((function e(n,t,i,r,l){var a=this;T(this,e),this._scene=n;var s=t.pickController,u=t.pivotController,o=t.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;var c=!1,f=!1;this.canvas=this._scene.canvas.canvas;var p=n.tickify(this._canvasMouseMoveHandler=function(e){if(i.active&&i.pointerEnabled&&!c&&!f){var t=o.hasSubs("hover"),l=o.hasSubs("hoverEnter"),u=o.hasSubs("hoverOut"),p=o.hasSubs("hoverOff"),d=o.hasSubs("hoverSurface"),v=o.hasSubs("hoverSnapOrSurface");if(t||l||u||p||d||v)if(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickEntity=!0,s.schedulePickSurface=d,s.scheduleSnapOrPick=v,s.update(),s.pickResult){if(s.pickResult.entity){var A=s.pickResult.entity.id;a._lastPickedEntityId!==A&&(void 0!==a._lastPickedEntityId&&o.fire("hoverOut",{entity:n.objects[a._lastPickedEntityId]},!0),o.fire("hoverEnter",s.pickResult,!0),a._lastPickedEntityId=A)}o.fire("hover",s.pickResult,!0),(s.pickResult.worldPos||s.pickResult.snappedWorldPos)&&o.fire("hoverSurface",s.pickResult,!0)}else void 0!==a._lastPickedEntityId&&(o.fire("hoverOut",{entity:n.objects[a._lastPickedEntityId]},!0),a._lastPickedEntityId=void 0),o.fire("hoverOff",{canvasPos:s.pickCursorPos},!0)}});this.canvas.addEventListener("mousemove",p),this.canvas.addEventListener("dblclick",this._canvasDblClickHandler=function(e){r.mouseDownClientX=e.clientX,r.mouseDownClientY=e.clientY,r.mouseDownCursorX=r.pointerCanvasPos[0],r.mouseDownCursorY=r.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickSurface=!0,s.update()),s.pickResult?(o.fire("doublePicked",s.pickResult,!0),s.pickedSurface&&o.fire("doublePickedSurface",s.pickResult,!0)):o.fire("doublePickedNothing",{canvasPos:r.pointerCanvasPos},!0)}),this.canvas.addEventListener("mousedown",this._canvasMouseDownHandler=function(e){if(1===e.which&&(c=!0),3===e.which&&(f=!0),1===e.which&&i.active&&i.pointerEnabled&&(r.mouseDownClientX=e.clientX,r.mouseDownClientY=e.clientY,r.mouseDownCursorX=r.pointerCanvasPos[0],r.mouseDownCursorY=r.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickSurface=!0,s.update(),1===e.which))){var t=s.pickResult;t&&t.worldPos?(u.setCanvasPivotPos(r.pointerCanvasPos),o.fire("mouseDownEntity",s.pickResult,!0)):(i.smartPivot?u.setCanvasPivotPos(r.pointerCanvasPos):u.setPivotPos(n.camera.look),u.startPivot(),o.fire("mouseDownNothing",s.pickResult,!0))}}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){1===e.which&&(c=!1),3===e.which&&(f=!1),u.getPivoting()&&u.endPivot()}),this.canvas.addEventListener("mouseup",this._canvasMouseUpHandler=function(e){if(i.active&&i.pointerEnabled&&(1===e.which&&(u.hidePivot(),!(Math.abs(e.clientX-r.mouseDownClientX)>3||Math.abs(e.clientY-r.mouseDownClientY)>3)))){var n=o.hasSubs("picked"),l=o.hasSubs("pickedNothing"),c=o.hasSubs("pickedSurface"),f=o.hasSubs("doublePicked"),p=o.hasSubs("doublePickedSurface"),d=o.hasSubs("doublePickedNothing");if(!(i.doublePickFlyTo||f||p||d))return(n||l||c)&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickEntity=!0,s.schedulePickSurface=c,s.update(),s.pickResult?(o.fire("picked",s.pickResult,!0),s.pickedSurface&&o.fire("pickedSurface",s.pickResult,!0)):o.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0)),void(a._clicks=0);s.pickCursorPos=r.pointerCanvasPos,s.schedulePickEntity=i.doublePickFlyTo,s.schedulePickSurface=c,s.update();var v=s.pickResult,A=s.pickedSurface;a._timeout=setTimeout((function(){v?(o.fire("picked",v,!0),A&&(o.fire("pickedSurface",v,!0),!i.firstPerson&&i.followPointer&&(t.pivotController.setPivotPos(v.worldPos),t.pivotController.startPivot()&&t.pivotController.showPivot()))):o.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0),a._clicks=0}),i.doubleClickTimeFrame)}},!1)}),[{key:"reset",value:function(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler),this.canvas.removeEventListener("mousedown",this._canvasMouseDownHandler),this.canvas.removeEventListener("dblclick",this._canvasDblClickHandler),this.canvas.removeEventListener("mouseup",this._canvasMouseUpHandler)),document.removeEventListener("mouseup",this._documentMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}])}(),zd=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n,this._updates=l;var a=n.input;this.input=a;var s=[],u=n.canvas.canvas,o=!0;this._onSceneMouseMove=a.on("mousemove",(function(){o=!0})),this._onSceneKeyDown=a.on("keydown",(function(e){i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&r.mouseover&&(s[e]=!0,e===a.KEY_SHIFT&&(u.style.cursor="move"))})),this._onSceneKeyUp=a.on("keyup",(function(e){i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&(s[e]=!1,e===a.KEY_SHIFT&&(u.style.cursor=null),t.pivotController.getPivoting()&&t.pivotController.endPivot())})),this._onTick=n.on("tick",(function(e){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&r.mouseover){var u=t.cameraControl,c=e.deltaTime/1e3;if(!i.planView){var f=u._isKeyDownForAction(u.ROTATE_Y_POS,s),p=u._isKeyDownForAction(u.ROTATE_Y_NEG,s),d=u._isKeyDownForAction(u.ROTATE_X_POS,s),v=u._isKeyDownForAction(u.ROTATE_X_NEG,s),A=c*i.keyboardRotationRate;(f||p||d||v)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),f?l.rotateDeltaY+=A:p&&(l.rotateDeltaY-=A),d?l.rotateDeltaX+=A:v&&(l.rotateDeltaX-=A),!i.firstPerson&&i.followPointer&&t.pivotController.startPivot())}if(!s[a.KEY_CTRL]&&!s[a.KEY_ALT]){var h=u._isKeyDownForAction(u.DOLLY_BACKWARDS,s),I=u._isKeyDownForAction(u.DOLLY_FORWARDS,s);if(h||I){var y=c*i.keyboardDollyRate;!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),I?l.dollyDelta-=y:h&&(l.dollyDelta+=y),o&&(r.followPointerDirty=!0,o=!1)}}var m=u._isKeyDownForAction(u.PAN_FORWARDS,s),w=u._isKeyDownForAction(u.PAN_BACKWARDS,s),g=u._isKeyDownForAction(u.PAN_LEFT,s),E=u._isKeyDownForAction(u.PAN_RIGHT,s),T=u._isKeyDownForAction(u.PAN_UP,s),b=u._isKeyDownForAction(u.PAN_DOWN,s),C=(s[a.KEY_ALT]?.3:1)*c*i.keyboardPanRate;(m||w||g||E||T||b)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),b?l.panDeltaY+=C:T&&(l.panDeltaY+=-C),E?l.panDeltaX+=-C:g&&(l.panDeltaX+=C),w?l.panDeltaZ+=C:m&&(l.panDeltaZ+=-C))}}))}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.off(this._onTick),this.input.off(this._onSceneMouseMove),this.input.off(this._onSceneKeyDown),this.input.off(this._onSceneKeyUp)}}])}(),Yd=.001,Kd=$.vec3(),Xd=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n;var a=n.camera,s=t.pickController,u=t.pivotController,o=t.panController,c=1,f=1,p=null;this._onTick=n.on("tick",(function(){if(i.active&&i.pointerEnabled){var e="default";if(Math.abs(l.dollyDelta)<Yd&&(l.dollyDelta=0),Math.abs(l.rotateDeltaX)<Yd&&(l.rotateDeltaX=0),Math.abs(l.rotateDeltaY)<Yd&&(l.rotateDeltaY=0),0===l.rotateDeltaX&&0===l.rotateDeltaY||(l.dollyDelta=0),i.followPointer&&--c<=0&&(c=1,0!==l.dollyDelta)){if(0===l.rotateDeltaY&&0===l.rotateDeltaX&&i.followPointer&&r.followPointerDirty&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickSurface=!0,s.update(),s.pickResult&&s.pickResult.worldPos?p=s.pickResult.worldPos:(f=1,p=null),r.followPointerDirty=!1),p){var t=Math.abs($.lenVec3($.subVec3(p,n.camera.eye,Kd)));f=t/i.dollyProximityThreshold}f<i.dollyMinSpeed&&(f=i.dollyMinSpeed)}var d=l.dollyDelta*f;if(0===l.rotateDeltaY&&0===l.rotateDeltaX||(!i.firstPerson&&i.followPointer&&u.getPivoting()?u.continuePivot(l.rotateDeltaY,l.rotateDeltaX):(0!==l.rotateDeltaX&&(i.firstPerson?a.pitch(-l.rotateDeltaX):a.orbitPitch(l.rotateDeltaX)),0!==l.rotateDeltaY&&(i.firstPerson?a.yaw(l.rotateDeltaY):a.orbitYaw(l.rotateDeltaY))),l.rotateDeltaX*=i.rotationInertia,l.rotateDeltaY*=i.rotationInertia,e="grabbing"),Math.abs(l.panDeltaX)<Yd&&(l.panDeltaX=0),Math.abs(l.panDeltaY)<Yd&&(l.panDeltaY=0),Math.abs(l.panDeltaZ)<Yd&&(l.panDeltaZ=0),0!==l.panDeltaX||0!==l.panDeltaY||0!==l.panDeltaZ){var v,A,h=$.vec3();if(h[0]=l.panDeltaX,h[1]=l.panDeltaY,h[2]=l.panDeltaZ,i.constrainVertical){a.xUp?(v=a.eye[0],A=a.look[0]):a.yUp?(v=a.eye[1],A=a.look[1]):a.zUp&&(v=a.eye[2],A=a.look[2]),a.pan(h);var I=a.eye,y=a.look;a.xUp?(I[0]=v,y[0]=A):a.yUp?(I[1]=v,y[1]=A):a.zUp&&(I[2]=v,y[2]=A),a.eye=I,a.look=y}else a.pan(h);e="grabbing"}if(l.panDeltaX*=i.panInertia,l.panDeltaY*=i.panInertia,l.panDeltaZ*=i.panInertia,0!==d){if(e=d<0?"zoom-in":"zoom-out",i.firstPerson){var m,w;if(i.constrainVertical&&(a.xUp?(m=a.eye[0],w=a.look[0]):a.yUp?(m=a.eye[1],w=a.look[1]):a.zUp&&(m=a.eye[2],w=a.look[2])),i.followPointer)o.dollyToCanvasPos(p,r.pointerCanvasPos,-d)&&(r.followPointerDirty=!0);else a.pan([0,0,d]),a.ortho.scale=a.ortho.scale-d;if(i.constrainVertical){var g=a.eye,E=a.look;a.xUp?(g[0]=m,E[0]=w):a.yUp?(g[1]=m,E[1]=w):a.zUp&&(g[2]=m,E[2]=w),a.eye=g,a.look=E}}else if(i.planView){if(i.followPointer)o.dollyToCanvasPos(p,r.pointerCanvasPos,-d)&&(r.followPointerDirty=!0);else a.ortho.scale=a.ortho.scale+d,a.zoom(d)}else{if(i.followPointer)o.dollyToCanvasPos(p,r.pointerCanvasPos,-d)&&(r.followPointerDirty=!0);else a.ortho.scale=a.ortho.scale+d,a.zoom(d)}l.dollyDelta*=i.dollyInertia}s.fireEvents(),document.body.style.cursor=e}}))}),[{key:"destroy",value:function(){this._scene.off(this._onTick)}}])}(),qd=function(){return C((function e(n,t,i,r,l){var a=this;T(this,e),this._scene=n,this.canvas=this._scene.canvas.canvas,this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){r.mouseover=!0}),this.canvas.addEventListener("mouseleave",this._mouseLeaveHandler=function(){r.mouseover=!1,a.canvas.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=function(e){Jd(e,a.canvas,r.pointerCanvasPos)}),this.canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){i.active&&i.pointerEnabled&&(Jd(e,a.canvas,r.pointerCanvasPos),r.mouseover=!0)}),this.canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){i.active&&i.pointerEnabled})}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler),this.canvas.removeEventListener("mouseleave",this._mouseLeaveHandler),this.canvas.removeEventListener("mousedown",this._mouseDownHandler),this.canvas.removeEventListener("mouseup",this._mouseUpHandler)),document.removeEventListener("mousemove",this._mouseMoveHandler)}}])}();function Jd(e,n,t){if(e){var i=n.getBoundingClientRect(),r=i.x,l=i.y;t[0]=e.clientX-r,t[1]=e.clientY-l}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var Zd=function(e,n){if(e){for(var t=e.target,i=0,r=0;t.offsetParent;)i+=t.offsetLeft,r+=t.offsetTop,t=t.offsetParent;n[0]=e.pageX-i,n[1]=e.pageY-r}else e=window.event,n[0]=e.x,n[1]=e.y;return n},$d=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n;var a=t.pickController,s=t.pivotController,u=$.vec2(),o=$.vec2(),c=$.vec2(),f=$.vec2(),p=[];this.canvas=this._scene.canvas.canvas;var d=0,v=!1;this._onTick=n.on("tick",(function(){v=!1})),this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(i.active&&i.pointerEnabled&&e.isTrusted){e.preventDefault();var t=e.touches,l=e.changedTouches;for(r.touchStartTime=Date.now(),1===t.length&&1===l.length&&(r.touchStartTime,Zd(t[0],u),i.followPointer&&(a.pickCursorPos=u,a.schedulePickSurface=!0,a.update(),s.setPivotPos(n.camera.look)));p.length<t.length;)p.push($.vec2());for(var o=0,c=t.length;o<c;++o)Zd(t[o],p[o]);d=t.length}}),this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(){s.getPivoting()&&(s.endPivot(),s.hidePivot())}),this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler),this.canvas.addEventListener("touchmove",this._canvasTouchMoveHandler=function(e){if(i.active&&i.pointerEnabled&&(e.stopPropagation(),e.preventDefault(),!v)){v=!0;var t=n.canvas.boundary,u=t[2],A=t[3],h=e.touches;if(e.touches.length===d){if(1===d){Zd(h[0],o),$.subVec2(o,p[0],f);var I=f[0],y=f[1];if(null!==r.longTouchTimeout&&(Math.abs(I)>i.longTapRadius||Math.abs(y)>i.longTapRadius)&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null),i.planView){var m=n.camera;if("perspective"===m.projection){var w=Math.abs(n.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);l.panDeltaX+=I*w/A*i.touchPanRate,l.panDeltaY+=y*w/A*i.touchPanRate}else l.panDeltaX+=.5*m.ortho.scale*(I/A)*i.touchPanRate,l.panDeltaY+=.5*m.ortho.scale*(y/A)*i.touchPanRate}else l.rotateDeltaY-=I/u*(1*i.dragRotationRate),l.rotateDeltaX+=y/A*(1.5*i.dragRotationRate)}else if(2===d){s.hidePivot();var g=h[0],E=h[1];Zd(g,o),Zd(E,c);var T=$.geometricMeanVec2(p[0],p[1]),b=$.geometricMeanVec2(o,c),C=$.vec2();$.subVec2(T,b,C);var D=C[0],R=C[1],P=n.camera,_=$.distVec2([g.pageX,g.pageY],[E.pageX,E.pageY]),O=($.distVec2(p[0],p[1])-_)*i.touchDollyRate;if(l.dollyDelta=O,Math.abs(O)<1)if("perspective"===P.projection){var S=a.pickResult?a.pickResult.worldPos:n.center,N=Math.abs($.lenVec3($.subVec3(S,n.camera.eye,[])))*Math.tan(P.perspective.fov/2*Math.PI/180);l.panDeltaX-=D*N/A*i.touchPanRate,l.panDeltaY-=R*N/A*i.touchPanRate}else l.panDeltaX-=.5*P.ortho.scale*(D/A)*i.touchPanRate,l.panDeltaY-=.5*P.ortho.scale*(R/A)*i.touchPanRate;r.pointerCanvasPos=b}for(var B=0;B<d;++B)Zd(h[B],p[B])}}})}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler),this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler),this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler),this.canvas.removeEventListener("touchmove",this._canvasTouchMoveHandler)),this._scene.off(this._onTick)}}])}(),ev=function(e,n){if(e){for(var t=e.target,i=0,r=0;t.offsetParent;)i+=t.offsetLeft,r+=t.offsetTop,t=t.offsetParent;n[0]=e.pageX-i,n[1]=e.pageY-r}else e=window.event,n[0]=e.x,n[1]=e.y;return n},nv=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n;var a,s=t.pickController,u=t.cameraControl,o=[],c=new Float32Array(2),f=-1,p=-1;this.canvas=this._scene.canvas.canvas;var d=function(e){var i;e&&e.worldPos&&(i=e.worldPos);var r=e?e.entity.aabb:n.aabb;if(i){var l=n.camera;$.subVec3(l.eye,l.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})};this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(i.active&&i.pointerEnabled&&e.isTrusted){null!==r.longTouchTimeout&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null);var n=e.touches,l=e.changedTouches;if(a=Date.now(),1===n.length&&1===l.length){f=a;var p=c[0],d=c[1],v=n[0].pageX,A=n[0].pageY;r.longTouchTimeout=setTimeout((function(){t.cameraControl.fire("rightClick",{pagePos:[Math.round(v),Math.round(A)],canvasPos:[Math.round(p),Math.round(d)],event:e},!0),r.longTouchTimeout=null}),i.longTapTimeout);var h=u.hasSubs("pickedSurface");ev(n[0],s.pickCursorPos),s.schedulePickEntity=!0,s.schedulePickSurface=h,s.update(),s.pickResult?(u.fire("touchEntity",s.pickResult),s.pickedSurface&&u.fire("touchSurface",s.pickResult)):u.fire("touchNothing"),f=-1}else f=-1;for(;o.length<n.length;)o.push(new Float32Array(2));for(var I=0,y=n.length;I<y;++I)ev(n[I],o[I]);o.length=n.length}},{passive:!0}),this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(e){if(i.active&&i.pointerEnabled){var n=Date.now(),t=e.touches,l=e.changedTouches,a=u.hasSubs("pickedSurface");null!==r.longTouchTimeout&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null),0===t.length&&1===l.length&&f>-1&&n-f<150&&(p>-1&&f-p<325?(ev(l[0],s.pickCursorPos),s.schedulePickEntity=!0,s.schedulePickSurface=a,s.update(),s.pickResult?(s.pickResult.touchInput=!0,u.fire("doublePicked",s.pickResult),u.fire("touchDoublePicked",s.pickResult),s.pickedSurface&&(u.fire("doublePickedSurface",s.pickResult),u.fire("touchDoublePickedSurface",s.pickResult)),i.doublePickFlyTo&&d(s.pickResult)):(u.fire("doublePickedNothing"),u.fire("touchDoublePickedNothing"),i.doublePickFlyTo&&d()),p=-1):$.distVec2(o[0],c)<4&&(ev(l[0],s.pickCursorPos),s.schedulePickEntity=!0,s.schedulePickSurface=a,s.update(),s.pickResult?(s.pickResult.touchInput=!0,u.fire("picked",s.pickResult),u.fire("touchPicked",s.pickResult),s.pickedSurface&&(u.fire("pickedSurface",s.pickResult),u.fire("touchPickedSurface",s.pickResult))):(u.fire("pickedNothing"),u.fire("touchPickedNothing")),p=n),f=-1),o.length=t.length;for(var v=0,A=t.length;v<A;++v)o[v][0]=t[v].pageX,o[v][1]=t[v].pageY}},{passive:!0}),this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler)}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler),this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler),this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler))}}])}(),tv=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n),(t=v(this,n,[e,i])).PAN_LEFT=0,t.PAN_RIGHT=1,t.PAN_UP=2,t.PAN_DOWN=3,t.PAN_FORWARDS=4,t.PAN_BACKWARDS=5,t.ROTATE_X_POS=6,t.ROTATE_X_NEG=7,t.ROTATE_Y_POS=8,t.ROTATE_Y_NEG=9,t.DOLLY_FORWARDS=10,t.DOLLY_BACKWARDS=11,t.AXIS_VIEW_RIGHT=12,t.AXIS_VIEW_BACK=13,t.AXIS_VIEW_LEFT=14,t.AXIS_VIEW_FRONT=15,t.AXIS_VIEW_TOP=16,t.AXIS_VIEW_BOTTOM=17,t._keyMap={},t.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},t._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:i.snapRadius?i.snapRadius:20,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},t._states={pointerCanvasPos:$.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:$.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},t._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};var r=t.scene;return t._controllers={cameraControl:t,pickController:new Md(t,t._configs),pivotController:new Ld(r,t._configs),panController:new Rd(r),cameraFlight:new Yp(t,{duration:.5})},t._handlers=[new qd(t.scene,t._controllers,t._configs,t._states,t._updates),new $d(t.scene,t._controllers,t._configs,t._states,t._updates),new xd(t.scene,t._controllers,t._configs,t._states,t._updates),new Qd(t.scene,t._controllers,t._configs,t._states,t._updates),new Wd(t.scene,t._controllers,t._configs,t._states,t._updates),new nv(t.scene,t._controllers,t._configs,t._states,t._updates),new zd(t.scene,t._controllers,t._configs,t._states,t._updates)],t._cameraUpdater=new Xd(t.scene,t._controllers,t._configs,t._states,t._updates),t.navMode=i.navMode,i.planView&&(t.planView=i.planView),t.constrainVertical=i.constrainVertical,i.keyboardLayout?t.keyboardLayout=i.keyboardLayout:t.keyMap=i.keyMap,t.doublePickFlyTo=i.doublePickFlyTo,t.panRightClick=i.panRightClick,t.active=i.active,t.followPointer=i.followPointer,t.rotationInertia=i.rotationInertia,t.keyboardPanRate=i.keyboardPanRate,t.touchPanRate=i.touchPanRate,t.keyboardRotationRate=i.keyboardRotationRate,t.dragRotationRate=i.dragRotationRate,t.touchDollyRate=i.touchDollyRate,t.dollyInertia=i.dollyInertia,t.dollyProximityThreshold=i.dollyProximityThreshold,t.dollyMinSpeed=i.dollyMinSpeed,t.panInertia=i.panInertia,t.pointerEnabled=!0,t.keyboardDollyRate=i.keyboardDollyRate,t.mouseWheelDollyRate=i.mouseWheelDollyRate,t._moveRate=1,t.scene.on("tick",(function(){(t._goLeft||t._goRight||t._goUp||t._goDown||t._goForward||t._goBackward)&&(t._goRight?t._updates.panDeltaX+=-.1*t._moveRate:t._goLeft&&(t._updates.panDeltaX+=.1*t._moveRate),t._goUp?t._updates.panDeltaY+=.1*t._moveRate:t._goDown&&(t._updates.panDeltaY+=-.1*t._moveRate),t._goForward?t._updates.panDeltaZ+=-.1*t._moveRate:t._goBackward&&(t._updates.panDeltaZ+=.1*t._moveRate),t._inputDirectionCommand=!0)})),t}return m(n,me),C(n,[{key:"setdirectionChangeCancel",value:function(){this._goLeft=!1,this._goRight=!1,this._goUp=!1,this._goDown=!1,this._goForward=!1,this._goBackward=!1}},{key:"moveRate",set:function(e){this._moveRate=e}},{key:"goRight",set:function(e){this._goRight=e}},{key:"goLeft",set:function(e){this._goLeft=e}},{key:"goUp",set:function(e){this._goUp=e}},{key:"goDown",set:function(e){this._goDown=e}},{key:"goForward",set:function(e){this._goForward=e}},{key:"goBackward",set:function(e){this._goBackward=e}},{key:"updatePivotElement",value:function(){this._controllers.pivotController.updatePivotElement()}},{key:"keyMap",get:function(){return this._keyMap},set:function(e){if(e=e||"qwerty",ue.isString(e)){var n=this.scene.input,t={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":t[this.PAN_LEFT]=[n.KEY_A],t[this.PAN_RIGHT]=[n.KEY_D],t[this.PAN_UP]=[n.KEY_Z],t[this.PAN_DOWN]=[n.KEY_X],t[this.PAN_BACKWARDS]=[],t[this.PAN_FORWARDS]=[],t[this.DOLLY_FORWARDS]=[n.KEY_W,n.KEY_ADD],t[this.DOLLY_BACKWARDS]=[n.KEY_S,n.KEY_SUBTRACT],t[this.ROTATE_X_POS]=[n.KEY_DOWN_ARROW],t[this.ROTATE_X_NEG]=[n.KEY_UP_ARROW],t[this.ROTATE_Y_POS]=[n.KEY_Q,n.KEY_LEFT_ARROW],t[this.ROTATE_Y_NEG]=[n.KEY_E,n.KEY_RIGHT_ARROW],t[this.AXIS_VIEW_RIGHT]=[n.KEY_NUM_1],t[this.AXIS_VIEW_BACK]=[n.KEY_NUM_2],t[this.AXIS_VIEW_LEFT]=[n.KEY_NUM_3],t[this.AXIS_VIEW_FRONT]=[n.KEY_NUM_4],t[this.AXIS_VIEW_TOP]=[n.KEY_NUM_5],t[this.AXIS_VIEW_BOTTOM]=[n.KEY_NUM_6];break;case"azerty":t[this.PAN_LEFT]=[n.KEY_Q],t[this.PAN_RIGHT]=[n.KEY_D],t[this.PAN_UP]=[n.KEY_W],t[this.PAN_DOWN]=[n.KEY_X],t[this.PAN_BACKWARDS]=[],t[this.PAN_FORWARDS]=[],t[this.DOLLY_FORWARDS]=[n.KEY_Z,n.KEY_ADD],t[this.DOLLY_BACKWARDS]=[n.KEY_S,n.KEY_SUBTRACT],t[this.ROTATE_X_POS]=[n.KEY_DOWN_ARROW],t[this.ROTATE_X_NEG]=[n.KEY_UP_ARROW],t[this.ROTATE_Y_POS]=[n.KEY_A,n.KEY_LEFT_ARROW],t[this.ROTATE_Y_NEG]=[n.KEY_E,n.KEY_RIGHT_ARROW],t[this.AXIS_VIEW_RIGHT]=[n.KEY_NUM_1],t[this.AXIS_VIEW_BACK]=[n.KEY_NUM_2],t[this.AXIS_VIEW_LEFT]=[n.KEY_NUM_3],t[this.AXIS_VIEW_FRONT]=[n.KEY_NUM_4],t[this.AXIS_VIEW_TOP]=[n.KEY_NUM_5],t[this.AXIS_VIEW_BOTTOM]=[n.KEY_NUM_6]}this._keyMap=t}else{var i=e;this._keyMap=i}}},{key:"_isKeyDownForAction",value:function(e,n){var t=this._keyMap[e];if(!t)return!1;n||(n=this.scene.input.keyDown);for(var i=0,r=t.length;i<r;i++){if(n[t[i]])return!0}return!1}},{key:"pivotElement",set:function(e){this._controllers.pivotController.setPivotElement(e)}},{key:"active",get:function(){return this._configs.active},set:function(e){e=!1!==e,this._configs.active=e,this._handlers[1]._active=e,this._handlers[5]._active=e}},{key:"snapToVertex",get:function(){return this._configs.snapToVertex},set:function(e){this._configs.snapToVertex=!!e}},{key:"snapToEdge",get:function(){return this._configs.snapToEdge},set:function(e){this._configs.snapToEdge=!!e}},{key:"snapRadius",get:function(){return this._configs.snapRadius},set:function(e){e=e||20,this._configs.snapRadius=e}},{key:"navMode",get:function(){return this._configs.navMode},set:function(e){"firstPerson"!==(e=e||"orbit")&&"orbit"!==e&&"planView"!==e&&(this.error("Unsupported value for navMode: "+e+" - supported values are 'orbit', 'firstPerson' and 'planView' - defaulting to 'orbit'"),e="orbit"),this._configs.firstPerson="firstPerson"===e,this._configs.planView="planView"===e,(this._configs.firstPerson||this._configs.planView)&&(this._controllers.pivotController.hidePivot(),this._controllers.pivotController.endPivot()),this._configs.navMode=e}},{key:"pointerEnabled",get:function(){return this._configs.pointerEnabled},set:function(e){this._reset(),this._configs.pointerEnabled=!!e}},{key:"_reset",value:function(){for(var e=0,n=this._handlers.length;e<n;e++){var t=this._handlers[e];t.reset&&t.reset()}this._updates.panDeltaX=0,this._updates.panDeltaY=0,this._updates.rotateDeltaX=0,this._updates.rotateDeltaY=0,this._updates.dolyDelta=0}},{key:"followPointer",get:function(){return this._configs.followPointer},set:function(e){this._configs.followPointer=!1!==e}},{key:"pivotPos",get:function(){return this._controllers.pivotController.getPivotPos()},set:function(e){this._controllers.pivotController.setPivotPos(e)}},{key:"dollyToPointer",get:function(){return this.warn("dollyToPointer property is deprecated - replaced with followPointer"),this.followPointer},set:function(e){this.warn("dollyToPointer property is deprecated - replaced with followPointer"),this.followPointer=e}},{key:"panToPointer",get:function(){return this.warn("panToPointer property is deprecated - replaced with followPointer"),!1},set:function(e){this.warn("panToPointer property is deprecated - replaced with followPointer")}},{key:"planView",get:function(){return this._configs.planView},set:function(e){this._configs.planView=!!e,this._configs.firstPerson=!1,this._configs.planView&&(this._controllers.pivotController.hidePivot(),this._controllers.pivotController.endPivot()),this.warn("planView property is deprecated - replaced with navMode")}},{key:"firstPerson",get:function(){return this.warn("firstPerson property is deprecated - replaced with navMode"),this._configs.firstPerson},set:function(e){this.warn("firstPerson property is deprecated - replaced with navMode"),this._configs.firstPerson=!!e,this._configs.planView=!1,this._configs.firstPerson&&(this._controllers.pivotController.hidePivot(),this._controllers.pivotController.endPivot())}},{key:"constrainVertical",get:function(){return this._configs.constrainVertical},set:function(e){this._configs.constrainVertical=!!e}},{key:"doublePickFlyTo",get:function(){return this._configs.doublePickFlyTo},set:function(e){this._configs.doublePickFlyTo=!1!==e}},{key:"panRightClick",get:function(){return this._configs.panRightClick},set:function(e){this._configs.panRightClick=!1!==e}},{key:"rotationInertia",get:function(){return this._configs.rotationInertia},set:function(e){this._configs.rotationInertia=null!=e?e:0}},{key:"keyboardPanRate",get:function(){return this._configs.keyboardPanRate},set:function(e){this._configs.keyboardPanRate=null!=e?e:5}},{key:"touchPanRate",get:function(){return this._configs.touchPanRate},set:function(e){this._configs.touchPanRate=null!=e?e:1}},{key:"keyboardRotationRate",get:function(){return this._configs.keyboardRotationRate},set:function(e){this._configs.keyboardRotationRate=null!=e?e:90}},{key:"dragRotationRate",get:function(){return this._configs.dragRotationRate},set:function(e){this._configs.dragRotationRate=null!=e?e:360}},{key:"keyboardDollyRate",get:function(){return this._configs.keyboardDollyRate},set:function(e){this._configs.keyboardDollyRate=null!=e?e:15}},{key:"touchDollyRate",get:function(){return this._configs.touchDollyRate},set:function(e){this._configs.touchDollyRate=null!=e?e:.2}},{key:"mouseWheelDollyRate",get:function(){return this._configs.mouseWheelDollyRate},set:function(e){this._configs.mouseWheelDollyRate=null!=e?e:100}},{key:"dollyInertia",get:function(){return this._configs.dollyInertia},set:function(e){this._configs.dollyInertia=null!=e?e:0}},{key:"dollyProximityThreshold",get:function(){return this._configs.dollyProximityThreshold},set:function(e){this._configs.dollyProximityThreshold=null!=e?e:35}},{key:"dollyMinSpeed",get:function(){return this._configs.dollyMinSpeed},set:function(e){this._configs.dollyMinSpeed=null!=e?e:.04}},{key:"panInertia",get:function(){return this._configs.panInertia},set:function(e){this._configs.panInertia=null!=e?e:.5}},{key:"keyboardLayout",get:function(){return this._configs.keyboardLayout},set:function(e){"qwerty"!==(e=e||"qwerty")&&"azerty"!==e&&(this.error("Unsupported value for keyboardLayout - defaulting to 'qwerty'"),e="qwerty"),this._configs.keyboardLayout=e,this.keyMap=this._configs.keyboardLayout}},{key:"enablePivotSphere",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._controllers.pivotController.enablePivotSphere(e)}},{key:"disablePivotSphere",value:function(){this._controllers.pivotController.disablePivotSphere()}},{key:"smartPivot",get:function(){return this._configs.smartPivot},set:function(e){this._configs.smartPivot=!1!==e}},{key:"doubleClickTimeFrame",get:function(){return this._configs.doubleClickTimeFrame},set:function(e){this._configs.doubleClickTimeFrame=null!=e?e:250}},{key:"destroy",value:function(){this._destroyHandlers(),this._destroyControllers(),this._cameraUpdater.destroy(),I(y(n.prototype),"destroy",this).call(this)}},{key:"_destroyHandlers",value:function(){for(var e=0,n=this._handlers.length;e<n;e++){var t=this._handlers[e];t.destroy&&t.destroy()}}},{key:"_destroyControllers",value:function(){for(var e=0,n=this._controllers.length;e<n;e++){var t=this._controllers[e];t.destroy&&t.destroy()}}}])}(),iv=C((function e(n){T(this,e),this.id=n.id,this.originalSystemId=n.originalSystemId,this.metaModels=[],this.name=n.name,this.type=n.type,this.properties=[],n.properties&&(this.properties=n.properties)})),rv=function(){return C((function e(n){T(this,e),this.metaModels=[],this.id=n.id,this.parentId=n.parentId,this.parent=null,this.originalSystemId=n.originalSystemId,this.name=n.name,this.type=n.type,this.propertySetIds=n.propertySetIds,this.propertySets=[],void 0!==n.external&&null!==n.external&&(this.external=n.external)}),[{key:"metaModel",get:function(){return 1==this.metaModels.length?this.metaModels[0]:null}},{key:"getObjectIDsInSubtree",value:function(){var e=[];return function n(t){if(t){e.push(t.id);var i=t.children;if(i)for(var r=0,l=i.length;r<l;r++)n(i[r])}}(this),e}},{key:"withMetaObjectsInSubtree",value:function(e){!function n(t){if(t){e(t);var i=t.children;if(i)for(var r=0,l=i.length;r<l;r++)n(i[r])}}(this)}},{key:"getObjectIDsInSubtreeByType",value:function(e){for(var n={},t=0,i=e.length;t<i;t++)n[e[t]]=e[t];var r=[];return function e(t){if(t){n[t.type]&&r.push(t.id);var i=t.children;if(i)for(var l=0,a=i.length;l<a;l++)e(i[l])}}(this),r}},{key:"getJSON",value:function(){var e={id:this.id,type:this.type,name:this.name};return this.parent&&(e.parent=this.parent.id),e}}])}(),lv=function(){return C((function e(n){T(this,e),this.id=n.id,this.projectId=n.projectId,this.revisionId=n.revisionId,this.author=n.author,this.createdAt=n.createdAt,this.creatingApplication=n.creatingApplication,this.schema=n.schema,this.metaScene=n.metaScene,this.propertySets=[],this.rootMetaObjects=[],this.metaObjects=[],this.objectCount=0,this.propertySetCount=0,this.graph=n.graph||{},this.metaScene.metaModels[this.id]=this,this._finalized=!1}),[{key:"finalized",get:function(){return this._finalized},set:function(e){this._finalized=e}},{key:"rootMetaObject",get:function(){return 1==this.rootMetaObjects.length?this.rootMetaObjects[0]:null}},{key:"loadData",value:function(e,n,t){if(this._finalized)throw"MetaScene already finalized - can't add more data";try{var i,r,l,a,s,u,o,c;if(null===e)throw"metaModelData is null!";this.author=null!==(i=e.author)&&void 0!==i?i:"",this.schema=null!==(r=e.schema)&&void 0!==r?r:"",this.createdAt=null!==(l=e.createdAt)&&void 0!==l?l:"",this.projectId=null!==(a=e.projectId)&&void 0!==a?a:"",this.revisionId=null!==(s=e.revisionId)&&void 0!==s?s:"",this.objectCount=null!==(u=e.objectCount)&&void 0!==u?u:"",this.propertySetCount=null!==(o=e.propertySetCount)&&void 0!==o?o:"",this.creatingApplication=null!==(c=e.creatingApplication)&&void 0!==c?c:"";var f=this.metaScene;if(e.propertySets)for(var p in e.propertySets){var d=e.propertySets[p],v=new iv({id:d.id,originalSystemId:d.originalSystemId||d.id,type:d.type,name:d.name,properties:d.properties});f.propertySets[p]=v,this.propertySets.push(v)}if(e.metaObjects)for(var A in e.metaObjects){var h=e.metaObjects[A],I=new rv({id:A,originalSystemId:A,parentId:h.parent,type:h.type,name:h.name,propertySetIds:h.propertySetIds,external:h.external});I.children=[],I.metaModels=[],I.metaModels.push(this),f.metaObjects[A]=I,this.metaObjects.push(I),h.parent||(this.rootMetaObjects.push(I),f.rootMetaObjects[A]=I)}"function"==typeof n&&n()}catch(e){"function"==typeof t?t(e):this.log(t)}}},{key:"_decompressProperties",value:function(e,n){for(var t=0,i=n.length;t<i;t++){var r=n[t];if(Number.isInteger(r)){var l=e[r];l&&(n[t]=l)}}}},{key:"finalize",value:function(){if(this._finalized)throw"MetaScene already finalized - can't re-finalize";var e=this.metaScene;for(var n in e.metaObjectsByType={},e.metaObjects){var t=e.metaObjects[n];if(t.parentId){var i=e.metaObjects[t.parentId];i&&(t.parent=i,(i.children||(i.children=[])).push(t))}if(t.propertySets&&(t.propertySets=[]),t.propertySetIds)for(var r=0,l=t.propertySetIds.length;r<l;r++){var a=t.propertySetIds[r],s=e.propertySets[a];t.propertySets.push(s)}var u=t.type;(e.metaObjectsByType[u]||(e.metaObjectsByType[u]={}))[n]=t}this._finalized=!0,this.metaScene.fire("metaModelCreated",this.id)}},{key:"getJSON",value:function(){for(var e={id:this.id,projectId:this.projectId,author:this.author,createdAt:this.createdAt,schema:this.schema,creatingApplication:this.creatingApplication,metaObjects:[],propertySets:[]},n=0,t=this.metaObjects.length;n<t;n++){var i=this.metaObjects[n],r={id:i.id,originalSystemId:i.originalSystemId,extId:i.extId,type:i.type,name:i.name};i.parent&&(r.parent=i.parent.id),i.attributes&&(r.attributes=i.attributes),i.propertySetIds&&(r.propertySetIds=i.propertySetIds),e.metaObjects.push(r)}for(var l=0,a=this.propertySets.length;l<a;l++){for(var s=this.propertySets[l],u={id:s.id,originalSystemId:s.originalSystemId,extId:s.extId,type:s.type,name:s.name,propertyies:[]},o=0,c=s.properties.length;o<c;o++){var f=s.properties[o],p={id:f.id,description:f.description,type:f.type,name:f.name,value:f.value,valueType:f.valueType};u.properties.push(p)}e.propertySets.push(u)}return e}},{key:"_globalizeIDs",value:function(e,n){var t=!!n.globalizeObjectIds;if(e.metaObjects)for(var i=0,r=e.metaObjects.length;i<r;i++){var l=e.metaObjects[i];if(l.originalSystemId=l.id,l.parent&&(l.originalParentSystemId=l.parent),t&&(l.id=$.globalizeObjectId(this.id,l.id),l.parent&&(l.parent=$.globalizeObjectId(this.id,l.parent))),t){var a=l.propertySetIds;if(a){for(var s=[],u=0,o=a.length;u<o;u++)s.push($.globalizeObjectId(this.id,a[u]));l.propertySetIds=s,l.originalSystemPropertySetIds=a}}else l.originalSystemPropertySetIds=l.propertySetIds}if(e.propertySets)for(var c=0,f=e.propertySets.length;c<f;c++){var p=e.propertySets[c];p.originalSystemId=p.id,t&&(p.id=$.globalizeObjectId(this.id,p.id))}}}])}(),av=function(){return C((function e(n,t){T(this,e),this.viewer=n,this.scene=t,this.metaModels={},this.propertySets={},this.metaObjects={},this.metaObjectsByType={},this.rootMetaObjects={},this._eventSubs={}}),[{key:"on",value:function(e,n){var t=this._eventSubs[e];t||(t=[],this._eventSubs[e]=t),t.push(n)}},{key:"fire",value:function(e,n){var t=this._eventSubs[e];if(t)for(var i=0,r=t.length;i<r;i++)t[i](n)}},{key:"off",value:function(e){}},{key:"createMetaModel",value:function(e,n){var t=new lv({metaScene:this,id:e,projectId:n.projectId||"none",revisionId:n.revisionId||"none",author:n.author||"none",createdAt:n.createdAt||"none",creatingApplication:n.creatingApplication||"none",schema:n.schema||"none",propertySets:[]});return t.loadData(n),t.finalize(),t}},{key:"destroyMetaModel",value:function(e){var n=this.metaModels[e];if(n){if(n.propertySets)for(var t=0,i=n.propertySets.length;t<i;t++){var r=n.propertySets[t];if(1===r.metaModels.length&&r.metaModels[0].id===e)delete this.propertySets[r.id];else{for(var l=[],a=0,s=r.metaModels.length;a<s;a++)r.metaModels[a].id!==e&&l.push(r.metaModels[a]);r.metaModels=l}}if(n.metaObjects)for(var u=0,o=n.metaObjects.length;u<o;u++){var c=n.metaObjects[u];c.type;var f=c.id;1===c.metaModels.length&&c.metaModels[0].id===e&&(delete this.metaObjects[f],c.parent||delete this.rootMetaObjects[f])}for(var p in this.metaObjects){var d=this.metaObjects[p];if(d.children&&(d.children=[]),d.propertySets&&(d.propertySets=[]),d.propertySetIds)for(var v=0,A=d.propertySetIds.length;v<A;v++){var h=d.propertySetIds[v],I=this.propertySets[h];d.propertySets.push(I)}}for(var y in this.metaObjectsByType={},this.metaObjects){var m=this.metaObjects[y],w=m.type;m.children&&(m.children=null),(this.metaObjectsByType[w]||(this.metaObjectsByType[w]={}))[y]=m}for(var g in this.metaObjects){var E=this.metaObjects[g];if(E.parentId){var T=this.metaObjects[E.parentId];T&&(E.parent=T,(T.children||(T.children=[])).push(E))}}delete this.metaModels[e],this.fire("metaModelDestroyed",e)}}},{key:"getObjectIDsByType",value:function(e){var n=this.metaObjectsByType[e];return n?Object.keys(n):[]}},{key:"getObjectIDsByTypes",value:function(e){for(var n=[],t=0;t<e.length;t++){var i=e[t];n=n.concat(this.getObjectIDsByType(i))}return n}},{key:"getObjectIDsInSubtree",value:function(e,n,t){var i=[],r=this.metaObjects[e],l=n&&n.length>0?sv(n):null,a=t&&t.length>0?sv(t):null;return function e(n){if(n){var t=!0;(a&&a[n.type]||l&&!l[n.type])&&(t=!1),t&&i.push(n.id);var r=n.children;if(r)for(var s=0,u=r.length;s<u;s++)e(r[s])}}(r),i}},{key:"withMetaObjectsInSubtree",value:function(e,n){var t=this.metaObjects[e];t&&t.withMetaObjectsInSubtree(n)}}])}();function sv(e){for(var n={},t=0,i=e.length;t<i;t++)n[e[t]]=!0;return n}
17
+ **/var Gf=8,kf=null;function Vf(e,n){var t,i,r,l,a,s,u=3*e,o=3*n,c=Math.min(t=kf[u],i=kf[u+1],r=kf[u+2]),f=Math.min(l=kf[o],a=kf[o+1],s=kf[o+2]);if(c!==f)return c-f;var p=Math.max(t,i,r),d=Math.max(l,a,s);return p!==d?p-d:0}var jf=null;function Qf(e,n){var t=jf[2*e]-jf[2*n];return 0!==t?t:jf[2*e+1]-jf[2*n+1]}function Wf(e,n){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.positionsCompressed||[],r=function(e,n){for(var t=new Int32Array(e.length/3),i=0,r=t.length;i<r;i++)t[i]=i;kf=new Int32Array(e.length);for(var l=0,a=e.length;l<a;l++)kf[l]=e[l]>>n;t.sort(Vf);for(var s=new Int32Array(e.length),u=0,o=t.length;u<o;u++)s[3*u+0]=e[3*t[u]+0],s[3*u+1]=e[3*t[u]+1],s[3*u+2]=e[3*t[u]+2];return s}(e.indices||[],n),l=function(e){if(0===(e||[]).length)return[];for(var n=new Int32Array(e.length/2),t=0,i=n.length;t<i;t++)n[t]=t;for(var r=0,l=e.length;r<l;r+=2)if(e[r]>e[r+1]){var a=e[r];e[r]=e[r+1],e[r+1]=a}jf=new Int32Array(e),n.sort(Qf);for(var s=new Int32Array(e.length),u=0,o=n.length;u<o;u++)s[2*u+0]=e[2*n[u]+0],s[2*u+1]=e[2*n[u]+1];return s}(e.edgeIndices||[]);function a(e,n){if(e>n){var t=e;e=n,n=t}function i(t,i){return t!==e?e-t:i!==n?n-i:0}for(var r=0,a=(l.length>>1)-1;r<=a;){var s=a+r>>1,u=i(l[2*s],l[2*s+1]);if(u>0)r=s+1;else{if(!(u<0))return s;a=s-1}}return-r-1}var s=new Int32Array(l.length/2);s.fill(0);var u=i.length/3;if(u>(1<<n)*Gf)return[e];var o=new Int32Array(u);o.fill(-1);var c=[];function f(){o.fill(-1);var e={positionsCompressed:[],indices:[],edgeIndices:[],maxNumPositions:(1<<n)-n,numPositions:0,bucketNumber:c.length};return c.push(e),e}for(var p=f(),d=0,v=r.length;d<v;d+=3){var A=0,h=r[d],I=r[d+1],y=r[d+2];if(-1===o[h]&&A++,-1===o[I]&&A++,-1===o[y]&&A++,A+p.numPositions>p.maxNumPositions&&(p=f()),p.bucketNumber>Gf)return[e];-1===o[h]&&(o[h]=p.numPositions++,p.positionsCompressed.push(i[3*h]),p.positionsCompressed.push(i[3*h+1]),p.positionsCompressed.push(i[3*h+2])),-1===o[I]&&(o[I]=p.numPositions++,p.positionsCompressed.push(i[3*I]),p.positionsCompressed.push(i[3*I+1]),p.positionsCompressed.push(i[3*I+2])),-1===o[y]&&(o[y]=p.numPositions++,p.positionsCompressed.push(i[3*y]),p.positionsCompressed.push(i[3*y+1]),p.positionsCompressed.push(i[3*y+2])),p.indices.push(o[h]),p.indices.push(o[I]),p.indices.push(o[y]);var m=void 0;(m=a(h,I))>=0&&0===s[m]&&(s[m]=1,p.edgeIndices.push(o[l[2*m]]),p.edgeIndices.push(o[l[2*m+1]])),(m=a(h,y))>=0&&0===s[m]&&(s[m]=1,p.edgeIndices.push(o[l[2*m]]),p.edgeIndices.push(o[l[2*m+1]])),(m=a(I,y))>=0&&0===s[m]&&(s[m]=1,p.edgeIndices.push(o[l[2*m]]),p.edgeIndices.push(o[l[2*m+1]]))}var w=n/8*2,g=n/8,E=2*i.length+(r.length+l.length)*w,T=0;i.length;return c.forEach((function(e){T+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*g,e.positionsCompressed.length/3})),T>E?[e]:(t&&function(e,n){var t={};e.forEach((function(e){for(var n=e.indices,i=e.edgeIndices,r=e.positionsCompressed,l=0,a=n.length;l<a;l+=3){var s=r[3*n[l]]+"_"+r[3*n[l]+1]+"_"+r[3*n[l]+2]+"/"+r[3*n[l+1]]+"_"+r[3*n[l+1]+1]+"_"+r[3*n[l+1]+2]+"/"+r[3*n[l+2]]+"_"+r[3*n[l+2]+1]+"_"+r[3*n[l+2]+2];t[s]=!0}e.edgeIndices.length/2;for(var u=0,o=i.length;u<o;u+=2)r[3*i[u]],r[3*i[u]+1],r[3*i[u]+2],r[3*i[u+1]],r[3*i[u+1]+1],r[3*i[u+1]+2]}));var i=n.indices;n.edgeIndices;for(var r=n.positionsCompressed,l=0,a=i.length;l<a;l+=3){var s=r[3*i[l]]+"_"+r[3*i[l]+1]+"_"+r[3*i[l]+2]+"/"+r[3*i[l+1]]+"_"+r[3*i[l+1]+1]+"_"+r[3*i[l+1]+2]+"/"+r[3*i[l+2]]+"_"+r[3*i[l+2]+1]+"_"+r[3*i[l+2]+2];if(!(s in t))throw console.log("Not found "+s),"Ohhhh!"}}(c,e),c)}var zf=$.vec4(4),Yf=$.vec4(),Kf=$.vec4(),Xf=$.vec3([1,0,0]),qf=$.vec3([0,1,0]),Jf=$.vec3([0,0,1]);$.vec3(3),$.vec3(3);var Zf=$.identityMat4(),$f=function(){return C((function e(n){T(this,e),this._model=n.model,this.id=n.id,this._parentTransform=n.parent,this._childTransforms=[],this._meshes=[],this._scale=new Float32Array([1,1,1]),this._quaternion=$.identityQuaternion(new Float32Array(4)),this._rotation=new Float32Array(3),this._position=new Float32Array(3),this._localMatrix=$.identityMat4(new Float32Array(16)),this._worldMatrix=$.identityMat4(new Float32Array(16)),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,n.matrix?this.matrix=n.matrix:(this.scale=n.scale,this.position=n.position,n.quaternion||(this.rotation=n.rotation)),n.parent&&n.parent._addChildTransform(this)}),[{key:"_addChildTransform",value:function(e){this._childTransforms.push(e),e._parentTransform=this,e._setWorldMatrixDirty(),e._setAABBDirty()}},{key:"_addMesh",value:function(e){this._meshes.push(e),e.transform=this}},{key:"parentTransform",get:function(){return this._parentTransform}},{key:"meshes",get:function(){return this._meshes}},{key:"position",get:function(){return this._position},set:function(e){this._position.set(e||[0,0,0]),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation.set(e||[0,0,0]),$.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"quaternion",get:function(){return this._quaternion},set:function(e){this._quaternion.set(e||[0,0,0,1]),$.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"scale",get:function(){return this._scale},set:function(e){this._scale.set(e||[1,1,1]),this._setLocalMatrixDirty(),this._model.glRedraw()}},{key:"matrix",get:function(){return this._localMatrixDirty&&(this._localMatrix||(this._localMatrix=$.identityMat4()),$.composeMat4(this._position,this._quaternion,this._scale,this._localMatrix),this._localMatrixDirty=!1),this._localMatrix},set:function(e){this._localMatrix||(this._localMatrix=$.identityMat4()),this._localMatrix.set(e||Zf),$.decomposeMat4(this._localMatrix,this._position,this._quaternion,this._scale),this._localMatrixDirty=!1,this._transformDirty(),this._model.glRedraw()}},{key:"worldMatrix",get:function(){return this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldMatrix}},{key:"rotate",value:function(e,n){return zf[0]=e[0],zf[1]=e[1],zf[2]=e[2],zf[3]=n*$.DEGTORAD,$.angleAxisToQuaternion(zf,Yf),$.mulQuaternions(this.quaternion,Yf,Kf),this.quaternion=Kf,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"rotateOnWorldAxis",value:function(e,n){return zf[0]=e[0],zf[1]=e[1],zf[2]=e[2],zf[3]=n*$.DEGTORAD,$.angleAxisToQuaternion(zf,Yf),$.mulQuaternions(Yf,this.quaternion,Yf),this}},{key:"rotateX",value:function(e){return this.rotate(Xf,e)}},{key:"rotateY",value:function(e){return this.rotate(qf,e)}},{key:"rotateZ",value:function(e){return this.rotate(Jf,e)}},{key:"translate",value:function(e){return this._position[0]+=e[0],this._position[1]+=e[1],this._position[2]+=e[2],this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"translateX",value:function(e){return this._position[0]+=e,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"translateY",value:function(e){return this._position[1]+=e,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"translateZ",value:function(e){return this._position[2]+=e,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"_setLocalMatrixDirty",value:function(){this._localMatrixDirty=!0,this._transformDirty()}},{key:"_transformDirty",value:function(){this._worldMatrixDirty=!0;for(var e=0,n=this._childTransforms.length;e<n;e++){var t=this._childTransforms[e];if(t._transformDirty(),t._meshes&&t._meshes.length>0)for(var i=t._meshes,r=0,l=i.length;r<l;r++)i[r]._transformDirty()}if(this._meshes&&this._meshes.length>0)for(var a=this._meshes,s=0,u=a.length;s<u;s++)a[s]._transformDirty()}},{key:"_buildWorldMatrix",value:function(){var e=this.matrix;if(this._parentTransform)$.mulMat4(this._parentTransform.worldMatrix,e,this._worldMatrix);else for(var n=0,t=e.length;n<t;n++)this._worldMatrix[n]=e[n];this._worldMatrixDirty=!1}},{key:"_setSubtreeAABBsDirty",value:function(e){if(e._aabbDirty=!0,e._childTransforms)for(var n=0,t=e._childTransforms.length;n<t;n++)this._setSubtreeAABBsDirty(e._childTransforms[n])}}])}(),ep=$.vec3(),np=$.OBB3(),tp=$.vec3([1,1,1]),ip=$.vec3([0,0,0]),rp=$.vec3([0,0,0]),lp=$.identityQuaternion(),ap=$.identityMat4(),sp="defaultColorTexture",up="defaultMetalRoughTexture",op="defaultNormalsTexture",cp="defaultEmissiveTexture",fp="defaultOcclusionTexture",pp="defaultTextureSet",dp=new Uint8Array([255,255,255]),vp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._dtxEnabled=t.scene.dtxEnabled&&!1!==i.dtxEnabled,t._enableVertexWelding=!1,t._enableIndexBucketing=!1,t._vboBatchingLayerScratchMemory=(ta++,na),t._textureTranscoder=i.textureTranscoder||Mf(t.scene.viewer),t._maxGeometryBatchSize=i.maxGeometryBatchSize,t._aabb=$.collapseAABB3(),t._aabbDirty=!0,t._aabbUpdate=!1,t._exceptionIds=[],t._quantizationRanges={},t._vboInstancingLayers={},t._vboBatchingLayers={},t._dtxLayers={},t.layerList=[],t._entityList=[],t._geometries={},t._dtxBuckets={},t._textures={},t._textureSets={},t._transforms={},t._meshes={},t._entities={},t._scheduledMeshes={},t._meshesCfgsBeforeMeshCreation={},t.renderFlags=new Kr,t.numGeometries=0,t.numPortions=0,t.numVisibleLayerPortions=0,t.numTransparentLayerPortions=0,t.numXRayedLayerPortions=0,t.numHighlightedLayerPortions=0,t.numSelectedLayerPortions=0,t.numEdgesLayerPortions=0,t.numPickableLayerPortions=0,t.numClippableLayerPortions=0,t.numCulledLayerPortions=0,t.numEntities=0,t._numTriangles=0,t._numLines=0,t._numPoints=0,t._edgeThreshold=i.edgeThreshold||10,t._origin=$.vec3(i.origin||[0,0,0]),t._position=$.vec3(i.position||[0,0,0]),t._rotation=$.vec3(i.rotation||[0,0,0]),t._quaternion=$.vec4(i.quaternion||[0,0,0,1]),t._conjugateQuaternion=$.vec4(i.quaternion||[0,0,0,1]),i.rotation&&$.eulerToQuaternion(t._rotation,"XYZ",t._quaternion),t._scale=$.vec3(i.scale||[1,1,1]),t._worldRotationMatrix=$.mat4(),t._worldRotationMatrixConjugate=$.mat4(),t._matrix=$.mat4(),t._matrixDirty=!0,t._rebuildMatrices(),t._worldNormalMatrix=$.mat4(),$.inverseMat4(t._matrix,t._worldNormalMatrix),$.transposeMat4(t._worldNormalMatrix),(i.matrix||i.position||i.rotation||i.scale||i.quaternion)&&(t._viewMatrix=$.mat4(),t._viewNormalMatrix=$.mat4(),t._viewMatrixDirty=!0,t._matrixNonIdentity=!0),t._opacity=1,t._colorize=[1,1,1],t._saoEnabled=!1!==i.saoEnabled,t._pbrEnabled=!1!==i.pbrEnabled,t._colorTextureEnabled=!1!==i.colorTextureEnabled,t._isModel=i.isModel,t._isModel&&t.scene._registerModel(t),t._onCameraViewMatrix=t.scene.camera.on("matrix",(function(){t._viewMatrixDirty=!0})),t._meshesWithDirtyMatrices=[],t._numMeshesWithDirtyMatrices=0,t._onTick=t.scene.on("tick",(function(){for(;t._numMeshesWithDirtyMatrices>0;)t._meshesWithDirtyMatrices[--t._numMeshesWithDirtyMatrices]._updateMatrix()})),t._createDefaultTextureSet(),t.visible=i.visible,t.culled=i.culled,t.pickable=i.pickable,t.clippable=i.clippable,t.collidable=i.collidable,t.castsShadow=i.castsShadow,t.receivesShadow=i.receivesShadow,t.xrayed=i.xrayed,t.highlighted=i.highlighted,t.selected=i.selected,t.edges=i.edges,t.colorize=i.colorize,t.opacity=i.opacity,t.backfaces=i.backfaces,t}return m(n,me),C(n,[{key:"_meshMatrixDirty",value:function(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}},{key:"_createDefaultTextureSet",value:function(){var e=new bf({id:sp,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),n=new bf({id:up,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),t=new bf({id:op,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),i=new bf({id:cp,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new bf({id:fp,texture:new Nl({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures[sp]=e,this._textures[up]=n,this._textures[op]=t,this._textures[cp]=i,this._textures[fp]=r,this._textureSets[pp]=new Tf({id:pp,model:this,colorTexture:e,metallicRoughnessTexture:n,normalsTexture:t,emissiveTexture:i,occlusionTexture:r})}},{key:"isPerformanceModel",get:function(){return!0}},{key:"transforms",get:function(){return this._transforms}},{key:"textures",get:function(){return this._textures}},{key:"textureSets",get:function(){return this._textureSets}},{key:"meshes",get:function(){return this._meshes}},{key:"objects",get:function(){return this._entities}},{key:"origin",get:function(){return this._origin}},{key:"position",get:function(){return this._position},set:function(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation.set(e||[0,0,0]),$.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"quaternion",get:function(){return this._quaternion},set:function(e){this._quaternion.set(e||[0,0,0,1]),$.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"scale",get:function(){return this._scale},set:function(e){}},{key:"matrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix},set:function(e){this._matrix.set(e||ap),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotationMatrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}},{key:"_rebuildMatrices",value:function(){this._matrixDirty&&($.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}},{key:"rotationMatrixConjugate",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}},{key:"_setWorldMatrixDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0}},{key:"_transformDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}},{key:"_sceneModelDirty",value:function(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(var e=0,n=this._entityList.length;e<n;e++)this._entityList[e]._sceneModelDirty()}},{key:"worldMatrix",get:function(){return this.matrix}},{key:"worldNormalMatrix",get:function(){return this._worldNormalMatrix}},{key:"viewMatrix",get:function(){return this._viewMatrix?(this._matrixDirty&&(this._rebuildMatrices(),this._viewMatrixDirty=!0),this._viewMatrixDirty&&($.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),$.inverseMat4(this._viewMatrix,this._viewNormalMatrix),$.transposeMat4(this._viewNormalMatrix),this._viewMatrixDirty=!1),this._viewMatrix):this.scene.camera.viewMatrix}},{key:"viewNormalMatrix",get:function(){return this._viewNormalMatrix?(this._matrixDirty&&(this._rebuildMatrices(),this._viewMatrixDirty=!0),this._viewMatrixDirty&&($.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),$.inverseMat4(this._viewMatrix,this._viewNormalMatrix),$.transposeMat4(this._viewNormalMatrix),this._viewMatrixDirty=!1),$.inverseMat4(this._viewMatrix,this._viewNormalMatrix),$.transposeMat4(this._viewNormalMatrix),this._viewNormalMatrix):this.scene.camera.viewNormalMatrix}},{key:"backfaces",get:function(){return this._backfaces},set:function(e){e=!!e,this._backfaces=e,this.glRedraw()}},{key:"entityList",get:function(){return this._entityList}},{key:"isEntity",get:function(){return!0}},{key:"isModel",get:function(){return this._isModel}},{key:"isObject",get:function(){return!1}},{key:"aabb",get:function(){if(this._aabbDirty){if(this._aabbUpdate)return this._aabb;if(this._exceptionIds.length>0)this.updateAABBCullException(this._exceptionIds);else{$.collapseAABB3(this._aabb);for(var e=0,n=this._entityList.length;e<n;e++)$.expandAABB3(this._aabb,this._entityList[e].aabb)}this._aabbDirty=!1}return this._aabb}},{key:"exceptionIds",get:function(){return this._exceptionIds},set:function(e){this._exceptionIds=e,this._aabbDirty=!0,this._aabbUpdate=!1,this.scene._setAABBDirty()}},{key:"updateAABBCullException",value:function(e,n){function t(n){var t=!0;return e.forEach((function(e){e===n&&(t=!1)})),t}for(var i=$.collapseAABB3(),r=0,l=this._entityList.length;r<l;r++)t(this._entityList[r].id)&&$.expandAABB3(i,this._entityList[r].aabb);for(var a=0;a<i.length;a++)this._aabb[a]=i[a];this._aabbDirty=!1,this._aabbUpdate=!0,this.scene._setAABBDirty(),"function"==typeof n&&n()}},{key:"cancelCullException",value:function(e){this._exceptionIds=[],this._aabbDirty=!0,this._aabbUpdate=!1,this.aabb,this.scene._aabbUpdate=!1,this.scene._setAABBDirty(),"function"==typeof e&&e()}},{key:"aabbs",get:function(){for(var e=[],n=0,t=this._entityList.length;n<t;n++)e.push(this._entityList[n].aabb);return e}},{key:"numTriangles",get:function(){return this._numTriangles}},{key:"numLines",get:function(){return this._numLines}},{key:"numPoints",get:function(){return this._numPoints}},{key:"visible",get:function(){return this.numVisibleLayerPortions>0},set:function(e){e=!1!==e,this._visible=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].visible=e;this.glRedraw()}},{key:"xrayed",get:function(){return this.numXRayedLayerPortions>0},set:function(e){e=!!e,this._xrayed=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].xrayed=e;this.glRedraw()}},{key:"highlighted",get:function(){return this.numHighlightedLayerPortions>0},set:function(e){e=!!e,this._highlighted=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].highlighted=e;this.glRedraw()}},{key:"selected",get:function(){return this.numSelectedLayerPortions>0},set:function(e){e=!!e,this._selected=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].selected=e;this.glRedraw()}},{key:"edges",get:function(){return this.numEdgesLayerPortions>0},set:function(e){e=!!e,this._edges=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].edges=e;this.glRedraw()}},{key:"culled",get:function(){return this._culled},set:function(e){e=!!e,this._culled=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].culled=e;this.glRedraw()}},{key:"clippable",get:function(){return this._clippable},set:function(e){e=!1!==e,this._clippable=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].clippable=e;this.glRedraw()}},{key:"collidable",get:function(){return this._collidable},set:function(e){e=!1!==e,this._collidable=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].collidable=e}},{key:"pickable",get:function(){return this.numPickableLayerPortions>0},set:function(e){e=!1!==e,this._pickable=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].pickable=e}},{key:"colorize",get:function(){return this._colorize},set:function(e){this._colorize=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].colorize=e}},{key:"opacity",get:function(){return this._opacity},set:function(e){this._opacity=e;for(var n=0,t=this._entityList.length;n<t;n++)this._entityList[n].opacity=e}},{key:"castsShadow",get:function(){return this._castsShadow},set:function(e){(e=!1!==e)!==this._castsShadow&&(this._castsShadow=e,this.glRedraw())}},{key:"receivesShadow",get:function(){return this._receivesShadow},set:function(e){(e=!1!==e)!==this._receivesShadow&&(this._receivesShadow=e,this.glRedraw())}},{key:"saoEnabled",get:function(){return this._saoEnabled}},{key:"pbrEnabled",get:function(){return this._pbrEnabled}},{key:"colorTextureEnabled",get:function(){return this._colorTextureEnabled}},{key:"isDrawable",get:function(){return!0}},{key:"isStateSortable",get:function(){return!1}},{key:"xrayMaterial",get:function(){return this.scene.xrayMaterial}},{key:"highlightMaterial",get:function(){return this.scene.highlightMaterial}},{key:"selectedMaterial",get:function(){return this.scene.selectedMaterial}},{key:"edgeMaterial",get:function(){return this.scene.edgeMaterial}},{key:"getPickViewMatrix",value:function(e){return this._viewMatrix?this._viewMatrix:e}},{key:"createQuantizationRange",value:function(e){void 0!==e.id&&null!==e.id?e.aabb?this.error("[createQuantizationRange] Config missing: aabb"):this._quantizationRanges[e.id]?this.error("[createQuantizationRange] QuantizationRange already created: "+e.id):this._quantizationRanges[e.id]={id:e.id,aabb:e.aabb,matrix:qa(e.aabb,$.mat4())}:this.error("[createQuantizationRange] Config missing: id")}},{key:"createGeometry",value:function(e){if(void 0!==e.id&&null!==e.id)if(this._geometries[e.id])this.error("[createGeometry] Geometry already created: "+e.id);else if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"===e.primitive||"lines"===e.primitive||"triangles"===e.primitive||"solid"===e.primitive||"surface"===e.primitive){if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("[createGeometry] Param expected: `positions`, `positionsCompressed' or 'buckets"),null;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("[createGeometry] Param expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')"),null;if(e.positionsDecodeMatrix&&e.positionsDecodeBoundary)return this.error("[createGeometry] Only one of these params expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')"),null;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("[createGeometry] Param expected: `uvDecodeMatrix` (required for `uvCompressed')"),null;if(!e.buckets&&!e.indices&&"points"!==e.primitive)return this.error("[createGeometry] Param expected: indices (required for '".concat(e.primitive,"' primitive type)")),null;if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=qa(e.positionsDecodeBoundary,$.mat4())),e.positions){var n=$.collapseAABB3();e.positionsDecodeMatrix=$.mat4(),$.expandAABB3Points3(n,e.positions),e.positionsCompressed=Xa(e.positions,n,e.positionsDecodeMatrix),e.aabb=n}else if(e.positionsCompressed){var t=$.collapseAABB3();e.positionsDecodeMatrix=new Float64Array(e.positionsDecodeMatrix),e.positionsCompressed=new Uint16Array(e.positionsCompressed),$.expandAABB3Points3(t,e.positionsCompressed),Bt.decompressAABB(t,e.positionsDecodeMatrix),e.aabb=t}else if(e.buckets){var i=$.collapseAABB3();this._dtxBuckets[e.id]=e.buckets;for(var r=0,l=e.buckets.length;r<l;r++){var a=e.buckets[r];a.positions?$.expandAABB3Points3(i,a.positions):a.positionsCompressed&&$.expandAABB3Points3(i,a.positionsCompressed)}e.positionsDecodeMatrix&&Bt.decompressAABB(i,e.positionsDecodeMatrix),e.aabb=i}if(e.colorsCompressed&&e.colorsCompressed.length>0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){for(var s=e.colors,u=new Uint8Array(s.length),o=0,c=s.length;o<c;o++)u[o]=255*s[o];e.colorsCompressed=u}if(e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=bt(e.positions,e.indices,null,5):e.edgeIndices=bt(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.uv){var f=Bt.getUVBounds(e.uv),p=Bt.compressUVs(e.uv,f.min,f.max);e.uvCompressed=p.quantized,e.uvDecodeMatrix=p.decodeMatrix}else e.uvCompressed&&(e.uvCompressed=new Uint16Array(e.uvCompressed),e.uvDecodeMatrix=new Float64Array(e.uvDecodeMatrix));e.normals&&(e.normals=null),this._geometries[e.id]=e,this._numTriangles+=e.indices?Math.round(e.indices.length/3):0,this.numGeometries++}else this.error("[createGeometry] Unsupported value for 'primitive': '".concat(e.primitive,"' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'."));else this.error("[createGeometry] Config missing: id")}},{key:"createTexture",value:function(e){var n=this,t=e.id;if(null!=t)if(this._textures[t])this.error("[createTexture] Texture already created: "+t);else{if(!e.src&&!e.image&&!e.buffers)return this.error("[createTexture] Param expected: `src`, `image' or 'buffers'"),null;var i=e.minFilter||pi;i!==oi&&i!==fi&&i!==pi&&i!==ui&&i!==li&&(this.error("[createTexture] Unsupported value for 'minFilter' - \n supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, \n NearestMipMapLinearFilter and LinearMipmapLinearFilter. Defaulting to LinearMipmapLinearFilter."),i=pi);var r=e.magFilter||oi;r!==oi&&r!==ri&&(this.error("[createTexture] Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter."),r=oi);var l=e.wrapS||ni;l!==ti&&l!==ii&&l!==ni&&(this.error("[createTexture] Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),l=ni);var a=e.wrapT||ni;a!==ti&&a!==ii&&a!==ni&&(this.error("[createTexture] Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),a=ni);var s=e.wrapR||ni;s!==ti&&s!==ii&&s!==ni&&(this.error("[createTexture] Unsupported value for 'wrapR' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),s=ni);var u=e.encoding||or;u!==or&&u!==cr&&(this.error("[createTexture] Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),u=or);var o=new Nl({gl:this.scene.canvas.gl,minFilter:i,magFilter:r,wrapS:l,wrapT:a,wrapR:s,encoding:u});if(e.preloadColor&&o.setPreloadColor(e.preloadColor),e.image){var c=e.image;c.crossOrigin="Anonymous",o.setImage(c,{minFilter:i,magFilter:r,wrapS:l,wrapT:a,wrapR:s,flipY:e.flipY,encoding:u})}else if(e.src){var f=e.src.split(".").pop();switch(f){case"jpeg":case"jpg":case"png":case"gif":var p=new Image;p.onload=function(){o.setImage(p,{minFilter:i,magFilter:r,wrapS:l,wrapT:a,wrapR:s,flipY:e.flipY,encoding:u}),n.glRedraw()},p.src=e.src;break;default:this._textureTranscoder?ue.loadArraybuffer(e.src,(function(e){e.byteLength?n._textureTranscoder.transcode([e],o).then((function(){n.glRedraw()})):n.error("[createTexture] Can't create texture from 'src': file data is zero length")}),(function(e){this.error("[createTexture] Can't create texture from 'src': ".concat(e))})):this.error("[createTexture] Can't create texture from 'src' - SceneModel needs to be configured with a TextureTranscoder for this file type ('".concat(f,"')"))}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,o).then((function(){n.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[t]=new bf({id:t,texture:o})}else this.error("[createTexture] Config missing: id")}},{key:"createTextureSet",value:function(e){var n=e.id;if(null!=n){if(!this._textureSets[n]){var t,i,r,l,a;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(!(t=this._textures[e.colorTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.colorTextureId," - ensure that you create it first with createTexture()"))}else t=this._textures[sp];if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(!(i=this._textures[e.metallicRoughnessTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.metallicRoughnessTextureId," - ensure that you create it first with createTexture()"))}else i=this._textures[up];if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(!(r=this._textures[e.normalsTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.normalsTextureId," - ensure that you create it first with createTexture()"))}else r=this._textures[op];if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(!(l=this._textures[e.emissiveTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.emissiveTextureId," - ensure that you create it first with createTexture()"))}else l=this._textures[cp];if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(!(a=this._textures[e.occlusionTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.occlusionTextureId," - ensure that you create it first with createTexture()"))}else a=this._textures[fp];var s=new Tf({id:n,model:this,colorTexture:t,metallicRoughnessTexture:i,normalsTexture:r,emissiveTexture:l,occlusionTexture:a});return this._textureSets[n]=s,s}this.error("[createTextureSet] Texture set already created: ".concat(n))}else this.error("[createTextureSet] Config missing: id")}},{key:"createTransform",value:function(e){if(void 0!==e.id&&null!==e.id)if(this._transforms[e.id])this.error("[createTransform] SceneModel already has a transform with this ID: ".concat(e.id));else{var n;if(!this.parentTransformId||(n=this._transforms[e.parentTransformId])){var t=new $f({id:e.id,model:this,parentTransform:n,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[t.id]=t,t}this.error("[createTransform] SceneModel.createTransform() config missing: id")}else this.error("[createTransform] SceneModel.createTransform() config missing: id")}},{key:"createMesh",value:function(e){if(void 0===e.id||null===e.id)return this.error("[createMesh] SceneModel.createMesh() config missing: id"),!1;if(this._scheduledMeshes[e.id])return this.error("[createMesh] SceneModel already has a mesh with this ID: ".concat(e.id)),!1;if(!(void 0!==e.geometryId)){if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"!==e.primitive&&"lines"!==e.primitive&&"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)return this.error("Unsupported value for 'primitive': '".concat(primitive,"' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.")),!1;if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)"),!1;if(e.positions&&(e.positionsDecodeMatrix||e.positionsDecodeBoundary))return this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)"),!1;if(!e.buckets&&!e.indices&&"points"!==e.primitive)return this.error("Param expected: indices (required for '".concat(e.primitive,"' primitive type)")),!1;if((e.matrix||e.position||e.rotation||e.scale)&&(e.positionsCompressed||e.positionsDecodeBoundary))return this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'"),!1;var n=!!this._dtxEnabled&&("triangles"===e.primitive||"solid"===e.primitive||"surface"===e.primitive);if(e.origin=e.origin?$.addVec3(this._origin,e.origin,$.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position){var t=e.scale||tp,i=e.position||ip,r=e.rotation||rp;$.eulerToQuaternion(r,"XYZ",lp),e.meshMatrix=$.composeMat4(i,lp,t,$.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=qa(e.positionsDecodeBoundary,$.mat4())),n){if(e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):dp,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){var l=$.vec3(),a=[];Be(e.positions,a,l)&&(e.positions=a,e.origin=$.addVec3(e.origin,l,l))}if(e.positions){var s=$.collapseAABB3();e.positionsDecodeMatrix=$.mat4(),$.expandAABB3Points3(s,e.positions),e.positionsCompressed=Xa(e.positions,s,e.positionsDecodeMatrix),e.aabb=s}else if(e.positionsCompressed){var u=$.collapseAABB3();$.expandAABB3Points3(u,e.positionsCompressed),Bt.decompressAABB(u,e.positionsDecodeMatrix),e.aabb=u}if(e.buckets){for(var o=$.collapseAABB3(),c=0,f=e.buckets.length;c<f;c++){var p=e.buckets[c];p.positions?$.expandAABB3Points3(o,p.positions):p.positionsCompressed&&$.expandAABB3Points3(o,p.positionsCompressed)}e.positionsDecodeMatrix&&Bt.decompressAABB(o,e.positionsDecodeMatrix),e.aabb=o}e.meshMatrix&&($.AABB3ToOBB3(e.aabb,np),$.transformOBB3(e.meshMatrix,np),$.OBB3ToAABB3(np,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=bt(e.positions,e.indices,null,2):e.edgeIndices=bt(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.buckets||(e.buckets=Ap(e,this._enableVertexWelding&&this._enableIndexBucketing))}else{if(e.type=1,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):[255,255,255],e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.metallic=void 0!==e.metallic&&null!==e.metallic?Math.floor(255*e.metallic):0,e.roughness=void 0!==e.roughness&&null!==e.roughness?Math.floor(255*e.roughness):255,e.positions){var d=[];Be(e.positions,d,ep)&&(e.positions=d,e.origin=$.addVec3(e.origin,ep,$.vec3()))}if(e.positions){var v=$.collapseAABB3();e.meshMatrix&&($.transformPositions3(e.meshMatrix,e.positions,e.positions),e.meshMatrix=null),$.expandAABB3Points3(v,e.positions),e.aabb=v}else{var A=$.collapseAABB3();$.expandAABB3Points3(A,e.positionsCompressed),Bt.decompressAABB(A,e.positionsDecodeMatrix),e.aabb=A}if(e.meshMatrix&&($.AABB3ToOBB3(e.aabb,np),$.transformOBB3(e.meshMatrix,np),$.OBB3ToAABB3(np,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=bt(e.positions,e.indices,null,2):e.edgeIndices=bt(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.textureSetId&&(e.textureSet=this._textureSets[e.textureSetId],!e.textureSet))return this.error("[createMesh] Texture set not found: ".concat(e.textureSetId," - ensure that you create it first with createTextureSet()")),!1}}else{if(e.positions||e.positionsCompressed||e.indices||e.edgeIndices||e.normals||e.normalsCompressed||e.uv||e.uvCompressed||e.positionsDecodeMatrix)return this.error("Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)"),!1;if(e.geometry=this._geometries[e.geometryId],!e.geometry)return this.error("[createMesh] Geometry not found: ".concat(e.geometryId," - ensure that you create it first with createGeometry()")),!1;if(e.origin=e.origin?$.addVec3(this._origin,e.origin,$.vec3()):this._origin,e.positionsDecodeMatrix=e.geometry.positionsDecodeMatrix,e.transformId){if(e.transform=this._transforms[e.transformId],!e.transform)return this.error("[createMesh] Transform not found: ".concat(e.transformId," - ensure that you create it first with createTransform()")),!1;e.aabb=e.geometry.aabb}else{if(e.matrix)e.meshMatrix=e.matrix.slice();else{var h=e.scale||tp,I=e.position||ip,y=e.rotation||rp;$.eulerToQuaternion(y,"XYZ",lp),e.meshMatrix=$.composeMat4(I,lp,h,$.mat4())}$.AABB3ToOBB3(e.geometry.aabb,np),$.transformOBB3(e.meshMatrix,np),e.aabb=$.OBB3ToAABB3(np,$.AABB3())}if(!!this._dtxEnabled&&("triangles"===e.geometry.primitive||"solid"===e.geometry.primitive||"surface"===e.geometry.primitive)){e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):dp,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255;var m=this._dtxBuckets[e.geometryId];m||(m=Ap(e.geometry,this._enableVertexWelding,this._enableIndexBucketing),this._dtxBuckets[e.geometryId]=m),e.buckets=m}else e.type=0,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):dp,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.metallic=void 0!==e.metallic&&null!==e.metallic?Math.floor(255*e.metallic):0,e.roughness=void 0!==e.roughness&&null!==e.roughness?Math.floor(255*e.roughness):255,e.textureSetId&&(e.textureSet=this._textureSets[e.textureSetId])}return e.numPrimitives=this._getNumPrimitives(e),this._meshesCfgsBeforeMeshCreation[e.id]=e,!0}},{key:"_createMesh",value:function(e){var n=new ea(this,e.id,e.color,e.opacity,e.transform,e.textureSet);n.pickId=this.scene._renderer.getPickID(n);var t=n.pickId,i=t>>24&255,r=t>>16&255,l=t>>8&255,a=255&t;switch(e.pickColor=new Uint8Array([a,l,r,i]),e.solid="solid"===e.primitive,n.origin=$.vec3(e.origin),e.type){case 2:n.layer=this._getDTXLayer(e),n.aabb=e.aabb;break;case 1:n.layer=this._getVBOBatchingLayer(e),n.aabb=e.aabb;break;case 0:n.layer=this._getVBOInstancingLayer(e),n.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),n.portionId=n.layer.createPortion(n,e),n}},{key:"_getNumPrimitives",value:function(e){var n=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(var t=0,i=e.buckets.length;t<i;t++)n+=e.buckets[t].indices.length;break;case 1:n+=e.indices.length;break;case 0:n+=e.geometry.indices.length}return Math.round(n/3);case"points":switch(e.type){case 2:for(var r=0,l=e.buckets.length;r<l;r++)n+=e.buckets[r].positionsCompressed.length;break;case 1:n+=e.positions?e.positions.length:e.positionsCompressed.length;break;case 0:var a=e.geometry;n+=a.positions?a.positions.length:a.positionsCompressed.length}return Math.round(n);case"lines":case"line-strip":switch(e.type){case 2:for(var s=0,u=e.buckets.length;s<u;s++)n+=e.buckets[s].indices.length;break;case 1:n+=e.indices.length;break;case 0:n+=e.geometry.indices.length}return Math.round(n/2)}return 0}},{key:"_getDTXLayer",value:function(e){var n=e.origin,t=e.geometry?e.geometry.primitive:e.primitive,i=".".concat(t,".").concat(Math.round(n[0]),".").concat(Math.round(n[1]),".").concat(Math.round(n[2])),r=this._dtxLayers[i];if(r){if(r.canCreatePortion(e))return r;r.finalize(),delete this._dtxLayers[i],r=null}switch(t){case"triangles":case"solid":case"surface":r=new Ef(this,{layerIndex:0,origin:n});break;case"lines":r=new Zo(this,{layerIndex:0,origin:n});break;default:return}return this._dtxLayers[i]=r,this.layerList.push(r),r}},{key:"_getVBOBatchingLayer",value:function(e){var n=this,t=e.origin,i=e.positionsDecodeMatrix||e.positionsDecodeBoundary?this._createHashStringFromMatrix(e.positionsDecodeMatrix||e.positionsDecodeBoundary):"-",r=e.textureSetId||"-",l="".concat(Math.round(t[0]),".").concat(Math.round(t[1]),".").concat(Math.round(t[2]),".").concat(e.primitive,".").concat(i,".").concat(r),a=this._vboBatchingLayers[l];if(a)return a;for(var s=e.textureSet;!a;){switch(e.primitive){case"triangles":case"solid":case"surface":a=new os({model:n,textureSet:s,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:t,maxGeometryBatchSize:this._maxGeometryBatchSize,solid:"solid"===e.primitive,autoNormals:!0});break;case"lines":a=new mu({model:n,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:t,maxGeometryBatchSize:this._maxGeometryBatchSize});break;case"points":a=new so({model:n,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:t,maxGeometryBatchSize:this._maxGeometryBatchSize})}var u=e.positionsCompressed?e.positionsCompressed.length:e.positions.length;("points"===e.primitive?a.canCreatePortion(u):a.canCreatePortion(u,e.indices.length))||(a.finalize(),delete this._vboBatchingLayers[l],a=null)}return this._vboBatchingLayers[l]=a,this.layerList.push(a),a}},{key:"_createHashStringFromMatrix",value:function(e){for(var n=e.join(""),t=0,i=0;i<n.length;i++){t=(t<<5)-t+n.charCodeAt(i),t|=0}return(t>>>0).toString(16)}},{key:"_getVBOInstancingLayer",value:function(e){var n=this,t=e.origin,i=e.textureSetId||"-",r=e.geometryId,l="".concat(Math.round(t[0]),".").concat(Math.round(t[1]),".").concat(Math.round(t[2]),".").concat(i,".").concat(r),a=this._vboInstancingLayers[l];if(a)return a;for(var s=e.textureSet,u=e.geometry;!a;)switch(u.primitive){case"triangles":case"surface":a=new eu({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0,solid:!1});break;case"solid":a=new eu({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0,solid:!0});break;case"lines":a=new Uu({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0});break;case"points":a=new Bo({model:n,textureSet:s,geometry:u,origin:t,layerIndex:0})}return this._vboInstancingLayers[l]=a,this.layerList.push(a),a}},{key:"createEntity",value:function(e){if(void 0===e.id?e.id=$.createUUID():this.scene.components[e.id]&&(this.error("Scene already has a Component with this ID: ".concat(e.id," - will assign random ID")),e.id=$.createUUID()),void 0!==e.meshIds){var n=0;this._visible&&!1!==e.visible&&(n|=Fe),this._pickable&&!1!==e.pickable&&(n|=He),this._culled&&!1!==e.culled&&(n|=xe),this._clippable&&!1!==e.clippable&&(n|=Ue),this._collidable&&!1!==e.collidable&&(n|=Ge),this._edges&&!1!==e.edges&&(n|=Qe),this._xrayed&&!1!==e.xrayed&&(n|=ke),this._highlighted&&!1!==e.highlighted&&(n|=Ve),this._selected&&!1!==e.selected&&(n|=je),e.flags=n,this._createEntity(e)}else this.error("Config missing: meshIds")}},{key:"_createEntity",value:function(e){for(var n=[],t=0,i=e.meshIds.length;t<i;t++){var r=e.meshIds[t],l=this._meshes[r];if(!l){var a=this._meshesCfgsBeforeMeshCreation[r];if(!a){this.error('Mesh with this ID not found: "'.concat(r,'" - ignoring this mesh'));continue}l=this._createMesh(a),this._meshes[e.id]=l}l.parent?this.error('Mesh with ID "'.concat(r,'" already belongs to object with ID "').concat(l.parent.id,'" - ignoring this mesh')):n.push(l)}var s=new Ye(this,e.isObject,e.id,n,e.flags,!0);this._entityList.push(s),this._entities[e.id]=s,this.numEntities++}},{key:"finalize",value:function(){if(!this.destroyed){for(var e=0,n=this.layerList.length;e<n;e++){this.layerList[e].finalize()}this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._dtxLayers={},this._vboInstancingLayers={},this._vboBatchingLayers={};for(var t=0,i=this._entityList.length;t<i;t++){this._entityList[t]._finalize()}for(var r=0,l=this._entityList.length;r<l;r++){this._entityList[r]._finalize2()}this.layerList.sort((function(e,n){return e.sortId<n.sortId?-1:e.sortId>n.sortId?1:0}));for(var a=0,s=this.layerList.length;a<s;a++){this.layerList[a].layerIndex=a}this.glRedraw(),this.scene._aabbDirty=!0,this._viewMatrixDirty=!0,this._matrixDirty=!0,this._aabbDirty=!0,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.position=this._position}}},{key:"stateSortCompare",value:function(e,n){}},{key:"rebuildRenderFlags",value:function(){this.renderFlags.reset(),this._updateRenderFlagsVisibleLayers(),this.renderFlags.numLayers>0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}},{key:"_updateRenderFlagsVisibleLayers",value:function(){var e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(var n=0,t=this.layerList.length;n<t;n++){var i=this.layerList[n];this._getActiveSectionPlanesForLayer(i)&&(e.visibleLayers[e.numVisibleLayers++]=n)}}},{key:"_getActiveSectionPlanesForLayer",value:function(e){var n=this.renderFlags,t=this.scene._sectionPlanesState.sectionPlanes,i=t.length,r=e.layerIndex*i;if(i>0)for(var l=0;l<i;l++){t[l].active?(n.sectionPlanesActivePerLayer[r+l]=!0,n.sectioned=!0):n.sectionPlanesActivePerLayer[r+l]=!1}return!0}},{key:"_updateRenderFlags",value:function(){if(0!==this.numVisibleLayerPortions&&this.numCulledLayerPortions!==this.numPortions){var e=this.renderFlags;if(e.colorOpaque=this.numTransparentLayerPortions<this.numPortions,this.numTransparentLayerPortions>0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){var n=this.scene.xrayMaterial._state;n.fill&&(n.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),n.edges&&(n.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0)this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions<this.numPortions,this.numTransparentLayerPortions>0&&(e.edgesTransparent=!0));if(this.numSelectedLayerPortions>0){var t=this.scene.selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){var i=this.scene.highlightMaterial._state;i.fill&&(i.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),i.edges&&(i.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}},{key:"drawColorOpaque",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawColorOpaque(n,e)}}},{key:"drawColorTransparent",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawColorTransparent(n,e)}}},{key:"drawDepth",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawDepth(n,e)}}},{key:"drawNormals",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawNormals(n,e)}}},{key:"drawSilhouetteXRayed",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawSilhouetteXRayed(n,e)}}},{key:"drawSilhouetteHighlighted",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawSilhouetteHighlighted(n,e)}}},{key:"drawSilhouetteSelected",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawSilhouetteSelected(n,e)}}},{key:"drawEdgesColorOpaque",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesColorOpaque(n,e)}}},{key:"drawEdgesColorTransparent",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesColorTransparent(n,e)}}},{key:"drawEdgesXRayed",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesXRayed(n,e)}}},{key:"drawEdgesHighlighted",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesHighlighted(n,e)}}},{key:"drawEdgesSelected",value:function(e){for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawEdgesSelected(n,e)}}},{key:"drawOcclusion",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawOcclusion(n,e)}}},{key:"drawShadow",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawShadow(n,e)}}},{key:"setPickMatrices",value:function(e,n){if(0!==this._numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var l=t.visibleLayers[i],a=this.layerList[l];a.setPickMatrices&&a.setPickMatrices(e,n)}}},{key:"drawPickMesh",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawPickMesh(n,e)}}},{key:"drawPickDepths",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawPickDepths(n,e)}}},{key:"drawPickNormals",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t];this.layerList[r].drawPickNormals(n,e)}}},{key:"drawSnapInit",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t],l=this.layerList[r];l.drawSnapInit&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,l.drawSnapInit(n,e),e.snapPickLayerParams[e.snapPickLayerNumber]={origin:e.snapPickOrigin.slice(),coordinateScale:e.snapPickCoordinateScale.slice()})}}},{key:"drawSnap",value:function(e){if(0!==this.numVisibleLayerPortions)for(var n=this.renderFlags,t=0,i=n.visibleLayers.length;t<i;t++){var r=n.visibleLayers[t],l=this.layerList[r];l.drawSnap&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,l.drawSnap(n,e),e.snapPickLayerParams[e.snapPickLayerNumber]={origin:e.snapPickOrigin.slice(),coordinateScale:e.snapPickCoordinateScale.slice()})}}},{key:"destroy",value:function(){for(var e in this._vboBatchingLayers)this._vboBatchingLayers.hasOwnProperty(e)&&this._vboBatchingLayers[e].destroy();for(var t in this._vboBatchingLayers={},this._vboInstancingLayers)this._vboInstancingLayers.hasOwnProperty(t)&&this._vboInstancingLayers[t].destroy();this._vboInstancingLayers={},this.scene.camera.off(this._onCameraViewMatrix),this.scene.off(this._onTick);for(var i=0,r=this.layerList.length;i<r;i++)this.layerList[i].destroy();this.layerList=[];for(var l=0,a=this._entityList.length;l<a;l++)this._entityList[l]._destroy();this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._meshes={},this._entities={},this.scene._aabbDirty=!0,this._isModel&&this.scene._deregisterModel(this),0!==ta&&0==--ta&&na._clear(),I(y(n.prototype),"destroy",this).call(this)}}])}();function Ap(e,n,t){var i,r,l,a;if(n||t){var s=f(Uf({positionsCompressed:e.positionsCompressed,indices:e.indices,edgeIndices:e.edgeIndices}),3);i=s[0],r=s[1],l=s[2]}else i=e.positionsCompressed,r=e.indices,l=e.edgeIndices;t?a=Wf({positionsCompressed:i,indices:r,edgeIndices:l},i.length/3>65536?16:8):a=[{positionsCompressed:i,indices:r,edgeIndices:l}];return a}var hp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(T(this,n),(t=v(this,n,[e,i]))._positions=i.positions||[],i.indices)t._indices=i.indices;else{t._indices=[];for(var r=0,l=t._positions.length/3-1;r<l;r+=2)t._indices.push(r),t._indices.push(r+1)}return t._sceneModel=new vp(t,{isModel:!1}),t._sceneModel.createMesh({id:"linesMesh",primitive:"lines",positions:t._positions,indices:t._indices}),t._sceneModel.createEntity({meshIds:["linesMesh"],visible:i.visible,clippable:i.clippable,collidable:i.collidable}),t._sceneModel.finalize(),t.scene._lineSetCreated(t),t}return m(n,me),C(n,[{key:"visible",get:function(){return this._sceneModel.visible},set:function(e){this._sceneModel.visible=e}},{key:"positions",get:function(){return this._positions}},{key:"indices",get:function(){return this._indices}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene._lineSetDestroyed(this)}}])}(),Ip=$.vec3(),yp=$.vec3(),mp=$.vec3(),wp=$.vec3(),gp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,["BCFViewpoints",e,i])).originatingSystem=i.originatingSystem||"xeokit.io",t.authoringTool=i.authoringTool||"xeokit.io",t}return m(n,_e),C(n,[{key:"getViewpoint",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.viewer.scene,i=t.camera,r=t.realWorldOffset,l=!0===n.reverseClippingPlanes,a={},s=$.normalizeVec3($.subVec3(i.look,i.eye,$.vec3())),u=i.eye,o=i.up;i.yUp&&(s=bp(s),u=bp(u),o=bp(o));var c=Ep($.addVec3(u,r));"ortho"===i.projection?a.orthogonal_camera={camera_view_point:c,camera_direction:Ep(s),camera_up_vector:Ep(o),view_to_world_scale:i.ortho.scale}:a.perspective_camera={camera_view_point:c,camera_direction:Ep(s),camera_up_vector:Ep(o),field_of_view:i.perspective.fov};var p=t.sectionPlanes;for(var d in p)if(p.hasOwnProperty(d)){var v=p[d];if(!v.active)continue;var A=v.pos,h=void 0;h=l?$.negateVec3(v.dir,$.vec3()):v.dir,i.yUp&&(A=bp(A),h=bp(h)),$.addVec3(A,r),A=Ep(A),h=Ep(h),a.clipping_planes||(a.clipping_planes=[]),a.clipping_planes.push({location:A,direction:h})}var I=t.lineSets;for(var y in I)if(I.hasOwnProperty(y)){var m=I[y];a.lines||(a.lines=[]);for(var w=m.positions,g=m.indices,E=0,T=g.length/2;E<T;E++){var b=g[2*E],C=g[2*E+1];a.lines.push({start_point:{x:w[3*b+0],y:w[3*b+1],z:w[3*b+2]},end_point:{x:w[3*C+0],y:w[3*C+1],z:w[3*C+2]}})}}var D=t.bitmaps;for(var R in D)if(D.hasOwnProperty(R)){var P=D[R],_=P.pos,O=P.normal,S=P.up;i.yUp&&(_=bp(_),O=bp(O),S=bp(S)),$.addVec3(_,r),a.bitmaps||(a.bitmaps=[]),a.bitmaps.push({bitmap_type:P.type,bitmap_data:P.imageData,location:Ep(_),normal:Ep(O),up:Ep(S),height:P.height})}a.components={visibility:{view_setup_hints:{spaces_visible:!!n.spacesVisible,space_boundaries_visible:!!n.spaceBoundariesVisible,openings_visible:!!n.openingsVisible,spaces_translucent:!!n.spaces_translucent,space_boundaries_translucent:!!n.space_boundaries_translucent,openings_translucent:!!n.openings_translucent}}};var N=new Set(t.opacityObjectIds),B=new Set(t.xrayedObjectIds),L=new Set(t.colorizedObjectIds),M=Object.values(t.objects).filter((function(e){return N.has(e.id)||L.has(e.id)||B.has(e.id)})).reduce((function(n,i){var r,l=function(e){var n="";return n+=Math.round(255*e[0]).toString(16).padStart(2,"0"),n+=Math.round(255*e[1]).toString(16).padStart(2,"0"),n+=Math.round(255*e[2]).toString(16).padStart(2,"0"),n}(i.colorize);i.xrayed?(r=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,l=(r=Math.round(255*r).toString(16).padStart(2,"0"))+l):N.has(i.id)&&(l=(r=Math.round(255*i.opacity).toString(16).padStart(2,"0"))+l),n[l]||(n[l]=[]);var a=i.id,s=i.originalSystemId,u={ifc_guid:s,originating_system:e.originatingSystem};return s!==a&&(u.authoring_tool_id=a),n[l].push(u),n}),{}),F=Object.entries(M).map((function(e){var n=f(e,2);return{color:n[0],components:n[1]}}));a.components.coloring=F;var x=t.objectIds,H=t.visibleObjects,U=t.visibleObjectIds,G=x.filter((function(e){return!H[e]})),k=t.selectedObjectIds;return n.defaultInvisible||U.length<G.length?(a.components.visibility.exceptions=this._createBCFComponents(U),a.components.visibility.default_visibility=!1):(a.components.visibility.exceptions=this._createBCFComponents(G),a.components.visibility.default_visibility=!0),a.components.selection=this._createBCFComponents(k),a.components.translucency=this._createBCFComponents(t.xrayedObjectIds),!1!==n.snapshot&&(a.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})}),a}},{key:"_createBCFComponents",value:function(e){for(var n=this.viewer.scene,t=[],i=0,r=e.length;i<r;i++){var l=e[i],a=n.objects[l];if(a){var s={ifc_guid:a.originalSystemId,originating_system:this.originatingSystem};a.originalSystemId!==l&&(s.authoring_tool_id=l),t.push(s)}}return t}},{key:"setViewpoint",value:function(e){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var i=this.viewer,r=i.scene,l=r.camera,a=!1!==t.rayCast,s=!1!==t.immediate,u=!1!==t.reset,o=r.realWorldOffset,c=!0===t.reverseClippingPlanes;if(r.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){var n=Tp(e.location,Ip),t=Tp(e.direction,Ip);c&&$.negateVec3(t),$.subVec3(n,o),l.yUp&&(n=Cp(n),t=Cp(t)),new pl(r,{pos:n,dir:t})})),r.clearLines(),e.lines&&e.lines.length>0){var f=[],p=[],d=0;e.lines.forEach((function(e){e.start_point&&e.end_point&&(f.push(e.start_point.x),f.push(e.start_point.y),f.push(e.start_point.z),f.push(e.end_point.x),f.push(e.end_point.y),f.push(e.end_point.z),p.push(d++),p.push(d++))})),new hp(r,{positions:f,indices:p,clippable:!1,collidable:!0})}if(r.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){var n=e.bitmap_type||"jpg",t=e.bitmap_data,i=Tp(e.location,yp),a=Tp(e.normal,mp),s=Tp(e.up,wp),u=e.height||1;n&&t&&i&&a&&s&&(l.yUp&&(i=Cp(i),a=Cp(a),s=Cp(s)),new ql(r,{src:t,type:n,pos:i,normal:a,up:s,clippable:!1,collidable:!0,height:u}))})),u&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),r.setObjectsHighlighted(r.highlightedObjectIds,!1),r.setObjectsSelected(r.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(r.setObjectsVisible(r.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.visible=!1}))}))):(r.setObjectsVisible(r.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.visible=!0}))})));var v=e.components.visibility.view_setup_hints;v&&(!1===v.spaces_visible&&r.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==v.spaces_translucent&&r.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),v.space_boundaries_visible,!1===v.openings_visible&&r.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),v.space_boundaries_translucent,void 0!==v.openings_translucent&&r.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(r.setObjectsSelected(r.selectedObjectIds,!1),e.components.selection.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.selected=!0}))}))),e.components.translucency&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),e.components.translucency.forEach((function(e){return n._withBCFComponent(t,e,(function(e){return e.xrayed=!0}))}))),e.components.coloring&&e.components.coloring.forEach((function(e){var i=e.color,r=0,l=!1;8===i.length&&((r=parseInt(i.substring(0,2),16)/256)<=1&&r>=.95&&(r=1),i=i.substring(2),l=!0);var a=[parseInt(i.substring(0,2),16)/256,parseInt(i.substring(2,4),16)/256,parseInt(i.substring(4,6),16)/256];e.components.map((function(e){return n._withBCFComponent(t,e,(function(e){e.colorize=a,l&&(e.opacity=r)}))}))}))}if(e.perspective_camera||e.orthogonal_camera){var A,h,I,y;if(e.perspective_camera?(A=Tp(e.perspective_camera.camera_view_point,Ip),h=Tp(e.perspective_camera.camera_direction,Ip),I=Tp(e.perspective_camera.camera_up_vector,Ip),l.perspective.fov=e.perspective_camera.field_of_view,y="perspective"):(A=Tp(e.orthogonal_camera.camera_view_point,Ip),h=Tp(e.orthogonal_camera.camera_direction,Ip),I=Tp(e.orthogonal_camera.camera_up_vector,Ip),l.ortho.scale=e.orthogonal_camera.view_to_world_scale,y="ortho"),$.subVec3(A,o),l.yUp&&(A=Cp(A),h=Cp(h),I=Cp(I)),a){var m=r.pick({pickSurface:!0,origin:A,direction:h});h=m?m.worldPos:$.addVec3(A,h,Ip)}else h=$.addVec3(A,h,Ip);s?(l.eye=A,l.look=h,l.up=I,l.projection=y):i.cameraFlight.flyTo({eye:A,look:h,up:I,duration:t.duration,projection:y})}}}},{key:"_withBCFComponent",value:function(e,n,t){var i=this.viewer,r=i.scene;if(n.authoring_tool_id&&n.originating_system===this.originatingSystem){var l=n.authoring_tool_id,a=r.objects[l];if(a)return void t(a);if(e.updateCompositeObjects)if(i.metaScene.metaObjects[l])return void r.withObjects(i.metaScene.getObjectIDsInSubtree(l),t)}if(n.ifc_guid){var s=n.ifc_guid,u=r.objects[s];if(u)return void t(u);if(e.updateCompositeObjects)if(i.metaScene.metaObjects[s])return void r.withObjects(i.metaScene.getObjectIDsInSubtree(s),t);Object.keys(r.models).forEach((function(n){var l=$.globalizeObjectId(n,s),a=r.objects[l];a?t(a):e.updateCompositeObjects&&i.metaScene.metaObjects[l]&&r.withObjects(i.metaScene.getObjectIDsInSubtree(l),t)}))}}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this)}}])}();function Ep(e){return{x:e[0],y:e[1],z:e[2]}}function Tp(e,n){return(n=new Float64Array(3))[0]=e.x,n[1]=e.y,n[2]=e.z,n}function bp(e){return new Float64Array([e[0],-e[2],e[1]])}function Cp(e){return new Float64Array([e[0],e[2],-e[1]])}var Dp=$.vec3(),Rp=function(e,n,t,i){var r=e-t,l=n-i;return Math.sqrt(r*r+l*l)},Pp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(T(this,n),(t=v(this,n,[e.viewer.scene,i])).plugin=e,t._container=i.container,!t._container)throw"config missing: container";t._eventSubs={},t._color=i.color?i.color:e.defaultColor,t._borderColor=e.defaultColor?e.defaultColor:"white";var r=t.plugin.viewer.scene;t._originMarker=new qe(r,i.origin),t._targetMarker=new qe(r,i.target),t._originWorld=$.vec3(),t._targetWorld=$.vec3(),t._wp=new Float64Array(24),t._vp=new Float64Array(24),t._pp=new Float64Array(24),t._cp=new Float64Array(8),t._xAxisLabelCulled=!1,t._yAxisLabelCulled=!1,t._zAxisLabelCulled=!1;var l=i.onMouseOver?function(e){i.onMouseOver(e,t),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,a=i.onMouseLeave?function(e){i.onMouseLeave(e,t),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,s=i.onMouseClick?function(e){i.onMouseClick(e,t),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("click",e))}:null,u=i.onTouchStart?function(e){i.onTouchStart(e,t),e.preventDefault(),t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("touchstart",e))}:null,o=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},c=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},f=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},p=i.onContextMenu?function(e){i.onContextMenu(e,t)}:null,d=function(e){t.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};return t._originDot=new Ze(t._container,{fillColor:t._color,borderColor:t._borderColor,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._targetDot=new Ze(t._container,{fillColor:t._color,borderColor:t._borderColor,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._lengthWire=new Je(t._container,{color:t._color,thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._lengthLabel=new $e(t._container,{fillColor:t._color||"#0065FC",prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._xAxisWire=new Je(t._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._yAxisWire=new Je(t._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._zAxisWire=new Je(t._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._xAxisLabel=new $e(t._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._yAxisLabel=new $e(t._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._zAxisLabel=new $e(t._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:l,onMouseLeave:a,onMouseWheel:d,onMouseDown:o,onMouseClick:s,onTouchStart:u,onMouseUp:c,onMouseMove:f,onContextMenu:p}),t._wpDirty=!1,t._vpDirty=!1,t._cpDirty=!1,t._sectionPlanesDirty=!0,t._visible=!1,t._originVisible=!1,t._targetVisible=!1,t._wireVisible=!1,t._axisVisible=!1,t._xAxisVisible=!1,t._yAxisVisible=!1,t._zAxisVisible=!1,t._axisEnabled=!0,t._labelsVisible=!1,t._labelsOnWires=!1,t._clickable=!1,t._originMarker.on("worldPos",(function(e){t._originWorld.set(e||[0,0,0]),t._wpDirty=!0,t._needUpdate(0)})),t._targetMarker.on("worldPos",(function(e){t._targetWorld.set(e||[0,0,0]),t._wpDirty=!0,t._needUpdate(0)})),t._onViewMatrix=r.camera.on("viewMatrix",(function(){t._vpDirty=!0,t._needUpdate(0)})),t._onProjMatrix=r.camera.on("projMatrix",(function(){t._cpDirty=!0,t._needUpdate()})),t._onCanvasBoundary=r.canvas.on("boundary",(function(){t._cpDirty=!0,t._needUpdate(0)})),t._onMetricsUnits=r.metrics.on("units",(function(){t._cpDirty=!0,t._needUpdate()})),t._onMetricsScale=r.metrics.on("scale",(function(){t._cpDirty=!0,t._needUpdate()})),t._onMetricsOrigin=r.metrics.on("origin",(function(){t._cpDirty=!0,t._needUpdate()})),t._onSectionPlaneUpdated=r.on("sectionPlaneUpdated",(function(){t._sectionPlanesDirty=!0,t._needUpdate()})),t.precision=void 0!==i.precision?i.precision:2,t.approximate=void 0===i.approximate||i.approximate,t.visible=i.visible,t.originVisible=i.originVisible,t.targetVisible=i.targetVisible,t.wireVisible=i.wireVisible,t.axisVisible=i.axisVisible,t.xAxisVisible=i.xAxisVisible,t.yAxisVisible=i.yAxisVisible,t.zAxisVisible=i.zAxisVisible,t.labelsVisible=i.labelsVisible,t.labelsOnWires=i.labelsOnWires,t}return m(n,me),C(n,[{key:"_update",value:function(){if(this._visible){var e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&($.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}var n=this._originMarker.viewPos[2],t=this._targetMarker.viewPos[2];if(n>-.3||t>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){$.transformPositions4(e.camera.project.matrix,this._vp,this._pp);for(var i=this._pp,r=this._cp,l=e.canvas.canvas.getBoundingClientRect(),a=this._container.getBoundingClientRect(),s=l.top-a.top,u=l.left-a.left,o=e.canvas.boundary,c=o[2],f=o[3],p=0,d=this.plugin.viewer.scene.metrics,v=d.scale,A=d.units,h=d.unitsInfo[A].abbrev,I=0,y=i.length;I<y;I+=4)r[p]=u+Math.floor((1+i[I+0]/i[I+3])*c/2),r[p+1]=s+Math.floor((1-i[I+1]/i[I+3])*f/2),p+=2;if(this._originDot.setPos(r[0],r[1]),this._targetDot.setPos(r[6],r[7]),this._lengthWire.setStartAndEnd(r[0],r[1],r[6],r[7]),this._xAxisWire.setStartAndEnd(r[0],r[1],r[2],r[3]),this._yAxisWire.setStartAndEnd(r[2],r[3],r[4],r[5]),this._zAxisWire.setStartAndEnd(r[4],r[5],r[6],r[7]),this.labelsVisible){if(this._lengthLabel.setPosOnWire(r[0],r[1],r[6],r[7]),this.labelsOnWires)this._xAxisLabel.setPosOnWire(r[0],r[1],r[2],r[3]),this._yAxisLabel.setPosOnWire(r[2],r[3],r[4],r[5]),this._zAxisLabel.setPosOnWire(r[4],r[5],r[6],r[7]);else{var m=35;this._xAxisLabel.setPosOnWire(r[0],r[1]+m,r[6],r[7]+m),m+=35,this._yAxisLabel.setPosOnWire(r[0],r[1]+m,r[6],r[7]+m),m+=35,this._zAxisLabel.setPosOnWire(r[0],r[1]+m,r[6],r[7]+m)}var w=this._approximate?" ":" = ";this._length=Math.abs($.lenVec3($.subVec3(this._targetWorld,this._originWorld,Dp))),this._lengthLabel.setText(w+(this._length*v).toFixed(this._precision)+h);var g=Math.abs(Rp(r[0],r[1],r[2],r[3])),E=Math.abs(Rp(r[2],r[3],r[4],r[5])),T=Math.abs(Rp(r[4],r[5],r[6],r[7])),b=this.plugin.labelMinAxisLength;this.labelsOnWires?(this._xAxisLabelCulled=g<b,this._yAxisLabelCulled=E<b,this._zAxisLabelCulled=T<b):(this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1),this._xAxisLabelCulled?this._xAxisLabel.setCulled(!0):(this._xAxisLabel.setText(w+Math.abs((this._targetWorld[0]-this._originWorld[0])*v).toFixed(this._precision)+h),this._xAxisLabel.setCulled(!this.axisVisible)),this._yAxisLabelCulled?this._yAxisLabel.setCulled(!0):(this._yAxisLabel.setText(w+Math.abs((this._targetWorld[1]-this._originWorld[1])*v).toFixed(this._precision)+h),this._yAxisLabel.setCulled(!this.axisVisible)),this._zAxisLabelCulled?this._zAxisLabel.setCulled(!0):(this._zAxisLabel.setText(w+Math.abs((this._targetWorld[2]-this._originWorld[2])*v).toFixed(this._precision)+h),this._zAxisLabel.setCulled(!this.axisVisible))}else this._lengthLabel.setCulled(!0),this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0);this._originDot.setVisible(this._visible&&this._originVisible),this._targetDot.setVisible(this._visible&&this._targetVisible),this._xAxisWire.setVisible(this.axisVisible&&this.xAxisVisible),this._yAxisWire.setVisible(this.axisVisible&&this.yAxisVisible),this._zAxisWire.setVisible(this.axisVisible&&this.zAxisVisible),this._lengthWire.setVisible(this.wireVisible),this._lengthLabel.setCulled(!this.wireVisible),this._cpDirty=!1}}}},{key:"_isSliced",value:function(e){for(var n=this.scene._sectionPlanesState.sectionPlanes,t=0,i=n.length;t<i;t++){var r=n[t];if($.planeClipsPositions3(r.pos,r.dir,e,4))return!0}return!1}},{key:"approximate",get:function(){return this._approximate},set:function(e){e=!1!==e,this._approximate!==e&&(this._approximate=e,this._cpDirty=!0,this._needUpdate(0))}},{key:"precision",get:function(){return this._precision},set:function(e){this._precision!==e&&(this._precision=e,this._cpDirty=!0,this._needUpdate(0))}},{key:"origin",get:function(){return this._originMarker}},{key:"target",get:function(){return this._targetMarker}},{key:"length",get:function(){this._update();var e=this.plugin.viewer.scene.metrics.scale;return this._length*e}},{key:"color",get:function(){return this._color},set:function(e){this._color=e,this._originDot.setFillColor(e),this._targetDot.setFillColor(e),this._lengthWire.setColor(e||"#0065FC"),this._lengthLabel.setFillColor(e||"#0065FC")}},{key:"visible",get:function(){return this._visible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultVisible,this._visible=e,this._originDot.setVisible(this._visible&&this._originVisible),this._targetDot.setVisible(this._visible&&this._targetVisible),this._lengthWire.setVisible(this._visible&&this._wireVisible),this._lengthLabel.setVisible(this._visible&&this._wireVisible);var n=this._visible&&this._axisVisible&&this._xAxisVisible,t=this._visible&&this._axisVisible&&this._yAxisVisible,i=this._visible&&this._axisVisible&&this._zAxisVisible;this._xAxisWire.setVisible(n),this._yAxisWire.setVisible(t),this._zAxisWire.setVisible(i),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled),this._zAxisLabel.setVisible(i&&!this._zAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"originVisible",get:function(){return this._originVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultOriginVisible,this._originVisible=e,this._originDot.setVisible(this._visible&&this._originVisible)}},{key:"targetVisible",get:function(){return this._targetVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultTargetVisible,this._targetVisible=e,this._targetDot.setVisible(this._visible&&this._targetVisible)}},{key:"axisEnabled",get:function(){return this._axisEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._axisEnabled=e;var n=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(n&&this._xAxisVisible),this._yAxisWire.setVisible(n&&this._yAxisVisible),this._zAxisWire.setVisible(n&&this._zAxisVisible),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled&&this._xAxisVisible),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled&&this._xAxisVisible),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled&&this._xAxisVisible),this._cpDirty=!0,this._needUpdate()}},{key:"axisVisible",get:function(){return this._axisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._axisVisible=e;var n=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(n&&this._xAxisVisible),this._yAxisWire.setVisible(n&&this._yAxisVisible),this._zAxisWire.setVisible(n&&this._zAxisVisible),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled&&this._xAxisVisible),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled&&this._yAxisVisible),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled&&this._zAxisVisible),this._cpDirty=!0,this._needUpdate()}},{key:"xAxisVisible",get:function(){return this._xAxisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._xAxisVisible=e;var n=this._visible&&this._axisVisible&&this._xAxisVisible&&this._axisEnabled;this._xAxisWire.setVisible(n),this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"yAxisVisible",get:function(){return this._yAxisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._yAxisVisible=e;var n=this._visible&&this._axisVisible&&this._yAxisVisible&&this._axisEnabled;this._yAxisWire.setVisible(n),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"zAxisVisible",get:function(){return this._zAxisVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultAxisVisible,this._zAxisVisible=e;var n=this._visible&&this._axisVisible&&this._zAxisVisible&&this._axisEnabled;this._zAxisWire.setVisible(n),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled),this._cpDirty=!0,this._needUpdate()}},{key:"wireVisible",get:function(){return this._wireVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultWireVisible,this._wireVisible=e;var n=this._visible&&this._wireVisible;this._lengthLabel.setVisible(n),this._lengthWire.setVisible(n)}},{key:"labelsVisible",get:function(){return this._labelsVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLabelsVisible,this._labelsVisible=e;var n=this._visible&&this._labelsVisible;this._xAxisLabel.setVisible(n&&!this._xAxisLabelCulled&&this._clickable&&this._axisEnabled),this._yAxisLabel.setVisible(n&&!this._yAxisLabelCulled&&this._clickable&&this._axisEnabled),this._zAxisLabel.setVisible(n&&!this._zAxisLabelCulled&&this._clickable&&this._axisEnabled),this._lengthLabel.setVisible(n),this._cpDirty=!0,this._needUpdate()}},{key:"labelsOnWires",get:function(){return this._labelsOnWires},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLabelsOnWires,this._labelsOnWires=e}},{key:"setHighlighted",value:function(e){this._originDot.setHighlighted(e),this._targetDot.setHighlighted(e),this._xAxisWire.setHighlighted(e),this._yAxisWire.setHighlighted(e),this._zAxisWire.setHighlighted(e),this._xAxisLabel.setHighlighted(e),this._yAxisLabel.setHighlighted(e),this._zAxisLabel.setHighlighted(e),this._lengthWire.setHighlighted(e),this._lengthLabel.setHighlighted(e)}},{key:"clickable",get:function(){return this._clickable},set:function(e){e=!!e,this._clickable=e,this._originDot.setClickable(this._clickable),this._targetDot.setClickable(this._clickable),this._xAxisWire.setClickable(this._clickable),this._yAxisWire.setClickable(this._clickable),this._zAxisWire.setClickable(this._clickable),this._lengthWire.setClickable(this._clickable),this._xAxisLabel.setClickable(this._clickable),this._yAxisLabel.setClickable(this._clickable),this._zAxisLabel.setClickable(this._clickable),this._lengthLabel.setClickable(this._clickable)}},{key:"destroy",value:function(){var e=this.plugin.viewer.scene,t=e.metrics;this._onViewMatrix&&e.camera.off(this._onViewMatrix),this._onProjMatrix&&e.camera.off(this._onProjMatrix),this._onCanvasBoundary&&e.canvas.off(this._onCanvasBoundary),this._onMetricsUnits&&t.off(this._onMetricsUnits),this._onMetricsScale&&t.off(this._onMetricsScale),this._onMetricsOrigin&&t.off(this._onMetricsOrigin),this._onSectionPlaneUpdated&&e.off(this._onSectionPlaneUpdated),this._originDot.destroy(),this._targetDot.destroy(),this._xAxisWire.destroy(),this._yAxisWire.destroy(),this._zAxisWire.destroy(),this._lengthLabel.destroy(),this._xAxisLabel.destroy(),this._yAxisLabel.destroy(),this._zAxisLabel.destroy(),this._lengthWire.destroy(),I(y(n.prototype),"destroy",this).call(this)}}])}(),_p=function(e){function n(){return T(this,n),v(this,n,arguments)}return m(n,me),C(n,[{key:"active",get:function(){}},{key:"snapping",get:function(){return!0},set:function(e){}},{key:"activate",value:function(){}},{key:"deactivate",value:function(){}},{key:"reset",value:function(){}},{key:"destroy",value:function(){}}])}(),Op=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e.viewer.scene])).cfg=i,t.pointerLens=i.pointerLens,t._active=!1,t._currentDistanceMeasurement=null,t._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},t._initMarkerDiv(),t._onCameraControlHoverSnapOrSurface=null,t._onCameraControlHoverSnapOrSurfaceOff=null,t._onMouseDown=null,t._onMouseUp=null,t._onCanvasTouchStart=null,t._onCanvasTouchEnd=null,t._snapping=!1!==i.snapping,t._mouseState=0,t._attachPlugin(e,i),t._offsetX=0|i._offsetX,t._offsetY=0|i._offsetY,t}return m(n,_p),C(n,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myDistancePivotMarker");var n=this.scene.canvas.canvas;n.parentNode.insertBefore(e,n),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.margin="-200px -200px",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){this._markerDiv&&(this._markerDiv.parentNode.removeChild(this._markerDiv),this._markerDiv=null)}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"offsetX",get:function(){return this._offsetX},set:function(e){this._offsetX=e}},{key:"offsetY",get:function(){return this._offsetY},set:function(e){this._offsetY=e}},{key:"active",get:function(){return this._active}},{key:"snapping",get:function(){return this._snapping},set:function(e){e!==this._snapping?(this._snapping=e,this.deactivate(),this.activate()):this._snapping=e}},{key:"activate",value:function(){var e=this;if(!this._active){this._markerDiv||this._initMarkerDiv(),this.fire("activated",!0);var n=this.distanceMeasurementsPlugin,t=!1;n.on("mouseOver",(function(e){t=!0})),n.on("mouseLeave",(function(e){t=!1})),n.on("measureDelete",(function(e){t=!1}));var i=this.scene,r=n.viewer.cameraControl,l=i.canvas.canvas;i.input;var a,s,u=!1,o=$.vec3(),c=$.vec2(),f=null;this._mouseState=0,this._onCameraControlHoverSnapOrSurface=r.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(function(n){if(!t){var i=n.snappedCanvasPos||n.canvasPos;if(u=!0,o.set(n.worldPos),c.set(n.canvasPos),0===e._mouseState){l.getBoundingClientRect();var r=window.pageXOffset||document.documentElement.scrollLeft,a=window.pageYOffset||document.documentElement.scrollTop;e._markerDiv.style.marginLeft="".concat(e._offsetX+r+i[0]-5,"px"),e._markerDiv.style.marginTop="".concat(e._offsetY+a+i[1]-5,"px"),e._markerDiv.style.background="pink",n.snappedToVertex||n.snappedToEdge?(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=n.canvasPos,e.pointerLens.snappedCanvasPos=n.snappedCanvasPos||n.canvasPos,e.pointerLens.snapped=!0),e._markerDiv.style.background="greenyellow",e._markerDiv.style.border="2px solid green"):(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=n.canvasPos,e.pointerLens.snappedCanvasPos=n.canvasPos,e.pointerLens.snapped=!1),e._markerDiv.style.background="pink",e._markerDiv.style.border="2px solid red"),f=n.entity}else e._markerDiv.style.marginLeft="-10000px",e._markerDiv.style.marginTop="-10000px";l.style.cursor="pointer",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=e._currentDistanceMeasurementInitState.wireVisible,e._currentDistanceMeasurement.axisVisible=e._currentDistanceMeasurementInitState.axisVisible&&e.distanceMeasurementsPlugin.defaultAxisVisible,e._currentDistanceMeasurement.xAxisVisible=e._currentDistanceMeasurementInitState.xAxisVisible&&e.distanceMeasurementsPlugin.defaultXAxisVisible,e._currentDistanceMeasurement.yAxisVisible=e._currentDistanceMeasurementInitState.yAxisVisible&&e.distanceMeasurementsPlugin.defaultYAxisVisible,e._currentDistanceMeasurement.zAxisVisible=e._currentDistanceMeasurementInitState.zAxisVisible&&e.distanceMeasurementsPlugin.defaultZAxisVisible,e._currentDistanceMeasurement.targetVisible=e._currentDistanceMeasurementInitState.targetVisible,e._currentDistanceMeasurement.target.worldPos=o.slice(),e._markerDiv.style.marginLeft="-10000px",e._markerDiv.style.marginTop="-10000px")}})),l.addEventListener("mousedown",this._onMouseDown=function(e){1===e.which&&(a=e.clientX,s=e.clientY)}),l.addEventListener("mouseup",this._onMouseUp=function(i){t||1===i.which&&(i.clientX>a+20||i.clientX<a-20||i.clientY>s+20||i.clientY<s-20||(e._currentDistanceMeasurement?u?(e._currentDistanceMeasurement.target.entity=f,f=null,e._currentDistanceMeasurement.clickable=!0,e.distanceMeasurementsPlugin.fire("measurementEnd",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null):(e._currentDistanceMeasurement.destroy(),e.distanceMeasurementsPlugin.fire("measurementCancel",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null,f=null):u&&(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:o.slice()},target:{worldPos:o.slice()},precision:n.precision,approximate:!0}),e._currentDistanceMeasurementInitState.axisVisible=e._currentDistanceMeasurement.axisVisible&&e.distanceMeasurementsPlugin.defaultAxisVisible,e._currentDistanceMeasurementInitState.xAxisVisible=e._currentDistanceMeasurement.xAxisVisible&&e.distanceMeasurementsPlugin.defaultXAxisVisible,e._currentDistanceMeasurementInitState.yAxisVisible=e._currentDistanceMeasurement.yAxisVisible&&e.distanceMeasurementsPlugin.defaultYAxisVisible,e._currentDistanceMeasurementInitState.zAxisVisible=e._currentDistanceMeasurement.zAxisVisible&&e.distanceMeasurementsPlugin.defaultZAxisVisible,e._currentDistanceMeasurementInitState.wireVisible=e._currentDistanceMeasurement.wireVisible,e._currentDistanceMeasurementInitState.targetVisible=e._currentDistanceMeasurement.targetVisible,e._currentDistanceMeasurement.clickable=!1,e._currentDistanceMeasurement.origin.entity=f,f=null,e.fire("measurementStart",e._currentDistanceMeasurement))))}),this._onCameraControlHoverSnapOrSurfaceOff=r.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",(function(n){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=n.canvasPos,e.pointerLens.snappedCanvasPos=n.snappedCanvasPos||n.canvasPos),u=!1,e._markerDiv.style.marginLeft="-100px",e._markerDiv.style.marginTop="-100px",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.axisVisible=!1),l.style.cursor="default"})),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this.reset();var e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);var n=this.distanceMeasurementsPlugin.viewer.cameraControl;n.off(this._onCameraControlHoverSnapOrSurface),n.off(this._onCameraControlHoverSnapOrSurfaceOff),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1}}},{key:"reset",value:function(){this._active&&this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null)}},{key:"destroy",value:function(){this.deactivate(),this._destroyMarkerDiv(),this.pointerLens&&this.pointerLens.destroy(),I(y(n.prototype),"destroy",this).call(this)}}])}(),Sp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,["DistanceMeasurements",e]))._pointerLens=i.pointerLens,t._container=i.container||e.viewerElement||document.body,t._defaultControl=null,t._measurements={},t.labelMinAxisLength=i.labelMinAxisLength,t.defaultVisible=!1!==i.defaultVisible,t.defaultOriginVisible=!1!==i.defaultOriginVisible,t.defaultTargetVisible=!1!==i.defaultTargetVisible,t.defaultWireVisible=!1!==i.defaultWireVisible,t.defaultLabelsVisible=!1!==i.defaultLabelsVisible,t.defaultAxisVisible=!1!==i.defaultAxisVisible,t.defaultXAxisVisible=!1!==i.defaultXAxisVisible,t.defaultYAxisVisible=!1!==i.defaultYAxisVisible,t.defaultZAxisVisible=!1!==i.defaultZAxisVisible,t.defaultLabelsOnWires=!1!==i.defaultLabelsOnWires,t.defaultColor=void 0!==i.defaultColor?i.defaultColor:"#0065fc",t.zIndex=i.zIndex||1e4,t.precision=void 0!==i.precision?i.precision:2,t._onMouseOver=function(e,n){t.fire("mouseOver",{plugin:t,distanceMeasurement:n,measurement:n,event:e})},t._onMouseLeave=function(e,n){t.fire("mouseLeave",{plugin:t,distanceMeasurement:n,measurement:n,event:e})},t._onMouseClick=function(e,n){t.fire("clickMeasure",{plugin:t,angleMeasurement:n,measurement:n,event:e})},t._onTouchStart=function(e,n){t.fire("touchMeasure",{plugin:t,angleMeasurement:n,measurement:n,event:e})},t._onContextMenu=function(e,n){t.fire("contextMenu",{plugin:t,distanceMeasurement:n,measurement:n,event:e})},t}return m(n,_e),C(n,[{key:"precision",get:function(){return this._precision},set:function(e){if(this._precision!=e&&(this._precision=e,this.measureNum>0))for(var n in this.measurements)this.measurements[n].precision=e}},{key:"scale",get:function(){return this._scale},set:function(e){if(this._scale!=e&&(this._scale=e,this.measureNum>0))for(var n in this.measurements)this.measurements[n].scale=e}},{key:"measureNum",get:function(){return Object.keys(this.measurements).length}},{key:"getContainerElement",value:function(){return this._container}},{key:"send",value:function(e,n){}},{key:"pointerLens",get:function(){return this._pointerLens}},{key:"control",get:function(){return this._defaultControl||(this._defaultControl=new Op(this,{})),this._defaultControl}},{key:"measurements",get:function(){return this._measurements}},{key:"labelMinAxisLength",get:function(){return this._labelMinAxisLength},set:function(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}},{key:"createMeasurement",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.viewer.scene.components[n.id]&&(this.error("Viewer scene component with this ID already exists: "+n.id),delete n.id);var t=n.origin,i=n.target,r=new Pp(this,{id:n.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.worldPos},borderColor:n.borderColor,color:n.color,visible:n.visible,originVisible:n.originVisible,targetVisible:n.targetVisible,wireVisible:n.wireVisible,axisVisible:!1!==n.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==n.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==n.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==n.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==n.labelsVisible&&!1!==this.defaultLabelsVisible,labelsOnWires:!1!==n.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onMouseClick:this._onMouseClick,onTouchStart:this._onTouchStart,onContextMenu:this._onContextMenu,precision:this._precision});return this._measurements[r.id]=r,r.on("destroyed",(function(){delete e._measurements[r.id]})),this.fire("measurementCreated",r),r}},{key:"destroyMeasurement",value:function(e){var n=this._measurements[e];n?(n.destroy(),this.fire("measurementDestroyed",n)):this.log("DistanceMeasurement not found: "+e)}},{key:"setLabelsShown",value:function(e){for(var n=0,t=Object.entries(this.measurements);n<t.length;n++){var i=f(t[n],2);i[0];i[1].labelShown=e}}},{key:"setAxisVisible",value:function(e){for(var n=0,t=Object.entries(this.measurements);n<t.length;n++){var i=f(t[n],2);i[0];i[1].axisVisible=e}this.defaultAxisVisible=e}},{key:"getAxisVisible",value:function(){return this.defaultAxisVisible}},{key:"clear",value:function(){for(var e=Object.keys(this._measurements),n=0,t=e.length;n<t;n++)this.destroyMeasurement(e[n])}},{key:"destroy",value:function(){this.clear(),I(y(n.prototype),"destroy",this).call(this)}}])}(),Np=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e.viewer.scene])).pointerLens=i.pointerLens,t.pointerCircle=new sn(e.viewer,{id:"distanceMeasure_Circle"}),t._active=!1,t._initMarkerDiv(),t._currentDistanceMeasurement=null,t._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},t._onCanvasTouchStart=null,t._onCanvasTouchEnd=null,t._longTouchTimeoutMs=300,t._snapping=!1!==i.snapping,t._snapToEdge=!1!==i.snapping,t._snapToVertex=!1!==i.snapping,t._touchState=0,t._attachPlugin(e,i),t._offsetX=0|i._offsetX,t._offsetY=0|i._offsetY,t}return m(n,_p),C(n,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myDistanceMeasureTouchMarker");var n=this.scene.canvas.canvas;n.parentNode.insertBefore(e,n),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.margin="-200px -200px",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this.markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){this.markerDiv&&(this.markerDiv.parentNode.removeChild(this.markerDiv),this.markerDiv=null)}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"offsetX",get:function(){return this._offsetX},set:function(e){this._offsetX=e}},{key:"offsetY",get:function(){return this._offsetY},set:function(e){this._offsetY=e}},{key:"active",get:function(){return this._active}},{key:"snapping",get:function(){return this._snapping},set:function(e){e!==this._snapping?(this._snapping=e,this.deactivate(),this.activate()):this._snapping=e}},{key:"activate",value:function(){var e=this;if(!this._active){var n=this.plugin,t=this.scene,i=t.canvas.canvas;this.pointerLens;var r=$.vec3(),l=20,a=null;this._touchState=0;var s=$.vec2(),u=$.vec2(),o=$.vec2(),c=null,f=function(){e.plugin.viewer.cameraControl.active=!1},p=function(){e.plugin.viewer.cameraControl.active=!0};i.addEventListener("touchstart",this._onCanvasTouchStart=function(i){if(i.isTrusted){var o=i.touches.length;if(1===o){var d=i.touches[0],v=d.clientX,A=d.clientY;switch(s.set([v,A]),u.set([v,A]),e._touchState){case 0:if(1!==o&&null!==a)return a&&(clearTimeout(a),a=null),e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),p(),void(e._touchState=0);var h=t.pick({canvasPos:u,snapping:e._snapping,snapToEdge:e._snapping});if(h&&h.snapped)r.set(h.worldPos),e.pointerCircle.start(h.snappedCanvasPos);else{var I=t.pick({canvasPos:u,pickSurface:!0});if(!I||!I.worldPos)return;r.set(I.worldPos),e.pointerCircle.start(I.canvasPos)}a=setTimeout((function(){1!==o||u[0]>s[0]+l||u[0]<s[0]-l||u[1]>s[1]+l||u[1]<s[1]-l||(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=s,e.pointerLens.cursorPos=s),e.pointerLens&&(e.pointerLens.canvasPos=u,e.pointerLens.snapped=!1),e.pointerLens&&(e.pointerLens.cursorPos=h.canvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=r:(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:r,entity:h.entity},target:{worldPos:r,entity:h.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.clickable=!1),e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement),e._touchState=2,f())}),e._longTouchTimeoutMs),e._touchState=1,c=d.identifier;break;case 3:if(1!==o&&null!==a)return clearTimeout(a),void(a=null);1===o&&(a=setTimeout((function(){if(a=null,!(1!==o||u[0]>s[0]+l||u[0]<s[0]-l||u[1]>s[1]+l||u[1]<s[1]-l)){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=s,e.pointerLens.snapped=!1);var n=t.pick({canvasPos:u,snapToVertex:e._snapping,snapToEdge:e._snapping});if(n&&n.snapped)e.pointerLens&&(e.pointerLens.cursorPos=n.snappedCanvasPos,e.pointerLens.snapped=!0),e.pointerCircle.start(n.snappedCanvasPos),r.set(n.worldPos),e._currentDistanceMeasurement.target.worldPos=n.worldPos,e._currentDistanceMeasurement.target.entity=n.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement);else{var i=t.pick({canvasPos:u,pickSurface:!0});i&&i.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=i.canvasPos,e.pointerLens.snapped=!1),e.pointerCircle.start(i.canvasPos),r.set(i.worldPos),e._currentDistanceMeasurement.target.worldPos=i.worldPos,e._currentDistanceMeasurement.target.entity=i.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):e.pointerLens&&(e.pointerLens.cursorPos=null,e.pointerLens.snapped=!1)}e._touchState=5,f()}}),e._longTouchTimeoutMs),e._touchState=4),c=d.identifier;break;default:return null!==a&&(clearTimeout(a),a=null),void(e._touchState=7)}}else a&&(clearTimeout(a),a=null)}},{passive:!0}),i.addEventListener("touchmove",(function(i){e.pointerCircle.stop();var l=i.touches.length;if(1===l&&1===i.changedTouches.length){var s,o,f=i.touches[0],p=f.clientX,d=f.clientY;if(f.identifier===c)switch(u.set([p,d]),e._touchState){case 2:e.pointerLens&&(e.pointerLens.canvasPos=u),(s=t.pick({canvasPos:u,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&s.snapped?(e.pointerLens&&(e.pointerLens.snappedCanvasPos=s.snappedCanvasPos,e.pointerLens.snapped=!0),r.set(s.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=s.worldPos:(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:s.worldPos,entity:s.entity},target:{worldPos:s.worldPos,entity:s.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.clickable=!1),e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):(o=t.pick({canvasPos:u,pickSurface:!0}))&&o.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=o.canvasPos,e.pointerLens.snapped=!1),r.set(o.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=o.worldPos:(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:o.worldPos,entity:o.entity},target:{worldPos:o.worldPos,entity:o.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.clickable=!1),e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):e.pointerLens&&(e.pointerLens.cursorPos=null,e.pointerLens.snapped=!1),e._touchState=2;break;case 5:if(1!==l&&null!==a)return clearTimeout(a),a=null,e.pointerLens&&(e.pointerLens.visible=!1),void(e._touchState=7);e.pointerLens&&(e.pointerLens.canvasPos=u),(s=t.pick({canvasPos:u,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&s.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=s.snappedCanvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement.target.worldPos=s.worldPos,e._currentDistanceMeasurement.target.entity=s.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0):(o=t.pick({canvasPos:u,pickSurface:!0}))&&o.worldPos&&(e.pointerLens&&(e.pointerLens.cursorPos=o.canvasPos,e.pointerLens.snapped=!1),e._currentDistanceMeasurement.target.worldPos=o.worldPos,e._currentDistanceMeasurement.target.entity=o.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0),e._touchState=5}}else a&&(clearTimeout(a),a=null)}),{passive:!0}),i.addEventListener("touchend",this._onCanvasTouchEnd=function(i){e.pointerCircle.stop();var r=i.changedTouches.length;if(1===r){var f=i.changedTouches[0],d=f.clientX,v=f.clientY;if(f.identifier===c)switch(a&&(clearTimeout(a),a=null),o.set([d,v]),e._touchState){case 1:if(1!==r||d>s[0]+l||d<s[0]-l||v>s[1]+l||v<s[1]-l)return void(e._touchState=0);var A=t.pick({canvasPos:u,pickSurface:!0});A&&A.worldPos?(e._currentDistanceMeasurement=n.createMeasurement({id:$.createUUID(),origin:{worldPos:A.worldPos,entity:A.entity},target:{worldPos:A.worldPos,entity:A.entity},precision:n.precision}),e._currentDistanceMeasurement.labelsVisible=!1,e._currentDistanceMeasurement.xAxisVisible=!1,e._currentDistanceMeasurement.yAxisVisible=!1,e._currentDistanceMeasurement.zAxisVisible=!1,e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.originVisible=!0,e._currentDistanceMeasurement.targetVisible=!1,e._touchState=3,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):(e._currentDistanceMeasurement&&e._currentDistanceMeasurement.destroy(),e._touchState=0),p();break;case 2:e.pointerLens&&(e.pointerLens.visible=!1),e._currentDistanceMeasurement?e._touchState=3:(e.pointerLens&&(e.pointerLens.snapped=!1,e.pointerLens.visible=!1),e._touchState=0),p();break;case 4:if(1!==r||d>s[0]+l||d<s[0]-l||v>s[1]+l||v<s[1]-l)return void(e._touchState=3);var h=t.pick({canvasPos:u,pickSurface:!0});h&&h.worldPos?(e._currentDistanceMeasurement.target.worldPos=h.worldPos,e._currentDistanceMeasurement.target.entity=h.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e._currentDistanceMeasurement.clickable=!0,e.distanceMeasurementsPlugin.fire("measurementEnd",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null):e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),e._touchState=0,p();break;case 5:e.pointerLens&&(e.pointerLens.visible=!1),e._currentDistanceMeasurement&&e._currentDistanceMeasurement.targetVisible?(e._currentDistanceMeasurement.clickable=!0,e.distanceMeasurementsPlugin.fire("measurementEnd",e._currentDistanceMeasurement),e._currentDistanceMeasurement=null,e._touchState=0):(e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),e._touchState=0),p()}}},{passive:!0}),i.addEventListener("touchcancel",this._onCanvasTouchEnd),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.pointerLens&&(this.pointerLens.visible=!1),this.reset();var e=this.plugin.viewer.scene.canvas.canvas;e.removeEventListener("touchstart",this._onCanvasTouchStart),e.removeEventListener("touchend",this._onCanvasTouchEnd),e.removeEventListener("touchcancel",this._onCanvasTouchEnd),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1,this.plugin.viewer.cameraControl.active=!0}}},{key:"reset",value:function(){this._active&&this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null)}},{key:"destroy",value:function(){this.deactivate(),this._destroyMarkerDiv(),this.pointerLens&&this.pointerLens.destroy(),this.pointerCircle&&this.pointerCircle.destroy(),I(y(n.prototype),"destroy",this).call(this)}}])}(),Bp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n),(t=v(this,n,["FastNav",e]))._hideColorTexture=!1!==i.hideColorTexture,t._hidePBR=!1!==i.hidePBR,t._hideSAO=!1!==i.hideSAO,t._hideEdges=!1!==i.hideEdges,t._hideTransparentObjects=!!i.hideTransparentObjects,t._scaleCanvasResolution=!!i.scaleCanvasResolution,t._scaleCanvasResolutionFactor=i.scaleCanvasResolutionFactor||.6,t._delayBeforeRestore=!1!==i.delayBeforeRestore,t._delayBeforeRestoreSeconds=i.delayBeforeRestoreSeconds||.5;var r=1e3*t._delayBeforeRestoreSeconds,l=!1,a=function(){r=1e3*t._delayBeforeRestoreSeconds,l||(e.scene._renderer.setColorTextureEnabled(!t._hideColorTexture),e.scene._renderer.setPBREnabled(!t._hidePBR),e.scene._renderer.setSAOEnabled(!t._hideSAO),e.scene._renderer.setTransparentEnabled(!t._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!t._hideEdges),t._scaleCanvasResolution?e.scene.canvas.resolutionScale=t._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=1,l=!0)};t._onCanvasBoundary=e.scene.canvas.on("boundary",a),t._onCameraMatrix=e.scene.camera.on("matrix",a),t._onSceneTick=e.scene.on("tick",(function(n){l&&(r-=n.deltaTime,(!t._delayBeforeRestore||r<=0)&&(e.scene.canvas.resolutionScale=1,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),l=!1))}));var s=!1;return t._onSceneMouseDown=e.scene.input.on("mousedown",(function(){s=!0})),t._onSceneMouseUp=e.scene.input.on("mouseup",(function(){s=!1})),t._onSceneMouseMove=e.scene.input.on("mousemove",(function(){s&&a()})),t}return m(n,_e),C(n,[{key:"hideColorTexture",get:function(){return this._hideColorTexture},set:function(e){this._hideColorTexture=e}},{key:"hidePBR",get:function(){return this._hidePBR},set:function(e){this._hidePBR=e}},{key:"hideSAO",get:function(){return this._hideSAO},set:function(e){this._hideSAO=e}},{key:"hideEdges",get:function(){return this._hideEdges},set:function(e){this._hideEdges=e}},{key:"hideTransparentObjects",get:function(){return this._hideTransparentObjects},set:function(e){this._hideTransparentObjects=!1!==e}},{key:"scaleCanvasResolution",get:function(){return this._scaleCanvasResolution},set:function(e){this._scaleCanvasResolution=e}},{key:"scaleCanvasResolutionFactor",get:function(){return this._scaleCanvasResolutionFactor},set:function(e){this._scaleCanvasResolutionFactor=e||.6}},{key:"delayBeforeRestore",get:function(){return this._delayBeforeRestore},set:function(e){this._delayBeforeRestore=e}},{key:"delayBeforeRestoreSeconds",get:function(){return this._delayBeforeRestoreSeconds},set:function(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}},{key:"send",value:function(e,n){}},{key:"destroy",value:function(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),I(y(n.prototype),"destroy",this).call(this)}}])}(),Lp=function(){return C((function e(){T(this,e)}),[{key:"getMetaModel",value:function(e,n,t){ue.loadJSON(e,(function(e){n(e)}),(function(e){t(e)}))}},{key:"getGLTF",value:function(e,n,t){ue.loadArraybuffer(e,(function(e){n(e)}),(function(e){t(e)}))}},{key:"getGLB",value:function(e,n,t){ue.loadArraybuffer(e,(function(e){n(e)}),(function(e){t(e)}))}},{key:"getArrayBuffer",value:function(e,n,t,i){!function(e,n,t,i){var r=function(){};t=t||r,i=i||r;var l=/^data:(.*?)(;base64)?,(.*)$/,a=n.match(l);if(a){var s=!!a[2],u=a[3];u=window.decodeURIComponent(u),s&&(u=window.atob(u));try{for(var o=new ArrayBuffer(u.length),c=new Uint8Array(o),f=0;f<u.length;f++)c[f]=u.charCodeAt(f);he.scheduleTask((function(){t(o)}))}catch(e){he.scheduleTask((function(){i(e)}))}}else{var p=function(e){var n=e.lastIndexOf("/");return 0!==n?e.substring(0,n+1):""}(e),d=p+n,v=new XMLHttpRequest;v.open("GET",d,!0),v.responseType="arraybuffer",v.onreadystatechange=function(){4===v.readyState&&(200===v.status?t(v.response):i("loadArrayBuffer error : "+v.response))},v.send(null)}}(e,n,(function(e){t(e)}),(function(e){i(e)}))}}])}();var Mp=function(){return C((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};T(this,e),this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=n.messages,this.locale=n.locale}),[{key:"messages",set:function(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}},{key:"loadMessages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var n in e)this._messages[n]=e[n];this.messages=this._messages}},{key:"clearMessages",value:function(){this.messages={}}},{key:"locales",get:function(){return this._locales}},{key:"locale",get:function(){return this._locale},set:function(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}},{key:"translate",value:function(e,n){var t=this._messages[this._locale];if(!t)return null;var i=Fp(e,t);return i?n?xp(i,n):i:null}},{key:"translatePlurals",value:function(e,n,t){var i=this._messages[this._locale];if(!i)return null;var r=Fp(e,i);return(r=0===(n=parseInt(""+n,10))?r.zero:n>1?r.other:r.one)?(r=xp(r,[n]),t&&(r=xp(r,t)),r):null}},{key:"fire",value:function(e,n,t){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==t&&(this._events[e]=n||!0);var i=this._eventSubs[e];if(i)for(var r in i){if(i.hasOwnProperty(r))i[r].callback(n)}}},{key:"on",value:function(e,n){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new G),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});var t=this._eventSubs[e];t||(t={},this._eventSubs[e]=t);var i=this._eventSubIDMap.addItem();t[i]={callback:n},this._eventSubEvents[i]=e;var r=this._events[e];return void 0!==r&&n(r),i}},{key:"off",value:function(e){if(null!=e&&this._eventSubEvents){var n=this._eventSubEvents[e];if(n){delete this._eventSubEvents[e];var t=this._eventSubs[n];t&&delete t[e],this._eventSubIDMap.removeItem(e)}}}}])}();function Fp(e,n){if(n[e])return n[e];for(var t=e.split("."),i=n,r=0,l=t.length;i&&r<l;r++){i=i[t[r]]}return i}function xp(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,t){return"{{"===e?"{":"}}"===e?"}":n[t]}))}var Hp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).t=i.t,t}return m(n,me),C(n,[{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"tangent",get:function(){return this.getTangent(this._t)}},{key:"length",get:function(){var e=this._getLengths();return e[e.length-1]}},{key:"getTangent",value:function(e){var n=1e-4;void 0===e&&(e=this._t);var t=e-n,i=e+n;t<0&&(t=0),i>1&&(i=1);var r=this.getPoint(t),l=this.getPoint(i),a=$.subVec3(l,r,[]);return $.normalizeVec3(a,[])}},{key:"getPointAt",value:function(e){var n=this.getUToTMapping(e);return this.getPoint(n)}},{key:"getPoints",value:function(e){e||(e=5);var n,t=[];for(n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}},{key:"_getLengths",value:function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n,t,i=[],r=this.getPoint(0),l=0;for(i.push(0),t=1;t<=e;t++)n=this.getPoint(t/e),l+=$.lenVec3($.subVec3(n,r,[])),i.push(l),r=n;return this.cacheArcLengths=i,i}},{key:"_updateArcLengths",value:function(){this.needsUpdate=!0,this._getLengths()}},{key:"getUToTMapping",value:function(e,n){var t,i=this._getLengths(),r=0,l=i.length;t=n||e*i[l-1];for(var a,s=0,u=l-1;s<=u;)if((a=i[r=Math.floor(s+(u-s)/2)]-t)<0)s=r+1;else{if(!(a>0)){u=r;break}u=r-1}if(i[r=u]===t)return r/(l-1);var o=i[r];return(r+(t-o)/(i[r+1]-o))/(l-1)}}])}(),Up=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).points=i.points,t.t=i.t,t}return m(n,Hp),C(n,[{key:"points",get:function(){return this._points},set:function(e){this._points=e||[]}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var n=this.points;if(!(n.length<3)){var t=(n.length-1)*e,i=Math.floor(t),r=t-i,l=n[0===i?i:i-1],a=n[i],s=n[i>n.length-2?n.length-1:i+1],u=n[i>n.length-3?n.length-1:i+2],o=$.vec3();return o[0]=$.catmullRomInterpolate(l[0],a[0],s[0],u[0],r),o[1]=$.catmullRomInterpolate(l[1],a[1],s[1],u[1],r),o[2]=$.catmullRomInterpolate(l[2],a[2],s[2],u[2],r),o}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}},{key:"getJSON",value:function(){return{points:points,t:this._t}}}])}(),Gp=$.vec3(),kp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._frames=[],t._eyeCurve=new Up(t),t._lookCurve=new Up(t),t._upCurve=new Up(t),i.frames&&(t.addFrames(i.frames),t.smoothFrameTimes(1)),t}return m(n,me),C(n,[{key:"type",get:function(){return"CameraPath"}},{key:"frames",get:function(){return this._frames}},{key:"eyeCurve",get:function(){return this._eyeCurve}},{key:"lookCurve",get:function(){return this._lookCurve}},{key:"upCurve",get:function(){return this._upCurve}},{key:"saveFrame",value:function(e){var n=this.scene.camera;this.addFrame(e,n.eye,n.look,n.up)}},{key:"addFrame",value:function(e,n,t,i){var r={t:e,eye:n.slice(0),look:t.slice(0),up:i.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}},{key:"addFrames",value:function(e){for(var n,t=0,i=e.length;t<i;t++)n=e[t],this.addFrame(n.t||0,n.eye,n.look,n.up)}},{key:"loadFrame",value:function(e){var n=this.scene.camera;e=(e/=this._frames[this._frames.length-1].t-this._frames[0].t)<0?0:e>1?1:e,n.eye=this._eyeCurve.getPoint(e,Gp),n.look=this._lookCurve.getPoint(e,Gp),n.up=this._upCurve.getPoint(e,Gp)}},{key:"sampleFrame",value:function(e,n,t,i){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,n),this._lookCurve.getPoint(e,t),this._upCurve.getPoint(e,i)}},{key:"smoothFrameTimes",value:function(e){if(0!==this._frames.length){var n=$.vec3(),t=0;this._frames[0].t=0;for(var i=[],r=1,l=this._frames.length;r<l;r++){var a=$.lenVec3($.subVec3(this._frames[r].eye,this._frames[r-1].eye,n));i[r]=a,t+=a}for(var s=1,u=this._frames.length;s<u;s++){var o=i[s]/t*e;this._frames[s].t=this._frames[s-1].t+o}}}},{key:"clearFrames",value:function(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}}])}(),Vp=$.vec3(),jp=$.vec3(),Qp=$.vec3(),Wp=$.vec3(),zp=$.vec3(),Yp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._look1=$.vec3(),t._eye1=$.vec3(),t._up1=$.vec3(),t._look2=$.vec3(),t._eye2=$.vec3(),t._up2=$.vec3(),t._orthoScale1=1,t._orthoScale2=1,t._flying=!1,t._flyEyeLookUp=!1,t._flyingEye=!1,t._flyingLook=!1,t._callback=null,t._callbackScope=null,t._time1=null,t._time2=null,t.easing=!1!==i.easing,t.duration=i.duration,t.fit=i.fit,t.fitFOV=i.fitFOV,t.trail=i.trail,t}return m(n,me),C(n,[{key:"type",get:function(){return"CameraFlightAnimation"}},{key:"flyTo",value:function(e,n,t){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=n,this._callbackScope=t;var i,r,l,a,s,u=this.scene.camera,o=!!e.projection&&e.projection!==u.projection;if(this._eye1[0]=u.eye[0],this._eye1[1]=u.eye[1],this._eye1[2]=u.eye[2],this._look1[0]=u.look[0],this._look1[1]=u.look[1],this._look1[2]=u.look[2],this._up1[0]=u.up[0],this._up1[1]=u.up[1],this._up1[2]=u.up[2],this._orthoScale1=u.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)i=e.aabb;else if(6===e.length)i=e;else if(e.eye&&e.look||e.up)r=e.eye,l=e.look,a=e.up;else if(e.eye)r=e.eye;else if(e.look)l=e.look;else{var c=e;if((ue.isNumeric(c)||ue.isString(c))&&(s=c,!(c=this.scene.components[s])))return this.error("Component not found: "+ue.inQuotes(s)),void(n&&(t?n.call(t):n()));o||(i=c.aabb||this.scene.aabb)}var f=e.poi;if(i){if(i[3]<i[0]||i[4]<i[1]||i[5]<i[2])return;if(i[3]===i[0]&&i[4]===i[1]&&i[5]===i[2])return;i=i.slice();var p=$.getAABB3Center(i);this._look2=f||p;var d=$.subVec3(this._eye1,this._look1,Vp),v=$.normalizeVec3(d),A=f?$.getAABB3DiagPoint(i,f):$.getAABB3Diag(i),h=e.fitFOV||this._fitFOV,I=Math.abs(A/Math.tan(h*$.DEGTORAD));this._orthoScale2=1.1*A,this._eye2[0]=this._look2[0]+v[0]*I,this._eye2[1]=this._look2[1]+v[1]*I,this._eye2[2]=this._look2[2]+v[2]*I,this._up2[0]=this._up1[0],this._up2[1]=this._up1[1],this._up2[2]=this._up1[2],this._flyingEyeLookUp=!0}else(r||l||a)&&(this._flyingEyeLookUp=!!r&&!!l&&!!a,this._flyingEye=!!r&&!l,this._flyingLook=!!l&&!r,r&&(this._eye2[0]=r[0],this._eye2[1]=r[1],this._eye2[2]=r[2]),l&&(this._look2[0]=l[0],this._look2[1]=l[1],this._look2[2]=l[2]),a&&(this._up2[0]=a[0],this._up2[1]=a[1],this._up2[2]=a[2]));o?("ortho"===e.projection&&"ortho"!==u.projection&&(this._projection2="ortho",this._projMatrix1=u.projMatrix.slice(),this._projMatrix2=u.ortho.matrix.slice(),u.projection="customProjection"),"perspective"===e.projection&&"perspective"!==u.projection&&(this._projection2="perspective",this._projMatrix1=u.projMatrix.slice(),this._projMatrix2=u.perspective.matrix.slice(),u.projection="customProjection")):this._projection2=null,this.fire("started",e,!0),this._time1=Date.now(),this._time2=this._time1+(e.duration?1e3*e.duration:this._duration),this._flying=!0,he.scheduleTask(this._update,this)}},{key:"jumpTo",value:function(e){this._jumpTo(e)}},{key:"_jumpTo",value:function(e){this._flying&&this.stop();var n,t,i,r,l,a=this.scene.camera;if(e.aabb)n=e.aabb;else if(6===e.length)n=e;else if(e.eye||e.look||e.up)i=e.eye,r=e.look,l=e.up;else{var s=e;if((ue.isNumeric(s)||ue.isString(s))&&(t=s,!(s=this.scene.components[t])))return void this.error("Component not found: "+ue.inQuotes(t));n=s.aabb||this.scene.aabb}var u=e.poi;if(n){if(n[3]<=n[0]||n[4]<=n[1]||n[5]<=n[2])return;var o,c=u?$.getAABB3DiagPoint(n,u):$.getAABB3Diag(n);r=u||$.getAABB3Center(n,r),this._trail?$.subVec3(a.look,r,zp):$.subVec3(a.eye,a.look,zp),$.normalizeVec3(zp),o=(void 0!==e.fit?e.fit:this._fit)?Math.abs(c/Math.tan((e.fitFOV||this._fitFOV)*$.DEGTORAD)):$.lenVec3($.subVec3(a.eye,a.look,Vp)),$.mulVec3Scalar(zp,o),a.eye=$.addVec3(r,zp,Vp),a.look=r,this.scene.camera.ortho.scale=1.1*c}else(i||r||l)&&(i&&(a.eye=i),r&&(a.look=r),l&&(a.up=l));e.projection&&(a.projection=e.projection)}},{key:"_update",value:function(){if(this._flying){var e=(Date.now()-this._time1)/(this._time2-this._time1),t=e>=1;e>1&&(e=1);var i=this.easing?n._ease(e,0,1,1):e,r=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?($.subVec3(r.eye,r.look,zp),r.eye=$.lerpVec3(i,0,1,this._eye1,this._eye2,Qp),r.look=$.subVec3(Qp,zp,jp)):this._flyingLook&&(r.look=$.lerpVec3(i,0,1,this._look1,this._look2,jp),r.up=$.lerpVec3(i,0,1,this._up1,this._up2,Wp)):this._flyingEyeLookUp&&(r.eye=$.lerpVec3(i,0,1,this._eye1,this._eye2,Qp),r.look=$.lerpVec3(i,0,1,this._look1,this._look2,jp),r.up=$.lerpVec3(i,0,1,this._up1,this._up2,Wp)),this._projection2){var l="ortho"===this._projection2?n._easeOutExpo(e,0,1,1):n._easeInCubic(e,0,1,1);r.customProjection.matrix=$.lerpMat4(l,0,1,this._projMatrix1,this._projMatrix2)}else r.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return r.ortho.scale=this._orthoScale2,void this.stop();he.scheduleTask(this._update,this)}}},{key:"stop",value:function(){if(this._flying){this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);var e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}}},{key:"cancel",value:function(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}},{key:"duration",get:function(){return this._duration/1e3},set:function(e){this._duration=e?1e3*e:500,this.stop()}},{key:"fit",get:function(){return this._fit},set:function(e){this._fit=!1!==e}},{key:"fitFOV",get:function(){return this._fitFOV},set:function(e){this._fitFOV=e||45}},{key:"trail",get:function(){return this._trail},set:function(e){this._trail=!!e}},{key:"destroy",value:function(){this.stop(),I(y(n.prototype),"destroy",this).call(this)}}],[{key:"_ease",value:function(e,n,t,i){return-t*(e/=i)*(e-2)+n}},{key:"_easeInCubic",value:function(e,n,t,i){return t*(e/=i)*e*e+n}},{key:"_easeOutExpo",value:function(e,n,t,i){return t*(1-Math.pow(2,-10*e/i))+n}}])}(),Kp=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._cameraFlightAnimation=new Yp(t),t._t=0,t.state=n.SCRUBBING,t._playingFromT=0,t._playingToT=0,t._playingRate=i.playingRate||1,t._playingDir=1,t._lastTime=null,t.cameraPath=i.cameraPath,t._tick=t.scene.on("tick",t._updateT,t),t}return m(n,me),C(n,[{key:"type",get:function(){return"CameraPathAnimation"}},{key:"_updateT",value:function(){var e=this._cameraPath;if(e){var t,i,r=performance.now(),l=this._lastTime?.001*(r-this._lastTime):0;if(this._lastTime=r,0!==l)switch(this.state){case n.SCRUBBING:return;case n.PLAYING:if(this._t+=this._playingRate*l,0===(t=this._cameraPath.frames.length)||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=n.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case n.PLAYING_TO:i=this._t+this._playingRate*l*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=n.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}}},{key:"_ease",value:function(e,n,t,i){return-t*(e/=i)*(e-2)+n}},{key:"cameraPath",get:function(){return this._cameraPath},set:function(e){this._cameraPath=e}},{key:"rate",get:function(){return this._playingRate},set:function(e){this._playingRate=e}},{key:"play",value:function(){this._cameraPath&&(this._lastTime=null,this.state=n.PLAYING)}},{key:"playToT",value:function(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=n.PLAYING_TO)}},{key:"playToFrame",value:function(e){var n=this._cameraPath;if(n){var t=n.frames[e];t?this.playToT(t.t):this.error("playToFrame - frame index out of range: "+e)}}},{key:"flyToFrame",value:function(e,t){var i=this._cameraPath;if(i){var r=i.frames[e];r?(this.state=n.SCRUBBING,this._cameraFlightAnimation.flyTo(r,t)):this.error("flyToFrame - frame index out of range: "+e)}}},{key:"scrubToT",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=n.SCRUBBING))}},{key:"scrubToFrame",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(t.frames[e]?(t.loadFrame(this._t),this.state=n.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)))}},{key:"stop",value:function(){this.state=n.SCRUBBING,this.fire("stopped")}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene.off(this._tick)}}])}();Kp.STOPPED=0,Kp.SCRUBBING=1,Kp.PLAYING=2,Kp.PLAYING_TO=3;var Xp=$.vec3(),qp=$.vec3();$.vec3();var Jp=$.vec3([0,-1,0]),Zp=$.vec4([0,0,0,1]),$p=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._src=null,t._image=null,t._pos=$.vec3(),t._origin=$.vec3(),t._rtcPos=$.vec3(),t._dir=$.vec3(),t._size=1,t._imageSize=$.vec2(),t._texture=new Hl(t),t._plane=new ll(t,{geometry:new Ft(t,Kl({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new kt(t,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:t._texture,emissiveMap:t._texture,backfaces:!0}),clippable:i.clippable}),t._grid=new ll(t,{geometry:new Ft(t,Yl({size:1,divisions:10})),material:new kt(t,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:i.clippable}),t._node=new El(t,{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[t._plane,t._grid]}),t._gridVisible=!1,t.visible=!0,t.gridVisible=i.gridVisible,t.position=i.position,t.rotation=i.rotation,t.dir=i.dir,t.size=i.size,t.collidable=i.collidable,t.clippable=i.clippable,t.pickable=i.pickable,t.opacity=i.opacity,i.image?t.image=i.image:t.src=i.src,t}return m(n,me),C(n,[{key:"visible",get:function(){return this._plane.visible},set:function(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}},{key:"gridVisible",get:function(){return this._gridVisible},set:function(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var n=this;if(this._src=e,this._src){this._image=null;var t=new Image;t.onload=function(){n._texture.image=t,n._imageSize[0]=t.width,n._imageSize[1]=t.height,n._updatePlaneSizeFromImage()},t.src=this._src}}},{key:"position",get:function(){return this._pos},set:function(e){this._pos.set(e||[0,0,0]),Ne(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}},{key:"rotation",get:function(){return this._node.rotation},set:function(e){this._node.rotation=e}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"dir",get:function(){return this._dir},set:function(e){if(this._dir.set(e||[0,0,-1]),e){var n=this.scene.center,t=[-this._dir[0],-this._dir[1],-this._dir[2]];$.subVec3(n,this.position,Xp);var i=-$.dotVec3(t,Xp);$.normalizeVec3(t),$.mulVec3Scalar(t,i,qp),$.vec3PairToQuaternion(Jp,e,Zp),this._node.quaternion=Zp}}},{key:"collidable",get:function(){return this._node.collidable},set:function(e){this._node.collidable=!1!==e}},{key:"clippable",get:function(){return this._node.clippable},set:function(e){this._node.clippable=!1!==e}},{key:"pickable",get:function(){return this._node.pickable},set:function(e){this._node.pickable=!1!==e}},{key:"opacity",get:function(){return this._node.opacity},set:function(e){this._node.opacity=e}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this)}},{key:"_updatePlaneSizeFromImage",value:function(){var e=this._size,n=this._imageSize[0],t=this._imageSize[1];if(n>t){var i=t/n;this._node.scale=[e,1,e*i]}else{var r=n/t;this._node.scale=[e*r,1,e]}}}])}(),ed=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n);var r=t=v(this,n,[e,i]);t._shadowRenderBuf=null,t._shadowViewMatrix=null,t._shadowProjMatrix=null,t._shadowViewMatrixDirty=!0,t._shadowProjMatrixDirty=!0;var l=t.scene.camera,a=t.scene.canvas;return t._onCameraViewMatrix=l.on("viewMatrix",(function(){t._shadowViewMatrixDirty=!0})),t._onCameraProjMatrix=l.on("projMatrix",(function(){t._shadowProjMatrixDirty=!0})),t._onCanvasBoundary=a.on("boundary",(function(){t._shadowProjMatrixDirty=!0})),t._state=new Zn({type:"point",pos:$.vec3([1,1,1]),color:$.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:i.space||"view",castsShadow:!1,getShadowViewMatrix:function(){if(r._shadowViewMatrixDirty){r._shadowViewMatrix||(r._shadowViewMatrix=$.identityMat4());var e=r._state.pos,n=l.look,t=l.up;$.lookAtMat4v(e,n,t,r._shadowViewMatrix),r._shadowViewMatrixDirty=!1}return r._shadowViewMatrix},getShadowProjMatrix:function(){if(r._shadowProjMatrixDirty){r._shadowProjMatrix||(r._shadowProjMatrix=$.identityMat4());var e=r.scene.canvas.canvas;$.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,r._shadowProjMatrix),r._shadowProjMatrixDirty=!1}return r._shadowProjMatrix},getShadowRenderBuf:function(){return r._shadowRenderBuf||(r._shadowRenderBuf=new zn(r.scene.canvas.canvas,r.scene.canvas.gl,{size:[1024,1024]})),r._shadowRenderBuf}}),t.pos=i.pos,t.color=i.color,t.intensity=i.intensity,t.constantAttenuation=i.constantAttenuation,t.linearAttenuation=i.linearAttenuation,t.quadraticAttenuation=i.quadraticAttenuation,t.castsShadow=i.castsShadow,t.scene._lightCreated(t),t}return m(n,wt),C(n,[{key:"type",get:function(){return"PointLight"}},{key:"pos",get:function(){return this._state.pos},set:function(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}},{key:"color",get:function(){return this._state.color},set:function(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}},{key:"intensity",get:function(){return this._state.intensity},set:function(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}},{key:"constantAttenuation",get:function(){return this._state.attenuation[0]},set:function(e){this._state.attenuation[0]=e||0,this.glRedraw()}},{key:"linearAttenuation",get:function(){return this._state.attenuation[1]},set:function(e){this._state.attenuation[1]=e||0,this.glRedraw()}},{key:"quadraticAttenuation",get:function(){return this._state.attenuation[2]},set:function(e){this._state.attenuation[2]=e||0,this.glRedraw()}},{key:"castsShadow",get:function(){return this._state.castsShadow},set:function(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}},{key:"destroy",value:function(){var e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),I(y(n.prototype),"destroy",this).call(this),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}])}();function nd(e){return 0==(e&e-1)}function td(e){--e;for(var n=1;n<32;n<<=1)e|=e>>n;return e+1}var id=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n);var r=(t=v(this,n,[e,i])).scene.canvas.gl;return t._state=new Zn({texture:new Nl({gl:r,target:r.TEXTURE_CUBE_MAP}),flipY:t._checkFlipY(i.minFilter),encoding:t._checkEncoding(i.encoding),minFilter:pi,magFilter:oi,wrapS:ti,wrapT:ti,mipmaps:!0}),t._src=i.src,t._images=[],t._loadSrc(i.src),ie.memory.textures++,t}return m(n,me),C(n,[{key:"type",get:function(){return"CubeTexture"}},{key:"_checkFlipY",value:function(e){return!!e}},{key:"_checkEncoding",value:function(e){return(e=e||or)!==or&&e!==cr&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=or),e}},{key:"_webglContextRestored",value:function(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}},{key:"_loadSrc",value:function(e){var n=this,t=this.scene.canvas.gl;this._images=[];for(var i=!1,r=0,l=function(l){var a,s,u=new Image;u.onload=(a=u,s=l,function(){if(!i&&(a=function(e){if(!nd(e.width)||!nd(e.height)){var n=document.createElement("canvas");n.width=td(e.width),n.height=td(e.height),n.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,n.width,n.height),e=n}return e}(a),n._images[s]=a,6==++r)){var e=n._state.texture;e||(e=new Nl({gl:t,target:t.TEXTURE_CUBE_MAP}),n._state.texture=e),e.setImage(n._images,n._state),n.fire("loaded",n._src,!1),n.glRedraw()}}),u.onerror=function(){i=!0},u.src=e[l]},a=0;a<e.length;a++)l(a)}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this._state.texture&&this._state.texture.destroy(),ie.memory.textures--,this._state.destroy()}}])}(),rd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).scene._lightsState.addReflectionMap(t._state),t.scene._reflectionMapCreated(t),t}return m(n,id),C(n,[{key:"type",get:function(){return"ReflectionMap"}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene._reflectionMapDestroyed(this)}}])}(),ld=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).scene._lightMapCreated(t),t}return m(n,id),C(n,[{key:"type",get:function(){return"LightMap"}},{key:"destroy",value:function(){I(y(n.prototype),"destroy",this).call(this),this.scene._lightMapDestroyed(this)}}])}(),ad=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,{entity:i.entity,occludable:i.occludable,worldPos:i.worldPos}]))._occluded=!1,t._visible=!0,t._src=null,t._image=null,t._pos=$.vec3(),t._origin=$.vec3(),t._rtcPos=$.vec3(),t._dir=$.vec3(),t._size=1,t._imageSize=$.vec2(),t._texture=new Hl(t,{src:i.src}),t._geometry=new Ft(t,{primitive:"triangles",positions:[3,3,0,-3,3,0,-3,-3,0,3,-3,0],normals:[-1,0,0,-1,0,0,-1,0,0,-1,0,0],uv:[1,-1,0,-1,0,0,1,0],indices:[0,1,2,0,2,3]}),t._mesh=new ll(t,{geometry:t._geometry,material:new kt(t,{ambient:[.9,.3,.9],shininess:30,diffuseMap:t._texture,backfaces:!0}),scale:[1,1,1],position:i.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),t.visible=!0,t.collidable=i.collidable,t.clippable=i.clippable,t.pickable=i.pickable,t.opacity=i.opacity,t.size=i.size,i.image?t.image=i.image:t.src=i.src,t}return m(n,qe),C(n,[{key:"_setVisible",value:function(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,I(y(n.prototype),"_setVisible",this).call(this,e)}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=null==e||e,this._mesh.visible=this._visible&&!this._occluded}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var n=this;if(this._src=e,this._src){this._image=null;var t=new Image;t.onload=function(){n._texture.image=t,n._imageSize[0]=t.width,n._imageSize[1]=t.height,n._updatePlaneSizeFromImage()},t.src=this._src}}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"collidable",get:function(){return this._mesh.collidable},set:function(e){this._mesh.collidable=!1!==e}},{key:"clippable",get:function(){return this._mesh.clippable},set:function(e){this._mesh.clippable=!1!==e}},{key:"pickable",get:function(){return this._mesh.pickable},set:function(e){this._mesh.pickable=!1!==e}},{key:"opacity",get:function(){return this._mesh.opacity},set:function(e){this._mesh.opacity=e}},{key:"_updatePlaneSizeFromImage",value:function(){var e=.5*this._size,n=this._imageSize[0],t=this._imageSize[1],i=t/n;this._geometry.positions=n>t?[e,e*i,0,-e,e*i,0,-e,-e*i,0,e,-e*i,0]:[e/i,e,0,-e/i,e,0,-e/i,-e,0,e/i,-e,0]}}])}(),sd=function(){return C((function e(n){T(this,e),this._eye=$.vec3(),this._look=$.vec3(),this._up=$.vec3(),this._projection={},n&&this.saveCamera(n)}),[{key:"saveCamera",value:function(e){var n=e.camera,t=n.project;switch(this._eye.set(n.eye),this._look.set(n.look),this._up.set(n.up),n.projection){case"perspective":this._projection={projection:"perspective",fov:t.fov,fovAxis:t.fovAxis,near:t.near,far:t.far};break;case"ortho":this._projection={projection:"ortho",scale:t.scale,near:t.near,far:t.far};break;case"frustum":this._projection={projection:"frustum",left:t.left,right:t.right,top:t.top,bottom:t.bottom,near:t.near,far:t.far};break;case"custom":this._projection={projection:"custom",matrix:t.matrix.slice()}}}},{key:"restoreCamera",value:function(e,n){var t=e.camera,i=this._projection;function r(){switch(i.type){case"perspective":t.perspective.fov=i.fov,t.perspective.fovAxis=i.fovAxis,t.perspective.near=i.near,t.perspective.far=i.far;break;case"ortho":t.ortho.scale=i.scale,t.ortho.near=i.near,t.ortho.far=i.far;break;case"frustum":t.frustum.left=i.left,t.frustum.right=i.right,t.frustum.top=i.top,t.frustum.bottom=i.bottom,t.frustum.near=i.near,t.frustum.far=i.far;break;case"custom":t.customProjection.matrix=i.matrix}}n?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:i.scale,projection:i.projection},(function(){r(),n()})):(t.eye=this._eye,t.look=this._look,t.up=this._up,r(),t.projection=i.projection)}}])}(),ud=$.vec3(),od=function(){return C((function e(n){if(T(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,n){var t=n.metaScene.scene;this.saveObjects(t,n)}}),[{key:"saveObjects",value:function(e,n,t){this.numObjects=0,this._mask=t?ue.apply(t,{}):null;for(var i=!t||t.visible,r=!t||t.edges,l=!t||t.xrayed,a=!t||t.highlighted,s=!t||t.selected,u=!t||t.clippable,o=!t||t.pickable,c=!t||t.colorize,f=!t||t.opacity,p=n.metaObjects,d=e.objects,v=0,A=p.length;v<A;v++){var h=d[p[v].id];if(h){if(i&&(this.objectsVisible[v]=h.visible),r&&(this.objectsEdges[v]=h.edges),l&&(this.objectsXrayed[v]=h.xrayed),a&&(this.objectsHighlighted[v]=h.highlighted),s&&(this.objectsSelected[v]=h.selected),u&&(this.objectsClippable[v]=h.clippable),o&&(this.objectsPickable[v]=h.pickable),c){var I=h.colorize;this.objectsColorize[3*v+0]=I[0],this.objectsColorize[3*v+1]=I[1],this.objectsColorize[3*v+2]=I[2]}f&&(this.objectsOpacity[v]=h.opacity),this.numObjects++}}}},{key:"restoreObjects",value:function(e,n){for(var t=this._mask,i=!t||t.visible,r=!t||t.edges,l=!t||t.xrayed,a=!t||t.highlighted,s=!t||t.selected,u=!t||t.clippable,o=!t||t.pickable,c=!t||t.colorize,f=!t||t.opacity,p=n.metaObjects,d=e.objects,v=0,A=p.length;v<A;v++){var h=d[p[v].id];h&&(i&&(h.visible=this.objectsVisible[v]),r&&(h.edges=this.objectsEdges[v]),l&&(h.xrayed=this.objectsXrayed[v]),a&&(h.highlighted=this.objectsHighlighted[v]),s&&(h.selected=this.objectsSelected[v]),u&&(h.clippable=this.objectsClippable[v]),o&&(h.pickable=this.objectsPickable[v]),c&&(ud[0]=this.objectsColorize[3*v+0],ud[1]=this.objectsColorize[3*v+1],ud[2]=this.objectsColorize[3*v+2],h.colorize=ud),f&&(h.opacity=this.objectsOpacity[v]))}}}])}(),cd=$.vec3(),fd=function(){return C((function e(){T(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsHasColorize=[],this.objectsOpacity=[],this.numObjects=0}),[{key:"saveObjects",value:function(e,n){this.numObjects=0,this._mask=n?ue.apply(n,{}):null;var t=e.objects,i=!n||n.visible,r=!n||n.edges,l=!n||n.xrayed,a=!n||n.highlighted,s=!n||n.selected,u=!n||n.clippable,o=!n||n.pickable,c=!n||n.colorize,f=!n||n.opacity;for(var p in t)if(t.hasOwnProperty(p)){var d=t[p],v=this.numObjects;if(i&&(this.objectsVisible[v]=d.visible),r&&(this.objectsEdges[v]=d.edges),l&&(this.objectsXrayed[v]=d.xrayed),a&&(this.objectsHighlighted[v]=d.highlighted),s&&(this.objectsSelected[v]=d.selected),u&&(this.objectsClippable[v]=d.clippable),o&&(this.objectsPickable[v]=d.pickable),c){var A=d.colorize;A?(this.objectsColorize[3*v+0]=A[0],this.objectsColorize[3*v+1]=A[1],this.objectsColorize[3*v+2]=A[2],this.objectsHasColorize[v]=!0):this.objectsHasColorize[v]=!1}f&&(this.objectsOpacity[v]=d.opacity),this.numObjects++}}},{key:"restoreObjects",value:function(e){var n=this._mask,t=!n||n.visible,i=!n||n.edges,r=!n||n.xrayed,l=!n||n.highlighted,a=!n||n.selected,s=!n||n.clippable,u=!n||n.pickable,o=!n||n.colorize,c=!n||n.opacity,f=0,p=e.objects;for(var d in p)if(p.hasOwnProperty(d)){var v=p[d];t&&(v.visible=this.objectsVisible[f]),i&&(v.edges=this.objectsEdges[f]),r&&(v.xrayed=this.objectsXrayed[f]),l&&(v.highlighted=this.objectsHighlighted[f]),a&&(v.selected=this.objectsSelected[f]),s&&(v.clippable=this.objectsClippable[f]),u&&(v.pickable=this.objectsPickable[f]),o&&(this.objectsHasColorize[f]?(cd[0]=this.objectsColorize[3*f+0],cd[1]=this.objectsColorize[3*f+1],cd[2]=this.objectsColorize[3*f+2],v.colorize=cd):v.colorize=null),c&&(v.opacity=this.objectsOpacity[f]),f++}}}])}(),pd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).v0=i.v0,t.v1=i.v1,t.v2=i.v2,t.v3=i.v3,t.t=i.t,t}return m(n,Hp),C(n,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"v3",get:function(){return this._v3},set:function(e){this.fire("v3",this._v3=e||$.vec3([0,0,0]))}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var n=$.vec3();return n[0]=$.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),n[1]=$.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),n[2]=$.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),n}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}])}(),dd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._cachedLengths=[],t._dirty=!0,t._curves=[],t._t=0,t._dirtySubs=[],t._destroyedSubs=[],t.curves=i.curves||[],t.t=i.t,t}return m(n,Hp),C(n,[{key:"addCurve",value:function(e){this._curves.push(e),this._dirty=!0}},{key:"curves",get:function(){return this._curves},set:function(e){var n,t,i;for(e=e||[],t=0,i=this._curves.length;t<i;t++)(n=this._curves[t]).off(this._dirtySubs[t]),n.off(this._destroyedSubs[t]);this._curves=[],this._dirtySubs=[],this._destroyedSubs=[];var r=this;function l(){r._dirty=!0}function a(){var e=this.id;for(t=0,i=r._curves.length;t<i;t++)if(r._curves[t].id===e)return r._curves=r._curves.slice(t,t+1),r._dirtySubs=r._dirtySubs.slice(t,t+1),r._destroyedSubs=r._destroyedSubs.slice(t,t+1),void(r._dirty=!0)}for(t=0,i=e.length;t<i;t++){if(n=e[t],ue.isNumeric(n)||ue.isString(n)){var s=n;if(!(n=this.scene.components[s])){this.error("Component not found: "+_inQuotes(s));continue}}var u=n.type;"xeokit.SplineCurve"===u||"xeokit.Path"===u||"xeokit.CubicBezierCurve"===u||"xeokit.QuadraticBezierCurve"===u?(this._curves.push(n),this._dirtySubs.push(n.on("dirty",l)),this._destroyedSubs.push(n.once("destroyed",a))):this.error("Component "+_inQuotes(n.id)+" is not a xeokit.SplineCurve, xeokit.Path or xeokit.QuadraticBezierCurve")}this._dirty=!0}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"length",get:function(){var e=this._getCurveLengths();return e[e.length-1]}},{key:"getPoint",value:function(e){for(var n,t=e*this.length,i=this._getCurveLengths(),r=0;r<i.length;){if(i[r]>=t){var l=1-(i[r]-t)/(n=this._curves[r]).length;return n.getPointAt(l)}r++}return null}},{key:"_getCurveLengths",value:function(){if(!this._dirty)return this._cachedLengths;var e,n=[],t=0,i=this._curves.length;for(e=0;e<i;e++)t+=this._curves[e].length,n.push(t);return this._cachedLengths=n,this._dirty=!1,n}},{key:"_getJSON",value:function(){for(var e=[],n=0,t=this._curves.length;n<t;n++)e.push(this._curves[n].id);return{curves:e,t:this._t}}},{key:"destroy",value:function(){var e,t,i;for(I(y(n.prototype),"destroy",this).call(this),e=0,t=this._curves.length;e<t;e++)(i=this._curves[e]).off(this._dirtySubs[e]),i.off(this._destroyedSubs[e])}}])}(),vd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i])).v0=i.v0,t.v1=i.v1,t.v2=i.v2,t.t=i.t,t}return m(n,Hp),C(n,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var n=$.vec3();return n[0]=$.b2(e,this._v0[0],this._v1[0],this._v2[0]),n[1]=$.b2(e,this._v0[1],this._v1[1],this._v2[1]),n[2]=$.b2(e,this._v0[2],this._v1[2],this._v2[2]),n}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}])}(),Ad=function(e){function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),v(this,n,[e,t])}return m(n,vp),C(n)}();$.vec3();var hd=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._state=new Zn({active:!0,pos:$.vec3(),dir:$.vec3(),dist:0}),t.active=i.active,t.pos=i.pos,t.dir=i.dir,t.scene._sectionBoxCreated(t),t}return m(n,me),C(n,[{key:"type",get:function(){return"SectionBox"}},{key:"control",get:function(){return this._control},set:function(e){this._control=e}},{key:"active",get:function(){return this._state.active},set:function(e){this._state.active=!1!==e,this.glRedraw(),this.fire("active",this._state.active)}},{key:"pos",get:function(){return this._state.pos},set:function(e){this._state.pos.set(e||[0,0,0]),this._state.dist=-$.dotVec3(this._state.pos,this._state.dir),this.fire("pos",this._state.pos),this.scene.fire("sectionBoxUpdated",this)}},{key:"dir",get:function(){return this._state.dir},set:function(e){this._state.dir.set(e||[0,0,-1]),this._state.dist=-$.dotVec3(this._state.pos,this._state.dir),this.glRedraw(),this.fire("dir",this._state.dir),this.scene.fire("sectionBoxUpdated",this)}},{key:"dist",get:function(){return this._state.dist}},{key:"flipDir",value:function(){var e=this._state.dir;e[0]*=-1,e[1]*=-1,e[2]*=-1,this._state.dist=-$.dotVec3(this._state.pos,this._state.dir),this.fire("dir",this._state.dir),this.glRedraw()}},{key:"destroy",value:function(){this._state.destroy(),this.scene._sectionBoxDestroyed(this),I(y(n.prototype),"destroy",this).call(this)}}])}(),Id=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return T(this,n),(t=v(this,n,[e,i]))._skyboxMesh=new ll(t,{geometry:new Ft(t,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new kt(t,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Hl(t,{scale:i.scale,src:i.src,flipY:!0,wrapS:1e3,wrapT:1e3,encoding:i.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),t.size=i.size,t.active=i.active,t}return m(n,me),C(n,[{key:"size",get:function(){return this._size},set:function(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}},{key:"active",get:function(){return this._skyboxMesh.visible},set:function(e){this._skyboxMesh.visible=e}}])}(),yd=function(){return C((function e(){T(this,e)}),[{key:"transcode",value:function(e,n){}},{key:"destroy",value:function(){}}])}(),md=$.vec4(),wd=$.vec4(),gd=$.vec3(),Ed=$.vec3(),Td=$.vec3(),bd=$.vec4(),Cd=$.vec4(),Dd=$.vec4(),Rd=function(){return C((function e(n){T(this,e),this._scene=n}),[{key:"dollyToCanvasPos",value:function(e,n,t){var i=!1,r=this._scene.camera;if(e){var l=$.subVec3(e,r.eye,gd);i=$.lenVec3(l)<t}if("perspective"===r.projection){r.ortho.scale=r.ortho.scale-t;var a=this._unproject(n,bd),s=$.subVec3(a,r.eye,Dd),u=$.mulVec3Scalar($.normalizeVec3(s),-t,[]);if(r.eye=[r.eye[0]-u[0],r.eye[1]-u[1],r.eye[2]-u[2]],r.look=[r.look[0]-u[0],r.look[1]-u[1],r.look[2]-u[2]],e){var o=$.subVec3(e,r.eye,gd),c=$.lenVec3(o),f=$.mulVec3Scalar($.normalizeVec3($.subVec3(r.look,r.eye,Ed)),c);r.look=[r.eye[0]+f[0],r.eye[1]+f[1],r.eye[2]+f[2]]}}else if("ortho"===r.projection){var p=this._unproject(n,bd);r.ortho.scale=r.ortho.scale-t,r.ortho._update();var d=this._unproject(n,Cd),v=$.subVec3(d,p,Dd),A=$.mulVec3Scalar($.normalizeVec3($.subVec3(r.look,r.eye,gd)),-t,Ed),h=$.addVec3(v,A,Td);r.eye=[r.eye[0]-h[0],r.eye[1]-h[1],r.eye[2]-h[2]],r.look=[r.look[0]-h[0],r.look[1]-h[1],r.look[2]-h[2]]}return i}},{key:"_unproject",value:function(e,n){var t=this._scene.camera,i=t.project.transposedMatrix,r=i.subarray(8,12),l=i.subarray(12),a=[0,0,-1,1],s=$.dotVec4(a,r)/$.dotVec4(a,l);return t.project.unproject(e,s,md,wd,n),n}},{key:"destroy",value:function(){}}])}(),Pd=$.vec3(),_d=$.vec3(),Od=$.vec3(),Sd=$.vec4(),Nd=$.vec4(),Bd=$.vec4(),Ld=function(){return C((function e(n,t){var i=this;T(this,e),this._scene=n,this._configs=t,this._pivotWorldPos=$.vec3(),this._cameraOffset=$.vec3(),this._azimuth=0,this._polar=0,this._radius=0,this._pivotPosSet=!1,this._pivoting=!1,this._shown=!1,this._pivotSphereEnabled=!1,this._pivotSphere=null,this._pivotSphereSize=1,this._pivotSphereGeometry=null,this._pivotSphereMaterial=null,this._rtcCenter=$.vec3(),this._rtcPos=$.vec3(),this._pivotViewPos=$.vec4(),this._pivotProjPos=$.vec4(),this._pivotCanvasPos=$.vec2(),this._cameraDirty=!0,this._onViewMatrix=this._scene.camera.on("viewMatrix",(function(){i._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(function(){i._cameraDirty=!0})),this._onTick=this._scene.on("tick",(function(){i.updatePivotElement(),i.updatePivotSphere()}))}),[{key:"createPivotSphere",value:function(){var e=this.getPivotPos(),n=$.vec3();$.decomposeMat4($.inverseMat4(this._scene.viewer.camera.viewMatrix,$.mat4()),n,$.vec4(),$.vec3());var t=$.distVec3(n,e),i=Math.tan(Math.PI/500)*t*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(i/=this._scene.camera.ortho.scale/2),Ne(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new Vl(this._scene,ul({radius:i})),this._pivotSphere=new ll(this._scene,{geometry:this._pivotSphereGeometry,material:this._pivotSphereMaterial,pickable:!1,position:this._rtcPos,rtcCenter:this._rtcCenter})}},{key:"destroyPivotSphere",value:function(){this._pivotSphere&&(this._pivotSphere.destroy(),this._pivotSphere=null),this._pivotSphereGeometry&&(this._pivotSphereGeometry.destroy(),this._pivotSphereGeometry=null)}},{key:"getPointScreenPos",value:function(e){var n=this._scene.camera,t=this._scene.canvas.boundary,i=t[2],r=t[3],l=$.vec4(),a=$.vec4(),s=$.vec2();return $.transformPoint3(n.viewMatrix,e,l),$.transformPoint4(n.projMatrix,e,a),s[0]=Math.floor((1+a[0]/a[3])*i/2),s[1]=Math.floor((1-a[1]/a[3])*r/2),s}},{key:"updatePivotElement",value:function(){var e=this._scene.camera,n=this._scene.canvas;if(this._pivoting&&this._cameraDirty){$.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,$.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);var t=n.boundary,i=t[2],r=t[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*i/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*r/2);var l=n._lastBoundingClientRect,a=n.canvas;l=n._lastBoundingClientRect=a.getBoundingClientRect(),this._pivotElement&&(this._pivotElement.style.left=Math.floor(l.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+n.offset[0],this._pivotElement.style.top=Math.floor(l.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+n.offset[1]),this._cameraDirty=!1}}},{key:"updatePivotSphere",value:function(){this._pivoting&&this._pivotSphere&&(Ne(this.getPivotPos(),this._rtcCenter,this._rtcPos),$.compareVec3(this._rtcPos,this._pivotSphere.position)||(this.destroyPivotSphere(),this.createPivotSphere()))}},{key:"setPivotElement",value:function(e){this._pivotElement=e}},{key:"enablePivotSphere",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);var n=e.color||[1,0,0];this._pivotSphereMaterial=new kt(this._scene,{emissive:n,ambient:n,specular:[0,0,0],diffuse:[0,0,0]})}},{key:"disablePivotSphere",value:function(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}},{key:"startPivot",value:function(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;var e=this._scene.camera,n=$.lookAtMat4v(e.eye,e.look,e.worldUp);$.transformPoint3(n,this.getPivotPos(),this._cameraOffset);var t=this.getPivotPos();this._cameraOffset[2]+=$.distVec3(e.eye,t),n=$.inverseMat4(n);var i=$.transformVec3(n,this._cameraOffset),r=$.vec3();if($.subVec3(e.eye,t,r),$.addVec3(r,i),e.zUp){var l=r[1];r[1]=r[2],r[2]=l}this._radius=$.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}},{key:"_cameraLookingDownwards",value:function(){var e=this._scene.camera,n=$.normalizeVec3($.subVec3(e.look,e.eye,Pd)),t=$.cross3Vec3(n,e.worldUp,_d);return $.sqLenVec3(t)<=1e-4}},{key:"getPivoting",value:function(){return this._pivoting}},{key:"setPivotPos",value:function(e){this._pivotWorldPos&&this._pivotWorldPos.set(e),this._pivotPosSet=!0}},{key:"setCanvasPivotPos",value:function(e){var n=this._scene.camera,t=Math.abs($.distVec3(this._scene.center,n.eye)),i=n.project.transposedMatrix,r=i.subarray(8,12),l=i.subarray(12),a=[0,0,-1,1],s=$.dotVec4(a,r)/$.dotVec4(a,l),u=Sd;n.project.unproject(e,s,Nd,Bd,u);var o=$.normalizeVec3($.subVec3(u,n.eye,Pd)),c=$.addVec3(n.eye,$.mulVec3Scalar(o,t,_d),Od);this.setPivotPos(c)}},{key:"getPivotPos",value:function(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}},{key:"continuePivot",value:function(e,n){if(this._pivoting&&(0!==e||0!==n)){var t=this._scene.camera,i=-e,r=-n;1===t.worldUp[2]&&(i=-i),this._azimuth+=.01*-i,this._polar+=.01*r,this._polar=$.clamp(this._polar,.001,Math.PI-.001);var l=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===t.worldUp[2]){var a=l[1];l[1]=l[2],l[2]=a}var s=$.lenVec3($.subVec3(t.look,t.eye,$.vec3())),u=this.getPivotPos();$.addVec3(l,u);var o=$.lookAtMat4v(l,u,t.worldUp);o=$.inverseMat4(o);var c=$.transformVec3(o,this._cameraOffset);o[12]-=c[0],o[13]-=c[1],o[14]-=c[2];var f=[o[8],o[9],o[10]];t.eye=[o[12],o[13],o[14]],$.subVec3(t.eye,$.mulVec3Scalar(f,s),t.look),t.up=[o[4],o[5],o[6]],this.showPivot()}}},{key:"showPivot",value:function(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}},{key:"hidePivot",value:function(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}},{key:"endPivot",value:function(){this._pivoting=!1}},{key:"destroy",value:function(){this._pivotElement&&this._pivotElement.parentNode.removeChild(this._pivotElement),this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}])}(),Md=function(){return C((function e(n,t){T(this,e),this._scene=n.scene,this._cameraControl=n,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=t,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=$.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}),[{key:"update",value:function(){if(this._configs.pointerEnabled&&(this.schedulePickEntity||this.schedulePickSurface)){var e="".concat(~~this.pickCursorPos[0],"-").concat(~~this.pickCursorPos[1],"-").concat(this.scheduleSnapOrPick,"-").concat(this.schedulePickSurface,"-").concat(this.schedulePickEntity);if(this._lastHash!==e){this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;var n=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var t=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});t&&(t.snappedToEdge||t.snappedToVertex)?(this.snapPickResult=t,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){var i=this.pickResult.canvasPos;if(i[0]===this.pickCursorPos[0]&&i[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=n?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){var r=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(r[0]===this.pickCursorPos[0]&&r[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}}}},{key:"fireEvents",value:function(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){var e=new bn;e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){var n=this.pickResult.entity.id;this._lastPickedEntityId!==n&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=n)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}])}(),Fd=$.vec2(),xd=function(){return C((function e(n,t,i,r,l){var a=this;T(this,e),this._scene=n;var s,u,o,c=t.pickController,f=0,p=0,d=0,v=0,A=!1,h=$.vec3(),I=!0;this.canvas=this._scene.canvas.canvas;var y=[];document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled){var t=e.keyCode;y[t]=!0}}),document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled){var t=e.keyCode;y[t]=!1}});var m=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];a.canvas.style.cursor="move",f=r.pointerCanvasPos[0],p=r.pointerCanvasPos[1],d=r.pointerCanvasPos[0],v=r.pointerCanvasPos[1],e&&(c.pickCursorPos=r.pointerCanvasPos,c.schedulePickSurface=!0,c.update(),c.picked&&c.pickedSurface&&c.pickResult&&c.pickResult.worldPos?(A=!0,h.set(c.pickResult.worldPos)):A=!1)};this.canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){if(i.active&&i.pointerEnabled)switch(e.which){case 1:y[n.input.KEY_SHIFT]||i.planView?(s=!0,m()):(s=!0,m(!1));break;case 2:u=!0,m();break;case 3:o=!0,i.panRightClick&&m()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=function(){if(i.active&&i.pointerEnabled&&(s||u||o)){var e=n.canvas.boundary,t=e[2],a=e[3],c=r.pointerCanvasPos[0],d=r.pointerCanvasPos[1];if(y[n.input.KEY_SHIFT]||i.planView||!i.panRightClick&&u||i.panRightClick&&o){var v=c-f,I=d-p,m=n.camera;if("perspective"===m.projection){var w=Math.abs(A?$.lenVec3($.subVec3(h,n.camera.eye,[])):n.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);l.panDeltaX+=1.5*v*w/a,l.panDeltaY+=1.5*I*w/a}else l.panDeltaX+=.5*m.ortho.scale*(v/a),l.panDeltaY+=.5*m.ortho.scale*(I/a)}else!s||u||o||i.planView||(i.firstPerson?(l.rotateDeltaY-=(c-f)/t*i.dragRotationRate/2,l.rotateDeltaX+=(d-p)/a*(i.dragRotationRate/4)):(l.rotateDeltaY-=(c-f)/t*(1.5*i.dragRotationRate),l.rotateDeltaX+=(d-p)/a*(1.5*i.dragRotationRate)));f=c,p=d}}),this.canvas.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){i.active&&i.pointerEnabled&&r.mouseover&&(I=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(i.active&&i.pointerEnabled)switch(e.which){case 1:case 2:case 3:s=!1,u=!1,o=!1}}),this.canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){if(i.active&&i.pointerEnabled){if(3===e.which){!function(e,n){if(e){for(var t=e.target,i=0,r=0,l=0,a=0;t.offsetParent;)i+=t.offsetLeft,r+=t.offsetTop,l+=t.scrollLeft,a+=t.scrollTop,t=t.offsetParent;n[0]=e.pageX+l-i,n[1]=e.pageY+a-r}else e=window.event,n[0]=e.x,n[1]=e.y}(e,Fd);var n=Fd[0],r=Fd[1];Math.abs(n-d)<3&&Math.abs(r-v)<3&&t.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Fd,event:e},!0)}a.canvas.style.removeProperty("cursor")}}),this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){i.active&&i.pointerEnabled});var w=1/60,g=null;this.canvas.addEventListener("wheel",this._mouseWheelHandler=function(e){if(e.preventDefault(),i.active&&i.pointerEnabled){var n=performance.now()/1e3,t=null!==g?n-g:0;g=n,t>.05&&(t=.05),t<w&&(t=w);var a=Math.max(-1,Math.min(1,40*-e.deltaY));if(0!==a){var s=a/Math.abs(a);l.dollyDelta+=-s*t*i.mouseWheelDollyRate,I&&(r.followPointerDirty=!0,I=!1)}}})}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("mousedown",this._mouseDownHandler),this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler),this.canvas.removeEventListener("mouseup",this._mouseUpHandler),this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler),this.canvas.removeEventListener("wheel",this._mouseWheelHandler)),document.removeEventListener("keydown",this._documentKeyDownHandler),document.removeEventListener("keyup",this._documentKeyUpHandler),document.removeEventListener("mousemove",this._documentMouseMoveHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler)}}])}(),Hd=$.vec3(),Ud=$.vec3(),Gd=$.vec3(),kd=$.vec3(),Vd=$.vec3(),jd={eye:$.vec3(),look:$.vec3(),up:$.vec3()},Qd=function(){return C((function e(n,t,i,r){T(this,e),this._scene=n,this.input=n.input;var l=t.cameraControl,a=n.camera;this._onSceneKeyDown=n.input.on("keydown",(function(){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&r.mouseover){var e=l._isKeyDownForAction(l.AXIS_VIEW_RIGHT),s=l._isKeyDownForAction(l.AXIS_VIEW_BACK),u=l._isKeyDownForAction(l.AXIS_VIEW_LEFT),o=l._isKeyDownForAction(l.AXIS_VIEW_FRONT),c=l._isKeyDownForAction(l.AXIS_VIEW_TOP),f=l._isKeyDownForAction(l.AXIS_VIEW_BOTTOM);if(e||s||u||o||c||f){var p=n.aabb,d=$.getAABB3Diag(p);$.getAABB3Center(p,Hd);var v=Math.abs(d/Math.tan(t.cameraFlight.fitFOV*$.DEGTORAD)),A=1.1*d;jd.orthoScale=A,e?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldRight,v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):s?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldForward,v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):u?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldRight,-v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):o?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldForward,-v,Ud),Vd)),jd.look.set(Hd),jd.up.set(a.worldUp)):c?(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldUp,v,Ud),Vd)),jd.look.set(Hd),jd.up.set($.normalizeVec3($.mulVec3Scalar(a.worldForward,1,Gd),kd))):f&&(jd.eye.set($.addVec3(Hd,$.mulVec3Scalar(a.worldUp,-v,Ud),Vd)),jd.look.set(Hd),jd.up.set($.normalizeVec3($.mulVec3Scalar(a.worldForward,-1,Gd)))),!i.firstPerson&&i.followPointer&&t.pivotController.setPivotPos(Hd),t.cameraFlight.duration>0?t.cameraFlight.flyTo(jd,(function(){t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot()})):(t.cameraFlight.jumpTo(jd),t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot())}}}))}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){this.input.off(this._onSceneKeyDown)}}])}(),Wd=function(){return C((function e(n,t,i,r,l){var a=this;T(this,e),this._scene=n;var s=t.pickController,u=t.pivotController,o=t.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;var c=!1,f=!1;this.canvas=this._scene.canvas.canvas;var p=n.tickify(this._canvasMouseMoveHandler=function(e){if(i.active&&i.pointerEnabled&&!c&&!f){var t=o.hasSubs("hover"),l=o.hasSubs("hoverEnter"),u=o.hasSubs("hoverOut"),p=o.hasSubs("hoverOff"),d=o.hasSubs("hoverSurface"),v=o.hasSubs("hoverSnapOrSurface");if(t||l||u||p||d||v)if(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickEntity=!0,s.schedulePickSurface=d,s.scheduleSnapOrPick=v,s.update(),s.pickResult){if(s.pickResult.entity){var A=s.pickResult.entity.id;a._lastPickedEntityId!==A&&(void 0!==a._lastPickedEntityId&&o.fire("hoverOut",{entity:n.objects[a._lastPickedEntityId]},!0),o.fire("hoverEnter",s.pickResult,!0),a._lastPickedEntityId=A)}o.fire("hover",s.pickResult,!0),(s.pickResult.worldPos||s.pickResult.snappedWorldPos)&&o.fire("hoverSurface",s.pickResult,!0)}else void 0!==a._lastPickedEntityId&&(o.fire("hoverOut",{entity:n.objects[a._lastPickedEntityId]},!0),a._lastPickedEntityId=void 0),o.fire("hoverOff",{canvasPos:s.pickCursorPos},!0)}});this.canvas.addEventListener("mousemove",p),this.canvas.addEventListener("dblclick",this._canvasDblClickHandler=function(e){r.mouseDownClientX=e.clientX,r.mouseDownClientY=e.clientY,r.mouseDownCursorX=r.pointerCanvasPos[0],r.mouseDownCursorY=r.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickSurface=!0,s.update()),s.pickResult?(o.fire("doublePicked",s.pickResult,!0),s.pickedSurface&&o.fire("doublePickedSurface",s.pickResult,!0)):o.fire("doublePickedNothing",{canvasPos:r.pointerCanvasPos},!0)}),this.canvas.addEventListener("mousedown",this._canvasMouseDownHandler=function(e){if(1===e.which&&(c=!0),3===e.which&&(f=!0),1===e.which&&i.active&&i.pointerEnabled&&(r.mouseDownClientX=e.clientX,r.mouseDownClientY=e.clientY,r.mouseDownCursorX=r.pointerCanvasPos[0],r.mouseDownCursorY=r.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickSurface=!0,s.update(),1===e.which))){var t=s.pickResult;t&&t.worldPos?(u.setCanvasPivotPos(r.pointerCanvasPos),o.fire("mouseDownEntity",s.pickResult,!0)):(i.smartPivot?u.setCanvasPivotPos(r.pointerCanvasPos):u.setPivotPos(n.camera.look),u.startPivot(),o.fire("mouseDownNothing",s.pickResult,!0))}}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){1===e.which&&(c=!1),3===e.which&&(f=!1),u.getPivoting()&&u.endPivot()}),this.canvas.addEventListener("mouseup",this._canvasMouseUpHandler=function(e){if(i.active&&i.pointerEnabled&&(1===e.which&&(u.hidePivot(),!(Math.abs(e.clientX-r.mouseDownClientX)>3||Math.abs(e.clientY-r.mouseDownClientY)>3)))){var n=o.hasSubs("picked"),l=o.hasSubs("pickedNothing"),c=o.hasSubs("pickedSurface"),f=o.hasSubs("doublePicked"),p=o.hasSubs("doublePickedSurface"),d=o.hasSubs("doublePickedNothing");if(!(i.doublePickFlyTo||f||p||d))return(n||l||c)&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickEntity=!0,s.schedulePickSurface=c,s.update(),s.pickResult?(o.fire("picked",s.pickResult,!0),s.pickedSurface&&o.fire("pickedSurface",s.pickResult,!0)):o.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0)),void(a._clicks=0);s.pickCursorPos=r.pointerCanvasPos,s.schedulePickEntity=i.doublePickFlyTo,s.schedulePickSurface=c,s.update();var v=s.pickResult,A=s.pickedSurface;a._timeout=setTimeout((function(){v?(o.fire("picked",v,!0),A&&(o.fire("pickedSurface",v,!0),!i.firstPerson&&i.followPointer&&(t.pivotController.setPivotPos(v.worldPos),t.pivotController.startPivot()&&t.pivotController.showPivot()))):o.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0),a._clicks=0}),i.doubleClickTimeFrame)}},!1)}),[{key:"reset",value:function(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler),this.canvas.removeEventListener("mousedown",this._canvasMouseDownHandler),this.canvas.removeEventListener("dblclick",this._canvasDblClickHandler),this.canvas.removeEventListener("mouseup",this._canvasMouseUpHandler)),document.removeEventListener("mouseup",this._documentMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}])}(),zd=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n,this._updates=l;var a=n.input;this.input=a;var s=[],u=n.canvas.canvas,o=!0;this._onSceneMouseMove=a.on("mousemove",(function(){o=!0})),this._onSceneKeyDown=a.on("keydown",(function(e){i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&r.mouseover&&(s[e]=!0,e===a.KEY_SHIFT&&(u.style.cursor="move"))})),this._onSceneKeyUp=a.on("keyup",(function(e){i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&(s[e]=!1,e===a.KEY_SHIFT&&(u.style.cursor=null),t.pivotController.getPivoting()&&t.pivotController.endPivot())})),this._onTick=n.on("tick",(function(e){if(i.active&&i.pointerEnabled&&n.input.keyboardEnabled&&r.mouseover){var u=t.cameraControl,c=e.deltaTime/1e3;if(!i.planView){var f=u._isKeyDownForAction(u.ROTATE_Y_POS,s),p=u._isKeyDownForAction(u.ROTATE_Y_NEG,s),d=u._isKeyDownForAction(u.ROTATE_X_POS,s),v=u._isKeyDownForAction(u.ROTATE_X_NEG,s),A=c*i.keyboardRotationRate;(f||p||d||v)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),f?l.rotateDeltaY+=A:p&&(l.rotateDeltaY-=A),d?l.rotateDeltaX+=A:v&&(l.rotateDeltaX-=A),!i.firstPerson&&i.followPointer&&t.pivotController.startPivot())}if(!s[a.KEY_CTRL]&&!s[a.KEY_ALT]){var h=u._isKeyDownForAction(u.DOLLY_BACKWARDS,s),I=u._isKeyDownForAction(u.DOLLY_FORWARDS,s);if(h||I){var y=c*i.keyboardDollyRate;!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),I?l.dollyDelta-=y:h&&(l.dollyDelta+=y),o&&(r.followPointerDirty=!0,o=!1)}}var m=u._isKeyDownForAction(u.PAN_FORWARDS,s),w=u._isKeyDownForAction(u.PAN_BACKWARDS,s),g=u._isKeyDownForAction(u.PAN_LEFT,s),E=u._isKeyDownForAction(u.PAN_RIGHT,s),T=u._isKeyDownForAction(u.PAN_UP,s),b=u._isKeyDownForAction(u.PAN_DOWN,s),C=(s[a.KEY_ALT]?.3:1)*c*i.keyboardPanRate;(m||w||g||E||T||b)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),b?l.panDeltaY+=C:T&&(l.panDeltaY+=-C),E?l.panDeltaX+=-C:g&&(l.panDeltaX+=C),w?l.panDeltaZ+=C:m&&(l.panDeltaZ+=-C))}}))}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.off(this._onTick),this.input.off(this._onSceneMouseMove),this.input.off(this._onSceneKeyDown),this.input.off(this._onSceneKeyUp)}}])}(),Yd=.001,Kd=$.vec3(),Xd=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n;var a=n.camera,s=t.pickController,u=t.pivotController,o=t.panController,c=1,f=1,p=null;this._onTick=n.on("tick",(function(){if(i.active&&i.pointerEnabled){var e="default";if(Math.abs(l.dollyDelta)<Yd&&(l.dollyDelta=0),Math.abs(l.rotateDeltaX)<Yd&&(l.rotateDeltaX=0),Math.abs(l.rotateDeltaY)<Yd&&(l.rotateDeltaY=0),0===l.rotateDeltaX&&0===l.rotateDeltaY||(l.dollyDelta=0),i.followPointer&&--c<=0&&(c=1,0!==l.dollyDelta)){if(0===l.rotateDeltaY&&0===l.rotateDeltaX&&i.followPointer&&r.followPointerDirty&&(s.pickCursorPos=r.pointerCanvasPos,s.schedulePickSurface=!0,s.update(),s.pickResult&&s.pickResult.worldPos?p=s.pickResult.worldPos:(f=1,p=null),r.followPointerDirty=!1),p){var t=Math.abs($.lenVec3($.subVec3(p,n.camera.eye,Kd)));f=t/i.dollyProximityThreshold}f<i.dollyMinSpeed&&(f=i.dollyMinSpeed)}var d=l.dollyDelta*f;if(0===l.rotateDeltaY&&0===l.rotateDeltaX||(!i.firstPerson&&i.followPointer&&u.getPivoting()?u.continuePivot(l.rotateDeltaY,l.rotateDeltaX):(0!==l.rotateDeltaX&&(i.firstPerson?a.pitch(-l.rotateDeltaX):a.orbitPitch(l.rotateDeltaX)),0!==l.rotateDeltaY&&(i.firstPerson?a.yaw(l.rotateDeltaY):a.orbitYaw(l.rotateDeltaY))),l.rotateDeltaX*=i.rotationInertia,l.rotateDeltaY*=i.rotationInertia,e="grabbing"),Math.abs(l.panDeltaX)<Yd&&(l.panDeltaX=0),Math.abs(l.panDeltaY)<Yd&&(l.panDeltaY=0),Math.abs(l.panDeltaZ)<Yd&&(l.panDeltaZ=0),0!==l.panDeltaX||0!==l.panDeltaY||0!==l.panDeltaZ){var v,A,h=$.vec3();if(h[0]=l.panDeltaX,h[1]=l.panDeltaY,h[2]=l.panDeltaZ,i.constrainVertical){a.xUp?(v=a.eye[0],A=a.look[0]):a.yUp?(v=a.eye[1],A=a.look[1]):a.zUp&&(v=a.eye[2],A=a.look[2]),a.pan(h);var I=a.eye,y=a.look;a.xUp?(I[0]=v,y[0]=A):a.yUp?(I[1]=v,y[1]=A):a.zUp&&(I[2]=v,y[2]=A),a.eye=I,a.look=y}else a.pan(h);e="grabbing"}if(l.panDeltaX*=i.panInertia,l.panDeltaY*=i.panInertia,l.panDeltaZ*=i.panInertia,0!==d){if(e=d<0?"zoom-in":"zoom-out",i.firstPerson){var m,w;if(i.constrainVertical&&(a.xUp?(m=a.eye[0],w=a.look[0]):a.yUp?(m=a.eye[1],w=a.look[1]):a.zUp&&(m=a.eye[2],w=a.look[2])),i.followPointer)o.dollyToCanvasPos(p,r.pointerCanvasPos,-d)&&(r.followPointerDirty=!0);else a.pan([0,0,d]),a.ortho.scale=a.ortho.scale-d;if(i.constrainVertical){var g=a.eye,E=a.look;a.xUp?(g[0]=m,E[0]=w):a.yUp?(g[1]=m,E[1]=w):a.zUp&&(g[2]=m,E[2]=w),a.eye=g,a.look=E}}else if(i.planView){if(i.followPointer)o.dollyToCanvasPos(p,r.pointerCanvasPos,-d)&&(r.followPointerDirty=!0);else a.ortho.scale=a.ortho.scale+d,a.zoom(d)}else{if(i.followPointer)o.dollyToCanvasPos(p,r.pointerCanvasPos,-d)&&(r.followPointerDirty=!0);else a.ortho.scale=a.ortho.scale+d,a.zoom(d)}l.dollyDelta*=i.dollyInertia}s.fireEvents(),document.body.style.cursor=e}}))}),[{key:"destroy",value:function(){this._scene.off(this._onTick)}}])}(),qd=function(){return C((function e(n,t,i,r,l){var a=this;T(this,e),this._scene=n,this.canvas=this._scene.canvas.canvas,this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){r.mouseover=!0}),this.canvas.addEventListener("mouseleave",this._mouseLeaveHandler=function(){r.mouseover=!1,a.canvas.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=function(e){Jd(e,a.canvas,r.pointerCanvasPos)}),this.canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){i.active&&i.pointerEnabled&&(Jd(e,a.canvas,r.pointerCanvasPos),r.mouseover=!0)}),this.canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){i.active&&i.pointerEnabled})}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler),this.canvas.removeEventListener("mouseleave",this._mouseLeaveHandler),this.canvas.removeEventListener("mousedown",this._mouseDownHandler),this.canvas.removeEventListener("mouseup",this._mouseUpHandler)),document.removeEventListener("mousemove",this._mouseMoveHandler)}}])}();function Jd(e,n,t){if(e){var i=n.getBoundingClientRect(),r=i.x,l=i.y;t[0]=e.clientX-r,t[1]=e.clientY-l}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var Zd=function(e,n){if(e){for(var t=e.target,i=0,r=0;t.offsetParent;)i+=t.offsetLeft,r+=t.offsetTop,t=t.offsetParent;n[0]=e.pageX-i,n[1]=e.pageY-r}else e=window.event,n[0]=e.x,n[1]=e.y;return n},$d=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n;var a=t.pickController,s=t.pivotController,u=$.vec2(),o=$.vec2(),c=$.vec2(),f=$.vec2(),p=[];this.canvas=this._scene.canvas.canvas;var d=0,v=!1;this._onTick=n.on("tick",(function(){v=!1})),this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(i.active&&i.pointerEnabled&&e.isTrusted){e.preventDefault();var t=e.touches,l=e.changedTouches;for(r.touchStartTime=Date.now(),1===t.length&&1===l.length&&(r.touchStartTime,Zd(t[0],u),i.followPointer&&(a.pickCursorPos=u,a.schedulePickSurface=!0,a.update(),s.setPivotPos(n.camera.look),i.planView||(a.picked&&a.pickedSurface&&a.pickResult&&a.pickResult.worldPos?(s.setPivotPos(n.camera.look),!i.firstPerson&&s.startPivot()):(i.smartPivot,s.setPivotPos(n.camera.look),!i.firstPerson&&s.startPivot()))));p.length<t.length;)p.push($.vec2());for(var o=0,c=t.length;o<c;++o)Zd(t[o],p[o]);d=t.length}}),this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(){s.getPivoting()&&(s.endPivot(),s.hidePivot())}),this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler),this.canvas.addEventListener("touchmove",this._canvasTouchMoveHandler=function(e){if(i.active&&i.pointerEnabled&&(e.stopPropagation(),e.preventDefault(),!v)){v=!0;var t=n.canvas.boundary,u=t[2],A=t[3],h=e.touches;if(e.touches.length===d){if(1===d){Zd(h[0],o),$.subVec2(o,p[0],f);var I=f[0],y=f[1];if(null!==r.longTouchTimeout&&(Math.abs(I)>i.longTapRadius||Math.abs(y)>i.longTapRadius)&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null),i.planView){var m=n.camera;if("perspective"===m.projection){var w=Math.abs(n.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);l.panDeltaX+=I*w/A*i.touchPanRate,l.panDeltaY+=y*w/A*i.touchPanRate}else l.panDeltaX+=.5*m.ortho.scale*(I/A)*i.touchPanRate,l.panDeltaY+=.5*m.ortho.scale*(y/A)*i.touchPanRate}else l.rotateDeltaY-=I/u*(1*i.dragRotationRate),l.rotateDeltaX+=y/A*(1.5*i.dragRotationRate)}else if(2===d){s.hidePivot();var g=h[0],E=h[1];Zd(g,o),Zd(E,c);var T=$.geometricMeanVec2(p[0],p[1]),b=$.geometricMeanVec2(o,c),C=$.vec2();$.subVec2(T,b,C);var D=C[0],R=C[1],P=n.camera,_=$.distVec2([g.pageX,g.pageY],[E.pageX,E.pageY]),O=($.distVec2(p[0],p[1])-_)*i.touchDollyRate;if(l.dollyDelta=O,Math.abs(O)<1)if("perspective"===P.projection){var S=a.pickResult?a.pickResult.worldPos:n.center,N=Math.abs($.lenVec3($.subVec3(S,n.camera.eye,[])))*Math.tan(P.perspective.fov/2*Math.PI/180);l.panDeltaX-=D*N/A*i.touchPanRate,l.panDeltaY-=R*N/A*i.touchPanRate}else l.panDeltaX-=.5*P.ortho.scale*(D/A)*i.touchPanRate,l.panDeltaY-=.5*P.ortho.scale*(R/A)*i.touchPanRate;r.pointerCanvasPos=b}for(var B=0;B<d;++B)Zd(h[B],p[B])}}})}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler),this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler),this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler),this.canvas.removeEventListener("touchmove",this._canvasTouchMoveHandler)),this._scene.off(this._onTick)}}])}(),ev=function(e,n){if(e){for(var t=e.target,i=0,r=0;t.offsetParent;)i+=t.offsetLeft,r+=t.offsetTop,t=t.offsetParent;n[0]=e.pageX-i,n[1]=e.pageY-r}else e=window.event,n[0]=e.x,n[1]=e.y;return n},nv=function(){return C((function e(n,t,i,r,l){T(this,e),this._scene=n;var a,s=t.pickController,u=t.cameraControl,o=[],c=new Float32Array(2),f=-1,p=-1;this.canvas=this._scene.canvas.canvas;var d=function(e){var i;e&&e.worldPos&&(i=e.worldPos);var r=e?e.entity.aabb:n.aabb;if(i){var l=n.camera;$.subVec3(l.eye,l.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})};this.canvas.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(i.active&&i.pointerEnabled&&e.isTrusted){null!==r.longTouchTimeout&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null);var n=e.touches,l=e.changedTouches;if(a=Date.now(),1===n.length&&1===l.length){f=a;var p=c[0],d=c[1],v=n[0].pageX,A=n[0].pageY;r.longTouchTimeout=setTimeout((function(){t.cameraControl.fire("rightClick",{pagePos:[Math.round(v),Math.round(A)],canvasPos:[Math.round(p),Math.round(d)],event:e},!0),r.longTouchTimeout=null}),i.longTapTimeout);var h=u.hasSubs("pickedSurface");ev(n[0],s.pickCursorPos),s.schedulePickEntity=!0,s.schedulePickSurface=h,s.update(),s.pickResult?(u.fire("touchEntity",s.pickResult),s.pickedSurface&&u.fire("touchSurface",s.pickResult)):u.fire("touchNothing")}else f=-1;for(;o.length<n.length;)o.push(new Float32Array(2));for(var I=0,y=n.length;I<y;++I)ev(n[I],o[I]);o.length=n.length}},{passive:!0}),this.canvas.addEventListener("touchend",this._canvasTouchEndHandler=function(e){if(i.active&&i.pointerEnabled){var n=Date.now(),t=e.touches,l=e.changedTouches,a=u.hasSubs("pickedSurface");null!==r.longTouchTimeout&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null),0===t.length&&1===l.length&&f>-1&&n-f<150&&(p>-1&&f-p<325?(ev(l[0],s.pickCursorPos),s.schedulePickEntity=!0,s.schedulePickSurface=a,s.update(),s.pickResult?(s.pickResult.touchInput=!0,u.fire("doublePicked",s.pickResult),u.fire("touchDoublePicked",s.pickResult),s.pickedSurface&&(u.fire("doublePickedSurface",s.pickResult),u.fire("touchDoublePickedSurface",s.pickResult)),i.doublePickFlyTo&&d(s.pickResult)):(u.fire("doublePickedNothing"),u.fire("touchDoublePickedNothing"),i.doublePickFlyTo&&d()),p=-1):$.distVec2(o[0],c)<1e3&&(ev(l[0],s.pickCursorPos),s.schedulePickEntity=!0,s.schedulePickSurface=a,s.update(),s.pickResult?(s.pickResult.touchInput=!0,u.fire("picked",s.pickResult),u.fire("touchPicked",s.pickResult),s.pickedSurface&&(u.fire("pickedSurface",s.pickResult),u.fire("touchPickedSurface",s.pickResult))):(u.fire("pickedNothing"),u.fire("touchPickedNothing")),p=n),f=-1),o.length=t.length;for(var v=0,A=t.length;v<A;++v)o[v][0]=t[v].pageX,o[v][1]=t[v].pageY;e.stopPropagation()}},{passive:!0}),this.canvas.addEventListener("touchcancel",this._canvasTouchEndHandler)}),[{key:"reset",value:function(){}},{key:"destroy",value:function(){null!=this.canvas&&(this.canvas.removeEventListener("touchstart",this._canvasTouchStartHandler),this.canvas.removeEventListener("touchend",this._canvasTouchEndHandler),this.canvas.removeEventListener("touchcancel",this._canvasTouchEndHandler))}}])}(),tv=function(e){function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,n),(t=v(this,n,[e,i])).PAN_LEFT=0,t.PAN_RIGHT=1,t.PAN_UP=2,t.PAN_DOWN=3,t.PAN_FORWARDS=4,t.PAN_BACKWARDS=5,t.ROTATE_X_POS=6,t.ROTATE_X_NEG=7,t.ROTATE_Y_POS=8,t.ROTATE_Y_NEG=9,t.DOLLY_FORWARDS=10,t.DOLLY_BACKWARDS=11,t.AXIS_VIEW_RIGHT=12,t.AXIS_VIEW_BACK=13,t.AXIS_VIEW_LEFT=14,t.AXIS_VIEW_FRONT=15,t.AXIS_VIEW_TOP=16,t.AXIS_VIEW_BOTTOM=17,t._keyMap={},t.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},t._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!1,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:i.snapRadius?i.snapRadius:20,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},t._states={pointerCanvasPos:$.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,touchEndTime:null,activeTouches:[],tapStartPos:$.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},t._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};var r=t.scene;return t._controllers={cameraControl:t,pickController:new Md(t,t._configs),pivotController:new Ld(r,t._configs),panController:new Rd(r),cameraFlight:new Yp(t,{duration:.5})},t._handlers=[new qd(t.scene,t._controllers,t._configs,t._states,t._updates),new $d(t.scene,t._controllers,t._configs,t._states,t._updates),new xd(t.scene,t._controllers,t._configs,t._states,t._updates),new Qd(t.scene,t._controllers,t._configs,t._states,t._updates),new Wd(t.scene,t._controllers,t._configs,t._states,t._updates),new nv(t.scene,t._controllers,t._configs,t._states,t._updates),new zd(t.scene,t._controllers,t._configs,t._states,t._updates)],t._cameraUpdater=new Xd(t.scene,t._controllers,t._configs,t._states,t._updates),t.navMode=i.navMode,i.planView&&(t.planView=i.planView),t.constrainVertical=i.constrainVertical,i.keyboardLayout?t.keyboardLayout=i.keyboardLayout:t.keyMap=i.keyMap,t.doublePickFlyTo=i.doublePickFlyTo,t.panRightClick=i.panRightClick,t.active=i.active,t.followPointer=i.followPointer,t.rotationInertia=i.rotationInertia,t.keyboardPanRate=i.keyboardPanRate,t.touchPanRate=i.touchPanRate,t.keyboardRotationRate=i.keyboardRotationRate,t.dragRotationRate=i.dragRotationRate,t.touchDollyRate=i.touchDollyRate,t.dollyInertia=i.dollyInertia,t.dollyProximityThreshold=i.dollyProximityThreshold,t.dollyMinSpeed=i.dollyMinSpeed,t.panInertia=i.panInertia,t.pointerEnabled=!0,t.keyboardDollyRate=i.keyboardDollyRate,t.mouseWheelDollyRate=i.mouseWheelDollyRate,t._moveRate=1,t.scene.on("tick",(function(){(t._goLeft||t._goRight||t._goUp||t._goDown||t._goForward||t._goBackward)&&(t._goRight?t._updates.panDeltaX+=-.1*t._moveRate:t._goLeft&&(t._updates.panDeltaX+=.1*t._moveRate),t._goUp?t._updates.panDeltaY+=.1*t._moveRate:t._goDown&&(t._updates.panDeltaY+=-.1*t._moveRate),t._goForward?t._updates.panDeltaZ+=-.1*t._moveRate:t._goBackward&&(t._updates.panDeltaZ+=.1*t._moveRate),t._inputDirectionCommand=!0)})),t}return m(n,me),C(n,[{key:"setdirectionChangeCancel",value:function(){this._goLeft=!1,this._goRight=!1,this._goUp=!1,this._goDown=!1,this._goForward=!1,this._goBackward=!1}},{key:"moveRate",set:function(e){this._moveRate=e}},{key:"goRight",set:function(e){this._goRight=e}},{key:"goLeft",set:function(e){this._goLeft=e}},{key:"goUp",set:function(e){this._goUp=e}},{key:"goDown",set:function(e){this._goDown=e}},{key:"goForward",set:function(e){this._goForward=e}},{key:"goBackward",set:function(e){this._goBackward=e}},{key:"updatePivotElement",value:function(){this._controllers.pivotController.updatePivotElement()}},{key:"keyMap",get:function(){return this._keyMap},set:function(e){if(e=e||"qwerty",ue.isString(e)){var n=this.scene.input,t={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":t[this.PAN_LEFT]=[n.KEY_A],t[this.PAN_RIGHT]=[n.KEY_D],t[this.PAN_UP]=[n.KEY_Z],t[this.PAN_DOWN]=[n.KEY_X],t[this.PAN_BACKWARDS]=[],t[this.PAN_FORWARDS]=[],t[this.DOLLY_FORWARDS]=[n.KEY_W,n.KEY_ADD],t[this.DOLLY_BACKWARDS]=[n.KEY_S,n.KEY_SUBTRACT],t[this.ROTATE_X_POS]=[n.KEY_DOWN_ARROW],t[this.ROTATE_X_NEG]=[n.KEY_UP_ARROW],t[this.ROTATE_Y_POS]=[n.KEY_Q,n.KEY_LEFT_ARROW],t[this.ROTATE_Y_NEG]=[n.KEY_E,n.KEY_RIGHT_ARROW],t[this.AXIS_VIEW_RIGHT]=[n.KEY_NUM_1],t[this.AXIS_VIEW_BACK]=[n.KEY_NUM_2],t[this.AXIS_VIEW_LEFT]=[n.KEY_NUM_3],t[this.AXIS_VIEW_FRONT]=[n.KEY_NUM_4],t[this.AXIS_VIEW_TOP]=[n.KEY_NUM_5],t[this.AXIS_VIEW_BOTTOM]=[n.KEY_NUM_6];break;case"azerty":t[this.PAN_LEFT]=[n.KEY_Q],t[this.PAN_RIGHT]=[n.KEY_D],t[this.PAN_UP]=[n.KEY_W],t[this.PAN_DOWN]=[n.KEY_X],t[this.PAN_BACKWARDS]=[],t[this.PAN_FORWARDS]=[],t[this.DOLLY_FORWARDS]=[n.KEY_Z,n.KEY_ADD],t[this.DOLLY_BACKWARDS]=[n.KEY_S,n.KEY_SUBTRACT],t[this.ROTATE_X_POS]=[n.KEY_DOWN_ARROW],t[this.ROTATE_X_NEG]=[n.KEY_UP_ARROW],t[this.ROTATE_Y_POS]=[n.KEY_A,n.KEY_LEFT_ARROW],t[this.ROTATE_Y_NEG]=[n.KEY_E,n.KEY_RIGHT_ARROW],t[this.AXIS_VIEW_RIGHT]=[n.KEY_NUM_1],t[this.AXIS_VIEW_BACK]=[n.KEY_NUM_2],t[this.AXIS_VIEW_LEFT]=[n.KEY_NUM_3],t[this.AXIS_VIEW_FRONT]=[n.KEY_NUM_4],t[this.AXIS_VIEW_TOP]=[n.KEY_NUM_5],t[this.AXIS_VIEW_BOTTOM]=[n.KEY_NUM_6]}this._keyMap=t}else{var i=e;this._keyMap=i}}},{key:"_isKeyDownForAction",value:function(e,n){var t=this._keyMap[e];if(!t)return!1;n||(n=this.scene.input.keyDown);for(var i=0,r=t.length;i<r;i++){if(n[t[i]])return!0}return!1}},{key:"pivotElement",set:function(e){this._controllers.pivotController.setPivotElement(e)}},{key:"active",get:function(){return this._configs.active},set:function(e){e=!1!==e,this._configs.active=e,this._handlers[1]._active=e,this._handlers[5]._active=e}},{key:"snapToVertex",get:function(){return this._configs.snapToVertex},set:function(e){this._configs.snapToVertex=!!e}},{key:"snapToEdge",get:function(){return this._configs.snapToEdge},set:function(e){this._configs.snapToEdge=!!e}},{key:"snapRadius",get:function(){return this._configs.snapRadius},set:function(e){e=e||20,this._configs.snapRadius=e}},{key:"navMode",get:function(){return this._configs.navMode},set:function(e){"firstPerson"!==(e=e||"orbit")&&"orbit"!==e&&"planView"!==e&&(this.error("Unsupported value for navMode: "+e+" - supported values are 'orbit', 'firstPerson' and 'planView' - defaulting to 'orbit'"),e="orbit"),this._configs.firstPerson="firstPerson"===e,this._configs.planView="planView"===e,(this._configs.firstPerson||this._configs.planView)&&(this._controllers.pivotController.hidePivot(),this._controllers.pivotController.endPivot()),this._configs.navMode=e}},{key:"pointerEnabled",get:function(){return this._configs.pointerEnabled},set:function(e){this._reset(),this._configs.pointerEnabled=!!e}},{key:"_reset",value:function(){for(var e=0,n=this._handlers.length;e<n;e++){var t=this._handlers[e];t.reset&&t.reset()}this._updates.panDeltaX=0,this._updates.panDeltaY=0,this._updates.rotateDeltaX=0,this._updates.rotateDeltaY=0,this._updates.dolyDelta=0}},{key:"followPointer",get:function(){return this._configs.followPointer},set:function(e){this._configs.followPointer=!1!==e}},{key:"pivotPos",get:function(){return this._controllers.pivotController.getPivotPos()},set:function(e){this._controllers.pivotController.setPivotPos(e)}},{key:"dollyToPointer",get:function(){return this.warn("dollyToPointer property is deprecated - replaced with followPointer"),this.followPointer},set:function(e){this.warn("dollyToPointer property is deprecated - replaced with followPointer"),this.followPointer=e}},{key:"panToPointer",get:function(){return this.warn("panToPointer property is deprecated - replaced with followPointer"),!1},set:function(e){this.warn("panToPointer property is deprecated - replaced with followPointer")}},{key:"planView",get:function(){return this._configs.planView},set:function(e){this._configs.planView=!!e,this._configs.firstPerson=!1,this._configs.planView&&(this._controllers.pivotController.hidePivot(),this._controllers.pivotController.endPivot()),this.warn("planView property is deprecated - replaced with navMode")}},{key:"firstPerson",get:function(){return this.warn("firstPerson property is deprecated - replaced with navMode"),this._configs.firstPerson},set:function(e){this.warn("firstPerson property is deprecated - replaced with navMode"),this._configs.firstPerson=!!e,this._configs.planView=!1,this._configs.firstPerson&&(this._controllers.pivotController.hidePivot(),this._controllers.pivotController.endPivot())}},{key:"constrainVertical",get:function(){return this._configs.constrainVertical},set:function(e){this._configs.constrainVertical=!!e}},{key:"doublePickFlyTo",get:function(){return this._configs.doublePickFlyTo},set:function(e){this._configs.doublePickFlyTo=!1!==e}},{key:"panRightClick",get:function(){return this._configs.panRightClick},set:function(e){this._configs.panRightClick=!1!==e}},{key:"rotationInertia",get:function(){return this._configs.rotationInertia},set:function(e){this._configs.rotationInertia=null!=e?e:0}},{key:"keyboardPanRate",get:function(){return this._configs.keyboardPanRate},set:function(e){this._configs.keyboardPanRate=null!=e?e:5}},{key:"touchPanRate",get:function(){return this._configs.touchPanRate},set:function(e){this._configs.touchPanRate=null!=e?e:1}},{key:"keyboardRotationRate",get:function(){return this._configs.keyboardRotationRate},set:function(e){this._configs.keyboardRotationRate=null!=e?e:90}},{key:"dragRotationRate",get:function(){return this._configs.dragRotationRate},set:function(e){this._configs.dragRotationRate=null!=e?e:360}},{key:"keyboardDollyRate",get:function(){return this._configs.keyboardDollyRate},set:function(e){this._configs.keyboardDollyRate=null!=e?e:15}},{key:"touchDollyRate",get:function(){return this._configs.touchDollyRate},set:function(e){this._configs.touchDollyRate=null!=e?e:.2}},{key:"mouseWheelDollyRate",get:function(){return this._configs.mouseWheelDollyRate},set:function(e){this._configs.mouseWheelDollyRate=null!=e?e:100}},{key:"dollyInertia",get:function(){return this._configs.dollyInertia},set:function(e){this._configs.dollyInertia=null!=e?e:0}},{key:"dollyProximityThreshold",get:function(){return this._configs.dollyProximityThreshold},set:function(e){this._configs.dollyProximityThreshold=null!=e?e:35}},{key:"dollyMinSpeed",get:function(){return this._configs.dollyMinSpeed},set:function(e){this._configs.dollyMinSpeed=null!=e?e:.04}},{key:"panInertia",get:function(){return this._configs.panInertia},set:function(e){this._configs.panInertia=null!=e?e:.5}},{key:"keyboardLayout",get:function(){return this._configs.keyboardLayout},set:function(e){"qwerty"!==(e=e||"qwerty")&&"azerty"!==e&&(this.error("Unsupported value for keyboardLayout - defaulting to 'qwerty'"),e="qwerty"),this._configs.keyboardLayout=e,this.keyMap=this._configs.keyboardLayout}},{key:"enablePivotSphere",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._controllers.pivotController.enablePivotSphere(e)}},{key:"disablePivotSphere",value:function(){this._controllers.pivotController.disablePivotSphere()}},{key:"smartPivot",get:function(){return this._configs.smartPivot},set:function(e){this._configs.smartPivot=!1!==e}},{key:"doubleClickTimeFrame",get:function(){return this._configs.doubleClickTimeFrame},set:function(e){this._configs.doubleClickTimeFrame=null!=e?e:250}},{key:"destroy",value:function(){this._destroyHandlers(),this._destroyControllers(),this._cameraUpdater.destroy(),I(y(n.prototype),"destroy",this).call(this)}},{key:"_destroyHandlers",value:function(){for(var e=0,n=this._handlers.length;e<n;e++){var t=this._handlers[e];t.destroy&&t.destroy()}}},{key:"_destroyControllers",value:function(){for(var e=0,n=this._controllers.length;e<n;e++){var t=this._controllers[e];t.destroy&&t.destroy()}}}])}(),iv=C((function e(n){T(this,e),this.id=n.id,this.originalSystemId=n.originalSystemId,this.metaModels=[],this.name=n.name,this.type=n.type,this.properties=[],n.properties&&(this.properties=n.properties)})),rv=function(){return C((function e(n){T(this,e),this.metaModels=[],this.id=n.id,this.parentId=n.parentId,this.parent=null,this.originalSystemId=n.originalSystemId,this.name=n.name,this.type=n.type,this.propertySetIds=n.propertySetIds,this.propertySets=[],void 0!==n.external&&null!==n.external&&(this.external=n.external)}),[{key:"metaModel",get:function(){return 1==this.metaModels.length?this.metaModels[0]:null}},{key:"getObjectIDsInSubtree",value:function(){var e=[];return function n(t){if(t){e.push(t.id);var i=t.children;if(i)for(var r=0,l=i.length;r<l;r++)n(i[r])}}(this),e}},{key:"withMetaObjectsInSubtree",value:function(e){!function n(t){if(t){e(t);var i=t.children;if(i)for(var r=0,l=i.length;r<l;r++)n(i[r])}}(this)}},{key:"getObjectIDsInSubtreeByType",value:function(e){for(var n={},t=0,i=e.length;t<i;t++)n[e[t]]=e[t];var r=[];return function e(t){if(t){n[t.type]&&r.push(t.id);var i=t.children;if(i)for(var l=0,a=i.length;l<a;l++)e(i[l])}}(this),r}},{key:"getJSON",value:function(){var e={id:this.id,type:this.type,name:this.name};return this.parent&&(e.parent=this.parent.id),e}}])}(),lv=function(){return C((function e(n){T(this,e),this.id=n.id,this.projectId=n.projectId,this.revisionId=n.revisionId,this.author=n.author,this.createdAt=n.createdAt,this.creatingApplication=n.creatingApplication,this.schema=n.schema,this.metaScene=n.metaScene,this.propertySets=[],this.rootMetaObjects=[],this.metaObjects=[],this.objectCount=0,this.propertySetCount=0,this.graph=n.graph||{},this.metaScene.metaModels[this.id]=this,this._finalized=!1}),[{key:"finalized",get:function(){return this._finalized},set:function(e){this._finalized=e}},{key:"rootMetaObject",get:function(){return 1==this.rootMetaObjects.length?this.rootMetaObjects[0]:null}},{key:"loadData",value:function(e,n,t){if(this._finalized)throw"MetaScene already finalized - can't add more data";try{var i,r,l,a,s,u,o,c;if(null===e)throw"metaModelData is null!";this.author=null!==(i=e.author)&&void 0!==i?i:"",this.schema=null!==(r=e.schema)&&void 0!==r?r:"",this.createdAt=null!==(l=e.createdAt)&&void 0!==l?l:"",this.projectId=null!==(a=e.projectId)&&void 0!==a?a:"",this.revisionId=null!==(s=e.revisionId)&&void 0!==s?s:"",this.objectCount=null!==(u=e.objectCount)&&void 0!==u?u:"",this.propertySetCount=null!==(o=e.propertySetCount)&&void 0!==o?o:"",this.creatingApplication=null!==(c=e.creatingApplication)&&void 0!==c?c:"";var f=this.metaScene;if(e.propertySets)for(var p in e.propertySets){var d=e.propertySets[p],v=new iv({id:d.id,originalSystemId:d.originalSystemId||d.id,type:d.type,name:d.name,properties:d.properties});f.propertySets[p]=v,this.propertySets.push(v)}if(e.metaObjects)for(var A in e.metaObjects){var h=e.metaObjects[A],I=new rv({id:A,originalSystemId:A,parentId:h.parent,type:h.type,name:h.name,propertySetIds:h.propertySetIds,external:h.external});I.children=[],I.metaModels=[],I.metaModels.push(this),f.metaObjects[A]=I,this.metaObjects.push(I),h.parent||(this.rootMetaObjects.push(I),f.rootMetaObjects[A]=I)}"function"==typeof n&&n()}catch(e){"function"==typeof t?t(e):this.log(t)}}},{key:"_decompressProperties",value:function(e,n){for(var t=0,i=n.length;t<i;t++){var r=n[t];if(Number.isInteger(r)){var l=e[r];l&&(n[t]=l)}}}},{key:"finalize",value:function(){if(this._finalized)throw"MetaScene already finalized - can't re-finalize";var e=this.metaScene;for(var n in e.metaObjectsByType={},e.metaObjects){var t=e.metaObjects[n];if(t.parentId){var i=e.metaObjects[t.parentId];i&&(t.parent=i,(i.children||(i.children=[])).push(t))}if(t.propertySets&&(t.propertySets=[]),t.propertySetIds)for(var r=0,l=t.propertySetIds.length;r<l;r++){var a=t.propertySetIds[r],s=e.propertySets[a];t.propertySets.push(s)}var u=t.type;(e.metaObjectsByType[u]||(e.metaObjectsByType[u]={}))[n]=t}this._finalized=!0,this.metaScene.fire("metaModelCreated",this.id)}},{key:"getJSON",value:function(){for(var e={id:this.id,projectId:this.projectId,author:this.author,createdAt:this.createdAt,schema:this.schema,creatingApplication:this.creatingApplication,metaObjects:[],propertySets:[]},n=0,t=this.metaObjects.length;n<t;n++){var i=this.metaObjects[n],r={id:i.id,originalSystemId:i.originalSystemId,extId:i.extId,type:i.type,name:i.name};i.parent&&(r.parent=i.parent.id),i.attributes&&(r.attributes=i.attributes),i.propertySetIds&&(r.propertySetIds=i.propertySetIds),e.metaObjects.push(r)}for(var l=0,a=this.propertySets.length;l<a;l++){for(var s=this.propertySets[l],u={id:s.id,originalSystemId:s.originalSystemId,extId:s.extId,type:s.type,name:s.name,propertyies:[]},o=0,c=s.properties.length;o<c;o++){var f=s.properties[o],p={id:f.id,description:f.description,type:f.type,name:f.name,value:f.value,valueType:f.valueType};u.properties.push(p)}e.propertySets.push(u)}return e}},{key:"_globalizeIDs",value:function(e,n){var t=!!n.globalizeObjectIds;if(e.metaObjects)for(var i=0,r=e.metaObjects.length;i<r;i++){var l=e.metaObjects[i];if(l.originalSystemId=l.id,l.parent&&(l.originalParentSystemId=l.parent),t&&(l.id=$.globalizeObjectId(this.id,l.id),l.parent&&(l.parent=$.globalizeObjectId(this.id,l.parent))),t){var a=l.propertySetIds;if(a){for(var s=[],u=0,o=a.length;u<o;u++)s.push($.globalizeObjectId(this.id,a[u]));l.propertySetIds=s,l.originalSystemPropertySetIds=a}}else l.originalSystemPropertySetIds=l.propertySetIds}if(e.propertySets)for(var c=0,f=e.propertySets.length;c<f;c++){var p=e.propertySets[c];p.originalSystemId=p.id,t&&(p.id=$.globalizeObjectId(this.id,p.id))}}}])}(),av=function(){return C((function e(n,t){T(this,e),this.viewer=n,this.scene=t,this.metaModels={},this.propertySets={},this.metaObjects={},this.metaObjectsByType={},this.rootMetaObjects={},this._eventSubs={}}),[{key:"on",value:function(e,n){var t=this._eventSubs[e];t||(t=[],this._eventSubs[e]=t),t.push(n)}},{key:"fire",value:function(e,n){var t=this._eventSubs[e];if(t)for(var i=0,r=t.length;i<r;i++)t[i](n)}},{key:"off",value:function(e){}},{key:"createMetaModel",value:function(e,n){var t=new lv({metaScene:this,id:e,projectId:n.projectId||"none",revisionId:n.revisionId||"none",author:n.author||"none",createdAt:n.createdAt||"none",creatingApplication:n.creatingApplication||"none",schema:n.schema||"none",propertySets:[]});return t.loadData(n),t.finalize(),t}},{key:"destroyMetaModel",value:function(e){var n=this.metaModels[e];if(n){if(n.propertySets)for(var t=0,i=n.propertySets.length;t<i;t++){var r=n.propertySets[t];if(1===r.metaModels.length&&r.metaModels[0].id===e)delete this.propertySets[r.id];else{for(var l=[],a=0,s=r.metaModels.length;a<s;a++)r.metaModels[a].id!==e&&l.push(r.metaModels[a]);r.metaModels=l}}if(n.metaObjects)for(var u=0,o=n.metaObjects.length;u<o;u++){var c=n.metaObjects[u];c.type;var f=c.id;1===c.metaModels.length&&c.metaModels[0].id===e&&(delete this.metaObjects[f],c.parent||delete this.rootMetaObjects[f])}for(var p in this.metaObjects){var d=this.metaObjects[p];if(d.children&&(d.children=[]),d.propertySets&&(d.propertySets=[]),d.propertySetIds)for(var v=0,A=d.propertySetIds.length;v<A;v++){var h=d.propertySetIds[v],I=this.propertySets[h];d.propertySets.push(I)}}for(var y in this.metaObjectsByType={},this.metaObjects){var m=this.metaObjects[y],w=m.type;m.children&&(m.children=null),(this.metaObjectsByType[w]||(this.metaObjectsByType[w]={}))[y]=m}for(var g in this.metaObjects){var E=this.metaObjects[g];if(E.parentId){var T=this.metaObjects[E.parentId];T&&(E.parent=T,(T.children||(T.children=[])).push(E))}}delete this.metaModels[e],this.fire("metaModelDestroyed",e)}}},{key:"getObjectIDsByType",value:function(e){var n=this.metaObjectsByType[e];return n?Object.keys(n):[]}},{key:"getObjectIDsByTypes",value:function(e){for(var n=[],t=0;t<e.length;t++){var i=e[t];n=n.concat(this.getObjectIDsByType(i))}return n}},{key:"getObjectIDsInSubtree",value:function(e,n,t){var i=[],r=this.metaObjects[e],l=n&&n.length>0?sv(n):null,a=t&&t.length>0?sv(t):null;return function e(n){if(n){var t=!0;(a&&a[n.type]||l&&!l[n.type])&&(t=!1),t&&i.push(n.id);var r=n.children;if(r)for(var s=0,u=r.length;s<u;s++)e(r[s])}}(r),i}},{key:"withMetaObjectsInSubtree",value:function(e,n){var t=this.metaObjects[e];t&&t.withMetaObjectsInSubtree(n)}}])}();function sv(e){for(var n={},t=0,i=e.length;t<i;t++)n[e[t]]=!0;return n}
18
18
  /*!
19
19
  * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
20
20
  * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtctwins/tctwins-core",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": false,
5
5
  "description": "Web Programming Toolkit for 3D/2D BIM and CAD",
6
6
  "module": "./dist/tctwins-core.es5.js",
@@ -45,10 +45,8 @@
45
45
  "@loaders.gl/core": "^3.2.6",
46
46
  "@loaders.gl/gltf": "^3.2.6",
47
47
  "@loaders.gl/las": "^3.2.6",
48
- "density-clustering": "^1.3.0",
49
48
  "html2canvas": "^1.4.1",
50
- "web-ifc": "^0.0.55",
51
- "webpack-cli": "^5.1.4"
49
+ "web-ifc": "^0.0.55"
52
50
  },
53
51
  "devDependencies": {
54
52
  "@babel/cli": "^7.24.7",
@@ -119,6 +119,7 @@ export declare class CameraControl extends Component {
119
119
 
120
120
  on(event: "mouseDownEntity", callback: (e?: { canvasPos: number[] }) => void, scope?: any): string;
121
121
  on(event: "mouseDownNothing", callback: (e?: { canvasPos: number[] }) => void, scope?: any): string;
122
+ on(event: "touchPicked", callback: (e?: { canvasPos: number[] }) => void, scope?: any): string;
122
123
  on(event: "touchEntity", callback: (e?: { canvasPos: number[] }) => void, scope?: any): string;
123
124
  on(event: "touchSurface", callback: (e?: { canvasPos: number[] }) => void, scope?: any): string;
124
125
  on(event: "touchNothing", callback: (e?: { canvasPos: number[] }) => void, scope?: any): string;