@babylonjs/core 8.45.3 → 8.45.4

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 (53) hide show
  1. package/Cameras/touchCamera.js +1 -1
  2. package/Cameras/touchCamera.js.map +1 -1
  3. package/Engines/Native/nativeHelpers.js +7 -0
  4. package/Engines/Native/nativeHelpers.js.map +1 -1
  5. package/Engines/Native/nativeInterfaces.d.ts +2 -0
  6. package/Engines/Native/nativeInterfaces.js.map +1 -1
  7. package/Engines/abstractEngine.js +2 -2
  8. package/Engines/abstractEngine.js.map +1 -1
  9. package/FrameGraph/Node/nodeRenderGraph.d.ts +0 -5
  10. package/FrameGraph/Node/nodeRenderGraph.js +0 -7
  11. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  12. package/FrameGraph/frameGraph.d.ts +0 -6
  13. package/FrameGraph/frameGraph.js +0 -23
  14. package/FrameGraph/frameGraph.js.map +1 -1
  15. package/FrameGraph/frameGraphObjectList.d.ts +0 -1
  16. package/FrameGraph/frameGraphObjectList.js +0 -1
  17. package/FrameGraph/frameGraphObjectList.js.map +1 -1
  18. package/FrameGraph/frameGraphRenderContext.d.ts +0 -1
  19. package/FrameGraph/frameGraphRenderContext.js +0 -1
  20. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  21. package/FrameGraph/frameGraphRenderTarget.d.ts +0 -1
  22. package/FrameGraph/frameGraphRenderTarget.js +0 -1
  23. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  24. package/FrameGraph/frameGraphTask.d.ts +0 -1
  25. package/FrameGraph/frameGraphTask.js +0 -1
  26. package/FrameGraph/frameGraphTask.js.map +1 -1
  27. package/FrameGraph/frameGraphTextureManager.d.ts +0 -1
  28. package/FrameGraph/frameGraphTextureManager.js +0 -1
  29. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  30. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +6 -0
  31. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +100 -41
  32. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  33. package/Particles/Node/Blocks/Update/updateFlowMapBlock.d.ts +4 -14
  34. package/Particles/Node/Blocks/Update/updateFlowMapBlock.js +9 -27
  35. package/Particles/Node/Blocks/Update/updateFlowMapBlock.js.map +1 -1
  36. package/Particles/Node/Blocks/particleVectorMathBlock.d.ts +3 -7
  37. package/Particles/Node/Blocks/particleVectorMathBlock.js +15 -32
  38. package/Particles/Node/Blocks/particleVectorMathBlock.js.map +1 -1
  39. package/Particles/Node/Blocks/systemBlock.d.ts +4 -0
  40. package/Particles/Node/Blocks/systemBlock.js +9 -1
  41. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  42. package/Particles/Node/nodeParticleSystemSet.helper.js +62 -4
  43. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  44. package/Particles/baseParticleSystem.d.ts +7 -0
  45. package/Particles/baseParticleSystem.js +7 -0
  46. package/Particles/baseParticleSystem.js.map +1 -1
  47. package/Particles/particleSystem.d.ts +12 -0
  48. package/Particles/particleSystem.js +12 -0
  49. package/Particles/particleSystem.js.map +1 -1
  50. package/Particles/thinParticleSystem.d.ts +10 -0
  51. package/Particles/thinParticleSystem.js +10 -1
  52. package/Particles/thinParticleSystem.js.map +1 -1
  53. package/package.json +1 -1
@@ -161,6 +161,24 @@ var PLYValue;
161
161
  * Class used to render a gaussian splatting mesh
162
162
  */
