@babylonjs/core 9.9.1 → 9.10.0

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 (109) hide show
  1. package/AudioV2/abstractAudio/audioEngineV2.d.ts +34 -1
  2. package/AudioV2/abstractAudio/audioEngineV2.js +54 -0
  3. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  4. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +12 -0
  5. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +18 -0
  6. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
  7. package/AudioV2/abstractAudio/index.d.ts +1 -0
  8. package/AudioV2/abstractAudio/index.js +1 -0
  9. package/AudioV2/abstractAudio/index.js.map +1 -1
  10. package/AudioV2/abstractAudio/pure.d.ts +1 -0
  11. package/AudioV2/abstractAudio/pure.js +1 -0
  12. package/AudioV2/abstractAudio/pure.js.map +1 -1
  13. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +7 -1
  14. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +12 -0
  15. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
  16. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +14 -0
  17. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
  18. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +4 -0
  19. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
  20. package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +6 -0
  21. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +12 -0
  22. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  23. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +2 -0
  24. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +4 -0
  25. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
  26. package/AudioV2/webAudio/webAudioEngine.js +2 -1
  27. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  28. package/Engines/abstractEngine.pure.js +2 -2
  29. package/Engines/abstractEngine.pure.js.map +1 -1
  30. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.d.ts +3 -0
  31. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js +16 -1
  32. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js.map +1 -1
  33. package/FrameGraph/Tasks/Layers/selectionOutlineTask.d.ts +2 -1
  34. package/FrameGraph/Tasks/Layers/selectionOutlineTask.js +5 -2
  35. package/FrameGraph/Tasks/Layers/selectionOutlineTask.js.map +1 -1
  36. package/Gizmos/index.d.ts +1 -0
  37. package/Gizmos/index.js +1 -0
  38. package/Gizmos/index.js.map +1 -1
  39. package/Gizmos/pure.d.ts +1 -0
  40. package/Gizmos/pure.js +1 -0
  41. package/Gizmos/pure.js.map +1 -1
  42. package/Gizmos/spatialAudioGizmo.d.ts +55 -0
  43. package/Gizmos/spatialAudioGizmo.js +151 -0
  44. package/Gizmos/spatialAudioGizmo.js.map +1 -0
  45. package/Layers/selectionOutlineLayer.pure.d.ts +9 -2
  46. package/Layers/selectionOutlineLayer.pure.js +29 -6
  47. package/Layers/selectionOutlineLayer.pure.js.map +1 -1
  48. package/Layers/thinEffectLayer.d.ts +1 -0
  49. package/Layers/thinEffectLayer.js +7 -4
  50. package/Layers/thinEffectLayer.js.map +1 -1
  51. package/Layers/thinSelectionOutlineLayer.d.ts +17 -3
  52. package/Layers/thinSelectionOutlineLayer.js +82 -17
  53. package/Layers/thinSelectionOutlineLayer.js.map +1 -1
  54. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +5 -0
  55. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +54 -1
  56. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  57. package/Materials/PBR/openpbrMaterial.pure.d.ts +13 -0
  58. package/Materials/PBR/openpbrMaterial.pure.js +17 -0
  59. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  60. package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.pure.d.ts +2 -1
  61. package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.pure.js +3 -2
  62. package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.pure.js.map +1 -1
  63. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +32 -2
  64. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +180 -22
  65. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  66. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +54 -10
  67. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +130 -13
  68. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  69. package/Meshes/abstractMesh.pure.d.ts +5 -1
  70. package/Meshes/abstractMesh.pure.js +92 -2
  71. package/Meshes/abstractMesh.pure.js.map +1 -1
  72. package/Meshes/thinInstanceMesh.pure.js +143 -2
  73. package/Meshes/thinInstanceMesh.pure.js.map +1 -1
  74. package/Meshes/thinInstanceMesh.types.d.ts +2 -1
  75. package/Meshes/thinInstanceMesh.types.js.map +1 -1
  76. package/Misc/tools.pure.js +1 -1
  77. package/Misc/tools.pure.js.map +1 -1
  78. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +12 -1
  79. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  80. package/Rendering/geometryBufferRenderer.pure.js +8 -0
  81. package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
  82. package/Rendering/objectRenderer.js +4 -2
  83. package/Rendering/objectRenderer.js.map +1 -1
  84. package/Shaders/ShadersInclude/gaussianSplatting.js +54 -5
  85. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  86. package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +1 -1
  87. package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
  88. package/Shaders/gaussianSplatting.vertex.js +14 -3
  89. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  90. package/Shaders/gaussianSplattingVoxel.vertex.js +1 -0
  91. package/Shaders/gaussianSplattingVoxel.vertex.js.map +1 -1
  92. package/Shaders/selectionOutline.fragment.js +16 -4
  93. package/Shaders/selectionOutline.fragment.js.map +1 -1
  94. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +56 -5
  95. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  96. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +2 -3
  97. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  98. package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +1 -1
  99. package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
  100. package/ShadersWGSL/gaussianSplatting.vertex.js +14 -3
  101. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  102. package/ShadersWGSL/gaussianSplattingVoxel.vertex.js +1 -0
  103. package/ShadersWGSL/gaussianSplattingVoxel.vertex.js.map +1 -1
  104. package/ShadersWGSL/selectionOutline.fragment.js +14 -2
  105. package/ShadersWGSL/selectionOutline.fragment.js.map +1 -1
  106. package/XR/features/WebXRBodyTracking.pure.d.ts +16 -0
  107. package/XR/features/WebXRBodyTracking.pure.js +167 -30
  108. package/XR/features/WebXRBodyTracking.pure.js.map +1 -1
  109. package/package.json +1 -1
