@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
@@ -10687,8 +10687,8 @@ class SceneModelEntity {
10687
10687
  }
10688
10688
  }
10689
10689
 
10690
- const tempVec4a$a = math.vec4();
10691
- const tempVec4b$6 = math.vec4();
10690
+ const tempVec4a$b = math.vec4();
10691
+ const tempVec4b$7 = math.vec4();
10692
10692
 
10693
10693
 
10694
10694
  /**
@@ -10847,12 +10847,12 @@ class Marker extends Component {
10847
10847
  this.fire("viewPos", this._viewPos);
10848
10848
  }
10849
10849
  if (this._canvasPosDirty) {
10850
- tempVec4a$a.set(this._viewPos);
10851
- tempVec4a$a[3] = 1.0;
10852
- math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$a, tempVec4b$6);
10850
+ tempVec4a$b.set(this._viewPos);
10851
+ tempVec4a$b[3] = 1.0;
10852
+ math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$b, tempVec4b$7);
10853
10853
  const aabb = this.scene.canvas.boundary;
10854
- this._canvasPos[0] = Math.floor((1 + tempVec4b$6[0] / tempVec4b$6[3]) * aabb[2] / 2);
10855
- this._canvasPos[1] = Math.floor((1 - tempVec4b$6[1] / tempVec4b$6[3]) * aabb[3] / 2);
10854
+ this._canvasPos[0] = Math.floor((1 + tempVec4b$7[0] / tempVec4b$7[3]) * aabb[2] / 2);
10855
+ this._canvasPos[1] = Math.floor((1 - tempVec4b$7[1] / tempVec4b$7[3]) * aabb[3] / 2);
10856
10856
  this._canvasPosDirty = false;
10857
10857
  this.fire("canvasPos", this._canvasPos);
10858
10858
  }
@@ -11183,7 +11183,7 @@ function activateDraggableDot(dot, cfg) {
11183
11183
 
11184
11184
  const onChange = event => {
11185
11185
  const canvasPos = math.vec2([ event.clientX, event.clientY ]);
11186
- transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
11186
+ transformToNode(canvas.ownerDocument.documentElement, canvas, canvasPos);
11187
11187
  onMove(canvasPos, pickWorldPos(canvasPos));
11188
11188
  };
11189
11189
 
@@ -12692,7 +12692,6 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12692
12692
 
12693
12693
  _initMarkerDiv() {
12694
12694
  const markerDiv = document.createElement('div');
12695
- markerDiv.setAttribute('id', 'myMarkerDiv');
12696
12695
  const canvas = this.scene.canvas.canvas;
12697
12696
  canvas.parentNode.insertBefore(markerDiv, canvas);
12698
12697
 
@@ -12713,8 +12712,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12713
12712
 
12714
12713
  _destroyMarkerDiv() {
12715
12714
  if (this.markerDiv) {
12716
- const element = document.getElementById('myMarkerDiv');
12717
- element.parentNode.removeChild(element);
12715
+ this.markerDiv.parentNode.removeChild(this.markerDiv);
12718
12716
  this.markerDiv = null;
12719
12717
  }
12720
12718
  }
@@ -23522,8 +23520,8 @@ const tempVec3c$u = math.vec3();
23522
23520
  const tempVec3d$d = math.vec3();
23523
23521
  const tempVec3e$2 = math.vec3();
23524
23522
  const tempVec3f$2 = math.vec3();
23525
- const tempVec4a$9 = math.vec4();
23526
- const tempVec4b$5 = math.vec4();
23523
+ const tempVec4a$a = math.vec4();
23524
+ const tempVec4b$6 = math.vec4();
23527
23525
  const tempVec4c$2 = math.vec4();
23528
23526
  const tempMat = math.mat4();
23529
23527
  const tempMatb = math.mat4();
@@ -24388,8 +24386,8 @@ class Camera extends Component {
24388
24386
  * @returns {[number, number]} the canvas position
24389
24387
  */
24390
24388
  projectWorldPos(worldPos) {
24391
- const _worldPos = tempVec4a$9;
24392
- const viewPos = tempVec4b$5;
24389
+ const _worldPos = tempVec4a$a;
24390
+ const viewPos = tempVec4b$6;
24393
24391
  const screenPos = tempVec4c$2;
24394
24392
  _worldPos[0] = worldPos[0];
24395
24393
  _worldPos[1] = worldPos[1];
@@ -53652,17 +53650,6 @@ class TrianglesDepthRenderer$1 extends TrianglesBatchingRenderer {
53652
53650
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
53653
53651
  }
53654
53652
  }
53655
- src.push("const float packUpScale = 256. / 255.;");
53656
- src.push("const float unpackDownscale = 255. / 256.;");
53657
- src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
53658
- src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");
53659
- src.push("const float shiftRight8 = 1.0 / 256.;");
53660
-
53661
- src.push("vec4 packDepthToRGBA( const in float v ) {");
53662
- src.push(" vec4 r = vec4( fract( v * packFactors ), v );");
53663
- src.push(" r.yzw -= r.xyz * shiftRight8;");
53664
- src.push(" return r * packUpScale;");
53665
- src.push("}");
53666
53653
  src.push("in vec2 vHighPrecisionZW;");
53667
53654
  src.push("out vec4 outColor;");
53668
53655
  src.push("void main(void) {");
