@xeokit/xeokit-sdk 2.6.96 → 2.6.97

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * xeokit-sdk v2.6.96
3
- * Commit: c76eb4c08555d55fdd54313f5fb25481d28d1150
4
- * Built: 2025-12-02T12:22:54.826Z
2
+ * xeokit-sdk v2.6.97
3
+ * Commit: fd8731b8272e4958c8231a6794a98a1874564a08
4
+ * Built: 2025-12-03T17:04:14.467Z
5
5
  */
6
6
 
7
7
  if (typeof window !== 'undefined') {
8
- window.__XEOKIT__ = { version: '2.6.96', commit: 'c76eb4c08555d55fdd54313f5fb25481d28d1150', built: '2025-12-02T12:22:54.826Z' };
8
+ window.__XEOKIT__ = { version: '2.6.97', commit: 'fd8731b8272e4958c8231a6794a98a1874564a08', built: '2025-12-03T17:04:14.467Z' };
9
9
  }
10
10
 
11
11
  'use strict';
@@ -1973,7 +1973,7 @@ const tempVec3a$j = new FloatArrayType(3);
1973
1973
 
1974
1974
  const tempMat1 = new FloatArrayType(16);
1975
1975
  const tempMat2 = new FloatArrayType(16);
1976
- const tempVec4$3 = new FloatArrayType(4);
1976
+ const tempVec4$4 = new FloatArrayType(4);
1977
1977
 
1978
1978
 
