@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
  /** @private */
@@ -1969,7 +1969,7 @@ const tempVec3a$j = new FloatArrayType(3);
1969
1969
 
1970
1970
  const tempMat1 = new FloatArrayType(16);
1971
1971
  const tempMat2 = new FloatArrayType(16);
1972
- const tempVec4$3 = new FloatArrayType(4);
1972
+ const tempVec4$4 = new FloatArrayType(4);
1973
1973
 
1974
1974
 
1975
1975
  /**
@@ -5184,7 +5184,7 @@ const math = {
5184
5184
  },
5185
5185
 
5186
5186
  quaternionToAngleAxis(q, angleAxis = math.vec4()) {
5187
- q = math.normalizeQuaternion(q, tempVec4$3);
5187
+ q = math.normalizeQuaternion(q, tempVec4$4);
5188
5188
  const q3 = q[3];
5189
5189
  const angle = 2 * Math.acos(q3);
5190
5190
  const s = Math.sqrt(1 - q3 * q3);
@@ -20658,7 +20658,7 @@ const CompressedMediaType = 10003;
20658
20658
 
20659
20659
  const ids$1 = new Map$1({});
20660
20660
  const tempVec3a$f = math.vec3();
20661
- const tempVec4$2 = math.vec4();
20661
+ const tempVec4$3 = math.vec4();
20662
20662
  const TEXTURE_DECODE_FUNCS = { [sRGBEncoding]: "sRGBToLinear" };
20663
20663
 
20664
20664
  const iota$3 = function(n) {
@@ -21078,11 +21078,11 @@ const createLightSetup = function(programVariables, lightsState) {
21078
21078
  const lightUniforms = {
21079
21079
  color: programVariables.createUniform("vec4", `lightColor${i}`, (set) => {
21080
21080
  const light = lights[i]; // in case it changed
21081
- tempVec4$2[0] = light.color[0];
21082
- tempVec4$2[1] = light.color[1];
21083
- tempVec4$2[2] = light.color[2];
21084
- tempVec4$2[3] = light.intensity;
21085
- set(tempVec4$2);
21081
+ tempVec4$3[0] = light.color[0];
21082
+ tempVec4$3[1] = light.color[1];
21083
+ tempVec4$3[2] = light.color[2];
21084
+ tempVec4$3[3] = light.intensity;
21085
+ set(tempVec4$3);
21086
21086
  }),
21087
21087
  position: programVariables.createUniform("vec3", `lightPos${i}`, (set) => set(lights[i].pos)),
21088
21088
  direction: programVariables.createUniform("vec3", `lightDir${i}`, (set) => set(lights[i].dir)),
@@ -21264,7 +21264,7 @@ const makeInputSetters = function(gl, handle) {
21264
21264
  };
21265
21265
  };
21266
21266
 
21267
- const tempVec4$1 = math.vec4();
21267
+ const tempVec4$2 = math.vec4();
21268
21268
 
21269
21269
  const DrawShaderSource = function(meshDrawHash, programVariables, geometry, material, scene) {
21270
21270
  const materialState = material._state;
@@ -21355,10 +21355,10 @@ const DrawShaderSource = function(meshDrawHash, programVariables, geometry, mate
21355
21355
  const materialAlphaModeCutoff = setupUniform("materialAlphaModeCutoff", "vec4", mtl => {
21356
21356
  const alpha = mtl.alpha;
21357
21357
  if ((alpha !== undefined) && (alpha !== null)) {
21358
- tempVec4$1[0] = alpha;
21359
- tempVec4$1[1] = (mtl.alphaMode === 1 ? 1 : 0);
21360
- tempVec4$1[2] = mtl.alphaCutoff;
21361
- return tempVec4$1;
21358
+ tempVec4$2[0] = alpha;
21359
+ tempVec4$2[1] = (mtl.alphaMode === 1 ? 1 : 0);
21360
+ tempVec4$2[2] = mtl.alphaCutoff;
21361
+ return tempVec4$2;
21362
21362
  } else {
21363
21363
  return null;
21364
21364
  }
@@ -31869,7 +31869,7 @@ const SnapProgram = function(programVariables, geometry, isSnapInit, isPoints) {
31869
31869
 
31870
31870
  const tempVec2 = math.vec2();
31871
31871
  const tempVec3$6 = math.vec3();
31872
- const tempVec4 = math.vec4();
31872
+ const tempVec4$1 = math.vec4();
31873
31873
  const tempMat4$2 = math.mat4();
31874
31874
  const vec3zero = math.vec3([0,0,0]);
31875
31875
 
@@ -32352,6 +32352,15 @@ class Layer {
32352
32352
 
32353
32353
  aabbChanged() { this._aabbDirty = true; }
32354
32354
 
32355
+ getAABB() {
32356
+ if (this._aabbDirty) { // Per-layer AABB for best RTC accuracy
32357
+ math.collapseAABB3(this._aabb);
32358
+ this._meshes.forEach(m => math.expandAABB3(this._aabb, m.aabb));
32359
+ this._aabbDirty = false;
32360
+ }
32361
+ return this._aabb;
32362
+ }
32363
+
32355
32364
  __drawLayer(renderFlags, frameCtx, renderer, pass) {
32356
32365
  if ((this._countsByFlag[ENTITY_FLAGS.CULLED].count < this._portions.length) && (this._countsByFlag[ENTITY_FLAGS.VISIBLE].count > 0)) {
32357
32366
  const backfacePasses = (this.primitive !== "points") && (this.primitive !== "lines") && [
@@ -32424,7 +32433,7 @@ class Layer {
32424
32433
  // ---------------------- SILHOUETTE RENDERING -----------------------------------
32425
32434
 
32426
32435
  __drawSilhouette(renderFlags, frameCtx, material, renderPass) {
32427
- frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.fillColor, material.fillAlpha, tempVec4);
32436
+ frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.fillColor, material.fillAlpha, tempVec4$1);
32428
32437
  this.__drawLayer(renderFlags, frameCtx, this._renderers.silhouetteRenderer, renderPass);
32429
32438
  }
32430
32439
 
@@ -32470,7 +32479,7 @@ class Layer {
32470
32479
  __drawUniformEdges(renderFlags, frameCtx, material, renderPass) {
32471
32480
  const renderer = this._renderers.edgesRenderers && this._renderers.edgesRenderers.uniform;
32472
32481
  if (renderer) {
32473
- frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.edgeColor, material.edgeAlpha, tempVec4);
32482
+ frameCtx.programColor = this.__setVec4FromMaterialColorAlpha(material.edgeColor, material.edgeAlpha, tempVec4$1);
32474
32483
  this.__drawLayer(renderFlags, frameCtx, renderer, renderPass);
32475
32484
  }
32476
32485
  }
@@ -32517,13 +32526,7 @@ class Layer {
32517
32526
  drawSnap(renderFlags, frameCtx, isSnapInit) {
32518
32527
  frameCtx.snapPickOrigin = [0, 0, 0];
32519
32528
 
32520
- if (this._aabbDirty) { // Per-layer AABB for best RTC accuracy
32521
- math.collapseAABB3(this._aabb);
32522
- this._meshes.forEach(m => math.expandAABB3(this._aabb, m.aabb));
32523
- this._aabbDirty = false;
32524
- }
32525
-
32526
- const aabb = this._aabb;
32529
+ const aabb = this.getAABB();
32527
32530
  frameCtx.snapPickCoordinateScale = math.mulVec3Scalar(
32528
32531
  safeInvVec3([ aabb[3] - aabb[0], aabb[4] - aabb[1], aabb[5] - aabb[2] ]),
32529
32532
  math.MAX_INT);
@@ -40968,34 +40971,37 @@ class SceneModel extends Component {
40968
40971
  /**
40969
40972
  * @private
40970
40973
  */
