@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
@@ -12015,7 +12015,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12015
12015
  const cameraControl = this.angleMeasurementsPlugin.viewer.cameraControl;
12016
12016
  const pointerLens = this.pointerLens;
12017
12017
  let mouseHovering = false;
12018
- let mouseHoverEntity = false;
12018
+ let hoveredEntity = null;
12019
12019
  let lastMouseCanvasX = 0;
12020
12020
  let lastMouseCanvasY = 0;
12021
12021
  const mouseWorldPos = math.vec3();
@@ -12047,7 +12047,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12047
12047
  }
12048
12048
  const canvasPos = event.snappedCanvasPos || event.canvasPos;
12049
12049
  mouseHovering = true;
12050
- mouseHoverEntity = event.entity;
12050
+ hoveredEntity = event.entity;
12051
12051
  mouseWorldPos.set(event.worldPos);
12052
12052
  mouseHoverCanvasPos.set(canvasPos);
12053
12053
  switch (this._mouseState) {
@@ -12062,6 +12062,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12062
12062
  this._currentAngleMeasurement.cornerVisible = true;
12063
12063
  this._currentAngleMeasurement.angleVisible = false;
12064
12064
  this._currentAngleMeasurement.corner.worldPos = event.worldPos;
12065
+ this._currentAngleMeasurement.corner.entity = event.entity;
12065
12066
  }
12066
12067
  this.markerDiv.style.marginLeft = `-10000px`;
12067
12068
  this.markerDiv.style.marginTop = `-10000px`;
@@ -12073,6 +12074,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12073
12074
  this._currentAngleMeasurement.targetVisible = true;
12074
12075
  this._currentAngleMeasurement.angleVisible = true;
12075
12076
  this._currentAngleMeasurement.target.worldPos = event.worldPos;
12077
+ this._currentAngleMeasurement.target.entity = event.entity;
12076
12078
  }
12077
12079
  this.markerDiv.style.marginLeft = `-10000px`;
12078
12080
  this.markerDiv.style.marginTop = `-10000px`;
@@ -12103,15 +12105,12 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12103
12105
  this._currentAngleMeasurement = this.angleMeasurementsPlugin.createMeasurement({
12104
12106
  id: math.createUUID(),
12105
12107
  origin: {
12106
- entity: mouseHoverEntity,
12107
12108
  worldPos: mouseWorldPos
12108
12109
  },
12109
12110
  corner: {
12110
- entity: mouseHoverEntity,
12111
12111
  worldPos: mouseWorldPos
12112
12112
  },
12113
12113
  target: {
12114
- entity: mouseHoverEntity,
12115
12114
  worldPos: mouseWorldPos
12116
12115
  },
12117
12116
  approximate: true
@@ -12123,6 +12122,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12123
12122
  this._currentAngleMeasurement.targetWireVisible = false;
12124
12123
  this._currentAngleMeasurement.targetVisible = false;
12125
12124
  this._currentAngleMeasurement.angleVisible = false;
12125
+ this._currentAngleMeasurement.origin.entity = hoveredEntity;
12126
12126
  this._mouseState = MOUSE_FINDING_CORNER;
12127
12127
  this.angleMeasurementsPlugin.fire("measurementStart", this._currentAngleMeasurement);
12128
12128
  }
@@ -12132,11 +12132,13 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12132
12132
  this._currentAngleMeasurement.targetWireVisible = false;
12133
12133
  this._currentAngleMeasurement.targetVisible = true;
12134
12134
  this._currentAngleMeasurement.angleVisible = true;
12135
+ this._currentAngleMeasurement.corner.entity = hoveredEntity;
12135
12136
  this._mouseState = MOUSE_FINDING_TARGET;
12136
12137
  } else {
12137
12138
  if (this._currentAngleMeasurement) {
12138
12139
  this._currentAngleMeasurement.destroy();
12139
12140
  this._currentAngleMeasurement = null;
12141
+ hoveredEntity = null;
12140
12142
  this._mouseState = MOUSE_FINDING_ORIGIN;
12141
12143
  this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12142
12144
  }
@@ -12146,7 +12148,9 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12146
12148
  if (mouseHovering) {
12147
12149
  this._currentAngleMeasurement.targetVisible = true;
12148
12150
  this._currentAngleMeasurement.angleVisible = true;
12151
+ this._currentAngleMeasurement.target.entity = hoveredEntity;
12149
12152
  this._currentAngleMeasurement.clickable = true;
12153
+ hoveredEntity = null;
12150
12154
  this.angleMeasurementsPlugin.fire("measurementEnd", this._currentAngleMeasurement);
12151
12155
  this._currentAngleMeasurement = null;
12152
12156
  this._mouseState = MOUSE_FINDING_ORIGIN;
@@ -12154,6 +12158,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12154
12158
  if (this._currentAngleMeasurement) {
12155
12159
  this._currentAngleMeasurement.destroy();
12156
12160
  this._currentAngleMeasurement = null;
12161
+ hoveredEntity = null;
12157
12162
  this._mouseState = MOUSE_FINDING_ORIGIN;
12158
12163
  this.angleMeasurementsPlugin.fire("measurementCancel", this._currentAngleMeasurement);
12159
12164
  }
@@ -50120,6 +50125,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50120
50125
  let pointerDownCanvasX;
50121
50126
  let pointerDownCanvasY;
50122
50127
  const clickTolerance = 20;
50128
+ let hoveredEntity = null;
50123
50129
 
50124
50130
  this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
50125
50131
 
@@ -50154,6 +50160,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50154
50160
  this._markerDiv.style.background = "pink";
50155
50161
  this._markerDiv.style.border = "2px solid red";
50156
50162
  }
50163
+ hoveredEntity = event.entity;
50157
50164
  } else {
50158
50165
  this._markerDiv.style.marginLeft = `-10000px`;
50159
50166
  this._markerDiv.style.marginTop = `-10000px`;
@@ -50192,6 +50199,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50192
50199
  }