1979
1979
  /**
@@ -5188,7 +5188,7 @@ const math = {
5188
5188
  },
5189
5189
 
5190
5190
  quaternionToAngleAxis(q, angleAxis = math.vec4()) {
5191
- q = math.normalizeQuaternion(q, tempVec4$3);
5191
+ q = math.normalizeQuaternion(q, tempVec4$4);
5192
5192
  const q3 = q[3];
5193
5193
  const angle = 2 * Math.acos(q3);
5194
5194
  const s = Math.sqrt(1 - q3 * q3);
@@ -20662,7 +20662,7 @@ const CompressedMediaType = 10003;
20662
20662
 
20663
20663
  const ids$1 = new Map$1({});
20664
20664
  const tempVec3a$f = math.vec3();
20665
- const tempVec4$2 = math.vec4();
20665
+ const tempVec4$3 = math.vec4();
20666
20666
  const TEXTURE_DECODE_FUNCS = { [sRGBEncoding]: "sRGBToLinear" };
20667
20667
 
20668
20668
  const iota$3 = function(n) {
@@ -21082,11 +21082,11 @@ const createLightSetup = function(programVariables, lightsState) {
21082
21082
  const lightUniforms = {
21083
21083
  color: programVariables.createUniform("vec4", `lightColor${i}`, (set) => {
21084
21084
  const light = lights[i]; // in case it changed
21085
- tempVec4$2[0] = light.color[0];
21086
- tempVec4$2[1] = light.color[1];
21087
- tempVec4$2[2] = light.color[2];
21088
- tempVec4$2[3] = light.intensity;
21089
- set(tempVec4$2);
21085
+ tempVec4$3[0] = light.color[0];
21086
+ tempVec4$3[1] = light.color[1];
21087
+ tempVec4$3[2] = light.color[2];
21088
+ tempVec4$3[3] = light.intensity;
21089
+ set(tempVec4$3);
21090
21090
  }),
21091
21091
  position: programVariables.createUniform("vec3", `lightPos${i}`, (set) => set(lights[i].pos)),
21092
21092
  direction: programVariables.createUniform("vec3", `lightDir${i}`, (set) => set(lights[i].dir)),
@@ -21268,7 +21268,7 @@ const makeInputSetters = function(gl, handle) {
21268
21268
  };
21269
21269
  };
21270
21270
 
21271
- const tempVec4$1 = math.vec4();
21271
+ const tempVec4$2 = math.vec4();
21272
21272
 
21273
21273
  const DrawShaderSource = function(meshDrawHash, programVariables, geometry, material, scene) {
21274
21274
  const materialState = material._state;
@@ -21359,10 +21359,10 @@ const DrawShaderSource = function(meshDrawHash, programVariables, geometry, mate
21359
21359
  const materialAlphaModeCutoff = setupUniform("materialAlphaModeCutoff", "vec4", mtl => {
21360
21360
  const alpha = mtl.alpha;
21361
21361
  if ((alpha !== undefined) && (alpha !== null)) {
21362
- tempVec4$1[0] = alpha;
21363
- tempVec4$1[1] = (mtl.alphaMode === 1 ? 1 : 0);
21364
- tempVec4$1[2] = mtl.alphaCutoff;
21365
- return tempVec4$1;
21362
+ tempVec4$2[0] = alpha;
21363
+ tempVec4$2[1] = (mtl.alphaMode === 1 ? 1 : 0);
21364
+ tempVec4$2[2] = mtl.alphaCutoff;
21365
+ return tempVec4$2;
21366
21366
  } else {
21367
21367
  return null;
21368
21368
  }
@@ -31873,7 +31873,7 @@ const SnapProgram = function(programVariables, geometry, isSnapInit, isPoints) {
31873
31873
 
31874
31874
  const tempVec2 = math.vec2();
31875
31875
  const tempVec3$6 = math.vec3();
31876
- const tempVec4 = math.vec4();
31876
+ const tempVec4$1 = math.vec4();
31877
31877
  const tempMat4$2 = math.mat4();
31878
31878
  const vec3zero = math.vec3([0,0,0]);
31879
31879
 
@@ -32356,6 +32356,15 @@ class Layer {
32356
32356
 
32357
32357
  aabbChanged() { this._aabbDirty = true; }
32358
32358
 
32359
+ getAABB() {
32360
+ if (this._aabbDirty) { // Per-layer AABB for best RTC accuracy
32361
+ math.collapseAABB3(this._aabb);
32362
+ this._meshes.forEach(m => math.expandAABB3(this._aabb, m.aabb));
32363
+ this._aabbDirty = false;
32364
+ }
32365
+ return this._aabb;
32366
+ }
32367
+
32359
32368
  __drawLayer(renderFlags, frameCtx, renderer, pass) {
32360
32369
  if ((this._countsByFlag[ENTITY_FLAGS.CULLED].count < this._portions.length) && (this._countsByFlag[ENTITY_FLAGS.VISIBLE].count > 0)) {
32361
32370
  const backfacePasses = (this.primitive !== "points") && (this.primitive !== "lines") && [
@@ -32428,7 +32437,7 @@ class Layer {
32428
32437
  // ---------------------- SILHOUETTE RENDERING -----------------------------------
32429
32438
 
32430
32439
  __drawSilhouette(renderFlags, frameCtx, material, renderPass) {
32431
- frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.fillColor, material.fillAlpha, tempVec4);
32440
+ frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.fillColor, material.fillAlpha, tempVec4$1);
32432
32441
  this.__drawLayer(renderFlags, frameCtx, this._renderers.silhouetteRenderer, renderPass);
32433
32442
  }
32434
32443
 
@@ -32474,7 +32483,7 @@ class Layer {
32474
32483
  __drawUniformEdges(renderFlags, frameCtx, material, renderPass) {
32475
32484
  const renderer = this._renderers.edgesRenderers && this._renderers.edgesRenderers.uniform;
32476
32485
  if (renderer) {
32477
- frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.edgeColor, material.edgeAlpha, tempVec4);
32486
+ frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.edgeColor, material.edgeAlpha, tempVec4$1);
32478
32487
  this.__drawLayer(renderFlags, frameCtx, renderer, renderPass);
32479
32488
  }
32480
32489
  }
@@ -32521,13 +32530,7 @@ class Layer {
32521
32530
  drawSnap(renderFlags, frameCtx, isSnapInit) {
32522
32531
  frameCtx.snapPickOrigin = [0, 0, 0];
32523
32532
 
32524
- if (this._aabbDirty) { // Per-layer AABB for best RTC accuracy
32525
- math.collapseAABB3(this._aabb);
32526
- this._meshes.forEach(m => math.expandAABB3(this._aabb, m.aabb));
32527
- this._aabbDirty = false;
32528
- }
32529
-
32530
- const aabb = this._aabb;
32533
+ const aabb = this.getAABB();
32531
32534
  frameCtx.snapPickCoordinateScale = math.mulVec3Scalar(
32532
32535
  safeInvVec3([ aabb[3] - aabb[0], aabb[4] - aabb[1], aabb[5] - aabb[2] ]),
32533
32536
  math.MAX_INT);
@@ -40972,34 +40975,37 @@ class SceneModel extends Component {
40972
40975
  /**
40973
40976
  * @private
40974
40977
  */