163
163
  export class GaussianSplattingMesh extends Mesh {
164
+ /**
165
+ * If true, disables depth sorting of the splats (default: false)
166
+ */
167
+ get disableDepthSort() {
168
+ return this._disableDepthSort;
169
+ }
170
+ set disableDepthSort(value) {
171
+ if (!this._disableDepthSort && value) {
172
+ this._worker?.terminate();
173
+ this._worker = null;
174
+ this._disableDepthSort = true;
175
+ }
176
+ else if (this._disableDepthSort && !value) {
177
+ this._disableDepthSort = false;
178
+ this._sortIsDirty = true;
179
+ this._instanciateWorker();
180
+ }
181
+ }
164
182
  /**
165
183
  * View direction factor used to compute the SH view direction in the shader.
166
184
  * @deprecated Not used anymore for SH rendering
@@ -297,6 +315,7 @@ export class GaussianSplattingMesh extends Mesh {
297
315
  this._sortIsDirty = false;
298
316
  this._shDegree = 0;
299
317
  this._cameraViewInfos = new Map();
318
+ this._disableDepthSort = false;
300
319
  this._loadingPromise = null;
301
320
  this.subMeshes = [];
302
321
  new SubMesh(0, 0, 4 * GaussianSplattingMesh._BatchSize, 0, 6 * GaussianSplattingMesh._BatchSize, this);
@@ -378,38 +397,39 @@ export class GaussianSplattingMesh extends Mesh {
378
397
  outdated = true;
379
398
  }
380
399
  });
381
- if ((forced || outdated) && this._worker && (this._scene.activeCameras?.length || this._scene.activeCamera) && this._canPostToWorker) {
382
- // array of cameras used for rendering
383
- const cameras = this._scene.activeCameras?.length ? this._scene.activeCameras : [this._scene.activeCamera];
384
- // list view infos for active cameras
385
- const activeViewInfos = [];
386
- cameras.forEach((camera) => {
387
- const cameraId = camera.uniqueId;
388
- const cameraViewInfos = this._cameraViewInfos.get(cameraId);
389
- if (cameraViewInfos) {
390
- activeViewInfos.push(cameraViewInfos);
391
- }
392
- else {
393
- // mesh doesn't exist yet for this camera
394
- const cameraMesh = new Mesh(this.name + "_cameraMesh_" + cameraId, this._scene);
395
- // not visible with inspector or the scene graph
396
- cameraMesh.reservedDataStore = { hidden: true };
397
- cameraMesh.setEnabled(false);
398
- cameraMesh.material = this.material;
399
- GaussianSplattingMesh._MakeSplatGeometryForMesh(cameraMesh);
400
- const newViewInfos = {
401
- camera: camera,
402
- cameraDirection: new Vector3(0, 0, 0),
403
- mesh: cameraMesh,
404
- frameIdLastUpdate: frameId,
405
- splatIndexBufferSet: false,
406
- };
407
- activeViewInfos.push(newViewInfos);
408
- this._cameraViewInfos.set(cameraId, newViewInfos);
409
- }
410
- });
411
- // sort view infos by last updated frame id: first item is the least recently updated
412
- activeViewInfos.sort((a, b) => a.frameIdLastUpdate - b.frameIdLastUpdate);
400
+ // array of cameras used for rendering
401
+ const cameras = this._scene.activeCameras?.length ? this._scene.activeCameras : [this._scene.activeCamera];
402
+ // list view infos for active cameras
403
+ const activeViewInfos = [];
404
+ cameras.forEach((camera) => {
405
+ const cameraId = camera.uniqueId;
406
+ const cameraViewInfos = this._cameraViewInfos.get(cameraId);
407
+ if (cameraViewInfos) {
408
+ activeViewInfos.push(cameraViewInfos);
409
+ }
410
+ else {
411
+ // mesh doesn't exist yet for this camera
412
+ const cameraMesh = new Mesh(this.name + "_cameraMesh_" + cameraId, this._scene);
413
+ // not visible with inspector or the scene graph
414
+ cameraMesh.reservedDataStore = { hidden: true };
415
+ cameraMesh.setEnabled(false);
416
+ cameraMesh.material = this.material;
417
+ GaussianSplattingMesh._MakeSplatGeometryForMesh(cameraMesh);
418
+ const newViewInfos = {
419
+ camera: camera,
420
+ cameraDirection: new Vector3(0, 0, 0),
421
+ mesh: cameraMesh,
422
+ frameIdLastUpdate: frameId,
423
+ splatIndexBufferSet: false,
424
+ };
425
+ activeViewInfos.push(newViewInfos);
426
+ this._cameraViewInfos.set(cameraId, newViewInfos);
427
+ }
428
+ });
429
+ // sort view infos by last updated frame id: first item is the least recently updated
430
+ activeViewInfos.sort((a, b) => a.frameIdLastUpdate - b.frameIdLastUpdate);
431
+ const hasSortFunction = this._worker || (_native && _native.sortSplats) || this._disableDepthSort;
432
+ if ((forced || outdated) && hasSortFunction && (this._scene.activeCameras?.length || this._scene.activeCamera) && this._canPostToWorker) {
413
433
  // view infos sorted by least recent updated frame id
414
434
  activeViewInfos.forEach((cameraViewInfos) => {
415
435
  const camera = cameraViewInfos.camera;
@@ -420,14 +440,38 @@ export class GaussianSplattingMesh extends Mesh {
420
440
  cameraViewInfos.cameraDirection.copyFrom(cameraDirection);
421
441
  cameraViewInfos.frameIdLastUpdate = frameId;
422
442
  this._canPostToWorker = false;
423
- this._worker.postMessage({
424
- view: this._modelViewMatrix.m,
425
- depthMix: this._depthMix,
426
- useRightHandedSystem: this._scene.useRightHandedSystem,
427
- cameraId: camera.uniqueId,
428
- }, [this._depthMix.buffer]);
443
+ if (this._worker) {
444
+ this._worker.postMessage({
445
+ view: this._modelViewMatrix.m,
446
+ depthMix: this._depthMix,
447
+ useRightHandedSystem: this._scene.useRightHandedSystem,
448
+ cameraId: camera.uniqueId,
449
+ }, [this._depthMix.buffer]);
450
+ }
451
+ else if (_native && _native.sortSplats) {
452
+ _native.sortSplats(this._modelViewMatrix, this._splatPositions, this._splatIndex, this._scene.useRightHandedSystem);
453
+ if (cameraViewInfos.splatIndexBufferSet) {
454
+ cameraViewInfos.mesh.thinInstanceBufferUpdated("splatIndex");
455
+ }
456
+ else {
457
+ cameraViewInfos.mesh.thinInstanceSetBuffer("splatIndex", this._splatIndex, 16, false);
458
+ cameraViewInfos.splatIndexBufferSet = true;
459
+ }
460
+ this._canPostToWorker = true;
461
+ this._readyToDisplay = true;
462
+ }
463
+ }
464
+ });
465
+ }
466
+ else if (this._disableDepthSort) {
467
+ activeViewInfos.forEach((cameraViewInfos) => {
468
+ if (!cameraViewInfos.splatIndexBufferSet) {
469
+ cameraViewInfos.mesh.thinInstanceSetBuffer("splatIndex", this._splatIndex, 16, false);
470
+ cameraViewInfos.splatIndexBufferSet = true;
429
471
  }
430
472
  });
473
+ this._canPostToWorker = true;
474
+ this._readyToDisplay = true;
431
475
  }
432
476
  }
433
477
  /**
@@ -1176,6 +1220,7 @@ export class GaussianSplattingMesh extends Mesh {
1176
1220
  newGS._modelViewMatrix = Matrix.Identity();
1177
1221
  newGS._splatPositions = this._splatPositions;
1178
1222
  newGS._readyToDisplay = false;
1223
+ newGS._disableDepthSort = this._disableDepthSort;
1179
1224
  newGS._instanciateWorker();
1180
1225
  const binfo = this.getBoundingInfo();
1181
1226
  newGS.getBoundingInfo().reConstruct(binfo.minimum, binfo.maximum, this.getWorldMatrix());
@@ -1259,7 +1304,9 @@ export class GaussianSplattingMesh extends Mesh {
1259
1304
  this._delayedTextureUpdate = { covA: covA, covB: covB, colors: colorArray, centers: this._splatPositions, sh: sh };
1260
1305
  const positions = Float32Array.from(this._splatPositions);
1261
1306
  const vertexCount = this._vertexCount;
1262
- this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
1307
+ if (this._worker) {
1308
+ this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
1309
+ }
1263
1310
  this._postToWorker(true);
1264
1311
  }
1265
1312
  else {
@@ -1330,7 +1377,9 @@ export class GaussianSplattingMesh extends Mesh {
1330
1377
  // sort will be dirty here as just finished filled positions will not be sorted
1331
1378
  const positions = Float32Array.from(this._splatPositions);
1332
1379
  const vertexCount = this._vertexCount;
1333
- this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
1380
+ if (this._worker) {
1381
+ this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
1382
+ }
1334
1383
  this._sortIsDirty = true;
1335
1384
  }
1336
1385
  else {
@@ -1386,6 +1435,9 @@ export class GaussianSplattingMesh extends Mesh {
1386
1435
  const paddedVertexCount = (vertexCount + 15) & ~0xf;
1387
1436
  if (!this._splatIndex || vertexCount > this._splatIndex.length) {
1388
1437
  this._splatIndex = new Float32Array(paddedVertexCount);
1438
+ for (let i = 0; i < paddedVertexCount; i++) {
1439
+ this._splatIndex[i] = i;
1440
+ }
1389
1441
  // update meshes for knowns cameras
1390
1442
  this._cameraViewInfos.forEach((cameraViewInfos) => {
1391
1443
  cameraViewInfos.mesh.thinInstanceSetBuffer("splatIndex", this._splatIndex, 16, false);
@@ -1421,7 +1473,14 @@ export class GaussianSplattingMesh extends Mesh {
1421
1473
  if (!this._vertexCount) {
1422
1474
  return;
1423
1475
  }
1476
+ if (this._disableDepthSort) {
1477
+ return;
1478
+ }
1424
1479
  this._updateSplatIndexBuffer(this._vertexCount);
1480
+ // no worker in native
1481
+ if (_native) {
1482
+ return;
1483
+ }
1425
1484
  // Start the worker thread
1426
1485
  this._worker?.terminate();
1427
1486
  this._worker = new Worker(URL.createObjectURL(new Blob(["(", GaussianSplattingMesh._CreateWorker.toString(), ")(self)"], {
@@ -1512,7 +1571,7 @@ GaussianSplattingMesh._CreateWorker = function (self) {
1512
1571
  else {
1513
1572
  const cameraId = e.data.cameraId;
1514
1573
  const viewProj = e.data.view;
1515
- const vertexCountPadded = (positions.length + 15) & ~0xf;
1574
+ const vertexCountPadded = (positions.length / 4 + 15) & ~0xf;
1516
1575
  if (!positions || !viewProj) {
1517
1576
  // Sanity check, it shouldn't happen!
1518
1577
  throw new Error("positions or view is not defined!");