50193
50200
  if (this._currentDistanceMeasurement) {
50194
50201
  if (mouseHovering) {
50202
+ this._currentDistanceMeasurement.target.entity = hoveredEntity;
50203
+ hoveredEntity = null;
50195
50204
  this._currentDistanceMeasurement.clickable = true;
50196
50205
  this.distanceMeasurementsPlugin.fire("measurementEnd", this._currentDistanceMeasurement);
50197
50206
  this._currentDistanceMeasurement = null;
@@ -50199,6 +50208,7 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50199
50208
  this._currentDistanceMeasurement.destroy();
50200
50209
  this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
50201
50210
  this._currentDistanceMeasurement = null;
50211
+ hoveredEntity = null;
50202
50212
  }
50203
50213
  } else {
50204
50214
  if (mouseHovering) {
@@ -50219,6 +50229,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50219
50229
  this._currentDistanceMeasurementInitState.wireVisible = this._currentDistanceMeasurement.wireVisible;
50220
50230
  this._currentDistanceMeasurementInitState.targetVisible = this._currentDistanceMeasurement.targetVisible;
50221
50231
  this._currentDistanceMeasurement.clickable = false;
50232
+ this._currentDistanceMeasurement.origin.entity = hoveredEntity;
50233
+ hoveredEntity = null;
50222
50234
  this.fire("measurementStart", this._currentDistanceMeasurement);
50223
50235
  }
50224
50236
  }