40975
- _withEachVisibleLayer(testNumVisibleLayerPortions, cb) {
40978
+ _withEachVisibleLayer(frameCtx, testNumVisibleLayerPortions, cb) {
40976
40979
  if (testNumVisibleLayerPortions && (this.numVisibleLayerPortions === 0)) {
40977
40980
  return;
40978
40981
  }
40982
+ const testLayerCull = frameCtx.testAABB;
40979
40983
  const renderFlags = this.renderFlags;
40980
40984
  for (let i = 0, len = renderFlags.visibleLayers.length; i < len; i++) {
40981
- const layerIndex = renderFlags.visibleLayers[i];
40982
- cb(this.layerList[layerIndex]);
40983
- }
40984
- }
40985
-
40986
- drawColorOpaque (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawColorOpaque (this.renderFlags, frameCtx)); }
40987
- drawColorTransparent (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawColorTransparent (this.renderFlags, frameCtx)); }
40988
- drawDepth (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawDepth (this.renderFlags, frameCtx)); } // Dedicated to SAO because it skips transparent objects
40989
- drawSilhouetteXRayed (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawSilhouetteXRayed (this.renderFlags, frameCtx)); }
40990
- drawSilhouetteHighlighted(frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawSilhouetteHighlighted(this.renderFlags, frameCtx)); }
40991
- drawSilhouetteSelected (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawSilhouetteSelected (this.renderFlags, frameCtx)); }
40992
- drawEdgesColorOpaque (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesColorOpaque (this.renderFlags, frameCtx)); }
40993
- drawEdgesColorTransparent(frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesColorTransparent(this.renderFlags, frameCtx)); }
40994
- drawEdgesXRayed (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesXRayed (this.renderFlags, frameCtx)); }
40995
- drawEdgesHighlighted (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesHighlighted (this.renderFlags, frameCtx)); }
40996
- drawEdgesSelected (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesSelected (this.renderFlags, frameCtx)); }
40997
- drawOcclusion (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawOcclusion (this.renderFlags, frameCtx)); }
40998
- drawShadow (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawShadow (this.renderFlags, frameCtx)); }
40999
- drawPickMesh (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawPickMesh (this.renderFlags, frameCtx)); }
41000
- drawPickDepths (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawPickDepths (this.renderFlags, frameCtx)); }
41001
- drawPickNormals (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawPickNormals (this.renderFlags, frameCtx)); }
41002
- _drawSnap (frameCtx, isSnapInit) { this._withEachVisibleLayer(true, layer => layer.drawSnap (this.renderFlags, frameCtx, isSnapInit)); }
40985
+ const layer = this.layerList[renderFlags.visibleLayers[i]];
40986
+ if ((! testLayerCull) || testLayerCull(layer.getAABB())) {
40987
+ cb(layer);
40988
+ }
40989
+ }
40990
+ }
40991
+
40992
+ drawColorOpaque (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawColorOpaque (this.renderFlags, frameCtx)); }
40993
+ drawColorTransparent (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawColorTransparent (this.renderFlags, frameCtx)); }
40994
+ drawDepth (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawDepth (this.renderFlags, frameCtx)); } // Dedicated to SAO because it skips transparent objects
40995
+ drawSilhouetteXRayed (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawSilhouetteXRayed (this.renderFlags, frameCtx)); }
40996
+ drawSilhouetteHighlighted(frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawSilhouetteHighlighted(this.renderFlags, frameCtx)); }
40997
+ drawSilhouetteSelected (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawSilhouetteSelected (this.renderFlags, frameCtx)); }
40998
+ drawEdgesColorOpaque (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesColorOpaque (this.renderFlags, frameCtx)); }
40999
+ drawEdgesColorTransparent(frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesColorTransparent(this.renderFlags, frameCtx)); }
41000
+ drawEdgesXRayed (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesXRayed (this.renderFlags, frameCtx)); }
41001
+ drawEdgesHighlighted (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesHighlighted (this.renderFlags, frameCtx)); }
41002
+ drawEdgesSelected (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesSelected (this.renderFlags, frameCtx)); }
41003
+ drawOcclusion (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawOcclusion (this.renderFlags, frameCtx)); }
41004
+ drawShadow (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawShadow (this.renderFlags, frameCtx)); }
41005
+ drawPickMesh (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawPickMesh (this.renderFlags, frameCtx)); }
41006
+ drawPickDepths (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawPickDepths (this.renderFlags, frameCtx)); }
41007
+ drawPickNormals (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawPickNormals (this.renderFlags, frameCtx)); }
41008
+ _drawSnap (frameCtx, isSnapInit) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawSnap (this.renderFlags, frameCtx, isSnapInit)); }
41003
41009
 