40971
- _withEachVisibleLayer(testNumVisibleLayerPortions, cb) {
40974
+ _withEachVisibleLayer(frameCtx, testNumVisibleLayerPortions, cb) {
40972
40975
  if (testNumVisibleLayerPortions && (this.numVisibleLayerPortions === 0)) {
40973
40976
  return;
40974
40977
  }
40978
+ const testLayerCull = frameCtx.testAABB;
40975
40979
  const renderFlags = this.renderFlags;
40976
40980
  for (let i = 0, len = renderFlags.visibleLayers.length; i < len; i++) {
40977
- const layerIndex = renderFlags.visibleLayers[i];
40978
- cb(this.layerList[layerIndex]);
40979
- }
40980
- }
40981
-
40982
- drawColorOpaque (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawColorOpaque (this.renderFlags, frameCtx)); }
40983
- drawColorTransparent (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawColorTransparent (this.renderFlags, frameCtx)); }
40984
- drawDepth (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawDepth (this.renderFlags, frameCtx)); } // Dedicated to SAO because it skips transparent objects
40985
- drawSilhouetteXRayed (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawSilhouetteXRayed (this.renderFlags, frameCtx)); }
40986
- drawSilhouetteHighlighted(frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawSilhouetteHighlighted(this.renderFlags, frameCtx)); }
40987
- drawSilhouetteSelected (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawSilhouetteSelected (this.renderFlags, frameCtx)); }
40988
- drawEdgesColorOpaque (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesColorOpaque (this.renderFlags, frameCtx)); }
40989
- drawEdgesColorTransparent(frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesColorTransparent(this.renderFlags, frameCtx)); }
40990
- drawEdgesXRayed (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesXRayed (this.renderFlags, frameCtx)); }
40991
- drawEdgesHighlighted (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesHighlighted (this.renderFlags, frameCtx)); }
40992
- drawEdgesSelected (frameCtx) { this._withEachVisibleLayer(false, layer => layer.drawEdgesSelected (this.renderFlags, frameCtx)); }
40993
- drawOcclusion (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawOcclusion (this.renderFlags, frameCtx)); }
40994
- drawShadow (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawShadow (this.renderFlags, frameCtx)); }
40995
- drawPickMesh (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawPickMesh (this.renderFlags, frameCtx)); }
40996
- drawPickDepths (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawPickDepths (this.renderFlags, frameCtx)); }
40997
- drawPickNormals (frameCtx) { this._withEachVisibleLayer(true, layer => layer.drawPickNormals (this.renderFlags, frameCtx)); }
40998
- _drawSnap (frameCtx, isSnapInit) { this._withEachVisibleLayer(true, layer => layer.drawSnap (this.renderFlags, frameCtx, isSnapInit)); }
40981
+ const layer = this.layerList[renderFlags.visibleLayers[i]];
40982
+ if ((! testLayerCull) || testLayerCull(layer.getAABB())) {
40983
+ cb(layer);
40984
+ }
40985
+ }
40986
+ }
40987
+
40988
+ drawColorOpaque (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawColorOpaque (this.renderFlags, frameCtx)); }
40989
+ drawColorTransparent (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawColorTransparent (this.renderFlags, frameCtx)); }
40990
+ drawDepth (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawDepth (this.renderFlags, frameCtx)); } // Dedicated to SAO because it skips transparent objects
40991
+ drawSilhouetteXRayed (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawSilhouetteXRayed (this.renderFlags, frameCtx)); }
40992
+ drawSilhouetteHighlighted(frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawSilhouetteHighlighted(this.renderFlags, frameCtx)); }
40993
+ drawSilhouetteSelected (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawSilhouetteSelected (this.renderFlags, frameCtx)); }
40994
+ drawEdgesColorOpaque (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesColorOpaque (this.renderFlags, frameCtx)); }
40995
+ drawEdgesColorTransparent(frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesColorTransparent(this.renderFlags, frameCtx)); }
40996
+ drawEdgesXRayed (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesXRayed (this.renderFlags, frameCtx)); }
40997
+ drawEdgesHighlighted (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesHighlighted (this.renderFlags, frameCtx)); }
40998
+ drawEdgesSelected (frameCtx) { this._withEachVisibleLayer(frameCtx, false, layer => layer.drawEdgesSelected (this.renderFlags, frameCtx)); }
40999
+ drawOcclusion (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawOcclusion (this.renderFlags, frameCtx)); }
41000
+ drawShadow (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawShadow (this.renderFlags, frameCtx)); }
41001
+ drawPickMesh (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawPickMesh (this.renderFlags, frameCtx)); }
41002
+ drawPickDepths (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawPickDepths (this.renderFlags, frameCtx)); }
41003
+ drawPickNormals (frameCtx) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawPickNormals (this.renderFlags, frameCtx)); }
41004
+ _drawSnap (frameCtx, isSnapInit) { this._withEachVisibleLayer(frameCtx, true, layer => layer.drawSnap (this.renderFlags, frameCtx, isSnapInit)); }
40999
41005
 
