@xeokit/xeokit-sdk 2.6.34 → 2.6.36

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.
Files changed (23) hide show
  1. package/dist/xeokit-sdk.cjs.js +1060 -370
  2. package/dist/xeokit-sdk.es.js +1060 -370
  3. package/dist/xeokit-sdk.es5.js +126 -87
  4. package/dist/xeokit-sdk.min.cjs.js +3 -3
  5. package/dist/xeokit-sdk.min.es.js +4 -4
  6. package/dist/xeokit-sdk.min.es5.js +4 -4
  7. package/package.json +1 -1
  8. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +2 -4
  9. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +2 -4
  10. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +21 -6
  11. package/src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js +9 -11
  12. package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +8 -0
  13. package/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +657 -0
  14. package/src/plugins/ZonesPlugin/ZonesPlugin.js +3 -3
  15. package/src/plugins/lib/ui/index.js +1 -1
  16. package/src/viewer/Viewer.js +3 -0
  17. package/src/viewer/scene/CameraControl/CameraControl.js +22 -1
  18. package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +1 -1
  19. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickDepthRenderer.js +10 -6
  20. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickMeshRenderer.js +14 -8
  21. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsFlatRenderer.js +13 -8
  22. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsRenderer.js +7 -10
  23. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesDepthRenderer.js +0 -11
@@ -10683,8 +10683,8 @@ class SceneModelEntity {
10683
10683
  }
10684
10684
  }
10685
10685
 
10686
- const tempVec4a$a = math.vec4();
10687
- const tempVec4b$6 = math.vec4();
10686
+ const tempVec4a$b = math.vec4();
10687
+ const tempVec4b$7 = math.vec4();
10688
10688
 
10689
10689
 
10690
10690
  /**
@@ -10843,12 +10843,12 @@ class Marker extends Component {
10843
10843
  this.fire("viewPos", this._viewPos);
10844
10844
  }
10845
10845
  if (this._canvasPosDirty) {
10846
- tempVec4a$a.set(this._viewPos);
10847
- tempVec4a$a[3] = 1.0;
10848
- math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$a, tempVec4b$6);
10846
+ tempVec4a$b.set(this._viewPos);
10847
+ tempVec4a$b[3] = 1.0;
10848
+ math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$b, tempVec4b$7);
10849
10849
  const aabb = this.scene.canvas.boundary;
10850
- this._canvasPos[0] = Math.floor((1 + tempVec4b$6[0] / tempVec4b$6[3]) * aabb[2] / 2);
10851
- this._canvasPos[1] = Math.floor((1 - tempVec4b$6[1] / tempVec4b$6[3]) * aabb[3] / 2);
10850
+ this._canvasPos[0] = Math.floor((1 + tempVec4b$7[0] / tempVec4b$7[3]) * aabb[2] / 2);
10851
+ this._canvasPos[1] = Math.floor((1 - tempVec4b$7[1] / tempVec4b$7[3]) * aabb[3] / 2);
10852
10852
  this._canvasPosDirty = false;
10853
10853
  this.fire("canvasPos", this._canvasPos);
10854
10854
  }
@@ -11179,7 +11179,7 @@ function activateDraggableDot(dot, cfg) {
11179
11179
 
11180
11180
  const onChange = event => {
11181
11181
  const canvasPos = math.vec2([ event.clientX, event.clientY ]);
11182
- transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
11182
+ transformToNode(canvas.ownerDocument.documentElement, canvas, canvasPos);
11183
11183
  onMove(canvasPos, pickWorldPos(canvasPos));
11184
11184
  };
11185
11185
 
@@ -12688,7 +12688,6 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12688
12688
 
12689
12689
  _initMarkerDiv() {
12690
12690
  const markerDiv = document.createElement('div');
12691
- markerDiv.setAttribute('id', 'myMarkerDiv');
12692
12691
  const canvas = this.scene.canvas.canvas;
12693
12692
  canvas.parentNode.insertBefore(markerDiv, canvas);
12694
12693
 
@@ -12709,8 +12708,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12709
12708
 
12710
12709
  _destroyMarkerDiv() {
12711
12710
  if (this.markerDiv) {
12712
- const element = document.getElementById('myMarkerDiv');
12713
- element.parentNode.removeChild(element);
12711
+ this.markerDiv.parentNode.removeChild(this.markerDiv);
12714
12712
  this.markerDiv = null;
12715
12713
  }
12716
12714
  }
@@ -23518,8 +23516,8 @@ const tempVec3c$u = math.vec3();
23518
23516
  const tempVec3d$d = math.vec3();
23519
23517
  const tempVec3e$2 = math.vec3();
23520
23518
  const tempVec3f$2 = math.vec3();
23521
- const tempVec4a$9 = math.vec4();
23522
- const tempVec4b$5 = math.vec4();
23519
+ const tempVec4a$a = math.vec4();
23520
+ const tempVec4b$6 = math.vec4();
23523
23521
  const tempVec4c$2 = math.vec4();
23524
23522
  const tempMat = math.mat4();
23525
23523
  const tempMatb = math.mat4();
@@ -24384,8 +24382,8 @@ class Camera extends Component {
24384
24382
  * @returns {[number, number]} the canvas position
24385
24383
  */
24386
24384
  projectWorldPos(worldPos) {
24387
- const _worldPos = tempVec4a$9;
24388
- const viewPos = tempVec4b$5;
24385
+ const _worldPos = tempVec4a$a;
24386
+ const viewPos = tempVec4b$6;
24389
24387
  const screenPos = tempVec4c$2;
24390
24388
  _worldPos[0] = worldPos[0];
24391
24389
  _worldPos[1] = worldPos[1];
@@ -53648,17 +53646,6 @@ class TrianglesDepthRenderer$1 extends TrianglesBatchingRenderer {
53648
53646
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
53649
53647
  }
53650
53648
  }
53651
- src.push("const float packUpScale = 256. / 255.;");
53652
- src.push("const float unpackDownscale = 255. / 256.;");
53653
- src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
53654
- src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");
53655
- src.push("const float shiftRight8 = 1.0 / 256.;");
53656
-
53657
- src.push("vec4 packDepthToRGBA( const in float v ) {");
53658
- src.push(" vec4 r = vec4( fract( v * packFactors ), v );");
53659
- src.push(" r.yzw -= r.xyz * shiftRight8;");
53660
- src.push(" return r * packUpScale;");
53661
- src.push("}");
53662
53649
  src.push("in vec2 vHighPrecisionZW;");
53663
53650
  src.push("out vec4 outColor;");
53664
53651
  src.push("void main(void) {");