41004
41010
  drawSnapInit(frameCtx) { this._drawSnap(frameCtx, true ); }
41005
41011
  drawSnap (frameCtx) { this._drawSnap(frameCtx, false); }
@@ -47041,6 +47047,9 @@ const vec3_0 = math.vec3([0,0,0]);
47041
47047
 
47042
47048
  const iota = (n) => { const ret = [ ]; for (let i = 0; i < n; ++i) ret.push(i); return ret; };
47043
47049
 
47050
+ const tempPlanes = iota(6).map(() => math.vec4());
47051
+ const tempVec4 = math.vec4();
47052
+
47044
47053
  const bitShiftScreenZ = math.vec4([1.0 / (256.0 * 256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0]);
47045
47054
 
47046
47055
  const pixelToInt = pix => pix[0] + (pix[1] << 8) + (pix[2] << 16) + (pix[3] << 24);
@@ -47050,6 +47059,66 @@ const toWorldPos = (p, origin, scale) => math.vec3([ p[0] * scale[0] + origin
47050
47059
  p[1] * scale[1] + origin[1],
47051
47060
  p[2] * scale[2] + origin[2] ]);
47052
47061
 
47062
+ const makeFrustumAABBIntersectionTest = function(camera) {
47063
+ const m = math.mat4();
47064
+ math.mulMat4(camera.projMatrix, camera.viewMatrix, m);
47065
+
47066
+ for (let i = 0; i < 3; ++i) {
47067
+ tempPlanes[i * 2 + 0][0] = m[ 3] + m[i];
47068
+ tempPlanes[i * 2 + 0][1] = m[ 7] + m[i + 4];
47069
+ tempPlanes[i * 2 + 0][2] = m[11] + m[i + 8];
47070
+ tempPlanes[i * 2 + 0][3] = m[15] + m[i + 12];
47071
+
47072
+ tempPlanes[i * 2 + 1][0] = m[ 3] - m[i];
47073
+ tempPlanes[i * 2 + 1][1] = m[ 7] - m[i + 4];
47074
+ tempPlanes[i * 2 + 1][2] = m[11] - m[i + 8];
47075
+ tempPlanes[i * 2 + 1][3] = m[15] - m[i + 12];
47076
+ }
47077
+
47078
+ // Normalize each plane
47079
+ tempPlanes.forEach(p => math.divVec4Scalar(p, math.lenVec3(p), p));
47080
+
47081
+ return aabb => tempPlanes.every(p => {
47082
+ // Compute the positive vertex (farthest in direction of normal)
47083
+ tempVec4[0] = aabb[(p[0] >= 0) ? 3 : 0];
47084
+ tempVec4[1] = aabb[(p[1] >= 0) ? 4 : 1];
47085
+ tempVec4[2] = aabb[(p[2] >= 0) ? 5 : 2];
47086
+ tempVec4[3] = 1;
47087
+ return math.dotVec4(p, tempVec4) >= 0;
47088
+ });
47089
+ };
47090
+
47091
+ const makeRayAABBIntersectionTest = (O, D) => aabb => {
47092
+ let tmin = -Infinity;
47093
+ let tmax = Infinity;
47094
+
47095
+ for (let i = 0; i < 3; i++) {
47096
+ const origin = O[i];
47097
+ const direction = D[i];
47098
+ const minBound = aabb[i];
47099
+ const maxBound = aabb[i + 3];
47100
+
47101
+ if (Math.abs(direction) < 1e-8) {
47102
+ // Ray is parallel to plane
47103
+ if ((origin < minBound) || (origin > maxBound)) {
47104
+ return false; // No intersection
47105
+ }
47106
+ } else {
47107
+ const t1 = (minBound - origin) / direction;
47108
+ const t2 = (maxBound - origin) / direction;
47109
+
47110
+ tmin = Math.max(tmin, Math.min(t1, t2)); // near
47111
+ tmax = Math.min(tmax, Math.max(t1, t2)); // far
47112
+
47113
+ if (tmin > tmax) {
47114
+ return false; // No intersection
47115
+ }
47116
+ }
47117
+ }
47118
+
47119
+ return tmax >= 0; // Check if intersection is in front of ray
47120
+ };
47121
+
47053
47122
  /**
47054
47123
  * @private
47055
47124
  */
@@ -47802,6 +47871,8 @@ const Renderer$1 = function (scene, options) {
47802
47871
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
47803
47872
  }
47804
47873
 
47874
+ frameCtx.testAABB = makeFrustumAABBIntersectionTest(scene.camera);
47875
+
47805
47876
  const renderDrawables = function(drawables) {
47806
47877
 
47807
47878
  let normalDrawSAOBinLen = 0;
@@ -48136,6 +48207,8 @@ const Renderer$1 = function (scene, options) {
48136
48207
  renderDrawables(uiDrawableList);
48137
48208
  }
48138
48209
 
48210
+ frameCtx.testAABB = null;
48211
+
48139
48212
  const endTime = Date.now();
48140
48213
  const frameStats = stats.frame;
48141
48214
 
@@ -48244,11 +48317,16 @@ const Renderer$1 = function (scene, options) {
48244
48317
 
48245
48318
  pickResult.canvasPos = params.canvasPos;
48246
48319
 
48320
+ math.canvasPosToWorldRay(canvas, pickViewMatrix, pickProjMatrix, projection, canvasPos, tempVec3a, tempVec3b);
48321
+ frameCtx.testAABB = makeRayAABBIntersectionTest(tempVec3a, tempVec3b);
48247
48322
  } else {
48248
48323
 
48249
48324
  // Picking with arbitrary World-space ray
48250
48325
  // Align camera along ray and fire ray through center of canvas
48251
48326
 
48327
+ canvasPos[0] = canvas.clientWidth * 0.5;
48328
+ canvasPos[1] = canvas.clientHeight * 0.5;
48329
+
48252
48330
  if (params.matrix) {
48253
48331
 
48254
48332
  pickViewMatrix = params.matrix;
@@ -48258,6 +48336,8 @@ const Renderer$1 = function (scene, options) {
48258
48336
  nearAndFar[0] = camera.project.near;
48259
48337
  nearAndFar[1] = camera.project.far;
48260
48338
 
48339
+ math.canvasPosToWorldRay(canvas, pickViewMatrix, pickProjMatrix, projection, canvasPos, tempVec3a, tempVec3b);
48340
+ frameCtx.testAABB = makeRayAABBIntersectionTest(tempVec3a, tempVec3b);
48261
48341
  } else {
48262
48342
 
48263
48343
  worldRayOrigin.set(params.origin || [0, 0, 0]);
@@ -48286,10 +48366,9 @@ const Renderer$1 = function (scene, options) {
48286
48366
 
48287
48367
  pickResult.origin = worldRayOrigin;
48288
48368
  pickResult.direction = worldRayDir;
48289
- }
48290
48369
 
48291
- canvasPos[0] = canvas.clientWidth * 0.5;
48292
- canvasPos[1] = canvas.clientHeight * 0.5;
48370
+ frameCtx.testAABB = makeRayAABBIntersectionTest(pickResult.origin, pickResult.direction);
48371
+ }
48293
48372
  }
48294
48373
 
48295
48374
  pickBuffer.bind();
@@ -48326,6 +48405,8 @@ const Renderer$1 = function (scene, options) {
48326
48405
  renderDrawables(uiDrawableList);
48327
48406
  }
48328
48407
 
48408
+ frameCtx.testAABB = null;
48409
+
48329
48410
  const pickID = pixelToInt(pickBuffer.read(0, 0));
48330
48411
  const pickable = (pickID >= 0) && pickIDs.items[pickID];
48331
48412