41000
41006
  drawSnapInit(frameCtx) { this._drawSnap(frameCtx, true ); }
41001
41007
  drawSnap (frameCtx) { this._drawSnap(frameCtx, false); }
@@ -47037,6 +47043,9 @@ const vec3_0 = math.vec3([0,0,0]);
47037
47043
 
47038
47044
  const iota = (n) => { const ret = [ ]; for (let i = 0; i < n; ++i) ret.push(i); return ret; };
47039
47045
 
47046
+ const tempPlanes = iota(6).map(() => math.vec4());
47047
+ const tempVec4 = math.vec4();
47048
+
47040
47049
  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]);
47041
47050
 
47042
47051
  const pixelToInt = pix => pix[0] + (pix[1] << 8) + (pix[2] << 16) + (pix[3] << 24);
@@ -47046,6 +47055,66 @@ const toWorldPos = (p, origin, scale) => math.vec3([ p[0] * scale[0] + origin
47046
47055
  p[1] * scale[1] + origin[1],
47047
47056
  p[2] * scale[2] + origin[2] ]);
47048
47057
 
47058
+ const makeFrustumAABBIntersectionTest = function(camera) {
47059
+ const m = math.mat4();
47060
+ math.mulMat4(camera.projMatrix, camera.viewMatrix, m);
47061
+
47062
+ for (let i = 0; i < 3; ++i) {
47063
+ tempPlanes[i * 2 + 0][0] = m[ 3] + m[i];
47064
+ tempPlanes[i * 2 + 0][1] = m[ 7] + m[i + 4];
47065
+ tempPlanes[i * 2 + 0][2] = m[11] + m[i + 8];
47066
+ tempPlanes[i * 2 + 0][3] = m[15] + m[i + 12];
47067
+
47068
+ tempPlanes[i * 2 + 1][0] = m[ 3] - m[i];
47069
+ tempPlanes[i * 2 + 1][1] = m[ 7] - m[i + 4];
47070
+ tempPlanes[i * 2 + 1][2] = m[11] - m[i + 8];
47071
+ tempPlanes[i * 2 + 1][3] = m[15] - m[i + 12];
47072
+ }
47073
+
47074
+ // Normalize each plane
47075
+ tempPlanes.forEach(p => math.divVec4Scalar(p, math.lenVec3(p), p));
47076
+
47077
+ return aabb => tempPlanes.every(p => {
47078
+ // Compute the positive vertex (farthest in direction of normal)
47079
+ tempVec4[0] = aabb[(p[0] >= 0) ? 3 : 0];
47080
+ tempVec4[1] = aabb[(p[1] >= 0) ? 4 : 1];
47081
+ tempVec4[2] = aabb[(p[2] >= 0) ? 5 : 2];
47082
+ tempVec4[3] = 1;
47083
+ return math.dotVec4(p, tempVec4) >= 0;
47084
+ });
47085
+ };
47086
+
47087
+ const makeRayAABBIntersectionTest = (O, D) => aabb => {
47088
+ let tmin = -Infinity;
47089
+ let tmax = Infinity;
47090
+
47091
+ for (let i = 0; i < 3; i++) {
47092
+ const origin = O[i];
47093
+ const direction = D[i];
47094
+ const minBound = aabb[i];
47095
+ const maxBound = aabb[i + 3];
47096
+
47097
+ if (Math.abs(direction) < 1e-8) {
47098
+ // Ray is parallel to plane
47099
+ if ((origin < minBound) || (origin > maxBound)) {
47100
+ return false; // No intersection
47101
+ }
47102
+ } else {
47103
+ const t1 = (minBound - origin) / direction;
47104
+ const t2 = (maxBound - origin) / direction;
47105
+
47106
+ tmin = Math.max(tmin, Math.min(t1, t2)); // near
47107
+ tmax = Math.min(tmax, Math.max(t1, t2)); // far
47108
+
47109
+ if (tmin > tmax) {
47110
+ return false; // No intersection
47111
+ }
47112
+ }
47113
+ }
47114
+
47115
+ return tmax >= 0; // Check if intersection is in front of ray
47116
+ };
47117
+
47049
47118
  /**
47050
47119
  * @private
47051
47120
  */