@@ -56331,6 +56343,7 @@ class SceneModelMesh {
56331
56343
 
56332
56344
  _sceneModelDirty() {
56333
56345
  this._aabbWorldDirty = true;
56346
+ this.layer.aabbDirty = true;
56334
56347
  }
56335
56348
 
56336
56349
  _transformDirty() {
@@ -56340,6 +56353,7 @@ class SceneModelMesh {
56340
56353
  this._matrixUpdateScheduled = true;
56341
56354
  }
56342
56355
  this._aabbWorldDirty = true;
56356
+ this.layer.aabbDirty = true;
56343
56357
  if (this.entity) {
56344
56358
  this.entity._transformDirty();
56345
56359
  }
@@ -60663,7 +60677,7 @@ class SnapBatchingDepthBufInitRenderer extends VBOSceneModelRenderer {
60663
60677
  const state = batchingLayer._state;
60664
60678
  const origin = batchingLayer._state.origin;
60665
60679
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
60666
- const aabb = model.aabb;
60680
+ const aabb = batchingLayer.aabb; // Per-layer AABB for best RTC accuracy
60667
60681
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
60668
60682
 
60669
60683
  if (this._vaoCache.has(batchingLayer)) {
@@ -60972,7 +60986,7 @@ class SnapBatchingDepthRenderer extends VBOSceneModelRenderer{
60972
60986
  const state = batchingLayer._state;
60973
60987
  const origin = batchingLayer._state.origin;
60974
60988
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
60975
- const aabb = model.aabb;
60989
+ const aabb = batchingLayer.aabb; // Per-layer AABB for best RTC accuracy
60976
60990
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
60977
60991
 
60978
60992
  if (this._vaoCache.has(batchingLayer)) {
@@ -61419,9 +61433,12 @@ class TrianglesBatchingLayer {
61419
61433
 
61420
61434
  this._modelAABB = math.collapseAABB3(); // Model-space AABB
61421
61435
  this._portions = [];
61422
-
61436
+ this._meshes = [];
61423
61437
  this._numVerts = 0;
61424
61438
 
61439
+ this._aabb = math.collapseAABB3();
61440
+ this.aabbDirty = true;
61441
+
61425
61442
  this._finalized = false;
61426
61443
 
61427
61444
  if (cfg.positionsDecodeMatrix) {
@@ -61452,6 +61469,16 @@ class TrianglesBatchingLayer {
61452
61469
  this.solid = !!cfg.solid;
61453
61470
  }
61454
61471
 
61472
+ get aabb() {
61473
+ if (this.aabbDirty) {
61474
+ math.collapseAABB3(this._aabb);
61475
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
61476
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
61477
+ }
61478
+ this.aabbDirty = false;
61479
+ }
61480
+ }
61481
+
61455
61482
  /**
61456
61483
  * Tests if there is room for another portion in this TrianglesBatchingLayer.
61457
61484
  *
@@ -61471,6 +61498,7 @@ class TrianglesBatchingLayer {
61471
61498
  *
61472
61499
  * Gives the portion the specified geometry, color and matrix.
61473
61500
  *
61501
+ * @param mesh The SceneModelMesh that owns the portion
61474
61502
  * @param cfg.positions Flat float Local-space positions array.
61475
61503
  * @param cfg.positionsCompressed Flat quantized positions array - decompressed with TrianglesBatchingLayer positionsDecodeMatrix
61476
61504
  * @param [cfg.normals] Flat float normals array.
@@ -61489,7 +61517,7 @@ class TrianglesBatchingLayer {
61489
61517
  * @param cfg.pickColor Quantized pick color
61490
61518
  * @returns {number} Portion ID
61491
61519
  */
61492
- createPortion(cfg) {
61520
+ createPortion(mesh, cfg) {
61493
61521
 
61494
61522
  if (this._finalized) {
61495
61523
  throw "Already finalized";
@@ -61528,8 +61556,7 @@ class TrianglesBatchingLayer {
61528
61556
  for (let i = 0, len = positionsCompressed.length; i < len; i++) {
61529
61557
  buffer.positions.push(positionsCompressed[i]);
61530
61558
  }
61531
- }
61532
- else {
61559
+ } else {
61533
61560
  if (!positions) {
61534
61561
  throw "positions expected";
61535
61562
  }
@@ -61646,13 +61673,10 @@ class TrianglesBatchingLayer {
61646
61673
  }
61647
61674
 
61648
61675
  this._portions.push(portion);
61649
-
61650
61676
  this._numPortions++;
61651
-
61652
61677
  this.model.numPortions++;
61653
-
61654
61678
  this._numVerts += portion.numVerts;
61655
-
61679
+ this._meshes.push(mesh);
61656
61680
  return portionId;
61657
61681
  }
61658
61682
 
@@ -65670,7 +65694,7 @@ class SnapInstancingDepthBufInitRenderer extends VBOSceneModelRenderer {
65670
65694
  const state = instancingLayer._state;
65671
65695
  const origin = instancingLayer._state.origin;
65672
65696
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
65673
- const aabb = model.aabb;
65697
+ const aabb = instancingLayer.aabb; // Per-layer AABB for best RTC accuracy
65674
65698
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
65675
65699
 
65676
65700
  if (this._vaoCache.has(instancingLayer)) {
@@ -66006,7 +66030,7 @@ class SnapInstancingDepthRenderer extends VBOSceneModelRenderer {
66006
66030
  const state = instancingLayer._state;
66007
66031
  const origin = instancingLayer._state.origin;
66008
66032
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
66009
- const aabb = model.aabb;
66033
+ const aabb = instancingLayer.aabb; // Per-layer AABB for best RTC accuracy
66010
66034
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
66011
66035
 
66012
66036
  if (this._vaoCache.has(instancingLayer)) {
@@ -66487,6 +66511,10 @@ class TrianglesInstancingLayer {
66487
66511
  this._modelNormalMatrixCol2 = [];
66488
66512
 
66489
66513
  this._portions = [];
66514
+ this._meshes = [];
66515
+
66516
+ this._aabb = math.collapseAABB3();
66517
+ this.aabbDirty = true;
66490
66518
 
66491
66519
  if (cfg.origin) {
66492
66520
  this._state.origin.set(cfg.origin);
@@ -66507,6 +66535,17 @@ class TrianglesInstancingLayer {
66507
66535
  this.numIndices = cfg.geometry.numIndices;
66508
66536
  }
66509
66537
 
66538
+ get aabb() {
66539
+ if (this.aabbDirty) {
66540
+ math.collapseAABB3(this._aabb);
66541
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
66542
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
66543
+ }
66544
+ this.aabbDirty = false;
66545
+ }
66546
+ return this._aabb;
66547
+ }
66548
+
66510
66549
  /**
66511
66550
  * Creates a new portion within this InstancingLayer, returns the new portion ID.
66512
66551
  *
@@ -66514,6 +66553,7 @@ class TrianglesInstancingLayer {
66514
66553
  *
66515
66554
  * Gives the portion the specified color and matrix.
66516
66555
  *
66556
+ * @param mesh The SceneModelMesh that owns the portion
66517
66557
  * @param cfg Portion params
66518
66558
  * @param cfg.color Color [0..255,0..255,0..255]
66519
66559
  * @param cfg.metallic Metalness factor [0..255]
@@ -66524,7 +66564,7 @@ class TrianglesInstancingLayer {
66524
66564
  * @param cfg.pickColor Quantized pick color
66525
66565
  * @returns {number} Portion ID.
66526
66566
  */
66527
- createPortion(cfg) {
66567
+ createPortion(mesh, cfg) {
66528
66568
 
66529
66569
  const color = cfg.color;
66530
66570
  const metallic = cfg.metallic;
@@ -66616,7 +66656,7 @@ class TrianglesInstancingLayer {
66616
66656
 
66617
66657
  this._numPortions++;
66618
66658
  this.model.numPortions++;
66619
-
66659
+ this._meshes.push(mesh);
66620
66660
  return portionId;
66621
66661
  }
66622
66662
 
@@ -67922,9 +67962,12 @@ class LinesBatchingLayer {
67922
67962
 
67923
67963
  this._modelAABB = math.collapseAABB3(); // Model-space AABB
67924
67964
  this._portions = [];
67925
-
67965
+ this._meshes = [];
67926
67966
  this._numVerts = 0;
67927
67967
 
67968
+ this._aabb = math.collapseAABB3();
67969
+ this.aabbDirty = true;
67970
+
67928
67971
  this._finalized = false;
67929
67972
 
67930
67973
  if (cfg.positionsDecodeMatrix) {
@@ -67945,6 +67988,17 @@ class LinesBatchingLayer {
67945
67988
  this.aabb = math.collapseAABB3();
67946
67989
  }
67947
67990
 
67991
+ get aabb() {
67992
+ if (this.aabbDirty) {
67993
+ math.collapseAABB3(this._aabb);
67994
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
67995
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
67996
+ }
67997
+ this.aabbDirty = false;
67998
+ }
67999
+ return this._aabb;
68000
+ }
68001
+
67948
68002
  /**
67949
68003
  * Tests if there is room for another portion in this LinesBatchingLayer.
67950
68004
  *
@@ -67964,6 +68018,7 @@ class LinesBatchingLayer {
67964
68018
  *
67965
68019
  * Gives the portion the specified geometry, color and matrix.
67966
68020
  *
68021
+ * @param mesh The SceneModelMesh that owns the portion
67967
68022
  * @param cfg.positions Flat float Local-space positions array.
67968
68023
  * @param cfg.positionsCompressed Flat quantized positions array - decompressed with TrianglesBatchingLayer positionsDecodeMatrix
67969
68024
  * @param cfg.indices Flat int indices array.
@@ -67974,7 +68029,7 @@ class LinesBatchingLayer {
67974
68029
  * @param cfg.pickColor Quantized pick color
67975
68030
  * @returns {number} Portion ID
67976
68031
  */
67977
- createPortion(cfg) {
68032
+ createPortion(mesh, cfg) {
67978
68033
 
67979
68034
  if (this._finalized) {
67980
68035
  throw "Already finalized";
@@ -68051,6 +68106,8 @@ class LinesBatchingLayer {
68051
68106
 
68052
68107
  this._numVerts += numVerts;
68053
68108
 
68109
+ this._meshes.push(mesh);
68110
+
68054
68111
  return portionId;
68055
68112
  }
68056
68113
 
@@ -68963,6 +69020,10 @@ class LinesInstancingLayer {
68963
69020
  this._modelMatrixCol2 = [];
68964
69021
 
68965
69022
  this._portions = [];
69023
+ this._meshes = [];
69024
+
69025
+ this._aabb = math.collapseAABB3();
69026
+ this.aabbDirty = true;
68966
69027
 
68967
69028
  if (cfg.origin) {
68968
69029
  this._state.origin = math.vec3(cfg.origin);
@@ -68971,6 +69032,17 @@ class LinesInstancingLayer {
68971
69032
  this._finalized = false;
68972
69033
  }
68973
69034
 
69035
+ get aabb() {
69036
+ if (this.aabbDirty) {
69037
+ math.collapseAABB3(this._aabb);
69038
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
69039
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
69040
+ }
69041
+ this.aabbDirty = false;
69042
+ }
69043
+ return this._aabb;
69044
+ }
69045
+
68974
69046
  /**
68975
69047
  * Creates a new portion within this InstancingLayer, returns the new portion ID.
68976
69048
  *
@@ -68978,13 +69050,14 @@ class LinesInstancingLayer {
68978
69050
  *
68979
69051
  * Gives the portion the specified color and matrix.
68980
69052
  *
69053
+ * @param mesh The SceneModelMesh that owns the portion
68981
69054
  * @param cfg Portion params
68982
69055
  * @param cfg.color Color [0..255,0..255,0..255]
68983
69056
  * @param cfg.opacity Opacity [0..255].
68984
69057
  * @param cfg.meshMatrix Flat float 4x4 matrix.
68985
69058
  * @returns {number} Portion ID.
68986
69059
  */
68987
- createPortion(cfg) {
69060
+ createPortion(mesh, cfg) {
68988
69061
 
68989
69062
  const color = cfg.color;
68990
69063
  const opacity = cfg.opacity;
@@ -69033,6 +69106,8 @@ class LinesInstancingLayer {
69033
69106
  this._numPortions++;
69034
69107
  this.model.numPortions++;
69035
69108
 
69109
+ this._meshes.push(mesh);
69110
+
69036
69111
  return portionId;
69037
69112
  }
69038
69113
 
@@ -70450,6 +70525,10 @@ class PointsBatchingLayer {
70450
70525
 
70451
70526
  this._modelAABB = math.collapseAABB3(); // Model-space AABB
70452
70527
  this._portions = [];
70528
+ this._meshes = [];
70529
+
70530
+ this._aabb = math.collapseAABB3();
70531
+ this.aabbDirty = true;
70453
70532
 
70454
70533
  this._finalized = false;
70455
70534
 
@@ -70471,6 +70550,17 @@ class PointsBatchingLayer {
70471
70550
  this.aabb = math.collapseAABB3();
70472
70551
  }
70473
70552
 
70553
+ get aabb() {
70554
+ if (this.aabbDirty) {
70555
+ math.collapseAABB3(this._aabb);
70556
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
70557
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
70558
+ }
70559
+ this.aabbDirty = false;
70560
+ }
70561
+ return this._aabb;
70562
+ }
70563
+
70474
70564
  /**
70475
70565
  * Tests if there is room for another portion in this PointsBatchingLayer.
70476
70566
  *
@@ -70489,6 +70579,7 @@ class PointsBatchingLayer {
70489
70579
  *
70490
70580
  * Gives the portion the specified geometry, color and matrix.
70491
70581
  *
70582
+ * @param mesh The SceneModelMesh that owns the portion
70492
70583
  * @param cfg.positions Flat float Local-space positions array.
70493
70584
  * @param cfg.positionsCompressed Flat quantized positions array - decompressed with PointsBatchingLayer positionsDecodeMatrix
70494
70585
  * @param [cfg.colorsCompressed] Quantized RGB colors [0..255,0..255,0..255,0..255]
@@ -70499,7 +70590,7 @@ class PointsBatchingLayer {
70499
70590
  * @param cfg.pickColor Quantized pick color
70500
70591
  * @returns {number} Portion ID
70501
70592
  */
70502
- createPortion(cfg) {
70593
+ createPortion(mesh, cfg) {
70503
70594
 
70504
70595
  if (this._finalized) {
70505
70596
  throw "Already finalized";
@@ -70510,7 +70601,7 @@ class PointsBatchingLayer {
70510
70601
  const color = cfg.color;
70511
70602
  const colorsCompressed = cfg.colorsCompressed;
70512
70603
  const colors = cfg.colors;
70513
- const pickColor = cfg.pickColor;
70604
+ const pickColor = cfg.pickColor;
70514
70605
 
70515
70606
  const buffer = this._buffer;
70516
70607
  const positionsIndex = buffer.positions.length;
@@ -70599,7 +70690,7 @@ class PointsBatchingLayer {
70599
70690
 
70600
70691
  this._numPortions++;
70601
70692
  this.model.numPortions++;
70602
-
70693
+ this._meshes.push(mesh);
70603
70694
  return portionId;
70604
70695
  }
70605
70696
 
@@ -70863,7 +70954,7 @@ class PointsBatchingLayer {
70863
70954
  let colorFlag;
70864
70955
  if (!visible || culled || xrayed
70865
70956
  || (highlighted && !this.model.scene.highlightMaterial.glowThrough)
70866
- || (selected && !this.model.scene.selectedMaterial.glowThrough) ) {
70957
+ || (selected && !this.model.scene.selectedMaterial.glowThrough)) {
70867
70958
  colorFlag = RENDER_PASSES.NOT_RENDERED;
70868
70959
  } else {
70869
70960
  if (transparent) {
@@ -70897,7 +70988,7 @@ class PointsBatchingLayer {
70897
70988
  // no edges
70898
70989
  vertFlag |= pickFlag << 12;
70899
70990
  vertFlag |= clippableFlag << 16;
70900
-
70991
+
70901
70992
  tempArray[i] = vertFlag;
70902
70993
  }
70903
70994
 
@@ -72357,10 +72448,24 @@ class PointsInstancingLayer {
72357
72448
  this._modelMatrixCol2 = [];
72358
72449
 
72359
72450
  this._portions = [];
72451
+ this._meshes = [];
72452
+ this._aabb = math.collapseAABB3();
72453
+ this.aabbDirty = true;
72360
72454
 
72361
72455
  this._finalized = false;
72362
72456
  }
72363
72457
 
72458
+ get aabb() {
72459
+ if (this.aabbDirty) {
72460
+ math.collapseAABB3(this._aabb);
72461
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
72462
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
72463
+ }
72464
+ this.aabbDirty = false;
72465
+ }
72466
+ return this._aabb;
72467
+ }
72468
+
72364
72469
  /**
72365
72470
  * Creates a new portion within this InstancingLayer, returns the new portion ID.
72366
72471
  *
@@ -72368,13 +72473,14 @@ class PointsInstancingLayer {
72368
72473
  *
72369
72474
  * Gives the portion the specified color and matrix.
72370
72475
  *
72476
+ * @param mesh The SceneModelMesh that owns the portion
72371
72477
  * @param cfg Portion params
72372
72478
  * @param cfg.meshMatrix Flat float 4x4 matrix.
72373
72479
  * @param [cfg.worldMatrix] Flat float 4x4 matrix.
72374
72480
  * @param cfg.pickColor Quantized pick color
72375
72481
  * @returns {number} Portion ID.
72376
72482
  */
72377
- createPortion(cfg) {
72483
+ createPortion(mesh, cfg) {
72378
72484
 
72379
72485
  const meshMatrix = cfg.meshMatrix;
72380
72486
  const pickColor = cfg.pickColor;
@@ -72418,7 +72524,7 @@ class PointsInstancingLayer {
72418
72524
 
72419
72525
  this._numPortions++;
72420
72526
  this.model.numPortions++;
72421
-
72527
+ this._meshes.push(mesh);
72422
72528
  return portionId;
72423
72529
  }
72424
72530
 
@@ -77377,7 +77483,7 @@ class TrianglesDataTextureSnapDepthRenderer {
77377
77483
  const textureState = state.textureState;
77378
77484
  const origin = dataTextureLayer._state.origin;
77379
77485
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
77380
- const aabb = model.aabb;
77486
+ const aabb = dataTextureLayer.aabb; // Per-layer AABB for best RTC accuracy
77381
77487
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
77382
77488
 
77383
77489
  const coordinateScaler = tempVec3a$e;
@@ -77795,7 +77901,7 @@ class TrianglesDataTextureSnapDepthBufInitRenderer {
77795
77901
  const textureState = state.textureState;
77796
77902
  const origin = dataTextureLayer._state.origin;
77797
77903
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
77798
- const aabb = model.aabb;
77904
+ const aabb = dataTextureLayer.aabb; // Per-layer AABB for best RTC accuracy
77799
77905
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
77800
77906
 
77801
77907
  const coordinateScaler = tempVec3a$d;
@@ -81147,10 +81253,13 @@ class TrianglesDataTextureLayer {
81147
81253
 
81148
81254
  this._bucketGeometries = {};
81149
81255
 
81256
+ this._meshes = [];
81257
+
81150
81258
  /**
81151
81259
  * The axis-aligned World-space boundary of this TrianglesDataTextureLayer's positions.
81152
81260
  */
81153
- this.aabb = math.collapseAABB3();
81261
+ this._aabb = math.collapseAABB3();
81262
+ this.aabbDirty = true;
81154
81263
 
81155
81264
  /**
81156
81265
  * The number of updates in the current frame;
@@ -81160,6 +81269,17 @@ class TrianglesDataTextureLayer {
81160
81269
  this._finalized = false;
81161
81270
  }
81162
81271
 
81272
+ get aabb() {
81273
+ if (this.aabbDirty) {
81274
+ math.collapseAABB3(this._aabb);
81275
+ for (let i = 0, len = this._meshes.length; i < len; i++) {
81276
+ math.expandAABB3(this._aabb, this._meshes[i].aabb);
81277
+ }
81278
+ this.aabbDirty = false;
81279
+ }
81280
+ return this._aabb;
81281
+ }
81282
+
81163
81283
  /**
81164
81284
  * Returns whether the ```TrianglesDataTextureLayer``` has room for more portions.
81165
81285
  *
@@ -81204,6 +81324,7 @@ class TrianglesDataTextureLayer {
81204
81324
  *
81205
81325
  * Gives the portion the specified geometry, color and matrix.
81206
81326
  *
81327
+ * @param mesh The SceneModelMesh that owns the portion
81207
81328
  * @param portionCfg.positionsCompressed Flat float Local-space positionsCompressed array.
81208
81329
  * @param [portionCfg.normals] Flat float normals array.
81209
81330
  * @param [portionCfg.colors] Flat float colors array.
@@ -81218,12 +81339,12 @@ class TrianglesDataTextureLayer {
81218
81339
  * @param portionCfg.pickColor Quantized pick color
81219
81340
  * @returns {number} Portion ID
81220
81341
  */
81221
- createPortion(portionCfg) {
81342
+ createPortion(mesh, portionCfg) {
81222
81343
  if (this._finalized) {
81223
81344
  throw "Already finalized";
81224
81345
  }
81225
81346
  const subPortionIds = [];
81226
- // const portionAABB = portionCfg.worldAABB;
81347
+ // const portionAABB = portionCfg.worldAABB;
81227
81348
  portionCfg.buckets.forEach((bucket, bucketIndex) => {
81228
81349
  const bucketGeometryId = portionCfg.geometryId !== undefined && portionCfg.geometryId !== null
81229
81350
  ? `${portionCfg.geometryId}#${bucketIndex}`
@@ -81233,7 +81354,7 @@ class TrianglesDataTextureLayer {
81233
81354
  bucketGeometry = this._createBucketGeometry(portionCfg, bucket);
81234
81355
  this._bucketGeometries[bucketGeometryId] = bucketGeometry;
81235
81356
  }
81236
- // const subPortionAABB = math.collapseAABB3(tempAABB3b);
81357
+ // const subPortionAABB = math.collapseAABB3(tempAABB3b);
81237
81358
  const subPortionId = this._createSubPortion(portionCfg, bucketGeometry, bucket);
81238
81359
  //math.expandAABB3(portionAABB, subPortionAABB);
81239
81360
  subPortionIds.push(subPortionId);
@@ -81251,6 +81372,7 @@ class TrianglesDataTextureLayer {
81251
81372
  const portionId = this._portionToSubPortionsMap.length;
81252
81373
  this._portionToSubPortionsMap.push(subPortionIds);
81253
81374
  this.model.numPortions++;
81375
+ this._meshes.push(mesh);
81254
81376
  return portionId;
81255
81377
  }
81256
81378
 
@@ -81355,7 +81477,7 @@ class TrianglesDataTextureLayer {
81355
81477
  numEdges,
81356
81478
  indicesBase,
81357
81479
  edgeIndicesBase,
81358
- // aabb,
81480
+ // aabb,
81359
81481
  obb: null // Lazy-created in _createSubPortion if needed
81360
81482
  };
81361
81483
 
@@ -81535,7 +81657,7 @@ class TrianglesDataTextureLayer {
81535
81657
  textureState.texturePerVertexIdCoordinates = this._dataTextureGenerator.generateTextureForPositions(
81536
81658
  gl,
81537
81659
  buffer.positionsCompressed,
81538
- buffer.lenPositionsCompressed );
81660
+ buffer.lenPositionsCompressed);
81539
81661
 
81540
81662
  textureState.texturePerPolygonIdPortionIds8Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
81541
81663
  gl,
@@ -82116,7 +82238,7 @@ class TrianglesDataTextureLayer {
82116
82238
  const textureState = this._dataTextureState;
82117
82239
  const gl = this.model.scene.canvas.gl;
82118
82240
  tempMat4a.set(matrix);
82119
- textureState.texturePerObjectInstanceMatrices._textureData.set(tempMat4a, subPortionId*16);
82241
+ textureState.texturePerObjectInstanceMatrices._textureData.set(tempMat4a, subPortionId * 16);
82120
82242
  if (this._deferredSetFlagsActive) {
82121
82243
  this._deferredSetFlagsDirty = true;
82122
82244
  return;
@@ -82139,7 +82261,7 @@ class TrianglesDataTextureLayer {
82139
82261
  );
82140
82262
  // gl.bindTexture (gl.TEXTURE_2D, null);
82141
82263
  }
82142
-
82264
+
82143
82265
  // ---------------------- COLOR RENDERING -----------------------------------
82144
82266
 
82145
82267
  drawColorOpaque(renderFlags, frameCtx) {
@@ -85823,7 +85945,7 @@ class SceneModel extends Component {
85823
85945
  if (cfg.transform) {
85824
85946
  cfg.meshMatrix = cfg.transform.worldMatrix;
85825
85947
  }
85826
- mesh.portionId = mesh.layer.createPortion(cfg);
85948
+ mesh.portionId = mesh.layer.createPortion(mesh, cfg);
85827
85949
  this._meshes[cfg.id] = mesh;
85828
85950
  this._meshList.push(mesh);
85829
85951
  return mesh;