@@ -352,7 +352,7 @@ export class GaussianSplattingMeshBase extends Mesh {
352
352
  this._needsRotationScaleTextures = value;
353
353
  if (value && this._covariancesATexture) {
354
354
  if (this._splatsData) {
355
- this.updateData(this._splatsData, this._shData ?? undefined, { flipY: false });
355
+ this.updateData(this._splatsData, this._shData ?? undefined, { flipY: false }, undefined, this._shDegree);
356
356
  }
357
357
  else {
358
358
  Logger.Error("GaussianSplattingMeshBase: needsRotationScaleTextures was enabled after the mesh was already loaded, but the splat data is not kept in RAM. " +
@@ -366,6 +366,96 @@ export class GaussianSplattingMeshBase extends Mesh {
366
366
  get shTextures() {
367
367
  return this._shTextures;
368
368
  }
369
+ /**
370
+ * True when this mesh holds raw SOG webp textures (dequantized in-shader) rather than the
371
+ * pre-decoded covariance/center/color textures produced by the standard splat loader.
372
+ */
373
+ get useSog() {
374
+ return this._useSog;
375
+ }
376
+ /**
377
+ * SOG dequantization parameters paired with the raw textures.
378
+ * Set by the splat loader when `useSogTextures: true`. Null otherwise.
379
+ */
380
+ get sogParams() {
381
+ return this._sogParams;
382
+ }
383
+ /**
384
+ * Install a set of raw SOG webp textures and bind the mesh to the in-shader dequantization path.
385
+ * @param pack SOG texture pack produced by ParseSogMetaAsTextures.
386
+ * @internal
387
+ */
388
+ setSogTextureData(pack) {
389
+ this._useSog = true;
390
+ this._sogParams?.codebookTexture?.dispose();
391
+ this._sogParams = pack;
392
+ this._vertexCount = pack.splatCount;
393
+ this._shDegree = pack.shDegree ?? 0;
394
+ this._maxShDegree = this._shDegree;
395
+ // Stride-4 (xyz + 1) — required by the depth-sort worker and the centers texture path.
396
+ this._splatPositions = pack.positions;
397
+ // Reuse existing texture slots for SOG textures (the shader, under USE_SOG, samples them as RGBA8).
398
+ this._covariancesATexture?.dispose();
399
+ this._covariancesBTexture?.dispose();
400
+ this._centersTexture?.dispose();
401
+ this._colorsTexture?.dispose();
402
+ this._rotationsATexture?.dispose();
403
+ if (this._shTextures) {
404
+ for (const t of this._shTextures) {
405
+ t.dispose();
406
+ }
407
+ }
408
+ this._centersTexture = pack.meansTextureL;
409
+ this._covariancesATexture = pack.meansTextureU;
410
+ this._covariancesBTexture = pack.scalesTexture;
411
+ this._rotationsATexture = pack.quatsTexture;
412
+ this._colorsTexture = pack.sh0Texture;
413
+ const shTextures = [];
414
+ if (pack.shCentroidsTexture) {
415
+ shTextures.push(pack.shCentroidsTexture);
416
+ }
417
+ if (pack.shLabelsTexture) {
418
+ shTextures.push(pack.shLabelsTexture);
419
+ }
420
+ this._shTextures = shTextures.length ? shTextures : null;
421
+ // Force pipeline rebuild so the USE_SOG define and extra samplers are picked up.
422
+ this._material?.resetDrawCache();
423
+ const size = pack.meansTextureL.getSize();
424
+ this._textureSize.x = size.width;
425
+ this._textureSize.y = size.height;
426
+ this._updateSplatIndexBuffer(this._vertexCount);
427
+ this._instantiateWorker();
428
+ // Compute bounds from the CPU-decoded positions (stride-4) so the mesh is not frustum-culled.
429
+ const positions = pack.positions;
430
+ const minimum = new Vector3(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
431
+ const maximum = new Vector3(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
432
+ for (let i = 0; i < this._vertexCount; i++) {
433
+ const x = positions[i * 4 + 0];
434
+ const y = positions[i * 4 + 1];
435
+ const z = positions[i * 4 + 2];
436
+ if (x < minimum.x) {
437
+ minimum.x = x;
438
+ }
439
+ if (y < minimum.y) {
440
+ minimum.y = y;
441
+ }
442
+ if (z < minimum.z) {
443
+ minimum.z = z;
444
+ }
445
+ if (x > maximum.x) {
446
+ maximum.x = x;
447
+ }
448
+ if (y > maximum.y) {
449
+ maximum.y = y;
450
+ }
451
+ if (z > maximum.z) {
452
+ maximum.z = z;
453
+ }
454
+ }
455
+ this.getBoundingInfo().reConstruct(minimum, maximum, this.getWorldMatrix());
456
+ this.setEnabled(true);
457
+ this._sortIsDirty = true;
458
+ }
369
459
  /**
370
460
  * Gets the kernel size
371
461
  * Documentation and mathematical explanations here:
@@ -458,6 +548,8 @@ export class GaussianSplattingMeshBase extends Mesh {
458
548
  this._flipY = false;
459
549
  this._delayedTextureUpdate = null;
460
550
  this._useRGBACovariants = false;
551
+ this._useSog = false;
552
+ this._sogParams = null;
461
553
  this._material = null;
462
554
  this._tmpCovariances = [0, 0, 0, 0, 0, 0];
463
555
  this._splatSizeMin = Infinity;
@@ -567,10 +659,11 @@ export class GaussianSplattingMeshBase extends Mesh {
567
659
  anyDirty = true;
568
660
  continue;
569
661
  }
570
- // Also detect drift: if the world or camera state has changed since the last post,
571
- // mark dirty so the next render does not silently queue a new sort that completes
572
- // after isReady has reported true.
573
- if (this._isSortStateDirty(cameraViewInfo, worldMatrix, camera)) {
662
+ // If world matrix drifted (user applied transforms after load), re-sort before first render.
663
+ // Camera drift is intentionally excluded here: checking camera movement would cause isReady()
664
+ // to return false indefinitely while the camera is moving. The render loop handles camera
665
+ // re-sorting continuously via _postToWorker() in render().
666
+ if (this._isSortStateDirty(cameraViewInfo, worldMatrix, camera, true)) {
574
667
  anyDirty = true;
575
668
  }
576
669
  }
@@ -643,7 +736,7 @@ export class GaussianSplattingMeshBase extends Mesh {
643
736
  localDirection.normalize();
644
737
  return localDirection;
645
738
  }
646
- _isSortStateDirty(cameraViewInfo, worldMatrix, camera) {
739
+ _isSortStateDirty(cameraViewInfo, worldMatrix, camera, worldMatrixOnly = false) {
647
740
  const world = worldMatrix.m;
648
741
  const previousWorld = cameraViewInfo.sortWorldMatrix.m;
649
742
  for (let i = 0; i < previousWorld.length; i++) {
@@ -651,6 +744,9 @@ export class GaussianSplattingMeshBase extends Mesh {
651
744
  return true;
652
745
  }
653
746
  }
747
+ if (worldMatrixOnly) {
748
+ return false;
749
+ }
654
750
  const cameraViewMatrix = camera.getViewMatrix();
655
751
  if (!Scalar.WithinEpsilon(cameraViewInfo.sortCameraForward.x, cameraViewMatrix.m[2], this.viewUpdateThreshold) ||
656
752
  !Scalar.WithinEpsilon(cameraViewInfo.sortCameraForward.y, cameraViewMatrix.m[6], this.viewUpdateThreshold) ||
@@ -1478,10 +1574,7 @@ export class GaussianSplattingMeshBase extends Mesh {
1478
1574
  const width = engine.getCaps().maxTextureSize;
1479
1575
  const height = Math.ceil(splatCount / width);
1480
1576
  // create array for the number of textures needed.
1481
- for (let textureIndex = 0; textureIndex < textureCount; textureIndex++) {
1482
- const texture = new Uint8Array(height * width * 4 * 4); // 4 components per texture, 4 sh per component
1483
- sh.push(texture);
1484
- }
1577
+ sh = AllocateShBuffers(textureCount, height * width * 4 * 4);
1485
1578
  for (let i = 0; i < splatCount; i++) {
1486
1579
  for (let shIndexWrite = 0; shIndexWrite < header.shCoefficientCount; shIndexWrite++) {
1487
1580
  const shValue = ubuf[shIndexRead++];
@@ -1571,6 +1664,7 @@ export class GaussianSplattingMeshBase extends Mesh {
1571
1664
  this._rotationsATexture?.dispose();
1572
1665
  this._rotationsBTexture?.dispose();
1573
1666
  this._rotationScaleTexture?.dispose();
1667
+ this._sogParams?.codebookTexture?.dispose();
1574
1668
  this._rotationsATexture = null;
1575
1669
  this._rotationsBTexture = null;
1576
1670
  this._rotationScaleTexture = null;
@@ -2201,9 +2295,14 @@ export class GaussianSplattingMeshBase extends Mesh {
2201
2295
  const vertexCountPadded = (this._vertexCount + 15) & ~0xf;
2202
2296
  // If the vertex count changed, we discard this result and trigger a new sort
2203
2297
  if (e.data.depthMix.length != vertexCountPadded) {
2204
- this._canPostToWorker = true;
2205
- this._postToWorker(true);
2206
- this._sortIsDirty = false;
2298
+ // Only re-enable posting and trigger a re-sort if the buffer is available.
2299
+ // If byteLength === 0 the buffer is already in-flight for a newer sort;
2300
+ // that sort's onmessage will handle things when it returns.
2301
+ if (this._depthMix.buffer.byteLength > 0) {
2302
+ this._canPostToWorker = true;
2303
+ this._postToWorker(true);
2304
+ this._sortIsDirty = false;
2305
+ }
2207
2306
  return;
2208
2307
  }
2209
2308
  this._depthMix = e.data.depthMix;
@@ -2478,4 +2577,22 @@ GaussianSplattingMeshBase._CreateWorker = function (self) {
2478
2577
  }
2479
2578
  };
2480
2579
  };
2580
+ /**
2581
+ * Allocates SH texture buffers pre-filled with 128 (the neutral encoding of ~0.0 in the
2582
+ * shader's decompose() function). Padding bytes beyond the actual coefficients in the last
2583
+ * texture are read as higher-order SH bands when the mesh is added to a compound with a
2584
+ * higher degree; zero would decode to -1.0 instead, producing wrong colors.
2585
+ * @param textureCount number of SH textures to allocate
2586
+ * @param bytesEach byte size of each texture buffer
2587
+ * @returns array of initialized Uint8Array buffers
2588
+ */
2589
+ export function AllocateShBuffers(textureCount, bytesEach) {
2590
+ const result = [];
2591
+ for (let i = 0; i < textureCount; i++) {
2592
+ const arr = new Uint8Array(bytesEach);
2593
+ arr.fill(128);
2594
+ result.push(arr);
2595
+ }
2596
+ return result;
2597
+ }
2481
2598
  //# sourceMappingURL=gaussianSplattingMeshBase.pure.js.map