@xeokit/xeokit-sdk 2.6.27 → 2.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +1 -1
- package/dist/xeokit-sdk.es.js +1 -1
- package/dist/xeokit-sdk.es5.js +1 -1
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/dist/xeokit-sdk.min.es5.js +1 -1
- package/package.json +1 -1
- package/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +1 -1
|
@@ -14,7 +14,7 @@ var e,t=a().mark(Ax),i=a().mark(cx),r=a().mark(wM);function s(e,t){var i=Object.
|
|
|
14
14
|
/**
|
|
15
15
|
* @author https://github.com/tmarti, with support from https://tribia.com/
|
|
16
16
|
* @license MIT
|
|
17
|
-
**/var ih=null;function rh(e,t){var i,r,s,n,o,a,l=3*e,u=3*t,A=Math.min(i=ih[l],r=ih[l+1],s=ih[l+2]),c=Math.min(n=ih[u],o=ih[u+1],a=ih[u+2]);if(A!==c)return A-c;var h=Math.max(i,r,s),d=Math.max(n,o,a);return h!==d?h-d:0}function sh(e,t){for(var i=new Int32Array(e.length/3),r=0,s=i.length;r<s;r++)i[r]=r;ih=new Int32Array(e.length);for(var n=0,o=e.length;n<o;n++)ih[n]=e[n]>>t;i.sort(rh);for(var a=new Int32Array(e.length),l=0,u=i.length;l<u;l++)a[3*l+0]=e[3*i[l]+0],a[3*l+1]=e[3*i[l]+1],a[3*l+2]=e[3*i[l]+2];return a}var nh=null;function oh(e,t){var i=nh[2*e]-nh[2*t];return 0!==i?i:nh[2*e+1]-nh[2*t+1]}function ah(e){if(0===(e||[]).length)return[];for(var t=new Int32Array(e.length/2),i=0,r=t.length;i<r;i++)t[i]=i;for(var s=0,n=e.length;s<n;s+=2)if(e[s]>e[s+1]){var o=e[s];e[s]=e[s+1],e[s+1]=o}nh=new Int32Array(e),t.sort(oh);for(var a=new Int32Array(e.length),l=0,u=t.length;l<u;l++)a[2*l+0]=e[2*t[l]+0],a[2*l+1]=e[2*t[l]+1];return a}function lh(e,t){var i={},r={};e.forEach((function(e){for(var t=e.indices,s=e.edgeIndices,n=e.positionsCompressed,o=0,a=t.length;o<a;o+=3){var l=n[3*t[o]]+"_"+n[3*t[o]+1]+"_"+n[3*t[o]+2]+"/"+n[3*t[o+1]]+"_"+n[3*t[o+1]+1]+"_"+n[3*t[o+1]+2]+"/"+n[3*t[o+2]]+"_"+n[3*t[o+2]+1]+"_"+n[3*t[o+2]+2];i[l]=!0}e.edgeIndices.length/2;for(var u=0,A=s.length;u<A;u+=2){var c=n[3*s[u]]+"_"+n[3*s[u]+1]+"_"+n[3*s[u]+2]+"/"+n[3*s[u+1]]+"_"+n[3*s[u+1]+1]+"_"+n[3*s[u+1]+2]+"/";r[c]=!0}}));var s=t.indices;t.edgeIndices;for(var n=t.positionsCompressed,o=0,a=s.length;o<a;o+=3){var l=n[3*s[o]]+"_"+n[3*s[o]+1]+"_"+n[3*s[o]+2]+"/"+n[3*s[o+1]]+"_"+n[3*s[o+1]+1]+"_"+n[3*s[o+1]+2]+"/"+n[3*s[o+2]]+"_"+n[3*s[o+2]+1]+"_"+n[3*s[o+2]+2];if(!(l in i))throw console.log("Not found "+l),"Ohhhh!"}}var uh=re.vec4(4),Ah=re.vec4(),ch=re.vec4(),hh=re.vec3([1,0,0]),dh=re.vec3([0,1,0]),ph=re.vec3([0,0,1]);re.vec3(3),re.vec3(3);var fh=re.identityMat4(),vh=function(){function e(t){x(this,e),this._model=t.model,this.id=t.id,this._parentTransform=t.parent,this._childTransforms=[],this._meshes=[],this._scale=new Float32Array([1,1,1]),this._quaternion=re.identityQuaternion(new Float32Array(4)),this._rotation=new Float32Array(3),this._position=new Float32Array(3),this._localMatrix=re.identityMat4(new Float32Array(16)),this._worldMatrix=re.identityMat4(new Float32Array(16)),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,t.matrix?this.matrix=t.matrix:(this.scale=t.scale,this.position=t.position,t.quaternion||(this.rotation=t.rotation)),t.parent&&t.parent._addChildTransform(this)}return C(e,[{key:"_addChildTransform",value:function(e){this._childTransforms.push(e),e._parentTransform=this,e._transformDirty(),e._setSubtreeAABBsDirty(this)}},{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]),re.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]),re.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=re.identityMat4()),re.composeMat4(this._position,this._quaternion,this._scale,this._localMatrix),this._localMatrixDirty=!1),this._localMatrix},set:function(e){this._localMatrix||(this._localMatrix=re.identityMat4()),this._localMatrix.set(e||fh),re.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,t){return uh[0]=e[0],uh[1]=e[1],uh[2]=e[2],uh[3]=t*re.DEGTORAD,re.angleAxisToQuaternion(uh,Ah),re.mulQuaternions(this.quaternion,Ah,ch),this.quaternion=ch,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"rotateOnWorldAxis",value:function(e,t){return uh[0]=e[0],uh[1]=e[1],uh[2]=e[2],uh[3]=t*re.DEGTORAD,re.angleAxisToQuaternion(uh,Ah),re.mulQuaternions(Ah,this.quaternion,Ah),this}},{key:"rotateX",value:function(e){return this.rotate(hh,e)}},{key:"rotateY",value:function(e){return this.rotate(dh,e)}},{key:"rotateZ",value:function(e){return this.rotate(ph,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,t=this._childTransforms.length;e<t;e++){var i=this._childTransforms[e];if(i._transformDirty(),i._meshes&&i._meshes.length>0)for(var r=i._meshes,s=0,n=r.length;s<n;s++)r[s]._transformDirty()}if(this._meshes&&this._meshes.length>0)for(var o=this._meshes,a=0,l=o.length;a<l;a++)o[a]._transformDirty()}},{key:"_buildWorldMatrix",value:function(){var e=this.matrix;if(this._parentTransform)re.mulMat4(this._parentTransform.worldMatrix,e,this._worldMatrix);else for(var t=0,i=e.length;t<i;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}},{key:"_setSubtreeAABBsDirty",value:function(e){if(e._aabbDirty=!0,e._childTransforms)for(var t=0,i=e._childTransforms.length;t<i;t++)this._setSubtreeAABBsDirty(e._childTransforms[t])}}]),e}(),gh=re.vec3(),mh=re.OBB3(),_h=re.vec4(),yh=re.vec3([1,1,1]),bh=re.vec3([0,0,0]);re.vec3([0,0,0]);var wh=re.identityQuaternion(),Bh=re.identityMat4(),xh=new Uint8Array([255,255,255]),Ph=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).renderOrder=s.renderOrder||0,r._dtxEnabled=r.scene.dtxEnabled&&!1!==s.dtxEnabled,r._enableVertexWelding=!1,r._enableIndexBucketing=!1,r._vboBatchingLayerScratchMemory=yo(),r._textureTranscoder=s.textureTranscoder||Zc(r.scene.viewer),r._maxGeometryBatchSize=s.maxGeometryBatchSize,r._aabb=re.collapseAABB3(),r._aabbDirty=!0,r._quantizationRanges={},r._vboInstancingLayers={},r._vboBatchingLayers={},r._dtxLayers={},r._meshList=[],r.layerList=[],r._entityList=[],r._geometries={},r._dtxBuckets={},r._textures={},r._textureSets={},r._transforms={},r._meshes={},r._unusedMeshes={},r._entities={},r.renderFlags=new on,r.numGeometries=0,r.numPortions=0,r.numVisibleLayerPortions=0,r.numTransparentLayerPortions=0,r.numXRayedLayerPortions=0,r.numHighlightedLayerPortions=0,r.numSelectedLayerPortions=0,r.numEdgesLayerPortions=0,r.numPickableLayerPortions=0,r.numClippableLayerPortions=0,r.numCulledLayerPortions=0,r.numEntities=0,r._numTriangles=0,r._numLines=0,r._numPoints=0,r._edgeThreshold=s.edgeThreshold||10,r._origin=re.vec3(s.origin||[0,0,0]),r._position=re.vec3(s.position||[0,0,0]),r._rotation=re.vec3(s.rotation||[0,0,0]),r._quaternion=re.vec4(s.quaternion||[0,0,0,1]),r._conjugateQuaternion=re.vec4(s.quaternion||[0,0,0,1]),s.rotation&&re.eulerToQuaternion(r._rotation,"XYZ",r._quaternion),r._scale=re.vec3(s.scale||[1,1,1]),r._worldRotationMatrix=re.mat4(),r._worldRotationMatrixConjugate=re.mat4(),r._matrix=re.mat4(),r._matrixDirty=!0,r._rebuildMatrices(),r._worldNormalMatrix=re.mat4(),re.inverseMat4(r._matrix,r._worldNormalMatrix),re.transposeMat4(r._worldNormalMatrix),(s.matrix||s.position||s.rotation||s.scale||s.quaternion)&&(r._viewMatrix=re.mat4(),r._viewNormalMatrix=re.mat4(),r._viewMatrixDirty=!0,r._matrixNonIdentity=!0),r._opacity=1,r._colorize=[1,1,1],r._saoEnabled=!1!==s.saoEnabled,r._pbrEnabled=!1!==s.pbrEnabled,r._colorTextureEnabled=!1!==s.colorTextureEnabled,r._isModel=s.isModel,r._isModel&&r.scene._registerModel(b(r)),r._onCameraViewMatrix=r.scene.camera.on("matrix",(function(){r._viewMatrixDirty=!0})),r._meshesWithDirtyMatrices=[],r._numMeshesWithDirtyMatrices=0,r._onTick=r.scene.on("tick",(function(){for(;r._numMeshesWithDirtyMatrices>0;)r._meshesWithDirtyMatrices[--r._numMeshesWithDirtyMatrices]._updateMatrix()})),r._createDefaultTextureSet(),r.visible=s.visible,r.culled=s.culled,r.pickable=s.pickable,r.clippable=s.clippable,r.collidable=s.collidable,r.castsShadow=s.castsShadow,r.receivesShadow=s.receivesShadow,r.xrayed=s.xrayed,r.highlighted=s.highlighted,r.selected=s.selected,r.edges=s.edges,r.colorize=s.colorize,r.opacity=s.opacity,r.backfaces=s.backfaces,r}return C(i,[{key:"_meshMatrixDirty",value:function(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}},{key:"_createDefaultTextureSet",value:function(){var e=new Qc({id:"defaultColorTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new Qc({id:"defaultMetalRoughTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new Qc({id:"defaultNormalsTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),r=new Qc({id:"defaultEmissiveTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),s=new Qc({id:"defaultOcclusionTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=r,this._textures.defaultOcclusionTexture=s,this._textureSets.defaultTextureSet=new Nc({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:r,occlusionTexture:s})}},{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]),re.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]),re.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||Bh),re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),re.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),re.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&&(re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),re.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),re.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,t=this._entityList.length;e<t;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&&(re.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),re.inverseMat4(this._viewMatrix,this._viewNormalMatrix),re.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&&(re.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),re.inverseMat4(this._viewMatrix,this._viewNormalMatrix),re.transposeMat4(this._viewNormalMatrix),this._viewMatrixDirty=!1),re.inverseMat4(this._viewMatrix,this._viewNormalMatrix),re.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){re.collapseAABB3(this._aabb);for(var e=0,t=this._entityList.length;e<t;e++)re.expandAABB3(this._aabb,this._entityList[e].aabb);this._aabbDirty=!1}return this._aabb}},{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 t=0,i=this._entityList.length;t<i;t++)this._entityList[t].visible=e;this.glRedraw()}},{key:"xrayed",get:function(){return this.numXRayedLayerPortions>0},set:function(e){e=!!e,this._xrayed=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].xrayed=e;this.glRedraw()}},{key:"highlighted",get:function(){return this.numHighlightedLayerPortions>0},set:function(e){e=!!e,this._highlighted=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].highlighted=e;this.glRedraw()}},{key:"selected",get:function(){return this.numSelectedLayerPortions>0},set:function(e){e=!!e,this._selected=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].selected=e;this.glRedraw()}},{key:"edges",get:function(){return this.numEdgesLayerPortions>0},set:function(e){e=!!e,this._edges=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].edges=e;this.glRedraw()}},{key:"culled",get:function(){return this._culled},set:function(e){e=!!e,this._culled=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].culled=e;this.glRedraw()}},{key:"clippable",get:function(){return this._clippable},set:function(e){e=!1!==e,this._clippable=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].clippable=e;this.glRedraw()}},{key:"collidable",get:function(){return this._collidable},set:function(e){e=!1!==e,this._collidable=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].collidable=e}},{key:"pickable",get:function(){return this.numPickableLayerPortions>0},set:function(e){e=!1!==e,this._pickable=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].pickable=e}},{key:"colorize",get:function(){return this._colorize},set:function(e){this._colorize=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].colorize=e}},{key:"opacity",get:function(){return this._opacity},set:function(e){this._opacity=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].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:pa(e.aabb,re.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||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){var t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}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=pa(e.positionsDecodeBoundary,re.mat4())),e.positions){var i=re.collapseAABB3();e.positionsDecodeMatrix=re.mat4(),re.expandAABB3Points3(i,e.positions),e.positionsCompressed=da(e.positions,i,e.positionsDecodeMatrix),e.aabb=i}else if(e.positionsCompressed){var r=re.collapseAABB3();e.positionsDecodeMatrix=new Float64Array(e.positionsDecodeMatrix),e.positionsCompressed=new Uint16Array(e.positionsCompressed),re.expandAABB3Points3(r,e.positionsCompressed),ji.decompressAABB(r,e.positionsDecodeMatrix),e.aabb=r}else if(e.buckets){var s=re.collapseAABB3();this._dtxBuckets[e.id]=e.buckets;for(var n=0,o=e.buckets.length;n<o;n++){var a=e.buckets[n];a.positions?re.expandAABB3Points3(s,a.positions):a.positionsCompressed&&re.expandAABB3Points3(s,a.positionsCompressed)}e.positionsDecodeMatrix&&ji.decompressAABB(s,e.positionsDecodeMatrix),e.aabb=s}if(e.colorsCompressed&&e.colorsCompressed.length>0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){for(var l=e.colors,u=new Uint8Array(l.length),A=0,c=l.length;A<c;A++)u[A]=255*l[A];e.colorsCompressed=u}if(e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=Ri(e.positions,e.indices,null,5):e.edgeIndices=Ri(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.uv){var h=ji.getUVBounds(e.uv),d=ji.compressUVs(e.uv,h.min,h.max);e.uvCompressed=d.quantized,e.uvDecodeMatrix=d.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 t=this,i=e.id;if(null!=i)if(this._textures[i])this.error("[createTexture] Texture already created: "+i);else{if(!e.src&&!e.image&&!e.buffers)return this.error("[createTexture] Param expected: `src`, `image' or 'buffers'"),null;var r=e.minFilter||1008;1006!==r&&1007!==r&&1008!==r&&1005!==r&&1004!==r&&(this.error("[createTexture] Unsupported value for 'minFilter' - \n supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, \n NearestMipMapLinearFilter and LinearMipmapLinearFilter. Defaulting to LinearMipmapLinearFilter."),r=1008);var s=e.magFilter||1006;1006!==s&&1003!==s&&(this.error("[createTexture] Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter."),s=1006);var n=e.wrapS||1e3;1001!==n&&1002!==n&&1e3!==n&&(this.error("[createTexture] Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),n=1e3);var o=e.wrapT||1e3;1001!==o&&1002!==o&&1e3!==o&&(this.error("[createTexture] Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),o=1e3);var a=e.wrapR||1e3;1001!==a&&1002!==a&&1e3!==a&&(this.error("[createTexture] Unsupported value for 'wrapR' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),a=1e3);var l=e.encoding||3e3;3e3!==l&&3001!==l&&(this.error("[createTexture] Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),l=3e3);var u=new Gn({gl:this.scene.canvas.gl,minFilter:r,magFilter:s,wrapS:n,wrapT:o,wrapR:a,encoding:l});if(e.preloadColor&&u.setPreloadColor(e.preloadColor),e.image){var A=e.image;A.crossOrigin="Anonymous",u.setImage(A,{minFilter:r,magFilter:s,wrapS:n,wrapT:o,wrapR:a,flipY:e.flipY,encoding:l})}else if(e.src){var c=e.src.split(".").pop();switch(c){case"jpeg":case"jpg":case"png":case"gif":var h=new Image;h.onload=function(){u.setImage(h,{minFilter:r,magFilter:s,wrapS:n,wrapT:o,wrapR:a,flipY:e.flipY,encoding:l}),t.glRedraw()},h.src=e.src;break;default:this._textureTranscoder?he.loadArraybuffer(e.src,(function(e){e.byteLength?t._textureTranscoder.transcode([e],u).then((function(){t.glRedraw()})):t.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(c,"')"))}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,u).then((function(){t.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[i]=new Qc({id:i,texture:u})}else this.error("[createTexture] Config missing: id")}},{key:"createTextureSet",value:function(e){var t=e.id;if(null!=t){if(!this._textureSets[t]){var i,r,s,n,o;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(!(i=this._textures[e.colorTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.colorTextureId," - ensure that you create it first with createTexture()"))}else i=this._textures.defaultColorTexture;if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(!(r=this._textures[e.metallicRoughnessTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.metallicRoughnessTextureId," - ensure that you create it first with createTexture()"))}else r=this._textures.defaultMetalRoughTexture;if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(!(s=this._textures[e.normalsTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.normalsTextureId," - ensure that you create it first with createTexture()"))}else s=this._textures.defaultNormalsTexture;if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(!(n=this._textures[e.emissiveTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.emissiveTextureId," - ensure that you create it first with createTexture()"))}else n=this._textures.defaultEmissiveTexture;if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(!(o=this._textures[e.occlusionTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.occlusionTextureId," - ensure that you create it first with createTexture()"))}else o=this._textures.defaultOcclusionTexture;var a=new Nc({id:t,model:this,colorTexture:i,metallicRoughnessTexture:r,normalsTexture:s,emissiveTexture:n,occlusionTexture:o});return this._textureSets[t]=a,a}this.error("[createTextureSet] Texture set already created: ".concat(t))}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 t;if(!e.parentTransformId||(t=this._transforms[e.parentTransformId])){var i=new vh({id:e.id,model:this,parent:t,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[i.id]=i,i}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._meshes[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||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){var t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}if(!e.buckets&&!e.indices&&"points"!==e.primitive)return e.indices=this._createDefaultIndices(numIndices),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 i=!(!this._dtxEnabled||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||e.textureSetId);if(e.origin=e.origin?re.addVec3(this._origin,e.origin,re.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position||e.quaternion){var r=e.scale||yh,s=e.position||bh;e.rotation?(re.eulerToQuaternion(e.rotation,"XYZ",_h),e.meshMatrix=re.composeMat4(s,_h,r,re.mat4())):e.meshMatrix=re.composeMat4(s,e.quaternion||wh,r,re.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=pa(e.positionsDecodeBoundary,re.mat4())),i){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])]):xh,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){var n=re.vec3(),o=[];je(e.positions,o,n)&&(e.positions=o,e.origin=re.addVec3(e.origin,n,n))}if(e.positions){var a=re.collapseAABB3();e.positionsDecodeMatrix=re.mat4(),re.expandAABB3Points3(a,e.positions),e.positionsCompressed=da(e.positions,a,e.positionsDecodeMatrix),e.aabb=a}else if(e.positionsCompressed){var l=re.collapseAABB3();re.expandAABB3Points3(l,e.positionsCompressed),ji.decompressAABB(l,e.positionsDecodeMatrix),e.aabb=l}if(e.buckets){for(var u=re.collapseAABB3(),A=0,c=e.buckets.length;A<c;A++){var h=e.buckets[A];h.positions?re.expandAABB3Points3(u,h.positions):h.positionsCompressed&&re.expandAABB3Points3(u,h.positionsCompressed)}e.positionsDecodeMatrix&&ji.decompressAABB(u,e.positionsDecodeMatrix),e.aabb=u}e.meshMatrix&&(re.AABB3ToOBB3(e.aabb,mh),re.transformOBB3(e.meshMatrix,mh),re.OBB3ToAABB3(mh,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=Ri(e.positions,e.indices,null,2):e.edgeIndices=Ri(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.buckets||(e.buckets=Ch(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=[];je(e.positions,d,gh)&&(e.positions=d,e.origin=re.addVec3(e.origin,gh,re.vec3()))}if(e.positions){var p=re.collapseAABB3();e.meshMatrix&&(re.transformPositions3(e.meshMatrix,e.positions,e.positions),e.meshMatrix=null),re.expandAABB3Points3(p,e.positions),e.aabb=p}else{var f=re.collapseAABB3();re.expandAABB3Points3(f,e.positionsCompressed),ji.decompressAABB(f,e.positionsDecodeMatrix),e.aabb=f}if(e.meshMatrix&&(re.AABB3ToOBB3(e.aabb,mh),re.transformOBB3(e.meshMatrix,mh),re.OBB3ToAABB3(mh,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=Ri(e.positions,e.indices,null,2):e.edgeIndices=Ri(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?re.addVec3(this._origin,e.origin,re.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;else if(e.scale||e.rotation||e.position||e.quaternion){var v=e.scale||yh,g=e.position||bh;e.rotation?(re.eulerToQuaternion(e.rotation,"XYZ",_h),e.meshMatrix=re.composeMat4(g,_h,v,re.mat4())):e.meshMatrix=re.composeMat4(g,e.quaternion||wh,v,re.mat4())}re.AABB3ToOBB3(e.geometry.aabb,mh),re.transformOBB3(e.meshMatrix,mh),e.aabb=re.OBB3ToAABB3(mh,re.AABB3())}if(!(!this._dtxEnabled||"triangles"!==e.geometry.primitive&&"solid"!==e.geometry.primitive&&"surface"!==e.geometry.primitive||e.textureSetId)){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])]):xh,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255;var m=this._dtxBuckets[e.geometryId];m||(m=Ch(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])]):xh,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._createMesh(e)}},{key:"_createMesh",value:function(e){var t=new go(this,e.id,e.color,e.opacity,e.transform,e.textureSet);t.pickId=this.scene._renderer.getPickID(t);var i=t.pickId,r=i>>24&255,s=i>>16&255,n=i>>8&255,o=255&i;switch(e.pickColor=new Uint8Array([o,n,s,r]),e.solid="solid"===e.primitive,t.origin=re.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}},{key:"_getNumPrimitives",value:function(e){var t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(var i=0,r=e.buckets.length;i<r;i++)t+=e.buckets[i].indices.length;break;case 1:t+=e.indices.length;break;case 0:t+=e.geometry.indices.length}return Math.round(t/3);case"points":switch(e.type){case 2:for(var s=0,n=e.buckets.length;s<n;s++)t+=e.buckets[s].positionsCompressed.length;break;case 1:t+=e.positions?e.positions.length:e.positionsCompressed.length;break;case 0:var o=e.geometry;t+=o.positions?o.positions.length:o.positionsCompressed.length}return Math.round(t);case"lines":case"line-strip":switch(e.type){case 2:for(var a=0,l=e.buckets.length;a<l;a++)t+=e.buckets[a].indices.length;break;case 1:t+=e.indices.length;break;case 0:t+=e.geometry.indices.length}return Math.round(t/2)}return 0}},{key:"_getDTXLayer",value:function(e){var t=e.origin,i=e.geometry?e.geometry.primitive:e.primitive,r=".".concat(i,".").concat(Math.round(t[0]),".").concat(Math.round(t[1]),".").concat(Math.round(t[2])),s=this._dtxLayers[r];if(s){if(s.canCreatePortion(e))return s;s.finalize(),delete this._dtxLayers[r],s=null}switch(i){case"triangles":case"solid":case"surface":s=new Oc(this,{layerIndex:0,origin:t});break;case"lines":s=new fA(this,{layerIndex:0,origin:t});break;default:return}return this._dtxLayers[r]=s,this.layerList.push(s),s}},{key:"_getVBOBatchingLayer",value:function(e){var t=this,i=e.origin;e.renderLayer;var r=e.positionsDecodeMatrix||e.positionsDecodeBoundary?this._createHashStringFromMatrix(e.positionsDecodeMatrix||e.positionsDecodeBoundary):"-",s=e.textureSetId||"-",n="".concat(Math.round(i[0]),".").concat(Math.round(i[1]),".").concat(Math.round(i[2]),".").concat(e.primitive,".").concat(r,".").concat(s),o=this._vboBatchingLayers[n];if(o)return o;for(var a=e.textureSet;!o;){switch(e.primitive){case"triangles":case"solid":case"surface":o=new Ma({model:t,textureSet:a,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:i,maxGeometryBatchSize:this._maxGeometryBatchSize,solid:"solid"===e.primitive,autoNormals:!0});break;case"lines":o=new Ul({model:t,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:i,maxGeometryBatchSize:this._maxGeometryBatchSize});break;case"points":o=new Pu({model:t,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:i,maxGeometryBatchSize:this._maxGeometryBatchSize})}var l=e.positionsCompressed?e.positionsCompressed.length:e.positions.length;("points"===e.primitive?o.canCreatePortion(l):o.canCreatePortion(l,e.indices.length))||(o.finalize(),delete this._vboBatchingLayers[n],o=null)}return this._vboBatchingLayers[n]=o,this.layerList.push(o),o}},{key:"_createHashStringFromMatrix",value:function(e){for(var t=e.join(""),i=0,r=0;r<t.length;r++){i=(i<<5)-i+t.charCodeAt(r),i|=0}return(i>>>0).toString(16)}},{key:"_getVBOInstancingLayer",value:function(e){var t=this,i=e.origin,r=e.textureSetId||"-",s=e.geometryId,n="".concat(Math.round(i[0]),".").concat(Math.round(i[1]),".").concat(Math.round(i[2]),".").concat(r,".").concat(s),o=this._vboInstancingLayers[n];if(o)return o;for(var a=e.textureSet,l=e.geometry;!o;)switch(l.primitive){case"triangles":case"surface":o=new ml({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":o=new ml({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":o=new ru({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":o=new Ju({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[n]=o,this.layerList.push(o),o}},{key:"createEntity",value:function(e){if(void 0===e.id?e.id=re.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=re.createUUID()),void 0!==e.meshIds){var t=0;this._visible&&!1!==e.visible&&(t|=We),this._pickable&&!1!==e.pickable&&(t|=Xe),this._culled&&!1!==e.culled&&(t|=Ke),this._clippable&&!1!==e.clippable&&(t|=Ye),this._collidable&&!1!==e.collidable&&(t|=Je),this._edges&&!1!==e.edges&&(t|=et),this._xrayed&&!1!==e.xrayed&&(t|=Ze),this._highlighted&&!1!==e.highlighted&&(t|=qe),this._selected&&!1!==e.selected&&(t|=$e),e.flags=t,this._createEntity(e)}else this.error("Config missing: meshIds")}},{key:"_createEntity",value:function(e){for(var t=[],i=0,r=e.meshIds.length;i<r;i++){var s=e.meshIds[i],n=this._meshes[s];n?n.parent?this.error('Mesh with ID "'.concat(s,'" already belongs to object with ID "').concat(n.parent.id,'" - ignoring this mesh')):(t.push(n),delete this._unusedMeshes[s]):this.error('Mesh with this ID not found: "'.concat(s,'" - ignoring this mesh'))}var o=new rt(this,e.isObject,e.id,t,e.flags,!0);this._entityList.push(o),this._entities[e.id]=o,this.numEntities++}},{key:"finalize",value:function(){if(!this.destroyed){this._createDummyEntityForUnusedMeshes();for(var e=0,t=this.layerList.length;e<t;e++){this.layerList[e].finalize()}this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._dtxLayers={},this._vboInstancingLayers={},this._vboBatchingLayers={};for(var i=0,r=this._entityList.length;i<r;i++){this._entityList[i]._finalize()}for(var s=0,n=this._entityList.length;s<n;s++){this._entityList[s]._finalize2()}this.layerList.sort((function(e,t){return e.sortId<t.sortId?-1:e.sortId>t.sortId?1:0}));for(var o=0,a=this.layerList.length;o<a;o++){this.layerList[o].layerIndex=o}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,t){}},{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 t=0,i=this.layerList.length;t<i;t++){var r=this.layerList[t];this._getActiveSectionPlanesForLayer(r)&&(e.visibleLayers[e.numVisibleLayers++]=t)}}},{key:"_createDummyEntityForUnusedMeshes",value:function(){var e=Object.keys(this._unusedMeshes);if(e.length>0){var t="".concat(this.id,"-dummyEntityForUnusedMeshes");this.warn('Creating dummy SceneModelEntity "'.concat(t,'" for unused SceneMeshes: [').concat(e.join(","),"]")),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}},{key:"_getActiveSectionPlanesForLayer",value:function(e){var t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,r=i.length,s=e.layerIndex*r;if(r>0)for(var n=0;n<r;n++){i[n].active?(t.sectionPlanesActivePerLayer[s+n]=!0,t.sectioned=!0):t.sectionPlanesActivePerLayer[s+n]=!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 t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.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 i=this.scene.selectedMaterial._state;i.fill&&(i.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),i.edges&&(i.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){var r=this.scene.highlightMaterial._state;r.fill&&(r.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),r.edges&&(r.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}},{key:"drawColorOpaque",value:function(e,t){for(var i=this.renderFlags,r=0,s=i.visibleLayers.length;r<s;r++){var n=i.visibleLayers[r];this.layerList[n].drawColorOpaque(i,e)}}},{key:"drawColorTransparent",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawColorTransparent(t,e)}}},{key:"drawDepth",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawDepth(t,e)}}},{key:"drawNormals",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawNormals(t,e)}}},{key:"drawSilhouetteXRayed",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawSilhouetteXRayed(t,e)}}},{key:"drawSilhouetteHighlighted",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawSilhouetteHighlighted(t,e)}}},{key:"drawSilhouetteSelected",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawSilhouetteSelected(t,e)}}},{key:"drawEdgesColorOpaque",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesColorOpaque(t,e)}}},{key:"drawEdgesColorTransparent",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesColorTransparent(t,e)}}},{key:"drawEdgesXRayed",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesXRayed(t,e)}}},{key:"drawEdgesHighlighted",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesHighlighted(t,e)}}},{key:"drawEdgesSelected",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesSelected(t,e)}}},{key:"drawOcclusion",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawOcclusion(t,e)}}},{key:"drawShadow",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawShadow(t,e)}}},{key:"setPickMatrices",value:function(e,t){if(0!==this._numVisibleLayerPortions)for(var i=this.renderFlags,r=0,s=i.visibleLayers.length;r<s;r++){var n=i.visibleLayers[r],o=this.layerList[n];o.setPickMatrices&&o.setPickMatrices(e,t)}}},{key:"drawPickMesh",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawPickMesh(t,e)}}},{key:"drawPickDepths",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawPickDepths(t,e)}}},{key:"drawPickNormals",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawPickNormals(t,e)}}},{key:"drawSnapInit",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i],n=this.layerList[s];n.drawSnapInit&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,n.drawSnapInit(t,e),e.snapPickLayerParams[e.snapPickLayerNumber]={origin:e.snapPickOrigin.slice(),coordinateScale:e.snapPickCoordinateScale.slice()})}}},{key:"drawSnap",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i],n=this.layerList[s];n.drawSnap&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,n.drawSnap(t,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 r=0,s=this.layerList.length;r<s;r++)this.layerList[r].destroy();this.layerList=[];for(var n=0,o=this._entityList.length;n<o;n++)this._entityList[n]._destroy();this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._meshes={},this._entities={},this.scene._aabbDirty=!0,this._isModel&&this.scene._deregisterModel(this),0!==_o&&0==--_o&&mo._clear(),f(w(i.prototype),"destroy",this).call(this)}}]),i}();function Ch(e,t,i){var r,s,n,o;if(t||i){var a=c(th({positionsCompressed:e.positionsCompressed,indices:e.indices,edgeIndices:e.edgeIndices}),3);r=a[0],s=a[1],n=a[2]}else r=e.positionsCompressed,s=e.indices,n=e.edgeIndices;i?o=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.positionsCompressed||[],s=sh(e.indices||[],t),n=ah(e.edgeIndices||[]);function o(e,t){if(e>t){var i=e;e=t,t=i}function r(i,r){return i!==e?e-i:r!==t?t-r:0}for(var s=0,o=(n.length>>1)-1;s<=o;){var a=o+s>>1,l=r(n[2*a],n[2*a+1]);if(l>0)s=a+1;else{if(!(l<0))return a;o=a-1}}return-s-1}var a=new Int32Array(n.length/2);a.fill(0);var l=r.length/3;if(l>8*(1<<t))return[e];var u=new Int32Array(l);u.fill(-1);var A=[];function c(){u.fill(-1);var e={positionsCompressed:[],indices:[],edgeIndices:[],maxNumPositions:(1<<t)-t,numPositions:0,bucketNumber:A.length};return A.push(e),e}for(var h=c(),d=0,p=s.length;d<p;d+=3){var f=0,v=s[d],g=s[d+1],m=s[d+2];if(-1===u[v]&&f++,-1===u[g]&&f++,-1===u[m]&&f++,f+h.numPositions>h.maxNumPositions&&(h=c()),h.bucketNumber>8)return[e];-1===u[v]&&(u[v]=h.numPositions++,h.positionsCompressed.push(r[3*v]),h.positionsCompressed.push(r[3*v+1]),h.positionsCompressed.push(r[3*v+2])),-1===u[g]&&(u[g]=h.numPositions++,h.positionsCompressed.push(r[3*g]),h.positionsCompressed.push(r[3*g+1]),h.positionsCompressed.push(r[3*g+2])),-1===u[m]&&(u[m]=h.numPositions++,h.positionsCompressed.push(r[3*m]),h.positionsCompressed.push(r[3*m+1]),h.positionsCompressed.push(r[3*m+2])),h.indices.push(u[v]),h.indices.push(u[g]),h.indices.push(u[m]);var _=void 0;(_=o(v,g))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(v,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(g,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]]))}var y=t/8*2,b=t/8,w=2*r.length+(s.length+n.length)*y,B=0;return r.length,A.forEach((function(e){B+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*b,e.positionsCompressed.length})),B>w?[e]:(i&&lh(A,e),A)}({positionsCompressed:r,indices:s,edgeIndices:n},r.length/3>65536?16:8):o=[{positionsCompressed:r,indices:s,edgeIndices:n}];return o}var Mh=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(r=t.call(this,e,s))._positions=s.positions||[],s.indices)r._indices=s.indices;else{r._indices=[];for(var n=0,o=r._positions.length/3-1;n<o;n+=2)r._indices.push(n),r._indices.push(n+1)}return r._sceneModel=new Ph(b(r),{isModel:!1}),r._sceneModel.createMesh({id:"linesMesh",primitive:"lines",positions:r._positions,indices:r._indices}),r._sceneModel.createEntity({meshIds:["linesMesh"],visible:s.visible,clippable:s.clippable,collidable:s.collidable}),r._sceneModel.finalize(),r.scene._lineSetCreated(b(r)),r}return C(i,[{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(){f(w(i.prototype),"destroy",this).call(this),this.scene._lineSetDestroyed(this)}}]),i}(),Eh=re.vec3(),Fh=re.vec3(),kh=re.vec3(),Ih=re.vec3(),Dh=function(e){g(i,Ue);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,"BCFViewpoints",e,s)).originatingSystem=s.originatingSystem||"xeokit.io",r.authoringTool=s.authoringTool||"xeokit.io",r}return C(i,[{key:"getViewpoint",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=this.viewer.scene,r=i.camera,s=i.realWorldOffset,n=!0===t.reverseClippingPlanes,o={},a=re.normalizeVec3(re.subVec3(r.look,r.eye,re.vec3())),l=r.eye,u=r.up;r.yUp&&(a=Lh(a),l=Lh(l),u=Lh(u));var A=Sh(re.addVec3(l,s));"ortho"===r.projection?o.orthogonal_camera={camera_view_point:A,camera_direction:Sh(a),camera_up_vector:Sh(u),view_to_world_scale:r.ortho.scale}:o.perspective_camera={camera_view_point:A,camera_direction:Sh(a),camera_up_vector:Sh(u),field_of_view:r.perspective.fov};var h=i.sectionPlanes;for(var d in h)if(h.hasOwnProperty(d)){var p=h[d];if(!p.active)continue;var f=p.pos,v=void 0;v=n?re.negateVec3(p.dir,re.vec3()):p.dir,r.yUp&&(f=Lh(f),v=Lh(v)),re.addVec3(f,s),f=Sh(f),v=Sh(v),o.clipping_planes||(o.clipping_planes=[]),o.clipping_planes.push({location:f,direction:v})}var g=i.lineSets;for(var m in g)if(g.hasOwnProperty(m)){var _=g[m];o.lines||(o.lines=[]);for(var y=_.positions,b=_.indices,w=0,B=b.length/2;w<B;w++){var x=b[2*w],P=b[2*w+1];o.lines.push({start_point:{x:y[3*x+0],y:y[3*x+1],z:y[3*x+2]},end_point:{x:y[3*P+0],y:y[3*P+1],z:y[3*P+2]}})}}var C=i.bitmaps;for(var M in C)if(C.hasOwnProperty(M)){var E=C[M],F=E.pos,k=E.normal,I=E.up;r.yUp&&(F=Lh(F),k=Lh(k),I=Lh(I)),re.addVec3(F,s),o.bitmaps||(o.bitmaps=[]),o.bitmaps.push({bitmap_type:E.type,bitmap_data:E.imageData,location:Sh(F),normal:Sh(k),up:Sh(I),height:E.height})}o.components={visibility:{view_setup_hints:{spaces_visible:!!t.spacesVisible,space_boundaries_visible:!!t.spaceBoundariesVisible,openings_visible:!!t.openingsVisible,spaces_translucent:!!t.spaces_translucent,space_boundaries_translucent:!!t.space_boundaries_translucent,openings_translucent:!!t.openings_translucent}}};var D=new Set(i.opacityObjectIds),S=new Set(i.xrayedObjectIds),T=new Set(i.colorizedObjectIds),L=Object.values(i.objects).filter((function(e){return D.has(e.id)||T.has(e.id)||S.has(e.id)})).reduce((function(t,r){var s,n=Uh(r.colorize);r.xrayed?(s=0===i.xrayMaterial.fillAlpha&&0!==i.xrayMaterial.edgeAlpha?.1:i.xrayMaterial.fillAlpha,n=(s=Math.round(255*s).toString(16).padStart(2,"0"))+n):D.has(r.id)&&(n=(s=Math.round(255*r.opacity).toString(16).padStart(2,"0"))+n),t[n]||(t[n]=[]);var o=r.id,a=r.originalSystemId,l={ifc_guid:a,originating_system:e.originatingSystem};return a!==o&&(l.authoring_tool_id=o),t[n].push(l),t}),{}),R=Object.entries(L).map((function(e){var t=c(e,2);return{color:t[0],components:t[1]}}));o.components.coloring=R;var U=i.objectIds,O=i.visibleObjects,N=i.visibleObjectIds,Q=U.filter((function(e){return!O[e]})),V=i.selectedObjectIds;return t.defaultInvisible||N.length<Q.length?(o.components.visibility.exceptions=this._createBCFComponents(N),o.components.visibility.default_visibility=!1):(o.components.visibility.exceptions=this._createBCFComponents(Q),o.components.visibility.default_visibility=!0),o.components.selection=this._createBCFComponents(V),o.components.translucency=this._createBCFComponents(i.xrayedObjectIds),!1!==t.snapshot&&(o.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})}),o}},{key:"_createBCFComponents",value:function(e){for(var t=this.viewer.scene,i=[],r=0,s=e.length;r<s;r++){var n=e[r],o=t.objects[n];if(o){var a={ifc_guid:o.originalSystemId,originating_system:this.originatingSystem};o.originalSystemId!==n&&(a.authoring_tool_id=n),i.push(a)}}return i}},{key:"setViewpoint",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var r=this.viewer,s=r.scene,n=s.camera,o=!1!==i.rayCast,a=!1!==i.immediate,l=!1!==i.reset,u=s.realWorldOffset,A=!0===i.reverseClippingPlanes;if(s.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){var t=Th(e.location,Eh),i=Th(e.direction,Eh);A&&re.negateVec3(i),re.subVec3(t,u),n.yUp&&(t=Rh(t),i=Rh(i)),new xn(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){var c=[],h=[],d=0;e.lines.forEach((function(e){e.start_point&&e.end_point&&(c.push(e.start_point.x),c.push(e.start_point.y),c.push(e.start_point.z),c.push(e.end_point.x),c.push(e.end_point.y),c.push(e.end_point.z),h.push(d++),h.push(d++))})),new Mh(s,{positions:c,indices:h,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){var t=e.bitmap_type||"jpg",i=e.bitmap_data,r=Th(e.location,Fh),o=Th(e.normal,kh),a=Th(e.up,Ih),l=e.height||1;t&&i&&r&&o&&a&&(n.yUp&&(r=Rh(r),o=Rh(o),a=Rh(a)),new ho(s,{src:i,type:t,pos:r,normal:o,up:a,clippable:!1,collidable:!0,height:l}))})),l&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!1}))}))):(s.setObjectsVisible(s.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!0}))})));var p=e.components.visibility.view_setup_hints;p&&(!1===p.spaces_visible&&s.setObjectsVisible(r.metaScene.getObjectIDsByType("IfcSpace"),!1),void 0!==p.spaces_translucent&&s.setObjectsXRayed(r.metaScene.getObjectIDsByType("IfcSpace"),!0),p.space_boundaries_visible,!1===p.openings_visible&&s.setObjectsVisible(r.metaScene.getObjectIDsByType("IfcOpening"),!0),p.space_boundaries_translucent,void 0!==p.openings_translucent&&s.setObjectsXRayed(r.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.selected=!0}))}))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.xrayed=!0}))}))),e.components.coloring&&e.components.coloring.forEach((function(e){var r=e.color,s=0,n=!1;8===r.length&&((s=parseInt(r.substring(0,2),16)/256)<=1&&s>=.95&&(s=1),r=r.substring(2),n=!0);var o=[parseInt(r.substring(0,2),16)/256,parseInt(r.substring(2,4),16)/256,parseInt(r.substring(4,6),16)/256];e.components.map((function(e){return t._withBCFComponent(i,e,(function(e){e.colorize=o,n&&(e.opacity=s)}))}))}))}if(e.perspective_camera||e.orthogonal_camera){var f,v,g,m;if(e.perspective_camera?(f=Th(e.perspective_camera.camera_view_point,Eh),v=Th(e.perspective_camera.camera_direction,Eh),g=Th(e.perspective_camera.camera_up_vector,Eh),n.perspective.fov=e.perspective_camera.field_of_view,m="perspective"):(f=Th(e.orthogonal_camera.camera_view_point,Eh),v=Th(e.orthogonal_camera.camera_direction,Eh),g=Th(e.orthogonal_camera.camera_up_vector,Eh),n.ortho.scale=e.orthogonal_camera.view_to_world_scale,m="ortho"),re.subVec3(f,u),n.yUp&&(f=Rh(f),v=Rh(v),g=Rh(g)),o){var _=s.pick({pickSurface:!0,origin:f,direction:v});v=_?_.worldPos:re.addVec3(f,v,Eh)}else v=re.addVec3(f,v,Eh);a?(n.eye=f,n.look=v,n.up=g,n.projection=m):r.cameraFlight.flyTo({eye:f,look:v,up:g,duration:i.duration,projection:m})}}}},{key:"_withBCFComponent",value:function(e,t,i){var r=this.viewer,s=r.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){var n=t.authoring_tool_id,o=s.objects[n];if(o)return void i(o);if(e.updateCompositeObjects)if(r.metaScene.metaObjects[n])return void s.withObjects(r.metaScene.getObjectIDsInSubtree(n),i)}if(t.ifc_guid){var a=t.ifc_guid,l=s.objects[a];if(l)return void i(l);if(e.updateCompositeObjects)if(r.metaScene.metaObjects[a])return void s.withObjects(r.metaScene.getObjectIDsInSubtree(a),i);Object.keys(s.models).forEach((function(t){var n=re.globalizeObjectId(t,a),o=s.objects[n];o?i(o):e.updateCompositeObjects&&r.metaScene.metaObjects[n]&&s.withObjects(r.metaScene.getObjectIDsInSubtree(n),i)}))}}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this)}}]),i}();function Sh(e){return{x:e[0],y:e[1],z:e[2]}}function Th(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function Lh(e){return new Float64Array([e[0],-e[2],e[1]])}function Rh(e){return new Float64Array([e[0],e[2],-e[1]])}function Uh(e){var t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0")}var Oh=re.vec3(),Nh=function(e,t,i,r){var s=e-i,n=t-r;return Math.sqrt(s*s+n*n)};var Qh=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(r=t.call(this,e.viewer.scene,s)).plugin=e,r._container=s.container,!r._container)throw"config missing: container";r._eventSubs={};var n=r.plugin.viewer.scene;r._originWorld=re.vec3(),r._targetWorld=re.vec3(),r._wp=new Float64Array(24),r._vp=new Float64Array(24),r._pp=new Float64Array(24),r._cp=new Float64Array(8),r._xAxisLabelCulled=!1,r._yAxisLabelCulled=!1,r._zAxisLabelCulled=!1,r._color=s.color||r.plugin.defaultColor;var o=s.onMouseOver?function(e){s.onMouseOver(e,b(r)),r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,a=s.onMouseLeave?function(e){s.onMouseLeave(e,b(r)),r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,l=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},u=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},A=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},c=s.onContextMenu?function(e){s.onContextMenu(e,b(r))}:null,h=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};return r._originDot=new ut(n,s.origin,r._container,{fillColor:r._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._targetDot=new ut(n,s.target,r._container,{fillColor:r._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._lengthWire=new ht(r._container,{color:r._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._xAxisWire=new ht(r._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._yAxisWire=new ht(r._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._zAxisWire=new ht(r._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._lengthLabel=new dt(r._container,{fillColor:r._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._xAxisLabel=new dt(r._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._yAxisLabel=new dt(r._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._zAxisLabel=new dt(r._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._measurementOrientation="Horizontal",r._wpDirty=!1,r._vpDirty=!1,r._cpDirty=!1,r._sectionPlanesDirty=!0,r._visible=!1,r._originVisible=!1,r._targetVisible=!1,r._wireVisible=!1,r._axisVisible=!1,r._xAxisVisible=!1,r._yAxisVisible=!1,r._zAxisVisible=!1,r._axisEnabled=!0,r._xLabelEnabled=!1,r._yLabelEnabled=!1,r._zLabelEnabled=!1,r._lengthLabelEnabled=!1,r._labelsVisible=!1,r._labelsOnWires=!1,r._clickable=!1,r._originDot.on("worldPos",(function(e){r._originWorld.set(e||[0,0,0]),r._wpDirty=!0,r._needUpdate(0)})),r._targetDot.on("worldPos",(function(e){r._targetWorld.set(e||[0,0,0]),r._wpDirty=!0,r._needUpdate(0)})),r._onViewMatrix=n.camera.on("viewMatrix",(function(){r._vpDirty=!0,r._needUpdate(0)})),r._onProjMatrix=n.camera.on("projMatrix",(function(){r._cpDirty=!0,r._needUpdate()})),r._onCanvasBoundary=n.canvas.on("boundary",(function(){r._cpDirty=!0,r._needUpdate(0)})),r._onMetricsUnits=n.metrics.on("units",(function(){r._cpDirty=!0,r._needUpdate()})),r._onMetricsScale=n.metrics.on("scale",(function(){r._cpDirty=!0,r._needUpdate()})),r._onMetricsOrigin=n.metrics.on("origin",(function(){r._cpDirty=!0,r._needUpdate()})),r._onSectionPlaneUpdated=n.on("sectionPlaneUpdated",(function(){r._sectionPlanesDirty=!0,r._needUpdate()})),r.approximate=s.approximate,r.visible=s.visible,r.originVisible=s.originVisible,r.targetVisible=s.targetVisible,r.wireVisible=s.wireVisible,r.axisVisible=s.axisVisible,r.xAxisVisible=s.xAxisVisible,r.yAxisVisible=s.yAxisVisible,r.zAxisVisible=s.zAxisVisible,r.xLabelEnabled=s.xLabelEnabled,r.yLabelEnabled=s.yLabelEnabled,r.zLabelEnabled=s.zLabelEnabled,r.lengthLabelEnabled=s.lengthLabelEnabled,r.labelsVisible=s.labelsVisible,r.labelsOnWires=s.labelsOnWires,r.useRotationAdjustment=s.useRotationAdjustment,r}return C(i,[{key:"_update",value:function(){if(this._visible){var e=this.plugin.viewer.scene;if(this._wpDirty&&(this._measurementOrientation=function(e,t,i){return Math.abs(t[1]-e[1])>i?"Vertical":"Horizontal"}(this._originWorld,this._targetWorld,0),"Vertical"===this._measurementOrientation&&this.useRotationAdjustment?(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._originWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._originWorld[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._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&&(re.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 t=this._originDot.viewPos[2],i=this._targetDot.viewPos[2];if(t>-.3||i>-.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){re.transformPositions4(e.camera.project.matrix,this._vp,this._pp);for(var r=this._pp,s=this._cp,n=e.canvas.canvas.getBoundingClientRect(),o=this._container.getBoundingClientRect(),a=n.top-o.top,l=n.left-o.left,u=e.canvas.boundary,A=u[2],c=u[3],h=0,d=this.plugin.viewer.scene.metrics,p=d.scale,f=d.units,v=d.unitsInfo[f].abbrev,g=0,m=r.length;g<m;g+=4)s[h]=l+Math.floor((1+r[g+0]/r[g+3])*A/2),s[h+1]=a+Math.floor((1-r[g+1]/r[g+3])*c/2),h+=2;if(this._lengthWire.setStartAndEnd(s[0],s[1],s[6],s[7]),this._xAxisWire.setStartAndEnd(s[0],s[1],s[2],s[3]),this._yAxisWire.setStartAndEnd(s[2],s[3],s[4],s[5]),this._zAxisWire.setStartAndEnd(s[4],s[5],s[6],s[7]),this.labelsVisible){if(this._lengthLabel.setPosOnWire(s[0],s[1],s[6],s[7]),this.labelsOnWires)this._xAxisLabel.setPosOnWire(s[0],s[1],s[2],s[3]),this._yAxisLabel.setPosOnWire(s[2],s[3],s[4],s[5]),this._zAxisLabel.setPosOnWire(s[4],s[5],s[6],s[7]);else{var _=35;this._xAxisLabel.setPosOnWire(s[0],s[1]+_,s[6],s[7]+_),_+=35,this._yAxisLabel.setPosOnWire(s[0],s[1]+_,s[6],s[7]+_),_+=35,this._zAxisLabel.setPosOnWire(s[0],s[1]+_,s[6],s[7]+_)}var y=this._approximate?" ~ ":" = ";this._length=Math.abs(re.lenVec3(re.subVec3(this._targetWorld,this._originWorld,Oh))),this._lengthLabel.setText(y+(this._length*p).toFixed(2)+v);var b=Math.abs(Nh(s[0],s[1],s[2],s[3])),w=Math.abs(Nh(s[2],s[3],s[4],s[5])),B=Math.abs(Nh(s[4],s[5],s[6],s[7])),x=this.plugin.labelMinAxisLength;this.labelsOnWires?(this._xAxisLabelCulled=b<x,this._yAxisLabelCulled=w<x,this._zAxisLabelCulled=B<x):(this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1),this._xAxisLabelCulled?this._xAxisLabel.setCulled(!0):(this._xAxisLabel.setText(y+Math.abs((this._targetWorld[0]-this._originWorld[0])*p).toFixed(2)+v),this._xAxisLabel.setCulled(!this.axisVisible)),this._yAxisLabelCulled?this._yAxisLabel.setCulled(!0):(this._yAxisLabel.setText(y+Math.abs((this._targetWorld[1]-this._originWorld[1])*p).toFixed(2)+v),this._yAxisLabel.setCulled(!this.axisVisible)),this._zAxisLabelCulled?this._zAxisLabel.setCulled(!0):("Vertical"===this._measurementOrientation&&this.useRotationAdjustment?(this._zAxisLabel.setPrefix(""),this._zAxisLabel.setText(y+Math.abs(re.lenVec3(re.subVec3(this._targetWorld,[this._originWorld[0],this._targetWorld[1],this._originWorld[2]],Oh))*p).toFixed(2)+v)):(this._zAxisLabel.setPrefix("Z"),this._zAxisLabel.setText(y+Math.abs((this._targetWorld[2]-this._originWorld[2])*p).toFixed(2)+v)),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 t=this.scene._sectionPlanesState.sectionPlanes,i=0,r=t.length;i<r;i++){var s=t[i];if(re.planeClipsPositions3(s.pos,s.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:"origin",get:function(){return this._originDot}},{key:"target",get:function(){return this._targetDot}},{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),this._lengthLabel.setFillColor(e)}},{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&&this._lengthLabelEnabled);var t=this._visible&&this._axisVisible&&this._xAxisVisible,i=this._visible&&this._axisVisible&&this._yAxisVisible,r=this._visible&&this._axisVisible&&this._zAxisVisible;this._xAxisWire.setVisible(t),this._yAxisWire.setVisible(i),this._zAxisWire.setVisible(r),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._EnabledVisible),this._yAxisLabel.setVisible(i&&!this._yAxisLabelCulled&&this._yLabelEnabled),this._zAxisLabel.setVisible(r&&!this._zAxisLabelCulled&&this._zLabelEnabled),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 t=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(t&&this._xAxisVisible),this._yAxisWire.setVisible(t&&this._yAxisVisible),this._zAxisWire.setVisible(t&&this._zAxisVisible),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._xAxisVisible&&this._xLabelEnabled),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._xAxisVisible&&this._yLabelEnabled),this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._xAxisVisible&&this._zLabelEnabled),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 t=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(t&&this._xAxisVisible),this._yAxisWire.setVisible(t&&this._yAxisVisible),this._zAxisWire.setVisible(t&&this._zAxisVisible),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._xAxisVisible),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._yAxisVisible),this._zAxisLabel.setVisible(t&&!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 t=this._visible&&this._axisVisible&&this._xAxisVisible&&this._axisEnabled;this._xAxisWire.setVisible(t),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._xLabelEnabled),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 t=this._visible&&this._axisVisible&&this._yAxisVisible&&this._axisEnabled;this._yAxisWire.setVisible(t),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._yLabelEnabled),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 t=this._visible&&this._axisVisible&&this._zAxisVisible&&this._axisEnabled;this._zAxisWire.setVisible(t),this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._zLabelEnabled),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 t=this._visible&&this._wireVisible;this._lengthLabel.setVisible(t&&this._lengthLabelEnabled),this._lengthWire.setVisible(t)}},{key:"labelsVisible",get:function(){return this._labelsVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLabelsVisible,this._labelsVisible=e;var t=this._visible&&this._labelsVisible;this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._xLabelEnabled),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._yLabelEnabled),this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._zLabelEnabled),this._lengthLabel.setVisible(t&&this._lengthLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"xLabelEnabled",get:function(){return this._xLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultXLabelEnabled,this._xLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._xLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"yLabelEnabled",get:function(){return this._yLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultYLabelEnabled,this._yLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._yLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"zLabelEnabled",get:function(){return this._zLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultZLabelEnabled,this._zLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._zLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"lengthLabelEnabled",get:function(){return this._lengthLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLengthLabelEnabled,this._lengthLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._lengthLabel.setVisible(t&&!this._lengthAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._lengthLabelEnabled),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(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Vh=function(e){g(i,Ce);var t=_(i);function i(){return x(this,i),t.apply(this,arguments)}return C(i,[{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:"currentMeasurement",get:function(){return null}},{key:"destroy",value:function(){}}]),i}(),Hh=function(e){g(i,Vh);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e.viewer.scene))._canvasToPagePos=s.canvasToPagePos,r.pointerLens=s.pointerLens,r._active=!1,r._currentDistanceMeasurement=null,r._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},r._initMarkerDiv(),r._onCameraControlHoverSnapOrSurface=null,r._onCameraControlHoverSnapOrSurfaceOff=null,r._onMouseDown=null,r._onMouseUp=null,r._onCanvasTouchStart=null,r._onCanvasTouchEnd=null,r._snapping=!1!==s.snapping,r._mouseState=0,r._attachPlugin(e,s),r}return C(i,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myMarkerDiv");var t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){if(this._markerDiv){var e=document.getElementById("myMarkerDiv");e.parentNode.removeChild(e),this._markerDiv=null}}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=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 t=this.distanceMeasurementsPlugin,i=this.scene,r=t.viewer.cameraControl,s=i.canvas.canvas;i.input;var n,o,a=!1,l=re.vec3(),u=re.vec2(),A=null;this._mouseState=0;var c=function e(t){return t.offsetTop+(t.offsetParent&&t.offsetParent!==s.parentNode&&e(t.offsetParent))},h=function e(t){return t.offsetLeft+(t.offsetParent&&t.offsetParent!==s.parentNode&&e(t.offsetParent))},d=re.vec2();this._onCameraControlHoverSnapOrSurface=r.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(function(t){var i=t.snappedCanvasPos||t.canvasPos;a=!0,l.set(t.worldPos),u.set(t.canvasPos),0===e._mouseState?(e._canvasToPagePos?(e._canvasToPagePos(s,i,d),e._markerDiv.style.left="".concat(d[0]-5,"px"),e._markerDiv.style.top="".concat(d[1]-5,"px")):(e._markerDiv.style.left="".concat(h(s)+i[0]-5,"px"),e._markerDiv.style.top="".concat(c(s)+i[1]-5,"px")),e._markerDiv.style.background="pink",t.snappedToVertex||t.snappedToEdge?(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.snappedCanvasPos||t.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=t.canvasPos,e.pointerLens.snappedCanvasPos=t.canvasPos,e.pointerLens.snapped=!1),e._markerDiv.style.background="pink",e._markerDiv.style.border="2px solid red"),A=t.entity):(e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px"),s.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=l.slice(),e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px")})),s.addEventListener("mousedown",this._onMouseDown=function(e){1===e.which&&(n=e.clientX,o=e.clientY)}),s.addEventListener("mouseup",this._onMouseUp=function(i){1===i.which&&(i.clientX>n+20||i.clientX<n-20||i.clientY>o+20||i.clientY<o-20||(e._currentDistanceMeasurement?a?(e._currentDistanceMeasurement.target.entity=A,A=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,A=null):a&&(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:l.slice(),entity:A},target:{worldPos:l.slice(),entity:A},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=A,A=null,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement))))}),this._onCameraControlHoverSnapOrSurfaceOff=r.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",(function(t){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.snappedCanvasPos||t.canvasPos),a=!1,e._markerDiv.style.left="-100px",e._markerDiv.style.top="-100px",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.axisVisible=!1),s.style.cursor="default"})),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1);var e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);var t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onCameraControlHoverSnapOrSurface),t.off(this._onCameraControlHoverSnapOrSurfaceOff),this._active=!1}}},{key:"reset",value:function(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._mouseState=0)}},{key:"currentMeasurement",get:function(){return this._currentDistanceMeasurement}},{key:"destroy",value:function(){this.deactivate(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),jh=function(e){g(i,Ue);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,"DistanceMeasurements",e))._pointerLens=s.pointerLens,r._container=s.container||document.body,r._defaultControl=null,r._measurements={},r.labelMinAxisLength=s.labelMinAxisLength,r.defaultVisible=!1!==s.defaultVisible,r.defaultOriginVisible=!1!==s.defaultOriginVisible,r.defaultTargetVisible=!1!==s.defaultTargetVisible,r.defaultWireVisible=!1!==s.defaultWireVisible,r.defaultXLabelEnabled=!1!==s.defaultXLabelEnabled,r.defaultYLabelEnabled=!1!==s.defaultYLabelEnabled,r.defaultZLabelEnabled=!1!==s.defaultZLabelEnabled,r.defaultLengthLabelEnabled=!1!==s.defaultLengthLabelEnabled,r.defaultLabelsVisible=!1!==s.defaultLabelsVisible,r.defaultAxisVisible=!1!==s.defaultAxisVisible,r.defaultXAxisVisible=!1!==s.defaultXAxisVisible,r.defaultYAxisVisible=!1!==s.defaultYAxisVisible,r.defaultZAxisVisible=!1!==s.defaultZAxisVisible,r.defaultColor=void 0!==s.defaultColor?s.defaultColor:"#00BBFF",r.zIndex=s.zIndex||1e4,r.defaultLabelsOnWires=!1!==s.defaultLabelsOnWires,r.useRotationAdjustment=void 0!==s.useRotationAdjustment&&!1!==s.useRotationAdjustment,r._onMouseOver=function(e,t){r.fire("mouseOver",{plugin:b(r),distanceMeasurement:t,measurement:t,event:e})},r._onMouseLeave=function(e,t){r.fire("mouseLeave",{plugin:b(r),distanceMeasurement:t,measurement:t,event:e})},r._onContextMenu=function(e,t){r.fire("contextMenu",{plugin:b(r),distanceMeasurement:t,measurement:t,event:e})},r}return C(i,[{key:"getContainerElement",value:function(){return this._container}},{key:"send",value:function(e,t){}},{key:"pointerLens",get:function(){return this._pointerLens}},{key:"control",get:function(){return this._defaultControl||(this._defaultControl=new Hh(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:"useRotationAdjustment",get:function(){return this._useRotationAdjustment},set:function(e){e=void 0!==e&&Boolean(e),this._useRotationAdjustment=e}},{key:"createMeasurement",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.viewer.scene.components[t.id]&&(this.error("Viewer scene component with this ID already exists: "+t.id),delete t.id);var i=t.origin,r=t.target,s=new Qh(this,{id:t.id,plugin:this,container:this._container,origin:{entity:i.entity,worldPos:i.worldPos},target:{entity:r.entity,worldPos:r.worldPos},visible:t.visible,wireVisible:t.wireVisible,axisVisible:!1!==t.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==t.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==t.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==t.zAxisVisible&&!1!==this.defaultZAxisVisible,xLabelEnabled:!1!==t.xLabelEnabled&&!1!==this.defaultXLabelEnabled,yLabelEnabled:!1!==t.yLabelEnabled&&!1!==this.defaultYLabelEnabled,zLabelEnabled:!1!==t.zLabelEnabled&&!1!==this.defaultZLabelEnabled,lengthLabelEnabled:!1!==t.lengthLabelEnabled&&!1!==this.defaultLengthLabelEnabled,labelsVisible:!1!==t.labelsVisible&&!1!==this.defaultLabelsVisible,useRotationAdjustment:this.useRotationAdjustment,originVisible:t.originVisible,targetVisible:t.targetVisible,color:t.color,labelsOnWires:!1!==t.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[s.id]=s,s.clickable=!0,s.on("destroyed",(function(){delete e._measurements[s.id]})),this.fire("measurementCreated",s),s}},{key:"destroyMeasurement",value:function(e){var t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}},{key:"setLabelsShown",value:function(e){for(var t=0,i=Object.entries(this.measurements);t<i.length;t++){var r=c(i[t],2);r[0];r[1].labelShown=e}}},{key:"setAxisVisible",value:function(e){for(var t=0,i=Object.entries(this.measurements);t<i.length;t++){var r=c(i[t],2);r[0];r[1].axisVisible=e}this.defaultAxisVisible=e}},{key:"getAxisVisible",value:function(){return this.defaultAxisVisible}},{key:"clear",value:function(){for(var e=Object.keys(this._measurements),t=0,i=e.length;t<i;t++)this.destroyMeasurement(e[t])}},{key:"destroy",value:function(){this.clear(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Gh=function(e){g(i,Vh);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(r=t.call(this,e.viewer.scene)).pointerLens=s.pointerLens,r.pointerCircle=new Re(e.viewer),r._active=!1;var n=document.createElement("div"),o=r.scene.canvas.canvas;return o.parentNode.insertBefore(n,o),n.style.background="black",n.style.border="2px solid blue",n.style.borderRadius="10px",n.style.width="5px",n.style.height="5px",n.style.margin="-200px -200px",n.style.zIndex="100",n.style.position="absolute",n.style.pointerEvents="none",r.markerDiv=n,r._currentDistanceMeasurement=null,r._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},r._onCanvasTouchStart=null,r._onCanvasTouchEnd=null,r._longTouchTimeoutMs=300,r._snapping=!1!==s.snapping,r._touchState=0,r._attachPlugin(e,s),r}return C(i,[{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=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 t=this.plugin,i=this.scene,r=i.canvas.canvas;t.pointerLens;var s=re.vec3(),n=20,o=null;this._touchState=0;var a=re.vec2(),l=re.vec2(),u=re.vec2(),A=null,c=function(){e.plugin.viewer.cameraControl.active=!1},h=function(){e.plugin.viewer.cameraControl.active=!0};r.addEventListener("touchstart",this._onCanvasTouchStart=function(r){var u=r.touches.length;if(1===u){var d=r.touches[0],p=d.clientX,f=d.clientY;switch(a.set([p,f]),l.set([p,f]),e._touchState){case 0:if(1!==u&&null!==o)return o&&(clearTimeout(o),o=null),e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),h(),void(e._touchState=0);var v=i.pick({canvasPos:l,snapping:e._snapping,snapToEdge:e._snapping});if(v&&v.snapped)s.set(v.worldPos),e.pointerCircle.start(v.snappedCanvasPos);else{var g=i.pick({canvasPos:l,pickSurface:!0});if(!g||!g.worldPos)return;s.set(g.worldPos),e.pointerCircle.start(g.canvasPos)}o=setTimeout((function(){1!==u||l[0]>a[0]+n||l[0]<a[0]-n||l[1]>a[1]+n||l[1]<a[1]-n||(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=a,e.pointerLens.cursorPos=a),e.pointerLens&&(e.pointerLens.canvasPos=l,e.pointerLens.snapped=!1),e.pointerLens&&(e.pointerLens.cursorPos=v.canvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=s:(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:s,entity:v.entity},target:{worldPos:s,entity:v.entity}}),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,c())}),e._longTouchTimeoutMs),e._touchState=1,A=d.identifier;break;case 3:if(1!==u&&null!==o)return clearTimeout(o),void(o=null);1===u&&(o=setTimeout((function(){if(o=null,!(1!==u||l[0]>a[0]+n||l[0]<a[0]-n||l[1]>a[1]+n||l[1]<a[1]-n)){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=a,e.pointerLens.snapped=!1);var t=i.pick({canvasPos:l,snapToVertex:e._snapping,snapToEdge:e._snapping});if(t&&t.snapped)e.pointerLens&&(e.pointerLens.cursorPos=t.snappedCanvasPos,e.pointerLens.snapped=!0),e.pointerCircle.start(t.snappedCanvasPos),s.set(t.worldPos),e._currentDistanceMeasurement.target.worldPos=t.worldPos,e._currentDistanceMeasurement.target.entity=t.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement);else{var r=i.pick({canvasPos:l,pickSurface:!0});r&&r.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=r.canvasPos,e.pointerLens.snapped=!1),e.pointerCircle.start(r.canvasPos),s.set(r.worldPos),e._currentDistanceMeasurement.target.worldPos=r.worldPos,e._currentDistanceMeasurement.target.entity=r.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,c()}}),e._longTouchTimeoutMs),e._touchState=4),A=d.identifier;break;default:return null!==o&&(clearTimeout(o),o=null),void(e._touchState=7)}}else o&&(clearTimeout(o),o=null)},{passive:!0}),r.addEventListener("touchmove",(function(r){e.pointerCircle.stop();var n=r.touches.length;if(1===n&&1===r.changedTouches.length){var a,u,c=r.touches[0],h=c.clientX,d=c.clientY;if(c.identifier===A)switch(l.set([h,d]),e._touchState){case 2:e.pointerLens&&(e.pointerLens.canvasPos=l),(a=i.pick({canvasPos:l,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&a.snapped?(e.pointerLens&&(e.pointerLens.snappedCanvasPos=a.snappedCanvasPos,e.pointerLens.snapped=!0),s.set(a.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=a.worldPos:(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:a.worldPos,entity:a.entity},target:{worldPos:a.worldPos,entity:a.entity}}),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)):(u=i.pick({canvasPos:l,pickSurface:!0}))&&u.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=u.canvasPos,e.pointerLens.snapped=!1),s.set(u.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=u.worldPos:(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:u.worldPos,entity:u.entity},target:{worldPos:u.worldPos,entity:u.entity}}),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!==n&&null!==o)return clearTimeout(o),o=null,e.pointerLens&&(e.pointerLens.visible=!1),void(e._touchState=7);e.pointerLens&&(e.pointerLens.canvasPos=l),(a=i.pick({canvasPos:l,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&a.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=a.snappedCanvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement.target.worldPos=a.worldPos,e._currentDistanceMeasurement.target.entity=a.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0):(u=i.pick({canvasPos:l,pickSurface:!0}))&&u.worldPos&&(e.pointerLens&&(e.pointerLens.cursorPos=u.canvasPos,e.pointerLens.snapped=!1),e._currentDistanceMeasurement.target.worldPos=u.worldPos,e._currentDistanceMeasurement.target.entity=u.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0),e._touchState=5}}else o&&(clearTimeout(o),o=null)}),{passive:!0}),r.addEventListener("touchend",this._onCanvasTouchEnd=function(r){e.pointerCircle.stop();var s=r.changedTouches.length;if(1===s){var c=r.changedTouches[0],d=c.clientX,p=c.clientY;if(c.identifier===A)switch(o&&(clearTimeout(o),o=null),u.set([d,p]),e._touchState){case 1:if(1!==s||d>a[0]+n||d<a[0]-n||p>a[1]+n||p<a[1]-n)return void(e._touchState=0);var f=i.pick({canvasPos:l,pickSurface:!0});f&&f.worldPos?(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:f.worldPos,entity:f.entity},target:{worldPos:f.worldPos,entity:f.entity}}),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._touchState=3,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):(e._currentDistanceMeasurement&&e._currentDistanceMeasurement.destroy(),e._touchState=0),h();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),h();break;case 4:if(1!==s||d>a[0]+n||d<a[0]-n||p>a[1]+n||p<a[1]-n)return void(e._touchState=3);var v=i.pick({canvasPos:l,pickSurface:!0});v&&v.worldPos?(e._currentDistanceMeasurement.target.worldPos=v.worldPos,e._currentDistanceMeasurement.target.entity=v.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e._currentDistanceMeasurement.xAxisVisible=!0,e._currentDistanceMeasurement.yAxisVisible=!0,e._currentDistanceMeasurement.zAxisVisible=!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,h();break;case 5:console.log("long touch"),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),h()}}},{passive:!0}),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.plugin.pointerLens&&(this.plugin.pointerLens.visible=!1),this.reset();var e=this.plugin.viewer.scene.canvas.canvas;e.removeEventListener("touchstart",this._onCanvasTouchStart),e.removeEventListener("touchend",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),this._mouseState=0)}},{key:"currentMeasurement",get:function(){return this._currentDistanceMeasurement}},{key:"destroy",value:function(){this.deactivate(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),zh=function(e){g(i,Ce);var t=_(i);function i(e,r,s,n){var o;x(this,i);var a=e.plugin.viewer;o=t.call(this,a.scene);var l=ct({viewer:a,handleMouseEvents:s,handleTouchEvents:n,pointerLens:r.pointerLens,dots:[e.origin,e.target],ray2WorldPos:function(e,t,i){return function e(t){var r=a.scene.pick({canvasPos:i,snapToEdge:t,snapToVertex:t,pickSurface:!0});return r&&r.worldPos?r.worldPos:t&&e(!1)}(!!r.snapping)},onEnd:function(e,t){var i=!re.compareVec3(e,t.worldPos);return i&&o.fire("edited"),i}}),u=e.on("destroyed",l);return o._deactivate=function(){e.off("destroyed",u),l()},o}return C(i,[{key:"deactivate",value:function(){this._deactivate(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Wh=function(e){g(i,zh);var t=_(i);function i(e,r){return x(this,i),t.call(this,e,r,!0,!1)}return C(i)}(),Kh=function(e){g(i,zh);var t=_(i);function i(e,r){return x(this,i),t.call(this,e,r,!1,!0)}return C(i)}(),Xh=function(e){g(i,Ue);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(r=t.call(this,"FastNav",e))._hideColorTexture=!1!==s.hideColorTexture,r._hidePBR=!1!==s.hidePBR,r._hideSAO=!1!==s.hideSAO,r._hideEdges=!1!==s.hideEdges,r._hideTransparentObjects=!!s.hideTransparentObjects,r._scaleCanvasResolution=!!s.scaleCanvasResolution,r._defaultScaleCanvasResolutionFactor=s.defaultScaleCanvasResolutionFactor||1,r._scaleCanvasResolutionFactor=s.scaleCanvasResolutionFactor||.6,r._delayBeforeRestore=!1!==s.delayBeforeRestore,r._delayBeforeRestoreSeconds=s.delayBeforeRestoreSeconds||.5;var n=1e3*r._delayBeforeRestoreSeconds,o=!1,a=function(){n=1e3*r._delayBeforeRestoreSeconds,o||(e.scene._renderer.setColorTextureEnabled(!r._hideColorTexture),e.scene._renderer.setPBREnabled(!r._hidePBR),e.scene._renderer.setSAOEnabled(!r._hideSAO),e.scene._renderer.setTransparentEnabled(!r._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!r._hideEdges),r._scaleCanvasResolution?e.scene.canvas.resolutionScale=r._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=r._defaultScaleCanvasResolutionFactor,o=!0)},l=function(){e.scene.canvas.resolutionScale=r._defaultScaleCanvasResolutionFactor,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),o=!1};r._onCanvasBoundary=e.scene.canvas.on("boundary",a),r._onCameraMatrix=e.scene.camera.on("matrix",a),r._onSceneTick=e.scene.on("tick",(function(e){o&&(n-=e.deltaTime,(!r._delayBeforeRestore||n<=0)&&l())}));var u=!1;return r._onSceneMouseDown=e.scene.input.on("mousedown",(function(){u=!0})),r._onSceneMouseUp=e.scene.input.on("mouseup",(function(){u=!1})),r._onSceneMouseMove=e.scene.input.on("mousemove",(function(){u&&a()})),r}return C(i,[{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:"defaultScaleCanvasResolutionFactor",get:function(){return this._defaultScaleCanvasResolutionFactor},set:function(e){this._defaultScaleCanvasResolutionFactor=e||1}},{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,t){}},{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),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Yh=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,e),this.cacheBuster=!1!==t.cacheBuster}return C(e,[{key:"_cacheBusterURL",value:function(e){if(!this.cacheBuster)return e;var t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}},{key:"getMetaModel",value:function(e,t,i){he.loadJSON(this._cacheBusterURL(e),(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLTF",value:function(e,t,i){he.loadArraybuffer(this._cacheBusterURL(e),(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLB",value:function(e,t,i){he.loadArraybuffer(this._cacheBusterURL(e),(function(e){t(e)}),(function(e){i(e)}))}},{key:"getArrayBuffer",value:function(e,t,i,r){!function(e,t,i,r){var s=function(){};i=i||s,r=r||s;var n=/^data:(.*?)(;base64)?,(.*)$/,o=t.match(n);if(o){var a=!!o[2],l=o[3];l=window.decodeURIComponent(l),a&&(l=window.atob(l));try{for(var u=new ArrayBuffer(l.length),A=new Uint8Array(u),c=0;c<l.length;c++)A[c]=l.charCodeAt(c);Be.scheduleTask((function(){i(u)}))}catch(e){Be.scheduleTask((function(){r(e)}))}}else{var h=function(e){var t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}(e),d=h+t,p=new XMLHttpRequest;p.open("GET",d,!0),p.responseType="arraybuffer",p.onreadystatechange=function(){4===p.readyState&&(200===p.status?i(p.response):r("loadArrayBuffer error : "+p.response))},p.send(null)}}(this._cacheBusterURL(e),t,(function(e){i(e)}),(function(e){r(e)}))}}]),e}();var Jh=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(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=t.messages,this.locale=t.locale}return C(e,[{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 t in e)this._messages[t]=e[t];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,t){var i=this._messages[this._locale];if(!i)return null;var r=Zh(e,i);return r?t?qh(r,t):r:null}},{key:"translatePlurals",value:function(e,t,i){var r=this._messages[this._locale];if(!r)return null;var s=Zh(e,r);return(s=0===(t=parseInt(""+t,10))?s.zero:t>1?s.other:s.one)?(s=qh(s,[t]),i&&(s=qh(s,i)),s):null}},{key:"fire",value:function(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);var r=this._eventSubs[e];if(r)for(var s in r){if(r.hasOwnProperty(s))r[s].callback(t)}}},{key:"on",value:function(e,t){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new G),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});var i=this._eventSubs[e];i||(i={},this._eventSubs[e]=i);var r=this._eventSubIDMap.addItem();i[r]={callback:t},this._eventSubEvents[r]=e;var s=this._events[e];return void 0!==s&&t(s),r}},{key:"off",value:function(e){if(null!=e&&this._eventSubEvents){var t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];var i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}}]),e}();function Zh(e,t){if(t[e])return t[e];for(var i=e.split("."),r=t,s=0,n=i.length;r&&s<n;s++){r=r[i[s]]}return r}function qh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,i){return"{{"===e?"{":"}}"===e?"}":t[i]}))}var $h=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).t=s.t,r}return C(i,[{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 t=1e-4;void 0===e&&(e=this._t);var i=e-t,r=e+t;i<0&&(i=0),r>1&&(r=1);var s=this.getPoint(i),n=this.getPoint(r),o=re.subVec3(n,s,[]);return re.normalizeVec3(o,[])}},{key:"getPointAt",value:function(e){var t=this.getUToTMapping(e);return this.getPoint(t)}},{key:"getPoints",value:function(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}},{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 t,i,r=[],s=this.getPoint(0),n=0;for(r.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),n+=re.lenVec3(re.subVec3(t,s,[])),r.push(n),s=t;return this.cacheArcLengths=r,r}},{key:"_updateArcLengths",value:function(){this.needsUpdate=!0,this._getLengths()}},{key:"getUToTMapping",value:function(e,t){var i,r=this._getLengths(),s=0,n=r.length;i=t||e*r[n-1];for(var o,a=0,l=n-1;a<=l;)if((o=r[s=Math.floor(a+(l-a)/2)]-i)<0)a=s+1;else{if(!(o>0)){l=s;break}l=s-1}if(r[s=l]===i)return s/(n-1);var u=r[s];return(s+(i-u)/(r[s+1]-u))/(n-1)}}]),i}(),ed=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).points=s.points,r.t=s.t,r}return C(i,[{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 t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,r=Math.floor(i),s=i-r,n=t[0===r?r:r-1],o=t[r],a=t[r>t.length-2?t.length-1:r+1],l=t[r>t.length-3?t.length-1:r+2],u=re.vec3();return u[0]=re.catmullRomInterpolate(n[0],o[0],a[0],l[0],s),u[1]=re.catmullRomInterpolate(n[1],o[1],a[1],l[1],s),u[2]=re.catmullRomInterpolate(n[2],o[2],a[2],l[2],s),u}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}}}]),i}(),td=re.vec3(),id=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._frames=[],r._eyeCurve=new ed(b(r)),r._lookCurve=new ed(b(r)),r._upCurve=new ed(b(r)),s.frames&&(r.addFrames(s.frames),r.smoothFrameTimes(1)),r}return C(i,[{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 t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}},{key:"addFrame",value:function(e,t,i,r){var s={t:e,eye:t.slice(0),look:i.slice(0),up:r.slice(0)};this._frames.push(s),this._eyeCurve.points.push(s.eye),this._lookCurve.points.push(s.look),this._upCurve.points.push(s.up)}},{key:"addFrames",value:function(e){for(var t,i=0,r=e.length;i<r;i++)t=e[i],this.addFrame(t.t||0,t.eye,t.look,t.up)}},{key:"loadFrame",value:function(e){var t=this.scene.camera;e=(e/=this._frames[this._frames.length-1].t-this._frames[0].t)<0?0:e>1?1:e,t.eye=this._eyeCurve.getPoint(e,td),t.look=this._lookCurve.getPoint(e,td),t.up=this._upCurve.getPoint(e,td)}},{key:"sampleFrame",value:function(e,t,i,r){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,r)}},{key:"smoothFrameTimes",value:function(e){if(0!==this._frames.length){var t=re.vec3(),i=0;this._frames[0].t=0;for(var r=[],s=1,n=this._frames.length;s<n;s++){var o=re.lenVec3(re.subVec3(this._frames[s].eye,this._frames[s-1].eye,t));r[s]=o,i+=o}for(var a=1,l=this._frames.length;a<l;a++){var u=r[a]/i*e;this._frames[a].t=this._frames[a-1].t+u}}}},{key:"clearFrames",value:function(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}}]),i}(),rd=re.vec3(),sd=re.vec3(),nd=re.vec3(),od=re.vec3(),ad=re.vec3(),ld=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._look1=re.vec3(),r._eye1=re.vec3(),r._up1=re.vec3(),r._look2=re.vec3(),r._eye2=re.vec3(),r._up2=re.vec3(),r._orthoScale1=1,r._orthoScale2=1,r._flying=!1,r._flyEyeLookUp=!1,r._flyingEye=!1,r._flyingLook=!1,r._callback=null,r._callbackScope=null,r._time1=null,r._time2=null,r.easing=!1!==s.easing,r.duration=s.duration,r.fit=s.fit,r.fitFOV=s.fitFOV,r.trail=s.trail,r}return C(i,[{key:"type",get:function(){return"CameraFlightAnimation"}},{key:"flyTo",value:function(e,t,i){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=i;var r,s,n,o,a,l=this.scene.camera,u=!!e.projection&&e.projection!==l.projection;if(this._eye1[0]=l.eye[0],this._eye1[1]=l.eye[1],this._eye1[2]=l.eye[2],this._look1[0]=l.look[0],this._look1[1]=l.look[1],this._look1[2]=l.look[2],this._up1[0]=l.up[0],this._up1[1]=l.up[1],this._up1[2]=l.up[2],this._orthoScale1=l.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)r=e.aabb;else if(6===e.length)r=e;else if(e.eye&&e.look||e.up)s=e.eye,n=e.look,o=e.up;else if(e.eye)s=e.eye;else if(e.look)n=e.look;else{var A=e;if((he.isNumeric(A)||he.isString(A))&&(a=A,!(A=this.scene.components[a])))return this.error("Component not found: "+he.inQuotes(a)),void(t&&(i?t.call(i):t()));u||(r=A.aabb||this.scene.aabb)}var c=e.poi;if(r){if(r[3]<r[0]||r[4]<r[1]||r[5]<r[2])return;if(r[3]===r[0]&&r[4]===r[1]&&r[5]===r[2])return;r=r.slice();var h=re.getAABB3Center(r);this._look2=c||h;var d=re.subVec3(this._eye1,this._look1,rd),p=re.normalizeVec3(d),f=c?re.getAABB3DiagPoint(r,c):re.getAABB3Diag(r),v=e.fitFOV||this._fitFOV,g=Math.abs(f/Math.tan(v*re.DEGTORAD));this._orthoScale2=1.1*f,this._eye2[0]=this._look2[0]+p[0]*g,this._eye2[1]=this._look2[1]+p[1]*g,this._eye2[2]=this._look2[2]+p[2]*g,this._up2[0]=this._up1[0],this._up2[1]=this._up1[1],this._up2[2]=this._up1[2],this._flyingEyeLookUp=!0}else(s||n||o)&&(this._flyingEyeLookUp=!!s&&!!n&&!!o,this._flyingEye=!!s&&!n,this._flyingLook=!!n&&!s,s&&(this._eye2[0]=s[0],this._eye2[1]=s[1],this._eye2[2]=s[2]),n&&(this._look2[0]=n[0],this._look2[1]=n[1],this._look2[2]=n[2]),o&&(this._up2[0]=o[0],this._up2[1]=o[1],this._up2[2]=o[2]));u?("ortho"===e.projection&&"ortho"!==l.projection&&(this._projection2="ortho",this._projMatrix1=l.projMatrix.slice(),this._projMatrix2=l.ortho.matrix.slice(),l.projection="customProjection"),"perspective"===e.projection&&"perspective"!==l.projection&&(this._projection2="perspective",this._projMatrix1=l.projMatrix.slice(),this._projMatrix2=l.perspective.matrix.slice(),l.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,Be.scheduleTask(this._update,this)}},{key:"jumpTo",value:function(e){this._jumpTo(e)}},{key:"_jumpTo",value:function(e){this._flying&&this.stop();var t,i,r,s,n,o=this.scene.camera;if(e.aabb)t=e.aabb;else if(6===e.length)t=e;else if(e.eye||e.look||e.up)r=e.eye,s=e.look,n=e.up;else{var a=e;if((he.isNumeric(a)||he.isString(a))&&(i=a,!(a=this.scene.components[i])))return void this.error("Component not found: "+he.inQuotes(i));t=a.aabb||this.scene.aabb}var l=e.poi;if(t){if(t[3]<=t[0]||t[4]<=t[1]||t[5]<=t[2])return;var u,A=l?re.getAABB3DiagPoint(t,l):re.getAABB3Diag(t);s=l||re.getAABB3Center(t,s),this._trail?re.subVec3(o.look,s,ad):re.subVec3(o.eye,o.look,ad),re.normalizeVec3(ad),u=(void 0!==e.fit?e.fit:this._fit)?Math.abs(A/Math.tan((e.fitFOV||this._fitFOV)*re.DEGTORAD)):re.lenVec3(re.subVec3(o.eye,o.look,rd)),re.mulVec3Scalar(ad,u),o.eye=re.addVec3(s,ad,rd),o.look=s,this.scene.camera.ortho.scale=1.1*A}else(r||s||n)&&(r&&(o.eye=r),s&&(o.look=s),n&&(o.up=n));e.projection&&(o.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 r=this.easing?i._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(re.subVec3(s.eye,s.look,ad),s.eye=re.lerpVec3(r,0,1,this._eye1,this._eye2,nd),s.look=re.subVec3(nd,ad,sd)):this._flyingLook&&(s.look=re.lerpVec3(r,0,1,this._look1,this._look2,sd),s.up=re.lerpVec3(r,0,1,this._up1,this._up2,od)):this._flyingEyeLookUp&&(s.eye=re.lerpVec3(r,0,1,this._eye1,this._eye2,nd),s.look=re.lerpVec3(r,0,1,this._look1,this._look2,sd),s.up=re.lerpVec3(r,0,1,this._up1,this._up2,od)),this._projection2){var n="ortho"===this._projection2?i._easeOutExpo(e,0,1,1):i._easeInCubic(e,0,1,1);s.customProjection.matrix=re.lerpMat4(n,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();Be.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(),f(w(i.prototype),"destroy",this).call(this)}}],[{key:"_ease",value:function(e,t,i,r){return-i*(e/=r)*(e-2)+t}},{key:"_easeInCubic",value:function(e,t,i,r){return i*(e/=r)*e*e+t}},{key:"_easeOutExpo",value:function(e,t,i,r){return i*(1-Math.pow(2,-10*e/r))+t}}]),i}(),ud=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._cameraFlightAnimation=new ld(b(r)),r._t=0,r.state=i.SCRUBBING,r._playingFromT=0,r._playingToT=0,r._playingRate=s.playingRate||1,r._playingDir=1,r._lastTime=null,r.cameraPath=s.cameraPath,r._tick=r.scene.on("tick",r._updateT,b(r)),r}return C(i,[{key:"type",get:function(){return"CameraPathAnimation"}},{key:"_updateT",value:function(){var e=this._cameraPath;if(e){var t,r,s=performance.now(),n=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==n)switch(this.state){case i.SCRUBBING:return;case i.PLAYING:if(this._t+=this._playingRate*n,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=i.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case i.PLAYING_TO:r=this._t+this._playingRate*n*this._playingDir,(this._playingDir<0&&r<=this._playingToT||this._playingDir>0&&r>=this._playingToT)&&(r=this._playingToT,this.state=i.SCRUBBING,this.fire("stopped")),this._t=r,e.loadFrame(this._t)}}}},{key:"_ease",value:function(e,t,i,r){return-i*(e/=r)*(e-2)+t}},{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=i.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=i.PLAYING_TO)}},{key:"playToFrame",value:function(e){var t=this._cameraPath;if(t){var i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}}},{key:"flyToFrame",value:function(e,t){var r=this._cameraPath;if(r){var s=r.frames[e];s?(this.state=i.SCRUBBING,this._cameraFlightAnimation.flyTo(s,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=i.SCRUBBING))}},{key:"scrubToFrame",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(t.frames[e]?(t.loadFrame(this._t),this.state=i.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)))}},{key:"stop",value:function(){this.state=i.SCRUBBING,this.fire("stopped")}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this.scene.off(this._tick)}}]),i}();ud.STOPPED=0,ud.SCRUBBING=1,ud.PLAYING=2,ud.PLAYING_TO=3;var Ad=re.vec3(),cd=re.vec3();re.vec3();var hd=re.vec3([0,-1,0]),dd=re.vec4([0,0,0,1]),pd=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._src=null,r._image=null,r._pos=re.vec3(),r._origin=re.vec3(),r._rtcPos=re.vec3(),r._dir=re.vec3(),r._size=1,r._imageSize=re.vec2(),r._texture=new Jn(b(r)),r._plane=new gn(b(r),{geometry:new Wi(b(r),ao({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Zi(b(r),{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:r._texture,emissiveMap:r._texture,backfaces:!0}),clippable:s.clippable}),r._grid=new gn(b(r),{geometry:new Wi(b(r),oo({size:1,divisions:10})),material:new Zi(b(r),{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:s.clippable}),r._node=new Tn(b(r),{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[r._plane,r._grid]}),r._gridVisible=!1,r.visible=!0,r.gridVisible=s.gridVisible,r.position=s.position,r.rotation=s.rotation,r.dir=s.dir,r.size=s.size,r.collidable=s.collidable,r.clippable=s.clippable,r.pickable=s.pickable,r.opacity=s.opacity,s.image?r.image=s.image:r.src=s.src,r}return C(i,[{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 t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.src=this._src}}},{key:"position",get:function(){return this._pos},set:function(e){this._pos.set(e||[0,0,0]),He(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 t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];re.subVec3(t,this.position,Ad);var r=-re.dotVec3(i,Ad);re.normalizeVec3(i),re.mulVec3Scalar(i,r,cd),re.vec3PairToQuaternion(hd,e,dd),this._node.quaternion=dd}}},{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(){f(w(i.prototype),"destroy",this).call(this)}},{key:"_updatePlaneSizeFromImage",value:function(){var e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){var r=i/t;this._node.scale=[e,1,e*r]}else{var s=t/i;this._node.scale=[e*s,1,e]}}}]),i}(),fd=function(e){g(i,Di);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=b(r=t.call(this,e,s));r._shadowRenderBuf=null,r._shadowViewMatrix=null,r._shadowProjMatrix=null,r._shadowViewMatrixDirty=!0,r._shadowProjMatrixDirty=!0;var o=r.scene.camera,a=r.scene.canvas;return r._onCameraViewMatrix=o.on("viewMatrix",(function(){r._shadowViewMatrixDirty=!0})),r._onCameraProjMatrix=o.on("projMatrix",(function(){r._shadowProjMatrixDirty=!0})),r._onCanvasBoundary=a.on("boundary",(function(){r._shadowProjMatrixDirty=!0})),r._state=new Ai({type:"point",pos:re.vec3([1,1,1]),color:re.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:s.space||"view",castsShadow:!1,getShadowViewMatrix:function(){if(n._shadowViewMatrixDirty){n._shadowViewMatrix||(n._shadowViewMatrix=re.identityMat4());var e=n._state.pos,t=o.look,i=o.up;re.lookAtMat4v(e,t,i,n._shadowViewMatrix),n._shadowViewMatrixDirty=!1}return n._shadowViewMatrix},getShadowProjMatrix:function(){if(n._shadowProjMatrixDirty){n._shadowProjMatrix||(n._shadowProjMatrix=re.identityMat4());var e=n.scene.canvas.canvas;re.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,n._shadowProjMatrix),n._shadowProjMatrixDirty=!1}return n._shadowProjMatrix},getShadowRenderBuf:function(){return n._shadowRenderBuf||(n._shadowRenderBuf=new si(n.scene.canvas.canvas,n.scene.canvas.gl,{size:[1024,1024]})),n._shadowRenderBuf}}),r.pos=s.pos,r.color=s.color,r.intensity=s.intensity,r.constantAttenuation=s.constantAttenuation,r.linearAttenuation=s.linearAttenuation,r.quadraticAttenuation=s.quadraticAttenuation,r.castsShadow=s.castsShadow,r.scene._lightCreated(b(r)),r}return C(i,[{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),f(w(i.prototype),"destroy",this).call(this),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}]),i}();function vd(e){return 0==(e&e-1)}function gd(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1}var md=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=(r=t.call(this,e,s)).scene.canvas.gl;return r._state=new Ai({texture:new Gn({gl:n,target:n.TEXTURE_CUBE_MAP}),flipY:r._checkFlipY(s.minFilter),encoding:r._checkEncoding(s.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),r._src=s.src,r._images=[],r._loadSrc(s.src),ae.memory.textures++,r}return C(i,[{key:"type",get:function(){return"CubeTexture"}},{key:"_checkFlipY",value:function(e){return!!e}},{key:"_checkEncoding",value:function(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),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 t=this,i=this.scene.canvas.gl;this._images=[];for(var r=!1,s=0,n=function(n){var o,a,l=new Image;l.onload=(o=l,a=n,function(){if(!r&&(o=function(e){if(!vd(e.width)||!vd(e.height)){var t=document.createElement("canvas");t.width=gd(e.width),t.height=gd(e.height),t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}(o),t._images[a]=o,6==++s)){var e=t._state.texture;e||(e=new Gn({gl:i,target:i.TEXTURE_CUBE_MAP}),t._state.texture=e),e.setImage(t._images,t._state),t.fire("loaded",t._src,!1),t.glRedraw()}}),l.onerror=function(){r=!0},l.src=e[n]},o=0;o<e.length;o++)n(o)}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this._state.texture&&this._state.texture.destroy(),ae.memory.textures--,this._state.destroy()}}]),i}(),_d=function(e){g(i,md);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).scene._lightsState.addReflectionMap(r._state),r.scene._reflectionMapCreated(b(r)),r}return C(i,[{key:"type",get:function(){return"ReflectionMap"}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this.scene._reflectionMapDestroyed(this)}}]),i}(),yd=function(e){g(i,md);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).scene._lightMapCreated(b(r)),r}return C(i,[{key:"type",get:function(){return"LightMap"}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this.scene._lightMapDestroyed(this)}}]),i}(),bd=function(e){g(i,ot);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,{entity:s.entity,occludable:s.occludable,worldPos:s.worldPos}))._occluded=!1,r._visible=!0,r._src=null,r._image=null,r._pos=re.vec3(),r._origin=re.vec3(),r._rtcPos=re.vec3(),r._dir=re.vec3(),r._size=1,r._imageSize=re.vec2(),r._texture=new Jn(b(r),{src:s.src}),r._geometry=new Wi(b(r),{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]}),r._mesh=new gn(b(r),{geometry:r._geometry,material:new Zi(b(r),{ambient:[.9,.3,.9],shininess:30,diffuseMap:r._texture,backfaces:!0}),scale:[1,1,1],position:s.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),r.visible=!0,r.collidable=s.collidable,r.clippable=s.clippable,r.pickable=s.pickable,r.opacity=s.opacity,r.size=s.size,s.image?r.image=s.image:r.src=s.src,r}return C(i,[{key:"_setVisible",value:function(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,f(w(i.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 t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.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,t=this._imageSize[0],i=this._imageSize[1],r=i/t;this._geometry.positions=t>i?[e,e*r,0,-e,e*r,0,-e,-e*r,0,e,-e*r,0]:[e/r,e,0,-e/r,e,0,-e/r,-e,0,e/r,-e,0]}}]),i}(),wd=function(){function e(t){x(this,e),this._eye=re.vec3(),this._look=re.vec3(),this._up=re.vec3(),this._projection={},t&&this.saveCamera(t)}return C(e,[{key:"saveCamera",value:function(e){var t=e.camera,i=t.project;switch(this._eye.set(t.eye),this._look.set(t.look),this._up.set(t.up),t.projection){case"perspective":this._projection={projection:"perspective",fov:i.fov,fovAxis:i.fovAxis,near:i.near,far:i.far};break;case"ortho":this._projection={projection:"ortho",scale:i.scale,near:i.near,far:i.far};break;case"frustum":this._projection={projection:"frustum",left:i.left,right:i.right,top:i.top,bottom:i.bottom,near:i.near,far:i.far};break;case"custom":this._projection={projection:"custom",matrix:i.matrix.slice()}}}},{key:"restoreCamera",value:function(e,t){var i=e.camera,r=this._projection;function s(){switch(r.type){case"perspective":i.perspective.fov=r.fov,i.perspective.fovAxis=r.fovAxis,i.perspective.near=r.near,i.perspective.far=r.far;break;case"ortho":i.ortho.scale=r.scale,i.ortho.near=r.near,i.ortho.far=r.far;break;case"frustum":i.frustum.left=r.left,i.frustum.right=r.right,i.frustum.top=r.top,i.frustum.bottom=r.bottom,i.frustum.near=r.near,i.frustum.far=r.far;break;case"custom":i.customProjection.matrix=r.matrix}}t?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:r.scale,projection:r.projection},(function(){s(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,s(),i.projection=r.projection)}}]),e}(),Bd=re.vec3(),xd=function(){function e(t){if(x(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,t){var i=t.metaScene.scene;this.saveObjects(i,t)}}return C(e,[{key:"saveObjects",value:function(e,t,i){this.numObjects=0,this._mask=i?he.apply(i,{}):null;for(var r=!i||i.visible,s=!i||i.edges,n=!i||i.xrayed,o=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,u=!i||i.pickable,A=!i||i.colorize,c=!i||i.opacity,h=t.metaObjects,d=e.objects,p=0,f=h.length;p<f;p++){var v=d[h[p].id];if(v){if(r&&(this.objectsVisible[p]=v.visible),s&&(this.objectsEdges[p]=v.edges),n&&(this.objectsXrayed[p]=v.xrayed),o&&(this.objectsHighlighted[p]=v.highlighted),a&&(this.objectsSelected[p]=v.selected),l&&(this.objectsClippable[p]=v.clippable),u&&(this.objectsPickable[p]=v.pickable),A){var g=v.colorize;this.objectsColorize[3*p+0]=g[0],this.objectsColorize[3*p+1]=g[1],this.objectsColorize[3*p+2]=g[2]}c&&(this.objectsOpacity[p]=v.opacity),this.numObjects++}}}},{key:"restoreObjects",value:function(e,t){for(var i=this._mask,r=!i||i.visible,s=!i||i.edges,n=!i||i.xrayed,o=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,u=!i||i.pickable,A=!i||i.colorize,c=!i||i.opacity,h=t.metaObjects,d=e.objects,p=0,f=h.length;p<f;p++){var v=d[h[p].id];v&&(r&&(v.visible=this.objectsVisible[p]),s&&(v.edges=this.objectsEdges[p]),n&&(v.xrayed=this.objectsXrayed[p]),o&&(v.highlighted=this.objectsHighlighted[p]),a&&(v.selected=this.objectsSelected[p]),l&&(v.clippable=this.objectsClippable[p]),u&&(v.pickable=this.objectsPickable[p]),A&&(Bd[0]=this.objectsColorize[3*p+0],Bd[1]=this.objectsColorize[3*p+1],Bd[2]=this.objectsColorize[3*p+2],v.colorize=Bd),c&&(v.opacity=this.objectsOpacity[p]))}}}]),e}(),Pd=re.vec3(),Cd=function(){function e(){x(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}return C(e,[{key:"saveObjects",value:function(e,t){this.numObjects=0,this._mask=t?he.apply(t,{}):null;var i=e.objects,r=!t||t.visible,s=!t||t.edges,n=!t||t.xrayed,o=!t||t.highlighted,a=!t||t.selected,l=!t||t.clippable,u=!t||t.pickable,A=!t||t.colorize,c=!t||t.opacity;for(var h in i)if(i.hasOwnProperty(h)){var d=i[h],p=this.numObjects;if(r&&(this.objectsVisible[p]=d.visible),s&&(this.objectsEdges[p]=d.edges),n&&(this.objectsXrayed[p]=d.xrayed),o&&(this.objectsHighlighted[p]=d.highlighted),a&&(this.objectsSelected[p]=d.selected),l&&(this.objectsClippable[p]=d.clippable),u&&(this.objectsPickable[p]=d.pickable),A){var f=d.colorize;f?(this.objectsColorize[3*p+0]=f[0],this.objectsColorize[3*p+1]=f[1],this.objectsColorize[3*p+2]=f[2],this.objectsHasColorize[p]=!0):this.objectsHasColorize[p]=!1}c&&(this.objectsOpacity[p]=d.opacity),this.numObjects++}}},{key:"restoreObjects",value:function(e){var t=this._mask,i=!t||t.visible,r=!t||t.edges,s=!t||t.xrayed,n=!t||t.highlighted,o=!t||t.selected,a=!t||t.clippable,l=!t||t.pickable,u=!t||t.colorize,A=!t||t.opacity,c=0,h=e.objects;for(var d in h)if(h.hasOwnProperty(d)){var p=h[d];i&&(p.visible=this.objectsVisible[c]),r&&(p.edges=this.objectsEdges[c]),s&&(p.xrayed=this.objectsXrayed[c]),n&&(p.highlighted=this.objectsHighlighted[c]),o&&(p.selected=this.objectsSelected[c]),a&&(p.clippable=this.objectsClippable[c]),l&&(p.pickable=this.objectsPickable[c]),u&&(this.objectsHasColorize[c]?(Pd[0]=this.objectsColorize[3*c+0],Pd[1]=this.objectsColorize[3*c+1],Pd[2]=this.objectsColorize[3*c+2],p.colorize=Pd):p.colorize=null),A&&(p.opacity=this.objectsOpacity[c]),c++}}}]),e}(),Md=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).v0=s.v0,r.v1=s.v1,r.v2=s.v2,r.v3=s.v3,r.t=s.t,r}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||re.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||re.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||re.vec3([0,0,0])}},{key:"v3",get:function(){return this._v3},set:function(e){this.fire("v3",this._v3=e||re.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 t=re.vec3();return t[0]=re.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=re.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=re.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}]),i}(),Ed=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._cachedLengths=[],r._dirty=!0,r._curves=[],r._t=0,r._dirtySubs=[],r._destroyedSubs=[],r.curves=s.curves||[],r.t=s.t,r}return C(i,[{key:"addCurve",value:function(e){this._curves.push(e),this._dirty=!0}},{key:"curves",get:function(){return this._curves},set:function(e){var t,i,r;for(e=e||[],i=0,r=this._curves.length;i<r;i++)(t=this._curves[i]).off(this._dirtySubs[i]),t.off(this._destroyedSubs[i]);this._curves=[],this._dirtySubs=[],this._destroyedSubs=[];var s=this;function n(){s._dirty=!0}function o(){var e=this.id;for(i=0,r=s._curves.length;i<r;i++)if(s._curves[i].id===e)return s._curves=s._curves.slice(i,i+1),s._dirtySubs=s._dirtySubs.slice(i,i+1),s._destroyedSubs=s._destroyedSubs.slice(i,i+1),void(s._dirty=!0)}for(i=0,r=e.length;i<r;i++){if(t=e[i],he.isNumeric(t)||he.isString(t)){var a=t;if(!(t=this.scene.components[a])){this.error("Component not found: "+_inQuotes(a));continue}}var l=t.type;"xeokit.SplineCurve"===l||"xeokit.Path"===l||"xeokit.CubicBezierCurve"===l||"xeokit.QuadraticBezierCurve"===l?(this._curves.push(t),this._dirtySubs.push(t.on("dirty",n)),this._destroyedSubs.push(t.once("destroyed",o))):this.error("Component "+_inQuotes(t.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 t,i=e*this.length,r=this._getCurveLengths(),s=0;s<r.length;){if(r[s]>=i){var n=1-(r[s]-i)/(t=this._curves[s]).length;return t.getPointAt(n)}s++}return null}},{key:"_getCurveLengths",value:function(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,r=this._curves.length;for(e=0;e<r;e++)i+=this._curves[e].length,t.push(i);return this._cachedLengths=t,this._dirty=!1,t}},{key:"_getJSON",value:function(){for(var e=[],t=0,i=this._curves.length;t<i;t++)e.push(this._curves[t].id);return{curves:e,t:this._t}}},{key:"destroy",value:function(){var e,t,r;for(f(w(i.prototype),"destroy",this).call(this),e=0,t=this._curves.length;e<t;e++)(r=this._curves[e]).off(this._dirtySubs[e]),r.off(this._destroyedSubs[e])}}]),i}(),Fd=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).v0=s.v0,r.v1=s.v1,r.v2=s.v2,r.t=s.t,r}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||re.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||re.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||re.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 t=re.vec3();return t[0]=re.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=re.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=re.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}]),i}(),kd=function(e){g(i,Ph);var t=_(i);function i(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),t.call(this,e,r)}return C(i)}(),Id=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._skyboxMesh=new gn(b(r),{geometry:new Wi(b(r),{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 Zi(b(r),{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Jn(b(r),{src:s.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:s.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),r.size=s.size,r.active=s.active,r}return C(i,[{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}}]),i}(),Dd=function(){function e(){x(this,e)}return C(e,[{key:"transcode",value:function(e,t){}},{key:"destroy",value:function(){}}]),e}(),Sd=re.vec4(),Td=re.vec4(),Ld=re.vec3(),Rd=re.vec3(),Ud=re.vec3(),Od=re.vec4(),Nd=re.vec4(),Qd=re.vec4(),Vd=function(){function e(t){x(this,e),this._scene=t}return C(e,[{key:"dollyToCanvasPos",value:function(e,t,i){var r=!1,s=this._scene.camera;if(e){var n=re.subVec3(e,s.eye,Ld);r=re.lenVec3(n)<i}if("perspective"===s.projection){s.ortho.scale=s.ortho.scale-i;var o=this._unproject(t,Od),a=re.subVec3(o,s.eye,Qd),l=re.mulVec3Scalar(re.normalizeVec3(a),-i,[]);if(s.eye=[s.eye[0]-l[0],s.eye[1]-l[1],s.eye[2]-l[2]],s.look=[s.look[0]-l[0],s.look[1]-l[1],s.look[2]-l[2]],e){var u=re.subVec3(e,s.eye,Ld),A=re.lenVec3(u),c=re.mulVec3Scalar(re.normalizeVec3(re.subVec3(s.look,s.eye,Rd)),A);s.look=[s.eye[0]+c[0],s.eye[1]+c[1],s.eye[2]+c[2]]}}else if("ortho"===s.projection){var h=this._unproject(t,Od);s.ortho.scale=s.ortho.scale-i,s.ortho._update();var d=this._unproject(t,Nd),p=re.subVec3(d,h,Qd),f=re.mulVec3Scalar(re.normalizeVec3(re.subVec3(s.look,s.eye,Ld)),-i,Rd),v=re.addVec3(p,f,Ud);s.eye=[s.eye[0]-v[0],s.eye[1]-v[1],s.eye[2]-v[2]],s.look=[s.look[0]-v[0],s.look[1]-v[1],s.look[2]-v[2]]}return r}},{key:"_unproject",value:function(e,t){var i=this._scene.camera,r=i.project.transposedMatrix,s=r.subarray(8,12),n=r.subarray(12),o=[0,0,-1,1],a=re.dotVec4(o,s)/re.dotVec4(o,n);return i.project.unproject(e,a,Sd,Td,t),t}},{key:"destroy",value:function(){}}]),e}(),Hd=re.vec3(),jd=re.vec3(),Gd=re.vec3(),zd=re.vec4(),Wd=re.vec4(),Kd=re.vec4(),Xd=function(){function e(t,i){var r=this;x(this,e),this._scene=t,this._configs=i,this._pivotWorldPos=re.vec3(),this._cameraOffset=re.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=re.vec3(),this._rtcPos=re.vec3(),this._pivotViewPos=re.vec4(),this._pivotProjPos=re.vec4(),this._pivotCanvasPos=re.vec2(),this._cameraDirty=!0,this._onViewMatrix=this._scene.camera.on("viewMatrix",(function(){r._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(function(){r._cameraDirty=!0})),this._onTick=this._scene.on("tick",(function(){r.updatePivotElement(),r.updatePivotSphere()}))}return C(e,[{key:"createPivotSphere",value:function(){var e=this.getPivotPos(),t=re.vec3();re.decomposeMat4(re.inverseMat4(this._scene.viewer.camera.viewMatrix,re.mat4()),t,re.vec4(),re.vec3());var i=re.distVec3(t,e),r=Math.tan(Math.PI/500)*i*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(r/=this._scene.camera.ortho.scale/2),He(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new eo(this._scene,yn({radius:r})),this._pivotSphere=new gn(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:"updatePivotElement",value:function(){var e=this._scene.camera,t=this._scene.canvas;if(this._pivoting&&this._cameraDirty){re.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,re.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);var i=t.boundary,r=i[2],s=i[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*r/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*s/2);var n=t._lastBoundingClientRect;if(!n||t._canvasSizeChanged){var o=t.canvas;n=t._lastBoundingClientRect=o.getBoundingClientRect()}this._pivotElement&&(this._pivotElement.style.left=Math.floor(n.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+"px",this._pivotElement.style.top=Math.floor(n.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+"px"),this._cameraDirty=!1}}},{key:"updatePivotSphere",value:function(){this._pivoting&&this._pivotSphere&&(He(this.getPivotPos(),this._rtcCenter,this._rtcPos),re.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 t=e.color||[1,0,0];this._pivotSphereMaterial=new Zi(this._scene,{emissive:t,ambient:t,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,t=re.lookAtMat4v(e.eye,e.look,e.worldUp);re.transformPoint3(t,this.getPivotPos(),this._cameraOffset);var i=this.getPivotPos();this._cameraOffset[2]+=re.distVec3(e.eye,i),t=re.inverseMat4(t);var r=re.transformVec3(t,this._cameraOffset),s=re.vec3();if(re.subVec3(e.eye,i,s),re.addVec3(s,r),e.zUp){var n=s[1];s[1]=s[2],s[2]=n}this._radius=re.lenVec3(s),this._polar=Math.acos(s[1]/this._radius),this._azimuth=Math.atan2(s[0],s[2]),this._pivoting=!0}},{key:"_cameraLookingDownwards",value:function(){var e=this._scene.camera,t=re.normalizeVec3(re.subVec3(e.look,e.eye,Hd)),i=re.cross3Vec3(t,e.worldUp,jd);return re.sqLenVec3(i)<=1e-4}},{key:"getPivoting",value:function(){return this._pivoting}},{key:"setPivotPos",value:function(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}},{key:"setCanvasPivotPos",value:function(e){var t=this._scene.camera,i=Math.abs(re.distVec3(this._scene.center,t.eye)),r=t.project.transposedMatrix,s=r.subarray(8,12),n=r.subarray(12),o=[0,0,-1,1],a=re.dotVec4(o,s)/re.dotVec4(o,n),l=zd;t.project.unproject(e,a,Wd,Kd,l);var u=re.normalizeVec3(re.subVec3(l,t.eye,Hd)),A=re.addVec3(t.eye,re.mulVec3Scalar(u,i,jd),Gd);this.setPivotPos(A)}},{key:"getPivotPos",value:function(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}},{key:"continuePivot",value:function(e,t){if(this._pivoting&&(0!==e||0!==t)){var i=this._scene.camera,r=-e,s=-t;1===i.worldUp[2]&&(r=-r),this._azimuth+=.01*-r,this._polar+=.01*s,this._polar=re.clamp(this._polar,.001,Math.PI-.001);var n=[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===i.worldUp[2]){var o=n[1];n[1]=n[2],n[2]=o}var a=re.lenVec3(re.subVec3(i.look,i.eye,re.vec3())),l=this.getPivotPos();re.addVec3(n,l);var u=re.lookAtMat4v(n,l,i.worldUp);u=re.inverseMat4(u);var A=re.transformVec3(u,this._cameraOffset);u[12]-=A[0],u[13]-=A[1],u[14]-=A[2];var c=[u[8],u[9],u[10]];i.eye=[u[12],u[13],u[14]],re.subVec3(i.eye,re.mulVec3Scalar(c,a),i.look),i.up=[u[4],u[5],u[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.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}]),e}(),Yd=function(){function e(t,i){x(this,e),this._scene=t.scene,this._cameraControl=t,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=i,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=re.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}return C(e,[{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 t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var i=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});i&&(i.snappedToEdge||i.snappedToVertex)?(this.snapPickResult=i,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){var r=this.pickResult.canvasPos;if(r[0]===this.pickCursorPos[0]&&r[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?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 s=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(s[0]===this.pickCursorPos[0]&&s[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 Rt;e.entity=this.snapPickResult.entity,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 t=this.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=t)}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}}}]),e}(),Jd=re.vec2(),Zd=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o,a,l,u=i.pickController,A=0,c=0,h=0,d=0,p=!1,f=re.vec3(),v=!0,g=this._scene.canvas.canvas,m=[];function _(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];g.style.cursor="move",y(),e&&b()}function y(){A=s.pointerCanvasPos[0],c=s.pointerCanvasPos[1],h=s.pointerCanvasPos[0],d=s.pointerCanvasPos[1]}function b(){u.pickCursorPos=s.pointerCanvasPos,u.schedulePickSurface=!0,u.update(),u.picked&&u.pickedSurface&&u.pickResult&&u.pickResult.worldPos?(p=!0,f.set(u.pickResult.worldPos)):p=!1}document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!0}}),document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!1}}),g.addEventListener("mousedown",this._mouseDownHandler=function(e){if(r.active&&r.pointerEnabled)switch(e.which){case 1:m[t.input.KEY_SHIFT]||r.planView?(o=!0,_()):(o=!0,_(!1));break;case 2:a=!0,_();break;case 3:l=!0,r.panRightClick&&_()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=function(e){if(r.active&&r.pointerEnabled&&(o||a||l)){var i=t.canvas.boundary,u=i[2],h=i[3],d=s.pointerCanvasPos[0],v=s.pointerCanvasPos[1],g=m[t.input.KEY_SHIFT]||r.planView||!r.panRightClick&&a||r.panRightClick&&l,_=document.pointerLockElement?e.movementX:d-A,y=document.pointerLockElement?e.movementY:v-c;if(g){var b=t.camera;if("perspective"===b.projection){var w=Math.abs(p?re.lenVec3(re.subVec3(f,t.camera.eye,[])):t.camera.eyeLookDist)*Math.tan(b.perspective.fov/2*Math.PI/180);n.panDeltaX+=1.5*_*w/h,n.panDeltaY+=1.5*y*w/h}else n.panDeltaX+=.5*b.ortho.scale*(_/h),n.panDeltaY+=.5*b.ortho.scale*(y/h)}else!o||a||l||r.planView||(r.firstPerson?(n.rotateDeltaY-=_/u*r.dragRotationRate/2,n.rotateDeltaX+=y/h*(r.dragRotationRate/4)):(n.rotateDeltaY-=_/u*(1.5*r.dragRotationRate),n.rotateDeltaX+=y/h*(1.5*r.dragRotationRate)));A=d,c=v}}),g.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){r.active&&r.pointerEnabled&&s.mouseover&&(v=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(r.active&&r.pointerEnabled)switch(e.which){case 1:case 2:case 3:o=!1,a=!1,l=!1}}),g.addEventListener("mouseup",this._mouseUpHandler=function(e){if(r.active&&r.pointerEnabled){if(3===e.which){!function(e,t){if(e){for(var i=e.target,r=0,s=0,n=0,o=0;i.offsetParent;)r+=i.offsetLeft,s+=i.offsetTop,n+=i.scrollLeft,o+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+n-r,t[1]=e.pageY+o-s}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Jd);var t=Jd[0],s=Jd[1];Math.abs(t-h)<3&&Math.abs(s-d)<3&&i.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Jd,event:e},!0)}g.style.removeProperty("cursor")}}),g.addEventListener("mouseenter",this._mouseEnterHandler=function(){r.active&&r.pointerEnabled});var w=1/60,B=null;g.addEventListener("wheel",this._mouseWheelHandler=function(e){if(r.active&&r.pointerEnabled){var t=performance.now()/1e3,i=null!==B?t-B:0;B=t,i>.05&&(i=.05),i<w&&(i=w);var o=Math.max(-1,Math.min(1,40*-e.deltaY));if(0!==o){var a=o/Math.abs(o);n.dollyDelta+=-a*i*r.mouseWheelDollyRate,v&&(s.followPointerDirty=!0,v=!1)}}},{passive:!0})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;document.removeEventListener("keydown",this._documentKeyDownHandler),document.removeEventListener("keyup",this._documentKeyUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),document.removeEventListener("mousemove",this._documentMouseMoveHandler),e.removeEventListener("mousemove",this._canvasMouseMoveHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("wheel",this._mouseWheelHandler)}}]),e}(),qd=re.vec3(),$d=re.vec3(),ep=re.vec3(),tp=re.vec3(),ip=re.vec3(),rp={eye:re.vec3(),look:re.vec3(),up:re.vec3()},sp=function(){function e(t,i,r,s){x(this,e),this._scene=t;var n=i.cameraControl,o=t.camera;this._onSceneKeyDown=t.input.on("keydown",(function(){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(!r.keyboardEnabledOnlyIfMouseover||s.mouseover)){var e=n._isKeyDownForAction(n.AXIS_VIEW_RIGHT),a=n._isKeyDownForAction(n.AXIS_VIEW_BACK),l=n._isKeyDownForAction(n.AXIS_VIEW_LEFT),u=n._isKeyDownForAction(n.AXIS_VIEW_FRONT),A=n._isKeyDownForAction(n.AXIS_VIEW_TOP),c=n._isKeyDownForAction(n.AXIS_VIEW_BOTTOM);if(e||a||l||u||A||c){var h=t.aabb,d=re.getAABB3Diag(h);re.getAABB3Center(h,qd);var p=Math.abs(d/Math.tan(i.cameraFlight.fitFOV*re.DEGTORAD)),f=1.1*d;rp.orthoScale=f,e?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldRight,p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):a?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldForward,p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):l?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldRight,-p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):u?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldForward,-p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):A?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldUp,p,$d),ip)),rp.look.set(qd),rp.up.set(re.normalizeVec3(re.mulVec3Scalar(o.worldForward,1,ep),tp))):c&&(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldUp,-p,$d),ip)),rp.look.set(qd),rp.up.set(re.normalizeVec3(re.mulVec3Scalar(o.worldForward,-1,ep)))),!r.firstPerson&&r.followPointer&&i.pivotController.setPivotPos(qd),i.cameraFlight.duration>0?i.cameraFlight.flyTo(rp,(function(){i.pivotController.getPivoting()&&r.followPointer&&i.pivotController.showPivot()})):(i.cameraFlight.jumpTo(rp),i.pivotController.getPivoting()&&r.followPointer&&i.pivotController.showPivot())}}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.input.off(this._onSceneKeyDown)}}]),e}(),np=function(){function e(t,i,r,s,n){var o=this;x(this,e),this._scene=t;var a=i.pickController,l=i.pivotController,u=i.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;var A=!1,c=!1,h=this._scene.canvas.canvas,d=function(e){var r;e&&e.worldPos&&(r=e.worldPos);var s=e&&e.entity?e.entity.aabb:t.aabb;if(r){var n=t.camera;re.subVec3(n.eye,n.look,[]),i.cameraFlight.flyTo({aabb:s})}else i.cameraFlight.flyTo({aabb:s})},p=t.tickify(this._canvasMouseMoveHandler=function(e){if(r.active&&r.pointerEnabled&&!A&&!c){if(u.hasSubs("rayMove")){var i=re.vec3(),n=re.vec3();re.canvasPosToWorldRay(t.canvas.canvas,t.camera.viewMatrix,t.camera.projMatrix,t.camera.projection,s.pointerCanvasPos,i,n),u.fire("rayMove",{canvasPos:s.pointerCanvasPos,ray:{origin:i,direction:n,canvasPos:s.pointerCanvasPos}},!0)}var l=u.hasSubs("hover"),h=u.hasSubs("hoverEnter"),d=u.hasSubs("hoverOut"),p=u.hasSubs("hoverOff"),f=u.hasSubs("hoverSurface"),v=u.hasSubs("hoverSnapOrSurface");if(l||h||d||p||f||v)if(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=f,a.scheduleSnapOrPick=v,a.update(),a.pickResult){if(a.pickResult.entity){var g=a.pickResult.entity.id;o._lastPickedEntityId!==g&&(void 0!==o._lastPickedEntityId&&u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),u.fire("hoverEnter",a.pickResult,!0),o._lastPickedEntityId=g)}u.fire("hover",a.pickResult,!0),(a.pickResult.worldPos||a.pickResult.snappedWorldPos)&&u.fire("hoverSurface",a.pickResult,!0)}else void 0!==o._lastPickedEntityId&&(u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),o._lastPickedEntityId=void 0),u.fire("hoverOff",{canvasPos:a.pickCursorPos},!0)}});h.addEventListener("mousemove",p),h.addEventListener("mousedown",this._canvasMouseDownHandler=function(e){if(1===e.which&&(A=!0),3===e.which&&(c=!0),1===e.which&&r.active&&r.pointerEnabled&&(s.mouseDownClientX=e.clientX,s.mouseDownClientY=e.clientY,s.mouseDownCursorX=s.pointerCanvasPos[0],s.mouseDownCursorY=s.pointerCanvasPos[1],!r.firstPerson&&r.followPointer&&(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),1===e.which))){var i=a.pickResult;i&&i.worldPos?(l.setPivotPos(i.worldPos),l.startPivot()):(r.smartPivot?l.setCanvasPivotPos(s.pointerCanvasPos):l.setPivotPos(t.camera.look),l.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){1===e.which&&(A=!1),3===e.which&&(c=!1),l.getPivoting()&&l.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=function(e){if(r.active&&r.pointerEnabled&&(1===e.which&&(l.hidePivot(),!(Math.abs(e.clientX-s.mouseDownClientX)>3||Math.abs(e.clientY-s.mouseDownClientY)>3)))){var n=u.hasSubs("picked"),A=u.hasSubs("pickedNothing"),c=u.hasSubs("pickedSurface"),h=u.hasSubs("doublePicked"),p=u.hasSubs("doublePickedSurface"),f=u.hasSubs("doublePickedNothing");if(!(r.doublePickFlyTo||h||p||f))return(n||A||c)&&(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=c,a.update(),a.pickResult?(u.fire("picked",a.pickResult,!0),a.pickedSurface&&u.fire("pickedSurface",a.pickResult,!0)):u.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0)),void(o._clicks=0);if(o._clicks++,1===o._clicks){a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=r.doublePickFlyTo,a.schedulePickSurface=c,a.update();var v=a.pickResult,g=a.pickedSurface;o._timeout=setTimeout((function(){v?(u.fire("picked",v,!0),g&&(u.fire("pickedSurface",v,!0),!r.firstPerson&&r.followPointer&&(i.pivotController.setPivotPos(v.worldPos),i.pivotController.startPivot()&&i.pivotController.showPivot()))):u.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0),o._clicks=0}),r.doubleClickTimeFrame)}else{if(null!==o._timeout&&(window.clearTimeout(o._timeout),o._timeout=null),a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=r.doublePickFlyTo||h||p,a.schedulePickSurface=a.schedulePickEntity&&p,a.update(),a.pickResult){if(u.fire("doublePicked",a.pickResult,!0),a.pickedSurface&&u.fire("doublePickedSurface",a.pickResult,!0),r.doublePickFlyTo&&(d(a.pickResult),!r.firstPerson&&r.followPointer)){var m=a.pickResult.entity.aabb,_=re.getAABB3Center(m);i.pivotController.setPivotPos(_),i.pivotController.startPivot()&&i.pivotController.showPivot()}}else if(u.fire("doublePickedNothing",{canvasPos:s.pointerCanvasPos},!0),r.doublePickFlyTo&&(d(),!r.firstPerson&&r.followPointer)){var y=t.aabb,b=re.getAABB3Center(y);i.pivotController.setPivotPos(b),i.pivotController.startPivot()&&i.pivotController.showPivot()}o._clicks=0}}},!1)}return C(e,[{key:"reset",value:function(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}]),e}(),op=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=t.input,a=[],l=t.canvas.canvas,u=!0;this._onSceneMouseMove=o.on("mousemove",(function(){u=!0})),this._onSceneKeyDown=o.on("keydown",(function(e){r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(r.keyboardEnabledOnlyIfMouseover&&!s.mouseover||(a[e]=!0,e===o.KEY_SHIFT&&(l.style.cursor="move")))})),this._onSceneKeyUp=o.on("keyup",(function(e){r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(a[e]=!1,e===o.KEY_SHIFT&&(l.style.cursor=null),i.pivotController.getPivoting()&&i.pivotController.endPivot())})),this._onTick=t.on("tick",(function(e){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(!r.keyboardEnabledOnlyIfMouseover||s.mouseover)){var l=i.cameraControl,A=e.deltaTime/1e3;if(!r.planView){var c=l._isKeyDownForAction(l.ROTATE_Y_POS,a),h=l._isKeyDownForAction(l.ROTATE_Y_NEG,a),d=l._isKeyDownForAction(l.ROTATE_X_POS,a),p=l._isKeyDownForAction(l.ROTATE_X_NEG,a),f=A*r.keyboardRotationRate;(c||h||d||p)&&(!r.firstPerson&&r.followPointer&&i.pivotController.startPivot(),c?n.rotateDeltaY+=f:h&&(n.rotateDeltaY-=f),d?n.rotateDeltaX+=f:p&&(n.rotateDeltaX-=f),!r.firstPerson&&r.followPointer&&i.pivotController.startPivot())}if(!a[o.KEY_CTRL]&&!a[o.KEY_ALT]){var v=l._isKeyDownForAction(l.DOLLY_BACKWARDS,a),g=l._isKeyDownForAction(l.DOLLY_FORWARDS,a);if(v||g){var m=A*r.keyboardDollyRate;!r.firstPerson&&r.followPointer&&i.pivotController.startPivot(),g?n.dollyDelta-=m:v&&(n.dollyDelta+=m),u&&(s.followPointerDirty=!0,u=!1)}}var _=l._isKeyDownForAction(l.PAN_FORWARDS,a),y=l._isKeyDownForAction(l.PAN_BACKWARDS,a),b=l._isKeyDownForAction(l.PAN_LEFT,a),w=l._isKeyDownForAction(l.PAN_RIGHT,a),B=l._isKeyDownForAction(l.PAN_UP,a),x=l._isKeyDownForAction(l.PAN_DOWN,a),P=(a[o.KEY_ALT]?.3:1)*A*r.keyboardPanRate;(_||y||b||w||B||x)&&(!r.firstPerson&&r.followPointer&&i.pivotController.startPivot(),x?n.panDeltaY+=P:B&&(n.panDeltaY+=-P),w?n.panDeltaX+=-P:b&&(n.panDeltaX+=P),y?n.panDeltaZ+=P:_&&(n.panDeltaZ+=-P))}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}]),e}(),ap=re.vec3(),lp=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=t.camera,a=i.pickController,l=i.pivotController,u=i.panController,A=1,c=1,h=null;this._onTick=t.on("tick",(function(){if(r.active&&r.pointerEnabled){var e="default";if(Math.abs(n.dollyDelta)<.001&&(n.dollyDelta=0),Math.abs(n.rotateDeltaX)<.001&&(n.rotateDeltaX=0),Math.abs(n.rotateDeltaY)<.001&&(n.rotateDeltaY=0),0===n.rotateDeltaX&&0===n.rotateDeltaY||(n.dollyDelta=0),r.followPointer){if(--A<=0&&(A=1,0!==n.dollyDelta)){if(0===n.rotateDeltaY&&0===n.rotateDeltaX&&r.followPointer&&s.followPointerDirty&&(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),a.pickResult&&a.pickResult.worldPos?h=a.pickResult.worldPos:(c=1,h=null),s.followPointerDirty=!1),h){var i=Math.abs(re.lenVec3(re.subVec3(h,t.camera.eye,ap)));c=i/r.dollyProximityThreshold}c<r.dollyMinSpeed&&(c=r.dollyMinSpeed)}}else c=1,h=null;var d=n.dollyDelta*c;if(0===n.rotateDeltaY&&0===n.rotateDeltaX||(!r.firstPerson&&r.followPointer&&l.getPivoting()?(l.continuePivot(n.rotateDeltaY,n.rotateDeltaX),l.showPivot()):(0!==n.rotateDeltaX&&(r.firstPerson?o.pitch(-n.rotateDeltaX):o.orbitPitch(n.rotateDeltaX)),0!==n.rotateDeltaY&&(r.firstPerson?o.yaw(n.rotateDeltaY):o.orbitYaw(n.rotateDeltaY))),n.rotateDeltaX*=r.rotationInertia,n.rotateDeltaY*=r.rotationInertia,e="grabbing"),Math.abs(n.panDeltaX)<.001&&(n.panDeltaX=0),Math.abs(n.panDeltaY)<.001&&(n.panDeltaY=0),Math.abs(n.panDeltaZ)<.001&&(n.panDeltaZ=0),0!==n.panDeltaX||0!==n.panDeltaY||0!==n.panDeltaZ){var p,f,v=re.vec3();if(v[0]=n.panDeltaX,v[1]=n.panDeltaY,v[2]=n.panDeltaZ,r.constrainVertical){o.xUp?(p=o.eye[0],f=o.look[0]):o.yUp?(p=o.eye[1],f=o.look[1]):o.zUp&&(p=o.eye[2],f=o.look[2]),o.pan(v);var g=o.eye,m=o.look;o.xUp?(g[0]=p,m[0]=f):o.yUp?(g[1]=p,m[1]=f):o.zUp&&(g[2]=p,m[2]=f),o.eye=g,o.look=m}else o.pan(v);e="grabbing"}if(n.panDeltaX*=r.panInertia,n.panDeltaY*=r.panInertia,n.panDeltaZ*=r.panInertia,0!==d){if(e=d<0?"zoom-in":"zoom-out",r.firstPerson){var _,y;if(r.constrainVertical&&(o.xUp?(_=o.eye[0],y=o.look[0]):o.yUp?(_=o.eye[1],y=o.look[1]):o.zUp&&(_=o.eye[2],y=o.look[2])),r.followPointer)u.dollyToCanvasPos(h,s.pointerCanvasPos,-d)&&(s.followPointerDirty=!0);else o.pan([0,0,d]),o.ortho.scale=o.ortho.scale-d;if(r.constrainVertical){var b=o.eye,w=o.look;o.xUp?(b[0]=_,w[0]=y):o.yUp?(b[1]=_,w[1]=y):o.zUp&&(b[2]=_,w[2]=y),o.eye=b,o.look=w}}else if(r.planView){if(r.followPointer)u.dollyToCanvasPos(h,s.pointerCanvasPos,-d)&&(s.followPointerDirty=!0);else o.ortho.scale=o.ortho.scale+d,o.zoom(d)}else{if(r.followPointer)u.dollyToCanvasPos(h,s.pointerCanvasPos,-d)&&(s.followPointerDirty=!0);else o.ortho.scale=o.ortho.scale+d,o.zoom(d)}n.dollyDelta*=r.dollyInertia}a.fireEvents(),document.body.style.cursor=e}}))}return C(e,[{key:"destroy",value:function(){this._scene.off(this._onTick)}}]),e}(),up=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=this._scene.canvas.canvas;o.addEventListener("mouseenter",this._mouseEnterHandler=function(){s.mouseover=!0}),o.addEventListener("mouseleave",this._mouseLeaveHandler=function(){s.mouseover=!1,o.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=function(e){Ap(e,o,s.pointerCanvasPos)}),o.addEventListener("mousedown",this._mouseDownHandler=function(e){r.active&&r.pointerEnabled&&(Ap(e,o,s.pointerCanvasPos),s.mouseover=!0)}),o.addEventListener("mouseup",this._mouseUpHandler=function(e){r.active&&r.pointerEnabled})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;document.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("mouseleave",this._mouseLeaveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler)}}]),e}();function Ap(e,t,i){if(e){var r=t.getBoundingClientRect(),s=r.left,n=r.top;i[0]=e.clientX-s,i[1]=e.clientY-n}else e=window.event,i[0]=e.x,i[1]=e.y;return i}var cp=function(e,t){if(e){for(var i=e.target,r=0,s=0;i.offsetParent;)r+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-r,t[1]=e.pageY-s}else e=window.event,t[0]=e.x,t[1]=e.y;return t},hp=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=i.pickController,a=i.pivotController,l=re.vec2(),u=re.vec2(),A=re.vec2(),c=re.vec2(),h=[],d=this._scene.canvas.canvas,p=0,f=!1;this._onTick=t.on("tick",(function(){f=!1})),d.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(r.active&&r.pointerEnabled){e.preventDefault();var i=e.touches,n=e.changedTouches;for(s.touchStartTime=Date.now(),1===i.length&&1===n.length&&(cp(i[0],l),r.followPointer&&(o.pickCursorPos=l,o.schedulePickSurface=!0,o.update(),r.planView||(o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(a.setPivotPos(o.pickResult.worldPos),!r.firstPerson&&a.startPivot()&&a.showPivot()):(r.smartPivot?a.setCanvasPivotPos(s.pointerCanvasPos):a.setPivotPos(t.camera.look),!r.firstPerson&&a.startPivot()&&a.showPivot()))));h.length<i.length;)h.push(re.vec2());for(var u=0,A=i.length;u<A;++u)cp(i[u],h[u]);p=i.length}}),d.addEventListener("touchend",this._canvasTouchEndHandler=function(){a.getPivoting()&&a.endPivot()}),d.addEventListener("touchmove",this._canvasTouchMoveHandler=function(e){if(r.active&&r.pointerEnabled&&(e.stopPropagation(),e.preventDefault(),!f)){f=!0;var i=t.canvas.boundary,a=i[2],l=i[3],d=e.touches;if(e.touches.length===p){if(1===p){cp(d[0],u),re.subVec2(u,h[0],c);var v=c[0],g=c[1];if(null!==s.longTouchTimeout&&(Math.abs(v)>r.longTapRadius||Math.abs(g)>r.longTapRadius)&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),r.planView){var m=t.camera;if("perspective"===m.projection){var _=Math.abs(t.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);n.panDeltaX+=v*_/l*r.touchPanRate,n.panDeltaY+=g*_/l*r.touchPanRate}else n.panDeltaX+=.5*m.ortho.scale*(v/l)*r.touchPanRate,n.panDeltaY+=.5*m.ortho.scale*(g/l)*r.touchPanRate}else n.rotateDeltaY-=v/a*(1*r.dragRotationRate),n.rotateDeltaX+=g/l*(1.5*r.dragRotationRate)}else if(2===p){var y=d[0],b=d[1];cp(y,u),cp(b,A);var w=re.geometricMeanVec2(h[0],h[1]),B=re.geometricMeanVec2(u,A),x=re.vec2();re.subVec2(w,B,x);var P=x[0],C=x[1],M=t.camera,E=re.distVec2([y.pageX,y.pageY],[b.pageX,b.pageY]),F=(re.distVec2(h[0],h[1])-E)*r.touchDollyRate;if(n.dollyDelta=F,Math.abs(F)<1)if("perspective"===M.projection){var k=o.pickResult?o.pickResult.worldPos:t.center,I=Math.abs(re.lenVec3(re.subVec3(k,t.camera.eye,[])))*Math.tan(M.perspective.fov/2*Math.PI/180);n.panDeltaX-=P*I/l*r.touchPanRate,n.panDeltaY-=C*I/l*r.touchPanRate}else n.panDeltaX-=.5*M.ortho.scale*(P/l)*r.touchPanRate,n.panDeltaY-=.5*M.ortho.scale*(C/l)*r.touchPanRate;s.pointerCanvasPos=B}for(var D=0;D<p;++D)cp(d[D],h[D])}}})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("touchstart",this._canvasTouchStartHandler),e.removeEventListener("touchend",this._canvasTouchEndHandler),e.removeEventListener("touchmove",this._canvasTouchMoveHandler),this._scene.off(this._onTick)}}]),e}(),dp=function(e,t){if(e){for(var i=e.target,r=0,s=0;i.offsetParent;)r+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-r,t[1]=e.pageY-s}else e=window.event,t[0]=e.x,t[1]=e.y;return t},pp=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o,a=i.pickController,l=i.cameraControl,u=[],A=new Float32Array(2),c=-1,h=-1,d=this._scene.canvas.canvas,p=function(e){var r;e&&e.worldPos&&(r=e.worldPos);var s=e?e.entity.aabb:t.aabb;if(r){var n=t.camera;re.subVec3(n.eye,n.look,[]),i.cameraFlight.flyTo({aabb:s})}else i.cameraFlight.flyTo({aabb:s})};d.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(r.active&&r.pointerEnabled){null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null);var t=e.touches,n=e.changedTouches;if(o=Date.now(),1===t.length&&1===n.length){c=o,dp(t[0],A);var a=A[0],l=A[1],h=t[0].pageX,d=t[0].pageY;s.longTouchTimeout=setTimeout((function(){i.cameraControl.fire("rightClick",{pagePos:[Math.round(h),Math.round(d)],canvasPos:[Math.round(a),Math.round(l)],event:e},!0),s.longTouchTimeout=null}),r.longTapTimeout)}else c=-1;for(;u.length<t.length;)u.push(new Float32Array(2));for(var p=0,f=t.length;p<f;++p)dp(t[p],u[p]);u.length=t.length}},{passive:!0}),d.addEventListener("touchend",this._canvasTouchEndHandler=function(e){if(r.active&&r.pointerEnabled){var t=Date.now(),i=e.touches,n=e.changedTouches,o=l.hasSubs("pickedSurface");null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),0===i.length&&1===n.length&&c>-1&&t-c<150&&(h>-1&&c-h<325?(dp(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("doublePicked",a.pickResult),a.pickedSurface&&l.fire("doublePickedSurface",a.pickResult),r.doublePickFlyTo&&p(a.pickResult)):(l.fire("doublePickedNothing"),r.doublePickFlyTo&&p()),h=-1):re.distVec2(u[0],A)<4&&(dp(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("picked",a.pickResult),a.pickedSurface&&l.fire("pickedSurface",a.pickResult)):l.fire("pickedNothing"),h=t),c=-1),u.length=i.length;for(var d=0,f=i.length;d<f;++d)u[d][0]=i[d].pageX,u[d][1]=i[d].pageY}},{passive:!0})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("touchstart",this._canvasTouchStartHandler),e.removeEventListener("touchend",this._canvasTouchEndHandler)}}]),e}(),fp=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(r=t.call(this,e,s)).PAN_LEFT=0,r.PAN_RIGHT=1,r.PAN_UP=2,r.PAN_DOWN=3,r.PAN_FORWARDS=4,r.PAN_BACKWARDS=5,r.ROTATE_X_POS=6,r.ROTATE_X_NEG=7,r.ROTATE_Y_POS=8,r.ROTATE_Y_NEG=9,r.DOLLY_FORWARDS=10,r.DOLLY_BACKWARDS=11,r.AXIS_VIEW_RIGHT=12,r.AXIS_VIEW_BACK=13,r.AXIS_VIEW_LEFT=14,r.AXIS_VIEW_FRONT=15,r.AXIS_VIEW_TOP=16,r.AXIS_VIEW_BOTTOM=17,r._keyMap={},r.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},r._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:30,keyboardEnabledOnlyIfMouseover:!0,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},r._states={pointerCanvasPos:re.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:re.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},r._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};var n=r.scene;return r._controllers={cameraControl:b(r),pickController:new Yd(b(r),r._configs),pivotController:new Xd(n,r._configs),panController:new Vd(n),cameraFlight:new ld(b(r),{duration:.5})},r._handlers=[new up(r.scene,r._controllers,r._configs,r._states,r._updates),new hp(r.scene,r._controllers,r._configs,r._states,r._updates),new Zd(r.scene,r._controllers,r._configs,r._states,r._updates),new sp(r.scene,r._controllers,r._configs,r._states,r._updates),new np(r.scene,r._controllers,r._configs,r._states,r._updates),new pp(r.scene,r._controllers,r._configs,r._states,r._updates),new op(r.scene,r._controllers,r._configs,r._states,r._updates)],r._cameraUpdater=new lp(r.scene,r._controllers,r._configs,r._states,r._updates),r.navMode=s.navMode,s.planView&&(r.planView=s.planView),r.constrainVertical=s.constrainVertical,s.keyboardLayout?r.keyboardLayout=s.keyboardLayout:r.keyMap=s.keyMap,r.doublePickFlyTo=s.doublePickFlyTo,r.panRightClick=s.panRightClick,r.active=s.active,r.followPointer=s.followPointer,r.rotationInertia=s.rotationInertia,r.keyboardPanRate=s.keyboardPanRate,r.touchPanRate=s.touchPanRate,r.keyboardRotationRate=s.keyboardRotationRate,r.dragRotationRate=s.dragRotationRate,r.touchDollyRate=s.touchDollyRate,r.dollyInertia=s.dollyInertia,r.dollyProximityThreshold=s.dollyProximityThreshold,r.dollyMinSpeed=s.dollyMinSpeed,r.panInertia=s.panInertia,r.pointerEnabled=!0,r.keyboardDollyRate=s.keyboardDollyRate,r.mouseWheelDollyRate=s.mouseWheelDollyRate,r}return C(i,[{key:"keyMap",get:function(){return this._keyMap},set:function(e){if(e=e||"qwerty",he.isString(e)){var t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{var r=e;this._keyMap=r}}},{key:"_isKeyDownForAction",value:function(e,t){var i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(var r=0,s=i.length;r<s;r++){if(t[i[r]])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||30,this._configs.snapRadius=e}},{key:"keyboardEnabledOnlyIfMouseover",get:function(){return this._configs.keyboardEnabledOnlyIfMouseover},set:function(e){this._configs.keyboardEnabledOnlyIfMouseover=!!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,t=this._handlers.length;e<t;e++){var i=this._handlers[e];i.reset&&i.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.warn("planView property is deprecated - replaced with navMode"),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(),f(w(i.prototype),"destroy",this).call(this)}},{key:"_destroyHandlers",value:function(){for(var e=0,t=this._handlers.length;e<t;e++){var i=this._handlers[e];i.destroy&&i.destroy()}}},{key:"_destroyControllers",value:function(){for(var e=0,t=this._controllers.length;e<t;e++){var i=this._controllers[e];i.destroy&&i.destroy()}}}]),i}(),vp=C((function e(t,i,r,s,n){x(this,e),this.name=t,this.type=r,this.value=i,this.valueType=s,this.description=n})),gp=C((function e(t){if(x(this,e),this.id=t.id,this.originalSystemId=t.originalSystemId,this.metaModels=[],this.name=t.name,this.type=t.type,this.properties=[],t.properties)for(var i=t.properties,r=0,s=i.length;r<s;r++){var n=i[r];Number.isInteger(n)?this.properties.push(n):this.properties.push(new vp(n.name,n.value,n.type,n.valueType,n.description))}})),mp=function(){function e(t){x(this,e),this.metaModels=[],this.id=t.id,this.parentId=t.parentId,this.parent=null,this.originalSystemId=t.originalSystemId,this.name=t.name,this.type=t.type,this.propertySetIds=t.propertySetIds,this.propertySets=[],this.attributes=t.attributes||{},void 0!==t.external&&null!==t.external&&(this.external=t.external)}return C(e,[{key:"metaModel",get:function(){return 1==this.metaModels.length?this.metaModels[0]:null}},{key:"getObjectIDsInSubtree",value:function(){var e=[];return function t(i){if(i){e.push(i.id);var r=i.children;if(r)for(var s=0,n=r.length;s<n;s++)t(r[s])}}(this),e}},{key:"withMetaObjectsInSubtree",value:function(e){!function t(i){if(i){e(i);var r=i.children;if(r)for(var s=0,n=r.length;s<n;s++)t(r[s])}}(this)}},{key:"getObjectIDsInSubtreeByType",value:function(e){for(var t={},i=0,r=e.length;i<r;i++)t[e[i]]=e[i];var s=[];return function e(i){if(i){t[i.type]&&s.push(i.id);var r=i.children;if(r)for(var n=0,o=r.length;n<o;n++)e(r[n])}}(this),s}},{key:"getJSON",value:function(){var e={id:this.id,type:this.type,name:this.name};return this.parent&&(e.parent=this.parent.id),e}}]),e}(),_p=function(){function e(t){x(this,e),this.id=t.id,this.projectId=t.projectId,this.revisionId=t.revisionId,this.author=t.author,this.createdAt=t.createdAt,this.creatingApplication=t.creatingApplication,this.schema=t.schema,this.metaScene=t.metaScene,this.propertySets=[],this.rootMetaObjects=[],this.metaObjects=[],this.graph=t.graph||{},this.metaScene.metaModels[this.id]=this,this._propertyLookup=[],this.finalized=!1}return C(e,[{key:"rootMetaObject",get:function(){return 1===this.rootMetaObjects.length?this.rootMetaObjects[0]:null}},{key:"loadData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.finalized)throw"MetaScene already finalized - can't add more data";this._globalizeIDs(e,t);var i=this.metaScene,r=e.properties;if(r)for(var s=0,n=r.length;s<n;s++)this._propertyLookup.push(r[s]);if(e.propertySets)for(var o=0,a=e.propertySets.length;o<a;o++){var l=e.propertySets[o];l.properties||(l.properties=[]);var u=i.propertySets[l.id];u||(u=new gp({id:l.id,originalSystemId:l.originalSystemId||l.id,type:l.type,name:l.name,properties:l.properties}),i.propertySets[u.id]=u),u.metaModels.push(this),this.propertySets.push(u)}if(e.metaObjects)for(var A=0,c=e.metaObjects.length;A<c;A++){var h=e.metaObjects[A],d=h.id,p=i.metaObjects[d];if(!p){var f=h.type,v=h.originalSystemId,g=h.propertySets||h.propertySetIds;p=new mp({id:d,originalSystemId:v,parentId:h.parent,type:f,name:h.name,attributes:h.attributes,propertySetIds:g,external:h.external}),this.metaScene.metaObjects[d]=p,p.metaModels=[]}this.metaObjects.push(p),h.parent||(this.rootMetaObjects.push(p),i.rootMetaObjects[d]=p)}}},{key:"_decompressProperties",value:function(e,t){for(var i=[],r=0,s=t.length;r<s;r++){var n=t[r];if(Number.isInteger(n)){var o=e[n];o?t[r]=o:i.push(n)}}i.length>0&&console.error("[MetaModel._decompressProperties] Properties not found: ".concat(i))}},{key:"finalize",value:function(){if(this.finalized)throw"MetaScene already finalized - can't re-finalize";var e=this.metaScene;for(var t in e.metaObjects){var i=e.metaObjects[t];if(i.children&&(i.children=[]),i.propertySets&&(i.propertySets=[]),i.propertySetIds)for(var r=0,s=i.propertySetIds.length;r<s;r++){var n=i.propertySetIds[r],o=e.propertySets[n];i.propertySets.push(o)}}for(var a in e.metaObjects){var l=e.metaObjects[a];if(l.parentId){var u=e.metaObjects[l.parentId];u&&(l.parent=u,(u.children||(u.children=[])).push(l))}}for(var A in e.metaObjects){e.metaObjects[A].metaModels=[]}for(var c in e.metaModels)for(var h=e.metaModels[c],d=0,p=h.metaObjects.length;d<p;d++){h.metaObjects[d].metaModels.push(h)}for(var f in e.metaObjectsByType={},e.metaObjects){var v=e.metaObjects[f],g=v.type;(e.metaObjectsByType[g]||(e.metaObjectsByType[g]={}))[f]=v}if(this.propertySets)for(var m=0,_=this.propertySets.length;m<_;m++){var y=this.propertySets[m];this._decompressProperties(this._propertyLookup,y.properties)}this._propertyLookup=[],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:[]},t=0,i=this.metaObjects.length;t<i;t++){var r=this.metaObjects[t],s={id:r.id,originalSystemId:r.originalSystemId,extId:r.extId,type:r.type,name:r.name};r.parent&&(s.parent=r.parent.id),r.attributes&&(s.attributes=r.attributes),r.propertySetIds&&(s.propertySetIds=r.propertySetIds),e.metaObjects.push(s)}for(var n=0,o=this.propertySets.length;n<o;n++){for(var a=this.propertySets[n],l={id:a.id,originalSystemId:a.originalSystemId,extId:a.extId,type:a.type,name:a.name,propertyies:[]},u=0,A=a.properties.length;u<A;u++){var c=a.properties[u],h={id:c.id,description:c.description,type:c.type,name:c.name,value:c.value,valueType:c.valueType};l.properties.push(h)}e.propertySets.push(l)}return e}},{key:"_globalizeIDs",value:function(e,t){var i=!!t.globalizeObjectIds;if(e.metaObjects)for(var r=0,s=e.metaObjects.length;r<s;r++){var n=e.metaObjects[r];if(n.originalSystemId=n.id,n.parent&&(n.originalParentSystemId=n.parent),i&&(n.id=re.globalizeObjectId(this.id,n.id),n.parent&&(n.parent=re.globalizeObjectId(this.id,n.parent))),i){var o=n.propertySetIds;if(o){for(var a=[],l=0,u=o.length;l<u;l++)a.push(re.globalizeObjectId(this.id,o[l]));n.propertySetIds=a,n.originalSystemPropertySetIds=o}}else n.originalSystemPropertySetIds=n.propertySetIds}if(e.propertySets)for(var A=0,c=e.propertySets.length;A<c;A++){var h=e.propertySets[A];h.originalSystemId=h.id,i&&(h.id=re.globalizeObjectId(this.id,h.id))}}}]),e}(),yp=function(){function e(t,i){x(this,e),this.viewer=t,this.scene=i,this.metaModels={},this.propertySets={},this.metaObjects={},this.metaObjectsByType={},this.rootMetaObjects={},this._eventSubs={}}return C(e,[{key:"on",value:function(e,t){var i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}},{key:"fire",value:function(e,t){var i=this._eventSubs[e];if(i)for(var r=0,s=i.length;r<s;r++)i[r](t)}},{key:"off",value:function(e){}},{key:"createMetaModel",value:function(e,t){var i=new _p({metaScene:this,id:e,projectId:t.projectId||"none",revisionId:t.revisionId||"none",author:t.author||"none",createdAt:t.createdAt||"none",creatingApplication:t.creatingApplication||"none",schema:t.schema||"none",propertySets:[]});return i.loadData(t),i.finalize(),i}},{key:"destroyMetaModel",value:function(e){var t=this.metaModels[e];if(t){if(t.propertySets)for(var i=0,r=t.propertySets.length;i<r;i++){var s=t.propertySets[i];if(1===s.metaModels.length&&s.metaModels[0].id===e)delete this.propertySets[s.id];else{for(var n=[],o=0,a=s.metaModels.length;o<a;o++)s.metaModels[o].id!==e&&n.push(s.metaModels[o]);s.metaModels=n}}if(t.metaObjects)for(var l=0,u=t.metaObjects.length;l<u;l++){var A=t.metaObjects[l];A.type;var c=A.id;1===A.metaModels.length&&A.metaModels[0].id===e&&(delete this.metaObjects[c],A.parent||delete this.rootMetaObjects[c])}for(var h in this.metaObjects){var d=this.metaObjects[h];if(d.children&&(d.children=[]),d.propertySets&&(d.propertySets=[]),d.propertySetIds)for(var p=0,f=d.propertySetIds.length;p<f;p++){var v=d.propertySetIds[p],g=this.propertySets[v];d.propertySets.push(g)}}for(var m in this.metaObjectsByType={},this.metaObjects){var _=this.metaObjects[m],y=_.type;_.children&&(_.children=null),(this.metaObjectsByType[y]||(this.metaObjectsByType[y]={}))[m]=_}for(var b in this.metaObjects){var w=this.metaObjects[b];if(w.parentId){var B=this.metaObjects[w.parentId];B&&(w.parent=B,(B.children||(B.children=[])).push(w))}}for(var x in delete this.metaModels[e],this.metaObjects){this.metaObjects[x].metaModels=[]}for(var P in this.metaModels)for(var C=this.metaModels[P],M=0,E=C.metaObjects.length;M<E;M++){C.metaObjects[M].metaModels.push(C)}this.fire("metaModelDestroyed",e)}}},{key:"getObjectIDsByType",value:function(e){var t=this.metaObjectsByType[e];return t?Object.keys(t):[]}},{key:"getObjectIDsInSubtree",value:function(e,t,i){var r=[],s=this.metaObjects[e],n=t&&t.length>0?bp(t):null,o=i&&i.length>0?bp(i):null;return function e(t){if(t){var i=!0;(o&&o[t.type]||n&&!n[t.type])&&(i=!1),i&&r.push(t.id);var s=t.children;if(s)for(var a=0,l=s.length;a<l;a++)e(s[a])}}(s),r}},{key:"withMetaObjectsInSubtree",value:function(e,t){var i=this.metaObjects[e];i&&i.withMetaObjectsInSubtree(t)}}]),e}();function bp(e){for(var t={},i=0,r=e.length;i<r;i++)t[e[i]]=!0;return t}
|
|
17
|
+
**/var ih=null;function rh(e,t){var i,r,s,n,o,a,l=3*e,u=3*t,A=Math.min(i=ih[l],r=ih[l+1],s=ih[l+2]),c=Math.min(n=ih[u],o=ih[u+1],a=ih[u+2]);if(A!==c)return A-c;var h=Math.max(i,r,s),d=Math.max(n,o,a);return h!==d?h-d:0}function sh(e,t){for(var i=new Int32Array(e.length/3),r=0,s=i.length;r<s;r++)i[r]=r;ih=new Int32Array(e.length);for(var n=0,o=e.length;n<o;n++)ih[n]=e[n]>>t;i.sort(rh);for(var a=new Int32Array(e.length),l=0,u=i.length;l<u;l++)a[3*l+0]=e[3*i[l]+0],a[3*l+1]=e[3*i[l]+1],a[3*l+2]=e[3*i[l]+2];return a}var nh=null;function oh(e,t){var i=nh[2*e]-nh[2*t];return 0!==i?i:nh[2*e+1]-nh[2*t+1]}function ah(e){if(0===(e||[]).length)return[];for(var t=new Int32Array(e.length/2),i=0,r=t.length;i<r;i++)t[i]=i;for(var s=0,n=e.length;s<n;s+=2)if(e[s]>e[s+1]){var o=e[s];e[s]=e[s+1],e[s+1]=o}nh=new Int32Array(e),t.sort(oh);for(var a=new Int32Array(e.length),l=0,u=t.length;l<u;l++)a[2*l+0]=e[2*t[l]+0],a[2*l+1]=e[2*t[l]+1];return a}function lh(e,t){var i={},r={};e.forEach((function(e){for(var t=e.indices,s=e.edgeIndices,n=e.positionsCompressed,o=0,a=t.length;o<a;o+=3){var l=n[3*t[o]]+"_"+n[3*t[o]+1]+"_"+n[3*t[o]+2]+"/"+n[3*t[o+1]]+"_"+n[3*t[o+1]+1]+"_"+n[3*t[o+1]+2]+"/"+n[3*t[o+2]]+"_"+n[3*t[o+2]+1]+"_"+n[3*t[o+2]+2];i[l]=!0}e.edgeIndices.length/2;for(var u=0,A=s.length;u<A;u+=2){var c=n[3*s[u]]+"_"+n[3*s[u]+1]+"_"+n[3*s[u]+2]+"/"+n[3*s[u+1]]+"_"+n[3*s[u+1]+1]+"_"+n[3*s[u+1]+2]+"/";r[c]=!0}}));var s=t.indices;t.edgeIndices;for(var n=t.positionsCompressed,o=0,a=s.length;o<a;o+=3){var l=n[3*s[o]]+"_"+n[3*s[o]+1]+"_"+n[3*s[o]+2]+"/"+n[3*s[o+1]]+"_"+n[3*s[o+1]+1]+"_"+n[3*s[o+1]+2]+"/"+n[3*s[o+2]]+"_"+n[3*s[o+2]+1]+"_"+n[3*s[o+2]+2];if(!(l in i))throw console.log("Not found "+l),"Ohhhh!"}}var uh=re.vec4(4),Ah=re.vec4(),ch=re.vec4(),hh=re.vec3([1,0,0]),dh=re.vec3([0,1,0]),ph=re.vec3([0,0,1]);re.vec3(3),re.vec3(3);var fh=re.identityMat4(),vh=function(){function e(t){x(this,e),this._model=t.model,this.id=t.id,this._parentTransform=t.parent,this._childTransforms=[],this._meshes=[],this._scale=new Float32Array([1,1,1]),this._quaternion=re.identityQuaternion(new Float32Array(4)),this._rotation=new Float32Array(3),this._position=new Float32Array(3),this._localMatrix=re.identityMat4(new Float32Array(16)),this._worldMatrix=re.identityMat4(new Float32Array(16)),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,t.matrix?this.matrix=t.matrix:(this.scale=t.scale,this.position=t.position,t.quaternion||(this.rotation=t.rotation)),t.parent&&t.parent._addChildTransform(this)}return C(e,[{key:"_addChildTransform",value:function(e){this._childTransforms.push(e),e._parentTransform=this,e._transformDirty(),e._setSubtreeAABBsDirty(this)}},{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]),re.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]),re.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=re.identityMat4()),re.composeMat4(this._position,this._quaternion,this._scale,this._localMatrix),this._localMatrixDirty=!1),this._localMatrix},set:function(e){this._localMatrix||(this._localMatrix=re.identityMat4()),this._localMatrix.set(e||fh),re.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,t){return uh[0]=e[0],uh[1]=e[1],uh[2]=e[2],uh[3]=t*re.DEGTORAD,re.angleAxisToQuaternion(uh,Ah),re.mulQuaternions(this.quaternion,Ah,ch),this.quaternion=ch,this._setLocalMatrixDirty(),this._model.glRedraw(),this}},{key:"rotateOnWorldAxis",value:function(e,t){return uh[0]=e[0],uh[1]=e[1],uh[2]=e[2],uh[3]=t*re.DEGTORAD,re.angleAxisToQuaternion(uh,Ah),re.mulQuaternions(Ah,this.quaternion,Ah),this}},{key:"rotateX",value:function(e){return this.rotate(hh,e)}},{key:"rotateY",value:function(e){return this.rotate(dh,e)}},{key:"rotateZ",value:function(e){return this.rotate(ph,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,t=this._childTransforms.length;e<t;e++){var i=this._childTransforms[e];if(i._transformDirty(),i._meshes&&i._meshes.length>0)for(var r=i._meshes,s=0,n=r.length;s<n;s++)r[s]._transformDirty()}if(this._meshes&&this._meshes.length>0)for(var o=this._meshes,a=0,l=o.length;a<l;a++)o[a]._transformDirty()}},{key:"_buildWorldMatrix",value:function(){var e=this.matrix;if(this._parentTransform)re.mulMat4(this._parentTransform.worldMatrix,e,this._worldMatrix);else for(var t=0,i=e.length;t<i;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}},{key:"_setSubtreeAABBsDirty",value:function(e){if(e._aabbDirty=!0,e._childTransforms)for(var t=0,i=e._childTransforms.length;t<i;t++)this._setSubtreeAABBsDirty(e._childTransforms[t])}}]),e}(),gh=re.vec3(),mh=re.OBB3(),_h=re.vec4(),yh=re.vec3([1,1,1]),bh=re.vec3([0,0,0]);re.vec3([0,0,0]);var wh=re.identityQuaternion(),Bh=re.identityMat4(),xh=new Uint8Array([255,255,255]),Ph=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).renderOrder=s.renderOrder||0,r._dtxEnabled=r.scene.dtxEnabled&&!1!==s.dtxEnabled,r._enableVertexWelding=!1,r._enableIndexBucketing=!1,r._vboBatchingLayerScratchMemory=yo(),r._textureTranscoder=s.textureTranscoder||Zc(r.scene.viewer),r._maxGeometryBatchSize=s.maxGeometryBatchSize,r._aabb=re.collapseAABB3(),r._aabbDirty=!0,r._quantizationRanges={},r._vboInstancingLayers={},r._vboBatchingLayers={},r._dtxLayers={},r._meshList=[],r.layerList=[],r._entityList=[],r._geometries={},r._dtxBuckets={},r._textures={},r._textureSets={},r._transforms={},r._meshes={},r._unusedMeshes={},r._entities={},r.renderFlags=new on,r.numGeometries=0,r.numPortions=0,r.numVisibleLayerPortions=0,r.numTransparentLayerPortions=0,r.numXRayedLayerPortions=0,r.numHighlightedLayerPortions=0,r.numSelectedLayerPortions=0,r.numEdgesLayerPortions=0,r.numPickableLayerPortions=0,r.numClippableLayerPortions=0,r.numCulledLayerPortions=0,r.numEntities=0,r._numTriangles=0,r._numLines=0,r._numPoints=0,r._edgeThreshold=s.edgeThreshold||10,r._origin=re.vec3(s.origin||[0,0,0]),r._position=re.vec3(s.position||[0,0,0]),r._rotation=re.vec3(s.rotation||[0,0,0]),r._quaternion=re.vec4(s.quaternion||[0,0,0,1]),r._conjugateQuaternion=re.vec4(s.quaternion||[0,0,0,1]),s.rotation&&re.eulerToQuaternion(r._rotation,"XYZ",r._quaternion),r._scale=re.vec3(s.scale||[1,1,1]),r._worldRotationMatrix=re.mat4(),r._worldRotationMatrixConjugate=re.mat4(),r._matrix=re.mat4(),r._matrixDirty=!0,r._rebuildMatrices(),r._worldNormalMatrix=re.mat4(),re.inverseMat4(r._matrix,r._worldNormalMatrix),re.transposeMat4(r._worldNormalMatrix),(s.matrix||s.position||s.rotation||s.scale||s.quaternion)&&(r._viewMatrix=re.mat4(),r._viewNormalMatrix=re.mat4(),r._viewMatrixDirty=!0,r._matrixNonIdentity=!0),r._opacity=1,r._colorize=[1,1,1],r._saoEnabled=!1!==s.saoEnabled,r._pbrEnabled=!1!==s.pbrEnabled,r._colorTextureEnabled=!1!==s.colorTextureEnabled,r._isModel=s.isModel,r._isModel&&r.scene._registerModel(b(r)),r._onCameraViewMatrix=r.scene.camera.on("matrix",(function(){r._viewMatrixDirty=!0})),r._meshesWithDirtyMatrices=[],r._numMeshesWithDirtyMatrices=0,r._onTick=r.scene.on("tick",(function(){for(;r._numMeshesWithDirtyMatrices>0;)r._meshesWithDirtyMatrices[--r._numMeshesWithDirtyMatrices]._updateMatrix()})),r._createDefaultTextureSet(),r.visible=s.visible,r.culled=s.culled,r.pickable=s.pickable,r.clippable=s.clippable,r.collidable=s.collidable,r.castsShadow=s.castsShadow,r.receivesShadow=s.receivesShadow,r.xrayed=s.xrayed,r.highlighted=s.highlighted,r.selected=s.selected,r.edges=s.edges,r.colorize=s.colorize,r.opacity=s.opacity,r.backfaces=s.backfaces,r}return C(i,[{key:"_meshMatrixDirty",value:function(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}},{key:"_createDefaultTextureSet",value:function(){var e=new Qc({id:"defaultColorTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new Qc({id:"defaultMetalRoughTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new Qc({id:"defaultNormalsTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),r=new Qc({id:"defaultEmissiveTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),s=new Qc({id:"defaultOcclusionTexture",texture:new Gn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=r,this._textures.defaultOcclusionTexture=s,this._textureSets.defaultTextureSet=new Nc({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:r,occlusionTexture:s})}},{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]),re.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]),re.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||Bh),re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),re.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),re.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&&(re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),re.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),re.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),re.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,t=this._entityList.length;e<t;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&&(re.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),re.inverseMat4(this._viewMatrix,this._viewNormalMatrix),re.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&&(re.mulMat4(this.scene.camera.viewMatrix,this._matrix,this._viewMatrix),re.inverseMat4(this._viewMatrix,this._viewNormalMatrix),re.transposeMat4(this._viewNormalMatrix),this._viewMatrixDirty=!1),re.inverseMat4(this._viewMatrix,this._viewNormalMatrix),re.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){re.collapseAABB3(this._aabb);for(var e=0,t=this._entityList.length;e<t;e++)re.expandAABB3(this._aabb,this._entityList[e].aabb);this._aabbDirty=!1}return this._aabb}},{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 t=0,i=this._entityList.length;t<i;t++)this._entityList[t].visible=e;this.glRedraw()}},{key:"xrayed",get:function(){return this.numXRayedLayerPortions>0},set:function(e){e=!!e,this._xrayed=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].xrayed=e;this.glRedraw()}},{key:"highlighted",get:function(){return this.numHighlightedLayerPortions>0},set:function(e){e=!!e,this._highlighted=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].highlighted=e;this.glRedraw()}},{key:"selected",get:function(){return this.numSelectedLayerPortions>0},set:function(e){e=!!e,this._selected=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].selected=e;this.glRedraw()}},{key:"edges",get:function(){return this.numEdgesLayerPortions>0},set:function(e){e=!!e,this._edges=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].edges=e;this.glRedraw()}},{key:"culled",get:function(){return this._culled},set:function(e){e=!!e,this._culled=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].culled=e;this.glRedraw()}},{key:"clippable",get:function(){return this._clippable},set:function(e){e=!1!==e,this._clippable=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].clippable=e;this.glRedraw()}},{key:"collidable",get:function(){return this._collidable},set:function(e){e=!1!==e,this._collidable=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].collidable=e}},{key:"pickable",get:function(){return this.numPickableLayerPortions>0},set:function(e){e=!1!==e,this._pickable=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].pickable=e}},{key:"colorize",get:function(){return this._colorize},set:function(e){this._colorize=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].colorize=e}},{key:"opacity",get:function(){return this._opacity},set:function(e){this._opacity=e;for(var t=0,i=this._entityList.length;t<i;t++)this._entityList[t].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:pa(e.aabb,re.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||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){var t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}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=pa(e.positionsDecodeBoundary,re.mat4())),e.positions){var i=re.collapseAABB3();e.positionsDecodeMatrix=re.mat4(),re.expandAABB3Points3(i,e.positions),e.positionsCompressed=da(e.positions,i,e.positionsDecodeMatrix),e.aabb=i}else if(e.positionsCompressed){var r=re.collapseAABB3();e.positionsDecodeMatrix=new Float64Array(e.positionsDecodeMatrix),e.positionsCompressed=new Uint16Array(e.positionsCompressed),re.expandAABB3Points3(r,e.positionsCompressed),ji.decompressAABB(r,e.positionsDecodeMatrix),e.aabb=r}else if(e.buckets){var s=re.collapseAABB3();this._dtxBuckets[e.id]=e.buckets;for(var n=0,o=e.buckets.length;n<o;n++){var a=e.buckets[n];a.positions?re.expandAABB3Points3(s,a.positions):a.positionsCompressed&&re.expandAABB3Points3(s,a.positionsCompressed)}e.positionsDecodeMatrix&&ji.decompressAABB(s,e.positionsDecodeMatrix),e.aabb=s}if(e.colorsCompressed&&e.colorsCompressed.length>0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){for(var l=e.colors,u=new Uint8Array(l.length),A=0,c=l.length;A<c;A++)u[A]=255*l[A];e.colorsCompressed=u}if(e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=Ri(e.positions,e.indices,null,5):e.edgeIndices=Ri(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.uv){var h=ji.getUVBounds(e.uv),d=ji.compressUVs(e.uv,h.min,h.max);e.uvCompressed=d.quantized,e.uvDecodeMatrix=d.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 t=this,i=e.id;if(null!=i)if(this._textures[i])this.error("[createTexture] Texture already created: "+i);else{if(!e.src&&!e.image&&!e.buffers)return this.error("[createTexture] Param expected: `src`, `image' or 'buffers'"),null;var r=e.minFilter||1008;1006!==r&&1007!==r&&1008!==r&&1005!==r&&1004!==r&&(this.error("[createTexture] Unsupported value for 'minFilter' - \n supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, \n NearestMipMapLinearFilter and LinearMipmapLinearFilter. Defaulting to LinearMipmapLinearFilter."),r=1008);var s=e.magFilter||1006;1006!==s&&1003!==s&&(this.error("[createTexture] Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter."),s=1006);var n=e.wrapS||1e3;1001!==n&&1002!==n&&1e3!==n&&(this.error("[createTexture] Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),n=1e3);var o=e.wrapT||1e3;1001!==o&&1002!==o&&1e3!==o&&(this.error("[createTexture] Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),o=1e3);var a=e.wrapR||1e3;1001!==a&&1002!==a&&1e3!==a&&(this.error("[createTexture] Unsupported value for 'wrapR' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping."),a=1e3);var l=e.encoding||3e3;3e3!==l&&3001!==l&&(this.error("[createTexture] Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),l=3e3);var u=new Gn({gl:this.scene.canvas.gl,minFilter:r,magFilter:s,wrapS:n,wrapT:o,wrapR:a,encoding:l});if(e.preloadColor&&u.setPreloadColor(e.preloadColor),e.image){var A=e.image;A.crossOrigin="Anonymous",u.setImage(A,{minFilter:r,magFilter:s,wrapS:n,wrapT:o,wrapR:a,flipY:e.flipY,encoding:l})}else if(e.src){var c=e.src.split(".").pop();switch(c){case"jpeg":case"jpg":case"png":case"gif":var h=new Image;h.onload=function(){u.setImage(h,{minFilter:r,magFilter:s,wrapS:n,wrapT:o,wrapR:a,flipY:e.flipY,encoding:l}),t.glRedraw()},h.src=e.src;break;default:this._textureTranscoder?he.loadArraybuffer(e.src,(function(e){e.byteLength?t._textureTranscoder.transcode([e],u).then((function(){t.glRedraw()})):t.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(c,"')"))}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,u).then((function(){t.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[i]=new Qc({id:i,texture:u})}else this.error("[createTexture] Config missing: id")}},{key:"createTextureSet",value:function(e){var t=e.id;if(null!=t){if(!this._textureSets[t]){var i,r,s,n,o;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(!(i=this._textures[e.colorTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.colorTextureId," - ensure that you create it first with createTexture()"))}else i=this._textures.defaultColorTexture;if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(!(r=this._textures[e.metallicRoughnessTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.metallicRoughnessTextureId," - ensure that you create it first with createTexture()"))}else r=this._textures.defaultMetalRoughTexture;if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(!(s=this._textures[e.normalsTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.normalsTextureId," - ensure that you create it first with createTexture()"))}else s=this._textures.defaultNormalsTexture;if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(!(n=this._textures[e.emissiveTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.emissiveTextureId," - ensure that you create it first with createTexture()"))}else n=this._textures.defaultEmissiveTexture;if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(!(o=this._textures[e.occlusionTextureId]))return void this.error("[createTextureSet] Texture not found: ".concat(e.occlusionTextureId," - ensure that you create it first with createTexture()"))}else o=this._textures.defaultOcclusionTexture;var a=new Nc({id:t,model:this,colorTexture:i,metallicRoughnessTexture:r,normalsTexture:s,emissiveTexture:n,occlusionTexture:o});return this._textureSets[t]=a,a}this.error("[createTextureSet] Texture set already created: ".concat(t))}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 t;if(!e.parentTransformId||(t=this._transforms[e.parentTransformId])){var i=new vh({id:e.id,model:this,parent:t,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[i.id]=i,i}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._meshes[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||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){var t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}if(!e.buckets&&!e.indices&&"points"!==e.primitive)return e.indices=this._createDefaultIndices(numIndices),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 i=!(!this._dtxEnabled||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||e.textureSetId);if(e.origin=e.origin?re.addVec3(this._origin,e.origin,re.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position||e.quaternion){var r=e.scale||yh,s=e.position||bh;e.rotation?(re.eulerToQuaternion(e.rotation,"XYZ",_h),e.meshMatrix=re.composeMat4(s,_h,r,re.mat4())):e.meshMatrix=re.composeMat4(s,e.quaternion||wh,r,re.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=pa(e.positionsDecodeBoundary,re.mat4())),i){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])]):xh,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){var n=re.vec3(),o=[];je(e.positions,o,n)&&(e.positions=o,e.origin=re.addVec3(e.origin,n,n))}if(e.positions){var a=re.collapseAABB3();e.positionsDecodeMatrix=re.mat4(),re.expandAABB3Points3(a,e.positions),e.positionsCompressed=da(e.positions,a,e.positionsDecodeMatrix),e.aabb=a}else if(e.positionsCompressed){var l=re.collapseAABB3();re.expandAABB3Points3(l,e.positionsCompressed),ji.decompressAABB(l,e.positionsDecodeMatrix),e.aabb=l}if(e.buckets){for(var u=re.collapseAABB3(),A=0,c=e.buckets.length;A<c;A++){var h=e.buckets[A];h.positions?re.expandAABB3Points3(u,h.positions):h.positionsCompressed&&re.expandAABB3Points3(u,h.positionsCompressed)}e.positionsDecodeMatrix&&ji.decompressAABB(u,e.positionsDecodeMatrix),e.aabb=u}e.meshMatrix&&(re.AABB3ToOBB3(e.aabb,mh),re.transformOBB3(e.meshMatrix,mh),re.OBB3ToAABB3(mh,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=Ri(e.positions,e.indices,null,2):e.edgeIndices=Ri(e.positionsCompressed,e.indices,e.positionsDecodeMatrix,2)),e.buckets||(e.buckets=Ch(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=[];je(e.positions,d,gh)&&(e.positions=d,e.origin=re.addVec3(e.origin,gh,re.vec3()))}if(e.positions){var p=re.collapseAABB3();e.meshMatrix&&(re.transformPositions3(e.meshMatrix,e.positions,e.positions),e.meshMatrix=null),re.expandAABB3Points3(p,e.positions),e.aabb=p}else{var f=re.collapseAABB3();re.expandAABB3Points3(f,e.positionsCompressed),ji.decompressAABB(f,e.positionsDecodeMatrix),e.aabb=f}if(e.meshMatrix&&(re.AABB3ToOBB3(e.aabb,mh),re.transformOBB3(e.meshMatrix,mh),re.OBB3ToAABB3(mh,e.aabb)),e.buckets||e.edgeIndices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||(e.positions?e.edgeIndices=Ri(e.positions,e.indices,null,2):e.edgeIndices=Ri(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?re.addVec3(this._origin,e.origin,re.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;else if(e.scale||e.rotation||e.position||e.quaternion){var v=e.scale||yh,g=e.position||bh;e.rotation?(re.eulerToQuaternion(e.rotation,"XYZ",_h),e.meshMatrix=re.composeMat4(g,_h,v,re.mat4())):e.meshMatrix=re.composeMat4(g,e.quaternion||wh,v,re.mat4())}re.AABB3ToOBB3(e.geometry.aabb,mh),re.transformOBB3(e.meshMatrix,mh),e.aabb=re.OBB3ToAABB3(mh,re.AABB3())}if(!(!this._dtxEnabled||"triangles"!==e.geometry.primitive&&"solid"!==e.geometry.primitive&&"surface"!==e.geometry.primitive||e.textureSetId)){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])]):xh,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255;var m=this._dtxBuckets[e.geometryId];m||(m=Ch(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])]):xh,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._createMesh(e)}},{key:"_createMesh",value:function(e){var t=new go(this,e.id,e.color,e.opacity,e.transform,e.textureSet);t.pickId=this.scene._renderer.getPickID(t);var i=t.pickId,r=i>>24&255,s=i>>16&255,n=i>>8&255,o=255&i;switch(e.pickColor=new Uint8Array([o,n,s,r]),e.solid="solid"===e.primitive,t.origin=re.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}},{key:"_getNumPrimitives",value:function(e){var t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(var i=0,r=e.buckets.length;i<r;i++)t+=e.buckets[i].indices.length;break;case 1:t+=e.indices.length;break;case 0:t+=e.geometry.indices.length}return Math.round(t/3);case"points":switch(e.type){case 2:for(var s=0,n=e.buckets.length;s<n;s++)t+=e.buckets[s].positionsCompressed.length;break;case 1:t+=e.positions?e.positions.length:e.positionsCompressed.length;break;case 0:var o=e.geometry;t+=o.positions?o.positions.length:o.positionsCompressed.length}return Math.round(t);case"lines":case"line-strip":switch(e.type){case 2:for(var a=0,l=e.buckets.length;a<l;a++)t+=e.buckets[a].indices.length;break;case 1:t+=e.indices.length;break;case 0:t+=e.geometry.indices.length}return Math.round(t/2)}return 0}},{key:"_getDTXLayer",value:function(e){var t=e.origin,i=e.geometry?e.geometry.primitive:e.primitive,r=".".concat(i,".").concat(Math.round(t[0]),".").concat(Math.round(t[1]),".").concat(Math.round(t[2])),s=this._dtxLayers[r];if(s){if(s.canCreatePortion(e))return s;s.finalize(),delete this._dtxLayers[r],s=null}switch(i){case"triangles":case"solid":case"surface":s=new Oc(this,{layerIndex:0,origin:t});break;case"lines":s=new fA(this,{layerIndex:0,origin:t});break;default:return}return this._dtxLayers[r]=s,this.layerList.push(s),s}},{key:"_getVBOBatchingLayer",value:function(e){var t=this,i=e.origin;e.renderLayer;var r=e.positionsDecodeMatrix||e.positionsDecodeBoundary?this._createHashStringFromMatrix(e.positionsDecodeMatrix||e.positionsDecodeBoundary):"-",s=e.textureSetId||"-",n="".concat(Math.round(i[0]),".").concat(Math.round(i[1]),".").concat(Math.round(i[2]),".").concat(e.primitive,".").concat(r,".").concat(s),o=this._vboBatchingLayers[n];if(o)return o;for(var a=e.textureSet;!o;){switch(e.primitive){case"triangles":case"solid":case"surface":o=new Ma({model:t,textureSet:a,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:i,maxGeometryBatchSize:this._maxGeometryBatchSize,solid:"solid"===e.primitive,autoNormals:!0});break;case"lines":o=new Ul({model:t,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:i,maxGeometryBatchSize:this._maxGeometryBatchSize});break;case"points":o=new Pu({model:t,layerIndex:0,scratchMemory:this._vboBatchingLayerScratchMemory,positionsDecodeMatrix:e.positionsDecodeMatrix,uvDecodeMatrix:e.uvDecodeMatrix,origin:i,maxGeometryBatchSize:this._maxGeometryBatchSize})}var l=e.positionsCompressed?e.positionsCompressed.length:e.positions.length;("points"===e.primitive?o.canCreatePortion(l):o.canCreatePortion(l,e.indices.length))||(o.finalize(),delete this._vboBatchingLayers[n],o=null)}return this._vboBatchingLayers[n]=o,this.layerList.push(o),o}},{key:"_createHashStringFromMatrix",value:function(e){for(var t=e.join(""),i=0,r=0;r<t.length;r++){i=(i<<5)-i+t.charCodeAt(r),i|=0}return(i>>>0).toString(16)}},{key:"_getVBOInstancingLayer",value:function(e){var t=this,i=e.origin,r=e.textureSetId||"-",s=e.geometryId,n="".concat(Math.round(i[0]),".").concat(Math.round(i[1]),".").concat(Math.round(i[2]),".").concat(r,".").concat(s),o=this._vboInstancingLayers[n];if(o)return o;for(var a=e.textureSet,l=e.geometry;!o;)switch(l.primitive){case"triangles":case"surface":o=new ml({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":o=new ml({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":o=new ru({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":o=new Ju({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[n]=o,this.layerList.push(o),o}},{key:"createEntity",value:function(e){if(void 0===e.id?e.id=re.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=re.createUUID()),void 0!==e.meshIds){var t=0;this._visible&&!1!==e.visible&&(t|=We),this._pickable&&!1!==e.pickable&&(t|=Xe),this._culled&&!1!==e.culled&&(t|=Ke),this._clippable&&!1!==e.clippable&&(t|=Ye),this._collidable&&!1!==e.collidable&&(t|=Je),this._edges&&!1!==e.edges&&(t|=et),this._xrayed&&!1!==e.xrayed&&(t|=Ze),this._highlighted&&!1!==e.highlighted&&(t|=qe),this._selected&&!1!==e.selected&&(t|=$e),e.flags=t,this._createEntity(e)}else this.error("Config missing: meshIds")}},{key:"_createEntity",value:function(e){for(var t=[],i=0,r=e.meshIds.length;i<r;i++){var s=e.meshIds[i],n=this._meshes[s];n?n.parent?this.error('Mesh with ID "'.concat(s,'" already belongs to object with ID "').concat(n.parent.id,'" - ignoring this mesh')):(t.push(n),delete this._unusedMeshes[s]):this.error('Mesh with this ID not found: "'.concat(s,'" - ignoring this mesh'))}var o=new rt(this,e.isObject,e.id,t,e.flags,!0);this._entityList.push(o),this._entities[e.id]=o,this.numEntities++}},{key:"finalize",value:function(){if(!this.destroyed){this._createDummyEntityForUnusedMeshes();for(var e=0,t=this.layerList.length;e<t;e++){this.layerList[e].finalize()}this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._dtxLayers={},this._vboInstancingLayers={},this._vboBatchingLayers={};for(var i=0,r=this._entityList.length;i<r;i++){this._entityList[i]._finalize()}for(var s=0,n=this._entityList.length;s<n;s++){this._entityList[s]._finalize2()}this.layerList.sort((function(e,t){return e.sortId<t.sortId?-1:e.sortId>t.sortId?1:0}));for(var o=0,a=this.layerList.length;o<a;o++){this.layerList[o].layerIndex=o}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,t){}},{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 t=0,i=this.layerList.length;t<i;t++){var r=this.layerList[t];this._getActiveSectionPlanesForLayer(r)&&(e.visibleLayers[e.numVisibleLayers++]=t)}}},{key:"_createDummyEntityForUnusedMeshes",value:function(){var e=Object.keys(this._unusedMeshes);if(e.length>0){var t="".concat(this.id,"-dummyEntityForUnusedMeshes");this.warn('Creating dummy SceneModelEntity "'.concat(t,'" for unused SceneMeshes: [').concat(e.join(","),"]")),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}},{key:"_getActiveSectionPlanesForLayer",value:function(e){var t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,r=i.length,s=e.layerIndex*r;if(r>0)for(var n=0;n<r;n++){i[n].active?(t.sectionPlanesActivePerLayer[s+n]=!0,t.sectioned=!0):t.sectionPlanesActivePerLayer[s+n]=!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 t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.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 i=this.scene.selectedMaterial._state;i.fill&&(i.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),i.edges&&(i.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){var r=this.scene.highlightMaterial._state;r.fill&&(r.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),r.edges&&(r.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}},{key:"drawColorOpaque",value:function(e,t){for(var i=this.renderFlags,r=0,s=i.visibleLayers.length;r<s;r++){var n=i.visibleLayers[r];this.layerList[n].drawColorOpaque(i,e)}}},{key:"drawColorTransparent",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawColorTransparent(t,e)}}},{key:"drawDepth",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawDepth(t,e)}}},{key:"drawNormals",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawNormals(t,e)}}},{key:"drawSilhouetteXRayed",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawSilhouetteXRayed(t,e)}}},{key:"drawSilhouetteHighlighted",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawSilhouetteHighlighted(t,e)}}},{key:"drawSilhouetteSelected",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawSilhouetteSelected(t,e)}}},{key:"drawEdgesColorOpaque",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesColorOpaque(t,e)}}},{key:"drawEdgesColorTransparent",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesColorTransparent(t,e)}}},{key:"drawEdgesXRayed",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesXRayed(t,e)}}},{key:"drawEdgesHighlighted",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesHighlighted(t,e)}}},{key:"drawEdgesSelected",value:function(e){for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawEdgesSelected(t,e)}}},{key:"drawOcclusion",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawOcclusion(t,e)}}},{key:"drawShadow",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawShadow(t,e)}}},{key:"setPickMatrices",value:function(e,t){if(0!==this._numVisibleLayerPortions)for(var i=this.renderFlags,r=0,s=i.visibleLayers.length;r<s;r++){var n=i.visibleLayers[r],o=this.layerList[n];o.setPickMatrices&&o.setPickMatrices(e,t)}}},{key:"drawPickMesh",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawPickMesh(t,e)}}},{key:"drawPickDepths",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawPickDepths(t,e)}}},{key:"drawPickNormals",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i];this.layerList[s].drawPickNormals(t,e)}}},{key:"drawSnapInit",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i],n=this.layerList[s];n.drawSnapInit&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,n.drawSnapInit(t,e),e.snapPickLayerParams[e.snapPickLayerNumber]={origin:e.snapPickOrigin.slice(),coordinateScale:e.snapPickCoordinateScale.slice()})}}},{key:"drawSnap",value:function(e){if(0!==this.numVisibleLayerPortions)for(var t=this.renderFlags,i=0,r=t.visibleLayers.length;i<r;i++){var s=t.visibleLayers[i],n=this.layerList[s];n.drawSnap&&(e.snapPickOrigin=[0,0,0],e.snapPickCoordinateScale=[1,1,1],e.snapPickLayerNumber++,n.drawSnap(t,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 r=0,s=this.layerList.length;r<s;r++)this.layerList[r].destroy();this.layerList=[];for(var n=0,o=this._entityList.length;n<o;n++)this._entityList[n]._destroy();this._geometries={},this._dtxBuckets={},this._textures={},this._textureSets={},this._meshes={},this._entities={},this.scene._aabbDirty=!0,this._isModel&&this.scene._deregisterModel(this),0!==_o&&0==--_o&&mo._clear(),f(w(i.prototype),"destroy",this).call(this)}}]),i}();function Ch(e,t,i){var r,s,n,o;if(t||i){var a=c(th({positionsCompressed:e.positionsCompressed,indices:e.indices,edgeIndices:e.edgeIndices}),3);r=a[0],s=a[1],n=a[2]}else r=e.positionsCompressed,s=e.indices,n=e.edgeIndices;i?o=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.positionsCompressed||[],s=sh(e.indices||[],t),n=ah(e.edgeIndices||[]);function o(e,t){if(e>t){var i=e;e=t,t=i}function r(i,r){return i!==e?e-i:r!==t?t-r:0}for(var s=0,o=(n.length>>1)-1;s<=o;){var a=o+s>>1,l=r(n[2*a],n[2*a+1]);if(l>0)s=a+1;else{if(!(l<0))return a;o=a-1}}return-s-1}var a=new Int32Array(n.length/2);a.fill(0);var l=r.length/3;if(l>8*(1<<t))return[e];var u=new Int32Array(l);u.fill(-1);var A=[];function c(){u.fill(-1);var e={positionsCompressed:[],indices:[],edgeIndices:[],maxNumPositions:(1<<t)-t,numPositions:0,bucketNumber:A.length};return A.push(e),e}for(var h=c(),d=0,p=s.length;d<p;d+=3){var f=0,v=s[d],g=s[d+1],m=s[d+2];if(-1===u[v]&&f++,-1===u[g]&&f++,-1===u[m]&&f++,f+h.numPositions>h.maxNumPositions&&(h=c()),h.bucketNumber>8)return[e];-1===u[v]&&(u[v]=h.numPositions++,h.positionsCompressed.push(r[3*v]),h.positionsCompressed.push(r[3*v+1]),h.positionsCompressed.push(r[3*v+2])),-1===u[g]&&(u[g]=h.numPositions++,h.positionsCompressed.push(r[3*g]),h.positionsCompressed.push(r[3*g+1]),h.positionsCompressed.push(r[3*g+2])),-1===u[m]&&(u[m]=h.numPositions++,h.positionsCompressed.push(r[3*m]),h.positionsCompressed.push(r[3*m+1]),h.positionsCompressed.push(r[3*m+2])),h.indices.push(u[v]),h.indices.push(u[g]),h.indices.push(u[m]);var _=void 0;(_=o(v,g))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(v,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(g,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]]))}var y=t/8*2,b=t/8,w=2*r.length+(s.length+n.length)*y,B=0;return r.length,A.forEach((function(e){B+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*b,e.positionsCompressed.length})),B>w?[e]:(i&&lh(A,e),A)}({positionsCompressed:r,indices:s,edgeIndices:n},r.length/3>65536?16:8):o=[{positionsCompressed:r,indices:s,edgeIndices:n}];return o}var Mh=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(r=t.call(this,e,s))._positions=s.positions||[],s.indices)r._indices=s.indices;else{r._indices=[];for(var n=0,o=r._positions.length/3-1;n<o;n+=2)r._indices.push(n),r._indices.push(n+1)}return r._sceneModel=new Ph(b(r),{isModel:!1}),r._sceneModel.createMesh({id:"linesMesh",primitive:"lines",positions:r._positions,indices:r._indices}),r._sceneModel.createEntity({meshIds:["linesMesh"],visible:s.visible,clippable:s.clippable,collidable:s.collidable}),r._sceneModel.finalize(),r.scene._lineSetCreated(b(r)),r}return C(i,[{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(){f(w(i.prototype),"destroy",this).call(this),this.scene._lineSetDestroyed(this)}}]),i}(),Eh=re.vec3(),Fh=re.vec3(),kh=re.vec3(),Ih=re.vec3(),Dh=function(e){g(i,Ue);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,"BCFViewpoints",e,s)).originatingSystem=s.originatingSystem||"xeokit.io",r.authoringTool=s.authoringTool||"xeokit.io",r}return C(i,[{key:"getViewpoint",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=this.viewer.scene,r=i.camera,s=i.realWorldOffset,n=!0===t.reverseClippingPlanes,o={},a=re.normalizeVec3(re.subVec3(r.look,r.eye,re.vec3())),l=r.eye,u=r.up;r.yUp&&(a=Lh(a),l=Lh(l),u=Lh(u));var A=Sh(re.addVec3(l,s));"ortho"===r.projection?o.orthogonal_camera={camera_view_point:A,camera_direction:Sh(a),camera_up_vector:Sh(u),view_to_world_scale:r.ortho.scale}:o.perspective_camera={camera_view_point:A,camera_direction:Sh(a),camera_up_vector:Sh(u),field_of_view:r.perspective.fov};var h=i.sectionPlanes;for(var d in h)if(h.hasOwnProperty(d)){var p=h[d];if(!p.active)continue;var f=p.pos,v=void 0;v=n?re.negateVec3(p.dir,re.vec3()):p.dir,r.yUp&&(f=Lh(f),v=Lh(v)),re.addVec3(f,s),f=Sh(f),v=Sh(v),o.clipping_planes||(o.clipping_planes=[]),o.clipping_planes.push({location:f,direction:v})}var g=i.lineSets;for(var m in g)if(g.hasOwnProperty(m)){var _=g[m];o.lines||(o.lines=[]);for(var y=_.positions,b=_.indices,w=0,B=b.length/2;w<B;w++){var x=b[2*w],P=b[2*w+1];o.lines.push({start_point:{x:y[3*x+0],y:y[3*x+1],z:y[3*x+2]},end_point:{x:y[3*P+0],y:y[3*P+1],z:y[3*P+2]}})}}var C=i.bitmaps;for(var M in C)if(C.hasOwnProperty(M)){var E=C[M],F=E.pos,k=E.normal,I=E.up;r.yUp&&(F=Lh(F),k=Lh(k),I=Lh(I)),re.addVec3(F,s),o.bitmaps||(o.bitmaps=[]),o.bitmaps.push({bitmap_type:E.type,bitmap_data:E.imageData,location:Sh(F),normal:Sh(k),up:Sh(I),height:E.height})}o.components={visibility:{view_setup_hints:{spaces_visible:!!t.spacesVisible,space_boundaries_visible:!!t.spaceBoundariesVisible,openings_visible:!!t.openingsVisible,spaces_translucent:!!t.spaces_translucent,space_boundaries_translucent:!!t.space_boundaries_translucent,openings_translucent:!!t.openings_translucent}}};var D=new Set(i.opacityObjectIds),S=new Set(i.xrayedObjectIds),T=new Set(i.colorizedObjectIds),L=Object.values(i.objects).filter((function(e){return D.has(e.id)||T.has(e.id)||S.has(e.id)})).reduce((function(t,r){var s,n=Uh(r.colorize);r.xrayed?(s=0===i.xrayMaterial.fillAlpha&&0!==i.xrayMaterial.edgeAlpha?.1:i.xrayMaterial.fillAlpha,n=(s=Math.round(255*s).toString(16).padStart(2,"0"))+n):D.has(r.id)&&(n=(s=Math.round(255*r.opacity).toString(16).padStart(2,"0"))+n),t[n]||(t[n]=[]);var o=r.id,a=r.originalSystemId,l={ifc_guid:a,originating_system:e.originatingSystem};return a!==o&&(l.authoring_tool_id=o),t[n].push(l),t}),{}),R=Object.entries(L).map((function(e){var t=c(e,2);return{color:t[0],components:t[1]}}));o.components.coloring=R;var U=i.objectIds,O=i.visibleObjects,N=i.visibleObjectIds,Q=U.filter((function(e){return!O[e]})),V=i.selectedObjectIds;return t.defaultInvisible||N.length<Q.length?(o.components.visibility.exceptions=this._createBCFComponents(N),o.components.visibility.default_visibility=!1):(o.components.visibility.exceptions=this._createBCFComponents(Q),o.components.visibility.default_visibility=!0),o.components.selection=this._createBCFComponents(V),o.components.translucency=this._createBCFComponents(i.xrayedObjectIds),!1!==t.snapshot&&(o.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})}),o}},{key:"_createBCFComponents",value:function(e){for(var t=this.viewer.scene,i=[],r=0,s=e.length;r<s;r++){var n=e[r],o=t.objects[n];if(o){var a={ifc_guid:o.originalSystemId,originating_system:this.originatingSystem};o.originalSystemId!==n&&(a.authoring_tool_id=n),i.push(a)}}return i}},{key:"setViewpoint",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var r=this.viewer,s=r.scene,n=s.camera,o=!1!==i.rayCast,a=!1!==i.immediate,l=!1!==i.reset,u=s.realWorldOffset,A=!0===i.reverseClippingPlanes;if(s.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){var t=Th(e.location,Eh),i=Th(e.direction,Eh);A&&re.negateVec3(i),re.subVec3(t,u),n.yUp&&(t=Rh(t),i=Rh(i)),new xn(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){var c=[],h=[],d=0;e.lines.forEach((function(e){e.start_point&&e.end_point&&(c.push(e.start_point.x),c.push(e.start_point.y),c.push(e.start_point.z),c.push(e.end_point.x),c.push(e.end_point.y),c.push(e.end_point.z),h.push(d++),h.push(d++))})),new Mh(s,{positions:c,indices:h,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){var t=e.bitmap_type||"jpg",i=e.bitmap_data,r=Th(e.location,Fh),o=Th(e.normal,kh),a=Th(e.up,Ih),l=e.height||1;t&&i&&r&&o&&a&&(n.yUp&&(r=Rh(r),o=Rh(o),a=Rh(a)),new ho(s,{src:i,type:t,pos:r,normal:o,up:a,clippable:!1,collidable:!0,height:l}))})),l&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!1}))}))):(s.setObjectsVisible(s.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!0}))})));var p=e.components.visibility.view_setup_hints;p&&(!1===p.spaces_visible&&s.setObjectsVisible(r.metaScene.getObjectIDsByType("IfcSpace"),!1),void 0!==p.spaces_translucent&&s.setObjectsXRayed(r.metaScene.getObjectIDsByType("IfcSpace"),!0),p.space_boundaries_visible,!1===p.openings_visible&&s.setObjectsVisible(r.metaScene.getObjectIDsByType("IfcOpening"),!0),p.space_boundaries_translucent,void 0!==p.openings_translucent&&s.setObjectsXRayed(r.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.selected=!0}))}))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.xrayed=!0}))}))),e.components.coloring&&e.components.coloring.forEach((function(e){var r=e.color,s=0,n=!1;8===r.length&&((s=parseInt(r.substring(0,2),16)/256)<=1&&s>=.95&&(s=1),r=r.substring(2),n=!0);var o=[parseInt(r.substring(0,2),16)/256,parseInt(r.substring(2,4),16)/256,parseInt(r.substring(4,6),16)/256];e.components.map((function(e){return t._withBCFComponent(i,e,(function(e){e.colorize=o,n&&(e.opacity=s)}))}))}))}if(e.perspective_camera||e.orthogonal_camera){var f,v,g,m;if(e.perspective_camera?(f=Th(e.perspective_camera.camera_view_point,Eh),v=Th(e.perspective_camera.camera_direction,Eh),g=Th(e.perspective_camera.camera_up_vector,Eh),n.perspective.fov=e.perspective_camera.field_of_view,m="perspective"):(f=Th(e.orthogonal_camera.camera_view_point,Eh),v=Th(e.orthogonal_camera.camera_direction,Eh),g=Th(e.orthogonal_camera.camera_up_vector,Eh),n.ortho.scale=e.orthogonal_camera.view_to_world_scale,m="ortho"),re.subVec3(f,u),n.yUp&&(f=Rh(f),v=Rh(v),g=Rh(g)),o){var _=s.pick({pickSurface:!0,origin:f,direction:v});v=_?_.worldPos:re.addVec3(f,v,Eh)}else v=re.addVec3(f,v,Eh);a?(n.eye=f,n.look=v,n.up=g,n.projection=m):r.cameraFlight.flyTo({eye:f,look:v,up:g,duration:i.duration,projection:m})}}}},{key:"_withBCFComponent",value:function(e,t,i){var r=this.viewer,s=r.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){var n=t.authoring_tool_id,o=s.objects[n];if(o)return void i(o);if(e.updateCompositeObjects)if(r.metaScene.metaObjects[n])return void s.withObjects(r.metaScene.getObjectIDsInSubtree(n),i)}if(t.ifc_guid){var a=t.ifc_guid,l=s.objects[a];if(l)return void i(l);if(e.updateCompositeObjects)if(r.metaScene.metaObjects[a])return void s.withObjects(r.metaScene.getObjectIDsInSubtree(a),i);Object.keys(s.models).forEach((function(t){var n=re.globalizeObjectId(t,a),o=s.objects[n];o?i(o):e.updateCompositeObjects&&r.metaScene.metaObjects[n]&&s.withObjects(r.metaScene.getObjectIDsInSubtree(n),i)}))}}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this)}}]),i}();function Sh(e){return{x:e[0],y:e[1],z:e[2]}}function Th(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function Lh(e){return new Float64Array([e[0],-e[2],e[1]])}function Rh(e){return new Float64Array([e[0],e[2],-e[1]])}function Uh(e){var t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0")}var Oh=re.vec3(),Nh=function(e,t,i,r){var s=e-i,n=t-r;return Math.sqrt(s*s+n*n)};var Qh=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(r=t.call(this,e.viewer.scene,s)).plugin=e,r._container=s.container,!r._container)throw"config missing: container";r._eventSubs={};var n=r.plugin.viewer.scene;r._originWorld=re.vec3(),r._targetWorld=re.vec3(),r._wp=new Float64Array(24),r._vp=new Float64Array(24),r._pp=new Float64Array(24),r._cp=new Float64Array(8),r._xAxisLabelCulled=!1,r._yAxisLabelCulled=!1,r._zAxisLabelCulled=!1,r._color=s.color||r.plugin.defaultColor;var o=s.onMouseOver?function(e){s.onMouseOver(e,b(r)),r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,a=s.onMouseLeave?function(e){s.onMouseLeave(e,b(r)),r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,l=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},u=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},A=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},c=s.onContextMenu?function(e){s.onContextMenu(e,b(r))}:null,h=function(e){r.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};return r._originDot=new ut(n,s.origin,r._container,{fillColor:r._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._targetDot=new ut(n,s.target,r._container,{fillColor:r._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._lengthWire=new ht(r._container,{color:r._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._xAxisWire=new ht(r._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._yAxisWire=new ht(r._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._zAxisWire=new ht(r._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._lengthLabel=new dt(r._container,{fillColor:r._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._xAxisLabel=new dt(r._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._yAxisLabel=new dt(r._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._zAxisLabel=new dt(r._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),r._measurementOrientation="Horizontal",r._wpDirty=!1,r._vpDirty=!1,r._cpDirty=!1,r._sectionPlanesDirty=!0,r._visible=!1,r._originVisible=!1,r._targetVisible=!1,r._wireVisible=!1,r._axisVisible=!1,r._xAxisVisible=!1,r._yAxisVisible=!1,r._zAxisVisible=!1,r._axisEnabled=!0,r._xLabelEnabled=!1,r._yLabelEnabled=!1,r._zLabelEnabled=!1,r._lengthLabelEnabled=!1,r._labelsVisible=!1,r._labelsOnWires=!1,r._clickable=!1,r._originDot.on("worldPos",(function(e){r._originWorld.set(e||[0,0,0]),r._wpDirty=!0,r._needUpdate(0)})),r._targetDot.on("worldPos",(function(e){r._targetWorld.set(e||[0,0,0]),r._wpDirty=!0,r._needUpdate(0)})),r._onViewMatrix=n.camera.on("viewMatrix",(function(){r._vpDirty=!0,r._needUpdate(0)})),r._onProjMatrix=n.camera.on("projMatrix",(function(){r._cpDirty=!0,r._needUpdate()})),r._onCanvasBoundary=n.canvas.on("boundary",(function(){r._cpDirty=!0,r._needUpdate(0)})),r._onMetricsUnits=n.metrics.on("units",(function(){r._cpDirty=!0,r._needUpdate()})),r._onMetricsScale=n.metrics.on("scale",(function(){r._cpDirty=!0,r._needUpdate()})),r._onMetricsOrigin=n.metrics.on("origin",(function(){r._cpDirty=!0,r._needUpdate()})),r._onSectionPlaneUpdated=n.on("sectionPlaneUpdated",(function(){r._sectionPlanesDirty=!0,r._needUpdate()})),r.approximate=s.approximate,r.visible=s.visible,r.originVisible=s.originVisible,r.targetVisible=s.targetVisible,r.wireVisible=s.wireVisible,r.axisVisible=s.axisVisible,r.xAxisVisible=s.xAxisVisible,r.yAxisVisible=s.yAxisVisible,r.zAxisVisible=s.zAxisVisible,r.xLabelEnabled=s.xLabelEnabled,r.yLabelEnabled=s.yLabelEnabled,r.zLabelEnabled=s.zLabelEnabled,r.lengthLabelEnabled=s.lengthLabelEnabled,r.labelsVisible=s.labelsVisible,r.labelsOnWires=s.labelsOnWires,r.useRotationAdjustment=s.useRotationAdjustment,r}return C(i,[{key:"_update",value:function(){if(this._visible){var e=this.plugin.viewer.scene;if(this._wpDirty&&(this._measurementOrientation=function(e,t,i){return Math.abs(t[1]-e[1])>i?"Vertical":"Horizontal"}(this._originWorld,this._targetWorld,0),"Vertical"===this._measurementOrientation&&this.useRotationAdjustment?(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._originWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._originWorld[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._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&&(re.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 t=this._originDot.viewPos[2],i=this._targetDot.viewPos[2];if(t>-.3||i>-.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){re.transformPositions4(e.camera.project.matrix,this._vp,this._pp);for(var r=this._pp,s=this._cp,n=e.canvas.canvas.getBoundingClientRect(),o=this._container.getBoundingClientRect(),a=n.top-o.top,l=n.left-o.left,u=e.canvas.boundary,A=u[2],c=u[3],h=0,d=this.plugin.viewer.scene.metrics,p=d.scale,f=d.units,v=d.unitsInfo[f].abbrev,g=0,m=r.length;g<m;g+=4)s[h]=l+Math.floor((1+r[g+0]/r[g+3])*A/2),s[h+1]=a+Math.floor((1-r[g+1]/r[g+3])*c/2),h+=2;if(this._lengthWire.setStartAndEnd(s[0],s[1],s[6],s[7]),this._xAxisWire.setStartAndEnd(s[0],s[1],s[2],s[3]),this._yAxisWire.setStartAndEnd(s[2],s[3],s[4],s[5]),this._zAxisWire.setStartAndEnd(s[4],s[5],s[6],s[7]),this.labelsVisible){if(this._lengthLabel.setPosOnWire(s[0],s[1],s[6],s[7]),this.labelsOnWires)this._xAxisLabel.setPosOnWire(s[0],s[1],s[2],s[3]),this._yAxisLabel.setPosOnWire(s[2],s[3],s[4],s[5]),this._zAxisLabel.setPosOnWire(s[4],s[5],s[6],s[7]);else{var _=35;this._xAxisLabel.setPosOnWire(s[0],s[1]+_,s[6],s[7]+_),_+=35,this._yAxisLabel.setPosOnWire(s[0],s[1]+_,s[6],s[7]+_),_+=35,this._zAxisLabel.setPosOnWire(s[0],s[1]+_,s[6],s[7]+_)}var y=this._approximate?" ~ ":" = ";this._length=Math.abs(re.lenVec3(re.subVec3(this._targetWorld,this._originWorld,Oh))),this._lengthLabel.setText(y+(this._length*p).toFixed(2)+v);var b=Math.abs(Nh(s[0],s[1],s[2],s[3])),w=Math.abs(Nh(s[2],s[3],s[4],s[5])),B=Math.abs(Nh(s[4],s[5],s[6],s[7])),x=this.plugin.labelMinAxisLength;this.labelsOnWires?(this._xAxisLabelCulled=b<x,this._yAxisLabelCulled=w<x,this._zAxisLabelCulled=B<x):(this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1),this._xAxisLabelCulled?this._xAxisLabel.setCulled(!0):(this._xAxisLabel.setText(y+Math.abs((this._targetWorld[0]-this._originWorld[0])*p).toFixed(2)+v),this._xAxisLabel.setCulled(!this.axisVisible)),this._yAxisLabelCulled?this._yAxisLabel.setCulled(!0):(this._yAxisLabel.setText(y+Math.abs((this._targetWorld[1]-this._originWorld[1])*p).toFixed(2)+v),this._yAxisLabel.setCulled(!this.axisVisible)),this._zAxisLabelCulled?this._zAxisLabel.setCulled(!0):("Vertical"===this._measurementOrientation&&this.useRotationAdjustment?(this._zAxisLabel.setPrefix(""),this._zAxisLabel.setText(y+Math.abs(re.lenVec3(re.subVec3(this._targetWorld,[this._originWorld[0],this._targetWorld[1],this._originWorld[2]],Oh))*p).toFixed(2)+v)):(this._zAxisLabel.setPrefix("Z"),this._zAxisLabel.setText(y+Math.abs((this._targetWorld[2]-this._originWorld[2])*p).toFixed(2)+v)),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 t=this.scene._sectionPlanesState.sectionPlanes,i=0,r=t.length;i<r;i++){var s=t[i];if(re.planeClipsPositions3(s.pos,s.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:"origin",get:function(){return this._originDot}},{key:"target",get:function(){return this._targetDot}},{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),this._lengthLabel.setFillColor(e)}},{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&&this._lengthLabelEnabled);var t=this._visible&&this._axisVisible&&this._xAxisVisible,i=this._visible&&this._axisVisible&&this._yAxisVisible,r=this._visible&&this._axisVisible&&this._zAxisVisible;this._xAxisWire.setVisible(t),this._yAxisWire.setVisible(i),this._zAxisWire.setVisible(r),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._EnabledVisible),this._yAxisLabel.setVisible(i&&!this._yAxisLabelCulled&&this._yLabelEnabled),this._zAxisLabel.setVisible(r&&!this._zAxisLabelCulled&&this._zLabelEnabled),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 t=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(t&&this._xAxisVisible),this._yAxisWire.setVisible(t&&this._yAxisVisible),this._zAxisWire.setVisible(t&&this._zAxisVisible),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._xAxisVisible&&this._xLabelEnabled),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._xAxisVisible&&this._yLabelEnabled),this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._xAxisVisible&&this._zLabelEnabled),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 t=this._visible&&this._axisVisible&&this._axisEnabled;this._xAxisWire.setVisible(t&&this._xAxisVisible),this._yAxisWire.setVisible(t&&this._yAxisVisible),this._zAxisWire.setVisible(t&&this._zAxisVisible),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._xAxisVisible),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._yAxisVisible),this._zAxisLabel.setVisible(t&&!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 t=this._visible&&this._axisVisible&&this._xAxisVisible&&this._axisEnabled;this._xAxisWire.setVisible(t),this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._xLabelEnabled),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 t=this._visible&&this._axisVisible&&this._yAxisVisible&&this._axisEnabled;this._yAxisWire.setVisible(t),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._yLabelEnabled),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 t=this._visible&&this._axisVisible&&this._zAxisVisible&&this._axisEnabled;this._zAxisWire.setVisible(t),this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._zLabelEnabled),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 t=this._visible&&this._wireVisible;this._lengthLabel.setVisible(t&&this._lengthLabelEnabled),this._lengthWire.setVisible(t)}},{key:"labelsVisible",get:function(){return this._labelsVisible},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLabelsVisible,this._labelsVisible=e;var t=this._visible&&this._labelsVisible;this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._xLabelEnabled),this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._yLabelEnabled),this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._zLabelEnabled),this._lengthLabel.setVisible(t&&this._lengthLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"xLabelEnabled",get:function(){return this._xLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultXLabelEnabled,this._xLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._xAxisLabel.setVisible(t&&!this._xAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._xLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"yLabelEnabled",get:function(){return this._yLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultYLabelEnabled,this._yLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._yAxisLabel.setVisible(t&&!this._yAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._yLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"zLabelEnabled",get:function(){return this._zLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultZLabelEnabled,this._zLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._zAxisLabel.setVisible(t&&!this._zAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._zLabelEnabled),this._cpDirty=!0,this._needUpdate()}},{key:"lengthLabelEnabled",get:function(){return this._lengthLabelEnabled},set:function(e){e=void 0!==e?Boolean(e):this.plugin.defaultLengthLabelEnabled,this._lengthLabelEnabled=e;var t=this._visible&&this._labelsVisible;this._lengthLabel.setVisible(t&&!this._lengthAxisLabelCulled&&this._clickable&&this._axisEnabled&&this._lengthLabelEnabled),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(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Vh=function(e){g(i,Ce);var t=_(i);function i(){return x(this,i),t.apply(this,arguments)}return C(i,[{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:"currentMeasurement",get:function(){return null}},{key:"destroy",value:function(){}}]),i}(),Hh=function(e){g(i,Vh);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e.viewer.scene))._canvasToPagePos=s.canvasToPagePos,r.pointerLens=s.pointerLens,r._active=!1,r._currentDistanceMeasurement=null,r._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},r._initMarkerDiv(),r._onCameraControlHoverSnapOrSurface=null,r._onCameraControlHoverSnapOrSurfaceOff=null,r._onMouseDown=null,r._onMouseUp=null,r._onCanvasTouchStart=null,r._onCanvasTouchEnd=null,r._snapping=!1!==s.snapping,r._mouseState=0,r._attachPlugin(e,s),r}return C(i,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myMarkerDiv");var t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){if(this._markerDiv){var e=document.getElementById("myMarkerDiv");e.parentNode.removeChild(e),this._markerDiv=null}}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=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 t=this.distanceMeasurementsPlugin,i=this.scene,r=t.viewer.cameraControl,s=i.canvas.canvas;i.input;var n,o,a=!1,l=re.vec3(),u=re.vec2(),A=null;this._mouseState=0;var c=function e(t){return t.offsetTop+(t.offsetParent&&t.offsetParent!==s.parentNode&&e(t.offsetParent))},h=function e(t){return t.offsetLeft+(t.offsetParent&&t.offsetParent!==s.parentNode&&e(t.offsetParent))},d=re.vec2();this._onCameraControlHoverSnapOrSurface=r.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(function(t){var i=t.snappedCanvasPos||t.canvasPos;a=!0,l.set(t.worldPos),u.set(t.canvasPos),0===e._mouseState?(e._canvasToPagePos?(e._canvasToPagePos(s,i,d),e._markerDiv.style.left="".concat(d[0]-5,"px"),e._markerDiv.style.top="".concat(d[1]-5,"px")):(e._markerDiv.style.left="".concat(h(s)+i[0]-5,"px"),e._markerDiv.style.top="".concat(c(s)+i[1]-5,"px")),e._markerDiv.style.background="pink",t.snappedToVertex||t.snappedToEdge?(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.snappedCanvasPos||t.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=t.canvasPos,e.pointerLens.snappedCanvasPos=t.canvasPos,e.pointerLens.snapped=!1),e._markerDiv.style.background="pink",e._markerDiv.style.border="2px solid red"),A=t.entity):(e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px"),s.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=l.slice(),e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px")})),s.addEventListener("mousedown",this._onMouseDown=function(e){1===e.which&&(n=e.clientX,o=e.clientY)}),s.addEventListener("mouseup",this._onMouseUp=function(i){1===i.which&&(i.clientX>n+20||i.clientX<n-20||i.clientY>o+20||i.clientY<o-20||(e._currentDistanceMeasurement?a?(e._currentDistanceMeasurement.target.entity=A,A=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,A=null):a&&(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:l.slice(),entity:A},target:{worldPos:l.slice(),entity:A},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=A,A=null,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement))))}),this._onCameraControlHoverSnapOrSurfaceOff=r.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",(function(t){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.snappedCanvasPos||t.canvasPos),a=!1,e._markerDiv.style.left="-100px",e._markerDiv.style.top="-100px",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=!1,e._currentDistanceMeasurement.targetVisible=!1,e._currentDistanceMeasurement.axisVisible=!1),s.style.cursor="default"})),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1);var e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);var t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onCameraControlHoverSnapOrSurface),t.off(this._onCameraControlHoverSnapOrSurfaceOff),this._active=!1}}},{key:"reset",value:function(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._mouseState=0)}},{key:"currentMeasurement",get:function(){return this._currentDistanceMeasurement}},{key:"destroy",value:function(){this.deactivate(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),jh=function(e){g(i,Ue);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,"DistanceMeasurements",e))._pointerLens=s.pointerLens,r._container=s.container||document.body,r._defaultControl=null,r._measurements={},r.labelMinAxisLength=s.labelMinAxisLength,r.defaultVisible=!1!==s.defaultVisible,r.defaultOriginVisible=!1!==s.defaultOriginVisible,r.defaultTargetVisible=!1!==s.defaultTargetVisible,r.defaultWireVisible=!1!==s.defaultWireVisible,r.defaultXLabelEnabled=!1!==s.defaultXLabelEnabled,r.defaultYLabelEnabled=!1!==s.defaultYLabelEnabled,r.defaultZLabelEnabled=!1!==s.defaultZLabelEnabled,r.defaultLengthLabelEnabled=!1!==s.defaultLengthLabelEnabled,r.defaultLabelsVisible=!1!==s.defaultLabelsVisible,r.defaultAxisVisible=!1!==s.defaultAxisVisible,r.defaultXAxisVisible=!1!==s.defaultXAxisVisible,r.defaultYAxisVisible=!1!==s.defaultYAxisVisible,r.defaultZAxisVisible=!1!==s.defaultZAxisVisible,r.defaultColor=void 0!==s.defaultColor?s.defaultColor:"#00BBFF",r.zIndex=s.zIndex||1e4,r.defaultLabelsOnWires=!1!==s.defaultLabelsOnWires,r.useRotationAdjustment=void 0!==s.useRotationAdjustment&&!1!==s.useRotationAdjustment,r._onMouseOver=function(e,t){r.fire("mouseOver",{plugin:b(r),distanceMeasurement:t,measurement:t,event:e})},r._onMouseLeave=function(e,t){r.fire("mouseLeave",{plugin:b(r),distanceMeasurement:t,measurement:t,event:e})},r._onContextMenu=function(e,t){r.fire("contextMenu",{plugin:b(r),distanceMeasurement:t,measurement:t,event:e})},r}return C(i,[{key:"getContainerElement",value:function(){return this._container}},{key:"send",value:function(e,t){}},{key:"pointerLens",get:function(){return this._pointerLens}},{key:"control",get:function(){return this._defaultControl||(this._defaultControl=new Hh(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:"useRotationAdjustment",get:function(){return this._useRotationAdjustment},set:function(e){e=void 0!==e&&Boolean(e),this._useRotationAdjustment=e}},{key:"createMeasurement",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.viewer.scene.components[t.id]&&(this.error("Viewer scene component with this ID already exists: "+t.id),delete t.id);var i=t.origin,r=t.target,s=new Qh(this,{id:t.id,plugin:this,container:this._container,origin:{entity:i.entity,worldPos:i.worldPos},target:{entity:r.entity,worldPos:r.worldPos},visible:t.visible,wireVisible:t.wireVisible,axisVisible:!1!==t.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==t.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==t.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==t.zAxisVisible&&!1!==this.defaultZAxisVisible,xLabelEnabled:!1!==t.xLabelEnabled&&!1!==this.defaultXLabelEnabled,yLabelEnabled:!1!==t.yLabelEnabled&&!1!==this.defaultYLabelEnabled,zLabelEnabled:!1!==t.zLabelEnabled&&!1!==this.defaultZLabelEnabled,lengthLabelEnabled:!1!==t.lengthLabelEnabled&&!1!==this.defaultLengthLabelEnabled,labelsVisible:!1!==t.labelsVisible&&!1!==this.defaultLabelsVisible,useRotationAdjustment:this.useRotationAdjustment,originVisible:t.originVisible,targetVisible:t.targetVisible,color:t.color,labelsOnWires:!1!==t.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[s.id]=s,s.clickable=!0,s.on("destroyed",(function(){delete e._measurements[s.id]})),this.fire("measurementCreated",s),s}},{key:"destroyMeasurement",value:function(e){var t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}},{key:"setLabelsShown",value:function(e){for(var t=0,i=Object.entries(this.measurements);t<i.length;t++){var r=c(i[t],2);r[0];r[1].labelShown=e}}},{key:"setAxisVisible",value:function(e){for(var t=0,i=Object.entries(this.measurements);t<i.length;t++){var r=c(i[t],2);r[0];r[1].axisVisible=e}this.defaultAxisVisible=e}},{key:"getAxisVisible",value:function(){return this.defaultAxisVisible}},{key:"clear",value:function(){for(var e=Object.keys(this._measurements),t=0,i=e.length;t<i;t++)this.destroyMeasurement(e[t])}},{key:"destroy",value:function(){this.clear(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Gh=function(e){g(i,Vh);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(r=t.call(this,e.viewer.scene)).pointerLens=s.pointerLens,r.pointerCircle=new Re(e.viewer),r._active=!1;var n=document.createElement("div"),o=r.scene.canvas.canvas;return o.parentNode.insertBefore(n,o),n.style.background="black",n.style.border="2px solid blue",n.style.borderRadius="10px",n.style.width="5px",n.style.height="5px",n.style.margin="-200px -200px",n.style.zIndex="100",n.style.position="absolute",n.style.pointerEvents="none",r.markerDiv=n,r._currentDistanceMeasurement=null,r._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},r._onCanvasTouchStart=null,r._onCanvasTouchEnd=null,r._longTouchTimeoutMs=300,r._snapping=!1!==s.snapping,r._touchState=0,r._attachPlugin(e,s),r}return C(i,[{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=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 t=this.plugin,i=this.scene,r=i.canvas.canvas;t.pointerLens;var s=re.vec3(),n=20,o=null;this._touchState=0;var a=re.vec2(),l=re.vec2(),u=re.vec2(),A=null,c=function(){e.plugin.viewer.cameraControl.active=!1},h=function(){e.plugin.viewer.cameraControl.active=!0};r.addEventListener("touchstart",this._onCanvasTouchStart=function(r){var u=r.touches.length;if(1===u){var d=r.touches[0],p=d.clientX,f=d.clientY;switch(a.set([p,f]),l.set([p,f]),e._touchState){case 0:if(1!==u&&null!==o)return o&&(clearTimeout(o),o=null),e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),h(),void(e._touchState=0);var v=i.pick({canvasPos:l,snapping:e._snapping,snapToEdge:e._snapping});if(v&&v.snapped)s.set(v.worldPos),e.pointerCircle.start(v.snappedCanvasPos);else{var g=i.pick({canvasPos:l,pickSurface:!0});if(!g||!g.worldPos)return;s.set(g.worldPos),e.pointerCircle.start(g.canvasPos)}o=setTimeout((function(){1!==u||l[0]>a[0]+n||l[0]<a[0]-n||l[1]>a[1]+n||l[1]<a[1]-n||(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=a,e.pointerLens.cursorPos=a),e.pointerLens&&(e.pointerLens.canvasPos=l,e.pointerLens.snapped=!1),e.pointerLens&&(e.pointerLens.cursorPos=v.canvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=s:(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:s,entity:v.entity},target:{worldPos:s,entity:v.entity}}),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,c())}),e._longTouchTimeoutMs),e._touchState=1,A=d.identifier;break;case 3:if(1!==u&&null!==o)return clearTimeout(o),void(o=null);1===u&&(o=setTimeout((function(){if(o=null,!(1!==u||l[0]>a[0]+n||l[0]<a[0]-n||l[1]>a[1]+n||l[1]<a[1]-n)){e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=a,e.pointerLens.snapped=!1);var t=i.pick({canvasPos:l,snapToVertex:e._snapping,snapToEdge:e._snapping});if(t&&t.snapped)e.pointerLens&&(e.pointerLens.cursorPos=t.snappedCanvasPos,e.pointerLens.snapped=!0),e.pointerCircle.start(t.snappedCanvasPos),s.set(t.worldPos),e._currentDistanceMeasurement.target.worldPos=t.worldPos,e._currentDistanceMeasurement.target.entity=t.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement);else{var r=i.pick({canvasPos:l,pickSurface:!0});r&&r.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=r.canvasPos,e.pointerLens.snapped=!1),e.pointerCircle.start(r.canvasPos),s.set(r.worldPos),e._currentDistanceMeasurement.target.worldPos=r.worldPos,e._currentDistanceMeasurement.target.entity=r.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,c()}}),e._longTouchTimeoutMs),e._touchState=4),A=d.identifier;break;default:return null!==o&&(clearTimeout(o),o=null),void(e._touchState=7)}}else o&&(clearTimeout(o),o=null)},{passive:!0}),r.addEventListener("touchmove",(function(r){e.pointerCircle.stop();var n=r.touches.length;if(1===n&&1===r.changedTouches.length){var a,u,c=r.touches[0],h=c.clientX,d=c.clientY;if(c.identifier===A)switch(l.set([h,d]),e._touchState){case 2:e.pointerLens&&(e.pointerLens.canvasPos=l),(a=i.pick({canvasPos:l,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&a.snapped?(e.pointerLens&&(e.pointerLens.snappedCanvasPos=a.snappedCanvasPos,e.pointerLens.snapped=!0),s.set(a.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=a.worldPos:(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:a.worldPos,entity:a.entity},target:{worldPos:a.worldPos,entity:a.entity}}),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)):(u=i.pick({canvasPos:l,pickSurface:!0}))&&u.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=u.canvasPos,e.pointerLens.snapped=!1),s.set(u.worldPos),e._currentDistanceMeasurement?e._currentDistanceMeasurement.origin.worldPos=u.worldPos:(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:u.worldPos,entity:u.entity},target:{worldPos:u.worldPos,entity:u.entity}}),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!==n&&null!==o)return clearTimeout(o),o=null,e.pointerLens&&(e.pointerLens.visible=!1),void(e._touchState=7);e.pointerLens&&(e.pointerLens.canvasPos=l),(a=i.pick({canvasPos:l,snapToVertex:e._snapping,snapToEdge:e._snapping}))&&a.worldPos?(e.pointerLens&&(e.pointerLens.cursorPos=a.snappedCanvasPos,e.pointerLens.snapped=!0),e._currentDistanceMeasurement.target.worldPos=a.worldPos,e._currentDistanceMeasurement.target.entity=a.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0):(u=i.pick({canvasPos:l,pickSurface:!0}))&&u.worldPos&&(e.pointerLens&&(e.pointerLens.cursorPos=u.canvasPos,e.pointerLens.snapped=!1),e._currentDistanceMeasurement.target.worldPos=u.worldPos,e._currentDistanceMeasurement.target.entity=u.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0),e._touchState=5}}else o&&(clearTimeout(o),o=null)}),{passive:!0}),r.addEventListener("touchend",this._onCanvasTouchEnd=function(r){e.pointerCircle.stop();var s=r.changedTouches.length;if(1===s){var c=r.changedTouches[0],d=c.clientX,p=c.clientY;if(c.identifier===A)switch(o&&(clearTimeout(o),o=null),u.set([d,p]),e._touchState){case 1:if(1!==s||d>a[0]+n||d<a[0]-n||p>a[1]+n||p<a[1]-n)return void(e._touchState=0);var f=i.pick({canvasPos:l,pickSurface:!0});f&&f.worldPos?(e._currentDistanceMeasurement=t.createMeasurement({id:re.createUUID(),origin:{worldPos:f.worldPos,entity:f.entity},target:{worldPos:f.worldPos,entity:f.entity}}),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._touchState=3,e.distanceMeasurementsPlugin.fire("measurementStart",e._currentDistanceMeasurement)):(e._currentDistanceMeasurement&&e._currentDistanceMeasurement.destroy(),e._touchState=0),h();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),h();break;case 4:if(1!==s||d>a[0]+n||d<a[0]-n||p>a[1]+n||p<a[1]-n)return void(e._touchState=3);var v=i.pick({canvasPos:l,pickSurface:!0});v&&v.worldPos?(e._currentDistanceMeasurement.target.worldPos=v.worldPos,e._currentDistanceMeasurement.target.entity=v.entity,e._currentDistanceMeasurement.targetVisible=!0,e._currentDistanceMeasurement.wireVisible=!0,e._currentDistanceMeasurement.labelsVisible=!0,e._currentDistanceMeasurement.xAxisVisible=!0,e._currentDistanceMeasurement.yAxisVisible=!0,e._currentDistanceMeasurement.zAxisVisible=!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,h();break;case 5:console.log("long touch"),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),h()}}},{passive:!0}),this._active=!0}}},{key:"deactivate",value:function(){if(this._active){this.plugin.pointerLens&&(this.plugin.pointerLens.visible=!1),this.reset();var e=this.plugin.viewer.scene.canvas.canvas;e.removeEventListener("touchstart",this._onCanvasTouchStart),e.removeEventListener("touchend",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),this._mouseState=0)}},{key:"currentMeasurement",get:function(){return this._currentDistanceMeasurement}},{key:"destroy",value:function(){this.deactivate(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),zh=function(e){g(i,Ce);var t=_(i);function i(e,r,s,n){var o;x(this,i);var a=e.plugin.viewer;o=t.call(this,a.scene);var l=ct({viewer:a,handleMouseEvents:s,handleTouchEvents:n,pointerLens:r.pointerLens,dots:[e.origin,e.target],ray2WorldPos:function(e,t,i){return function e(t){var r=a.scene.pick({canvasPos:i,snapToEdge:t,snapToVertex:t,pickSurface:!0});return r&&r.worldPos?r.worldPos:t&&e(!1)}(!!r.snapping)},onEnd:function(e,t){var i=!re.compareVec3(e,t.worldPos);return i&&o.fire("edited"),i}}),u=e.on("destroyed",l);return o._deactivate=function(){e.off("destroyed",u),l()},o}return C(i,[{key:"deactivate",value:function(){this._deactivate(),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Wh=function(e){g(i,zh);var t=_(i);function i(e,r){return x(this,i),t.call(this,e,r,!0,!1)}return C(i)}(),Kh=function(e){g(i,zh);var t=_(i);function i(e,r){return x(this,i),t.call(this,e,r,!1,!0)}return C(i)}(),Xh=function(e){g(i,Ue);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(r=t.call(this,"FastNav",e))._hideColorTexture=!1!==s.hideColorTexture,r._hidePBR=!1!==s.hidePBR,r._hideSAO=!1!==s.hideSAO,r._hideEdges=!1!==s.hideEdges,r._hideTransparentObjects=!!s.hideTransparentObjects,r._scaleCanvasResolution=!!s.scaleCanvasResolution,r._defaultScaleCanvasResolutionFactor=s.defaultScaleCanvasResolutionFactor||1,r._scaleCanvasResolutionFactor=s.scaleCanvasResolutionFactor||.6,r._delayBeforeRestore=!1!==s.delayBeforeRestore,r._delayBeforeRestoreSeconds=s.delayBeforeRestoreSeconds||.5;var n=1e3*r._delayBeforeRestoreSeconds,o=!1,a=function(){n=1e3*r._delayBeforeRestoreSeconds,o||(e.scene._renderer.setColorTextureEnabled(!r._hideColorTexture),e.scene._renderer.setPBREnabled(!r._hidePBR),e.scene._renderer.setSAOEnabled(!r._hideSAO),e.scene._renderer.setTransparentEnabled(!r._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!r._hideEdges),r._scaleCanvasResolution?e.scene.canvas.resolutionScale=r._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=r._defaultScaleCanvasResolutionFactor,o=!0)},l=function(){e.scene.canvas.resolutionScale=r._defaultScaleCanvasResolutionFactor,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),o=!1};r._onCanvasBoundary=e.scene.canvas.on("boundary",a),r._onCameraMatrix=e.scene.camera.on("matrix",a),r._onSceneTick=e.scene.on("tick",(function(e){o&&(n-=e.deltaTime,(!r._delayBeforeRestore||n<=0)&&l())}));var u=!1;return r._onSceneMouseDown=e.scene.input.on("mousedown",(function(){u=!0})),r._onSceneMouseUp=e.scene.input.on("mouseup",(function(){u=!1})),r._onSceneMouseMove=e.scene.input.on("mousemove",(function(){u&&a()})),r}return C(i,[{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:"defaultScaleCanvasResolutionFactor",get:function(){return this._defaultScaleCanvasResolutionFactor},set:function(e){this._defaultScaleCanvasResolutionFactor=e||1}},{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,t){}},{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),f(w(i.prototype),"destroy",this).call(this)}}]),i}(),Yh=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(this,e),this.cacheBuster=!1!==t.cacheBuster}return C(e,[{key:"_cacheBusterURL",value:function(e){if(!this.cacheBuster)return e;var t=(new Date).getTime();return e.indexOf("?")>-1?e+"&_="+t:e+"?_="+t}},{key:"getMetaModel",value:function(e,t,i){he.loadJSON(this._cacheBusterURL(e),(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLTF",value:function(e,t,i){he.loadArraybuffer(this._cacheBusterURL(e),(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLB",value:function(e,t,i){he.loadArraybuffer(this._cacheBusterURL(e),(function(e){t(e)}),(function(e){i(e)}))}},{key:"getArrayBuffer",value:function(e,t,i,r){!function(e,t,i,r){var s=function(){};i=i||s,r=r||s;var n=/^data:(.*?)(;base64)?,(.*)$/,o=t.match(n);if(o){var a=!!o[2],l=o[3];l=window.decodeURIComponent(l),a&&(l=window.atob(l));try{for(var u=new ArrayBuffer(l.length),A=new Uint8Array(u),c=0;c<l.length;c++)A[c]=l.charCodeAt(c);Be.scheduleTask((function(){i(u)}))}catch(e){Be.scheduleTask((function(){r(e)}))}}else{var h=function(e){var t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}(e),d=h+t,p=new XMLHttpRequest;p.open("GET",d,!0),p.responseType="arraybuffer",p.onreadystatechange=function(){4===p.readyState&&(200===p.status?i(p.response):r("loadArrayBuffer error : "+p.response))},p.send(null)}}(this._cacheBusterURL(e),t,(function(e){i(e)}),(function(e){r(e)}))}}]),e}();var Jh=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x(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=t.messages,this.locale=t.locale}return C(e,[{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 t in e)this._messages[t]=e[t];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,t){var i=this._messages[this._locale];if(!i)return null;var r=Zh(e,i);return r?t?qh(r,t):r:null}},{key:"translatePlurals",value:function(e,t,i){var r=this._messages[this._locale];if(!r)return null;var s=Zh(e,r);return(s=0===(t=parseInt(""+t,10))?s.zero:t>1?s.other:s.one)?(s=qh(s,[t]),i&&(s=qh(s,i)),s):null}},{key:"fire",value:function(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);var r=this._eventSubs[e];if(r)for(var s in r){if(r.hasOwnProperty(s))r[s].callback(t)}}},{key:"on",value:function(e,t){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new G),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});var i=this._eventSubs[e];i||(i={},this._eventSubs[e]=i);var r=this._eventSubIDMap.addItem();i[r]={callback:t},this._eventSubEvents[r]=e;var s=this._events[e];return void 0!==s&&t(s),r}},{key:"off",value:function(e){if(null!=e&&this._eventSubEvents){var t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];var i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}}]),e}();function Zh(e,t){if(t[e])return t[e];for(var i=e.split("."),r=t,s=0,n=i.length;r&&s<n;s++){r=r[i[s]]}return r}function qh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,i){return"{{"===e?"{":"}}"===e?"}":t[i]}))}var $h=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).t=s.t,r}return C(i,[{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 t=1e-4;void 0===e&&(e=this._t);var i=e-t,r=e+t;i<0&&(i=0),r>1&&(r=1);var s=this.getPoint(i),n=this.getPoint(r),o=re.subVec3(n,s,[]);return re.normalizeVec3(o,[])}},{key:"getPointAt",value:function(e){var t=this.getUToTMapping(e);return this.getPoint(t)}},{key:"getPoints",value:function(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}},{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 t,i,r=[],s=this.getPoint(0),n=0;for(r.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),n+=re.lenVec3(re.subVec3(t,s,[])),r.push(n),s=t;return this.cacheArcLengths=r,r}},{key:"_updateArcLengths",value:function(){this.needsUpdate=!0,this._getLengths()}},{key:"getUToTMapping",value:function(e,t){var i,r=this._getLengths(),s=0,n=r.length;i=t||e*r[n-1];for(var o,a=0,l=n-1;a<=l;)if((o=r[s=Math.floor(a+(l-a)/2)]-i)<0)a=s+1;else{if(!(o>0)){l=s;break}l=s-1}if(r[s=l]===i)return s/(n-1);var u=r[s];return(s+(i-u)/(r[s+1]-u))/(n-1)}}]),i}(),ed=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).points=s.points,r.t=s.t,r}return C(i,[{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 t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,r=Math.floor(i),s=i-r,n=t[0===r?r:r-1],o=t[r],a=t[r>t.length-2?t.length-1:r+1],l=t[r>t.length-3?t.length-1:r+2],u=re.vec3();return u[0]=re.catmullRomInterpolate(n[0],o[0],a[0],l[0],s),u[1]=re.catmullRomInterpolate(n[1],o[1],a[1],l[1],s),u[2]=re.catmullRomInterpolate(n[2],o[2],a[2],l[2],s),u}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}}}]),i}(),td=re.vec3(),id=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._frames=[],r._eyeCurve=new ed(b(r)),r._lookCurve=new ed(b(r)),r._upCurve=new ed(b(r)),s.frames&&(r.addFrames(s.frames),r.smoothFrameTimes(1)),r}return C(i,[{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 t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}},{key:"addFrame",value:function(e,t,i,r){var s={t:e,eye:t.slice(0),look:i.slice(0),up:r.slice(0)};this._frames.push(s),this._eyeCurve.points.push(s.eye),this._lookCurve.points.push(s.look),this._upCurve.points.push(s.up)}},{key:"addFrames",value:function(e){for(var t,i=0,r=e.length;i<r;i++)t=e[i],this.addFrame(t.t||0,t.eye,t.look,t.up)}},{key:"loadFrame",value:function(e){var t=this.scene.camera;e=(e/=this._frames[this._frames.length-1].t-this._frames[0].t)<0?0:e>1?1:e,t.eye=this._eyeCurve.getPoint(e,td),t.look=this._lookCurve.getPoint(e,td),t.up=this._upCurve.getPoint(e,td)}},{key:"sampleFrame",value:function(e,t,i,r){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,r)}},{key:"smoothFrameTimes",value:function(e){if(0!==this._frames.length){var t=re.vec3(),i=0;this._frames[0].t=0;for(var r=[],s=1,n=this._frames.length;s<n;s++){var o=re.lenVec3(re.subVec3(this._frames[s].eye,this._frames[s-1].eye,t));r[s]=o,i+=o}for(var a=1,l=this._frames.length;a<l;a++){var u=r[a]/i*e;this._frames[a].t=this._frames[a-1].t+u}}}},{key:"clearFrames",value:function(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}}]),i}(),rd=re.vec3(),sd=re.vec3(),nd=re.vec3(),od=re.vec3(),ad=re.vec3(),ld=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._look1=re.vec3(),r._eye1=re.vec3(),r._up1=re.vec3(),r._look2=re.vec3(),r._eye2=re.vec3(),r._up2=re.vec3(),r._orthoScale1=1,r._orthoScale2=1,r._flying=!1,r._flyEyeLookUp=!1,r._flyingEye=!1,r._flyingLook=!1,r._callback=null,r._callbackScope=null,r._time1=null,r._time2=null,r.easing=!1!==s.easing,r.duration=s.duration,r.fit=s.fit,r.fitFOV=s.fitFOV,r.trail=s.trail,r}return C(i,[{key:"type",get:function(){return"CameraFlightAnimation"}},{key:"flyTo",value:function(e,t,i){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=i;var r,s,n,o,a,l=this.scene.camera,u=!!e.projection&&e.projection!==l.projection;if(this._eye1[0]=l.eye[0],this._eye1[1]=l.eye[1],this._eye1[2]=l.eye[2],this._look1[0]=l.look[0],this._look1[1]=l.look[1],this._look1[2]=l.look[2],this._up1[0]=l.up[0],this._up1[1]=l.up[1],this._up1[2]=l.up[2],this._orthoScale1=l.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)r=e.aabb;else if(6===e.length)r=e;else if(e.eye&&e.look||e.up)s=e.eye,n=e.look,o=e.up;else if(e.eye)s=e.eye;else if(e.look)n=e.look;else{var A=e;if((he.isNumeric(A)||he.isString(A))&&(a=A,!(A=this.scene.components[a])))return this.error("Component not found: "+he.inQuotes(a)),void(t&&(i?t.call(i):t()));u||(r=A.aabb||this.scene.aabb)}var c=e.poi;if(r){if(r[3]<r[0]||r[4]<r[1]||r[5]<r[2])return;if(r[3]===r[0]&&r[4]===r[1]&&r[5]===r[2])return;r=r.slice();var h=re.getAABB3Center(r);this._look2=c||h;var d=re.subVec3(this._eye1,this._look1,rd),p=re.normalizeVec3(d),f=c?re.getAABB3DiagPoint(r,c):re.getAABB3Diag(r),v=e.fitFOV||this._fitFOV,g=Math.abs(f/Math.tan(v*re.DEGTORAD));this._orthoScale2=1.1*f,this._eye2[0]=this._look2[0]+p[0]*g,this._eye2[1]=this._look2[1]+p[1]*g,this._eye2[2]=this._look2[2]+p[2]*g,this._up2[0]=this._up1[0],this._up2[1]=this._up1[1],this._up2[2]=this._up1[2],this._flyingEyeLookUp=!0}else(s||n||o)&&(this._flyingEyeLookUp=!!s&&!!n&&!!o,this._flyingEye=!!s&&!n,this._flyingLook=!!n&&!s,s&&(this._eye2[0]=s[0],this._eye2[1]=s[1],this._eye2[2]=s[2]),n&&(this._look2[0]=n[0],this._look2[1]=n[1],this._look2[2]=n[2]),o&&(this._up2[0]=o[0],this._up2[1]=o[1],this._up2[2]=o[2]));u?("ortho"===e.projection&&"ortho"!==l.projection&&(this._projection2="ortho",this._projMatrix1=l.projMatrix.slice(),this._projMatrix2=l.ortho.matrix.slice(),l.projection="customProjection"),"perspective"===e.projection&&"perspective"!==l.projection&&(this._projection2="perspective",this._projMatrix1=l.projMatrix.slice(),this._projMatrix2=l.perspective.matrix.slice(),l.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,Be.scheduleTask(this._update,this)}},{key:"jumpTo",value:function(e){this._jumpTo(e)}},{key:"_jumpTo",value:function(e){this._flying&&this.stop();var t,i,r,s,n,o=this.scene.camera;if(e.aabb)t=e.aabb;else if(6===e.length)t=e;else if(e.eye||e.look||e.up)r=e.eye,s=e.look,n=e.up;else{var a=e;if((he.isNumeric(a)||he.isString(a))&&(i=a,!(a=this.scene.components[i])))return void this.error("Component not found: "+he.inQuotes(i));t=a.aabb||this.scene.aabb}var l=e.poi;if(t){if(t[3]<=t[0]||t[4]<=t[1]||t[5]<=t[2])return;var u,A=l?re.getAABB3DiagPoint(t,l):re.getAABB3Diag(t);s=l||re.getAABB3Center(t,s),this._trail?re.subVec3(o.look,s,ad):re.subVec3(o.eye,o.look,ad),re.normalizeVec3(ad),u=(void 0!==e.fit?e.fit:this._fit)?Math.abs(A/Math.tan((e.fitFOV||this._fitFOV)*re.DEGTORAD)):re.lenVec3(re.subVec3(o.eye,o.look,rd)),re.mulVec3Scalar(ad,u),o.eye=re.addVec3(s,ad,rd),o.look=s,this.scene.camera.ortho.scale=1.1*A}else(r||s||n)&&(r&&(o.eye=r),s&&(o.look=s),n&&(o.up=n));e.projection&&(o.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 r=this.easing?i._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(re.subVec3(s.eye,s.look,ad),s.eye=re.lerpVec3(r,0,1,this._eye1,this._eye2,nd),s.look=re.subVec3(nd,ad,sd)):this._flyingLook&&(s.look=re.lerpVec3(r,0,1,this._look1,this._look2,sd),s.up=re.lerpVec3(r,0,1,this._up1,this._up2,od)):this._flyingEyeLookUp&&(s.eye=re.lerpVec3(r,0,1,this._eye1,this._eye2,nd),s.look=re.lerpVec3(r,0,1,this._look1,this._look2,sd),s.up=re.lerpVec3(r,0,1,this._up1,this._up2,od)),this._projection2){var n="ortho"===this._projection2?i._easeOutExpo(e,0,1,1):i._easeInCubic(e,0,1,1);s.customProjection.matrix=re.lerpMat4(n,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();Be.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(),f(w(i.prototype),"destroy",this).call(this)}}],[{key:"_ease",value:function(e,t,i,r){return-i*(e/=r)*(e-2)+t}},{key:"_easeInCubic",value:function(e,t,i,r){return i*(e/=r)*e*e+t}},{key:"_easeOutExpo",value:function(e,t,i,r){return i*(1-Math.pow(2,-10*e/r))+t}}]),i}(),ud=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._cameraFlightAnimation=new ld(b(r)),r._t=0,r.state=i.SCRUBBING,r._playingFromT=0,r._playingToT=0,r._playingRate=s.playingRate||1,r._playingDir=1,r._lastTime=null,r.cameraPath=s.cameraPath,r._tick=r.scene.on("tick",r._updateT,b(r)),r}return C(i,[{key:"type",get:function(){return"CameraPathAnimation"}},{key:"_updateT",value:function(){var e=this._cameraPath;if(e){var t,r,s=performance.now(),n=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==n)switch(this.state){case i.SCRUBBING:return;case i.PLAYING:if(this._t+=this._playingRate*n,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=i.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case i.PLAYING_TO:r=this._t+this._playingRate*n*this._playingDir,(this._playingDir<0&&r<=this._playingToT||this._playingDir>0&&r>=this._playingToT)&&(r=this._playingToT,this.state=i.SCRUBBING,this.fire("stopped")),this._t=r,e.loadFrame(this._t)}}}},{key:"_ease",value:function(e,t,i,r){return-i*(e/=r)*(e-2)+t}},{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=i.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=i.PLAYING_TO)}},{key:"playToFrame",value:function(e){var t=this._cameraPath;if(t){var i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}}},{key:"flyToFrame",value:function(e,t){var r=this._cameraPath;if(r){var s=r.frames[e];s?(this.state=i.SCRUBBING,this._cameraFlightAnimation.flyTo(s,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=i.SCRUBBING))}},{key:"scrubToFrame",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(t.frames[e]?(t.loadFrame(this._t),this.state=i.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)))}},{key:"stop",value:function(){this.state=i.SCRUBBING,this.fire("stopped")}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this.scene.off(this._tick)}}]),i}();ud.STOPPED=0,ud.SCRUBBING=1,ud.PLAYING=2,ud.PLAYING_TO=3;var Ad=re.vec3(),cd=re.vec3();re.vec3();var hd=re.vec3([0,-1,0]),dd=re.vec4([0,0,0,1]),pd=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._src=null,r._image=null,r._pos=re.vec3(),r._origin=re.vec3(),r._rtcPos=re.vec3(),r._dir=re.vec3(),r._size=1,r._imageSize=re.vec2(),r._texture=new Jn(b(r)),r._plane=new gn(b(r),{geometry:new Wi(b(r),ao({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Zi(b(r),{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:r._texture,emissiveMap:r._texture,backfaces:!0}),clippable:s.clippable}),r._grid=new gn(b(r),{geometry:new Wi(b(r),oo({size:1,divisions:10})),material:new Zi(b(r),{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:s.clippable}),r._node=new Tn(b(r),{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[r._plane,r._grid]}),r._gridVisible=!1,r.visible=!0,r.gridVisible=s.gridVisible,r.position=s.position,r.rotation=s.rotation,r.dir=s.dir,r.size=s.size,r.collidable=s.collidable,r.clippable=s.clippable,r.pickable=s.pickable,r.opacity=s.opacity,s.image?r.image=s.image:r.src=s.src,r}return C(i,[{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 t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.src=this._src}}},{key:"position",get:function(){return this._pos},set:function(e){this._pos.set(e||[0,0,0]),He(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 t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];re.subVec3(t,this.position,Ad);var r=-re.dotVec3(i,Ad);re.normalizeVec3(i),re.mulVec3Scalar(i,r,cd),re.vec3PairToQuaternion(hd,e,dd),this._node.quaternion=dd}}},{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(){f(w(i.prototype),"destroy",this).call(this)}},{key:"_updatePlaneSizeFromImage",value:function(){var e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){var r=i/t;this._node.scale=[e,1,e*r]}else{var s=t/i;this._node.scale=[e*s,1,e]}}}]),i}(),fd=function(e){g(i,Di);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=b(r=t.call(this,e,s));r._shadowRenderBuf=null,r._shadowViewMatrix=null,r._shadowProjMatrix=null,r._shadowViewMatrixDirty=!0,r._shadowProjMatrixDirty=!0;var o=r.scene.camera,a=r.scene.canvas;return r._onCameraViewMatrix=o.on("viewMatrix",(function(){r._shadowViewMatrixDirty=!0})),r._onCameraProjMatrix=o.on("projMatrix",(function(){r._shadowProjMatrixDirty=!0})),r._onCanvasBoundary=a.on("boundary",(function(){r._shadowProjMatrixDirty=!0})),r._state=new Ai({type:"point",pos:re.vec3([1,1,1]),color:re.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:s.space||"view",castsShadow:!1,getShadowViewMatrix:function(){if(n._shadowViewMatrixDirty){n._shadowViewMatrix||(n._shadowViewMatrix=re.identityMat4());var e=n._state.pos,t=o.look,i=o.up;re.lookAtMat4v(e,t,i,n._shadowViewMatrix),n._shadowViewMatrixDirty=!1}return n._shadowViewMatrix},getShadowProjMatrix:function(){if(n._shadowProjMatrixDirty){n._shadowProjMatrix||(n._shadowProjMatrix=re.identityMat4());var e=n.scene.canvas.canvas;re.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,n._shadowProjMatrix),n._shadowProjMatrixDirty=!1}return n._shadowProjMatrix},getShadowRenderBuf:function(){return n._shadowRenderBuf||(n._shadowRenderBuf=new si(n.scene.canvas.canvas,n.scene.canvas.gl,{size:[1024,1024]})),n._shadowRenderBuf}}),r.pos=s.pos,r.color=s.color,r.intensity=s.intensity,r.constantAttenuation=s.constantAttenuation,r.linearAttenuation=s.linearAttenuation,r.quadraticAttenuation=s.quadraticAttenuation,r.castsShadow=s.castsShadow,r.scene._lightCreated(b(r)),r}return C(i,[{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),f(w(i.prototype),"destroy",this).call(this),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}]),i}();function vd(e){return 0==(e&e-1)}function gd(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1}var md=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=(r=t.call(this,e,s)).scene.canvas.gl;return r._state=new Ai({texture:new Gn({gl:n,target:n.TEXTURE_CUBE_MAP}),flipY:r._checkFlipY(s.minFilter),encoding:r._checkEncoding(s.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),r._src=s.src,r._images=[],r._loadSrc(s.src),ae.memory.textures++,r}return C(i,[{key:"type",get:function(){return"CubeTexture"}},{key:"_checkFlipY",value:function(e){return!!e}},{key:"_checkEncoding",value:function(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),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 t=this,i=this.scene.canvas.gl;this._images=[];for(var r=!1,s=0,n=function(n){var o,a,l=new Image;l.onload=(o=l,a=n,function(){if(!r&&(o=function(e){if(!vd(e.width)||!vd(e.height)){var t=document.createElement("canvas");t.width=gd(e.width),t.height=gd(e.height),t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}(o),t._images[a]=o,6==++s)){var e=t._state.texture;e||(e=new Gn({gl:i,target:i.TEXTURE_CUBE_MAP}),t._state.texture=e),e.setImage(t._images,t._state),t.fire("loaded",t._src,!1),t.glRedraw()}}),l.onerror=function(){r=!0},l.src=e[n]},o=0;o<e.length;o++)n(o)}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this._state.texture&&this._state.texture.destroy(),ae.memory.textures--,this._state.destroy()}}]),i}(),_d=function(e){g(i,md);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).scene._lightsState.addReflectionMap(r._state),r.scene._reflectionMapCreated(b(r)),r}return C(i,[{key:"type",get:function(){return"ReflectionMap"}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this.scene._reflectionMapDestroyed(this)}}]),i}(),yd=function(e){g(i,md);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).scene._lightMapCreated(b(r)),r}return C(i,[{key:"type",get:function(){return"LightMap"}},{key:"destroy",value:function(){f(w(i.prototype),"destroy",this).call(this),this.scene._lightMapDestroyed(this)}}]),i}(),bd=function(e){g(i,ot);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,{entity:s.entity,occludable:s.occludable,worldPos:s.worldPos}))._occluded=!1,r._visible=!0,r._src=null,r._image=null,r._pos=re.vec3(),r._origin=re.vec3(),r._rtcPos=re.vec3(),r._dir=re.vec3(),r._size=1,r._imageSize=re.vec2(),r._texture=new Jn(b(r),{src:s.src}),r._geometry=new Wi(b(r),{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]}),r._mesh=new gn(b(r),{geometry:r._geometry,material:new Zi(b(r),{ambient:[.9,.3,.9],shininess:30,diffuseMap:r._texture,backfaces:!0}),scale:[1,1,1],position:s.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),r.visible=!0,r.collidable=s.collidable,r.clippable=s.clippable,r.pickable=s.pickable,r.opacity=s.opacity,r.size=s.size,s.image?r.image=s.image:r.src=s.src,r}return C(i,[{key:"_setVisible",value:function(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,f(w(i.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 t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.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,t=this._imageSize[0],i=this._imageSize[1],r=i/t;this._geometry.positions=t>i?[e,e*r,0,-e,e*r,0,-e,-e*r,0,e,-e*r,0]:[e/r,e,0,-e/r,e,0,-e/r,-e,0,e/r,-e,0]}}]),i}(),wd=function(){function e(t){x(this,e),this._eye=re.vec3(),this._look=re.vec3(),this._up=re.vec3(),this._projection={},t&&this.saveCamera(t)}return C(e,[{key:"saveCamera",value:function(e){var t=e.camera,i=t.project;switch(this._eye.set(t.eye),this._look.set(t.look),this._up.set(t.up),t.projection){case"perspective":this._projection={projection:"perspective",fov:i.fov,fovAxis:i.fovAxis,near:i.near,far:i.far};break;case"ortho":this._projection={projection:"ortho",scale:i.scale,near:i.near,far:i.far};break;case"frustum":this._projection={projection:"frustum",left:i.left,right:i.right,top:i.top,bottom:i.bottom,near:i.near,far:i.far};break;case"custom":this._projection={projection:"custom",matrix:i.matrix.slice()}}}},{key:"restoreCamera",value:function(e,t){var i=e.camera,r=this._projection;function s(){switch(r.type){case"perspective":i.perspective.fov=r.fov,i.perspective.fovAxis=r.fovAxis,i.perspective.near=r.near,i.perspective.far=r.far;break;case"ortho":i.ortho.scale=r.scale,i.ortho.near=r.near,i.ortho.far=r.far;break;case"frustum":i.frustum.left=r.left,i.frustum.right=r.right,i.frustum.top=r.top,i.frustum.bottom=r.bottom,i.frustum.near=r.near,i.frustum.far=r.far;break;case"custom":i.customProjection.matrix=r.matrix}}t?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:r.scale,projection:r.projection},(function(){s(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,s(),i.projection=r.projection)}}]),e}(),Bd=re.vec3(),xd=function(){function e(t){if(x(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,t){var i=t.metaScene.scene;this.saveObjects(i,t)}}return C(e,[{key:"saveObjects",value:function(e,t,i){this.numObjects=0,this._mask=i?he.apply(i,{}):null;for(var r=!i||i.visible,s=!i||i.edges,n=!i||i.xrayed,o=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,u=!i||i.pickable,A=!i||i.colorize,c=!i||i.opacity,h=t.metaObjects,d=e.objects,p=0,f=h.length;p<f;p++){var v=d[h[p].id];if(v){if(r&&(this.objectsVisible[p]=v.visible),s&&(this.objectsEdges[p]=v.edges),n&&(this.objectsXrayed[p]=v.xrayed),o&&(this.objectsHighlighted[p]=v.highlighted),a&&(this.objectsSelected[p]=v.selected),l&&(this.objectsClippable[p]=v.clippable),u&&(this.objectsPickable[p]=v.pickable),A){var g=v.colorize;this.objectsColorize[3*p+0]=g[0],this.objectsColorize[3*p+1]=g[1],this.objectsColorize[3*p+2]=g[2]}c&&(this.objectsOpacity[p]=v.opacity),this.numObjects++}}}},{key:"restoreObjects",value:function(e,t){for(var i=this._mask,r=!i||i.visible,s=!i||i.edges,n=!i||i.xrayed,o=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,u=!i||i.pickable,A=!i||i.colorize,c=!i||i.opacity,h=t.metaObjects,d=e.objects,p=0,f=h.length;p<f;p++){var v=d[h[p].id];v&&(r&&(v.visible=this.objectsVisible[p]),s&&(v.edges=this.objectsEdges[p]),n&&(v.xrayed=this.objectsXrayed[p]),o&&(v.highlighted=this.objectsHighlighted[p]),a&&(v.selected=this.objectsSelected[p]),l&&(v.clippable=this.objectsClippable[p]),u&&(v.pickable=this.objectsPickable[p]),A&&(Bd[0]=this.objectsColorize[3*p+0],Bd[1]=this.objectsColorize[3*p+1],Bd[2]=this.objectsColorize[3*p+2],v.colorize=Bd),c&&(v.opacity=this.objectsOpacity[p]))}}}]),e}(),Pd=re.vec3(),Cd=function(){function e(){x(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}return C(e,[{key:"saveObjects",value:function(e,t){this.numObjects=0,this._mask=t?he.apply(t,{}):null;var i=e.objects,r=!t||t.visible,s=!t||t.edges,n=!t||t.xrayed,o=!t||t.highlighted,a=!t||t.selected,l=!t||t.clippable,u=!t||t.pickable,A=!t||t.colorize,c=!t||t.opacity;for(var h in i)if(i.hasOwnProperty(h)){var d=i[h],p=this.numObjects;if(r&&(this.objectsVisible[p]=d.visible),s&&(this.objectsEdges[p]=d.edges),n&&(this.objectsXrayed[p]=d.xrayed),o&&(this.objectsHighlighted[p]=d.highlighted),a&&(this.objectsSelected[p]=d.selected),l&&(this.objectsClippable[p]=d.clippable),u&&(this.objectsPickable[p]=d.pickable),A){var f=d.colorize;f?(this.objectsColorize[3*p+0]=f[0],this.objectsColorize[3*p+1]=f[1],this.objectsColorize[3*p+2]=f[2],this.objectsHasColorize[p]=!0):this.objectsHasColorize[p]=!1}c&&(this.objectsOpacity[p]=d.opacity),this.numObjects++}}},{key:"restoreObjects",value:function(e){var t=this._mask,i=!t||t.visible,r=!t||t.edges,s=!t||t.xrayed,n=!t||t.highlighted,o=!t||t.selected,a=!t||t.clippable,l=!t||t.pickable,u=!t||t.colorize,A=!t||t.opacity,c=0,h=e.objects;for(var d in h)if(h.hasOwnProperty(d)){var p=h[d];i&&(p.visible=this.objectsVisible[c]),r&&(p.edges=this.objectsEdges[c]),s&&(p.xrayed=this.objectsXrayed[c]),n&&(p.highlighted=this.objectsHighlighted[c]),o&&(p.selected=this.objectsSelected[c]),a&&(p.clippable=this.objectsClippable[c]),l&&(p.pickable=this.objectsPickable[c]),u&&(this.objectsHasColorize[c]?(Pd[0]=this.objectsColorize[3*c+0],Pd[1]=this.objectsColorize[3*c+1],Pd[2]=this.objectsColorize[3*c+2],p.colorize=Pd):p.colorize=null),A&&(p.opacity=this.objectsOpacity[c]),c++}}}]),e}(),Md=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).v0=s.v0,r.v1=s.v1,r.v2=s.v2,r.v3=s.v3,r.t=s.t,r}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||re.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||re.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||re.vec3([0,0,0])}},{key:"v3",get:function(){return this._v3},set:function(e){this.fire("v3",this._v3=e||re.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 t=re.vec3();return t[0]=re.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=re.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=re.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}]),i}(),Ed=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._cachedLengths=[],r._dirty=!0,r._curves=[],r._t=0,r._dirtySubs=[],r._destroyedSubs=[],r.curves=s.curves||[],r.t=s.t,r}return C(i,[{key:"addCurve",value:function(e){this._curves.push(e),this._dirty=!0}},{key:"curves",get:function(){return this._curves},set:function(e){var t,i,r;for(e=e||[],i=0,r=this._curves.length;i<r;i++)(t=this._curves[i]).off(this._dirtySubs[i]),t.off(this._destroyedSubs[i]);this._curves=[],this._dirtySubs=[],this._destroyedSubs=[];var s=this;function n(){s._dirty=!0}function o(){var e=this.id;for(i=0,r=s._curves.length;i<r;i++)if(s._curves[i].id===e)return s._curves=s._curves.slice(i,i+1),s._dirtySubs=s._dirtySubs.slice(i,i+1),s._destroyedSubs=s._destroyedSubs.slice(i,i+1),void(s._dirty=!0)}for(i=0,r=e.length;i<r;i++){if(t=e[i],he.isNumeric(t)||he.isString(t)){var a=t;if(!(t=this.scene.components[a])){this.error("Component not found: "+_inQuotes(a));continue}}var l=t.type;"xeokit.SplineCurve"===l||"xeokit.Path"===l||"xeokit.CubicBezierCurve"===l||"xeokit.QuadraticBezierCurve"===l?(this._curves.push(t),this._dirtySubs.push(t.on("dirty",n)),this._destroyedSubs.push(t.once("destroyed",o))):this.error("Component "+_inQuotes(t.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 t,i=e*this.length,r=this._getCurveLengths(),s=0;s<r.length;){if(r[s]>=i){var n=1-(r[s]-i)/(t=this._curves[s]).length;return t.getPointAt(n)}s++}return null}},{key:"_getCurveLengths",value:function(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,r=this._curves.length;for(e=0;e<r;e++)i+=this._curves[e].length,t.push(i);return this._cachedLengths=t,this._dirty=!1,t}},{key:"_getJSON",value:function(){for(var e=[],t=0,i=this._curves.length;t<i;t++)e.push(this._curves[t].id);return{curves:e,t:this._t}}},{key:"destroy",value:function(){var e,t,r;for(f(w(i.prototype),"destroy",this).call(this),e=0,t=this._curves.length;e<t;e++)(r=this._curves[e]).off(this._dirtySubs[e]),r.off(this._destroyedSubs[e])}}]),i}(),Fd=function(e){g(i,$h);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s)).v0=s.v0,r.v1=s.v1,r.v2=s.v2,r.t=s.t,r}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||re.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||re.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||re.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 t=re.vec3();return t[0]=re.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=re.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=re.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}]),i}(),kd=function(e){g(i,Ph);var t=_(i);function i(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),t.call(this,e,r)}return C(i)}(),Id=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(r=t.call(this,e,s))._skyboxMesh=new gn(b(r),{geometry:new Wi(b(r),{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 Zi(b(r),{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Jn(b(r),{src:s.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:s.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),r.size=s.size,r.active=s.active,r}return C(i,[{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}}]),i}(),Dd=function(){function e(){x(this,e)}return C(e,[{key:"transcode",value:function(e,t){}},{key:"destroy",value:function(){}}]),e}(),Sd=re.vec4(),Td=re.vec4(),Ld=re.vec3(),Rd=re.vec3(),Ud=re.vec3(),Od=re.vec4(),Nd=re.vec4(),Qd=re.vec4(),Vd=function(){function e(t){x(this,e),this._scene=t}return C(e,[{key:"dollyToCanvasPos",value:function(e,t,i){var r=!1,s=this._scene.camera;if(e){var n=re.subVec3(e,s.eye,Ld);r=re.lenVec3(n)<i}if("perspective"===s.projection){s.ortho.scale=s.ortho.scale-i;var o=this._unproject(t,Od),a=re.subVec3(o,s.eye,Qd),l=re.mulVec3Scalar(re.normalizeVec3(a),-i,[]);if(s.eye=[s.eye[0]-l[0],s.eye[1]-l[1],s.eye[2]-l[2]],s.look=[s.look[0]-l[0],s.look[1]-l[1],s.look[2]-l[2]],e){var u=re.subVec3(e,s.eye,Ld),A=re.lenVec3(u),c=re.mulVec3Scalar(re.normalizeVec3(re.subVec3(s.look,s.eye,Rd)),A);s.look=[s.eye[0]+c[0],s.eye[1]+c[1],s.eye[2]+c[2]]}}else if("ortho"===s.projection){var h=this._unproject(t,Od);s.ortho.scale=s.ortho.scale-i,s.ortho._update();var d=this._unproject(t,Nd),p=re.subVec3(d,h,Qd),f=re.mulVec3Scalar(re.normalizeVec3(re.subVec3(s.look,s.eye,Ld)),-i,Rd),v=re.addVec3(p,f,Ud);s.eye=[s.eye[0]-v[0],s.eye[1]-v[1],s.eye[2]-v[2]],s.look=[s.look[0]-v[0],s.look[1]-v[1],s.look[2]-v[2]]}return r}},{key:"_unproject",value:function(e,t){var i=this._scene.camera,r=i.project.transposedMatrix,s=r.subarray(8,12),n=r.subarray(12),o=[0,0,-1,1],a=re.dotVec4(o,s)/re.dotVec4(o,n);return i.project.unproject(e,a,Sd,Td,t),t}},{key:"destroy",value:function(){}}]),e}(),Hd=re.vec3(),jd=re.vec3(),Gd=re.vec3(),zd=re.vec4(),Wd=re.vec4(),Kd=re.vec4(),Xd=function(){function e(t,i){var r=this;x(this,e),this._scene=t,this._configs=i,this._pivotWorldPos=re.vec3(),this._cameraOffset=re.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=re.vec3(),this._rtcPos=re.vec3(),this._pivotViewPos=re.vec4(),this._pivotProjPos=re.vec4(),this._pivotCanvasPos=re.vec2(),this._cameraDirty=!0,this._onViewMatrix=this._scene.camera.on("viewMatrix",(function(){r._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(function(){r._cameraDirty=!0})),this._onTick=this._scene.on("tick",(function(){r.updatePivotElement(),r.updatePivotSphere()}))}return C(e,[{key:"createPivotSphere",value:function(){var e=this.getPivotPos(),t=re.vec3();re.decomposeMat4(re.inverseMat4(this._scene.viewer.camera.viewMatrix,re.mat4()),t,re.vec4(),re.vec3());var i=re.distVec3(t,e),r=Math.tan(Math.PI/500)*i*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(r/=this._scene.camera.ortho.scale/2),He(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new eo(this._scene,yn({radius:r})),this._pivotSphere=new gn(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:"updatePivotElement",value:function(){var e=this._scene.camera,t=this._scene.canvas;if(this._pivoting&&this._cameraDirty){re.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,re.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);var i=t.boundary,r=i[2],s=i[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*r/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*s/2);var n=t._lastBoundingClientRect;if(!n||t._canvasSizeChanged){var o=t.canvas;n=t._lastBoundingClientRect=o.getBoundingClientRect()}this._pivotElement&&(this._pivotElement.style.left=Math.floor(n.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+"px",this._pivotElement.style.top=Math.floor(n.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+"px"),this._cameraDirty=!1}}},{key:"updatePivotSphere",value:function(){this._pivoting&&this._pivotSphere&&(He(this.getPivotPos(),this._rtcCenter,this._rtcPos),re.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 t=e.color||[1,0,0];this._pivotSphereMaterial=new Zi(this._scene,{emissive:t,ambient:t,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,t=re.lookAtMat4v(e.eye,e.look,e.worldUp);re.transformPoint3(t,this.getPivotPos(),this._cameraOffset);var i=this.getPivotPos();this._cameraOffset[2]+=re.distVec3(e.eye,i),t=re.inverseMat4(t);var r=re.transformVec3(t,this._cameraOffset),s=re.vec3();if(re.subVec3(e.eye,i,s),re.addVec3(s,r),e.zUp){var n=s[1];s[1]=s[2],s[2]=n}this._radius=re.lenVec3(s),this._polar=Math.acos(s[1]/this._radius),this._azimuth=Math.atan2(s[0],s[2]),this._pivoting=!0}},{key:"_cameraLookingDownwards",value:function(){var e=this._scene.camera,t=re.normalizeVec3(re.subVec3(e.look,e.eye,Hd)),i=re.cross3Vec3(t,e.worldUp,jd);return re.sqLenVec3(i)<=1e-4}},{key:"getPivoting",value:function(){return this._pivoting}},{key:"setPivotPos",value:function(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}},{key:"setCanvasPivotPos",value:function(e){var t=this._scene.camera,i=Math.abs(re.distVec3(this._scene.center,t.eye)),r=t.project.transposedMatrix,s=r.subarray(8,12),n=r.subarray(12),o=[0,0,-1,1],a=re.dotVec4(o,s)/re.dotVec4(o,n),l=zd;t.project.unproject(e,a,Wd,Kd,l);var u=re.normalizeVec3(re.subVec3(l,t.eye,Hd)),A=re.addVec3(t.eye,re.mulVec3Scalar(u,i,jd),Gd);this.setPivotPos(A)}},{key:"getPivotPos",value:function(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}},{key:"continuePivot",value:function(e,t){if(this._pivoting&&(0!==e||0!==t)){var i=this._scene.camera,r=-e,s=-t;1===i.worldUp[2]&&(r=-r),this._azimuth+=.01*-r,this._polar+=.01*s,this._polar=re.clamp(this._polar,.001,Math.PI-.001);var n=[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===i.worldUp[2]){var o=n[1];n[1]=n[2],n[2]=o}var a=re.lenVec3(re.subVec3(i.look,i.eye,re.vec3())),l=this.getPivotPos();re.addVec3(n,l);var u=re.lookAtMat4v(n,l,i.worldUp);u=re.inverseMat4(u);var A=re.transformVec3(u,this._cameraOffset);u[12]-=A[0],u[13]-=A[1],u[14]-=A[2];var c=[u[8],u[9],u[10]];i.eye=[u[12],u[13],u[14]],re.subVec3(i.eye,re.mulVec3Scalar(c,a),i.look),i.up=[u[4],u[5],u[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.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}]),e}(),Yd=function(){function e(t,i){x(this,e),this._scene=t.scene,this._cameraControl=t,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=i,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=re.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}return C(e,[{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 t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var i=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});i&&(i.snappedToEdge||i.snappedToVertex)?(this.snapPickResult=i,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){var r=this.pickResult.canvasPos;if(r[0]===this.pickCursorPos[0]&&r[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?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 s=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(s[0]===this.pickCursorPos[0]&&s[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 Rt;e.entity=this.snapPickResult.entity,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 t=this.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=t)}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}}}]),e}(),Jd=re.vec2(),Zd=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o,a,l,u=i.pickController,A=0,c=0,h=0,d=0,p=!1,f=re.vec3(),v=!0,g=this._scene.canvas.canvas,m=[];function _(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];g.style.cursor="move",y(),e&&b()}function y(){A=s.pointerCanvasPos[0],c=s.pointerCanvasPos[1],h=s.pointerCanvasPos[0],d=s.pointerCanvasPos[1]}function b(){u.pickCursorPos=s.pointerCanvasPos,u.schedulePickSurface=!0,u.update(),u.picked&&u.pickedSurface&&u.pickResult&&u.pickResult.worldPos?(p=!0,f.set(u.pickResult.worldPos)):p=!1}document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!0}}),document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!1}}),g.addEventListener("mousedown",this._mouseDownHandler=function(e){if(r.active&&r.pointerEnabled)switch(e.which){case 1:m[t.input.KEY_SHIFT]||r.planView?(o=!0,_()):(o=!0,_(!1));break;case 2:a=!0,_();break;case 3:l=!0,r.panRightClick&&_()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=function(e){if(r.active&&r.pointerEnabled&&(o||a||l)){var i=t.canvas.boundary,u=i[2],h=i[3],d=s.pointerCanvasPos[0],v=s.pointerCanvasPos[1],g=m[t.input.KEY_SHIFT]||r.planView||!r.panRightClick&&a||r.panRightClick&&l,_=document.pointerLockElement?e.movementX:d-A,y=document.pointerLockElement?e.movementY:v-c;if(g){var b=t.camera;if("perspective"===b.projection){var w=Math.abs(p?re.lenVec3(re.subVec3(f,t.camera.eye,[])):t.camera.eyeLookDist)*Math.tan(b.perspective.fov/2*Math.PI/180);n.panDeltaX+=1.5*_*w/h,n.panDeltaY+=1.5*y*w/h}else n.panDeltaX+=.5*b.ortho.scale*(_/h),n.panDeltaY+=.5*b.ortho.scale*(y/h)}else!o||a||l||r.planView||(r.firstPerson?(n.rotateDeltaY-=_/u*r.dragRotationRate/2,n.rotateDeltaX+=y/h*(r.dragRotationRate/4)):(n.rotateDeltaY-=_/u*(1.5*r.dragRotationRate),n.rotateDeltaX+=y/h*(1.5*r.dragRotationRate)));A=d,c=v}}),g.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){r.active&&r.pointerEnabled&&s.mouseover&&(v=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(r.active&&r.pointerEnabled)switch(e.which){case 1:case 2:case 3:o=!1,a=!1,l=!1}}),g.addEventListener("mouseup",this._mouseUpHandler=function(e){if(r.active&&r.pointerEnabled){if(3===e.which){!function(e,t){if(e){for(var i=e.target,r=0,s=0,n=0,o=0;i.offsetParent;)r+=i.offsetLeft,s+=i.offsetTop,n+=i.scrollLeft,o+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+n-r,t[1]=e.pageY+o-s}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Jd);var t=Jd[0],s=Jd[1];Math.abs(t-h)<3&&Math.abs(s-d)<3&&i.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Jd,event:e},!0)}g.style.removeProperty("cursor")}}),g.addEventListener("mouseenter",this._mouseEnterHandler=function(){r.active&&r.pointerEnabled});var w=1/60,B=null;g.addEventListener("wheel",this._mouseWheelHandler=function(e){if(r.active&&r.pointerEnabled){var t=performance.now()/1e3,i=null!==B?t-B:0;B=t,i>.05&&(i=.05),i<w&&(i=w);var o=Math.max(-1,Math.min(1,40*-e.deltaY));if(0!==o){var a=o/Math.abs(o);n.dollyDelta+=-a*i*r.mouseWheelDollyRate,v&&(s.followPointerDirty=!0,v=!1)}}},{passive:!0})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;document.removeEventListener("keydown",this._documentKeyDownHandler),document.removeEventListener("keyup",this._documentKeyUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),document.removeEventListener("mousemove",this._documentMouseMoveHandler),e.removeEventListener("mousemove",this._canvasMouseMoveHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("wheel",this._mouseWheelHandler)}}]),e}(),qd=re.vec3(),$d=re.vec3(),ep=re.vec3(),tp=re.vec3(),ip=re.vec3(),rp={eye:re.vec3(),look:re.vec3(),up:re.vec3()},sp=function(){function e(t,i,r,s){x(this,e),this._scene=t;var n=i.cameraControl,o=t.camera;this._onSceneKeyDown=t.input.on("keydown",(function(){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(!r.keyboardEnabledOnlyIfMouseover||s.mouseover)){var e=n._isKeyDownForAction(n.AXIS_VIEW_RIGHT),a=n._isKeyDownForAction(n.AXIS_VIEW_BACK),l=n._isKeyDownForAction(n.AXIS_VIEW_LEFT),u=n._isKeyDownForAction(n.AXIS_VIEW_FRONT),A=n._isKeyDownForAction(n.AXIS_VIEW_TOP),c=n._isKeyDownForAction(n.AXIS_VIEW_BOTTOM);if(e||a||l||u||A||c){var h=t.aabb,d=re.getAABB3Diag(h);re.getAABB3Center(h,qd);var p=Math.abs(d/Math.tan(i.cameraFlight.fitFOV*re.DEGTORAD)),f=1.1*d;rp.orthoScale=f,e?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldRight,p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):a?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldForward,p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):l?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldRight,-p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):u?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldForward,-p,$d),ip)),rp.look.set(qd),rp.up.set(o.worldUp)):A?(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldUp,p,$d),ip)),rp.look.set(qd),rp.up.set(re.normalizeVec3(re.mulVec3Scalar(o.worldForward,1,ep),tp))):c&&(rp.eye.set(re.addVec3(qd,re.mulVec3Scalar(o.worldUp,-p,$d),ip)),rp.look.set(qd),rp.up.set(re.normalizeVec3(re.mulVec3Scalar(o.worldForward,-1,ep)))),!r.firstPerson&&r.followPointer&&i.pivotController.setPivotPos(qd),i.cameraFlight.duration>0?i.cameraFlight.flyTo(rp,(function(){i.pivotController.getPivoting()&&r.followPointer&&i.pivotController.showPivot()})):(i.cameraFlight.jumpTo(rp),i.pivotController.getPivoting()&&r.followPointer&&i.pivotController.showPivot())}}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.input.off(this._onSceneKeyDown)}}]),e}(),np=function(){function e(t,i,r,s,n){var o=this;x(this,e),this._scene=t;var a=i.pickController,l=i.pivotController,u=i.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;var A=!1,c=!1,h=this._scene.canvas.canvas,d=function(e){var r;e&&e.worldPos&&(r=e.worldPos);var s=e&&e.entity?e.entity.aabb:t.aabb;if(r){var n=t.camera;re.subVec3(n.eye,n.look,[]),i.cameraFlight.flyTo({aabb:s})}else i.cameraFlight.flyTo({aabb:s})},p=t.tickify(this._canvasMouseMoveHandler=function(e){if(r.active&&r.pointerEnabled&&!A&&!c){if(u.hasSubs("rayMove")){var i=re.vec3(),n=re.vec3();re.canvasPosToWorldRay(t.canvas.canvas,t.camera.viewMatrix,t.camera.projMatrix,t.camera.projection,s.pointerCanvasPos,i,n),u.fire("rayMove",{canvasPos:s.pointerCanvasPos,ray:{origin:i,direction:n,canvasPos:s.pointerCanvasPos}},!0)}var l=u.hasSubs("hover"),h=u.hasSubs("hoverEnter"),d=u.hasSubs("hoverOut"),p=u.hasSubs("hoverOff"),f=u.hasSubs("hoverSurface"),v=u.hasSubs("hoverSnapOrSurface");if(l||h||d||p||f||v)if(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=f,a.scheduleSnapOrPick=v,a.update(),a.pickResult){if(a.pickResult.entity){var g=a.pickResult.entity.id;o._lastPickedEntityId!==g&&(void 0!==o._lastPickedEntityId&&u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),u.fire("hoverEnter",a.pickResult,!0),o._lastPickedEntityId=g)}u.fire("hover",a.pickResult,!0),(a.pickResult.worldPos||a.pickResult.snappedWorldPos)&&u.fire("hoverSurface",a.pickResult,!0)}else void 0!==o._lastPickedEntityId&&(u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),o._lastPickedEntityId=void 0),u.fire("hoverOff",{canvasPos:a.pickCursorPos},!0)}});h.addEventListener("mousemove",p),h.addEventListener("mousedown",this._canvasMouseDownHandler=function(e){if(1===e.which&&(A=!0),3===e.which&&(c=!0),1===e.which&&r.active&&r.pointerEnabled&&(s.mouseDownClientX=e.clientX,s.mouseDownClientY=e.clientY,s.mouseDownCursorX=s.pointerCanvasPos[0],s.mouseDownCursorY=s.pointerCanvasPos[1],!r.firstPerson&&r.followPointer&&(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),1===e.which))){var i=a.pickResult;i&&i.worldPos?(l.setPivotPos(i.worldPos),l.startPivot()):(r.smartPivot?l.setCanvasPivotPos(s.pointerCanvasPos):l.setPivotPos(t.camera.look),l.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){1===e.which&&(A=!1),3===e.which&&(c=!1),l.getPivoting()&&l.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=function(e){if(r.active&&r.pointerEnabled&&(1===e.which&&(l.hidePivot(),!(Math.abs(e.clientX-s.mouseDownClientX)>3||Math.abs(e.clientY-s.mouseDownClientY)>3)))){var n=u.hasSubs("picked"),A=u.hasSubs("pickedNothing"),c=u.hasSubs("pickedSurface"),h=u.hasSubs("doublePicked"),p=u.hasSubs("doublePickedSurface"),f=u.hasSubs("doublePickedNothing");if(!(r.doublePickFlyTo||h||p||f))return(n||A||c)&&(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=c,a.update(),a.pickResult?(u.fire("picked",a.pickResult,!0),a.pickedSurface&&u.fire("pickedSurface",a.pickResult,!0)):u.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0)),void(o._clicks=0);if(o._clicks++,1===o._clicks){a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=r.doublePickFlyTo,a.schedulePickSurface=c,a.update();var v=a.pickResult,g=a.pickedSurface;o._timeout=setTimeout((function(){v&&v.worldPos?(u.fire("picked",v,!0),g&&(u.fire("pickedSurface",v,!0),!r.firstPerson&&r.followPointer&&(i.pivotController.setPivotPos(v.worldPos),i.pivotController.startPivot()&&i.pivotController.showPivot()))):u.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0),o._clicks=0}),r.doubleClickTimeFrame)}else{if(null!==o._timeout&&(window.clearTimeout(o._timeout),o._timeout=null),a.pickCursorPos=s.pointerCanvasPos,a.schedulePickEntity=r.doublePickFlyTo||h||p,a.schedulePickSurface=a.schedulePickEntity&&p,a.update(),a.pickResult){if(u.fire("doublePicked",a.pickResult,!0),a.pickedSurface&&u.fire("doublePickedSurface",a.pickResult,!0),r.doublePickFlyTo&&(d(a.pickResult),!r.firstPerson&&r.followPointer)){var m=a.pickResult.entity.aabb,_=re.getAABB3Center(m);i.pivotController.setPivotPos(_),i.pivotController.startPivot()&&i.pivotController.showPivot()}}else if(u.fire("doublePickedNothing",{canvasPos:s.pointerCanvasPos},!0),r.doublePickFlyTo&&(d(),!r.firstPerson&&r.followPointer)){var y=t.aabb,b=re.getAABB3Center(y);i.pivotController.setPivotPos(b),i.pivotController.startPivot()&&i.pivotController.showPivot()}o._clicks=0}}},!1)}return C(e,[{key:"reset",value:function(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}]),e}(),op=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=t.input,a=[],l=t.canvas.canvas,u=!0;this._onSceneMouseMove=o.on("mousemove",(function(){u=!0})),this._onSceneKeyDown=o.on("keydown",(function(e){r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(r.keyboardEnabledOnlyIfMouseover&&!s.mouseover||(a[e]=!0,e===o.KEY_SHIFT&&(l.style.cursor="move")))})),this._onSceneKeyUp=o.on("keyup",(function(e){r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(a[e]=!1,e===o.KEY_SHIFT&&(l.style.cursor=null),i.pivotController.getPivoting()&&i.pivotController.endPivot())})),this._onTick=t.on("tick",(function(e){if(r.active&&r.pointerEnabled&&t.input.keyboardEnabled&&(!r.keyboardEnabledOnlyIfMouseover||s.mouseover)){var l=i.cameraControl,A=e.deltaTime/1e3;if(!r.planView){var c=l._isKeyDownForAction(l.ROTATE_Y_POS,a),h=l._isKeyDownForAction(l.ROTATE_Y_NEG,a),d=l._isKeyDownForAction(l.ROTATE_X_POS,a),p=l._isKeyDownForAction(l.ROTATE_X_NEG,a),f=A*r.keyboardRotationRate;(c||h||d||p)&&(!r.firstPerson&&r.followPointer&&i.pivotController.startPivot(),c?n.rotateDeltaY+=f:h&&(n.rotateDeltaY-=f),d?n.rotateDeltaX+=f:p&&(n.rotateDeltaX-=f),!r.firstPerson&&r.followPointer&&i.pivotController.startPivot())}if(!a[o.KEY_CTRL]&&!a[o.KEY_ALT]){var v=l._isKeyDownForAction(l.DOLLY_BACKWARDS,a),g=l._isKeyDownForAction(l.DOLLY_FORWARDS,a);if(v||g){var m=A*r.keyboardDollyRate;!r.firstPerson&&r.followPointer&&i.pivotController.startPivot(),g?n.dollyDelta-=m:v&&(n.dollyDelta+=m),u&&(s.followPointerDirty=!0,u=!1)}}var _=l._isKeyDownForAction(l.PAN_FORWARDS,a),y=l._isKeyDownForAction(l.PAN_BACKWARDS,a),b=l._isKeyDownForAction(l.PAN_LEFT,a),w=l._isKeyDownForAction(l.PAN_RIGHT,a),B=l._isKeyDownForAction(l.PAN_UP,a),x=l._isKeyDownForAction(l.PAN_DOWN,a),P=(a[o.KEY_ALT]?.3:1)*A*r.keyboardPanRate;(_||y||b||w||B||x)&&(!r.firstPerson&&r.followPointer&&i.pivotController.startPivot(),x?n.panDeltaY+=P:B&&(n.panDeltaY+=-P),w?n.panDeltaX+=-P:b&&(n.panDeltaX+=P),y?n.panDeltaZ+=P:_&&(n.panDeltaZ+=-P))}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}]),e}(),ap=re.vec3(),lp=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=t.camera,a=i.pickController,l=i.pivotController,u=i.panController,A=1,c=1,h=null;this._onTick=t.on("tick",(function(){if(r.active&&r.pointerEnabled){var e="default";if(Math.abs(n.dollyDelta)<.001&&(n.dollyDelta=0),Math.abs(n.rotateDeltaX)<.001&&(n.rotateDeltaX=0),Math.abs(n.rotateDeltaY)<.001&&(n.rotateDeltaY=0),0===n.rotateDeltaX&&0===n.rotateDeltaY||(n.dollyDelta=0),r.followPointer){if(--A<=0&&(A=1,0!==n.dollyDelta)){if(0===n.rotateDeltaY&&0===n.rotateDeltaX&&r.followPointer&&s.followPointerDirty&&(a.pickCursorPos=s.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),a.pickResult&&a.pickResult.worldPos?h=a.pickResult.worldPos:(c=1,h=null),s.followPointerDirty=!1),h){var i=Math.abs(re.lenVec3(re.subVec3(h,t.camera.eye,ap)));c=i/r.dollyProximityThreshold}c<r.dollyMinSpeed&&(c=r.dollyMinSpeed)}}else c=1,h=null;var d=n.dollyDelta*c;if(0===n.rotateDeltaY&&0===n.rotateDeltaX||(!r.firstPerson&&r.followPointer&&l.getPivoting()?(l.continuePivot(n.rotateDeltaY,n.rotateDeltaX),l.showPivot()):(0!==n.rotateDeltaX&&(r.firstPerson?o.pitch(-n.rotateDeltaX):o.orbitPitch(n.rotateDeltaX)),0!==n.rotateDeltaY&&(r.firstPerson?o.yaw(n.rotateDeltaY):o.orbitYaw(n.rotateDeltaY))),n.rotateDeltaX*=r.rotationInertia,n.rotateDeltaY*=r.rotationInertia,e="grabbing"),Math.abs(n.panDeltaX)<.001&&(n.panDeltaX=0),Math.abs(n.panDeltaY)<.001&&(n.panDeltaY=0),Math.abs(n.panDeltaZ)<.001&&(n.panDeltaZ=0),0!==n.panDeltaX||0!==n.panDeltaY||0!==n.panDeltaZ){var p,f,v=re.vec3();if(v[0]=n.panDeltaX,v[1]=n.panDeltaY,v[2]=n.panDeltaZ,r.constrainVertical){o.xUp?(p=o.eye[0],f=o.look[0]):o.yUp?(p=o.eye[1],f=o.look[1]):o.zUp&&(p=o.eye[2],f=o.look[2]),o.pan(v);var g=o.eye,m=o.look;o.xUp?(g[0]=p,m[0]=f):o.yUp?(g[1]=p,m[1]=f):o.zUp&&(g[2]=p,m[2]=f),o.eye=g,o.look=m}else o.pan(v);e="grabbing"}if(n.panDeltaX*=r.panInertia,n.panDeltaY*=r.panInertia,n.panDeltaZ*=r.panInertia,0!==d){if(e=d<0?"zoom-in":"zoom-out",r.firstPerson){var _,y;if(r.constrainVertical&&(o.xUp?(_=o.eye[0],y=o.look[0]):o.yUp?(_=o.eye[1],y=o.look[1]):o.zUp&&(_=o.eye[2],y=o.look[2])),r.followPointer)u.dollyToCanvasPos(h,s.pointerCanvasPos,-d)&&(s.followPointerDirty=!0);else o.pan([0,0,d]),o.ortho.scale=o.ortho.scale-d;if(r.constrainVertical){var b=o.eye,w=o.look;o.xUp?(b[0]=_,w[0]=y):o.yUp?(b[1]=_,w[1]=y):o.zUp&&(b[2]=_,w[2]=y),o.eye=b,o.look=w}}else if(r.planView){if(r.followPointer)u.dollyToCanvasPos(h,s.pointerCanvasPos,-d)&&(s.followPointerDirty=!0);else o.ortho.scale=o.ortho.scale+d,o.zoom(d)}else{if(r.followPointer)u.dollyToCanvasPos(h,s.pointerCanvasPos,-d)&&(s.followPointerDirty=!0);else o.ortho.scale=o.ortho.scale+d,o.zoom(d)}n.dollyDelta*=r.dollyInertia}a.fireEvents(),document.body.style.cursor=e}}))}return C(e,[{key:"destroy",value:function(){this._scene.off(this._onTick)}}]),e}(),up=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=this._scene.canvas.canvas;o.addEventListener("mouseenter",this._mouseEnterHandler=function(){s.mouseover=!0}),o.addEventListener("mouseleave",this._mouseLeaveHandler=function(){s.mouseover=!1,o.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=function(e){Ap(e,o,s.pointerCanvasPos)}),o.addEventListener("mousedown",this._mouseDownHandler=function(e){r.active&&r.pointerEnabled&&(Ap(e,o,s.pointerCanvasPos),s.mouseover=!0)}),o.addEventListener("mouseup",this._mouseUpHandler=function(e){r.active&&r.pointerEnabled})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;document.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("mouseleave",this._mouseLeaveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler)}}]),e}();function Ap(e,t,i){if(e){var r=t.getBoundingClientRect(),s=r.left,n=r.top;i[0]=e.clientX-s,i[1]=e.clientY-n}else e=window.event,i[0]=e.x,i[1]=e.y;return i}var cp=function(e,t){if(e){for(var i=e.target,r=0,s=0;i.offsetParent;)r+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-r,t[1]=e.pageY-s}else e=window.event,t[0]=e.x,t[1]=e.y;return t},hp=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o=i.pickController,a=i.pivotController,l=re.vec2(),u=re.vec2(),A=re.vec2(),c=re.vec2(),h=[],d=this._scene.canvas.canvas,p=0,f=!1;this._onTick=t.on("tick",(function(){f=!1})),d.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(r.active&&r.pointerEnabled){e.preventDefault();var i=e.touches,n=e.changedTouches;for(s.touchStartTime=Date.now(),1===i.length&&1===n.length&&(cp(i[0],l),r.followPointer&&(o.pickCursorPos=l,o.schedulePickSurface=!0,o.update(),r.planView||(o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(a.setPivotPos(o.pickResult.worldPos),!r.firstPerson&&a.startPivot()&&a.showPivot()):(r.smartPivot?a.setCanvasPivotPos(s.pointerCanvasPos):a.setPivotPos(t.camera.look),!r.firstPerson&&a.startPivot()&&a.showPivot()))));h.length<i.length;)h.push(re.vec2());for(var u=0,A=i.length;u<A;++u)cp(i[u],h[u]);p=i.length}}),d.addEventListener("touchend",this._canvasTouchEndHandler=function(){a.getPivoting()&&a.endPivot()}),d.addEventListener("touchmove",this._canvasTouchMoveHandler=function(e){if(r.active&&r.pointerEnabled&&(e.stopPropagation(),e.preventDefault(),!f)){f=!0;var i=t.canvas.boundary,a=i[2],l=i[3],d=e.touches;if(e.touches.length===p){if(1===p){cp(d[0],u),re.subVec2(u,h[0],c);var v=c[0],g=c[1];if(null!==s.longTouchTimeout&&(Math.abs(v)>r.longTapRadius||Math.abs(g)>r.longTapRadius)&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),r.planView){var m=t.camera;if("perspective"===m.projection){var _=Math.abs(t.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);n.panDeltaX+=v*_/l*r.touchPanRate,n.panDeltaY+=g*_/l*r.touchPanRate}else n.panDeltaX+=.5*m.ortho.scale*(v/l)*r.touchPanRate,n.panDeltaY+=.5*m.ortho.scale*(g/l)*r.touchPanRate}else n.rotateDeltaY-=v/a*(1*r.dragRotationRate),n.rotateDeltaX+=g/l*(1.5*r.dragRotationRate)}else if(2===p){var y=d[0],b=d[1];cp(y,u),cp(b,A);var w=re.geometricMeanVec2(h[0],h[1]),B=re.geometricMeanVec2(u,A),x=re.vec2();re.subVec2(w,B,x);var P=x[0],C=x[1],M=t.camera,E=re.distVec2([y.pageX,y.pageY],[b.pageX,b.pageY]),F=(re.distVec2(h[0],h[1])-E)*r.touchDollyRate;if(n.dollyDelta=F,Math.abs(F)<1)if("perspective"===M.projection){var k=o.pickResult?o.pickResult.worldPos:t.center,I=Math.abs(re.lenVec3(re.subVec3(k,t.camera.eye,[])))*Math.tan(M.perspective.fov/2*Math.PI/180);n.panDeltaX-=P*I/l*r.touchPanRate,n.panDeltaY-=C*I/l*r.touchPanRate}else n.panDeltaX-=.5*M.ortho.scale*(P/l)*r.touchPanRate,n.panDeltaY-=.5*M.ortho.scale*(C/l)*r.touchPanRate;s.pointerCanvasPos=B}for(var D=0;D<p;++D)cp(d[D],h[D])}}})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("touchstart",this._canvasTouchStartHandler),e.removeEventListener("touchend",this._canvasTouchEndHandler),e.removeEventListener("touchmove",this._canvasTouchMoveHandler),this._scene.off(this._onTick)}}]),e}(),dp=function(e,t){if(e){for(var i=e.target,r=0,s=0;i.offsetParent;)r+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-r,t[1]=e.pageY-s}else e=window.event,t[0]=e.x,t[1]=e.y;return t},pp=function(){function e(t,i,r,s,n){x(this,e),this._scene=t;var o,a=i.pickController,l=i.cameraControl,u=[],A=new Float32Array(2),c=-1,h=-1,d=this._scene.canvas.canvas,p=function(e){var r;e&&e.worldPos&&(r=e.worldPos);var s=e?e.entity.aabb:t.aabb;if(r){var n=t.camera;re.subVec3(n.eye,n.look,[]),i.cameraFlight.flyTo({aabb:s})}else i.cameraFlight.flyTo({aabb:s})};d.addEventListener("touchstart",this._canvasTouchStartHandler=function(e){if(r.active&&r.pointerEnabled){null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null);var t=e.touches,n=e.changedTouches;if(o=Date.now(),1===t.length&&1===n.length){c=o,dp(t[0],A);var a=A[0],l=A[1],h=t[0].pageX,d=t[0].pageY;s.longTouchTimeout=setTimeout((function(){i.cameraControl.fire("rightClick",{pagePos:[Math.round(h),Math.round(d)],canvasPos:[Math.round(a),Math.round(l)],event:e},!0),s.longTouchTimeout=null}),r.longTapTimeout)}else c=-1;for(;u.length<t.length;)u.push(new Float32Array(2));for(var p=0,f=t.length;p<f;++p)dp(t[p],u[p]);u.length=t.length}},{passive:!0}),d.addEventListener("touchend",this._canvasTouchEndHandler=function(e){if(r.active&&r.pointerEnabled){var t=Date.now(),i=e.touches,n=e.changedTouches,o=l.hasSubs("pickedSurface");null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),0===i.length&&1===n.length&&c>-1&&t-c<150&&(h>-1&&c-h<325?(dp(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("doublePicked",a.pickResult),a.pickedSurface&&l.fire("doublePickedSurface",a.pickResult),r.doublePickFlyTo&&p(a.pickResult)):(l.fire("doublePickedNothing"),r.doublePickFlyTo&&p()),h=-1):re.distVec2(u[0],A)<4&&(dp(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("picked",a.pickResult),a.pickedSurface&&l.fire("pickedSurface",a.pickResult)):l.fire("pickedNothing"),h=t),c=-1),u.length=i.length;for(var d=0,f=i.length;d<f;++d)u[d][0]=i[d].pageX,u[d][1]=i[d].pageY}},{passive:!0})}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("touchstart",this._canvasTouchStartHandler),e.removeEventListener("touchend",this._canvasTouchEndHandler)}}]),e}(),fp=function(e){g(i,Ce);var t=_(i);function i(e){var r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(r=t.call(this,e,s)).PAN_LEFT=0,r.PAN_RIGHT=1,r.PAN_UP=2,r.PAN_DOWN=3,r.PAN_FORWARDS=4,r.PAN_BACKWARDS=5,r.ROTATE_X_POS=6,r.ROTATE_X_NEG=7,r.ROTATE_Y_POS=8,r.ROTATE_Y_NEG=9,r.DOLLY_FORWARDS=10,r.DOLLY_BACKWARDS=11,r.AXIS_VIEW_RIGHT=12,r.AXIS_VIEW_BACK=13,r.AXIS_VIEW_LEFT=14,r.AXIS_VIEW_FRONT=15,r.AXIS_VIEW_TOP=16,r.AXIS_VIEW_BOTTOM=17,r._keyMap={},r.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},r._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:30,keyboardEnabledOnlyIfMouseover:!0,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},r._states={pointerCanvasPos:re.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:re.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},r._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};var n=r.scene;return r._controllers={cameraControl:b(r),pickController:new Yd(b(r),r._configs),pivotController:new Xd(n,r._configs),panController:new Vd(n),cameraFlight:new ld(b(r),{duration:.5})},r._handlers=[new up(r.scene,r._controllers,r._configs,r._states,r._updates),new hp(r.scene,r._controllers,r._configs,r._states,r._updates),new Zd(r.scene,r._controllers,r._configs,r._states,r._updates),new sp(r.scene,r._controllers,r._configs,r._states,r._updates),new np(r.scene,r._controllers,r._configs,r._states,r._updates),new pp(r.scene,r._controllers,r._configs,r._states,r._updates),new op(r.scene,r._controllers,r._configs,r._states,r._updates)],r._cameraUpdater=new lp(r.scene,r._controllers,r._configs,r._states,r._updates),r.navMode=s.navMode,s.planView&&(r.planView=s.planView),r.constrainVertical=s.constrainVertical,s.keyboardLayout?r.keyboardLayout=s.keyboardLayout:r.keyMap=s.keyMap,r.doublePickFlyTo=s.doublePickFlyTo,r.panRightClick=s.panRightClick,r.active=s.active,r.followPointer=s.followPointer,r.rotationInertia=s.rotationInertia,r.keyboardPanRate=s.keyboardPanRate,r.touchPanRate=s.touchPanRate,r.keyboardRotationRate=s.keyboardRotationRate,r.dragRotationRate=s.dragRotationRate,r.touchDollyRate=s.touchDollyRate,r.dollyInertia=s.dollyInertia,r.dollyProximityThreshold=s.dollyProximityThreshold,r.dollyMinSpeed=s.dollyMinSpeed,r.panInertia=s.panInertia,r.pointerEnabled=!0,r.keyboardDollyRate=s.keyboardDollyRate,r.mouseWheelDollyRate=s.mouseWheelDollyRate,r}return C(i,[{key:"keyMap",get:function(){return this._keyMap},set:function(e){if(e=e||"qwerty",he.isString(e)){var t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{var r=e;this._keyMap=r}}},{key:"_isKeyDownForAction",value:function(e,t){var i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(var r=0,s=i.length;r<s;r++){if(t[i[r]])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||30,this._configs.snapRadius=e}},{key:"keyboardEnabledOnlyIfMouseover",get:function(){return this._configs.keyboardEnabledOnlyIfMouseover},set:function(e){this._configs.keyboardEnabledOnlyIfMouseover=!!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,t=this._handlers.length;e<t;e++){var i=this._handlers[e];i.reset&&i.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.warn("planView property is deprecated - replaced with navMode"),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(),f(w(i.prototype),"destroy",this).call(this)}},{key:"_destroyHandlers",value:function(){for(var e=0,t=this._handlers.length;e<t;e++){var i=this._handlers[e];i.destroy&&i.destroy()}}},{key:"_destroyControllers",value:function(){for(var e=0,t=this._controllers.length;e<t;e++){var i=this._controllers[e];i.destroy&&i.destroy()}}}]),i}(),vp=C((function e(t,i,r,s,n){x(this,e),this.name=t,this.type=r,this.value=i,this.valueType=s,this.description=n})),gp=C((function e(t){if(x(this,e),this.id=t.id,this.originalSystemId=t.originalSystemId,this.metaModels=[],this.name=t.name,this.type=t.type,this.properties=[],t.properties)for(var i=t.properties,r=0,s=i.length;r<s;r++){var n=i[r];Number.isInteger(n)?this.properties.push(n):this.properties.push(new vp(n.name,n.value,n.type,n.valueType,n.description))}})),mp=function(){function e(t){x(this,e),this.metaModels=[],this.id=t.id,this.parentId=t.parentId,this.parent=null,this.originalSystemId=t.originalSystemId,this.name=t.name,this.type=t.type,this.propertySetIds=t.propertySetIds,this.propertySets=[],this.attributes=t.attributes||{},void 0!==t.external&&null!==t.external&&(this.external=t.external)}return C(e,[{key:"metaModel",get:function(){return 1==this.metaModels.length?this.metaModels[0]:null}},{key:"getObjectIDsInSubtree",value:function(){var e=[];return function t(i){if(i){e.push(i.id);var r=i.children;if(r)for(var s=0,n=r.length;s<n;s++)t(r[s])}}(this),e}},{key:"withMetaObjectsInSubtree",value:function(e){!function t(i){if(i){e(i);var r=i.children;if(r)for(var s=0,n=r.length;s<n;s++)t(r[s])}}(this)}},{key:"getObjectIDsInSubtreeByType",value:function(e){for(var t={},i=0,r=e.length;i<r;i++)t[e[i]]=e[i];var s=[];return function e(i){if(i){t[i.type]&&s.push(i.id);var r=i.children;if(r)for(var n=0,o=r.length;n<o;n++)e(r[n])}}(this),s}},{key:"getJSON",value:function(){var e={id:this.id,type:this.type,name:this.name};return this.parent&&(e.parent=this.parent.id),e}}]),e}(),_p=function(){function e(t){x(this,e),this.id=t.id,this.projectId=t.projectId,this.revisionId=t.revisionId,this.author=t.author,this.createdAt=t.createdAt,this.creatingApplication=t.creatingApplication,this.schema=t.schema,this.metaScene=t.metaScene,this.propertySets=[],this.rootMetaObjects=[],this.metaObjects=[],this.graph=t.graph||{},this.metaScene.metaModels[this.id]=this,this._propertyLookup=[],this.finalized=!1}return C(e,[{key:"rootMetaObject",get:function(){return 1===this.rootMetaObjects.length?this.rootMetaObjects[0]:null}},{key:"loadData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.finalized)throw"MetaScene already finalized - can't add more data";this._globalizeIDs(e,t);var i=this.metaScene,r=e.properties;if(r)for(var s=0,n=r.length;s<n;s++)this._propertyLookup.push(r[s]);if(e.propertySets)for(var o=0,a=e.propertySets.length;o<a;o++){var l=e.propertySets[o];l.properties||(l.properties=[]);var u=i.propertySets[l.id];u||(u=new gp({id:l.id,originalSystemId:l.originalSystemId||l.id,type:l.type,name:l.name,properties:l.properties}),i.propertySets[u.id]=u),u.metaModels.push(this),this.propertySets.push(u)}if(e.metaObjects)for(var A=0,c=e.metaObjects.length;A<c;A++){var h=e.metaObjects[A],d=h.id,p=i.metaObjects[d];if(!p){var f=h.type,v=h.originalSystemId,g=h.propertySets||h.propertySetIds;p=new mp({id:d,originalSystemId:v,parentId:h.parent,type:f,name:h.name,attributes:h.attributes,propertySetIds:g,external:h.external}),this.metaScene.metaObjects[d]=p,p.metaModels=[]}this.metaObjects.push(p),h.parent||(this.rootMetaObjects.push(p),i.rootMetaObjects[d]=p)}}},{key:"_decompressProperties",value:function(e,t){for(var i=[],r=0,s=t.length;r<s;r++){var n=t[r];if(Number.isInteger(n)){var o=e[n];o?t[r]=o:i.push(n)}}i.length>0&&console.error("[MetaModel._decompressProperties] Properties not found: ".concat(i))}},{key:"finalize",value:function(){if(this.finalized)throw"MetaScene already finalized - can't re-finalize";var e=this.metaScene;for(var t in e.metaObjects){var i=e.metaObjects[t];if(i.children&&(i.children=[]),i.propertySets&&(i.propertySets=[]),i.propertySetIds)for(var r=0,s=i.propertySetIds.length;r<s;r++){var n=i.propertySetIds[r],o=e.propertySets[n];i.propertySets.push(o)}}for(var a in e.metaObjects){var l=e.metaObjects[a];if(l.parentId){var u=e.metaObjects[l.parentId];u&&(l.parent=u,(u.children||(u.children=[])).push(l))}}for(var A in e.metaObjects){e.metaObjects[A].metaModels=[]}for(var c in e.metaModels)for(var h=e.metaModels[c],d=0,p=h.metaObjects.length;d<p;d++){h.metaObjects[d].metaModels.push(h)}for(var f in e.metaObjectsByType={},e.metaObjects){var v=e.metaObjects[f],g=v.type;(e.metaObjectsByType[g]||(e.metaObjectsByType[g]={}))[f]=v}if(this.propertySets)for(var m=0,_=this.propertySets.length;m<_;m++){var y=this.propertySets[m];this._decompressProperties(this._propertyLookup,y.properties)}this._propertyLookup=[],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:[]},t=0,i=this.metaObjects.length;t<i;t++){var r=this.metaObjects[t],s={id:r.id,originalSystemId:r.originalSystemId,extId:r.extId,type:r.type,name:r.name};r.parent&&(s.parent=r.parent.id),r.attributes&&(s.attributes=r.attributes),r.propertySetIds&&(s.propertySetIds=r.propertySetIds),e.metaObjects.push(s)}for(var n=0,o=this.propertySets.length;n<o;n++){for(var a=this.propertySets[n],l={id:a.id,originalSystemId:a.originalSystemId,extId:a.extId,type:a.type,name:a.name,propertyies:[]},u=0,A=a.properties.length;u<A;u++){var c=a.properties[u],h={id:c.id,description:c.description,type:c.type,name:c.name,value:c.value,valueType:c.valueType};l.properties.push(h)}e.propertySets.push(l)}return e}},{key:"_globalizeIDs",value:function(e,t){var i=!!t.globalizeObjectIds;if(e.metaObjects)for(var r=0,s=e.metaObjects.length;r<s;r++){var n=e.metaObjects[r];if(n.originalSystemId=n.id,n.parent&&(n.originalParentSystemId=n.parent),i&&(n.id=re.globalizeObjectId(this.id,n.id),n.parent&&(n.parent=re.globalizeObjectId(this.id,n.parent))),i){var o=n.propertySetIds;if(o){for(var a=[],l=0,u=o.length;l<u;l++)a.push(re.globalizeObjectId(this.id,o[l]));n.propertySetIds=a,n.originalSystemPropertySetIds=o}}else n.originalSystemPropertySetIds=n.propertySetIds}if(e.propertySets)for(var A=0,c=e.propertySets.length;A<c;A++){var h=e.propertySets[A];h.originalSystemId=h.id,i&&(h.id=re.globalizeObjectId(this.id,h.id))}}}]),e}(),yp=function(){function e(t,i){x(this,e),this.viewer=t,this.scene=i,this.metaModels={},this.propertySets={},this.metaObjects={},this.metaObjectsByType={},this.rootMetaObjects={},this._eventSubs={}}return C(e,[{key:"on",value:function(e,t){var i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}},{key:"fire",value:function(e,t){var i=this._eventSubs[e];if(i)for(var r=0,s=i.length;r<s;r++)i[r](t)}},{key:"off",value:function(e){}},{key:"createMetaModel",value:function(e,t){var i=new _p({metaScene:this,id:e,projectId:t.projectId||"none",revisionId:t.revisionId||"none",author:t.author||"none",createdAt:t.createdAt||"none",creatingApplication:t.creatingApplication||"none",schema:t.schema||"none",propertySets:[]});return i.loadData(t),i.finalize(),i}},{key:"destroyMetaModel",value:function(e){var t=this.metaModels[e];if(t){if(t.propertySets)for(var i=0,r=t.propertySets.length;i<r;i++){var s=t.propertySets[i];if(1===s.metaModels.length&&s.metaModels[0].id===e)delete this.propertySets[s.id];else{for(var n=[],o=0,a=s.metaModels.length;o<a;o++)s.metaModels[o].id!==e&&n.push(s.metaModels[o]);s.metaModels=n}}if(t.metaObjects)for(var l=0,u=t.metaObjects.length;l<u;l++){var A=t.metaObjects[l];A.type;var c=A.id;1===A.metaModels.length&&A.metaModels[0].id===e&&(delete this.metaObjects[c],A.parent||delete this.rootMetaObjects[c])}for(var h in this.metaObjects){var d=this.metaObjects[h];if(d.children&&(d.children=[]),d.propertySets&&(d.propertySets=[]),d.propertySetIds)for(var p=0,f=d.propertySetIds.length;p<f;p++){var v=d.propertySetIds[p],g=this.propertySets[v];d.propertySets.push(g)}}for(var m in this.metaObjectsByType={},this.metaObjects){var _=this.metaObjects[m],y=_.type;_.children&&(_.children=null),(this.metaObjectsByType[y]||(this.metaObjectsByType[y]={}))[m]=_}for(var b in this.metaObjects){var w=this.metaObjects[b];if(w.parentId){var B=this.metaObjects[w.parentId];B&&(w.parent=B,(B.children||(B.children=[])).push(w))}}for(var x in delete this.metaModels[e],this.metaObjects){this.metaObjects[x].metaModels=[]}for(var P in this.metaModels)for(var C=this.metaModels[P],M=0,E=C.metaObjects.length;M<E;M++){C.metaObjects[M].metaModels.push(C)}this.fire("metaModelDestroyed",e)}}},{key:"getObjectIDsByType",value:function(e){var t=this.metaObjectsByType[e];return t?Object.keys(t):[]}},{key:"getObjectIDsInSubtree",value:function(e,t,i){var r=[],s=this.metaObjects[e],n=t&&t.length>0?bp(t):null,o=i&&i.length>0?bp(i):null;return function e(t){if(t){var i=!0;(o&&o[t.type]||n&&!n[t.type])&&(i=!1),i&&r.push(t.id);var s=t.children;if(s)for(var a=0,l=s.length;a<l;a++)e(s[a])}}(s),r}},{key:"withMetaObjectsInSubtree",value:function(e,t){var i=this.metaObjects[e];i&&i.withMetaObjectsInSubtree(t)}}]),e}();function bp(e){for(var t={},i=0,r=e.length;i<r;i++)t[e[i]]=!0;return t}
|
|
18
18
|
/*!
|
|
19
19
|
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
20
20
|
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|