@xeokit/xeokit-sdk 2.4.2-beta-38 → 2.4.2-beta-40

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 (24) hide show
  1. package/dist/xeokit-sdk.cjs.js +162 -40
  2. package/dist/xeokit-sdk.es.js +162 -40
  3. package/dist/xeokit-sdk.es5.js +264 -251
  4. package/dist/xeokit-sdk.min.cjs.js +2 -2
  5. package/dist/xeokit-sdk.min.es.js +2 -2
  6. package/dist/xeokit-sdk.min.es5.js +2 -2
  7. package/package.json +1 -1
  8. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +10 -5
  9. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +7 -0
  10. package/src/viewer/scene/model/SceneModel.js +1 -1
  11. package/src/viewer/scene/model/SceneModelMesh.js +2 -0
  12. package/src/viewer/scene/model/dtx/triangles/TrianglesDataTextureLayer.js +24 -9
  13. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +1 -1
  14. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +1 -1
  15. package/src/viewer/scene/model/vbo/linesBatching/LinesBatchingLayer.js +19 -3
  16. package/src/viewer/scene/model/vbo/linesInstancing/LinesInstancingLayer.js +19 -1
  17. package/src/viewer/scene/model/vbo/pointsBatching/PointsBatchingLayer.js +21 -6
  18. package/src/viewer/scene/model/vbo/pointsInstancing/PointsInstancingLayer.js +17 -2
  19. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthBufInitRenderer.js +1 -1
  20. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthRenderer.js +1 -1
  21. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthBufInitRenderer.js +1 -1
  22. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthRenderer.js +1 -1
  23. package/src/viewer/scene/model/vbo/trianglesBatching/TrianglesBatchingLayer.js +18 -8
  24. package/src/viewer/scene/model/vbo/trianglesInstancing/TrianglesInstancingLayer.js +18 -2
@@ -12011,7 +12011,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12011
12011
  const cameraControl = this.angleMeasurementsPlugin.viewer.cameraControl;
12012
12012
  const pointerLens = this.pointerLens;
12013
12013
  let mouseHovering = false;
12014
- let mouseHoverEntity = false;
12014
+ let hoveredEntity = null;
12015
12015
  let lastMouseCanvasX = 0;
12016
12016
  let lastMouseCanvasY = 0;
12017
12017
  const mouseWorldPos = math.vec3();
@@ -12043,7 +12043,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12043
12043
  }
12044
12044
  const canvasPos = event.snappedCanvasPos || event.canvasPos;
12045
12045
  mouseHovering = true;
12046
- mouseHoverEntity = event.entity;
12046
+ hoveredEntity = event.entity;
12047
12047
  mouseWorldPos.set(event.worldPos);
12048
12048
  mouseHoverCanvasPos.set(canvasPos);
12049
12049
  switch (this._mouseState) {
@@ -12058,6 +12058,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12058
12058
  this._currentAngleMeasurement.cornerVisible = true;
12059
12059
  this._currentAngleMeasurement.angleVisible = false;
12060
12060
  this._currentAngleMeasurement.corner.worldPos = event.worldPos;
12061
+ this._currentAngleMeasurement.corner.entity = event.entity;
12061
12062
  }
12062
12063
  this.markerDiv.style.marginLeft = `-10000px`;
12063
12064
  this.markerDiv.style.marginTop = `-10000px`;
@@ -12069,6 +12070,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12069
12070
  this._currentAngleMeasurement.targetVisible = true;
12070
12071
  this._currentAngleMeasurement.angleVisible = true;
12071
12072
  this._currentAngleMeasurement.target.worldPos = event.worldPos;
12073
+ this._currentAngleMeasurement.target.entity = event.entity;
12072
12074
  }
12073
12075
  this.markerDiv.style.marginLeft = `-10000px`;
12074
12076
  this.markerDiv.style.marginTop = `-10000px`;