@@ -56196,7 +56183,7 @@ function octDecodeVec2(oct) { // Decode an oct-encoded normal
56196
56183
 
56197
56184
  const tempMat4$1 = math.mat4();
56198
56185
  const tempMat4b = math.mat4();
56199
- const tempVec4a$8 = math.vec4([0, 0, 0, 1]);
56186
+ const tempVec4a$9 = math.vec4([0, 0, 0, 1]);
56200
56187
 
56201
56188
  const tempVec3a$z = math.vec3();
56202
56189
  const tempVec3b$v = math.vec3();
@@ -57005,7 +56992,7 @@ class VBOBatchingTrianglesLayer {
57005
56992
  const offsetX = origin[0] ;
57006
56993
  const offsetY = origin[1] ;
57007
56994
  const offsetZ = origin[2] ;
57008
- const worldPos = tempVec4a$8;
56995
+ const worldPos = tempVec4a$9;
57009
56996
  const sceneModelMatrix = this.model.matrix;
57010
56997
  const positionsDecodeMatrix = state.positionsDecodeMatrix;
57011
56998
  for (let i = 0, len = positions.length; i < len; i += 3) {
@@ -61368,7 +61355,7 @@ function getRenderers$6(scene) {
61368
61355
 
61369
61356
  const tempUint8Vec4$2 = new Uint8Array(4);
61370
61357
  const tempFloat32$2 = new Float32Array(1);
61371
- const tempVec4a$7 = math.vec4([0, 0, 0, 1]);
61358
+ const tempVec4a$8 = math.vec4([0, 0, 0, 1]);
61372
61359
  const tempVec3fa$2 = new Float32Array(3);
61373
61360
 
61374
61361
  const tempVec3a$w = math.vec3();
@@ -62072,7 +62059,7 @@ class VBOInstancingTrianglesLayer {
62072
62059
  const offsetX = origin[0];
62073
62060
  const offsetY = origin[1];
62074
62061
  const offsetZ = origin[2];
62075
- const worldPos = tempVec4a$7;
62062
+ const worldPos = tempVec4a$8;
62076
62063
  const portionMatrix = portion.matrix;
62077
62064
  const sceneModelMatrix = this.model.matrix;
62078
62065
  const positionsDecodeMatrix = state.positionsDecodeMatrix;
@@ -72778,7 +72765,7 @@ const tempVec3b$i = math.vec3();
72778
72765
  const tempVec3c$e = math.vec3();
72779
72766
  math.vec3();
72780
72767
 
72781
- const tempVec4a$6 = math.vec4();
72768
+ const tempVec4a$7 = math.vec4();
72782
72769
 
72783
72770
  const tempMat4a$c = math.mat4();
72784
72771
 
@@ -73057,11 +73044,11 @@ class DTXTrianglesColorRenderer {
73057
73044
  if (saoEnabled) {
73058
73045
  const viewportWidth = gl.drawingBufferWidth;
73059
73046
  const viewportHeight = gl.drawingBufferHeight;
73060
- tempVec4a$6[0] = viewportWidth;
73061
- tempVec4a$6[1] = viewportHeight;
73062
- tempVec4a$6[2] = sao.blendCutoff;
73063
- tempVec4a$6[3] = sao.blendFactor;
73064
- gl.uniform4fv(this._uSAOParams, tempVec4a$6);
73047
+ tempVec4a$7[0] = viewportWidth;
73048
+ tempVec4a$7[1] = viewportHeight;
73049
+ tempVec4a$7[2] = sao.blendCutoff;
73050
+ tempVec4a$7[3] = sao.blendFactor;
73051
+ gl.uniform4fv(this._uSAOParams, tempVec4a$7);
73065
73052
  this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, 10);
73066
73053
  }
73067
73054
  }
@@ -74720,6 +74707,12 @@ class DTXTrianglesPickMeshRenderer {
74720
74707
  const textureState = state.textureState;
74721
74708
  const origin = dataTextureLayer._state.origin;
74722
74709
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
74710
+
74711
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
74712
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
74713
+ const eye = frameCtx.pickOrigin || camera.eye;
74714
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
74715
+
74723
74716
  textureState.bindCommonTextures(
74724
74717
  this._program,
74725
74718
  this.uTexturePerObjectPositionsDecodeMatrix,
@@ -74746,24 +74739,24 @@ class DTXTrianglesPickMeshRenderer {
74746
74739
  rtcOrigin[0] += position[0];
74747
74740
  rtcOrigin[1] += position[1];
74748
74741
  rtcOrigin[2] += position[2];
74749
- rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$8);
74742
+ rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$8);
74750
74743
  rtcCameraEye = tempVec3c$c;
74751
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
74752
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
74753
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
74744
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
74745
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
74746
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
74754
74747
  } else {
74755
- rtcViewMatrix = camera.viewMatrix;
74756
- rtcCameraEye = camera.eye;
74748
+ rtcViewMatrix = viewMatrix;
74749
+ rtcCameraEye = eye;
74757
74750
  }
74758
74751
  gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
74759
74752
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
74760
74753
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
74761
74754
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
74762
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
74755
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
74763
74756
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
74764
74757
  gl.uniform1i(this._uRenderPass, renderPass);
74765
74758
  if (scene.logarithmicDepthBufferEnabled) {
74766
- const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
74759
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
74767
74760
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
74768
74761
  }
74769
74762
  const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
@@ -75140,7 +75133,11 @@ class DTXTrianglesPickDepthRenderer {
75140
75133
  const textureState = state.textureState;
75141
75134
  const origin = dataTextureLayer._state.origin;
75142
75135
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
75136
+
75143
75137
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
75138
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
75139
+ const eye = frameCtx.pickOrigin || camera.eye;
75140
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
75144
75141
 
75145
75142
  if (!this._program) {
75146
75143
  this._allocate();
@@ -75180,15 +75177,15 @@ class DTXTrianglesPickDepthRenderer {
75180
75177
  rtcOrigin[2] += position[2];
75181
75178
  rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$7);
75182
75179
  rtcCameraEye = tempVec3c$b;
75183
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
75184
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
75185
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
75180
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
75181
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
75182
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
75186
75183
  frameCtx.snapPickOrigin[0] = rtcOrigin[0];
75187
75184
  frameCtx.snapPickOrigin[1] = rtcOrigin[1];
75188
75185
  frameCtx.snapPickOrigin[2] = rtcOrigin[2];
75189
75186
  } else {
75190
75187
  rtcViewMatrix = viewMatrix;
75191
- rtcCameraEye = camera.eye;
75188
+ rtcCameraEye = eye;
75192
75189
  frameCtx.snapPickOrigin[0] = 0;
75193
75190
  frameCtx.snapPickOrigin[1] = 0;
75194
75191
  frameCtx.snapPickOrigin[2] = 0;
@@ -75203,9 +75200,9 @@ class DTXTrianglesPickDepthRenderer {
75203
75200
  gl.uniform1f(this._uPickZFar, frameCtx.pickZFar);
75204
75201
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
75205
75202
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
75206
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
75203
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
75207
75204
  if (scene.logarithmicDepthBufferEnabled) {
75208
- const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
75205
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
75209
75206
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
75210
75207
  }
75211
75208
 
@@ -77715,6 +77712,11 @@ class DTXTrianglesPickNormalsFlatRenderer {
77715
77712
  this._bindProgram(frameCtx, state);
77716
77713
  }
77717
77714
 
77715
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
77716
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
77717
+ const eye = frameCtx.pickOrigin || camera.eye;
77718
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
77719
+
77718
77720
  textureState.bindCommonTextures(
77719
77721
  this._program,
77720
77722
  this.uTexturePerObjectPositionsDecodeMatrix,
@@ -77743,24 +77745,24 @@ class DTXTrianglesPickNormalsFlatRenderer {
77743
77745
  rtcOrigin[0] += position[0];
77744
77746
  rtcOrigin[1] += position[1];
77745
77747
  rtcOrigin[2] += position[2];
77746
- rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$1);
77748
+ rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$1);
77747
77749
  rtcCameraEye = tempVec3c$5;
77748
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
77749
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
77750
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
77750
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
77751
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
77752
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
77751
77753
  } else {
77752
- rtcViewMatrix = camera.viewMatrix; // TODO: make pickMatrix
77753
- rtcCameraEye = camera.eye;
77754
+ rtcViewMatrix = viewMatrix;
77755
+ rtcCameraEye = eye;
77754
77756
  }
77755
77757
  gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
77756
77758
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
77757
77759
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
77758
77760
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
77759
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); // TODO: pickProjMatrix
77761
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
77760
77762
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
77761
77763
  gl.uniform1i(this._uRenderPass, renderPass);
77762
77764
  if (scene.logarithmicDepthBufferEnabled) {
77763
- const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
77765
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
77764
77766
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
77765
77767
  }
77766
77768
  const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
@@ -79304,7 +79306,7 @@ const INDICES_EDGE_INDICES_ALIGNEMENT_SIZE = 8;
79304
79306
  */
79305
79307
  const MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE = 10;
79306
79308
 
79307
- const tempVec4a$5 = math.vec4();
79309
+ const tempVec4a$6 = math.vec4();
79308
79310
  const tempMat4a = new Float32Array(16);
79309
79311
  const tempUint8Array4 = new Uint8Array(4);
79310
79312
  const tempFloat32Array3 = new Float32Array(3);
@@ -80381,7 +80383,7 @@ class DTXTrianglesLayer {
80381
80383
  const offsetX = origin[0] ;
80382
80384
  const offsetY = origin[1] ;
80383
80385
  const offsetZ = origin[2] ;
80384
- const worldPos = tempVec4a$5;
80386
+ const worldPos = tempVec4a$6;
80385
80387
  for (let i = 0, len = positions.length; i < len; i += 3) {
80386
80388
  worldPos[0] = positions[i];
80387
80389
  worldPos[1] = positions[i + 1];
@@ -89154,7 +89156,6 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
89154
89156
 
89155
89157
  _initMarkerDiv() {
89156
89158
  const markerDiv = document.createElement('div');
89157
- markerDiv.setAttribute('id', 'myMarkerDiv');
89158
89159
  const canvas = this.scene.canvas.canvas;
89159
89160
  canvas.parentNode.insertBefore(markerDiv, canvas);
89160
89161
  markerDiv.style.background = "black";
@@ -89174,8 +89175,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
89174
89175
 
89175
89176
  _destroyMarkerDiv() {
89176
89177
  if (this._markerDiv) {
89177
- const element = document.getElementById('myMarkerDiv');
89178
- element.parentNode.removeChild(element);
89178
+ this._markerDiv.parentNode.removeChild(this._markerDiv);
89179
89179
  this._markerDiv = null;
89180
89180
  }
89181
89181
  }
@@ -90220,8 +90220,13 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90220
90220
  }
90221
90221
 
90222
90222
  const touch = event.touches[0];
90223
- const touchX = touch.clientX;
90224
- const touchY = touch.clientY;
90223
+
90224
+ // Get the canvas's bounding rectangle
90225
+ const rect = canvas.getBoundingClientRect();
90226
+
90227
+ // Calculate the touch position relative to the canvas
90228
+ const touchX = touch.clientX - rect.left;
90229
+ const touchY = touch.clientY - rect.top;
90225
90230
 
90226
90231
  touchStartCanvasPos.set([touchX, touchY]);
90227
90232
  touchMoveCanvasPos.set([touchX, touchY]);
@@ -90429,9 +90434,14 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90429
90434
  }
90430
90435
 
90431
90436
  const touch = event.touches[0];
90432
- const touchX = touch.clientX;
90433
- const touchY = touch.clientY;
90434
90437
 
90438
+ // Get the canvas's bounding rectangle
90439
+ const rect = canvas.getBoundingClientRect();
90440
+
90441
+ // Calculate the touch position relative to the canvas
90442
+ const touchX = touch.clientX - rect.left;
90443
+ const touchY = touch.clientY - rect.top;
90444
+
90435
90445
  if (touch.identifier !== touchId) {
90436
90446
  return;
90437
90447
  }
@@ -90598,8 +90608,13 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90598
90608
  }
90599
90609
 
90600
90610
  const touch = event.changedTouches[0];
90601
- const touchX = touch.clientX;
90602
- const touchY = touch.clientY;
90611
+
90612
+ // Get the canvas's bounding rectangle
90613
+ const rect = canvas.getBoundingClientRect();
90614
+
90615
+ // Calculate the touch position relative to the canvas
90616
+ const touchX = touch.clientX - rect.left;
90617
+ const touchY = touch.clientY - rect.top;
90603
90618
 
90604
90619
  if (touch.identifier !== touchId) {
90605
90620
  return;
@@ -96497,8 +96512,8 @@ const tempVec3a$7 = math.vec3();
96497
96512
  const tempVec3b$4 = math.vec3();
96498
96513
  const tempVec3c$3 = math.vec3();
96499
96514
 
96500
- const tempVec4a$4 = math.vec4();
96501
- const tempVec4b$4 = math.vec4();
96515
+ const tempVec4a$5 = math.vec4();
96516
+ const tempVec4b$5 = math.vec4();
96502
96517
  const tempVec4c$1 = math.vec4();
96503
96518
 
96504
96519
  /**
@@ -96537,7 +96552,7 @@ class PanController {
96537
96552
 
96538
96553
  camera.ortho.scale = camera.ortho.scale - dollyDelta;
96539
96554
 
96540
- const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$4);
96555
+ const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$5);
96541
96556
  const offset = math.subVec3(unprojectedWorldPos, camera.eye, tempVec4c$1);
96542
96557
  const moveVec = math.mulVec3Scalar(math.normalizeVec3(offset), -dollyDelta, []);
96543
96558
 
@@ -96564,12 +96579,12 @@ class PanController {
96564
96579
  // - get the vector in which we're dollying;
96565
96580
  // - add both vectors to camera eye and look.
96566
96581
 
96567
- const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$4);
96582
+ const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$5);
96568
96583
 
96569
96584
  camera.ortho.scale = camera.ortho.scale - dollyDelta;
96570
96585
  camera.ortho._update(); // HACK
96571
96586
 
96572
- const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$4);
96587
+ const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$5);
96573
96588
  const offset = math.subVec3(worldPos2, worldPos1, tempVec4c$1);
96574
96589
  const eyeLookMoveVec = math.mulVec3Scalar(math.normalizeVec3(math.subVec3(camera.look, camera.eye, tempVec3a$7)), -dollyDelta, tempVec3b$4);
96575
96590
  const moveVec = math.addVec3(offset, eyeLookMoveVec, tempVec3c$3);
@@ -96603,8 +96618,8 @@ const tempVec3a$6 = math.vec3();
96603
96618
  const tempVec3b$3 = math.vec3();
96604
96619
  const tempVec3c$2 = math.vec3();
96605
96620
 
96606
- const tempVec4a$3 = math.vec4();
96607
- const tempVec4b$3 = math.vec4();
96621
+ const tempVec4a$4 = math.vec4();
96622
+ const tempVec4b$4 = math.vec4();
96608
96623
  const tempVec4c = math.vec4();
96609
96624
 
96610
96625
 
@@ -96857,8 +96872,8 @@ class PivotController {
96857
96872
  const Pt4 = transposedProjectMat.subarray(12);
96858
96873
  const D = [0, 0, -1.0, 1];
96859
96874
  const screenZ = math.dotVec4(D, Pt3) / math.dotVec4(D, Pt4);
96860
- const worldPos = tempVec4a$3;
96861
- camera.project.unproject(canvasPos, screenZ, tempVec4b$3, tempVec4c, worldPos);
96875
+ const worldPos = tempVec4a$4;
96876
+ camera.project.unproject(canvasPos, screenZ, tempVec4b$4, tempVec4c, worldPos);
96862
96877
  const eyeWorldPosVec = math.normalizeVec3(math.subVec3(worldPos, camera.eye, tempVec3a$6));
96863
96878
  const posOnSphere = math.addVec3(camera.eye, math.mulVec3Scalar(eyeWorldPosVec, pivotShereRadius, tempVec3b$3), tempVec3c$2);
96864
96879
  this.setPivotPos(posOnSphere);
@@ -97512,7 +97527,7 @@ class MousePanRotateDollyHandler {
97512
97527
  let secsNowLast = null;
97513
97528
 
97514
97529
  canvas.addEventListener("wheel", this._mouseWheelHandler = (e) => {
97515
- if (!(configs.active && configs.pointerEnabled)) {
97530
+ if (!(configs.active && configs.pointerEnabled && configs.zoomOnMouseWheel)) {
97516
97531
  return;
97517
97532
  }
97518
97533
  const secsNow = performance.now() / 1000.0;
@@ -99747,7 +99762,8 @@ class CameraControl extends Component {
99747
99762
  constrainVertical: false,
99748
99763
  smartPivot: false,
99749
99764
  doubleClickTimeFrame: 250,
99750
-
99765
+ zoomOnMouseWheel: true,
99766
+
99751
99767
  snapToVertex: DEFAULT_SNAP_VERTEX,
99752
99768
  snapToEdge: DEFAULT_SNAP_EDGE,
99753
99769
  snapRadius: DEFAULT_SNAP_PICK_RADIUS,
@@ -100838,6 +100854,26 @@ class CameraControl extends Component {
100838
100854
  return this._configs.doubleClickTimeFrame;
100839
100855
  }
100840
100856
 
100857
+ /**
100858
+ * Sets whether to zoom the camera on mouse wheel
100859
+ *
100860
+ * Default is ````true````
100861
+ *
100862
+ * @param {Boolean} enabled
100863
+ */
100864
+ set zoomOnMouseWheel(enabled) {
100865
+ this._configs.zoomOnMouseWheel = !!enabled;
100866
+ }
100867
+
100868
+ /**
100869
+ * Gets whether to zoom the camera on mouse wheel
100870
+ *
100871
+ * @returns {Boolean}
100872
+ */
100873
+ get zoomOnMouseWheel() {
100874
+ return this._configs.zoomOnMouseWheel;
100875
+ }
100876
+
100841
100877
  /**
100842
100878
  * Destroys this ````CameraControl````.
100843
100879
  * @private
@@ -110197,6 +110233,9 @@ class Viewer {
110197
110233
  }
110198
110234
  }
110199
110235
 
110236
+ // firing "rendering" is necessary to trigger DTX{Lines,Triangles}Layer::_uploadDeferredFlags
110237
+ this.scene.fire("rendering", { }, true);
110238
+
110200
110239
  this.scene._renderer.renderSnapshot();
110201
110240
 
110202
110241
  const imageDataURI = this.scene._renderer.readSnapshot(params);
@@ -128112,7 +128151,7 @@ if (!pako$9.inflate) { // See https://github.com/nodeca/pako/issues/97
128112
128151
  pako$9 = pako$9.default;
128113
128152
  }
128114
128153
 
128115
- const decompressColor$9 = (function () {
128154
+ const decompressColor$a = (function () {
128116
128155
  const color2 = new Float32Array(3);
128117
128156
  return function (color) {
128118
128157
  color2[0] = color[0] / 255.0;
@@ -128156,7 +128195,7 @@ function inflate$9(deflatedData) {
128156
128195
  };
128157
128196
  }
128158
128197
 
128159
- function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128198
+ function load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128160
128199
 
128161
128200
  manifestCtx.getNextId();
128162
128201
 
@@ -128225,7 +128264,7 @@ function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128225
128264
  const lastMesh = (j === (numMeshes - 1));
128226
128265
  const meshId = entityId + ".mesh." + j;
128227
128266
 
128228
- const color = decompressColor$9(meshColors.subarray((j * 4), (j * 4) + 3));
128267
+ const color = decompressColor$a(meshColors.subarray((j * 4), (j * 4) + 3));
128229
128268
  const opacity = meshColors[(j * 4) + 3] / 255.0;
128230
128269
 
128231
128270
  sceneModel.createMesh(utils.apply(meshDefaults, {
@@ -128257,7 +128296,7 @@ const ParserV1 = {
128257
128296
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128258
128297
  const deflatedData = extract$9(elements);
128259
128298
  const inflatedData = inflate$9(deflatedData);
128260
- load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128299
+ load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128261
128300
  }
128262
128301
  };
128263
128302
 
@@ -128325,6 +128364,222 @@ function inflate$8(deflatedData) {
128325
128364
  };
128326
128365
  }
128327
128366
 
128367
+ const decompressColor$9 = (function () {
128368
+ const color2 = new Float32Array(3);
128369
+ return function (color) {
128370
+ color2[0] = color[0] / 255.0;
128371
+ color2[1] = color[1] / 255.0;
128372
+ color2[2] = color[2] / 255.0;
128373
+ return color2;
128374
+ };
128375
+ })();
128376
+
128377
+ function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128378
+
128379
+ const modelPartId = manifestCtx.getNextId();
128380
+
128381
+ sceneModel.positionsCompression = "precompressed";
128382
+ sceneModel.normalsCompression = "precompressed";
128383
+
128384
+ const positions = inflatedData.positions;
128385
+ const normals = inflatedData.normals;
128386
+ const indices = inflatedData.indices;
128387
+ const edgeIndices = inflatedData.edgeIndices;
128388
+ const meshPositions = inflatedData.meshPositions;
128389
+ const meshIndices = inflatedData.meshIndices;
128390
+ const meshEdgesIndices = inflatedData.meshEdgesIndices;
128391
+ const meshColors = inflatedData.meshColors;
128392
+ const entityIDs = JSON.parse(inflatedData.entityIDs);
128393
+ const entityMeshes = inflatedData.entityMeshes;
128394
+ const entityIsObjects = inflatedData.entityIsObjects;
128395
+ const entityMeshIds = inflatedData.entityMeshIds;
128396
+ const entityMatrices = inflatedData.entityMatrices;
128397
+ const entityUsesInstancing = inflatedData.entityUsesInstancing;
128398
+
128399
+ const numMeshes = meshPositions.length;
128400
+ const numEntities = entityMeshes.length;
128401
+
128402
+ const alreadyCreatedGeometries = {};
128403
+
128404
+ for (let i = 0; i < numEntities; i++) {
128405
+
128406
+ const xktEntityId = entityIDs [i];
128407
+ const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId;
128408
+ const metaObject = viewer.metaScene.metaObjects[entityId];
128409
+ const entityDefaults = {};
128410
+ const meshDefaults = {};
128411
+ const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16);
128412
+
128413
+ if (metaObject) {
128414
+ if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) {
128415
+ continue;
128416
+ }
128417
+ if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) {
128418
+ continue;
128419
+ }
128420
+ const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
128421
+ if (props) {
128422
+ if (props.visible === false) {
128423
+ entityDefaults.visible = false;
128424
+ }
128425
+ if (props.pickable === false) {
128426
+ entityDefaults.pickable = false;
128427
+ }
128428
+ if (props.colorize) {
128429
+ meshDefaults.color = props.colorize;
128430
+ }
128431
+ if (props.opacity !== undefined && props.opacity !== null) {
128432
+ meshDefaults.opacity = props.opacity;
128433
+ }
128434
+ }
128435
+ } else {
128436
+ if (options.excludeUnclassifiedObjects) {
128437
+ continue;
128438
+ }
128439
+ }
128440
+
128441
+ const lastEntity = (i === numEntities - 1);
128442
+
128443
+ const meshIds = [];
128444
+
128445
+ for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) {
128446
+
128447
+ const jj = entityMeshIds [j];
128448
+
128449
+ const lastMesh = (jj === (numMeshes - 1));
128450
+ const meshId = manifestCtx.getNextId();
128451
+
128452
+ const color = decompressColor$9(meshColors.subarray((jj * 4), (jj * 4) + 3));
128453
+ const opacity = meshColors[(jj * 4) + 3] / 255.0;
128454
+
128455
+ const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128456
+ const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128457
+ const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]);
128458
+ const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]);
128459
+
128460
+ if (entityUsesInstancing [i] === 1) {
128461
+
128462
+ const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`;
128463
+
128464
+ if (!(geometryId in alreadyCreatedGeometries)) {
128465
+
128466
+ sceneModel.createGeometry({
128467
+ id: geometryId,
128468
+ positionsCompressed: tmpPositions,
128469
+ normalsCompressed: tmpNormals,
128470
+ indices: tmpIndices,
128471
+ edgeIndices: tmpEdgeIndices,
128472
+ primitive: "triangles",
128473
+ positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128474
+ });
128475
+
128476
+ alreadyCreatedGeometries [geometryId] = true;
128477
+ }
128478
+
128479
+ sceneModel.createMesh(utils.apply(meshDefaults, {
128480
+ id: meshId,
128481
+ color: color,
128482
+ opacity: opacity,
128483
+ matrix: entityMatrix,
128484
+ geometryId,
128485
+ }));
128486
+
128487
+ meshIds.push(meshId);
128488
+
128489
+ } else {
128490
+
128491
+ sceneModel.createMesh(utils.apply(meshDefaults, {
128492
+ id: meshId,
128493
+ primitive: "triangles",
128494
+ positionsCompressed: tmpPositions,
128495
+ normalsCompressed: tmpNormals,
128496
+ indices: tmpIndices,
128497
+ edgeIndices: tmpEdgeIndices,
128498
+ positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128499
+ color: color,
128500
+ opacity: opacity
128501
+ }));
128502
+
128503
+ meshIds.push(meshId);
128504
+ }
128505
+ }
128506
+
128507
+ if (meshIds.length) {
128508
+
128509
+ sceneModel.createEntity(utils.apply(entityDefaults, {
128510
+ id: entityId,
128511
+ isObject: (entityIsObjects [i] === 1),
128512
+ meshIds: meshIds
128513
+ }));
128514
+ }
128515
+ }
128516
+ }
128517
+
128518
+ /** @private */
128519
+ const ParserV2 = {
128520
+ version: 2,
128521
+ parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128522
+ const deflatedData = extract$8(elements);
128523
+ const inflatedData = inflate$8(deflatedData);
128524
+ load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128525
+ }
128526
+ };
128527
+
128528
+ /*
128529
+
128530
+ Parser for .XKT Format V3
128531
+
128532
+ .XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format
128533
+
128534
+ */
128535
+
128536
+ let pako$7 = window.pako || p;
128537
+ if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97
128538
+ pako$7 = pako$7.default;
128539
+ }
128540
+
128541
+ function extract$7(elements) {
128542
+ return {
128543
+ positions: elements[0],
128544
+ normals: elements[1],
128545
+ indices: elements[2],
128546
+ edgeIndices: elements[3],
128547
+ meshPositions: elements[4],
128548
+ meshIndices: elements[5],
128549
+ meshEdgesIndices: elements[6],
128550
+ meshColors: elements[7],
128551
+ entityIDs: elements[8],
128552
+ entityMeshes: elements[9],
128553
+ entityIsObjects: elements[10],
128554
+ instancedPositionsDecodeMatrix: elements[11],
128555
+ batchedPositionsDecodeMatrix: elements[12],
128556
+ entityMeshIds: elements[13],
128557
+ entityMatrices: elements[14],
128558
+ entityUsesInstancing: elements[15]
128559
+ };
128560
+ }
128561
+
128562
+ function inflate$7(deflatedData) {
128563
+ return {
128564
+ positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer),
128565
+ normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer),
128566
+ indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer),
128567
+ edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer),
128568
+ meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer),
128569
+ meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer),
128570
+ meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer),
128571
+ meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer),
128572
+ entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}),
128573
+ entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer),
128574
+ entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer),
128575
+ instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer),
128576
+ batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer),
128577
+ entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer),
128578
+ entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer),
128579
+ entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer)
128580
+ };
128581
+ }
128582
+
128328
128583
  const decompressColor$8 = (function () {
128329
128584
  const color2 = new Float32Array(3);
128330
128585
  return function (color) {
@@ -128360,222 +128615,6 @@ function load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128360
128615
  const numMeshes = meshPositions.length;
128361
128616
  const numEntities = entityMeshes.length;
128362
128617
 
128363
- const alreadyCreatedGeometries = {};
128364
-
128365
- for (let i = 0; i < numEntities; i++) {
128366
-
128367
- const xktEntityId = entityIDs [i];
128368
- const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId;
128369
- const metaObject = viewer.metaScene.metaObjects[entityId];
128370
- const entityDefaults = {};
128371
- const meshDefaults = {};
128372
- const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16);
128373
-
128374
- if (metaObject) {
128375
- if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) {
128376
- continue;
128377
- }
128378
- if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) {
128379
- continue;
128380
- }
128381
- const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
128382
- if (props) {
128383
- if (props.visible === false) {
128384
- entityDefaults.visible = false;
128385
- }
128386
- if (props.pickable === false) {
128387
- entityDefaults.pickable = false;
128388
- }
128389
- if (props.colorize) {
128390
- meshDefaults.color = props.colorize;
128391
- }
128392
- if (props.opacity !== undefined && props.opacity !== null) {
128393
- meshDefaults.opacity = props.opacity;
128394
- }
128395
- }
128396
- } else {
128397
- if (options.excludeUnclassifiedObjects) {
128398
- continue;
128399
- }
128400
- }
128401
-
128402
- const lastEntity = (i === numEntities - 1);
128403
-
128404
- const meshIds = [];
128405
-
128406
- for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) {
128407
-
128408
- const jj = entityMeshIds [j];
128409
-
128410
- const lastMesh = (jj === (numMeshes - 1));
128411
- const meshId = manifestCtx.getNextId();
128412
-
128413
- const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3));
128414
- const opacity = meshColors[(jj * 4) + 3] / 255.0;
128415
-
128416
- const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128417
- const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
128418
- const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]);
128419
- const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]);
128420
-
128421
- if (entityUsesInstancing [i] === 1) {
128422
-
128423
- const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`;
128424
-
128425
- if (!(geometryId in alreadyCreatedGeometries)) {
128426
-
128427
- sceneModel.createGeometry({
128428
- id: geometryId,
128429
- positionsCompressed: tmpPositions,
128430
- normalsCompressed: tmpNormals,
128431
- indices: tmpIndices,
128432
- edgeIndices: tmpEdgeIndices,
128433
- primitive: "triangles",
128434
- positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128435
- });
128436
-
128437
- alreadyCreatedGeometries [geometryId] = true;
128438
- }
128439
-
128440
- sceneModel.createMesh(utils.apply(meshDefaults, {
128441
- id: meshId,
128442
- color: color,
128443
- opacity: opacity,
128444
- matrix: entityMatrix,
128445
- geometryId,
128446
- }));
128447
-
128448
- meshIds.push(meshId);
128449
-
128450
- } else {
128451
-
128452
- sceneModel.createMesh(utils.apply(meshDefaults, {
128453
- id: meshId,
128454
- primitive: "triangles",
128455
- positionsCompressed: tmpPositions,
128456
- normalsCompressed: tmpNormals,
128457
- indices: tmpIndices,
128458
- edgeIndices: tmpEdgeIndices,
128459
- positionsDecodeMatrix: inflatedData.positionsDecodeMatrix,
128460
- color: color,
128461
- opacity: opacity
128462
- }));
128463
-
128464
- meshIds.push(meshId);
128465
- }
128466
- }
128467
-
128468
- if (meshIds.length) {
128469
-
128470
- sceneModel.createEntity(utils.apply(entityDefaults, {
128471
- id: entityId,
128472
- isObject: (entityIsObjects [i] === 1),
128473
- meshIds: meshIds
128474
- }));
128475
- }
128476
- }
128477
- }
128478
-
128479
- /** @private */
128480
- const ParserV2 = {
128481
- version: 2,
128482
- parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128483
- const deflatedData = extract$8(elements);
128484
- const inflatedData = inflate$8(deflatedData);
128485
- load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128486
- }
128487
- };
128488
-
128489
- /*
128490
-
128491
- Parser for .XKT Format V3
128492
-
128493
- .XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format
128494
-
128495
- */
128496
-
128497
- let pako$7 = window.pako || p;
128498
- if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97
128499
- pako$7 = pako$7.default;
128500
- }
128501
-
128502
- function extract$7(elements) {
128503
- return {
128504
- positions: elements[0],
128505
- normals: elements[1],
128506
- indices: elements[2],
128507
- edgeIndices: elements[3],
128508
- meshPositions: elements[4],
128509
- meshIndices: elements[5],
128510
- meshEdgesIndices: elements[6],
128511
- meshColors: elements[7],
128512
- entityIDs: elements[8],
128513
- entityMeshes: elements[9],
128514
- entityIsObjects: elements[10],
128515
- instancedPositionsDecodeMatrix: elements[11],
128516
- batchedPositionsDecodeMatrix: elements[12],
128517
- entityMeshIds: elements[13],
128518
- entityMatrices: elements[14],
128519
- entityUsesInstancing: elements[15]
128520
- };
128521
- }
128522
-
128523
- function inflate$7(deflatedData) {
128524
- return {
128525
- positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer),
128526
- normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer),
128527
- indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer),
128528
- edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer),
128529
- meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer),
128530
- meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer),
128531
- meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer),
128532
- meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer),
128533
- entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}),
128534
- entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer),
128535
- entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer),
128536
- instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer),
128537
- batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer),
128538
- entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer),
128539
- entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer),
128540
- entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer)
128541
- };
128542
- }
128543
-
128544
- const decompressColor$7 = (function () {
128545
- const color2 = new Float32Array(3);
128546
- return function (color) {
128547
- color2[0] = color[0] / 255.0;
128548
- color2[1] = color[1] / 255.0;
128549
- color2[2] = color[2] / 255.0;
128550
- return color2;
128551
- };
128552
- })();
128553
-
128554
- function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128555
-
128556
- const modelPartId = manifestCtx.getNextId();
128557
-
128558
- sceneModel.positionsCompression = "precompressed";
128559
- sceneModel.normalsCompression = "precompressed";
128560
-
128561
- const positions = inflatedData.positions;
128562
- const normals = inflatedData.normals;
128563
- const indices = inflatedData.indices;
128564
- const edgeIndices = inflatedData.edgeIndices;
128565
- const meshPositions = inflatedData.meshPositions;
128566
- const meshIndices = inflatedData.meshIndices;
128567
- const meshEdgesIndices = inflatedData.meshEdgesIndices;
128568
- const meshColors = inflatedData.meshColors;
128569
- const entityIDs = JSON.parse(inflatedData.entityIDs);
128570
- const entityMeshes = inflatedData.entityMeshes;
128571
- const entityIsObjects = inflatedData.entityIsObjects;
128572
- const entityMeshIds = inflatedData.entityMeshIds;
128573
- const entityMatrices = inflatedData.entityMatrices;
128574
- const entityUsesInstancing = inflatedData.entityUsesInstancing;
128575
-
128576
- const numMeshes = meshPositions.length;
128577
- const numEntities = entityMeshes.length;
128578
-
128579
128618
  const _alreadyCreatedGeometries = {};
128580
128619
 
128581
128620
  for (let i = 0; i < numEntities; i++) {
@@ -128629,7 +128668,7 @@ function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128629
128668
  const lastMesh = (jj === (numMeshes - 1));
128630
128669
  const meshId = `${modelPartId}.${entityId}.mesh.${jj}`;
128631
128670
 
128632
- const color = decompressColor$7(meshColors.subarray((jj * 4), (jj * 4) + 3));
128671
+ const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3));
128633
128672
  const opacity = meshColors[(jj * 4) + 3] / 255.0;
128634
128673
 
128635
128674
  var tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]);
@@ -128700,7 +128739,7 @@ const ParserV3 = {
128700
128739
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128701
128740
  const deflatedData = extract$7(elements);
128702
128741
  const inflatedData = inflate$7(deflatedData);
128703
- load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128742
+ load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128704
128743
  }
128705
128744
  };
128706
128745
 
@@ -128758,7 +128797,7 @@ function inflate$6(deflatedData) {
128758
128797
  };
128759
128798
  }
128760
128799
 
128761
- const decompressColor$6 = (function () {
128800
+ const decompressColor$7 = (function () {
128762
128801
  const color2 = new Float32Array(3);
128763
128802
  return function (color) {
128764
128803
  color2[0] = color[0] / 255.0;
@@ -128768,7 +128807,7 @@ const decompressColor$6 = (function () {
128768
128807
  };
128769
128808
  })();
128770
128809
 
128771
- function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128810
+ function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
128772
128811
 
128773
128812
  const modelPartId = manifestCtx.getNextId();
128774
128813
 
@@ -128864,7 +128903,7 @@ function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
128864
128903
  const primitiveInstanceCount = primitiveInstanceCounts[orderedPrimitiveIndex];
128865
128904
  const isInstancedPrimitive = (primitiveInstanceCount > 1);
128866
128905
 
128867
- const color = decompressColor$6(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3));
128906
+ const color = decompressColor$7(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3));
128868
128907
  const opacity = eachPrimitiveColor[(orderedPrimitiveIndex * 4) + 3] / 255.0;
128869
128908
 
128870
128909
  const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex + 1]);
@@ -128974,7 +129013,7 @@ const ParserV4 = {
128974
129013
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
128975
129014
  const deflatedData = extract$6(elements);
128976
129015
  const inflatedData = inflate$6(deflatedData);
128977
- load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129016
+ load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
128978
129017
  }
128979
129018
  };
128980
129019
 
@@ -129027,7 +129066,7 @@ function inflate$5(deflatedData) {
129027
129066
  };
129028
129067
  }
129029
129068
 
129030
- const decompressColor$5 = (function () {
129069
+ const decompressColor$6 = (function () {
129031
129070
  const color2 = new Float32Array(3);
129032
129071
  return function (color) {
129033
129072
  color2[0] = color[0] / 255.0;
@@ -129037,7 +129076,7 @@ const decompressColor$5 = (function () {
129037
129076
  };
129038
129077
  })();
129039
129078
 
129040
- function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129079
+ function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129041
129080
 
129042
129081
  const modelPartId = manifestCtx.getNextId();
129043
129082
 
@@ -129106,7 +129145,7 @@ function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
129106
129145
  const primitiveInstanceCount = primitiveInstanceCounts[primitiveIndex];
129107
129146
  const isInstancedPrimitive = (primitiveInstanceCount > 1);
129108
129147
 
129109
- const color = decompressColor$5(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129148
+ const color = decompressColor$6(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129110
129149
  const opacity = eachPrimitiveColor[(primitiveIndex * 4) + 3] / 255.0;
129111
129150
 
129112
129151
  const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [primitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [primitiveIndex + 1]);
@@ -129212,7 +129251,7 @@ const ParserV5 = {
129212
129251
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
129213
129252
  const deflatedData = extract$5(elements);
129214
129253
  const inflatedData = inflate$5(deflatedData);
129215
- load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129254
+ load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129216
129255
  }
129217
129256
  };
129218
129257
 
@@ -129275,7 +129314,7 @@ function inflate$4(deflatedData) {
129275
129314
  };
129276
129315
  }
129277
129316
 
129278
- const decompressColor$4 = (function () {
129317
+ const decompressColor$5 = (function () {
129279
129318
  const floatColor = new Float32Array(3);
129280
129319
  return function (intColor) {
129281
129320
  floatColor[0] = intColor[0] / 255.0;
@@ -129285,7 +129324,7 @@ const decompressColor$4 = (function () {
129285
129324
  };
129286
129325
  })();
129287
129326
 
129288
- function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129327
+ function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129289
129328
 
129290
129329
  const modelPartId = manifestCtx.getNextId();
129291
129330
 
@@ -129433,7 +129472,7 @@ function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
129433
129472
  const primitiveIndices = indices.subarray(eachPrimitiveIndicesPortion [primitiveIndex], atLastPrimitive ? indices.length : eachPrimitiveIndicesPortion [primitiveIndex + 1]);
129434
129473
  const primitiveEdgeIndices = edgeIndices.subarray(eachPrimitiveEdgeIndicesPortion [primitiveIndex], atLastPrimitive ? edgeIndices.length : eachPrimitiveEdgeIndicesPortion [primitiveIndex + 1]);
129435
129474
 
129436
- const color = decompressColor$4(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129475
+ const color = decompressColor$5(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3));
129437
129476
  const opacity = eachPrimitiveColorAndOpacity[(primitiveIndex * 4) + 3] / 255.0;
129438
129477
 
129439
129478
  const meshId = manifestCtx.getNextId();
@@ -129507,7 +129546,7 @@ const ParserV6 = {
129507
129546
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
129508
129547
  const deflatedData = extract$4(elements);
129509
129548
  const inflatedData = inflate$4(deflatedData);
129510
- load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129549
+ load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129511
129550
  }
129512
129551
  };
129513
129552
 
@@ -129605,7 +129644,7 @@ function inflate$3(deflatedData) {
129605
129644
  };
129606
129645
  }
129607
129646
 
129608
- const decompressColor$3 = (function () {
129647
+ const decompressColor$4 = (function () {
129609
129648
  const floatColor = new Float32Array(3);
129610
129649
  return function (intColor) {
129611
129650
  floatColor[0] = intColor[0] / 255.0;
@@ -129626,7 +129665,7 @@ function convertColorsRGBToRGBA$1(colorsRGB) {
129626
129665
  return colorsRGBA;
129627
129666
  }
129628
129667
 
129629
- function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129668
+ function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
129630
129669
 
129631
129670
  const modelPartId = manifestCtx.getNextId();
129632
129671
 
@@ -129777,7 +129816,7 @@ function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
129777
129816
 
129778
129817
  const atLastGeometry = (geometryIndex === (numGeometries - 1));
129779
129818
 
129780
- const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
129819
+ const meshColor = decompressColor$4(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
129781
129820
  const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
129782
129821
  const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
129783
129822
  const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;
@@ -129938,7 +129977,7 @@ const ParserV7 = {
129938
129977
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
129939
129978
  const deflatedData = extract$3(elements);
129940
129979
  const inflatedData = inflate$3(deflatedData);
129941
- load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129980
+ load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
129942
129981
  }
129943
129982
  };
129944
129983
 
@@ -129953,8 +129992,8 @@ if (!pako$2.inflate) { // See https://github.com/nodeca/pako/issues/97
129953
129992
  pako$2 = pako$2.default;
129954
129993
  }
129955
129994
 
129956
- const tempVec4a$2 = math.vec4();
129957
- const tempVec4b$2 = math.vec4();
129995
+ const tempVec4a$3 = math.vec4();
129996
+ const tempVec4b$3 = math.vec4();
129958
129997
 
129959
129998
  function extract$2(elements) {
129960
129999
 
@@ -130046,7 +130085,7 @@ function inflate$2(deflatedData) {
130046
130085
  };
130047
130086
  }
130048
130087
 
130049
- const decompressColor$2 = (function () {
130088
+ const decompressColor$3 = (function () {
130050
130089
  const floatColor = new Float32Array(3);
130051
130090
  return function (intColor) {
130052
130091
  floatColor[0] = intColor[0] / 255.0;
@@ -130067,7 +130106,7 @@ function convertColorsRGBToRGBA(colorsRGB) {
130067
130106
  return colorsRGBA;
130068
130107
  }
130069
130108
 
130070
- function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130109
+ function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130071
130110
 
130072
130111
  const modelPartId = manifestCtx.getNextId();
130073
130112
 
@@ -130253,7 +130292,7 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130253
130292
 
130254
130293
  const atLastGeometry = (geometryIndex === (numGeometries - 1));
130255
130294
 
130256
- const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130295
+ const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130257
130296
  const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
130258
130297
  const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
130259
130298
  const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;
@@ -130342,15 +130381,15 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130342
130381
  const decompressedPositions = geometryArrays.decompressedPositions;
130343
130382
  const positions = new Uint16Array(decompressedPositions.length);
130344
130383
  for (let i = 0, len = decompressedPositions.length; i < len; i += 3) {
130345
- tempVec4a$2[0] = decompressedPositions[i + 0];
130346
- tempVec4a$2[1] = decompressedPositions[i + 1];
130347
- tempVec4a$2[2] = decompressedPositions[i + 2];
130348
- tempVec4a$2[3] = 1;
130349
- math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2);
130350
- geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2);
130351
- positions[i + 0] = tempVec4a$2[0];
130352
- positions[i + 1] = tempVec4a$2[1];
130353
- positions[i + 2] = tempVec4a$2[2];
130384
+ tempVec4a$3[0] = decompressedPositions[i + 0];
130385
+ tempVec4a$3[1] = decompressedPositions[i + 1];
130386
+ tempVec4a$3[2] = decompressedPositions[i + 2];
130387
+ tempVec4a$3[3] = 1;
130388
+ math.transformVec4(meshMatrix, tempVec4a$3, tempVec4b$3);
130389
+ geometryCompressionUtils.compressPosition(tempVec4b$3, rtcAABB, tempVec4a$3);
130390
+ positions[i + 0] = tempVec4a$3[0];
130391
+ positions[i + 1] = tempVec4a$3[1];
130392
+ positions[i + 2] = tempVec4a$3[2];
130354
130393
  }
130355
130394
 
130356
130395
  sceneModel.createMesh(utils.apply(meshDefaults, {
@@ -130490,7 +130529,7 @@ const ParserV8 = {
130490
130529
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
130491
130530
  const deflatedData = extract$2(elements);
130492
130531
  const inflatedData = inflate$2(deflatedData);
130493
- load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
130532
+ load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
130494
130533
  }
130495
130534
  };
130496
130535
 
@@ -130505,8 +130544,8 @@ if (!pako$1.inflate) { // See https://github.com/nodeca/pako/issues/97
130505
130544
  pako$1 = pako$1.default;
130506
130545
  }
130507
130546
 
130508
- const tempVec4a$1 = math.vec4();
130509
- const tempVec4b$1 = math.vec4();
130547
+ const tempVec4a$2 = math.vec4();
130548
+ const tempVec4b$2 = math.vec4();
130510
130549
 
130511
130550
  function extract$1(elements) {
130512
130551
 
@@ -130590,7 +130629,7 @@ function inflate$1(deflatedData) {
130590
130629
  };
130591
130630
  }
130592
130631
 
130593
- const decompressColor$1 = (function () {
130632
+ const decompressColor$2 = (function () {
130594
130633
  const floatColor = new Float32Array(3);
130595
130634
  return function (intColor) {
130596
130635
  floatColor[0] = intColor[0] / 255.0;
@@ -130600,7 +130639,7 @@ const decompressColor$1 = (function () {
130600
130639
  };
130601
130640
  })();
130602
130641
 
130603
- function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130642
+ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
130604
130643
 
130605
130644
  const modelPartId = manifestCtx.getNextId();
130606
130645
 
@@ -130762,7 +130801,7 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130762
130801
 
130763
130802
  const atLastGeometry = (geometryIndex === (numGeometries - 1));
130764
130803
 
130765
- const meshColor = decompressColor$1(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130804
+ const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
130766
130805
  const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
130767
130806
  const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
130768
130807
  const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;
@@ -130849,15 +130888,15 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt
130849
130888
  const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions;
130850
130889
 
130851
130890
  for (let i = 0, len = decompressedPositions.length; i < len; i += 3) {
130852
- tempVec4a$1[0] = decompressedPositions[i + 0];
130853
- tempVec4a$1[1] = decompressedPositions[i + 1];
130854
- tempVec4a$1[2] = decompressedPositions[i + 2];
130855
- tempVec4a$1[3] = 1;
130856
- math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1);
130857
- geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1);
130858
- transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0];
130859
- transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1];
130860
- transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2];
130891
+ tempVec4a$2[0] = decompressedPositions[i + 0];
130892
+ tempVec4a$2[1] = decompressedPositions[i + 1];
130893
+ tempVec4a$2[2] = decompressedPositions[i + 2];
130894
+ tempVec4a$2[3] = 1;
130895
+ math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2);
130896
+ geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2);
130897
+ transformedAndRecompressedPositions[i + 0] = tempVec4a$2[0];
130898
+ transformedAndRecompressedPositions[i + 1] = tempVec4a$2[1];
130899
+ transformedAndRecompressedPositions[i + 2] = tempVec4a$2[2];
130861
130900
  }
130862
130901
 
130863
130902
  sceneModel.createMesh(utils.apply(meshDefaults, {
@@ -130997,7 +131036,7 @@ const ParserV9 = {
130997
131036
  parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
130998
131037
  const deflatedData = extract$1(elements);
130999
131038
  const inflatedData = inflate$1(deflatedData);
131000
- load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131039
+ load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131001
131040
  }
131002
131041
  };
131003
131042
 
@@ -131010,10 +131049,10 @@ if (!pako.inflate) { // See https://github.com/nodeca/pako/issues/97
131010
131049
  pako = pako.default;
131011
131050
  }
131012
131051
 
131013
- const tempVec4a = math.vec4();
131014
- const tempVec4b = math.vec4();
131052
+ const tempVec4a$1 = math.vec4();
131053
+ const tempVec4b$1 = math.vec4();
131015
131054
 
131016
- const NUM_TEXTURE_ATTRIBUTES = 9;
131055
+ const NUM_TEXTURE_ATTRIBUTES$1 = 9;
131017
131056
 
131018
131057
  function extract(elements) {
131019
131058
 
@@ -131089,6 +131128,648 @@ function inflate(deflatedData) {
131089
131128
  };
131090
131129
  }
131091
131130
 
131131
+ const decompressColor$1 = (function () {
131132
+ const floatColor = new Float32Array(3);
131133
+ return function (intColor) {
131134
+ floatColor[0] = intColor[0] / 255.0;
131135
+ floatColor[1] = intColor[1] / 255.0;
131136
+ floatColor[2] = intColor[2] / 255.0;
131137
+ return floatColor;
131138
+ };
131139
+ })();
131140
+
131141
+ ((function () {
131142
+ const canvas = document.createElement('canvas');
131143
+ const context = canvas.getContext('2d');
131144
+ return function (imagedata) {
131145
+ canvas.width = imagedata.width;
131146
+ canvas.height = imagedata.height;
131147
+ context.putImageData(imagedata, 0, 0);
131148
+ return canvas.toDataURL();
131149
+ };
131150
+ }))();
131151
+
131152
+ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) {
131153
+
131154
+ const modelPartId = manifestCtx.getNextId();
131155
+
131156
+ const metadata = inflatedData.metadata;
131157
+ const textureData = inflatedData.textureData;
131158
+ const eachTextureDataPortion = inflatedData.eachTextureDataPortion;
131159
+ const eachTextureAttributes = inflatedData.eachTextureAttributes;
131160
+ const positions = inflatedData.positions;
131161
+ const normals = inflatedData.normals;
131162
+ const colors = inflatedData.colors;
131163
+ const uvs = inflatedData.uvs;
131164
+ const indices = inflatedData.indices;
131165
+ const edgeIndices = inflatedData.edgeIndices;
131166
+ const eachTextureSetTextures = inflatedData.eachTextureSetTextures;
131167
+ const matrices = inflatedData.matrices;
131168
+ const reusedGeometriesDecodeMatrix = inflatedData.reusedGeometriesDecodeMatrix;
131169
+ const eachGeometryPrimitiveType = inflatedData.eachGeometryPrimitiveType;
131170
+ const eachGeometryPositionsPortion = inflatedData.eachGeometryPositionsPortion;
131171
+ const eachGeometryNormalsPortion = inflatedData.eachGeometryNormalsPortion;
131172
+ const eachGeometryColorsPortion = inflatedData.eachGeometryColorsPortion;
131173
+ const eachGeometryUVsPortion = inflatedData.eachGeometryUVsPortion;
131174
+ const eachGeometryIndicesPortion = inflatedData.eachGeometryIndicesPortion;
131175
+ const eachGeometryEdgeIndicesPortion = inflatedData.eachGeometryEdgeIndicesPortion;
131176
+ const eachMeshGeometriesPortion = inflatedData.eachMeshGeometriesPortion;
131177
+ const eachMeshMatricesPortion = inflatedData.eachMeshMatricesPortion;
131178
+ const eachMeshTextureSet = inflatedData.eachMeshTextureSet;
131179
+ const eachMeshMaterialAttributes = inflatedData.eachMeshMaterialAttributes;
131180
+ const eachEntityId = inflatedData.eachEntityId;
131181
+ const eachEntityMeshesPortion = inflatedData.eachEntityMeshesPortion;
131182
+ const eachTileAABB = inflatedData.eachTileAABB;
131183
+ const eachTileEntitiesPortion = inflatedData.eachTileEntitiesPortion;
131184
+
131185
+ const numTextures = eachTextureDataPortion.length;
131186
+ const numTextureSets = eachTextureSetTextures.length / 5;
131187
+ const numGeometries = eachGeometryPositionsPortion.length;
131188
+ const numMeshes = eachMeshGeometriesPortion.length;
131189
+ const numEntities = eachEntityMeshesPortion.length;
131190
+ const numTiles = eachTileEntitiesPortion.length;
131191
+
131192
+ if (metaModel) {
131193
+ metaModel.loadData(metadata, {
131194
+ includeTypes: options.includeTypes,
131195
+ excludeTypes: options.excludeTypes,
131196
+ globalizeObjectIds: options.globalizeObjectIds
131197
+ }); // Can be empty
131198
+ }
131199
+
131200
+ // Create textures
131201
+
131202
+ for (let textureIndex = 0; textureIndex < numTextures; textureIndex++) {
131203
+ const atLastTexture = (textureIndex === (numTextures - 1));
131204
+ const textureDataPortionStart = eachTextureDataPortion[textureIndex];
131205
+ const textureDataPortionEnd = atLastTexture ? textureData.length : (eachTextureDataPortion[textureIndex + 1]);
131206
+
131207
+ const textureDataPortionSize = textureDataPortionEnd - textureDataPortionStart;
131208
+ const textureDataPortionExists = (textureDataPortionSize > 0);
131209
+
131210
+ const textureAttrBaseIdx = (textureIndex * NUM_TEXTURE_ATTRIBUTES$1);
131211
+
131212
+ const compressed = (eachTextureAttributes[textureAttrBaseIdx + 0] === 1);
131213
+ const mediaType = eachTextureAttributes[textureAttrBaseIdx + 1];
131214
+ eachTextureAttributes[textureAttrBaseIdx + 2];
131215
+ eachTextureAttributes[textureAttrBaseIdx + 3];
131216
+ const minFilter = eachTextureAttributes[textureAttrBaseIdx + 4];
131217
+ const magFilter = eachTextureAttributes[textureAttrBaseIdx + 5]; // LinearFilter | NearestFilter
131218
+ const wrapS = eachTextureAttributes[textureAttrBaseIdx + 6]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping
131219
+ const wrapT = eachTextureAttributes[textureAttrBaseIdx + 7]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping
131220
+ const wrapR = eachTextureAttributes[textureAttrBaseIdx + 8]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping
131221
+
131222
+ if (textureDataPortionExists) {
131223
+
131224
+ const imageDataSubarray = new Uint8Array(textureData.subarray(textureDataPortionStart, textureDataPortionEnd));
131225
+ const arrayBuffer = imageDataSubarray.buffer;
131226
+ const textureId = `${modelPartId}-texture-${textureIndex}`;
131227
+
131228
+ if (compressed) {
131229
+
131230
+ sceneModel.createTexture({
131231
+ id: textureId,
131232
+ buffers: [arrayBuffer],
131233
+ minFilter,
131234
+ magFilter,
131235
+ wrapS,
131236
+ wrapT,
131237
+ wrapR
131238
+ });
131239
+
131240
+ } else {
131241
+
131242
+ const mimeType = mediaType === JPEGMediaType ? "image/jpeg" : (mediaType === PNGMediaType ? "image/png" : "image/gif");
131243
+ const blob = new Blob([arrayBuffer], {type: mimeType});
131244
+ const urlCreator = window.URL || window.webkitURL;
131245
+ const imageUrl = urlCreator.createObjectURL(blob);
131246
+ const img = document.createElement('img');
131247
+ img.src = imageUrl;
131248
+
131249
+ sceneModel.createTexture({
131250
+ id: textureId,
131251
+ image: img,
131252
+ //mediaType,
131253
+ minFilter,
131254
+ magFilter,
131255
+ wrapS,
131256
+ wrapT,
131257
+ wrapR
131258
+ });
131259
+ }
131260
+ }
131261
+ }
131262
+
131263
+ // Create texture sets
131264
+
131265
+ for (let textureSetIndex = 0; textureSetIndex < numTextureSets; textureSetIndex++) {
131266
+ const eachTextureSetTexturesIndex = textureSetIndex * 5;
131267
+ const textureSetId = `${modelPartId}-textureSet-${textureSetIndex}`;
131268
+ const colorTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 0];
131269
+ const metallicRoughnessTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 1];
131270
+ const normalsTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 2];
131271
+ const emissiveTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 3];
131272
+ const occlusionTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 4];
131273
+ sceneModel.createTextureSet({
131274
+ id: textureSetId,
131275
+ colorTextureId: colorTextureIndex >= 0 ? `${modelPartId}-texture-${colorTextureIndex}` : null,
131276
+ normalsTextureId: normalsTextureIndex >= 0 ? `${modelPartId}-texture-${normalsTextureIndex}` : null,
131277
+ metallicRoughnessTextureId: metallicRoughnessTextureIndex >= 0 ? `${modelPartId}-texture-${metallicRoughnessTextureIndex}` : null,
131278
+ emissiveTextureId: emissiveTextureIndex >= 0 ? `${modelPartId}-texture-${emissiveTextureIndex}` : null,
131279
+ occlusionTextureId: occlusionTextureIndex >= 0 ? `${modelPartId}-texture-${occlusionTextureIndex}` : null
131280
+ });
131281
+ }
131282
+
131283
+ // Count instances of each geometry
131284
+
131285
+ const geometryReuseCounts = new Uint32Array(numGeometries);
131286
+
131287
+ for (let meshIndex = 0; meshIndex < numMeshes; meshIndex++) {
131288
+ const geometryIndex = eachMeshGeometriesPortion[meshIndex];
131289
+ if (geometryReuseCounts[geometryIndex] !== undefined) {
131290
+ geometryReuseCounts[geometryIndex]++;
131291
+ } else {
131292
+ geometryReuseCounts[geometryIndex] = 1;
131293
+ }
131294
+ }
131295
+
131296
+ // Iterate over tiles
131297
+
131298
+ const tileCenter = math.vec3();
131299
+ const rtcAABB = math.AABB3();
131300
+
131301
+ const geometryArraysCache = {};
131302
+
131303
+ for (let tileIndex = 0; tileIndex < numTiles; tileIndex++) {
131304
+
131305
+ const lastTileIndex = (numTiles - 1);
131306
+
131307
+ const atLastTile = (tileIndex === lastTileIndex);
131308
+
131309
+ const firstTileEntityIndex = eachTileEntitiesPortion [tileIndex];
131310
+ const lastTileEntityIndex = atLastTile ? (numEntities - 1) : (eachTileEntitiesPortion[tileIndex + 1] - 1);
131311
+
131312
+ const tileAABBIndex = tileIndex * 6;
131313
+ const tileAABB = eachTileAABB.subarray(tileAABBIndex, tileAABBIndex + 6);
131314
+
131315
+ math.getAABB3Center(tileAABB, tileCenter);
131316
+
131317
+ rtcAABB[0] = tileAABB[0] - tileCenter[0];
131318
+ rtcAABB[1] = tileAABB[1] - tileCenter[1];
131319
+ rtcAABB[2] = tileAABB[2] - tileCenter[2];
131320
+ rtcAABB[3] = tileAABB[3] - tileCenter[0];
131321
+ rtcAABB[4] = tileAABB[4] - tileCenter[1];
131322
+ rtcAABB[5] = tileAABB[5] - tileCenter[2];
131323
+
131324
+ const tileDecodeMatrix = geometryCompressionUtils.createPositionsDecodeMatrix(rtcAABB);
131325
+
131326
+ const geometryCreatedInTile = {};
131327
+
131328
+ // Iterate over each tile's entities
131329
+
131330
+ for (let tileEntityIndex = firstTileEntityIndex; tileEntityIndex <= lastTileEntityIndex; tileEntityIndex++) {
131331
+
131332
+ const xktEntityId = eachEntityId[tileEntityIndex];
131333
+
131334
+ const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId;
131335
+
131336
+ const finalTileEntityIndex = (numEntities - 1);
131337
+ const atLastTileEntity = (tileEntityIndex === finalTileEntityIndex);
131338
+ const firstMeshIndex = eachEntityMeshesPortion [tileEntityIndex];
131339
+ const lastMeshIndex = atLastTileEntity ? (eachMeshGeometriesPortion.length - 1) : (eachEntityMeshesPortion[tileEntityIndex + 1] - 1);
131340
+
131341
+ const meshIds = [];
131342
+
131343
+ const metaObject = viewer.metaScene.metaObjects[entityId];
131344
+ const entityDefaults = {};
131345
+ const meshDefaults = {};
131346
+
131347
+ if (metaObject) {
131348
+
131349
+ // Mask loading of object types
131350
+
131351
+ if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) {
131352
+ continue;
131353
+ }
131354
+
131355
+ if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) {
131356
+ continue;
131357
+ }
131358
+
131359
+ // Get initial property values for object types
131360
+
131361
+ const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
131362
+
131363
+ if (props) {
131364
+ if (props.visible === false) {
131365
+ entityDefaults.visible = false;
131366
+ }
131367
+ if (props.pickable === false) {
131368
+ entityDefaults.pickable = false;
131369
+ }
131370
+ if (props.colorize) {
131371
+ meshDefaults.color = props.colorize;
131372
+ }
131373
+ if (props.opacity !== undefined && props.opacity !== null) {
131374
+ meshDefaults.opacity = props.opacity;
131375
+ }
131376
+ if (props.metallic !== undefined && props.metallic !== null) {
131377
+ meshDefaults.metallic = props.metallic;
131378
+ }
131379
+ if (props.roughness !== undefined && props.roughness !== null) {
131380
+ meshDefaults.roughness = props.roughness;
131381
+ }
131382
+ }
131383
+
131384
+ } else {
131385
+ if (options.excludeUnclassifiedObjects) {
131386
+ continue;
131387
+ }
131388
+ }
131389
+
131390
+ // Iterate each entity's meshes
131391
+
131392
+ for (let meshIndex = firstMeshIndex; meshIndex <= lastMeshIndex; meshIndex++) {
131393
+
131394
+ const geometryIndex = eachMeshGeometriesPortion[meshIndex];
131395
+ const geometryReuseCount = geometryReuseCounts[geometryIndex];
131396
+ const isReusedGeometry = (geometryReuseCount > 1);
131397
+
131398
+ const atLastGeometry = (geometryIndex === (numGeometries - 1));
131399
+
131400
+ const textureSetIndex = eachMeshTextureSet[meshIndex];
131401
+
131402
+ const textureSetId = (textureSetIndex >= 0) ? `${modelPartId}-textureSet-${textureSetIndex}` : null;
131403
+
131404
+ const meshColor = decompressColor$1(eachMeshMaterialAttributes.subarray((meshIndex * 6), (meshIndex * 6) + 3));
131405
+ const meshOpacity = eachMeshMaterialAttributes[(meshIndex * 6) + 3] / 255.0;
131406
+ const meshMetallic = eachMeshMaterialAttributes[(meshIndex * 6) + 4] / 255.0;
131407
+ const meshRoughness = eachMeshMaterialAttributes[(meshIndex * 6) + 5] / 255.0;
131408
+
131409
+ const meshId = manifestCtx.getNextId();
131410
+
131411
+ if (isReusedGeometry) {
131412
+
131413
+ // Create mesh for multi-use geometry - create (or reuse) geometry, create mesh using that geometry
131414
+
131415
+ const meshMatrixIndex = eachMeshMatricesPortion[meshIndex];
131416
+ const meshMatrix = matrices.slice(meshMatrixIndex, meshMatrixIndex + 16);
131417
+
131418
+ const geometryId = `${modelPartId}-geometry.${tileIndex}.${geometryIndex}`; // These IDs are local to the SceneModel
131419
+
131420
+ let geometryArrays = geometryArraysCache[geometryId];
131421
+
131422
+ if (!geometryArrays) {
131423
+ geometryArrays = {
131424
+ batchThisMesh: (!options.reuseGeometries)
131425
+ };
131426
+ const primitiveType = eachGeometryPrimitiveType[geometryIndex];
131427
+ let geometryValid = false;
131428
+ switch (primitiveType) {
131429
+ case 0:
131430
+ geometryArrays.primitiveName = "solid";
131431
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131432
+ geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131433
+ geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131434
+ geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131435
+ geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131436
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131437
+ break;
131438
+ case 1:
131439
+ geometryArrays.primitiveName = "surface";
131440
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131441
+ geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131442
+ geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131443
+ geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131444
+ geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131445
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131446
+ break;
131447
+ case 2:
131448
+ geometryArrays.primitiveName = "points";
131449
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131450
+ geometryArrays.geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]);
131451
+ geometryValid = (geometryArrays.geometryPositions.length > 0);
131452
+ break;
131453
+ case 3:
131454
+ geometryArrays.primitiveName = "lines";
131455
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131456
+ geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131457
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131458
+ break;
131459
+ case 4:
131460
+ geometryArrays.primitiveName = "lines";
131461
+ geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131462
+ geometryArrays.geometryIndices = lineStripToLines$1(
131463
+ geometryArrays.geometryPositions,
131464
+ indices.subarray(eachGeometryIndicesPortion [geometryIndex],
131465
+ atLastGeometry
131466
+ ? indices.length
131467
+ : eachGeometryIndicesPortion [geometryIndex + 1]));
131468
+ geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0);
131469
+ break;
131470
+ default:
131471
+ continue;
131472
+ }
131473
+
131474
+ if (!geometryValid) {
131475
+ geometryArrays = null;
131476
+ }
131477
+
131478
+ if (geometryArrays) {
131479
+ if (geometryArrays.geometryPositions.length > 1000) ;
131480
+ if (geometryArrays.batchThisMesh) {
131481
+ geometryArrays.decompressedPositions = new Float32Array(geometryArrays.geometryPositions.length);
131482
+ geometryArrays.transformedAndRecompressedPositions = new Uint16Array(geometryArrays.geometryPositions.length);
131483
+ const geometryPositions = geometryArrays.geometryPositions;
131484
+ const decompressedPositions = geometryArrays.decompressedPositions;
131485
+ for (let i = 0, len = geometryPositions.length; i < len; i += 3) {
131486
+ decompressedPositions[i + 0] = geometryPositions[i + 0] * reusedGeometriesDecodeMatrix[0] + reusedGeometriesDecodeMatrix[12];
131487
+ decompressedPositions[i + 1] = geometryPositions[i + 1] * reusedGeometriesDecodeMatrix[5] + reusedGeometriesDecodeMatrix[13];
131488
+ decompressedPositions[i + 2] = geometryPositions[i + 2] * reusedGeometriesDecodeMatrix[10] + reusedGeometriesDecodeMatrix[14];
131489
+ }
131490
+ geometryArrays.geometryPositions = null;
131491
+ geometryArraysCache[geometryId] = geometryArrays;
131492
+ }
131493
+ }
131494
+ }
131495
+
131496
+ if (geometryArrays) {
131497
+
131498
+ if (geometryArrays.batchThisMesh) {
131499
+
131500
+ const decompressedPositions = geometryArrays.decompressedPositions;
131501
+ const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions;
131502
+
131503
+ for (let i = 0, len = decompressedPositions.length; i < len; i += 3) {
131504
+ tempVec4a$1[0] = decompressedPositions[i + 0];
131505
+ tempVec4a$1[1] = decompressedPositions[i + 1];
131506
+ tempVec4a$1[2] = decompressedPositions[i + 2];
131507
+ tempVec4a$1[3] = 1;
131508
+ math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1);
131509
+ geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1);
131510
+ transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0];
131511
+ transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1];
131512
+ transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2];
131513
+ }
131514
+
131515
+ sceneModel.createMesh(utils.apply(meshDefaults, {
131516
+ id: meshId,
131517
+ textureSetId,
131518
+ origin: tileCenter,
131519
+ primitive: geometryArrays.primitiveName,
131520
+ positionsCompressed: transformedAndRecompressedPositions,
131521
+ normalsCompressed: geometryArrays.geometryNormals,
131522
+ uv: geometryArrays.geometryUVs,
131523
+ colorsCompressed: geometryArrays.geometryColors,
131524
+ indices: geometryArrays.geometryIndices,
131525
+ edgeIndices: geometryArrays.geometryEdgeIndices,
131526
+ positionsDecodeMatrix: tileDecodeMatrix,
131527
+ color: meshColor,
131528
+ metallic: meshMetallic,
131529
+ roughness: meshRoughness,
131530
+ opacity: meshOpacity
131531
+ }));
131532
+
131533
+ meshIds.push(meshId);
131534
+
131535
+ } else {
131536
+
131537
+ if (!geometryCreatedInTile[geometryId]) {
131538
+
131539
+ sceneModel.createGeometry({
131540
+ id: geometryId,
131541
+ primitive: geometryArrays.primitiveName,
131542
+ positionsCompressed: geometryArrays.geometryPositions,
131543
+ normalsCompressed: geometryArrays.geometryNormals,
131544
+ uv: geometryArrays.geometryUVs,
131545
+ colorsCompressed: geometryArrays.geometryColors,
131546
+ indices: geometryArrays.geometryIndices,
131547
+ edgeIndices: geometryArrays.geometryEdgeIndices,
131548
+ positionsDecodeMatrix: reusedGeometriesDecodeMatrix
131549
+ });
131550
+
131551
+ geometryCreatedInTile[geometryId] = true;
131552
+ }
131553
+
131554
+ sceneModel.createMesh(utils.apply(meshDefaults, {
131555
+ id: meshId,
131556
+ geometryId,
131557
+ textureSetId,
131558
+ matrix: meshMatrix,
131559
+ color: meshColor,
131560
+ metallic: meshMetallic,
131561
+ roughness: meshRoughness,
131562
+ opacity: meshOpacity,
131563
+ origin: tileCenter
131564
+ }));
131565
+
131566
+ meshIds.push(meshId);
131567
+ }
131568
+ }
131569
+
131570
+ } else { // Do not reuse geometry
131571
+
131572
+ const primitiveType = eachGeometryPrimitiveType[geometryIndex];
131573
+
131574
+ let primitiveName;
131575
+ let geometryPositions;
131576
+ let geometryNormals;
131577
+ let geometryUVs;
131578
+ let geometryColors;
131579
+ let geometryIndices;
131580
+ let geometryEdgeIndices;
131581
+ let geometryValid = false;
131582
+
131583
+ switch (primitiveType) {
131584
+ case 0:
131585
+ primitiveName = "solid";
131586
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131587
+ geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131588
+ geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131589
+ geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131590
+ geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131591
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131592
+ break;
131593
+ case 1:
131594
+ primitiveName = "surface";
131595
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131596
+ geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]);
131597
+ geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]);
131598
+ geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131599
+ geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]);
131600
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131601
+ break;
131602
+ case 2:
131603
+ primitiveName = "points";
131604
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131605
+ geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]);
131606
+ geometryValid = (geometryPositions.length > 0);
131607
+ break;
131608
+ case 3:
131609
+ primitiveName = "lines";
131610
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131611
+ geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]);
131612
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131613
+ break;
131614
+ case 4:
131615
+ primitiveName = "lines";
131616
+ geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
131617
+ geometryIndices = lineStripToLines$1(
131618
+ geometryPositions,
131619
+ indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry
131620
+ ? indices.length
131621
+ : eachGeometryIndicesPortion [geometryIndex + 1]));
131622
+ geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0);
131623
+ break;
131624
+ default:
131625
+ continue;
131626
+ }
131627
+
131628
+ if (geometryValid) {
131629
+
131630
+ sceneModel.createMesh(utils.apply(meshDefaults, {
131631
+ id: meshId,
131632
+ textureSetId,
131633
+ origin: tileCenter,
131634
+ primitive: primitiveName,
131635
+ positionsCompressed: geometryPositions,
131636
+ normalsCompressed: geometryNormals,
131637
+ uv: geometryUVs && geometryUVs.length > 0 ? geometryUVs : null,
131638
+ colorsCompressed: geometryColors,
131639
+ indices: geometryIndices,
131640
+ edgeIndices: geometryEdgeIndices,
131641
+ positionsDecodeMatrix: tileDecodeMatrix,
131642
+ color: meshColor,
131643
+ metallic: meshMetallic,
131644
+ roughness: meshRoughness,
131645
+ opacity: meshOpacity
131646
+ }));
131647
+
131648
+ meshIds.push(meshId);
131649
+ }
131650
+ }
131651
+ }
131652
+
131653
+ if (meshIds.length > 0) {
131654
+
131655
+ sceneModel.createEntity(utils.apply(entityDefaults, {
131656
+ id: entityId,
131657
+ isObject: true,
131658
+ meshIds: meshIds
131659
+ }));
131660
+ }
131661
+ }
131662
+ }
131663
+ }
131664
+
131665
+ function lineStripToLines$1(positions, indices) {
131666
+ const linesIndices = [];
131667
+ if (indices.length > 1) {
131668
+ for (let i = 0, len = indices.length - 1; i < len; i++) {
131669
+ linesIndices.push(indices[i]);
131670
+ linesIndices.push(indices[i + 1]);
131671
+ }
131672
+ } else if (positions.length > 1) {
131673
+ for (let i = 0, len = (positions.length / 3) - 1; i < len; i++) {
131674
+ linesIndices.push(i);
131675
+ linesIndices.push(i + 1);
131676
+ }
131677
+ }
131678
+ return linesIndices;
131679
+ }
131680
+
131681
+ /** @private */
131682
+ const ParserV10 = {
131683
+ version: 10,
131684
+ parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
131685
+ const deflatedData = extract(elements);
131686
+ const inflatedData = inflate(deflatedData);
131687
+ load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131688
+ }
131689
+ };
131690
+
131691
+ /*
131692
+ Parser for .XKT Format V11
131693
+ */
131694
+
131695
+ const tempVec4a = math.vec4();
131696
+ const tempVec4b = math.vec4();
131697
+
131698
+ const NUM_TEXTURE_ATTRIBUTES = 9;
131699
+
131700
+ function decodeData(arrayBuffer) {
131701
+ const requiresSwapFromLittleEndian = (function() {
131702
+ const buffer = new ArrayBuffer(2);
131703
+ new Uint16Array(buffer)[0] = 1;
131704
+ return new Uint8Array(buffer)[0] !== 1;
131705
+ })();
131706
+
131707
+ const nextArray = (function() {
131708
+ let i = 0;
131709
+ const dataView = new DataView(arrayBuffer);
131710
+ return function(type) {
131711
+ const idx = 1 + 2 * i++; // `1' for the version nr
131712
+ const byteOffset = dataView.getUint32(idx * 4, true);
131713
+ const byteLength = dataView.getUint32((idx + 1) * 4, true);
131714
+
131715
+ const BPE = type.BYTES_PER_ELEMENT;
131716
+ if (requiresSwapFromLittleEndian && (BPE > 1)) {
131717
+ const subarray = new Uint8Array(arrayBuffer, byteOffset, byteLength);
131718
+ const swaps = BPE / 2;
131719
+ const cnt = subarray.length / BPE;
131720
+ for (let b = 0; b < cnt; b++) {
131721
+ const offset = b * BPE;
131722
+ for (let j = 0; j < swaps; j++) {
131723
+ const i1 = offset + j;
131724
+ const i2 = offset - j + BPE - 1;
131725
+ const tmp = subarray[i1];
131726
+ subarray[i1] = subarray[i2];
131727
+ subarray[i2] = tmp;
131728
+ }
131729
+ }
131730
+ }
131731
+
131732
+ return new type(arrayBuffer, byteOffset, byteLength / BPE);
131733
+ };
131734
+ })();
131735
+
131736
+ const nextObject = (function() {
131737
+ const decoder = new TextDecoder();
131738
+ return () => JSON.parse(decoder.decode(nextArray(Uint8Array)));
131739
+ })();
131740
+
131741
+ return {
131742
+ metadata: nextObject(),
131743
+ textureData: nextArray(Uint8Array), // <<----------------------------- ??? ZIPPing to blame?
131744
+ eachTextureDataPortion: nextArray(Uint32Array),
131745
+ eachTextureAttributes: nextArray(Uint16Array),
131746
+ positions: nextArray(Uint16Array),
131747
+ normals: nextArray(Int8Array),
131748
+ colors: nextArray(Uint8Array),
131749
+ uvs: nextArray(Float32Array),
131750
+ indices: nextArray(Uint32Array),
131751
+ edgeIndices: nextArray(Uint32Array),
131752
+ eachTextureSetTextures: nextArray(Int32Array),
131753
+ matrices: nextArray(Float32Array),
131754
+ reusedGeometriesDecodeMatrix: nextArray(Float32Array),
131755
+ eachGeometryPrimitiveType: nextArray(Uint8Array),
131756
+ eachGeometryPositionsPortion: nextArray(Uint32Array),
131757
+ eachGeometryNormalsPortion: nextArray(Uint32Array),
131758
+ eachGeometryColorsPortion: nextArray(Uint32Array),
131759
+ eachGeometryUVsPortion: nextArray(Uint32Array),
131760
+ eachGeometryIndicesPortion: nextArray(Uint32Array),
131761
+ eachGeometryEdgeIndicesPortion: nextArray(Uint32Array),
131762
+ eachMeshGeometriesPortion: nextArray(Uint32Array),
131763
+ eachMeshMatricesPortion: nextArray(Uint32Array),
131764
+ eachMeshTextureSet: nextArray(Int32Array), // Can be -1
131765
+ eachMeshMaterialAttributes: nextArray(Uint8Array),
131766
+ eachEntityId: nextObject(),
131767
+ eachEntityMeshesPortion: nextArray(Uint32Array),
131768
+ eachTileAABB: nextArray(Float64Array),
131769
+ eachTileEntitiesPortion: nextArray(Uint32Array),
131770
+ };
131771
+ }
131772
+
131092
131773
  const decompressColor = (function () {
131093
131774
  const floatColor = new Float32Array(3);
131094
131775
  return function (intColor) {
@@ -131640,11 +132321,15 @@ function lineStripToLines(positions, indices) {
131640
132321
  }
131641
132322
 
131642
132323
  /** @private */
131643
- const ParserV10 = {
131644
- version: 10,
131645
- parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) {
131646
- const deflatedData = extract(elements);
131647
- const inflatedData = inflate(deflatedData);
132324
+ // V11 uses a single uncompressed Uint8Array buffer to store arrays of different types.
132325
+ // To efficiently create typed arrays from this buffer,
132326
+ // each typed array's source data needs to be aligned with its element byte size.
132327
+ // This sometimes requires padding subarrays inside the single Uint8Array, so the byteOffset needs to be stored alongside element count.
132328
+ // It is a different encoding than used in earlier versions, and requires different approach to parsing elements.
132329
+ const ParserV11 = {
132330
+ version: 11,
132331
+ parseArrayBuffer: function (viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx) {
132332
+ const inflatedData = decodeData(arrayBuffer);
131648
132333
  load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx);
131649
132334
  }
131650
132335
  };
@@ -131661,6 +132346,7 @@ parsers[ParserV7.version] = ParserV7;
131661
132346
  parsers[ParserV8.version] = ParserV8;
131662
132347
  parsers[ParserV9.version] = ParserV9;
131663
132348
  parsers[ParserV10.version] = ParserV10;
132349
+ parsers[ParserV11.version] = ParserV11;
131664
132350
 
131665
132351
  /**
131666
132352
  * {@link Viewer} plugin that loads models from xeokit's optimized *````.XKT````* format.
@@ -132778,6 +133464,12 @@ class XKTLoaderPlugin extends Plugin {
132778
133464
  return;
132779
133465
  }
132780
133466
  // this.log("Loading .xkt V" + xktVersion);
133467
+
133468
+ if (parser.parseArrayBuffer) {
133469
+ parser.parseArrayBuffer(this.viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx);
133470
+ return;
133471
+ }
133472
+
132781
133473
  const numElements = dataView.getUint32(4, true);
132782
133474
  const elements = [];
132783
133475
  let byteOffset = (numElements + 2) * 4;
@@ -139227,7 +139919,6 @@ class DotBIMLoaderPlugin extends Plugin {
139227
139919
  const fileData = ctx.fileData;
139228
139920
  const sceneModel = ctx.sceneModel;
139229
139921
 
139230
- const dbMeshIndices = {};
139231
139922
  const dbMeshLoaded = {};
139232
139923
 
139233
139924
  const ifcProjectId = math.createUUID();
@@ -139265,17 +139956,14 @@ class DotBIMLoaderPlugin extends Plugin {
139265
139956
  propertySets: []
139266
139957
  };
139267
139958
 
139268
- for (let i = 0, len = fileData.meshes.length; i < len; i++) {
139269
- const dbMesh = fileData.meshes[i];
139270
- dbMeshIndices[dbMesh.mesh_id] = i;
139271
- }
139272
-
139273
- const parseDBMesh = (dbMeshId) => {
139959
+ const parseDBMesh = (dbMeshId, element) => {
139274
139960
  if (dbMeshLoaded[dbMeshId]) {
139275
139961
  return;
139276
139962
  }
139277
- const dbMeshIndex = dbMeshIndices[dbMeshId];
139278
- const dbMesh = fileData.meshes[dbMeshIndex];
139963
+
139964
+ const dbMesh = fileData.meshes.find(obj => {
139965
+ return obj.mesh_id === element.mesh_id;
139966
+ });
139279
139967
  sceneModel.createGeometry({
139280
139968
  id: dbMeshId,
139281
139969
  primitive: "triangles",
@@ -139314,7 +140002,7 @@ class DotBIMLoaderPlugin extends Plugin {
139314
140002
 
139315
140003
  if (element.face_colors === undefined) {
139316
140004
 
139317
- parseDBMesh(dbMeshId);
140005
+ parseDBMesh(dbMeshId, element);
139318
140006
 
139319
140007
  const meshId = `${objectId}-mesh`;
139320
140008
 
@@ -139357,7 +140045,9 @@ class DotBIMLoaderPlugin extends Plugin {
139357
140045
  let faceColors = element.face_colors;
139358
140046
  let coloredTrianglesDictionary = {};
139359
140047
  let currentTriangleIndicesCount = 0;
139360
- let dbMesh = fileData.meshes[element.mesh_id];
140048
+ let dbMesh = fileData.meshes.find(obj => {
140049
+ return obj.mesh_id === element.mesh_id;
140050
+ });
139361
140051
  for (let i = 0, len = faceColors.length; i < len; i+=4) {
139362
140052
  let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
139363
140053
  if (coloredTrianglesDictionary[faceColor] === undefined) {
@@ -139843,7 +140533,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
139843
140533
  const copyCanvasPos = (event, vec2) => {
139844
140534
  vec2[0] = event.clientX;
139845
140535
  vec2[1] = event.clientY;
139846
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
140536
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
139847
140537
  return vec2;
139848
140538
  };
139849
140539
 
@@ -139918,7 +140608,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
139918
140608
  const copyCanvasPos = (event, vec2) => {
139919
140609
  vec2[0] = event.clientX;
139920
140610
  vec2[1] = event.clientY;
139921
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
140611
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
139922
140612
  return vec2;
139923
140613
  };
139924
140614
 
@@ -141212,7 +141902,7 @@ class ZoneTranslateControl extends Component {
141212
141902
  const copyCanvasPos = (event, vec2) => {
141213
141903
  vec2[0] = event.clientX;
141214
141904
  vec2[1] = event.clientY;
141215
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
141905
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
141216
141906
  return vec2;
141217
141907
  };
141218
141908