@@ -47798,6 +47867,8 @@ const Renderer$1 = function (scene, options) {
47798
47867
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
47799
47868
  }
47800
47869
 
47870
+ frameCtx.testAABB = makeFrustumAABBIntersectionTest(scene.camera);
47871
+
47801
47872
  const renderDrawables = function(drawables) {
47802
47873
 
47803
47874
  let normalDrawSAOBinLen = 0;
@@ -48132,6 +48203,8 @@ const Renderer$1 = function (scene, options) {
48132
48203
  renderDrawables(uiDrawableList);
48133
48204
  }
48134
48205
 
48206
+ frameCtx.testAABB = null;
48207
+
48135
48208
  const endTime = Date.now();
48136
48209
  const frameStats = stats.frame;
48137
48210
 
@@ -48240,11 +48313,16 @@ const Renderer$1 = function (scene, options) {
48240
48313
 
48241
48314
  pickResult.canvasPos = params.canvasPos;
48242
48315
 
48316
+ math.canvasPosToWorldRay(canvas, pickViewMatrix, pickProjMatrix, projection, canvasPos, tempVec3a, tempVec3b);
48317
+ frameCtx.testAABB = makeRayAABBIntersectionTest(tempVec3a, tempVec3b);
48243
48318
  } else {
48244
48319
 
48245
48320
  // Picking with arbitrary World-space ray
48246
48321
  // Align camera along ray and fire ray through center of canvas
48247
48322
 
48323
+ canvasPos[0] = canvas.clientWidth * 0.5;
48324
+ canvasPos[1] = canvas.clientHeight * 0.5;
48325
+
48248
48326
  if (params.matrix) {
48249
48327
 
48250
48328
  pickViewMatrix = params.matrix;
@@ -48254,6 +48332,8 @@ const Renderer$1 = function (scene, options) {
48254
48332
  nearAndFar[0] = camera.project.near;
48255
48333
  nearAndFar[1] = camera.project.far;
48256
48334
 
48335
+ math.canvasPosToWorldRay(canvas, pickViewMatrix, pickProjMatrix, projection, canvasPos, tempVec3a, tempVec3b);
48336
+ frameCtx.testAABB = makeRayAABBIntersectionTest(tempVec3a, tempVec3b);
48257
48337
  } else {
48258
48338
 
48259
48339
  worldRayOrigin.set(params.origin || [0, 0, 0]);
@@ -48282,10 +48362,9 @@ const Renderer$1 = function (scene, options) {
48282
48362
 
48283
48363
  pickResult.origin = worldRayOrigin;
48284
48364
  pickResult.direction = worldRayDir;
48285
- }
48286
48365
 
48287
- canvasPos[0] = canvas.clientWidth * 0.5;
48288
- canvasPos[1] = canvas.clientHeight * 0.5;
48366
+ frameCtx.testAABB = makeRayAABBIntersectionTest(pickResult.origin, pickResult.direction);
48367
+ }
48289
48368
  }
48290
48369
 
48291
48370
  pickBuffer.bind();
@@ -48322,6 +48401,8 @@ const Renderer$1 = function (scene, options) {
48322
48401
  renderDrawables(uiDrawableList);
48323
48402
  }
48324
48403
 
48404
+ frameCtx.testAABB = null;
48405
+
48325
48406
  const pickID = pixelToInt(pickBuffer.read(0, 0));
48326
48407
  const pickable = (pickID >= 0) && pickIDs.items[pickID];
48327
48408