@@ -12099,15 +12101,12 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12099
12101
  this._currentAngleMeasurement = this.angleMeasurementsPlugin.createMeasurement({
12100
12102
  id: math.createUUID(),
12101
12103
  origin: {
12102
- entity: mouseHoverEntity,
12103
12104
  worldPos: mouseWorldPos
12104
12105
  },
12105
12106
  corner: {
12106
- entity: mouseHoverEntity,
12107
12107
  worldPos: mouseWorldPos
12108
12108
  },
12109
12109
  target: {
12110
- entity: mouseHoverEntity,
12111
12110
  worldPos: mouseWorldPos
12112
12111
  },
12113
12112
  approximate: true
@@ -12119,6 +12118,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12119
12118
  this._currentAngleMeasurement.targetWireVisible = false;
12120
12119
  this._currentAngleMeasurement.targetVisible = false;
12121
12120
  this._currentAngleMeasurement.angleVisible = false;
12121
+ this._currentAngleMeasurement.origin.entity = hoveredEntity;
12122
12122
  this._mouseState = MOUSE_FINDING_CORNER;
12123
12123
  this.angleMeasurementsPlugin.fire("measurementStart", this._currentAngleMeasurement);
12124
12124
  }
@@ -12128,11 +12128,13 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12128
12128
  this._currentAngleMeasurement.targetWireVisible = false;
12129
12129
  this._currentAngleMeasurement.targetVisible = true;
12130
12130
  this._currentAngleMeasurement.angleVisible = true;
12131
+ this._currentAngleMeasurement.corner.entity = hoveredEntity;
12131
12132
  this._mouseState = MOUSE_FINDING_TARGET;
12132
12133
  } else {
12133
12134
  if (this._currentAngleMeasurement) {
12134
12135
  this._currentAngleMeasurement.destroy();
12135
12136
  this._currentAngleMeasurement = null;
12137
+ hoveredEntity = null;
12136
12138
  this._mouseState = MOUSE_FINDING_ORIGIN;
12137
12139
  this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12138
12140
  }
@@ -12142,7 +12144,9 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12142
12144
  if (mouseHovering) {
12143
12145
  this._currentAngleMeasurement.targetVisible = true;
12144
12146
  this._currentAngleMeasurement.angleVisible = true;
12147
+ this._currentAngleMeasurement.target.entity = hoveredEntity;
12145
12148
  this._currentAngleMeasurement.clickable = true;
12149
+ hoveredEntity = null;
12146
12150
  this.angleMeasurementsPlugin.fire("measurementEnd", this._currentAngleMeasurement);
12147
12151
  this._currentAngleMeasurement = null;
12148
12152
  this._mouseState = MOUSE_FINDING_ORIGIN;
@@ -12150,6 +12154,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12150
12154
  if (this._currentAngleMeasurement) {
12151
12155
  this._currentAngleMeasurement.destroy();
12152
12156
  this._currentAngleMeasurement = null;
12157
+ hoveredEntity = null;
12153
12158
  this._mouseState = MOUSE_FINDING_ORIGIN;
12154
12159
  this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12155
12160
  }
@@ -50116,6 +50121,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50116
50121
  let pointerDownCanvasX;
50117
50122
  let pointerDownCanvasY;
50118
50123
  const clickTolerance = 20;
50124
+ let hoveredEntity = null;
50119
50125
 
50120
50126
  this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
50121
50127
 
@@ -50150,6 +50156,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50150
50156
  this._markerDiv.style.background = "pink";
50151
50157
  this._markerDiv.style.border = "2px solid red";
50152
50158
  }
50159
+ hoveredEntity = event.entity;
50153
50160
  } else {
50154
50161
  this._markerDiv.style.marginLeft = `-10000px`;
50155
50162
  this._markerDiv.style.marginTop = `-10000px`;
@@ -50188,6 +50195,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50188
50195
  }
50189
50196
  if (this._currentDistanceMeasurement) {
50190
50197
  if (mouseHovering) {
50198
+ this._currentDistanceMeasurement.target.entity = hoveredEntity;
50199
+ hoveredEntity = null;
50191
50200
  this._currentDistanceMeasurement.clickable = true;
50192
50201
  this.distanceMeasurementsPlugin.fire("measurementEnd", this._currentDistanceMeasurement);
50193
50202
  this._currentDistanceMeasurement = null;
@@ -50195,6 +50204,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50195
50204
  this._currentDistanceMeasurement.destroy();
50196
50205
  this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
50197
50206
  this._currentDistanceMeasurement = null;
50207
+ hoveredEntity = null;
50198
50208
  }
50199
50209
  } else {
50200
50210
  if (mouseHovering) {
@@ -50215,6 +50225,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50215
50225
  this._currentDistanceMeasurementInitState.wireVisible = this._currentDistanceMeasurement.wireVisible;
50216
50226
  this._currentDistanceMeasurementInitState.targetVisible = this._currentDistanceMeasurement.targetVisible;
50217
50227
  this._currentDistanceMeasurement.clickable = false;
50228
+ this._currentDistanceMeasurement.origin.entity = hoveredEntity;
50229
+ hoveredEntity = null;
50218
50230
  this.fire("measurementStart", this._currentDistanceMeasurement);
50219
50231
  }
50220
50232
  }
