@xeokit/xeokit-sdk 2.6.32 → 2.6.34
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 +86 -25
- package/dist/xeokit-sdk.es.js +86 -25
- package/dist/xeokit-sdk.es5.js +33 -12
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +4 -4
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/extras/PointerLens/PointerLens.js +14 -6
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +59 -9
- package/src/viewer/scene/math/MeshVolume.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +3 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +9 -7
- package/types/extras/ContextMenu/ContextMenu.d.ts +2 -0
- package/types/extras/PointerLens/PointerLens.d.ts +47 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +18 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +12 -0
- package/types/plugins/DistanceMeasurementsPlugin/index.d.ts +1 -0
- package/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +4 -0
- package/types/plugins/NavCubePlugin/NavCubePlugin.d.ts +7 -7
- package/types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts +19 -0
- package/types/viewer/scene/scene/Scene.d.ts +23 -0
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -387,11 +387,11 @@ menuElement.style.display='block';var menuHeight=menuElement.offsetHeight;var me
|
|
|
387
387
|
* @param viewer The Viewer
|
|
388
388
|
* @param [cfg] PointerLens configuration.
|
|
389
389
|
* @param [cfg.active=true] Whether PointerLens is active. The PointerLens can only be shown when this is `true` (default).
|
|
390
|
-
*/function PointerLens(viewer){var _this6=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointerLens);this.viewer=viewer;this.scene=this.viewer.scene;this._lensCursorDiv=document.createElement('div');this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._lensCursorDiv,this.viewer.scene.canvas.canvas);this._lensCursorDiv.style.background="pink";this._lensCursorDiv.style.border="2px solid red";this._lensCursorDiv.style.borderRadius="20px";this._lensCursorDiv.style.width="10px";this._lensCursorDiv.style.height="10px";this._lensCursorDiv.style.margin="-200px -200px";this._lensCursorDiv.style.zIndex="100000";this._lensCursorDiv.style.position="absolute";this._lensCursorDiv.style.pointerEvents="none";this._lensContainer=document.createElement('div');this._lensContainer.style.border="1px solid black";this._lensContainer.style.background="white";// this._lensContainer.style.opacity = "0";
|
|
391
|
-
this._lensContainer.style.borderRadius="50%";this._lensContainer.style.width="300px";this._lensContainer.style.height="300px";this._lensContainer.style.
|
|
392
|
-
this._lensCanvas.style.borderRadius="50%";this._lensCanvas.style.width="300px";this._lensCanvas.style.height="300px";this._lensCanvas.style.zIndex="15000";this._lensCanvas.style.pointerEvents="none";document.body.appendChild(this._lensContainer);this._lensContainer.appendChild(this._lensCanvas);this._lensCanvasContext=this._lensCanvas.getContext('2d');this._canvasElement=this.viewer.scene.canvas.canvas;this._canvasPos=null;this._snappedCanvasPos=null;this._lensPosToggle=true;this._zoomLevel=cfg.zoomLevel||2;this._active=cfg.active!==false;this._visible=false;this._snapped=false;this._onViewerRendering=this.viewer.scene.on("rendering",function(){if(_this6._active&&_this6._visible){_this6.update();}});}/**
|
|
390
|
+
*/function PointerLens(viewer){var _this6=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointerLens);this.viewer=viewer;this.scene=this.viewer.scene;this._lensCursorDiv=document.createElement('div');this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._lensCursorDiv,this.viewer.scene.canvas.canvas);this._lensCursorDiv.style.background="pink";this._lensCursorDiv.style.border="2px solid red";this._lensCursorDiv.style.borderRadius="20px";this._lensCursorDiv.style.width="10px";this._lensCursorDiv.style.height="10px";this._lensCursorDiv.style.margin="-200px -200px";this._lensCursorDiv.style.zIndex="100000";this._lensCursorDiv.style.position="absolute";this._lensCursorDiv.style.pointerEvents="none";this._lensContainer=document.createElement('div');this._lensContainerId=cfg.containerId||'xeokit-lens';this._lensContainer.setAttribute("id",this._lensContainerId);this._lensContainer.style.border="1px solid black";this._lensContainer.style.background="white";// this._lensContainer.style.opacity = "0";
|
|
391
|
+
this._lensContainer.style.borderRadius="50%";this._lensContainer.style.width="300px";this._lensContainer.style.height="300px";this._lensContainer.style.zIndex="15000";this._lensContainer.style.position="absolute";this._lensContainer.style.pointerEvents="none";this._lensContainer.style.visibility="hidden";this._lensCanvas=document.createElement('canvas');this._lensCanvas.id="".concat(this._lensContainerId,"-canvas");// this._lensCanvas.style.background = "darkblue";
|
|
392
|
+
this._lensCanvas.style.borderRadius="50%";this._lensCanvas.style.width="300px";this._lensCanvas.style.height="300px";this._lensCanvas.style.zIndex="15000";this._lensCanvas.style.pointerEvents="none";document.body.appendChild(this._lensContainer);this._lensContainer.appendChild(this._lensCanvas);this._lensCanvasContext=this._lensCanvas.getContext('2d');this._canvasElement=this.viewer.scene.canvas.canvas;this._canvasPos=null;this._snappedCanvasPos=null;this._lensPosToggle=cfg.lensPosToggle||true;this._lensPosToggleAmount=cfg.lensPosToggleAmount||85;this._lensPosMarginLeft=cfg.lensPosMarginLeft||85;this._lensPosMarginTop=cfg.lensPosMarginTop||25;this._lensContainer.style.marginTop="".concat(this._lensPosMarginTop,"px");this._lensContainer.style.marginLeft="".concat(this._lensPosMarginLeft,"px");this._zoomLevel=cfg.zoomLevel||2;this._active=cfg.active!==false;this._visible=false;this._snapped=false;this._onViewerRendering=this.viewer.scene.on("rendering",function(){if(_this6._active&&_this6._visible){_this6.update();}});}/**
|
|
393
393
|
* Updates this PointerLens.
|
|
394
|
-
*/_createClass(PointerLens,[{key:"update",value:function update(){if(!this._active||!this._visible){return;}if(!this._canvasPos){return;}var lensRect=this._lensContainer.getBoundingClientRect();var canvasRect=this._canvasElement.getBoundingClientRect();var pointerOnLens=this._canvasPos[0]<lensRect.right&&this._canvasPos[0]>lensRect.left&&this._canvasPos[1]<lensRect.bottom&&this._canvasPos[1]>lensRect.top;this._lensContainer.style.marginLeft="
|
|
394
|
+
*/_createClass(PointerLens,[{key:"update",value:function update(){if(!this._active||!this._visible){return;}if(!this._canvasPos){return;}var lensRect=this._lensContainer.getBoundingClientRect();var canvasRect=this._canvasElement.getBoundingClientRect();var pointerOnLens=this._canvasPos[0]<lensRect.right&&this._canvasPos[0]>lensRect.left&&this._canvasPos[1]<lensRect.bottom&&this._canvasPos[1]>lensRect.top;this._lensContainer.style.marginLeft="".concat(this._lensPosMarginLeft,"px");if(pointerOnLens){if(this._lensPosToggle){this._lensContainer.style.marginTop="".concat(canvasRect.bottom-canvasRect.top-this._lensCanvas.height-this._lensPosToggleAmount,"px");}else{this._lensContainer.style.marginTop="".concat(this._lensPosMarginTop,"px");}this._lensPosToggle=!this._lensPosToggle;}this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);var size=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,// source canvas
|
|
395
395
|
this._canvasPos[0]-size/2,// source x (zoom center)
|
|
396
396
|
this._canvasPos[1]-size/2,// source y (zoom center)
|
|
397
397
|
size,// source width
|
|
@@ -14679,7 +14679,7 @@ return true;};var v1$1=math.vec3();var v2$1=math.vec3();var v3$1=math.vec3();/**
|
|
|
14679
14679
|
* The mesh must be a closed solid.
|
|
14680
14680
|
*
|
|
14681
14681
|
* @returns {number} The volume of the mesh, or -1 if the mesh is not solid, in which case volume cannot be determined.
|
|
14682
|
-
*/},{key:"volume",get:function get(){var vertices=this.vertices;var indices=this.indices;if(this.primitive!=="solid"&&this.primitive!=="surface"&&this.primitive!=="triangles"){return-1;}if(this.primitive!=="solid"&&!isTriangleMeshSolid(indices,vertices)){return-1;}var volume=0;for(var _i165=0;_i165<this.lenIndices;_i165+=3){var index1=indices[_i165]*3;var index2=indices[_i165+1]*3;var index3=indices[_i165+2]*3;v1$1[0]=vertices[index1];v1$1[1]=vertices[index1+1];v1$1[2]=vertices[index1+2];v2$1[0]=vertices[index2];v2$1[1]=vertices[index2+1];v2$1[2]=vertices[index2+2];v3$1[0]=vertices[index3];v3$1[1]=vertices[index3+1];v3$1[2]=vertices[index3+2];math.cross3Vec3(v1$1,v2$1,v1$1);volume+=math.dotVec3(v1$1,v3$1);}return volume;}}]);return MeshVolume;}();/**
|
|
14682
|
+
*/},{key:"volume",get:function get(){var vertices=this.vertices;var indices=this.indices;if(this.primitive!=="solid"&&this.primitive!=="surface"&&this.primitive!=="triangles"){return-1;}if(this.primitive!=="solid"&&!isTriangleMeshSolid(indices,vertices)){return-1;}var volume=0;for(var _i165=0;_i165<this.lenIndices;_i165+=3){var index1=indices[_i165]*3;var index2=indices[_i165+1]*3;var index3=indices[_i165+2]*3;v1$1[0]=vertices[index1];v1$1[1]=vertices[index1+1];v1$1[2]=vertices[index1+2];v2$1[0]=vertices[index2];v2$1[1]=vertices[index2+1];v2$1[2]=vertices[index2+2];v3$1[0]=vertices[index3];v3$1[1]=vertices[index3+1];v3$1[2]=vertices[index3+2];math.cross3Vec3(v1$1,v2$1,v1$1);volume+=math.dotVec3(v1$1,v3$1);}return volume/6;}}]);return MeshVolume;}();/**
|
|
14683
14683
|
* Singleton instance of {@link MeshVolume}.
|
|
14684
14684
|
* @type {MeshVolume}
|
|
14685
14685
|
*/var meshVolume=new MeshVolume();var v1=math.vec3();var v2=math.vec3();var v3=math.vec3();var v4=math.vec3();var v5=math.vec3();var v6=math.vec3();/**
|
|
@@ -15368,7 +15368,7 @@ var _notNormalized3=false;state.flagsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Flo
|
|
|
15368
15368
|
// state.normalsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, geometry.normalsCompressed, geometry.normalsCompressed.length, 3, gl.STATIC_DRAW, normalized);
|
|
15369
15369
|
// }
|
|
15370
15370
|
if(geometry.colorsCompressed&&geometry.colorsCompressed.length>0){var colorsCompressed=new Uint8Array(geometry.colorsCompressed);var _notNormalized5=false;state.colorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,colorsCompressed,colorsCompressed.length,4,gl.STATIC_DRAW,_notNormalized5);}if(geometry.uvCompressed&&geometry.uvCompressed.length>0){var uvCompressed=geometry.uvCompressed;state.uvDecodeMatrix=geometry.uvDecodeMatrix;state.uvBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,uvCompressed,uvCompressed.length,2,gl.STATIC_DRAW,false);}if(geometry.indices&&geometry.indices.length>0){state.indicesBuf=new ArrayBuf(gl,gl.ELEMENT_ARRAY_BUFFER,new Uint32Array(geometry.indices),geometry.indices.length,1,gl.STATIC_DRAW);state.numIndices=geometry.indices.length;}if(geometry.primitive==="triangles"||geometry.primitive==="solid"||geometry.primitive==="surface"){state.edgeIndicesBuf=new ArrayBuf(gl,gl.ELEMENT_ARRAY_BUFFER,new Uint32Array(geometry.edgeIndices),geometry.edgeIndices.length,1,gl.STATIC_DRAW);}if(this._modelMatrixCol0.length>0){var _normalized5=false;state.modelMatrixCol0Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol0),this._modelMatrixCol0.length,4,gl.STATIC_DRAW,_normalized5);state.modelMatrixCol1Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol1),this._modelMatrixCol1.length,4,gl.STATIC_DRAW,_normalized5);state.modelMatrixCol2Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol2),this._modelMatrixCol2.length,4,gl.STATIC_DRAW,_normalized5);this._modelMatrixCol0=[];this._modelMatrixCol1=[];this._modelMatrixCol2=[];if(state.normalsBuf){state.modelNormalMatrixCol0Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelNormalMatrixCol0),this._modelNormalMatrixCol0.length,4,gl.STATIC_DRAW,_normalized5);state.modelNormalMatrixCol1Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelNormalMatrixCol1),this._modelNormalMatrixCol1.length,4,gl.STATIC_DRAW,_normalized5);state.modelNormalMatrixCol2Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelNormalMatrixCol2),this._modelNormalMatrixCol2.length,4,gl.STATIC_DRAW,_normalized5);this._modelNormalMatrixCol0=[];this._modelNormalMatrixCol1=[];this._modelNormalMatrixCol2=[];}}if(this._pickColors.length>0){var _normalized6=false;state.pickColorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Uint8Array(this._pickColors),this._pickColors.length,4,gl.STATIC_DRAW,_normalized6);this._pickColors=[];// Release memory
|
|
15371
|
-
}state.pbrSupported=!!state.metallicRoughnessBuf&&!!state.uvBuf&&!!state.normalsBuf&&!!textureSet&&!!textureSet.colorTexture&&!!textureSet.metallicRoughnessTexture;state.colorTextureSupported=!!state.uvBuf&&!!textureSet&&!!textureSet.colorTexture;this._state.geometry=null;this._finalized=true;}// The following setters are called by VBOSceneModelMesh, in turn called by VBOSceneModelNode, only after the layer is finalized.
|
|
15371
|
+
}state.pbrSupported=!!state.metallicRoughnessBuf&&!!state.uvBuf&&!!state.normalsBuf&&!!textureSet&&!!textureSet.colorTexture&&!!textureSet.metallicRoughnessTexture;state.colorTextureSupported=!!state.uvBuf&&!!textureSet&&!!textureSet.colorTexture;if(!this.model.scene.readableGeometryEnabled){this._state.geometry=null;}this._finalized=true;}// The following setters are called by VBOSceneModelMesh, in turn called by VBOSceneModelNode, only after the layer is finalized.
|
|
15372
15372
|
// It's important that these are called after finalize() in order to maintain integrity of counts like _numVisibleLayerPortions etc.
|
|
15373
15373
|
},{key:"initFlags",value:function initFlags(portionId,flags,meshTransparent){if(flags&ENTITY_FLAGS.VISIBLE){this._numVisibleLayerPortions++;this.model.numVisibleLayerPortions++;}if(flags&ENTITY_FLAGS.HIGHLIGHTED){this._numHighlightedLayerPortions++;this.model.numHighlightedLayerPortions++;}if(flags&ENTITY_FLAGS.XRAYED){this._numXRayedLayerPortions++;this.model.numXRayedLayerPortions++;}if(flags&ENTITY_FLAGS.SELECTED){this._numSelectedLayerPortions++;this.model.numSelectedLayerPortions++;}if(flags&ENTITY_FLAGS.CLIPPABLE){this._numClippableLayerPortions++;this.model.numClippableLayerPortions++;}if(flags&ENTITY_FLAGS.EDGES){this._numEdgesLayerPortions++;this.model.numEdgesLayerPortions++;}if(flags&ENTITY_FLAGS.PICKABLE){this._numPickableLayerPortions++;this.model.numPickableLayerPortions++;}if(flags&ENTITY_FLAGS.CULLED){this._numCulledLayerPortions++;this.model.numCulledLayerPortions++;}if(meshTransparent){this._numTransparentLayerPortions++;this.model.numTransparentLayerPortions++;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setVisible",value:function setVisible(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.VISIBLE){this._numVisibleLayerPortions++;this.model.numVisibleLayerPortions++;}else{this._numVisibleLayerPortions--;this.model.numVisibleLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setHighlighted",value:function setHighlighted(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.HIGHLIGHTED){this._numHighlightedLayerPortions++;this.model.numHighlightedLayerPortions++;}else{this._numHighlightedLayerPortions--;this.model.numHighlightedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setXRayed",value:function setXRayed(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.XRAYED){this._numXRayedLayerPortions++;this.model.numXRayedLayerPortions++;}else{this._numXRayedLayerPortions--;this.model.numXRayedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setSelected",value:function setSelected(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.SELECTED){this._numSelectedLayerPortions++;this.model.numSelectedLayerPortions++;}else{this._numSelectedLayerPortions--;this.model.numSelectedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setEdges",value:function setEdges(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.EDGES){this._numEdgesLayerPortions++;this.model.numEdgesLayerPortions++;}else{this._numEdgesLayerPortions--;this.model.numEdgesLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setClippable",value:function setClippable(portionId,flags){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.CLIPPABLE){this._numClippableLayerPortions++;this.model.numClippableLayerPortions++;}else{this._numClippableLayerPortions--;this.model.numClippableLayerPortions--;}this._setFlags(portionId,flags);}},{key:"setCollidable",value:function setCollidable(portionId,flags){if(!this._finalized){throw"Not finalized";}}},{key:"setPickable",value:function setPickable(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.PICKABLE){this._numPickableLayerPortions++;this.model.numPickableLayerPortions++;}else{this._numPickableLayerPortions--;this.model.numPickableLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setCulled",value:function setCulled(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.CULLED){this._numCulledLayerPortions++;this.model.numCulledLayerPortions++;}else{this._numCulledLayerPortions--;this.model.numCulledLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setColor",value:function setColor(portionId,color){// RGBA color is normalized as ints
|
|
15374
15374
|
if(!this._finalized){throw"Not finalized";}tempUint8Vec4$2[0]=color[0];tempUint8Vec4$2[1]=color[1];tempUint8Vec4$2[2]=color[2];tempUint8Vec4$2[3]=color[3];if(this._state.colorsBuf){this._state.colorsBuf.setData(tempUint8Vec4$2,portionId*4);}}},{key:"setTransparent",value:function setTransparent(portionId,flags,transparent){if(transparent){this._numTransparentLayerPortions++;this.model.numTransparentLayerPortions++;}else{this._numTransparentLayerPortions--;this.model.numTransparentLayerPortions--;}this._setFlags(portionId,flags,transparent);}// setMatrix(portionId, matrix) {
|
|
@@ -15403,7 +15403,7 @@ if(!this._finalized){throw"Not finalized";}tempUint8Vec4$2[0]=color[0];tempUint8
|
|
|
15403
15403
|
/**
|
|
15404
15404
|
* flags are 4bits values encoded on a 32bit base. color flag on the first 4 bits, silhouette flag on the next 4 bits and so on for edge, pick and clippable.
|
|
15405
15405
|
*/},{key:"_setFlags",value:function _setFlags(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}var visible=!!(flags&ENTITY_FLAGS.VISIBLE);var xrayed=!!(flags&ENTITY_FLAGS.XRAYED);var highlighted=!!(flags&ENTITY_FLAGS.HIGHLIGHTED);var selected=!!(flags&ENTITY_FLAGS.SELECTED);var edges=!!(flags&ENTITY_FLAGS.EDGES);var pickable=!!(flags&ENTITY_FLAGS.PICKABLE);var culled=!!(flags&ENTITY_FLAGS.CULLED);var colorFlag;if(!visible||culled||xrayed||highlighted&&!this.model.scene.highlightMaterial.glowThrough||selected&&!this.model.scene.selectedMaterial.glowThrough){colorFlag=RENDER_PASSES.NOT_RENDERED;}else{if(meshTransparent){colorFlag=RENDER_PASSES.COLOR_TRANSPARENT;}else{colorFlag=RENDER_PASSES.COLOR_OPAQUE;}}var silhouetteFlag;if(!visible||culled){silhouetteFlag=RENDER_PASSES.NOT_RENDERED;}else if(selected){silhouetteFlag=RENDER_PASSES.SILHOUETTE_SELECTED;}else if(highlighted){silhouetteFlag=RENDER_PASSES.SILHOUETTE_HIGHLIGHTED;}else if(xrayed){silhouetteFlag=RENDER_PASSES.SILHOUETTE_XRAYED;}else{silhouetteFlag=RENDER_PASSES.NOT_RENDERED;}var edgeFlag=0;if(!visible||culled){edgeFlag=RENDER_PASSES.NOT_RENDERED;}else if(selected){edgeFlag=RENDER_PASSES.EDGES_SELECTED;}else if(highlighted){edgeFlag=RENDER_PASSES.EDGES_HIGHLIGHTED;}else if(xrayed){edgeFlag=RENDER_PASSES.EDGES_XRAYED;}else if(edges){if(meshTransparent){edgeFlag=RENDER_PASSES.EDGES_COLOR_TRANSPARENT;}else{edgeFlag=RENDER_PASSES.EDGES_COLOR_OPAQUE;}}else{edgeFlag=RENDER_PASSES.NOT_RENDERED;}var pickFlag=visible&&!culled&&pickable?RENDER_PASSES.PICK:RENDER_PASSES.NOT_RENDERED;var clippableFlag=!!(flags&ENTITY_FLAGS.CLIPPABLE)?1:0;var vertFlag=0;vertFlag|=colorFlag;vertFlag|=silhouetteFlag<<4;vertFlag|=edgeFlag<<8;vertFlag|=pickFlag<<12;vertFlag|=clippableFlag<<16;tempFloat32$2[0]=vertFlag;if(this._state.flagsBuf){this._state.flagsBuf.setData(tempFloat32$2,portionId);}}},{key:"setOffset",value:function setOffset(portionId,offset){if(!this._finalized){throw"Not finalized";}if(!this.model.scene.entityOffsetsEnabled){this.model.error("Entity#offset not enabled for this Viewer");// See Viewer entityOffsetsEnabled
|
|
15406
|
-
return;}tempVec3fa$2[0]=offset[0];tempVec3fa$2[1]=offset[1];tempVec3fa$2[2]=offset[2];if(this._state.offsetsBuf){this._state.offsetsBuf.setData(tempVec3fa$2,portionId*3);}}},{key:"getEachVertex",value:function getEachVertex(portionId,callback){if(!this.model.scene.readableGeometryEnabled){return false;}var state=this._state;var geometry=state.geometry;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return;}var positions=geometry.
|
|
15406
|
+
return;}tempVec3fa$2[0]=offset[0];tempVec3fa$2[1]=offset[1];tempVec3fa$2[2]=offset[2];if(this._state.offsetsBuf){this._state.offsetsBuf.setData(tempVec3fa$2,portionId*3);}}},{key:"getEachVertex",value:function getEachVertex(portionId,callback){if(!this.model.scene.readableGeometryEnabled){return false;}var state=this._state;var geometry=state.geometry;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return;}var positions=geometry.positionsCompressed;var origin=state.origin;var offsetX=origin[0];var offsetY=origin[1];var offsetZ=origin[2];var worldPos=tempVec4a$7;var portionMatrix=portion.matrix;var sceneModelMatrix=this.model.matrix;var positionsDecodeMatrix=state.positionsDecodeMatrix;for(var _i260=0,len=positions.length;_i260<len;_i260+=3){worldPos[0]=positions[_i260];worldPos[1]=positions[_i260+1];worldPos[2]=positions[_i260+2];math.decompressPosition(worldPos,positionsDecodeMatrix);math.transformPoint3(portionMatrix,worldPos);math.transformPoint3(sceneModelMatrix,worldPos);worldPos[0]+=offsetX;worldPos[1]+=offsetY;worldPos[2]+=offsetZ;callback(worldPos);}}},{key:"getEachIndex",value:function getEachIndex(portionId,callback){if(!this.model.scene.readableGeometryEnabled){return false;}var state=this._state;var geometry=state.geometry;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return;}var indices=geometry.indices;for(var _i261=0,len=indices.length;_i261<len;_i261++){callback(indices[_i261]);}}},{key:"setMatrix",value:function setMatrix(portionId,matrix){if(!this._finalized){throw"Not finalized";}////////////////////////////////////////
|
|
15407
15407
|
// TODO: Update portion matrix
|
|
15408
15408
|
////////////////////////////////////////
|
|
15409
15409
|
var offset=portionId*4;tempFloat32Vec4$2[0]=matrix[0];tempFloat32Vec4$2[1]=matrix[4];tempFloat32Vec4$2[2]=matrix[8];tempFloat32Vec4$2[3]=matrix[12];this._state.modelMatrixCol0Buf.setData(tempFloat32Vec4$2,offset);tempFloat32Vec4$2[0]=matrix[1];tempFloat32Vec4$2[1]=matrix[5];tempFloat32Vec4$2[2]=matrix[9];tempFloat32Vec4$2[3]=matrix[13];this._state.modelMatrixCol1Buf.setData(tempFloat32Vec4$2,offset);tempFloat32Vec4$2[0]=matrix[2];tempFloat32Vec4$2[1]=matrix[6];tempFloat32Vec4$2[2]=matrix[10];tempFloat32Vec4$2[3]=matrix[14];this._state.modelMatrixCol2Buf.setData(tempFloat32Vec4$2,offset);}// ---------------------- COLOR RENDERING -----------------------------------
|
|
@@ -15635,7 +15635,7 @@ var g=color[1];var b=color[2];color[3];this._colors.push(r);this._colors.push(g)
|
|
|
15635
15635
|
}if(flagsLength>0){// Because we only build flags arrays here,
|
|
15636
15636
|
// get their length from the colors array
|
|
15637
15637
|
var _notNormalized6=false;this._state.flagsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(flagsLength),flagsLength,1,gl.DYNAMIC_DRAW,_notNormalized6);}if(this.model.scene.entityOffsetsEnabled){if(this._offsets.length>0){var _notNormalized7=false;this._state.offsetsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._offsets),this._offsets.length,3,gl.DYNAMIC_DRAW,_notNormalized7);this._offsets=[];// Release memory
|
|
15638
|
-
}}if(geometry.colorsCompressed&&geometry.colorsCompressed.length>0){var colorsCompressed=new Uint8Array(geometry.colorsCompressed);var _notNormalized8=false;state.colorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,colorsCompressed,colorsCompressed.length,4,gl.STATIC_DRAW,_notNormalized8);}if(geometry.positionsCompressed&&geometry.positionsCompressed.length>0){var normalized=false;state.positionsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,geometry.positionsCompressed,geometry.positionsCompressed.length,3,gl.STATIC_DRAW,normalized);state.positionsDecodeMatrix=math.mat4(geometry.positionsDecodeMatrix);}if(geometry.indices&&geometry.indices.length>0){state.indicesBuf=new ArrayBuf(gl,gl.ELEMENT_ARRAY_BUFFER,new Uint32Array(geometry.indices),geometry.indices.length,1,gl.STATIC_DRAW);state.numIndices=geometry.indices.length;}if(this._modelMatrixCol0.length>0){var _normalized7=false;this._state.modelMatrixCol0Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol0),this._modelMatrixCol0.length,4,gl.STATIC_DRAW,_normalized7);this._state.modelMatrixCol1Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol1),this._modelMatrixCol1.length,4,gl.STATIC_DRAW,_normalized7);this._state.modelMatrixCol2Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol2),this._modelMatrixCol2.length,4,gl.STATIC_DRAW,_normalized7);this._modelMatrixCol0=[];this._modelMatrixCol1=[];this._modelMatrixCol2=[];}this._state.geometry=null;this._finalized=true;}// The following setters are called by VBOSceneModelMesh, in turn called by VBOSceneModelNode, only after the layer is finalized.
|
|
15638
|
+
}}if(geometry.colorsCompressed&&geometry.colorsCompressed.length>0){var colorsCompressed=new Uint8Array(geometry.colorsCompressed);var _notNormalized8=false;state.colorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,colorsCompressed,colorsCompressed.length,4,gl.STATIC_DRAW,_notNormalized8);}if(geometry.positionsCompressed&&geometry.positionsCompressed.length>0){var normalized=false;state.positionsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,geometry.positionsCompressed,geometry.positionsCompressed.length,3,gl.STATIC_DRAW,normalized);state.positionsDecodeMatrix=math.mat4(geometry.positionsDecodeMatrix);}if(geometry.indices&&geometry.indices.length>0){state.indicesBuf=new ArrayBuf(gl,gl.ELEMENT_ARRAY_BUFFER,new Uint32Array(geometry.indices),geometry.indices.length,1,gl.STATIC_DRAW);state.numIndices=geometry.indices.length;}if(this._modelMatrixCol0.length>0){var _normalized7=false;this._state.modelMatrixCol0Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol0),this._modelMatrixCol0.length,4,gl.STATIC_DRAW,_normalized7);this._state.modelMatrixCol1Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol1),this._modelMatrixCol1.length,4,gl.STATIC_DRAW,_normalized7);this._state.modelMatrixCol2Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol2),this._modelMatrixCol2.length,4,gl.STATIC_DRAW,_normalized7);this._modelMatrixCol0=[];this._modelMatrixCol1=[];this._modelMatrixCol2=[];}if(!this.model.scene.readableGeometryEnabled){this._state.geometry=null;}this._finalized=true;}// The following setters are called by VBOSceneModelMesh, in turn called by VBOSceneModelNode, only after the layer is finalized.
|
|
15639
15639
|
// It's important that these are called after finalize() in order to maintain integrity of counts like _numVisibleLayerPortions etc.
|
|
15640
15640
|
},{key:"initFlags",value:function initFlags(portionId,flags,meshTransparent){if(flags&ENTITY_FLAGS.VISIBLE){this._numVisibleLayerPortions++;this.model.numVisibleLayerPortions++;}if(flags&ENTITY_FLAGS.HIGHLIGHTED){this._numHighlightedLayerPortions++;this.model.numHighlightedLayerPortions++;}if(flags&ENTITY_FLAGS.XRAYED){this._numXRayedLayerPortions++;this.model.numXRayedLayerPortions++;}if(flags&ENTITY_FLAGS.SELECTED){this._numSelectedLayerPortions++;this.model.numSelectedLayerPortions++;}if(flags&ENTITY_FLAGS.CLIPPABLE){this._numClippableLayerPortions++;this.model.numClippableLayerPortions++;}if(flags&ENTITY_FLAGS.EDGES){this._numEdgesLayerPortions++;this.model.numEdgesLayerPortions++;}if(flags&ENTITY_FLAGS.PICKABLE){this._numPickableLayerPortions++;this.model.numPickableLayerPortions++;}if(flags&ENTITY_FLAGS.CULLED){this._numCulledLayerPortions++;this.model.numCulledLayerPortions++;}if(meshTransparent){this._numTransparentLayerPortions++;this.model.numTransparentLayerPortions++;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setVisible",value:function setVisible(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.VISIBLE){this._numVisibleLayerPortions++;this.model.numVisibleLayerPortions++;}else{this._numVisibleLayerPortions--;this.model.numVisibleLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setHighlighted",value:function setHighlighted(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.HIGHLIGHTED){this._numHighlightedLayerPortions++;this.model.numHighlightedLayerPortions++;}else{this._numHighlightedLayerPortions--;this.model.numHighlightedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setXRayed",value:function setXRayed(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.XRAYED){this._numXRayedLayerPortions++;this.model.numXRayedLayerPortions++;}else{this._numXRayedLayerPortions--;this.model.numXRayedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setSelected",value:function setSelected(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.SELECTED){this._numSelectedLayerPortions++;this.model.numSelectedLayerPortions++;}else{this._numSelectedLayerPortions--;this.model.numSelectedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setEdges",value:function setEdges(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.EDGES){this._numEdgesLayerPortions++;this.model.numEdgesLayerPortions++;}else{this._numEdgesLayerPortions--;this.model.numEdgesLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setClippable",value:function setClippable(portionId,flags){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.CLIPPABLE){this._numClippableLayerPortions++;this.model.numClippableLayerPortions++;}else{this._numClippableLayerPortions--;this.model.numClippableLayerPortions--;}this._setFlags(portionId,flags);}},{key:"setCollidable",value:function setCollidable(portionId,flags){if(!this._finalized){throw"Not finalized";}}},{key:"setPickable",value:function setPickable(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.PICKABLE){this._numPickableLayerPortions++;this.model.numPickableLayerPortions++;}else{this._numPickableLayerPortions--;this.model.numPickableLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setCulled",value:function setCulled(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.CULLED){this._numCulledLayerPortions++;this.model.numCulledLayerPortions++;}else{this._numCulledLayerPortions--;this.model.numCulledLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setColor",value:function setColor(portionId,color){// RGBA color is normalized as ints
|
|
15641
15641
|
if(!this._finalized){throw"Not finalized";}tempUint8Vec4$1[0]=color[0];tempUint8Vec4$1[1]=color[1];tempUint8Vec4$1[2]=color[2];tempUint8Vec4$1[3]=color[3];this._state.colorsBuf.setData(tempUint8Vec4$1,portionId*4,4);}},{key:"setTransparent",value:function setTransparent(portionId,flags,transparent){if(transparent){this._numTransparentLayerPortions++;this.model.numTransparentLayerPortions++;}else{this._numTransparentLayerPortions--;this.model.numTransparentLayerPortions--;}this._setFlags(portionId,flags,transparent);}/**
|
|
@@ -19620,7 +19620,7 @@ var bitmap_data=e.bitmap_data;// base64
|
|
|
19620
19620
|
var location=xyzObjectToArray(e.location,tempVec3a$9);var normal=xyzObjectToArray(e.normal,tempVec3b$6);var up=xyzObjectToArray(e.up,tempVec3c$4);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this85._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this85._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.spaces_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"),true);}if(view_setup_hints.space_boundaries_visible!==undefined);if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}if(view_setup_hints.space_boundaries_translucent!==undefined);if(view_setup_hints.openings_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this85._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.translucency){scene.setObjectsXRayed(scene.xrayedObjectIds,false);bcfViewpoint.components.translucency.forEach(function(component){return _this85._withBCFComponent(options,component,function(entity){return entity.xrayed=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this85._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){entity.opacity=alpha;}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var up;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);up=ZToY(up);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
|
|
19621
19621
|
origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=up;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:up,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity2=scene.objects[originalSystemId];if(_entity2){callback(_entity2);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
|
|
19622
19622
|
* Destroys this BCFViewpointsPlugin.
|
|
19623
|
-
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var distVec3=math.vec3();var lengthWire=function lengthWire(x1,y1,x2,y2){var a=x1-x2;var b=y1-y2;return Math.sqrt(a*a+b*b);};function determineMeasurementOrientation(A,B,distance){var yDiff=Math.abs(B[1]-A[1]);return yDiff>distance?'Vertical':'Horizontal';}// function findDistance
|
|
19623
|
+
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var distVec3=math.vec3();var tmpVec3=math.vec3();var lengthWire=function lengthWire(x1,y1,x2,y2){var a=x1-x2;var b=y1-y2;return Math.sqrt(a*a+b*b);};function determineMeasurementOrientation(A,B,distance){var yDiff=Math.abs(B[1]-A[1]);return yDiff>distance?'Vertical':'Horizontal';}// function findDistance
|
|
19624
19624
|
/**
|
|
19625
19625
|
* @desc Measures the distance between two 3D points.
|
|
19626
19626
|
*
|
|
@@ -19637,10 +19637,31 @@ _this86._xAxisLabelCulled=false;_this86._yAxisLabelCulled=false;_this86._zAxisLa
|
|
|
19637
19637
|
});_this86._targetDot.on("worldPos",function(value){_this86._targetWorld.set(value||[0,0,0]);_this86._wpDirty=true;_this86._needUpdate(0);// No lag
|
|
19638
19638
|
});_this86._onViewMatrix=scene.camera.on("viewMatrix",function(){_this86._vpDirty=true;_this86._needUpdate(0);// No lag
|
|
19639
19639
|
});_this86._onProjMatrix=scene.camera.on("projMatrix",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onCanvasBoundary=scene.canvas.on("boundary",function(){_this86._cpDirty=true;_this86._needUpdate(0);// No lag
|
|
19640
|
-
});_this86._onMetricsUnits=scene.metrics.on("units",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onMetricsScale=scene.metrics.on("scale",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onMetricsOrigin=scene.metrics.on("origin",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onSectionPlaneUpdated=scene.on("sectionPlaneUpdated",function(){_this86._sectionPlanesDirty=true;_this86._needUpdate();});_this86.approximate=cfg.approximate;_this86.visible=cfg.visible;_this86.originVisible=cfg.originVisible;_this86.targetVisible=cfg.targetVisible;_this86.wireVisible=cfg.wireVisible;_this86.axisVisible=cfg.axisVisible;_this86.xAxisVisible=cfg.xAxisVisible;_this86.yAxisVisible=cfg.yAxisVisible;_this86.zAxisVisible=cfg.zAxisVisible;_this86.xLabelEnabled=cfg.xLabelEnabled;_this86.yLabelEnabled=cfg.yLabelEnabled;_this86.zLabelEnabled=cfg.zLabelEnabled;_this86.lengthLabelEnabled=cfg.lengthLabelEnabled;_this86.labelsVisible=cfg.labelsVisible;_this86.labelsOnWires=cfg.labelsOnWires;_this86.useRotationAdjustment=cfg.useRotationAdjustment
|
|
19640
|
+
});_this86._onMetricsUnits=scene.metrics.on("units",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onMetricsScale=scene.metrics.on("scale",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onMetricsOrigin=scene.metrics.on("origin",function(){_this86._cpDirty=true;_this86._needUpdate();});_this86._onSectionPlaneUpdated=scene.on("sectionPlaneUpdated",function(){_this86._sectionPlanesDirty=true;_this86._needUpdate();});_this86.approximate=cfg.approximate;_this86.visible=cfg.visible;_this86.originVisible=cfg.originVisible;_this86.targetVisible=cfg.targetVisible;_this86.wireVisible=cfg.wireVisible;_this86.axisVisible=cfg.axisVisible;_this86.xAxisVisible=cfg.xAxisVisible;_this86.yAxisVisible=cfg.yAxisVisible;_this86.zAxisVisible=cfg.zAxisVisible;_this86.xLabelEnabled=cfg.xLabelEnabled;_this86.yLabelEnabled=cfg.yLabelEnabled;_this86.zLabelEnabled=cfg.zLabelEnabled;_this86.lengthLabelEnabled=cfg.lengthLabelEnabled;_this86.labelsVisible=cfg.labelsVisible;_this86.labelsOnWires=cfg.labelsOnWires;_this86.useRotationAdjustment=cfg.useRotationAdjustment;/**
|
|
19641
|
+
* @type {number[]}
|
|
19642
|
+
*/_this86._axesBasis=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return _this86;}/**
|
|
19643
|
+
* Sets the axes basis for the measurement.
|
|
19644
|
+
*
|
|
19645
|
+
* The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
|
|
19646
|
+
*
|
|
19647
|
+
* This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
|
|
19648
|
+
*
|
|
19649
|
+
* @param {number[]} value
|
|
19650
|
+
*/_createClass(DistanceMeasurement,[{key:"axesBasis",get:/**
|
|
19651
|
+
* Gets the axes basis for the measurement.
|
|
19652
|
+
*
|
|
19653
|
+
* The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
|
|
19654
|
+
*
|
|
19655
|
+
* This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
|
|
19656
|
+
*
|
|
19657
|
+
* @type {number[]}
|
|
19658
|
+
*/function get(){return this._axesBasis;},set:function set(value){this._axesBasis=value.slice();this._wpDirty=true;this._needUpdate(0);// No lag
|
|
19659
|
+
}},{key:"_update",value:function _update(){if(!this._visible){return;}var scene=this.plugin.viewer.scene;if(this._wpDirty){this._measurementOrientation=determineMeasurementOrientation(this._originWorld,this._targetWorld,0);if(this._measurementOrientation==='Vertical'&&this.useRotationAdjustment){this._wp[0]=this._originWorld[0];this._wp[1]=this._originWorld[1];this._wp[2]=this._originWorld[2];this._wp[3]=1.0;this._wp[4]=this._originWorld[0];//x-axis
|
|
19641
19660
|
this._wp[5]=this._originWorld[1];this._wp[6]=this._originWorld[2];this._wp[7]=1.0;this._wp[8]=this._originWorld[0];//x-axis
|
|
19642
19661
|
this._wp[9]=this._targetWorld[1];//y-axis
|
|
19643
|
-
this._wp[10]=this._originWorld[2];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}else{
|
|
19662
|
+
this._wp[10]=this._originWorld[2];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}else{var delta=math.subVec3(this._targetWorld,this._originWorld,tmpVec3);/**
|
|
19663
|
+
* The length detected for each measurement axis.
|
|
19664
|
+
*/this._factors=math.transformVec3(this._axesBasis,delta);this._wp[0]=this._originWorld[0];this._wp[1]=this._originWorld[1];this._wp[2]=this._originWorld[2];this._wp[3]=1.0;this._wp[4]=this._originWorld[0]+this._axesBasis[0]*this._factors[0];this._wp[5]=this._originWorld[1]+this._axesBasis[4]*this._factors[0];this._wp[6]=this._originWorld[2]+this._axesBasis[8]*this._factors[0];this._wp[7]=1.0;this._wp[8]=this._originWorld[0]+this._axesBasis[0]*this._factors[0]+this._axesBasis[1]*this._factors[1];this._wp[9]=this._originWorld[1]+this._axesBasis[4]*this._factors[0]+this._axesBasis[5]*this._factors[1];this._wp[10]=this._originWorld[2]+this._axesBasis[8]*this._factors[0]+this._axesBasis[9]*this._factors[1];this._wp[11]=1.0;this._wp[12]=this._targetWorld[0];this._wp[13]=this._targetWorld[1];this._wp[14]=this._targetWorld[2];this._wp[15]=1.0;}this._wpDirty=false;this._vpDirty=true;}if(this._vpDirty){math.transformPositions4(scene.camera.viewMatrix,this._wp,this._vp);this._vp[3]=1.0;this._vp[7]=1.0;this._vp[11]=1.0;this._vp[15]=1.0;this._vpDirty=false;this._cpDirty=true;}if(this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld)){this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);this._lengthLabel.setCulled(true);this._xAxisWire.setCulled(true);this._yAxisWire.setCulled(true);this._zAxisWire.setCulled(true);this._lengthWire.setCulled(true);this._originDot.setCulled(true);this._targetDot.setCulled(true);return;}else{this._xAxisLabel.setCulled(false);this._yAxisLabel.setCulled(false);this._zAxisLabel.setCulled(false);this._lengthLabel.setCulled(false);this._xAxisWire.setCulled(false);this._yAxisWire.setCulled(false);this._zAxisWire.setCulled(false);this._lengthWire.setCulled(false);this._originDot.setCulled(false);this._targetDot.setCulled(false);}this._sectionPlanesDirty=true;}var near=-0.3;var vpz1=this._originDot.viewPos[2];var vpz2=this._targetDot.viewPos[2];if(vpz1>near||vpz2>near){this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);this._lengthLabel.setCulled(true);this._xAxisWire.setVisible(false);this._yAxisWire.setVisible(false);this._zAxisWire.setVisible(false);this._lengthWire.setVisible(false);this._originDot.setVisible(false);this._targetDot.setVisible(false);return;}if(this._cpDirty){math.transformPositions4(scene.camera.project.matrix,this._vp,this._pp);var pp=this._pp;var cp=this._cp;var canvas=scene.canvas.canvas;var offsets=canvas.getBoundingClientRect();var containerOffsets=this._container.getBoundingClientRect();var top=offsets.top-containerOffsets.top;var left=offsets.left-containerOffsets.left;var aabb=scene.canvas.boundary;var canvasWidth=aabb[2];var canvasHeight=aabb[3];var j=0;var metrics=this.plugin.viewer.scene.metrics;var _scale5=metrics.scale;var units=metrics.units;var unitInfo=metrics.unitsInfo[units];var unitAbbrev=unitInfo.abbrev;for(var i=0,len=pp.length;i<len;i+=4){cp[j]=left+Math.floor((1+pp[i+0]/pp[i+3])*canvasWidth/2);cp[j+1]=top+Math.floor((1-pp[i+1]/pp[i+3])*canvasHeight/2);j+=2;}this._lengthWire.setStartAndEnd(cp[0],cp[1],cp[6],cp[7]);this._xAxisWire.setStartAndEnd(cp[0],cp[1],cp[2],cp[3]);this._yAxisWire.setStartAndEnd(cp[2],cp[3],cp[4],cp[5]);this._zAxisWire.setStartAndEnd(cp[4],cp[5],cp[6],cp[7]);if(!this.labelsVisible){this._lengthLabel.setCulled(true);this._xAxisLabel.setCulled(true);this._yAxisLabel.setCulled(true);this._zAxisLabel.setCulled(true);}else{this._lengthLabel.setPosOnWire(cp[0],cp[1],cp[6],cp[7]);if(this.labelsOnWires){this._xAxisLabel.setPosOnWire(cp[0],cp[1],cp[2],cp[3]);this._yAxisLabel.setPosOnWire(cp[2],cp[3],cp[4],cp[5]);this._zAxisLabel.setPosOnWire(cp[4],cp[5],cp[6],cp[7]);}else{var labelOffset=35;var currentLabelOffset=labelOffset;this._xAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);currentLabelOffset+=labelOffset;this._yAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);currentLabelOffset+=labelOffset;this._zAxisLabel.setPosOnWire(cp[0],cp[1]+currentLabelOffset,cp[6],cp[7]+currentLabelOffset);}var tilde=this._approximate?" ~ ":" = ";this._length=Math.abs(math.lenVec3(math.subVec3(this._targetWorld,this._originWorld,distVec3)));this._lengthLabel.setText(tilde+(this._length*_scale5).toFixed(2)+unitAbbrev);var xAxisCanvasLength=Math.abs(lengthWire(cp[0],cp[1],cp[2],cp[3]));var yAxisCanvasLength=Math.abs(lengthWire(cp[2],cp[3],cp[4],cp[5]));var zAxisCanvasLength=Math.abs(lengthWire(cp[4],cp[5],cp[6],cp[7]));var labelMinAxisLength=this.plugin.labelMinAxisLength;if(this.labelsOnWires){this._xAxisLabelCulled=xAxisCanvasLength<labelMinAxisLength;this._yAxisLabelCulled=yAxisCanvasLength<labelMinAxisLength;this._zAxisLabelCulled=zAxisCanvasLength<labelMinAxisLength;}else{this._xAxisLabelCulled=false;this._yAxisLabelCulled=false;this._zAxisLabelCulled=false;}if(!this._xAxisLabelCulled){this._xAxisLabel.setText(tilde+Math.abs(this._factors[0]*_scale5).toFixed(2)+unitAbbrev);this._xAxisLabel.setCulled(!this.axisVisible);}else{this._xAxisLabel.setCulled(true);}if(!this._yAxisLabelCulled){this._yAxisLabel.setText(tilde+Math.abs(this._factors[1]*_scale5).toFixed(2)+unitAbbrev);this._yAxisLabel.setCulled(!this.axisVisible);}else{this._yAxisLabel.setCulled(true);}if(!this._zAxisLabelCulled){if(this._measurementOrientation==='Vertical'&&this.useRotationAdjustment){this._zAxisLabel.setPrefix("");this._zAxisLabel.setText(tilde+Math.abs(math.lenVec3(math.subVec3(this._targetWorld,[this._originWorld[0],this._targetWorld[1],this._originWorld[2]],distVec3))*_scale5).toFixed(2)+unitAbbrev);}else{this._zAxisLabel.setPrefix("Z");this._zAxisLabel.setText(tilde+Math.abs(this._factors[2]*_scale5).toFixed(2)+unitAbbrev);}this._zAxisLabel.setCulled(!this.axisVisible);}else{this._zAxisLabel.setCulled(true);}}// this._xAxisLabel.setVisible(this.axisVisible && this.xAxisVisible);
|
|
19644
19665
|
// this._yAxisLabel.setVisible(this.axisVisible && this.yAxisVisible);
|
|
19645
19666
|
// this._zAxisLabel.setVisible(this.axisVisible && this.zAxisVisible);
|
|
19646
19667
|
// this._lengthLabel.setVisible(false);
|
|
@@ -30339,7 +30360,7 @@ var pos=[];var ind=[];var addPlane=function addPlane(isCeiling){var baseIdx=pos.
|
|
|
30339
30360
|
addPlane(true);// ceiling
|
|
30340
30361
|
// sides
|
|
30341
30362
|
var _loop9=function _loop9(_i621){var a=baseVertices[_i621];var b=baseVertices[(baseVertices.length+_i621+(isCCW?1:-1))%baseVertices.length];var f=altitude;var c=altitude+height;var baseIdx=pos.length;pos.push([a[0],f,a[1]],[b[0],f,b[1]],[b[0],c,b[1]],[a[0],c,a[1]]);ind.push.apply(ind,_toConsumableArray([0,1,2,0,2,3].map(function(i){return i+baseIdx;})));};for(var _i621=0;_i621<baseVertices.length;++_i621){_loop9(_i621);}if(this._zoneMesh){this._zoneMesh.destroy();}var positions=(_ref24=[]).concat.apply(_ref24,pos);this._zoneMesh=new Mesh(scene,{edges:this._edges,geometry:new ReadableGeometry(scene,{positions:positions,indices:ind,normals:math.buildNormals(positions,ind)}),material:new PhongMaterial(scene,{alpha:this._alpha,backfaces:true,diffuse:hex2rgb(this._color)}),visible:this._visible});this._zoneMesh.highlighted=this._highlighted;this._zoneMesh.zone=this;{var _u2=math.vec2();var v=math.vec2();var baseArea=0;var _iterator43=_createForOfIteratorHelper(baseTriangles),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var t=_step43.value;var p0=baseVertices[t[0]];var p1=baseVertices[t[1]];var p2=baseVertices[t[2]];math.subVec2(p1,p0,_u2);math.subVec2(p2,p0,v);baseArea+=Math.abs(_u2[0]*v[1]-_u2[1]*v[0]);}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}this._baseArea=baseArea/2;}this._metrics=null;var min=function min(idx){return Math.min.apply(Math,_toConsumableArray(pos.map(function(p){return p[idx];})));};var max=function max(idx){return Math.max.apply(Math,_toConsumableArray(pos.map(function(p){return p[idx];})));};var xmin=min(0);var ymin=min(1);var zmin=min(2);var xmax=max(0);var ymax=max(1);var zmax=max(2);this._center=math.vec3([(xmin+xmax)/2,(ymin+ymax)/2,(zmin+zmax)/2]);}},{key:"baseArea",get:function get(){return this._baseArea;}},{key:"area",get:function get(){return this._getMetrics().area;}},{key:"volume",get:function get(){return this._getMetrics().volume;}},{key:"_getMetrics",value:function _getMetrics(){if(this._metrics===null){// Sum the volume of tetrahedrons formed by the origin and face triangles
|
|
30342
|
-
var volume=0;var _area4=0;var geo=this._zoneMesh.geometry;var pts=[math.vec3(),math.vec3(),math.vec3()];var
|
|
30363
|
+
var volume=0;var _area4=0;var geo=this._zoneMesh.geometry;var pts=[math.vec3(),math.vec3(),math.vec3()];var _tmpVec=math.vec3();for(var _i622=0;_i622<geo.indices.length;_i622+=3){for(var off=0;off<3;++off){var _p4=pts[off];var pIdx=3*geo.indices[_i622+off];for(var c=0;c<3;++c){_p4[c]=geo.positions[pIdx+c];}}volume+=math.dotVec3(pts[0],math.cross3Vec3(pts[1],pts[2],_tmpVec));math.subVec3(pts[1],pts[0],pts[1]);math.subVec3(pts[2],pts[0],pts[2]);_area4+=math.lenVec3(math.cross3Vec3(pts[1],pts[2],_tmpVec));}this._metrics={area:_area4/2,volume:volume/6};}return this._metrics;}},{key:"sectionedAverage",value:function sectionedAverage(sectionPlanes){var planeCoords=this._geometry.planeCoordinates.slice();var faces=[];{var h=this._geometry.height;var _a11=this._geometry.altitude;var c=_a11+Math.max(0,h);var _f2=_a11+Math.min(0,h);var addPlane=function addPlane(isCeiling){var face=planeCoords.map(function(p){return[p[0],isCeiling?c:_f2,p[1]];});faces.push(isCeiling?face:face.slice(0).reverse());};addPlane(true);// ceiling
|
|
30343
30364
|
addPlane(false);// floor
|
|
30344
30365
|
// sides
|
|
30345
30366
|
var _p5=function _p5(idx,y){return[planeCoords[idx][0],y,planeCoords[idx][1]];};for(var _i623=0;_i623<planeCoords.length;++_i623){var _j6=(_i623+1)%planeCoords.length;faces.push([_p5(_i623,_f2),_p5(_j6,_f2),_p5(_j6,c),_p5(_i623,c)]);}}var _iterator44=_createForOfIteratorHelper(sectionPlanes),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var _s2=_step44.value;var dir=_s2.dir;var dist=_s2.dist;var newFaces=[];var _iterator47=_createForOfIteratorHelper(faces),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var face=_step47.value;var _EPSILON=1e-5;var COPLANAR=0;var FRONT=1;var BACK=2;var SPANNING=3;// Classify each point as well as the entire polygon into one of the above four classes.
|