@@ -56192,7 +56179,7 @@ function octDecodeVec2(oct) { // Decode an oct-encoded normal
56192
56179
 
56193
56180
  const tempMat4$1 = math.mat4();
56194
56181
  const tempMat4b = math.mat4();
56195
- const tempVec4a$8 = math.vec4([0, 0, 0, 1]);
56182
+ const tempVec4a$9 = math.vec4([0, 0, 0, 1]);
56196
56183
 
56197
56184
  const tempVec3a$z = math.vec3();
56198
56185
  const tempVec3b$v = math.vec3();
@@ -57001,7 +56988,7 @@ class VBOBatchingTrianglesLayer {
57001
56988
  const offsetX = origin[0] ;
57002
56989
  const offsetY = origin[1] ;
57003
56990
  const offsetZ = origin[2] ;
57004
- const worldPos = tempVec4a$8;
56991
+ const worldPos = tempVec4a$9;
57005
56992
  const sceneModelMatrix = this.model.matrix;
57006
56993
  const positionsDecodeMatrix = state.positionsDecodeMatrix;
57007
56994
  for (let i = 0, len = positions.length; i < len; i += 3) {
@@ -61364,7 +61351,7 @@ function getRenderers$6(scene) {
61364
61351
 
61365
61352
  const tempUint8Vec4$2 = new Uint8Array(4);
61366
61353
  const tempFloat32$2 = new Float32Array(1);
61367
- const tempVec4a$7 = math.vec4([0, 0, 0, 1]);
61354
+ const tempVec4a$8 = math.vec4([0, 0, 0, 1]);
61368
61355
  const tempVec3fa$2 = new Float32Array(3);
61369
61356
 
61370
61357
  const tempVec3a$w = math.vec3();
@@ -62068,7 +62055,7 @@ class VBOInstancingTrianglesLayer {
62068
62055
  const offsetX = origin[0];
62069
62056
  const offsetY = origin[1];
62070
62057
  const offsetZ = origin[2];
62071
- const worldPos = tempVec4a$7;
62058
+ const worldPos = tempVec4a$8;
62072
62059
  const portionMatrix = portion.matrix;
62073
62060
  const sceneModelMatrix = this.model.matrix;
62074
62061
  const positionsDecodeMatrix = state.positionsDecodeMatrix;
@@ -72774,7 +72761,7 @@ const tempVec3b$i = math.vec3();
72774
72761
  const tempVec3c$e = math.vec3();
72775
72762
  math.vec3();
72776
72763
 
72777
- const tempVec4a$6 = math.vec4();
72764
+ const tempVec4a$7 = math.vec4();
72778
72765
 
72779
72766
  const tempMat4a$c = math.mat4();
72780
72767
 
@@ -73053,11 +73040,11 @@ class DTXTrianglesColorRenderer {
73053
73040
  if (saoEnabled) {
73054
73041
  const viewportWidth = gl.drawingBufferWidth;
73055
73042
  const viewportHeight = gl.drawingBufferHeight;
73056
- tempVec4a$6[0] = viewportWidth;
73057
- tempVec4a$6[1] = viewportHeight;
73058
- tempVec4a$6[2] = sao.blendCutoff;
73059
- tempVec4a$6[3] = sao.blendFactor;
73060
- gl.uniform4fv(this._uSAOParams, tempVec4a$6);
73043
+ tempVec4a$7[0] = viewportWidth;
73044
+ tempVec4a$7[1] = viewportHeight;
73045
+ tempVec4a$7[2] = sao.blendCutoff;
73046
+ tempVec4a$7[3] = sao.blendFactor;
73047
+ gl.uniform4fv(this._uSAOParams, tempVec4a$7);
73061
73048
  this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, 10);
73062
73049
  }
73063
73050
  }
@@ -74716,6 +74703,12 @@ class DTXTrianglesPickMeshRenderer {
74716
74703
  const textureState = state.textureState;
74717
74704
  const origin = dataTextureLayer._state.origin;
74718
74705
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
74706
+
74707
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
74708
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
74709
+ const eye = frameCtx.pickOrigin || camera.eye;
74710
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
74711
+
74719
74712
  textureState.bindCommonTextures(
74720
74713
  this._program,
74721
74714
  this.uTexturePerObjectPositionsDecodeMatrix,
@@ -74742,24 +74735,24 @@ class DTXTrianglesPickMeshRenderer {
74742
74735
  rtcOrigin[0] += position[0];
74743
74736
  rtcOrigin[1] += position[1];
74744
74737
  rtcOrigin[2] += position[2];
74745
- rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$8);
74738
+ rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$8);
74746
74739
  rtcCameraEye = tempVec3c$c;
74747
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
74748
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
74749
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
74740
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
74741
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
74742
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
74750
74743
  } else {
74751
- rtcViewMatrix = camera.viewMatrix;
74752
- rtcCameraEye = camera.eye;
74744
+ rtcViewMatrix = viewMatrix;
74745
+ rtcCameraEye = eye;
74753
74746
  }
74754
74747
  gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
74755
74748
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
74756
74749
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
74757
74750
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
74758
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
74751
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
74759
74752
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
74760
74753
  gl.uniform1i(this._uRenderPass, renderPass);
74761
74754
  if (scene.logarithmicDepthBufferEnabled) {
74762
- const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
74755
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
74763
74756
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
74764
74757
  }
74765
74758
  const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
@@ -75136,7 +75129,11 @@ class DTXTrianglesPickDepthRenderer {
75136
75129
  const textureState = state.textureState;
75137
75130
  const origin = dataTextureLayer._state.origin;
75138
75131
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
75132
+
75139
75133
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
75134
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
75135
+ const eye = frameCtx.pickOrigin || camera.eye;
75136
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
75140
75137
 
75141
75138
  if (!this._program) {
75142
75139
  this._allocate();
@@ -75176,15 +75173,15 @@ class DTXTrianglesPickDepthRenderer {
75176
75173
  rtcOrigin[2] += position[2];
75177
75174
  rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$7);
75178
75175
  rtcCameraEye = tempVec3c$b;
75179
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
75180
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
75181
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
75176
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
75177
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
75178
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
75182
75179
  frameCtx.snapPickOrigin[0] = rtcOrigin[0];
75183
75180
  frameCtx.snapPickOrigin[1] = rtcOrigin[1];
75184
75181
  frameCtx.snapPickOrigin[2] = rtcOrigin[2];
75185
75182
  } else {
75186
75183
  rtcViewMatrix = viewMatrix;
75187
- rtcCameraEye = camera.eye;
75184
+ rtcCameraEye = eye;
75188
75185
  frameCtx.snapPickOrigin[0] = 0;
75189
75186
  frameCtx.snapPickOrigin[1] = 0;
75190
75187
  frameCtx.snapPickOrigin[2] = 0;
@@ -75199,9 +75196,9 @@ class DTXTrianglesPickDepthRenderer {
75199
75196
  gl.uniform1f(this._uPickZFar, frameCtx.pickZFar);
75200
75197
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
75201
75198
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
75202
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
75199
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
75203
75200
  if (scene.logarithmicDepthBufferEnabled) {
75204
- const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
75201
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
75205
75202
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
75206
75203
  }
75207
75204
 
@@ -77711,6 +77708,11 @@ class DTXTrianglesPickNormalsFlatRenderer {
77711
77708
  this._bindProgram(frameCtx, state);
77712
77709
  }
77713
77710
 
77711
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
77712
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
77713
+ const eye = frameCtx.pickOrigin || camera.eye;
77714
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
77715
+
77714
77716
  textureState.bindCommonTextures(
77715
77717
  this._program,
77716
77718
  this.uTexturePerObjectPositionsDecodeMatrix,
@@ -77739,24 +77741,24 @@ class DTXTrianglesPickNormalsFlatRenderer {
77739
77741
  rtcOrigin[0] += position[0];
77740
77742
  rtcOrigin[1] += position[1];
77741
77743
  rtcOrigin[2] += position[2];
77742
- rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$1);
77744
+ rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$1);
77743
77745
  rtcCameraEye = tempVec3c$5;
77744
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
77745
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
77746
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
77746
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
77747
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
77748
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
77747
77749
  } else {
77748
- rtcViewMatrix = camera.viewMatrix; // TODO: make pickMatrix
77749
- rtcCameraEye = camera.eye;
77750
+ rtcViewMatrix = viewMatrix;
77751
+ rtcCameraEye = eye;
77750
77752
  }
77751
77753
  gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
77752
77754
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
77753
77755
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
77754
77756
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
77755
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); // TODO: pickProjMatrix
77757
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
77756
77758
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
77757
77759
  gl.uniform1i(this._uRenderPass, renderPass);
77758
77760
  if (scene.logarithmicDepthBufferEnabled) {
77759
- const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
77761
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
77760
77762
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
77761
77763
  }
77762
77764
  const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
@@ -79300,7 +79302,7 @@ const INDICES_EDGE_INDICES_ALIGNEMENT_SIZE = 8;
79300
79302
  */
79301
79303
  const MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE = 10;
79302
79304
 
79303
- const tempVec4a$5 = math.vec4();
79305
+ const tempVec4a$6 = math.vec4();
79304
79306
  const tempMat4a = new Float32Array(16);
79305
79307
  const tempUint8Array4 = new Uint8Array(4);
79306
79308
  const tempFloat32Array3 = new Float32Array(3);
@@ -80377,7 +80379,7 @@ class DTXTrianglesLayer {
80377
80379
  const offsetX = origin[0] ;
80378
80380
  const offsetY = origin[1] ;
80379
80381
  const offsetZ = origin[2] ;
80380
- const worldPos = tempVec4a$5;
80382
+ const worldPos = tempVec4a$6;
80381
80383
  for (let i = 0, len = positions.length; i < len; i += 3) {
80382
80384
  worldPos[0] = positions[i];
80383
80385
  worldPos[1] = positions[i + 1];
@@ -89150,7 +89152,6 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
89150
89152
 
89151
89153
  _initMarkerDiv() {
89152
89154
  const markerDiv = document.createElement('div');
89153
- markerDiv.setAttribute('id', 'myMarkerDiv');
89154
89155
  const canvas = this.scene.canvas.canvas;
89155
89156
  canvas.parentNode.insertBefore(markerDiv, canvas);
89156
89157
  markerDiv.style.background = "black";
@@ -89170,8 +89171,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
89170
89171
 
89171
89172
  _destroyMarkerDiv() {
89172
89173
  if (this._markerDiv) {
89173
- const element = document.getElementById('myMarkerDiv');
89174
- element.parentNode.removeChild(element);
89174
+ this._markerDiv.parentNode.removeChild(this._markerDiv);
89175
89175
  this._markerDiv = null;
89176
89176
  }
89177
89177
  }
@@ -90216,8 +90216,13 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90216
90216
  }
90217
90217
 
90218
90218
  const touch = event.touches[0];
90219
- const touchX = touch.clientX;
90220
- const touchY = touch.clientY;
90219
+
90220
+ // Get the canvas's bounding rectangle
90221
+ const rect = canvas.getBoundingClientRect();
90222
+
90223
+ // Calculate the touch position relative to the canvas
90224
+ const touchX = touch.clientX - rect.left;
90225
+ const touchY = touch.clientY - rect.top;
90221
90226
 
90222
90227
  touchStartCanvasPos.set([touchX, touchY]);
90223
90228
  touchMoveCanvasPos.set([touchX, touchY]);
@@ -90425,9 +90430,14 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90425
90430
  }
90426
90431
 
90427
90432
  const touch = event.touches[0];
90428
- const touchX = touch.clientX;
90429
- const touchY = touch.clientY;
90430
90433
 
90434
+ // Get the canvas's bounding rectangle
90435
+ const rect = canvas.getBoundingClientRect();
90436
+
90437
+ // Calculate the touch position relative to the canvas
90438
+ const touchX = touch.clientX - rect.left;
90439
+ const touchY = touch.clientY - rect.top;
90440
+
90431
90441
  if (touch.identifier !== touchId) {
90432
90442
  return;
90433
90443
  }
@@ -90594,8 +90604,13 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90594
90604
  }
90595
90605
 
90596
90606
  const touch = event.changedTouches[0];
90597
- const touchX = touch.clientX;
90598
- const touchY = touch.clientY;
90607
+
90608
+ // Get the canvas's bounding rectangle
90609
+ const rect = canvas.getBoundingClientRect();
90610
+
90611
+ // Calculate the touch position relative to the canvas
90612
+ const touchX = touch.clientX - rect.left;
90613
+ const touchY = touch.clientY - rect.top;
90599
90614
 
90600
90615
  if (touch.identifier !== touchId) {
90601
90616
  return;
@@ -96493,8 +96508,8 @@ const tempVec3a$7 = math.vec3();
96493
96508
  const tempVec3b$4 = math.vec3();
96494
96509
  const tempVec3c$3 = math.vec3();
96495
96510
 
96496
- const tempVec4a$4 = math.vec4();
96497
- const tempVec4b$4 = math.vec4();
96511
+ const tempVec4a$5 = math.vec4();
96512
+ const tempVec4b$5 = math.vec4();
96498
96513
  const tempVec4c$1 = math.vec4();
96499
96514
 
96500
96515
  /**
@@ -96533,7 +96548,7 @@ class PanController {
96533
96548
 
96534
96549
  camera.ortho.scale = camera.ortho.scale - dollyDelta;
96535
96550
 
96536
- const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$4);
96551
+ const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$5);
96537
96552
  const offset = math.subVec3(unprojectedWorldPos, camera.eye, tempVec4c$1);
96538
96553
  const moveVec = math.mulVec3Scalar(math.normalizeVec3(offset), -dollyDelta, []);
96539
96554
 
@@ -96560,12 +96575,12 @@ class PanController {
96560
96575
  // - get the vector in which we're dollying;
96561
96576
  // - add both vectors to camera eye and look.
96562
96577
 
96563
- const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$4);
96578
+ const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$5);
96564
96579
 
96565
96580
  camera.ortho.scale = camera.ortho.scale - dollyDelta;
96566
96581
  camera.ortho._update(); // HACK
96567
96582
 
96568
- const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$4);
96583
+ const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$5);
96569
96584
  const offset = math.subVec3(worldPos2, worldPos1, tempVec4c$1);
96570
96585
  const eyeLookMoveVec = math.mulVec3Scalar(math.normalizeVec3(math.subVec3(camera.look, camera.eye, tempVec3a$7)), -dollyDelta, tempVec3b$4);
96571
96586
  const moveVec = math.addVec3(offset, eyeLookMoveVec, tempVec3c$3);
@@ -96599,8 +96614,8 @@ const tempVec3a$6 = math.vec3();
96599
96614
  const tempVec3b$3 = math.vec3();
96600
96615
  const tempVec3c$2 = math.vec3();
96601
96616
 
96602
- const tempVec4a$3 = math.vec4();
96603
- const tempVec4b$3 = math.vec4();
96617
+ const tempVec4a$4 = math.vec4();
96618
+ const tempVec4b$4 = math.vec4();
96604
96619
  const tempVec4c = math.vec4();
96605
96620
 
96606
96621
 
@@ -96853,8 +96868,8 @@ class PivotController {
96853
96868
  const Pt4 = transposedProjectMat.subarray(12);
96854
96869
  const D = [0, 0, -1.0, 1];
96855
96870
  const screenZ = math.dotVec4(D, Pt3) / math.dotVec4(D, Pt4);
96856
- const worldPos = tempVec4a$3;
96857
- camera.project.unproject(canvasPos, screenZ, tempVec4b$3, tempVec4c, worldPos);
96871
+ const worldPos = tempVec4a$4;
96872
+ camera.project.unproject(canvasPos, screenZ, tempVec4b$4, tempVec4c, worldPos);
96858
96873
  const eyeWorldPosVec = math.normalizeVec3(math.subVec3(worldPos, camera.eye, tempVec3a$6));
96859
96874
  const posOnSphere = math.addVec3(camera.eye, math.mulVec3Scalar(eyeWorldPosVec, pivotShereRadius, tempVec3b$3), tempVec3c$2);
96860
96875
  this.setPivotPos(posOnSphere);
@@ -97508,7 +97523,7 @@ class MousePanRotateDollyHandler {
97508
97523
  let secsNowLast = null;
97509
97524
 
97510
97525
  canvas.addEventListener("wheel", this._mouseWheelHandler = (e) => {
97511
- if (!(configs.active && configs.pointerEnabled)) {
97526
+ if (!(configs.active && configs.pointerEnabled && configs.zoomOnMouseWheel)) {
97512
97527
  return;
97513
97528
  }
97514
97529
  const secsNow = performance.now() / 1000.0;
@@ -99743,7 +99758,8 @@ class CameraControl extends Component {
99743
99758
  constrainVertical: false,
99744
99759
  smartPivot: false,
99745
99760
  doubleClickTimeFrame: 250,
99746
-
99761
+ zoomOnMouseWheel: true,
99762
+
99747
99763
  snapToVertex: DEFAULT_SNAP_VERTEX,
99748
99764
  snapToEdge: DEFAULT_SNAP_EDGE,
99749
99765
  snapRadius: DEFAULT_SNAP_PICK_RADIUS,
@@ -100834,6 +100850,26 @@ class CameraControl extends Component {
100834
100850
  return this._configs.doubleClickTimeFrame;
100835
100851
  }
100836
100852
 
100853
+ /**
100854
+ * Sets whether to zoom the camera on mouse wheel
100855
+ *
100856
+ * Default is ````true````
100857
+ *
100858
+ * @param {Boolean} enabled
100859
+ */
100860
+ set zoomOnMouseWheel(enabled) {
100861
+ this._configs.zoomOnMouseWheel = !!enabled;
100862
+ }
100863
+
100864
+ /**
100865
+ * Gets whether to zoom the camera on mouse wheel
100866
+ *
100867
+ * @returns {Boolean}
100868
+ */
100869
+ get zoomOnMouseWheel() {
100870
+ return this._configs.zoomOnMouseWheel;
100871
+ }
100872
+
100837
100873
  /**
100838
100874
  * Destroys this ````CameraControl````.
100839
100875
  * @private
@@ -110193,6 +110229,9 @@ class Viewer {
110193
110229
  }
110194
110230
  }
110195
110231
 
110232
+ // firing "rendering" is necessary to trigger DTX{Lines,Triangles}Layer::_uploadDeferredFlags
110233
+ this.scene.fire("rendering", { }, true);
110234
+
110196
110235
  this.scene._renderer.renderSnapshot();
110197
110236
 
110198
110237
  const imageDataURI = this.scene._renderer.readSnapshot(params);
@@ -128108,7 +128147,7 @@ if (!pako$9.inflate) { // See https://github.com/nodeca/pako/issues/97
128108
128147
  pako$9 = pako$9.default;
128109
128148
  }
128110
128149
 
128111
- const decompressColor$9 = (function () {
128150
+ const decompressColor$a = (function () {
128112
128151
  const color2 = new Float32Array(3);
128113
128152
  return function (color) {
128114
128153
  color2[0] = color[0] / 255.0;
@@ -128152,7 +128191,7 @@ function inflate$9(deflatedData) {
128152
128191
  };
128153
128192
  }
128154
128193
 
128155
- function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128194
+ function load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128156
128195
 
128157
128196
  manifestCtx.getNextId();
128158
128197
 
@@ -128221,7 +128260,7 @@ function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128221
128260
  const lastMesh = (j === (numMeshes - 1));
128222
128261
  const meshId = entityId + ".mesh." + j;
128223
128262
 
128224
- const color = decompressColor$9(meshColors.subarray((j * 4), (j * 4) + 3));
128263
+ const color = decompressColor$a(meshColors.subarray((j * 4), (j * 4) + 3));
128225
128264
  const opacity = meshColors[(j * 4) + 3] / 255.0;
128226
128265
 
128227
128266
  sceneModel.createMesh(utils.apply(meshDefaults, {
@@ -128253,7 +128292,7 @@ const ParserV1 = {
128253
128292
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128254
128293
  const deflatedData = extract$9(elements);
128255
128294
  const inflatedData = inflate$9(deflatedData);
128256
- load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128295
+ load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128257
128296
  }
128258
128297
  };
128259
128298
 
@@ -128321,6 +128360,222 @@ function inflate$8(deflatedData) {
128321
128360
  };
128322
128361
  }
128323
128362
 
128363
+ const decompressColor$9 = (function () {
128364
+ const color2 = new Float32Array(3);
128365
+ return function (color) {
128366
+ color2[0] = color[0] / 255.0;
128367
+ color2[1] = color[1] / 255.0;
128368
+ color2[2] = color[2] / 255.0;
128369
+ return color2;
128370
+ };
128371
+ })();
128372
+
128373
+ function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128374
+
128375
+ const modelPartId = manifestCtx.getNextId();
128376
+
128377
+ sceneModel.positionsCompression = "precompressed";
128378
+ sceneModel.normalsCompression = "precompressed";
128379
+
128380
+ const positions = inflatedData.positions;
128381
+ const normals = inflatedData.normals;
128382
+ const indices = inflatedData.indices;
128383
+ const edgeIndices = inflatedData.edgeIndices;
128384
+ const meshPositions = inflatedData.meshPositions;
128385
+ const meshIndices = inflatedData.meshIndices;
128386
+ const meshEdgesIndices = inflatedData.meshEdgesIndices;
128387
+ const meshColors = inflatedData.meshColors;
128388
+ const entityIDs = JSON.parse(inflatedData.entityIDs);
128389
+ const entityMeshes = inflatedData.entityMeshes;
128390
+ const entityIsObjects = inflatedData.entityIsObjects;
128391
+ const entityMeshIds = inflatedData.entityMeshIds;
128392
+ const entityMatrices = inflatedData.entityMatrices;
128393
+ const entityUsesInstancing = inflatedData.entityUsesInstancing;
128394
+
128395
+ const numMeshes = meshPositions.length;
128396
+ const numEntities = entityMeshes.length;
128397
+
128398
+ const alreadyCreatedGeometries = {};
128399
+
128400
+ for (let i = 0; i < numEntities; i++) {
128401
+
128402
+ const xktEntityId = entityIDs [i];
128403
+ const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId;
128404
+ const metaObject = viewer.metaScene.metaObjects[entityId];
128405
+ const entityDefaults = {};
128406
+ const meshDefaults = {};
128407
+ const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16);
128408
+
128409
+ if (metaObject) {
128410
+ if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) {
128411
+ continue;
128412
+ }
128413
+ if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) {
128414
+ continue;
128415
+ }
128416
+ const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
128417
+ if (props) {
128418
+ if (props.visible === false) {
128419
+ entityDefaults.visible = false;
128420
+ }
128421
+ if (props.pickable === false) {
128422
+ entityDefaults.pickable = false;
128423
+ }
128424
+ if (props.colorize) {
128425
+ meshDefaults.color = props.colorize;
128426
+ }
128427
+ if (props.opacity !== undefined && props.opacity !== null) {
128428
+ meshDefaults.opacity = props.opacity;
128429
+ }
128430
+ }
128431
+ } else {
128432
+ if (options.excludeUnclassifiedObjects) {
128433
+ continue;
128434
+ }
128435
+ }
128436
+
128437
+ const lastEntity = (i === numEntities - 1);
128438
+
128439
+ const meshIds = [];
128440
+
128441
+ for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) {
128442
+
128443
+ const jj = entityMeshIds [j];
128444
+
128445
+ const lastMesh = (jj === (numMeshes - 1));
128446
+ const meshId = manifestCtx.getNextId();
128447
+
128448
+ const color = decompressColor$9(meshColors.subarray((jj * 4), (jj * 4) + 3));
128449
+ const opacity = meshColors[(jj * 4) + 3] / 255.0;
128450
+
128451
+ const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128452
+ const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128453
+ const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]);
128454
+ const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]);
128455
+
128456
+ if (entityUsesInstancing [i] === 1) {
128457
+
128458
+ const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`;
128459
+
128460
+ if (!(geometryId in alreadyCreatedGeometries)) {
128461
+
128462
+ sceneModel.createGeometry({
128463
+ id: geometryId,
128464
+ positionsCompressed: tmpPositions,
128465
+ normalsCompressed: tmpNormals,
128466
+ indices: tmpIndices,
128467
+ edgeIndices: tmpEdgeIndices,
128468
+ primitive: "triangles",
128469
+ positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128470
+ });
128471
+
128472
+ alreadyCreatedGeometries [geometryId] = true;
128473
+ }
128474
+
128475
+ sceneModel.createMesh(utils.apply(meshDefaults, {
128476
+ id: meshId,
128477
+ color: color,
128478
+ opacity: opacity,
128479
+ matrix: entityMatrix,
128480
+ geometryId,
128481
+ }));
128482
+
128483
+ meshIds.push(meshId);
128484
+
128485
+ } else {
128486
+
128487
+ sceneModel.createMesh(utils.apply(meshDefaults, {
128488
+ id: meshId,
128489
+ primitive: "triangles",
128490
+ positionsCompressed: tmpPositions,
128491
+ normalsCompressed: tmpNormals,
128492
+ indices: tmpIndices,
128493
+ edgeIndices: tmpEdgeIndices,
128494
+ positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128495
+ color: color,
128496
+ opacity: opacity
128497
+ }));
128498
+
128499
+ meshIds.push(meshId);
128500
+ }
128501
+ }
128502
+
128503
+ if (meshIds.length) {
128504
+
128505
+ sceneModel.createEntity(utils.apply(entityDefaults, {
128506
+ id: entityId,
128507
+ isObject: (entityIsObjects [i] === 1),
128508
+ meshIds: meshIds
128509
+ }));
128510
+ }
128511
+ }
128512
+ }
128513
+
128514
+ /** @private */
128515
+ const ParserV2 = {
128516
+ version: 2,
128517
+ parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128518
+ const deflatedData = extract$8(elements);
128519
+ const inflatedData = inflate$8(deflatedData);
128520
+ load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128521
+ }
128522
+ };
128523
+
128524
+ /*
128525
+
128526
+ Parser for .XKT Format V3
128527
+
128528
+ .XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format
128529
+
128530
+ */
128531
+
128532
+ let pako$7 = window.pako || p;
128533
+ if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97
128534
+ pako$7 = pako$7.default;
128535
+ }
128536
+
128537
+ function extract$7(elements) {
128538
+ return {
128539
+ positions: elements[0],
128540
+ normals: elements[1],
128541
+ indices: elements[2],
128542
+ edgeIndices: elements[3],
128543
+ meshPositions: elements[4],
128544
+ meshIndices: elements[5],
128545
+ meshEdgesIndices: elements[6],
128546
+ meshColors: elements[7],
128547
+ entityIDs: elements[8],
128548
+ entityMeshes: elements[9],
128549
+ entityIsObjects: elements[10],
128550
+ instancedPositionsDecodeMatrix: elements[11],
128551
+ batchedPositionsDecodeMatrix: elements[12],
128552
+ entityMeshIds: elements[13],
128553
+ entityMatrices: elements[14],
128554
+ entityUsesInstancing: elements[15]
128555
+ };
128556
+ }
128557
+
128558
+ function inflate$7(deflatedData) {
128559
+ return {
128560
+ positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer),
128561
+ normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer),
128562
+ indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer),
128563
+ edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer),
128564
+ meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer),
128565
+ meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer),
128566
+ meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer),
128567
+ meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer),
128568
+ entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}),
128569
+ entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer),
128570
+ entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer),
128571
+ instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer),
128572
+ batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer),
128573
+ entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer),
128574
+ entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer),
128575
+ entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer)
128576
+ };
128577
+ }
128578
+
128324
128579
  const decompressColor$8 = (function () {
128325
128580
  const color2 = new Float32Array(3);
128326
128581
  return function (color) {
@@ -128356,222 +128611,6 @@ function load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128356
128611
  const numMeshes = meshPositions.length;
128357
128612
  const numEntities = entityMeshes.length;
128358
128613
 
128359
- const alreadyCreatedGeometries = {};
128360
-
128361
- for (let i = 0; i < numEntities; i++) {
128362
-
128363
- const xktEntityId = entityIDs [i];
128364
- const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId;
128365
- const metaObject = viewer.metaScene.metaObjects[entityId];
128366
- const entityDefaults = {};
128367
- const meshDefaults = {};
128368
- const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16);
128369
-
128370
- if (metaObject) {
128371
- if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) {
128372
- continue;
128373
- }
128374
- if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) {
128375
- continue;
128376
- }
128377
- const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
128378
- if (props) {
128379
- if (props.visible === false) {
128380
- entityDefaults.visible = false;
128381
- }
128382
- if (props.pickable === false) {
128383
- entityDefaults.pickable = false;
128384
- }
128385
- if (props.colorize) {
128386
- meshDefaults.color = props.colorize;
128387
- }
128388
- if (props.opacity !== undefined && props.opacity !== null) {
128389
- meshDefaults.opacity = props.opacity;
128390
- }
128391
- }
128392
- } else {
128393
- if (options.excludeUnclassifiedObjects) {
128394
- continue;
128395
- }
128396
- }
128397
-
128398
- const lastEntity = (i === numEntities - 1);
128399
-
128400
- const meshIds = [];
128401
-
128402
- for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) {
128403
-
128404
- const jj = entityMeshIds [j];
128405
-
128406
- const lastMesh = (jj === (numMeshes - 1));
128407
- const meshId = manifestCtx.getNextId();
128408
-
128409
- const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3));
128410
- const opacity = meshColors[(jj * 4) + 3] / 255.0;
128411
-
128412
- const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128413
- const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128414
- const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]);
128415
- const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]);
128416
-
128417
- if (entityUsesInstancing [i] === 1) {
128418
-
128419
- const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`;
128420
-
128421
- if (!(geometryId in alreadyCreatedGeometries)) {
128422
-
128423
- sceneModel.createGeometry({
128424
- id: geometryId,
128425
- positionsCompressed: tmpPositions,
128426
- normalsCompressed: tmpNormals,
128427
- indices: tmpIndices,
128428
- edgeIndices: tmpEdgeIndices,
128429
- primitive: "triangles",
128430
- positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128431
- });
128432
-
128433
- alreadyCreatedGeometries [geometryId] = true;
128434
- }
128435
-
128436
- sceneModel.createMesh(utils.apply(meshDefaults, {
128437
- id: meshId,
128438
- color: color,
128439
- opacity: opacity,
128440
- matrix: entityMatrix,
128441
- geometryId,
128442
- }));
128443
-
128444
- meshIds.push(meshId);
128445
-
128446
- } else {
128447
-
128448
- sceneModel.createMesh(utils.apply(meshDefaults, {
128449
- id: meshId,
128450
- primitive: "triangles",
128451
- positionsCompressed: tmpPositions,
128452
- normalsCompressed: tmpNormals,
128453
- indices: tmpIndices,
128454
- edgeIndices: tmpEdgeIndices,
128455
- positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128456
- color: color,
128457
- opacity: opacity
128458
- }));
128459
-
128460
- meshIds.push(meshId);
128461
- }
128462
- }
128463
-
128464
- if (meshIds.length) {
128465
-
128466
- sceneModel.createEntity(utils.apply(entityDefaults, {
128467
- id: entityId,
128468
- isObject: (entityIsObjects [i] === 1),
128469
- meshIds: meshIds
128470
- }));
128471
- }
128472
- }
128473
- }
128474
-
128475
- /** @private */
128476
- const ParserV2 = {
128477
- version: 2,
128478
- parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128479
- const deflatedData = extract$8(elements);
128480
- const inflatedData = inflate$8(deflatedData);
128481
- load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128482
- }
128483
- };
128484
-
128485
- /*
128486
-
128487
- Parser for .XKT Format V3
128488
-
128489
- .XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format
128490
-
128491
- */
128492
-
128493
- let pako$7 = window.pako || p;
128494
- if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97
128495
- pako$7 = pako$7.default;
128496
- }
128497
-
128498
- function extract$7(elements) {
128499
- return {
128500
- positions: elements[0],
128501
- normals: elements[1],
128502
- indices: elements[2],
128503
- edgeIndices: elements[3],
128504
- meshPositions: elements[4],
128505
- meshIndices: elements[5],
128506
- meshEdgesIndices: elements[6],
128507
- meshColors: elements[7],
128508
- entityIDs: elements[8],
128509
- entityMeshes: elements[9],
128510
- entityIsObjects: elements[10],
128511
- instancedPositionsDecodeMatrix: elements[11],
128512
- batchedPositionsDecodeMatrix: elements[12],
128513
- entityMeshIds: elements[13],
128514
- entityMatrices: elements[14],
128515
- entityUsesInstancing: elements[15]
128516
- };
128517
- }
128518
-
128519
- function inflate$7(deflatedData) {
128520
- return {
128521
- positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer),
128522
- normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer),
128523
- indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer),
128524
- edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer),
128525
- meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer),
128526
- meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer),
128527
- meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer),
128528
- meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer),
128529
- entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}),
128530
- entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer),
128531
- entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer),
128532
- instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer),
128533
- batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer),
128534
- entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer),
128535
- entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer),
128536
- entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer)
128537
- };
128538
- }
128539
-
128540
- const decompressColor$7 = (function () {
128541
- const color2 = new Float32Array(3);
128542
- return function (color) {
128543
- color2[0] = color[0] / 255.0;
128544
- color2[1] = color[1] / 255.0;
128545
- color2[2] = color[2] / 255.0;
128546
- return color2;
128547
- };
128548
- })();
128549
-
128550
- function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128551
-
128552
- const modelPartId = manifestCtx.getNextId();
128553
-
128554
- sceneModel.positionsCompression = "precompressed";
128555
- sceneModel.normalsCompression = "precompressed";
128556
-
128557
- const positions = inflatedData.positions;
128558
- const normals = inflatedData.normals;
128559
- const indices = inflatedData.indices;
128560
- const edgeIndices = inflatedData.edgeIndices;
128561
- const meshPositions = inflatedData.meshPositions;
128562
- const meshIndices = inflatedData.meshIndices;
128563
- const meshEdgesIndices = inflatedData.meshEdgesIndices;
128564
- const meshColors = inflatedData.meshColors;
128565
- const entityIDs = JSON.parse(inflatedData.entityIDs);
128566
- const entityMeshes = inflatedData.entityMeshes;
128567
- const entityIsObjects = inflatedData.entityIsObjects;
128568
- const entityMeshIds = inflatedData.entityMeshIds;
128569
- const entityMatrices = inflatedData.entityMatrices;
128570
- const entityUsesInstancing = inflatedData.entityUsesInstancing;
128571
-
128572
- const numMeshes = meshPositions.length;
128573
- const numEntities = entityMeshes.length;
128574
-
128575
128614
  const _alreadyCreatedGeometries = {};
128576
128615
 
128577
128616
  for (let i = 0; i < numEntities; i++) {
@@ -128625,7 +128664,7 @@ function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128625
128664
  const lastMesh = (jj === (numMeshes - 1));
128626
128665
  const meshId = `${modelPartId}.${entityId}.mesh.${jj}`;
128627
128666
 
128628
- const color = decompressColor$7(meshColors.subarray((jj * 4), (jj * 4) + 3));
128667
+ const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3));
128629
128668
  const opacity = meshColors[(jj * 4) + 3] / 255.0;
128630
128669
 
128631
128670
  var tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
@@ -128696,7 +128735,7 @@ const ParserV3 = {
128696
128735
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128697
128736
  const deflatedData = extract$7(elements);
128698
128737
  const inflatedData = inflate$7(deflatedData);
128699
- load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128738
+ load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128700
128739
  }
128701
128740
  };
128702
128741
 
@@ -128754,7 +128793,7 @@ function inflate$6(deflatedData) {
128754
128793
  };
128755
128794
  }
128756
128795
 
128757
- const decompressColor$6 = (function () {
128796
+ const decompressColor$7 = (function () {
128758
128797
  const color2 = new Float32Array(3);
128759
128798
  return function (color) {
128760
128799
  color2[0] = color[0] / 255.0;
@@ -128764,7 +128803,7 @@ const decompressColor$6 = (function () {
128764
128803
  };
128765
128804
  })();
128766
128805
 
128767
- function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128806
+ function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128768
128807
 
128769
128808
  const modelPartId = manifestCtx.getNextId();
128770
128809
 
@@ -128860,7 +128899,7 @@ function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128860
128899
  const primitiveInstanceCount = primitiveInstanceCounts[orderedPrimitiveIndex];
128861
128900
  const isInstancedPrimitive = (primitiveInstanceCount > 1);
128862
128901
 
128863
- const color = decompressColor$6(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3));
128902
+ const color = decompressColor$7(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3));
128864
128903
  const opacity = eachPrimitiveColor[(orderedPrimitiveIndex * 4) + 3] / 255.0;
128865
128904
 
128866
128905
  const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex + 1]);
@@ -128970,7 +129009,7 @@ const ParserV4 = {
128970
129009
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128971
129010
  const deflatedData = extract$6(elements);
128972
129011
  const inflatedData = inflate$6(deflatedData);
128973
- load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129012
+ load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128974
129013
  }
128975
129014
  };
128976
129015
 
@@ -129023,7 +129062,7 @@ function inflate$5(deflatedData) {
129023
129062
  };
129024
129063
  }
129025
129064
 
129026
- const decompressColor$5 = (function () {
129065
+ const decompressColor$6 = (function () {
129027
129066
  const color2 = new Float32Array(3);
129028
129067
  return function (color) {
129029
129068
  color2[0] = color[0] / 255.0;
@@ -129033,7 +129072,7 @@ const decompressColor$5 = (function () {
129033
129072
  };
129034
129073
  })();
129035
129074
 
129036
- function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129075
+ function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129037
129076
 
129038
129077
  const modelPartId = manifestCtx.getNextId();
129039
129078
 
@@ -129102,7 +129141,7 @@ function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
129102
129141
  const primitiveInstanceCount = primitiveInstanceCounts[primitiveIndex];
129103
129142
  const isInstancedPrimitive = (primitiveInstanceCount > 1);
129104
129143
 
129105
- const color = decompressColor$5(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129144
+ const color = decompressColor$6(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129106
129145
  const opacity = eachPrimitiveColor[(primitiveIndex * 4) + 3] / 255.0;
129107
129146
 
129108
129147
  const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [primitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [primitiveIndex + 1]);
@@ -129208,7 +129247,7 @@ const ParserV5 = {
129208
129247
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
129209
129248
  const deflatedData = extract$5(elements);
129210
129249
  const inflatedData = inflate$5(deflatedData);
129211
- load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129250
+ load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129212
129251
  }
129213
129252
  };
129214
129253
 
@@ -129271,7 +129310,7 @@ function inflate$4(deflatedData) {
129271
129310
  };
129272
129311
  }
129273
129312
 
129274
- const decompressColor$4 = (function () {
129313
+ const decompressColor$5 = (function () {
129275
129314
  const floatColor = new Float32Array(3);
129276
129315
  return function (intColor) {
129277
129316
  floatColor[0] = intColor[0] / 255.0;
@@ -129281,7 +129320,7 @@ const decompressColor$4 = (function () {
129281
129320
  };
129282
129321
  })();
129283
129322
 
129284
- function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129323
+ function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129285
129324
 
129286
129325
  const modelPartId = manifestCtx.getNextId();
129287
129326
 
@@ -129429,7 +129468,7 @@ function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
129429
129468
  const primitiveIndices = indices.subarray(eachPrimitiveIndicesPortion [primitiveIndex], atLastPrimitive ? indices.length : eachPrimitiveIndicesPortion [primitiveIndex + 1]);
129430
129469
  const primitiveEdgeIndices = edgeIndices.subarray(eachPrimitiveEdgeIndicesPortion [primitiveIndex], atLastPrimitive ? edgeIndices.length : eachPrimitiveEdgeIndicesPortion [primitiveIndex + 1]);
129431
129470
 
129432
- const color = decompressColor$4(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129471
+ const color = decompressColor$5(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129433
129472
  const opacity = eachPrimitiveColorAndOpacity[(primitiveIndex * 4) + 3] / 255.0;
129434
129473
 
129435
129474
  const meshId = manifestCtx.getNextId();
@@ -129503,7 +129542,7 @@ const ParserV6 = {
129503
129542
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
129504
129543
  const deflatedData = extract$4(elements);
129505
129544
  const inflatedData = inflate$4(deflatedData);
129506
- load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129545
+ load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129507
129546
  }
129508
129547
  };
129509
129548
 
@@ -129601,7 +129640,7 @@ function inflate$3(deflatedData) {
129601
129640
  };
129602
129641
  }
129603
129642
 
129604
- const decompressColor$3 = (function () {
129643
+ const decompressColor$4 = (function () {
129605
129644
  const floatColor = new Float32Array(3);
129606
129645
  return function (intColor) {
129607
129646
  floatColor[0] = intColor[0] / 255.0;
@@ -129622,7 +129661,7 @@ function convertColorsRGBToRGBA$1(colorsRGB) {
129622
129661
  return colorsRGBA;
129623
129662
  }
129624
129663
 
129625
- function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129664
+ function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129626
129665
 
129627
129666
  const modelPartId = manifestCtx.getNextId();
129628
129667
 
@@ -129773,7 +129812,7 @@ function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
129773
129812
 
129774
129813
  const atLastGeometry = (geometryIndex === (numGeometries - 1));
129775
129814
 
129776
- const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
129815
+ const meshColor = decompressColor$4(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
129777
129816
  const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
129778
129817
  const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
129779
129818
  const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;
@@ -129934,7 +129973,7 @@ const ParserV7 = {
129934
129973
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
129935
129974
  const deflatedData = extract$3(elements);
129936
129975
  const inflatedData = inflate$3(deflatedData);
129937
- load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129976
+ load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129938
129977
  }
129939
129978
  };
129940
129979
 
@@ -129949,8 +129988,8 @@ if (!pako$2.inflate) { // See https://github.com/nodeca/pako/issues/97
129949
129988
  pako$2 = pako$2.default;
129950
129989
  }
129951
129990
 
129952
- const tempVec4a$2 = math.vec4();
129953
- const tempVec4b$2 = math.vec4();
129991
+ const tempVec4a$3 = math.vec4();
129992
+ const tempVec4b$3 = math.vec4();
129954
129993
 
129955
129994
  function extract$2(elements) {
129956
129995
 
@@ -130042,7 +130081,7 @@ function inflate$2(deflatedData) {
130042
130081
  };
130043
130082
  }
130044
130083
 
130045
- const decompressColor$2 = (function () {
130084
+ const decompressColor$3 = (function () {
130046
130085
  const floatColor = new Float32Array(3);
130047
130086
  return function (intColor) {
130048
130087
  floatColor[0] = intColor[0] / 255.0;
@@ -130063,7 +130102,7 @@ function convertColorsRGBToRGBA(colorsRGB) {
130063
130102
  return colorsRGBA;
130064
130103
  }
130065
130104
 
130066
- function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130105
+ function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130067
130106
 
130068
130107
  const modelPartId = manifestCtx.getNextId();
130069
130108
 
@@ -130249,7 +130288,7 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130249
130288
 
130250
130289
  const atLastGeometry = (geometryIndex === (numGeometries - 1));
130251
130290
 
130252
- const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130291
+ const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130253
130292
  const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
130254
130293
  const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
130255
130294
  const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;
@@ -130338,15 +130377,15 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130338
130377
  const decompressedPositions = geometryArrays.decompressedPositions;
130339
130378
  const positions = new Uint16Array(decompressedPositions.length);
130340
130379
  for (let i = 0, len = decompressedPositions.length; i < len; i += 3) {
130341
- tempVec4a$2[0] = decompressedPositions[i + 0];
130342
- tempVec4a$2[1] = decompressedPositions[i + 1];
130343
- tempVec4a$2[2] = decompressedPositions[i + 2];
130344
- tempVec4a$2[3] = 1;
130345
- math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2);
130346
- geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2);
130347
- positions[i + 0] = tempVec4a$2[0];
130348
- positions[i + 1] = tempVec4a$2[1];
130349
- positions[i + 2] = tempVec4a$2[2];
130380
+ tempVec4a$3[0] = decompressedPositions[i + 0];
130381
+ tempVec4a$3[1] = decompressedPositions[i + 1];
130382
+ tempVec4a$3[2] = decompressedPositions[i + 2];
130383
+ tempVec4a$3[3] = 1;
130384
+ math.transformVec4(meshMatrix, tempVec4a$3, tempVec4b$3);
130385
+ geometryCompressionUtils.compressPosition(tempVec4b$3, rtcAABB, tempVec4a$3);
130386
+ positions[i + 0] = tempVec4a$3[0];
130387
+ positions[i + 1] = tempVec4a$3[1];
130388
+ positions[i + 2] = tempVec4a$3[2];
130350
130389
  }
130351
130390
 
130352
130391
  sceneModel.createMesh(utils.apply(meshDefaults, {
@@ -130486,7 +130525,7 @@ const ParserV8 = {
130486
130525
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
130487
130526
  const deflatedData = extract$2(elements);
130488
130527
  const inflatedData = inflate$2(deflatedData);
130489
- load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
130528
+ load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
130490
130529
  }
130491
130530
  };
130492
130531
 
@@ -130501,8 +130540,8 @@ if (!pako$1.inflate) { // See https://github.com/nodeca/pako/issues/97
130501
130540
  pako$1 = pako$1.default;
130502
130541
  }
130503
130542
 
130504
- const tempVec4a$1 = math.vec4();
130505
- const tempVec4b$1 = math.vec4();
130543
+ const tempVec4a$2 = math.vec4();
130544
+ const tempVec4b$2 = math.vec4();
130506
130545
 
130507
130546
  function extract$1(elements) {
130508
130547
 
@@ -130586,7 +130625,7 @@ function inflate$1(deflatedData) {
130586
130625
  };
130587
130626
  }
130588
130627
 
130589
- const decompressColor$1 = (function () {
130628
+ const decompressColor$2 = (function () {
130590
130629
  const floatColor = new Float32Array(3);
130591
130630
  return function (intColor) {
130592
130631
  floatColor[0] = intColor[0] / 255.0;
@@ -130596,7 +130635,7 @@ const decompressColor$1 = (function () {
130596
130635
  };
130597
130636
  })();
130598
130637
 
130599
- function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130638
+ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130600
130639
 
130601
130640
  const modelPartId = manifestCtx.getNextId();
130602
130641
 
@@ -130758,7 +130797,7 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130758
130797
 
130759
130798
  const atLastGeometry = (geometryIndex === (numGeometries - 1));
130760
130799
 
130761
- const meshColor = decompressColor$1(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130800
+ const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130762
130801
  const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
130763
130802
  const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
130764
130803
  const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;
@@ -130845,15 +130884,15 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130845
130884
  const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions;
130846
130885
 
130847
130886
  for (let i = 0, len = decompressedPositions.length; i < len; i += 3) {
130848
- tempVec4a$1[0] = decompressedPositions[i + 0];
130849
- tempVec4a$1[1] = decompressedPositions[i + 1];
130850
- tempVec4a$1[2] = decompressedPositions[i + 2];
130851
- tempVec4a$1[3] = 1;
130852
- math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1);
130853
- geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1);
130854
- transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0];
130855
- transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1];
130856
- transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2];
130887
+ tempVec4a$2[0] = decompressedPositions[i + 0];
130888
+ tempVec4a$2[1] = decompressedPositions[i + 1];
130889
+ tempVec4a$2[2] = decompressedPositions[i + 2];
130890
+ tempVec4a$2[3] = 1;
130891
+ math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2);
130892
+ geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2);
130893
+ transformedAndRecompressedPositions[i + 0] = tempVec4a$2[0];
130894
+ transformedAndRecompressedPositions[i + 1] = tempVec4a$2[1];
130895
+ transformedAndRecompressedPositions[i + 2] = tempVec4a$2[2];
130857
130896
  }
130858
130897
 
130859
130898
  sceneModel.createMesh(utils.apply(meshDefaults, {
@@ -130993,7 +131032,7 @@ const ParserV9 = {
130993
131032
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
130994
131033
  const deflatedData = extract$1(elements);
130995
131034
  const inflatedData = inflate$1(deflatedData);
130996
- load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131035
+ load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
130997
131036
  }
130998
131037
  };
130999
131038
 
@@ -131006,10 +131045,10 @@ if (!pako.inflate) { // See https://github.com/nodeca/pako/issues/97
131006
131045
  pako = pako.default;
131007
131046
  }
131008
131047
 
131009
- const tempVec4a = math.vec4();
131010
- const tempVec4b = math.vec4();
131048
+ const tempVec4a$1 = math.vec4();
131049
+ const tempVec4b$1 = math.vec4();
131011
131050
 
131012
- const NUM_TEXTURE_ATTRIBUTES = 9;
131051
+ const NUM_TEXTURE_ATTRIBUTES$1 = 9;
131013
131052
 
131014
131053
  function extract(elements) {
131015
131054
 
@@ -131085,6 +131124,648 @@ function inflate(deflatedData) {
131085
131124
  };
131086
131125
  }
131087
131126
 
131127
+ const decompressColor$1 = (function () {
131128
+ const floatColor = new Float32Array(3);
131129
+ return function (intColor) {
131130
+ floatColor[0] = intColor[0] / 255.0;
131131
+ floatColor[1] = intColor[1] / 255.0;
131132
+ floatColor[2] = intColor[2] / 255.0;
131133
+ return floatColor;
131134
+ };
131135
+ })();
131136
+
131137
+ ((function () {
131138
+ const canvas = document.createElement('canvas');
131139
+ const context = canvas.getContext('2d');
131140
+ return function (imagedata) {
131141
+ canvas.width = imagedata.width;
131142
+ canvas.height = imagedata.height;
131143
+ context.putImageData(imagedata, 0, 0);
131144
+ return canvas.toDataURL();
131145
+ };
131146
+ }))();
131147
+
131148
+ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
131149
+
131150
+ const modelPartId = manifestCtx.getNextId();
131151
+
131152
+ const metadata = inflatedData.metadata;
131153
+ const textureData = inflatedData.textureData;
131154
+ const eachTextureDataPortion = inflatedData.eachTextureDataPortion;
131155
+ const eachTextureAttributes = inflatedData.eachTextureAttributes;
131156
+ const positions = inflatedData.positions;
131157
+ const normals = inflatedData.normals;
131158
+ const colors = inflatedData.colors;
131159
+ const uvs = inflatedData.uvs;
131160
+ const indices = inflatedData.indices;
131161
+ const edgeIndices = inflatedData.edgeIndices;
131162
+ const eachTextureSetTextures = inflatedData.eachTextureSetTextures;
131163
+ const matrices = inflatedData.matrices;
131164
+ const reusedGeometriesDecodeMatrix = inflatedData.reusedGeometriesDecodeMatrix;
131165
+ const eachGeometryPrimitiveType = inflatedData.eachGeometryPrimitiveType;
131166
+ const eachGeometryPositionsPortion = inflatedData.eachGeometryPositionsPortion;
131167
+ const eachGeometryNormalsPortion = inflatedData.eachGeometryNormalsPortion;
131168
+ const eachGeometryColorsPortion = inflatedData.eachGeometryColorsPortion;
131169
+ const eachGeometryUVsPortion = inflatedData.eachGeometryUVsPortion;
131170
+ const eachGeometryIndicesPortion = inflatedData.eachGeometryIndicesPortion;
131171
+ const eachGeometryEdgeIndicesPortion = inflatedData.eachGeometryEdgeIndicesPortion;
131172
+ const eachMeshGeometriesPortion = inflatedData.eachMeshGeometriesPortion;
131173
+ const eachMeshMatricesPortion = inflatedData.eachMeshMatricesPortion;
131174
+ const eachMeshTextureSet = inflatedData.eachMeshTextureSet;
131175
+ const eachMeshMaterialAttributes = inflatedData.eachMeshMaterialAttributes;
131176
+ const eachEntityId = inflatedData.eachEntityId;
131177
+ const eachEntityMeshesPortion = inflatedData.eachEntityMeshesPortion;
131178
+ const eachTileAABB = inflatedData.eachTileAABB;
131179
+ const eachTileEntitiesPortion = inflatedData.eachTileEntitiesPortion;
131180
+
131181
+ const numTextures = eachTextureDataPortion.length;
131182
+ const numTextureSets = eachTextureSetTextures.length / 5;
131183
+ const numGeometries = eachGeometryPositionsPortion.length;
131184
+ const numMeshes = eachMeshGeometriesPortion.length;
131185
+ const numEntities = eachEntityMeshesPortion.length;
131186
+ const numTiles = eachTileEntitiesPortion.length;
131187
+
131188
+ if (metaModel) {
131189
+ metaModel.loadData(metadata, {
131190
+ includeTypes: options.includeTypes,
131191
+ excludeTypes: options.excludeTypes,
131192
+ globalizeObjectIds: options.globalizeObjectIds
131193
+ }); // Can be empty
131194
+ }
131195
+
131196
+ // Create textures
131197
+
131198
+ for (let textureIndex = 0; textureIndex < numTextures; textureIndex++) {
131199
+ const atLastTexture = (textureIndex === (numTextures - 1));
131200
+ const textureDataPortionStart = eachTextureDataPortion[textureIndex];
131201
+ const textureDataPortionEnd = atLastTexture ? textureData.length : (eachTextureDataPortion[textureIndex + 1]);
131202
+
131203
+ const textureDataPortionSize = textureDataPortionEnd - textureDataPortionStart;
131204
+ const textureDataPortionExists = (textureDataPortionSize > 0);
131205
+
131206
+ const textureAttrBaseIdx = (textureIndex * NUM_TEXTURE_ATTRIBUTES$1);
131207
+
131208
+ const compressed = (eachTextureAttributes[textureAttrBaseIdx + 0] === 1);
131209
+ const mediaType = eachTextureAttributes[textureAttrBaseIdx + 1];
131210
+ eachTextureAttributes[textureAttrBaseIdx + 2];
131211
+ eachTextureAttributes[textureAttrBaseIdx + 3];
131212
+ const minFilter = eachTextureAttributes[textureAttrBaseIdx + 4];
131213
+ const magFilter = eachTextureAttributes[textureAttrBaseIdx + 5]; // LinearFilter | NearestFilter
131214
+ const wrapS = eachTextureAttributes[textureAttrBaseIdx + 6]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping
131215
+ const wrapT = eachTextureAttributes[textureAttrBaseIdx + 7]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping
131216
+ const wrapR = eachTextureAttributes[textureAttrBaseIdx + 8]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping
131217
+
131218
+ if (textureDataPortionExists) {
131219
+
131220
+ const imageDataSubarray = new Uint8Array(textureData.subarray(textureDataPortionStart, textureDataPortionEnd));
131221
+ const arrayBuffer = imageDataSubarray.buffer;
131222
+ const textureId = `${modelPartId}-texture-${textureIndex}`;
131223
+
131224
+ if (compressed) {
131225
+
131226
+ sceneModel.createTexture({
131227
+ id: textureId,
131228
+ buffers: [arrayBuffer],
131229
+ minFilter,
131230
+ magFilter,
131231
+ wrapS,
131232
+ wrapT,
131233
+ wrapR
131234
+ });
131235
+
131236
+ } else {
131237
+
131238
+ const mimeType = mediaType === JPEGMediaType ? "image/jpeg" : (mediaType === PNGMediaType ? "image/png" : "image/gif");
131239
+ const blob = new Blob([arrayBuffer], {type: mimeType});
131240
+ const urlCreator = window.URL || window.webkitURL;
131241
+ const imageUrl = urlCreator.createObjectURL(blob);
131242
+ const img = document.createElement('img');
131243
+ img.src = imageUrl;
131244
+
131245
+ sceneModel.createTexture({
131246
+ id: textureId,
131247
+ image: img,
131248
+ //mediaType,
131249
+ minFilter,
131250
+ magFilter,
131251
+ wrapS,
131252
+ wrapT,
131253
+ wrapR
131254
+ });
131255
+ }
131256
+ }
131257
+ }
131258
+
131259
+ // Create texture sets
131260
+
131261
+ for (let textureSetIndex = 0; textureSetIndex < numTextureSets; textureSetIndex++) {
131262
+ const eachTextureSetTexturesIndex = textureSetIndex * 5;
131263
+ const textureSetId = `${modelPartId}-textureSet-${textureSetIndex}`;
131264
+ const colorTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 0];
131265
+ const metallicRoughnessTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 1];
131266
+ const normalsTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 2];
131267
+ const emissiveTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 3];
131268
+ const occlusionTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 4];
131269
+ sceneModel.createTextureSet({
131270
+ id: textureSetId,
131271
+ colorTextureId: colorTextureIndex >= 0 ? `${modelPartId}-texture-${colorTextureIndex}` : null,
131272
+ normalsTextureId: normalsTextureIndex >= 0 ? `${modelPartId}-texture-${normalsTextureIndex}` : null,
131273
+ metallicRoughnessTextureId: metallicRoughnessTextureIndex >= 0 ? `${modelPartId}-texture-${metallicRoughnessTextureIndex}` : null,
131274
+ emissiveTextureId: emissiveTextureIndex >= 0 ? `${modelPartId}-texture-${emissiveTextureIndex}` : null,
131275
+ occlusionTextureId: occlusionTextureIndex >= 0 ? `${modelPartId}-texture-${occlusionTextureIndex}` : null
131276
+ });
131277
+ }
131278
+
131279
+ // Count instances of each geometry
131280
+
131281
+ const geometryReuseCounts = new Uint32Array(numGeometries);
131282
+
131283
+ for (let meshIndex = 0; meshIndex < numMeshes; meshIndex++) {
131284
+ const geometryIndex = eachMeshGeometriesPortion[meshIndex];
131285
+ if (geometryReuseCounts[geometryIndex] !== undefined) {
131286
+ geometryReuseCounts[geometryIndex]++;
131287
+ } else {
131288
+ geometryReuseCounts[geometryIndex] = 1;
131289
+ }
131290
+ }
131291
+
131292
+ // Iterate over tiles
131293
+
131294
+ const tileCenter = math.vec3();
131295
+ const rtcAABB = math.AABB3();
131296
+
131297
+ const geometryArraysCache = {};
131298
+
131299
+ for (let tileIndex = 0; tileIndex < numTiles; tileIndex++) {
131300
+
131301
+ const lastTileIndex = (numTiles - 1);
131302
+
131303
+ const atLastTile = (tileIndex === lastTileIndex);
131304
+
131305
+ const firstTileEntityIndex = eachTileEntitiesPortion [tileIndex];
131306
+ const lastTileEntityIndex = atLastTile ? (numEntities - 1) : (eachTileEntitiesPortion[tileIndex + 1] - 1);
131307
+
131308
+ const tileAABBIndex = tileIndex * 6;
131309
+ const tileAABB = eachTileAABB.subarray(tileAABBIndex, tileAABBIndex + 6);
131310
+
131311
+ math.getAABB3Center(tileAABB, tileCenter);
131312
+
131313
+ rtcAABB[0] = tileAABB[0] - tileCenter[0];
131314
+ rtcAABB[1] = tileAABB[1] - tileCenter[1];
131315
+ rtcAABB[2] = tileAABB[2] - tileCenter[2];
131316
+ rtcAABB[3] = tileAABB[3] - tileCenter[0];
131317
+ rtcAABB[4] = tileAABB[4] - tileCenter[1];
131318
+ rtcAABB[5] = tileAABB[5] - tileCenter[2];
131319
+
131320
+ const tileDecodeMatrix = geometryCompressionUtils.createPositionsDecodeMatrix(rtcAABB);
131321
+
131322
+ const geometryCreatedInTile = {};
131323
+
131324
+ // Iterate over each tile's entities
131325
+
131326
+ for (let tileEntityIndex = firstTileEntityIndex; tileEntityIndex <= lastTileEntityIndex; tileEntityIndex++) {
131327
+
131328
+ const xktEntityId = eachEntityId[tileEntityIndex];
131329
+
131330
+ const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId;
131331
+
131332
+ const finalTileEntityIndex = (numEntities - 1);
131333
+ const atLastTileEntity = (tileEntityIndex === finalTileEntityIndex);
131334
+ const firstMeshIndex = eachEntityMeshesPortion [tileEntityIndex];
131335
+ const lastMeshIndex = atLastTileEntity ? (eachMeshGeometriesPortion.length - 1) : (eachEntityMeshesPortion[tileEntityIndex + 1] - 1);
131336
+
131337
+ const meshIds = [];
131338
+
131339
+ const metaObject = viewer.metaScene.metaObjects[entityId];
131340
+ const entityDefaults = {};
131341
+ const meshDefaults = {};
131342
+
131343
+ if (metaObject) {
131344
+
131345
+ // Mask loading of object types
131346
+
131347
+ if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) {
131348
+ continue;
131349
+ }
131350
+
131351
+ if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) {
131352
+ continue;
131353
+ }
131354
+
131355
+ // Get initial property values for object types
131356
+
131357
+ const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
131358
+
131359
+ if (props) {
131360
+ if (props.visible === false) {
131361
+ entityDefaults.visible = false;
131362
+ }
131363
+ if (props.pickable === false) {
131364
+ entityDefaults.pickable = false;
131365
+ }
131366
+ if (props.colorize) {
131367
+ meshDefaults.color = props.colorize;
131368
+ }
131369
+ if (props.opacity !== undefined && props.opacity !== null) {
131370
+ meshDefaults.opacity = props.opacity;
131371
+ }
131372
+ if (props.metallic !== undefined && props.metallic !== null) {
131373
+ meshDefaults.metallic = props.metallic;
131374
+ }
131375
+ if (props.roughness !== undefined && props.roughness !== null) {
131376
+ meshDefaults.roughness = props.roughness;
131377
+ }
131378
+ }
131379
+
131380
+ } else {
131381
+ if (options.excludeUnclassifiedObjects) {
131382
+ continue;
131383
+ }
131384
+ }
131385
+
131386
+ // Iterate each entity's meshes
131387
+
131388
+ for (let meshIndex = firstMeshIndex; meshIndex <= lastMeshIndex; meshIndex++) {
131389
+
131390
+ const geometryIndex = eachMeshGeometriesPortion[meshIndex];
131391
+ const geometryReuseCount = geometryReuseCounts[geometryIndex];
131392
+ const isReusedGeometry = (geometryReuseCount > 1);
131393
+
131394
+ const atLastGeometry = (geometryIndex === (numGeometries - 1));
131395
+
131396
+ const textureSetIndex = eachMeshTextureSet[meshIndex];
131397
+
131398
+ const textureSetId = (textureSetIndex >= 0) ? `${modelPartId}-textureSet-${textureSetIndex}` : null;
131399
+
131400
+ const meshColor = decompressColor$1(eachMeshMaterialAttributes.subarray((meshIndex * 6), (meshIndex * 6) + 3));
131401
+ const meshOpacity = eachMeshMaterialAttributes[(meshIndex * 6) + 3] / 255.0;
131402
+ const meshMetallic = eachMeshMaterialAttributes[(meshIndex * 6) + 4] / 255.0;
131403
+ const meshRoughness = eachMeshMaterialAttributes[(meshIndex * 6) + 5] / 255.0;
131404
+
131405
+ const meshId = manifestCtx.getNextId();
131406
+
131407
+ if (isReusedGeometry) {
131408
+
131409
+ // Create mesh for multi-use geometry - create (or reuse) geometry, create mesh using that geometry
131410
+
131411
+ const meshMatrixIndex = eachMeshMatricesPortion[meshIndex];
131412
+ const meshMatrix = matrices.slice(meshMatrixIndex, meshMatrixIndex + 16);
131413
+
131414
+ const geometryId = `${modelPartId}-geometry.${tileIndex}.${geometryIndex}`; // These IDs are local to the SceneModel
131415
+
131416
+ let geometryArrays = geometryArraysCache[geometryId];
131417
+
131418
+ if (!geometryArrays) {
131419
+ geometryArrays = {
131420
+ batchThisMesh: (!options.reuseGeometries)
131421
+ };
131422
+ const primitiveType = eachGeometryPrimitiveType[geometryIndex];
131423
+ let geometryValid = false;
131424
+ switch (primitiveType) {
131425
+ case 0:
131426
+ geometryArrays.primitiveName = "solid";
131427
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131428
+ geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131429
+ geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131430
+ geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131431
+ geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131432
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131433
+ break;
131434
+ case 1:
131435
+ geometryArrays.primitiveName = "surface";
131436
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131437
+ geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131438
+ geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131439
+ geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131440
+ geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131441
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131442
+ break;
131443
+ case 2:
131444
+ geometryArrays.primitiveName = "points";
131445
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131446
+ geometryArrays.geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]);
131447
+ geometryValid = (geometryArrays.geometryPositions.length > 0);
131448
+ break;
131449
+ case 3:
131450
+ geometryArrays.primitiveName = "lines";
131451
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131452
+ geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131453
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131454
+ break;
131455
+ case 4:
131456
+ geometryArrays.primitiveName = "lines";
131457
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131458
+ geometryArrays.geometryIndices = lineStripToLines$1(
131459
+ geometryArrays.geometryPositions,
131460
+ indices.subarray(eachGeometryIndicesPortion [geometryIndex],
131461
+ atLastGeometry
131462
+ ? indices.length
131463
+ : eachGeometryIndicesPortion [geometryIndex + 1]));
131464
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131465
+ break;
131466
+ default:
131467
+ continue;
131468
+ }
131469
+
131470
+ if (!geometryValid) {
131471
+ geometryArrays = null;
131472
+ }
131473
+
131474
+ if (geometryArrays) {
131475
+ if (geometryArrays.geometryPositions.length > 1000) ;
131476
+ if (geometryArrays.batchThisMesh) {
131477
+ geometryArrays.decompressedPositions = new Float32Array(geometryArrays.geometryPositions.length);
131478
+ geometryArrays.transformedAndRecompressedPositions = new Uint16Array(geometryArrays.geometryPositions.length);
131479
+ const geometryPositions = geometryArrays.geometryPositions;
131480
+ const decompressedPositions = geometryArrays.decompressedPositions;
131481
+ for (let i = 0, len = geometryPositions.length; i < len; i += 3) {
131482
+ decompressedPositions[i + 0] = geometryPositions[i + 0] * reusedGeometriesDecodeMatrix[0] + reusedGeometriesDecodeMatrix[12];
131483
+ decompressedPositions[i + 1] = geometryPositions[i + 1] * reusedGeometriesDecodeMatrix[5] + reusedGeometriesDecodeMatrix[13];
131484
+ decompressedPositions[i + 2] = geometryPositions[i + 2] * reusedGeometriesDecodeMatrix[10] + reusedGeometriesDecodeMatrix[14];
131485
+ }
131486
+ geometryArrays.geometryPositions = null;
131487
+ geometryArraysCache[geometryId] = geometryArrays;
131488
+ }
131489
+ }
131490
+ }
131491
+
131492
+ if (geometryArrays) {
131493
+
131494
+ if (geometryArrays.batchThisMesh) {
131495
+
131496
+ const decompressedPositions = geometryArrays.decompressedPositions;
131497
+ const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions;
131498
+
131499
+ for (let i = 0, len = decompressedPositions.length; i < len; i += 3) {
131500
+ tempVec4a$1[0] = decompressedPositions[i + 0];
131501
+ tempVec4a$1[1] = decompressedPositions[i + 1];
131502
+ tempVec4a$1[2] = decompressedPositions[i + 2];
131503
+ tempVec4a$1[3] = 1;
131504
+ math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1);
131505
+ geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1);
131506
+ transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0];
131507
+ transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1];
131508
+ transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2];
131509
+ }
131510
+
131511
+ sceneModel.createMesh(utils.apply(meshDefaults, {
131512
+ id: meshId,
131513
+ textureSetId,
131514
+ origin: tileCenter,
131515
+ primitive: geometryArrays.primitiveName,
131516
+ positionsCompressed: transformedAndRecompressedPositions,
131517
+ normalsCompressed: geometryArrays.geometryNormals,
131518
+ uv: geometryArrays.geometryUVs,
131519
+ colorsCompressed: geometryArrays.geometryColors,
131520
+ indices: geometryArrays.geometryIndices,
131521
+ edgeIndices: geometryArrays.geometryEdgeIndices,
131522
+ positionsDecodeMatrix: tileDecodeMatrix,
131523
+ color: meshColor,
131524
+ metallic: meshMetallic,
131525
+ roughness: meshRoughness,
131526
+ opacity: meshOpacity
131527
+ }));
131528
+
131529
+ meshIds.push(meshId);
131530
+
131531
+ } else {
131532
+
131533
+ if (!geometryCreatedInTile[geometryId]) {
131534
+
131535
+ sceneModel.createGeometry({
131536
+ id: geometryId,
131537
+ primitive: geometryArrays.primitiveName,
131538
+ positionsCompressed: geometryArrays.geometryPositions,
131539
+ normalsCompressed: geometryArrays.geometryNormals,
131540
+ uv: geometryArrays.geometryUVs,
131541
+ colorsCompressed: geometryArrays.geometryColors,
131542
+ indices: geometryArrays.geometryIndices,
131543
+ edgeIndices: geometryArrays.geometryEdgeIndices,
131544
+ positionsDecodeMatrix: reusedGeometriesDecodeMatrix
131545
+ });
131546
+
131547
+ geometryCreatedInTile[geometryId] = true;
131548
+ }
131549
+
131550
+ sceneModel.createMesh(utils.apply(meshDefaults, {
131551
+ id: meshId,
131552
+ geometryId,
131553
+ textureSetId,
131554
+ matrix: meshMatrix,
131555
+ color: meshColor,
131556
+ metallic: meshMetallic,
131557
+ roughness: meshRoughness,
131558
+ opacity: meshOpacity,
131559
+ origin: tileCenter
131560
+ }));
131561
+
131562
+ meshIds.push(meshId);
131563
+ }
131564
+ }
131565
+
131566
+ } else { // Do not reuse geometry
131567
+
131568
+ const primitiveType = eachGeometryPrimitiveType[geometryIndex];
131569
+
131570
+ let primitiveName;
131571
+ let geometryPositions;
131572
+ let geometryNormals;
131573
+ let geometryUVs;
131574
+ let geometryColors;
131575
+ let geometryIndices;
131576
+ let geometryEdgeIndices;
131577
+ let geometryValid = false;
131578
+
131579
+ switch (primitiveType) {
131580
+ case 0:
131581
+ primitiveName = "solid";
131582
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131583
+ geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131584
+ geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131585
+ geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131586
+ geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131587
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131588
+ break;
131589
+ case 1:
131590
+ primitiveName = "surface";
131591
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131592
+ geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131593
+ geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131594
+ geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131595
+ geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131596
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131597
+ break;
131598
+ case 2:
131599
+ primitiveName = "points";
131600
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131601
+ geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]);
131602
+ geometryValid = (geometryPositions.length > 0);
131603
+ break;
131604
+ case 3:
131605
+ primitiveName = "lines";
131606
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131607
+ geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131608
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131609
+ break;
131610
+ case 4:
131611
+ primitiveName = "lines";
131612
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131613
+ geometryIndices = lineStripToLines$1(
131614
+ geometryPositions,
131615
+ indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry
131616
+ ? indices.length
131617
+ : eachGeometryIndicesPortion [geometryIndex + 1]));
131618
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131619
+ break;
131620
+ default:
131621
+ continue;
131622
+ }
131623
+
131624
+ if (geometryValid) {
131625
+
131626
+ sceneModel.createMesh(utils.apply(meshDefaults, {
131627
+ id: meshId,
131628
+ textureSetId,
131629
+ origin: tileCenter,
131630
+ primitive: primitiveName,
131631
+ positionsCompressed: geometryPositions,
131632
+ normalsCompressed: geometryNormals,
131633
+ uv: geometryUVs && geometryUVs.length > 0 ? geometryUVs : null,
131634
+ colorsCompressed: geometryColors,
131635
+ indices: geometryIndices,
131636
+ edgeIndices: geometryEdgeIndices,
131637
+ positionsDecodeMatrix: tileDecodeMatrix,
131638
+ color: meshColor,
131639
+ metallic: meshMetallic,
131640
+ roughness: meshRoughness,
131641
+ opacity: meshOpacity
131642
+ }));
131643
+
131644
+ meshIds.push(meshId);
131645
+ }
131646
+ }
131647
+ }
131648
+
131649
+ if (meshIds.length > 0) {
131650
+
131651
+ sceneModel.createEntity(utils.apply(entityDefaults, {
131652
+ id: entityId,
131653
+ isObject: true,
131654
+ meshIds: meshIds
131655
+ }));
131656
+ }
131657
+ }
131658
+ }
131659
+ }
131660
+
131661
+ function lineStripToLines$1(positions, indices) {
131662
+ const linesIndices = [];
131663
+ if (indices.length > 1) {
131664
+ for (let i = 0, len = indices.length - 1; i < len; i++) {
131665
+ linesIndices.push(indices[i]);
131666
+ linesIndices.push(indices[i + 1]);
131667
+ }
131668
+ } else if (positions.length > 1) {
131669
+ for (let i = 0, len = (positions.length / 3) - 1; i < len; i++) {
131670
+ linesIndices.push(i);
131671
+ linesIndices.push(i + 1);
131672
+ }
131673
+ }
131674
+ return linesIndices;
131675
+ }
131676
+
131677
+ /** @private */
131678
+ const ParserV10 = {
131679
+ version: 10,
131680
+ parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
131681
+ const deflatedData = extract(elements);
131682
+ const inflatedData = inflate(deflatedData);
131683
+ load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131684
+ }
131685
+ };
131686
+
131687
+ /*
131688
+ Parser for .XKT Format V11
131689
+ */
131690
+
131691
+ const tempVec4a = math.vec4();
131692
+ const tempVec4b = math.vec4();
131693
+
131694
+ const NUM_TEXTURE_ATTRIBUTES = 9;
131695
+
131696
+ function decodeData(arrayBuffer) {
131697
+ const requiresSwapFromLittleEndian = (function() {
131698
+ const buffer = new ArrayBuffer(2);
131699
+ new Uint16Array(buffer)[0] = 1;
131700
+ return new Uint8Array(buffer)[0] !== 1;
131701
+ })();
131702
+
131703
+ const nextArray = (function() {
131704
+ let i = 0;
131705
+ const dataView = new DataView(arrayBuffer);
131706
+ return function(type) {
131707
+ const idx = 1 + 2 * i++; // `1' for the version nr
131708
+ const byteOffset = dataView.getUint32(idx * 4, true);
131709
+ const byteLength = dataView.getUint32((idx + 1) * 4, true);
131710
+
131711
+ const BPE = type.BYTES_PER_ELEMENT;
131712
+ if (requiresSwapFromLittleEndian && (BPE > 1)) {
131713
+ const subarray = new Uint8Array(arrayBuffer, byteOffset, byteLength);
131714
+ const swaps = BPE / 2;
131715
+ const cnt = subarray.length / BPE;
131716
+ for (let b = 0; b < cnt; b++) {
131717
+ const offset = b * BPE;
131718
+ for (let j = 0; j < swaps; j++) {
131719
+ const i1 = offset + j;
131720
+ const i2 = offset - j + BPE - 1;
131721
+ const tmp = subarray[i1];
131722
+ subarray[i1] = subarray[i2];
131723
+ subarray[i2] = tmp;
131724
+ }
131725
+ }
131726
+ }
131727
+
131728
+ return new type(arrayBuffer, byteOffset, byteLength / BPE);
131729
+ };
131730
+ })();
131731
+
131732
+ const nextObject = (function() {
131733
+ const decoder = new TextDecoder();
131734
+ return () => JSON.parse(decoder.decode(nextArray(Uint8Array)));
131735
+ })();
131736
+
131737
+ return {
131738
+ metadata: nextObject(),
131739
+ textureData: nextArray(Uint8Array), // <<----------------------------- ??? ZIPPing to blame?
131740
+ eachTextureDataPortion: nextArray(Uint32Array),
131741
+ eachTextureAttributes: nextArray(Uint16Array),
131742
+ positions: nextArray(Uint16Array),
131743
+ normals: nextArray(Int8Array),
131744
+ colors: nextArray(Uint8Array),
131745
+ uvs: nextArray(Float32Array),
131746
+ indices: nextArray(Uint32Array),
131747
+ edgeIndices: nextArray(Uint32Array),
131748
+ eachTextureSetTextures: nextArray(Int32Array),
131749
+ matrices: nextArray(Float32Array),
131750
+ reusedGeometriesDecodeMatrix: nextArray(Float32Array),
131751
+ eachGeometryPrimitiveType: nextArray(Uint8Array),
131752
+ eachGeometryPositionsPortion: nextArray(Uint32Array),
131753
+ eachGeometryNormalsPortion: nextArray(Uint32Array),
131754
+ eachGeometryColorsPortion: nextArray(Uint32Array),
131755
+ eachGeometryUVsPortion: nextArray(Uint32Array),
131756
+ eachGeometryIndicesPortion: nextArray(Uint32Array),
131757
+ eachGeometryEdgeIndicesPortion: nextArray(Uint32Array),
131758
+ eachMeshGeometriesPortion: nextArray(Uint32Array),
131759
+ eachMeshMatricesPortion: nextArray(Uint32Array),
131760
+ eachMeshTextureSet: nextArray(Int32Array), // Can be -1
131761
+ eachMeshMaterialAttributes: nextArray(Uint8Array),
131762
+ eachEntityId: nextObject(),
131763
+ eachEntityMeshesPortion: nextArray(Uint32Array),
131764
+ eachTileAABB: nextArray(Float64Array),
131765
+ eachTileEntitiesPortion: nextArray(Uint32Array),
131766
+ };
131767
+ }
131768
+
131088
131769
  const decompressColor = (function () {
131089
131770
  const floatColor = new Float32Array(3);
131090
131771
  return function (intColor) {
@@ -131636,11 +132317,15 @@ function lineStripToLines(positions, indices) {
131636
132317
  }
131637
132318
 
131638
132319
  /** @private */
131639
- const ParserV10 = {
131640
- version: 10,
131641
- parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
131642
- const deflatedData = extract(elements);
131643
- const inflatedData = inflate(deflatedData);
132320
+ // V11 uses a single uncompressed Uint8Array buffer to store arrays of different types.
132321
+ // To efficiently create typed arrays from this buffer,
132322
+ // each typed array's source data needs to be aligned with its element byte size.
132323
+ // This sometimes requires padding subarrays inside the single Uint8Array, so the byteOffset needs to be stored alongside element count.
132324
+ // It is a different encoding than used in earlier versions, and requires different approach to parsing elements.
132325
+ const ParserV11 = {
132326
+ version: 11,
132327
+ parseArrayBuffer: function (viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx) {
132328
+ const inflatedData = decodeData(arrayBuffer);
131644
132329
  load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131645
132330
  }
131646
132331
  };
@@ -131657,6 +132342,7 @@ parsers[ParserV7.version] = ParserV7;
131657
132342
  parsers[ParserV8.version] = ParserV8;
131658
132343
  parsers[ParserV9.version] = ParserV9;
131659
132344
  parsers[ParserV10.version] = ParserV10;
132345
+ parsers[ParserV11.version] = ParserV11;
131660
132346
 
131661
132347
  /**
131662
132348
  * {@link Viewer} plugin that loads models from xeokit's optimized *````.XKT````* format.
@@ -132774,6 +133460,12 @@ class XKTLoaderPlugin extends Plugin {
132774
133460
  return;
132775
133461
  }
132776
133462
  // this.log("Loading .xkt V" + xktVersion);
133463
+
133464
+ if (parser.parseArrayBuffer) {
133465
+ parser.parseArrayBuffer(this.viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx);
133466
+ return;
133467
+ }
133468
+
132777
133469
  const numElements = dataView.getUint32(4, true);
132778
133470
  const elements = [];
132779
133471
  let byteOffset = (numElements + 2) * 4;
@@ -139223,7 +139915,6 @@ class DotBIMLoaderPlugin extends Plugin {
139223
139915
  const fileData = ctx.fileData;
139224
139916
  const sceneModel = ctx.sceneModel;
139225
139917
 
139226
- const dbMeshIndices = {};
139227
139918
  const dbMeshLoaded = {};
139228
139919
 
139229
139920
  const ifcProjectId = math.createUUID();
@@ -139261,17 +139952,14 @@ class DotBIMLoaderPlugin extends Plugin {
139261
139952
  propertySets: []
139262
139953
  };
139263
139954
 
139264
- for (let i = 0, len = fileData.meshes.length; i < len; i++) {
139265
- const dbMesh = fileData.meshes[i];
139266
- dbMeshIndices[dbMesh.mesh_id] = i;
139267
- }
139268
-
139269
- const parseDBMesh = (dbMeshId) => {
139955
+ const parseDBMesh = (dbMeshId, element) => {
139270
139956
  if (dbMeshLoaded[dbMeshId]) {
139271
139957
  return;
139272
139958
  }
139273
- const dbMeshIndex = dbMeshIndices[dbMeshId];
139274
- const dbMesh = fileData.meshes[dbMeshIndex];
139959
+
139960
+ const dbMesh = fileData.meshes.find(obj => {
139961
+ return obj.mesh_id === element.mesh_id;
139962
+ });
139275
139963
  sceneModel.createGeometry({
139276
139964
  id: dbMeshId,
139277
139965
  primitive: "triangles",
@@ -139310,7 +139998,7 @@ class DotBIMLoaderPlugin extends Plugin {
139310
139998
 
139311
139999
  if (element.face_colors === undefined) {
139312
140000
 
139313
- parseDBMesh(dbMeshId);
140001
+ parseDBMesh(dbMeshId, element);
139314
140002
 
139315
140003
  const meshId = `${objectId}-mesh`;
139316
140004
 
@@ -139353,7 +140041,9 @@ class DotBIMLoaderPlugin extends Plugin {
139353
140041
  let faceColors = element.face_colors;
139354
140042
  let coloredTrianglesDictionary = {};
139355
140043
  let currentTriangleIndicesCount = 0;
139356
- let dbMesh = fileData.meshes[element.mesh_id];
140044
+ let dbMesh = fileData.meshes.find(obj => {
140045
+ return obj.mesh_id === element.mesh_id;
140046
+ });
139357
140047
  for (let i = 0, len = faceColors.length; i < len; i+=4) {
139358
140048
  let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
139359
140049
  if (coloredTrianglesDictionary[faceColor] === undefined) {
@@ -139839,7 +140529,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
139839
140529
  const copyCanvasPos = (event, vec2) => {
139840
140530
  vec2[0] = event.clientX;
139841
140531
  vec2[1] = event.clientY;
139842
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
140532
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
139843
140533
  return vec2;
139844
140534
  };
139845
140535
 
@@ -139914,7 +140604,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
139914
140604
  const copyCanvasPos = (event, vec2) => {
139915
140605
  vec2[0] = event.clientX;
139916
140606
  vec2[1] = event.clientY;
139917
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
140607
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
139918
140608
  return vec2;
139919
140609
  };
139920
140610
 
@@ -141208,7 +141898,7 @@ class ZoneTranslateControl extends Component {
141208
141898
  const copyCanvasPos = (event, vec2) => {
141209
141899
  vec2[0] = event.clientX;
141210
141900
  vec2[1] = event.clientY;
141211
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
141901
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
141212
141902
  return vec2;
141213
141903
  };
141214
141904