@@ -56327,6 +56339,7 @@ class SceneModelMesh {
56327
56339
 
56328
56340
  _sceneModelDirty() {
56329
56341
  this._aabbWorldDirty = true;
56342
+ this.layer.aabbDirty = true;
56330
56343
  }
56331
56344
 
56332
56345
  _transformDirty() {
@@ -56336,6 +56349,7 @@ class SceneModelMesh {
56336
56349
  this._matrixUpdateScheduled = true;
56337
56350
  }
56338
56351
  this._aabbWorldDirty = true;
56352
+ this.layer.aabbDirty = true;
56339
56353
  if (this.entity) {
56340
56354
  this.entity._transformDirty();
56341
56355
  }
@@ -60659,7 +60673,7 @@ class SnapBatchingDepthBufInitRenderer extends VBOSceneModelRenderer {
60659
60673
  const state = batchingLayer._state;
60660
60674
  const origin = batchingLayer._state.origin;
60661
60675
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
60662
- const aabb = model.aabb;
60676
+ const aabb = batchingLayer.aabb; // Per-layer AABB for best RTC accuracy
60663
60677
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
60664
60678
 
60665
60679
  if (this._vaoCache.has(batchingLayer)) {
@@ -60968,7 +60982,7 @@ class SnapBatchingDepthRenderer extends VBOSceneModelRenderer{
60968
60982
  const state = batchingLayer._state;
60969
60983
  const origin = batchingLayer._state.origin;
60970
60984
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
60971
- const aabb = model.aabb;
60985
+ const aabb = batchingLayer.aabb; // Per-layer AABB for best RTC accuracy
60972
60986
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
60973
60987
 
60974
60988
  if (this._vaoCache.has(batchingLayer)) {
@@ -61415,9 +61429,12 @@ class TrianglesBatchingLayer {
61415
61429
 
61416
61430
  this._modelAABB = math.collapseAABB3(); // Model-space AABB
61417
61431
  this._portions = [];
61418
-
61432
+ this._meshes = [];
61419
61433
  this._numVerts = 0;
61420
61434
 
61435
+ this._aabb = math.collapseAABB3();
61436
+ this.aabbDirty = true;
61437
+
61421
61438
  this._finalized = false;
61422
61439
 
61423
61440
  if (cfg.positionsDecodeMatrix) {
@@ -61448,6 +61465,16 @@ class TrianglesBatchingLayer {
61448
61465
  this.solid = !!cfg.solid;
61449
61466
  }
61450
61467
 
61468
+ get aabb() {
61469
+ if (this.aabbDirty) {
61470
+ math.collapseAABB3(this._aabb);
61471
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
61472
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
61473
+ }
61474
+ this.aabbDirty = false;
61475
+ }
61476
+ }
61477
+
61451
61478
  /**
61452
61479
  * Tests if there is room for another portion in this TrianglesBatchingLayer.
61453
61480
  *
@@ -61467,6 +61494,7 @@ class TrianglesBatchingLayer {
61467
61494
  *
61468
61495
  * Gives the portion the specified geometry, color and matrix.
61469
61496
  *
61497
+ * @param mesh The SceneModelMesh that owns the portion
61470
61498
  * @param cfg.positions Flat float Local-space positions array.
61471
61499
  * @param cfg.positionsCompressed Flat quantized positions array - decompressed with TrianglesBatchingLayer positionsDecodeMatrix
61472
61500
  * @param [cfg.normals] Flat float normals array.
@@ -61485,7 +61513,7 @@ class TrianglesBatchingLayer {
61485
61513
  * @param cfg.pickColor Quantized pick color
61486
61514
  * @returns {number} Portion ID
61487
61515
  */
61488
- createPortion(cfg) {
61516
+ createPortion(mesh, cfg) {
61489
61517
 
61490
61518
  if (this._finalized) {
61491
61519
  throw "Already finalized";
@@ -61524,8 +61552,7 @@ class TrianglesBatchingLayer {
61524
61552
  for (let i = 0, len = positionsCompressed.length; i < len; i++) {
61525
61553
  buffer.positions.push(positionsCompressed[i]);
61526
61554
  }
61527
- }
61528
- else {
61555
+ } else {
61529
61556
  if (!positions) {
61530
61557
  throw "positions expected";
61531
61558
  }
@@ -61642,13 +61669,10 @@ class TrianglesBatchingLayer {
61642
61669
  }
61643
61670
 
61644
61671
  this._portions.push(portion);
61645
-
61646
61672
  this._numPortions++;
61647
-
61648
61673
  this.model.numPortions++;
61649
-
61650
61674
  this._numVerts += portion.numVerts;
61651
-
61675
+ this._meshes.push(mesh);
61652
61676
  return portionId;
61653
61677
  }
61654
61678
 
@@ -65666,7 +65690,7 @@ class SnapInstancingDepthBufInitRenderer extends VBOSceneModelRenderer {
65666
65690
  const state = instancingLayer._state;
65667
65691
  const origin = instancingLayer._state.origin;
65668
65692
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
65669
- const aabb = model.aabb;
65693
+ const aabb = instancingLayer.aabb; // Per-layer AABB for best RTC accuracy
65670
65694
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
65671
65695
 
65672
65696
  if (this._vaoCache.has(instancingLayer)) {
@@ -66002,7 +66026,7 @@ class SnapInstancingDepthRenderer extends VBOSceneModelRenderer {
66002
66026
  const state = instancingLayer._state;
66003
66027
  const origin = instancingLayer._state.origin;
66004
66028
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
66005
- const aabb = model.aabb;
66029
+ const aabb = instancingLayer.aabb; // Per-layer AABB for best RTC accuracy
66006
66030
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
66007
66031
 
66008
66032
  if (this._vaoCache.has(instancingLayer)) {
@@ -66483,6 +66507,10 @@ class TrianglesInstancingLayer {
66483
66507
  this._modelNormalMatrixCol2 = [];
66484
66508
 
66485
66509
  this._portions = [];
66510
+ this._meshes = [];
66511
+
66512
+ this._aabb = math.collapseAABB3();
66513
+ this.aabbDirty = true;
66486
66514
 
66487
66515
  if (cfg.origin) {
66488
66516
  this._state.origin.set(cfg.origin);
@@ -66503,6 +66531,17 @@ class TrianglesInstancingLayer {
66503
66531
  this.numIndices = cfg.geometry.numIndices;
66504
66532
  }
66505
66533
 
66534
+ get aabb() {
66535
+ if (this.aabbDirty) {
66536
+ math.collapseAABB3(this._aabb);
66537
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
66538
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
66539
+ }
66540
+ this.aabbDirty = false;
66541
+ }
66542
+ return this._aabb;
66543
+ }
66544
+
66506
66545
  /**
66507
66546
  * Creates a new portion within this InstancingLayer, returns the new portion ID.
66508
66547
  *
@@ -66510,6 +66549,7 @@ class TrianglesInstancingLayer {
66510
66549
  *
66511
66550
  * Gives the portion the specified color and matrix.
66512
66551
  *
66552
+ * @param mesh The SceneModelMesh that owns the portion
66513
66553
  * @param cfg Portion params
66514
66554
  * @param cfg.color Color [0..255,0..255,0..255]
66515
66555
  * @param cfg.metallic Metalness factor [0..255]
@@ -66520,7 +66560,7 @@ class TrianglesInstancingLayer {
66520
66560
  * @param cfg.pickColor Quantized pick color
66521
66561
  * @returns {number} Portion ID.
66522
66562
  */
66523
- createPortion(cfg) {
66563
+ createPortion(mesh, cfg) {
66524
66564
 
66525
66565
  const color = cfg.color;
66526
66566
  const metallic = cfg.metallic;
@@ -66612,7 +66652,7 @@ class TrianglesInstancingLayer {
66612
66652
 
66613
66653
  this._numPortions++;
66614
66654
  this.model.numPortions++;
66615
-
66655
+ this._meshes.push(mesh);
66616
66656
  return portionId;
66617
66657
  }
66618
66658
 
@@ -67918,9 +67958,12 @@ class LinesBatchingLayer {
67918
67958
 
67919
67959
  this._modelAABB = math.collapseAABB3(); // Model-space AABB
67920
67960
  this._portions = [];
67921
-
67961
+ this._meshes = [];
67922
67962
  this._numVerts = 0;
67923
67963
 
67964
+ this._aabb = math.collapseAABB3();
67965
+ this.aabbDirty = true;
67966
+
67924
67967
  this._finalized = false;
67925
67968
 
67926
67969
  if (cfg.positionsDecodeMatrix) {
@@ -67941,6 +67984,17 @@ class LinesBatchingLayer {
67941
67984
  this.aabb = math.collapseAABB3();
67942
67985
  }
67943
67986
 
67987
+ get aabb() {
67988
+ if (this.aabbDirty) {
67989
+ math.collapseAABB3(this._aabb);
67990
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
67991
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
67992
+ }
67993
+ this.aabbDirty = false;
67994
+ }
67995
+ return this._aabb;
67996
+ }
67997
+
67944
67998
  /**
67945
67999
  * Tests if there is room for another portion in this LinesBatchingLayer.
67946
68000
  *
@@ -67960,6 +68014,7 @@ class LinesBatchingLayer {
67960
68014
  *
67961
68015
  * Gives the portion the specified geometry, color and matrix.
67962
68016
  *
68017
+ * @param mesh The SceneModelMesh that owns the portion
67963
68018
  * @param cfg.positions Flat float Local-space positions array.
67964
68019
  * @param cfg.positionsCompressed Flat quantized positions array - decompressed with TrianglesBatchingLayer positionsDecodeMatrix
67965
68020
  * @param cfg.indices Flat int indices array.
@@ -67970,7 +68025,7 @@ class LinesBatchingLayer {
67970
68025
  * @param cfg.pickColor Quantized pick color
67971
68026
  * @returns {number} Portion ID
67972
68027
  */
67973
- createPortion(cfg) {
68028
+ createPortion(mesh, cfg) {
67974
68029
 
67975
68030
  if (this._finalized) {
67976
68031
  throw "Already finalized";
@@ -68047,6 +68102,8 @@ class LinesBatchingLayer {
68047
68102
 
68048
68103
  this._numVerts += numVerts;
68049
68104
 
68105
+ this._meshes.push(mesh);
68106
+
68050
68107
  return portionId;
68051
68108
  }
68052
68109
 
@@ -68959,6 +69016,10 @@ class LinesInstancingLayer {
68959
69016
  this._modelMatrixCol2 = [];
68960
69017
 
68961
69018
  this._portions = [];
69019
+ this._meshes = [];
69020
+
69021
+ this._aabb = math.collapseAABB3();
69022
+ this.aabbDirty = true;
68962
69023
 
68963
69024
  if (cfg.origin) {
68964
69025
  this._state.origin = math.vec3(cfg.origin);
@@ -68967,6 +69028,17 @@ class LinesInstancingLayer {
68967
69028
  this._finalized = false;
68968
69029
  }
68969
69030
 
69031
+ get aabb() {
69032
+ if (this.aabbDirty) {
69033
+ math.collapseAABB3(this._aabb);
69034
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
69035
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
69036
+ }
69037
+ this.aabbDirty = false;
69038
+ }
69039
+ return this._aabb;
69040
+ }
69041
+
68970
69042
  /**
68971
69043
  * Creates a new portion within this InstancingLayer, returns the new portion ID.
68972
69044
  *
@@ -68974,13 +69046,14 @@ class LinesInstancingLayer {
68974
69046
  *
68975
69047
  * Gives the portion the specified color and matrix.
68976
69048
  *
69049
+ * @param mesh The SceneModelMesh that owns the portion
68977
69050
  * @param cfg Portion params
68978
69051
  * @param cfg.color Color [0..255,0..255,0..255]
68979
69052
  * @param cfg.opacity Opacity [0..255].
68980
69053
  * @param cfg.meshMatrix Flat float 4x4 matrix.
68981
69054
  * @returns {number} Portion ID.
68982
69055
  */
68983
- createPortion(cfg) {
69056
+ createPortion(mesh, cfg) {
68984
69057
 
68985
69058
  const color = cfg.color;
68986
69059
  const opacity = cfg.opacity;
@@ -69029,6 +69102,8 @@ class LinesInstancingLayer {
69029
69102
  this._numPortions++;
69030
69103
  this.model.numPortions++;
69031
69104
 
69105
+ this._meshes.push(mesh);
69106
+
69032
69107
  return portionId;
69033
69108
  }
69034
69109
 
@@ -70446,6 +70521,10 @@ class PointsBatchingLayer {
70446
70521
 
70447
70522
  this._modelAABB = math.collapseAABB3(); // Model-space AABB
70448
70523
  this._portions = [];
70524
+ this._meshes = [];
70525
+
70526
+ this._aabb = math.collapseAABB3();
70527
+ this.aabbDirty = true;
70449
70528
 
70450
70529
  this._finalized = false;
70451
70530
 
@@ -70467,6 +70546,17 @@ class PointsBatchingLayer {
70467
70546
  this.aabb = math.collapseAABB3();
70468
70547
  }
70469
70548
 
70549
+ get aabb() {
70550
+ if (this.aabbDirty) {
70551
+ math.collapseAABB3(this._aabb);
70552
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
70553
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
70554
+ }
70555
+ this.aabbDirty = false;
70556
+ }
70557
+ return this._aabb;
70558
+ }
70559
+
70470
70560
  /**
70471
70561
  * Tests if there is room for another portion in this PointsBatchingLayer.
70472
70562
  *
@@ -70485,6 +70575,7 @@ class PointsBatchingLayer {
70485
70575
  *
70486
70576
  * Gives the portion the specified geometry, color and matrix.
70487
70577
  *
70578
+ * @param mesh The SceneModelMesh that owns the portion
70488
70579
  * @param cfg.positions Flat float Local-space positions array.
70489
70580
  * @param cfg.positionsCompressed Flat quantized positions array - decompressed with PointsBatchingLayer positionsDecodeMatrix
70490
70581
  * @param [cfg.colorsCompressed] Quantized RGB colors [0..255,0..255,0..255,0..255]
@@ -70495,7 +70586,7 @@ class PointsBatchingLayer {
70495
70586
  * @param cfg.pickColor Quantized pick color
70496
70587
  * @returns {number} Portion ID
70497
70588
  */
70498
- createPortion(cfg) {
70589
+ createPortion(mesh, cfg) {
70499
70590
 
70500
70591
  if (this._finalized) {
70501
70592
  throw "Already finalized";
@@ -70506,7 +70597,7 @@ class PointsBatchingLayer {
70506
70597
  const color = cfg.color;
70507
70598
  const colorsCompressed = cfg.colorsCompressed;
70508
70599
  const colors = cfg.colors;
70509
- const pickColor = cfg.pickColor;
70600
+ const pickColor = cfg.pickColor;
70510
70601
 
70511
70602
  const buffer = this._buffer;
70512
70603
  const positionsIndex = buffer.positions.length;
@@ -70595,7 +70686,7 @@ class PointsBatchingLayer {
70595
70686
 
70596
70687
  this._numPortions++;
70597
70688
  this.model.numPortions++;
70598
-
70689
+ this._meshes.push(mesh);
70599
70690
  return portionId;
70600
70691
  }
70601
70692
 
@@ -70859,7 +70950,7 @@ class PointsBatchingLayer {
70859
70950
  let colorFlag;
70860
70951
  if (!visible || culled || xrayed
70861
70952
  || (highlighted && !this.model.scene.highlightMaterial.glowThrough)
70862
- || (selected && !this.model.scene.selectedMaterial.glowThrough) ) {
70953
+ || (selected && !this.model.scene.selectedMaterial.glowThrough)) {
70863
70954
  colorFlag = RENDER_PASSES.NOT_RENDERED;
70864
70955
  } else {
70865
70956
  if (transparent) {
@@ -70893,7 +70984,7 @@ class PointsBatchingLayer {
70893
70984
  // no edges
70894
70985
  vertFlag |= pickFlag << 12;
70895
70986
  vertFlag |= clippableFlag << 16;
70896
-
70987
+
70897
70988
  tempArray[i] = vertFlag;
70898
70989
  }
70899
70990
 
@@ -72353,10 +72444,24 @@ class PointsInstancingLayer {
72353
72444
  this._modelMatrixCol2 = [];
72354
72445
 
72355
72446
  this._portions = [];
72447
+ this._meshes = [];
72448
+ this._aabb = math.collapseAABB3();
72449
+ this.aabbDirty = true;
72356
72450
 
72357
72451
  this._finalized = false;
72358
72452
  }
72359
72453
 
72454
+ get aabb() {
72455
+ if (this.aabbDirty) {
72456
+ math.collapseAABB3(this._aabb);
72457
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
72458
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
72459
+ }
72460
+ this.aabbDirty = false;
72461
+ }
72462
+ return this._aabb;
72463
+ }
72464
+
72360
72465
  /**
72361
72466
  * Creates a new portion within this InstancingLayer, returns the new portion ID.
72362
72467
  *
@@ -72364,13 +72469,14 @@ class PointsInstancingLayer {
72364
72469
  *
72365
72470
  * Gives the portion the specified color and matrix.
72366
72471
  *
72472
+ * @param mesh The SceneModelMesh that owns the portion
72367
72473
  * @param cfg Portion params
72368
72474
  * @param cfg.meshMatrix Flat float 4x4 matrix.
72369
72475
  * @param [cfg.worldMatrix] Flat float 4x4 matrix.
72370
72476
  * @param cfg.pickColor Quantized pick color
72371
72477
  * @returns {number} Portion ID.
72372
72478
  */
72373
- createPortion(cfg) {
72479
+ createPortion(mesh, cfg) {
72374
72480
 
72375
72481
  const meshMatrix = cfg.meshMatrix;
72376
72482
  const pickColor = cfg.pickColor;
@@ -72414,7 +72520,7 @@ class PointsInstancingLayer {
72414
72520
 
72415
72521
  this._numPortions++;
72416
72522
  this.model.numPortions++;
72417
-
72523
+ this._meshes.push(mesh);
72418
72524
  return portionId;
72419
72525
  }
72420
72526
 
@@ -77373,7 +77479,7 @@ class TrianglesDataTextureSnapDepthRenderer {
77373
77479
  const textureState = state.textureState;
77374
77480
  const origin = dataTextureLayer._state.origin;
77375
77481
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
77376
- const aabb = model.aabb;
77482
+ const aabb = dataTextureLayer.aabb; // Per-layer AABB for best RTC accuracy
77377
77483
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
77378
77484
 
77379
77485
  const coordinateScaler = tempVec3a$e;
@@ -77791,7 +77897,7 @@ class TrianglesDataTextureSnapDepthBufInitRenderer {
77791
77897
  const textureState = state.textureState;
77792
77898
  const origin = dataTextureLayer._state.origin;
77793
77899
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
77794
- const aabb = model.aabb;
77900
+ const aabb = dataTextureLayer.aabb; // Per-layer AABB for best RTC accuracy
77795
77901
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
77796
77902
 
77797
77903
  const coordinateScaler = tempVec3a$d;
@@ -81143,10 +81249,13 @@ class TrianglesDataTextureLayer {
81143
81249
 
81144
81250
  this._bucketGeometries = {};
81145
81251
 
81252
+ this._meshes = [];
81253
+
81146
81254
  /**
81147
81255
  * The axis-aligned World-space boundary of this TrianglesDataTextureLayer's positions.
81148
81256
  */
81149
- this.aabb = math.collapseAABB3();
81257
+ this._aabb = math.collapseAABB3();
81258
+ this.aabbDirty = true;
81150
81259
 
81151
81260
  /**
81152
81261
  * The number of updates in the current frame;
@@ -81156,6 +81265,17 @@ class TrianglesDataTextureLayer {
81156
81265
  this._finalized = false;
81157
81266
  }
81158
81267
 
81268
+ get aabb() {
81269
+ if (this.aabbDirty) {
81270
+ math.collapseAABB3(this._aabb);
81271
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
81272
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
81273
+ }
81274
+ this.aabbDirty = false;
81275
+ }
81276
+ return this._aabb;
81277
+ }
81278
+
81159
81279
  /**
81160
81280
  * Returns whether the ```TrianglesDataTextureLayer``` has room for more portions.
81161
81281
  *
@@ -81200,6 +81320,7 @@ class TrianglesDataTextureLayer {
81200
81320
  *
81201
81321
  * Gives the portion the specified geometry, color and matrix.
81202
81322
  *
81323
+ * @param mesh The SceneModelMesh that owns the portion
81203
81324
  * @param portionCfg.positionsCompressed Flat float Local-space positionsCompressed array.
81204
81325
  * @param [portionCfg.normals] Flat float normals array.
81205
81326
  * @param [portionCfg.colors] Flat float colors array.
@@ -81214,12 +81335,12 @@ class TrianglesDataTextureLayer {
81214
81335
  * @param portionCfg.pickColor Quantized pick color
81215
81336
  * @returns {number} Portion ID
81216
81337
  */
81217
- createPortion(portionCfg) {
81338
+ createPortion(mesh, portionCfg) {
81218
81339
  if (this._finalized) {
81219
81340
  throw "Already finalized";
81220
81341
  }
81221
81342
  const subPortionIds = [];
81222
- // const portionAABB = portionCfg.worldAABB;
81343
+ // const portionAABB = portionCfg.worldAABB;
81223
81344
  portionCfg.buckets.forEach((bucket, bucketIndex) => {
81224
81345
  const bucketGeometryId = portionCfg.geometryId !== undefined && portionCfg.geometryId !== null
81225
81346
  ? `${portionCfg.geometryId}#${bucketIndex}`
@@ -81229,7 +81350,7 @@ class TrianglesDataTextureLayer {
81229
81350
  bucketGeometry = this._createBucketGeometry(portionCfg, bucket);
81230
81351
  this._bucketGeometries[bucketGeometryId] = bucketGeometry;
81231
81352
  }
81232
- // const subPortionAABB = math.collapseAABB3(tempAABB3b);
81353
+ // const subPortionAABB = math.collapseAABB3(tempAABB3b);
81233
81354
  const subPortionId = this._createSubPortion(portionCfg, bucketGeometry, bucket);
81234
81355
  //math.expandAABB3(portionAABB, subPortionAABB);
81235
81356
  subPortionIds.push(subPortionId);
@@ -81247,6 +81368,7 @@ class TrianglesDataTextureLayer {
81247
81368
  const portionId = this._portionToSubPortionsMap.length;
81248
81369
  this._portionToSubPortionsMap.push(subPortionIds);
81249
81370
  this.model.numPortions++;
81371
+ this._meshes.push(mesh);
81250
81372
  return portionId;
81251
81373
  }
81252
81374
 
@@ -81351,7 +81473,7 @@ class TrianglesDataTextureLayer {
81351
81473
  numEdges,
81352
81474
  indicesBase,
81353
81475
  edgeIndicesBase,
81354
- // aabb,
81476
+ // aabb,
81355
81477
  obb: null // Lazy-created in _createSubPortion if needed
81356
81478
  };
81357
81479
 
@@ -81531,7 +81653,7 @@ class TrianglesDataTextureLayer {
81531
81653
  textureState.texturePerVertexIdCoordinates = this._dataTextureGenerator.generateTextureForPositions(
81532
81654
  gl,
81533
81655
  buffer.positionsCompressed,
81534
- buffer.lenPositionsCompressed );
81656
+ buffer.lenPositionsCompressed);
81535
81657
 
81536
81658
  textureState.texturePerPolygonIdPortionIds8Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
81537
81659
  gl,
@@ -82112,7 +82234,7 @@ class TrianglesDataTextureLayer {
82112
82234
  const textureState = this._dataTextureState;
82113
82235
  const gl = this.model.scene.canvas.gl;
82114
82236
  tempMat4a.set(matrix);
82115
- textureState.texturePerObjectInstanceMatrices._textureData.set(tempMat4a, subPortionId*16);
82237
+ textureState.texturePerObjectInstanceMatrices._textureData.set(tempMat4a, subPortionId * 16);
82116
82238
  if (this._deferredSetFlagsActive) {
82117
82239
  this._deferredSetFlagsDirty = true;
82118
82240
  return;
@@ -82135,7 +82257,7 @@ class TrianglesDataTextureLayer {
82135
82257
  );
82136
82258
  // gl.bindTexture (gl.TEXTURE_2D, null);
82137
82259
  }
82138
-
82260
+
82139
82261
  // ---------------------- COLOR RENDERING -----------------------------------
82140
82262
 
82141
82263
  drawColorOpaque(renderFlags, frameCtx) {
@@ -85819,7 +85941,7 @@ class SceneModel extends Component {
85819
85941
  if (cfg.transform) {
85820
85942
  cfg.meshMatrix = cfg.transform.worldMatrix;
85821
85943
  }
85822
- mesh.portionId = mesh.layer.createPortion(cfg);
85944
+ mesh.portionId = mesh.layer.createPortion(mesh, cfg);
85823
85945
  this._meshes[cfg.id] = mesh;
85824
85946
  this._meshList.push(mesh);
85825
85947
  return mesh;