@onerjs/core 8.32.8 → 8.33.1

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.
@@ -197,7 +197,6 @@ export declare class GaussianSplattingMesh extends Mesh {
197
197
  private _splatIndex;
198
198
  private _shTextures;
199
199
  private _splatsData;
200
- private _sh;
201
200
  private readonly _keepInRam;
202
201
  private _delayedTextureUpdate;
203
202
  private _useRGBACovariants;
@@ -264,6 +263,7 @@ export declare class GaussianSplattingMesh extends Mesh {
264
263
  * Get the compensation state
265
264
  */
266
265
  get compensation(): boolean;
266
+ private _loadingPromise;
267
267
  /**
268
268
  * set rendering material
269
269
  */
@@ -281,6 +281,11 @@ export declare class GaussianSplattingMesh extends Mesh {
281
281
  * @param keepInRam keep datas in ram for editing purpose
282
282
  */
283
283
  constructor(name: string, url?: Nullable<string>, scene?: Nullable<Scene>, keepInRam?: boolean);
284
+ /**
285
+ * Get the loading promise when loading the mesh from a URL in the constructor
286
+ * @returns constructor loading promise or null if no URL was provided
287
+ */
288
+ getLoadingPromise(): Promise<void> | null;
284
289
  /**
285
290
  * Returns the class name
286
291
  * @returns "GaussianSplattingMesh"
@@ -289,7 +289,6 @@ export class GaussianSplattingMesh extends Mesh {
289
289
  this._splatIndex = null;
290
290
  this._shTextures = null;
291
291
  this._splatsData = null;
292
- this._sh = null;
293
292
  this._keepInRam = false;
294
293
  this._delayedTextureUpdate = null;
295
294
  this._useRGBACovariants = false;
@@ -298,6 +297,7 @@ export class GaussianSplattingMesh extends Mesh {
298
297
  this._sortIsDirty = false;
299
298
  this._shDegree = 0;
300
299
  this._cameraViewInfos = new Map();
300
+ this._loadingPromise = null;
301
301
  this.subMeshes = [];
302
302
  new SubMesh(0, 0, 4 * GaussianSplattingMesh._BatchSize, 0, 6 * GaussianSplattingMesh._BatchSize, this);
303
303
  this.setEnabled(false);
@@ -305,8 +305,7 @@ export class GaussianSplattingMesh extends Mesh {
305
305
  this._useRGBACovariants = !this.getEngine().isWebGPU && this.getEngine().version === 1.0;
306
306
  this._keepInRam = keepInRam;
307
307
  if (url) {
308
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
309
- this.loadFileAsync(url);
308
+ this._loadingPromise = this.loadFileAsync(url);
310
309
  }
311
310
  const gaussianSplattingMaterial = new GaussianSplattingMaterial(this.name + "_material", this._scene);
312
311
  gaussianSplattingMaterial.setSourceMesh(this);
@@ -322,6 +321,13 @@ export class GaussianSplattingMesh extends Mesh {
322
321
  }
323
322
  });
324
323
  }
324
+ /**
325
+ * Get the loading promise when loading the mesh from a URL in the constructor
326
+ * @returns constructor loading promise or null if no URL was provided
327
+ */
328
+ getLoadingPromise() {
329
+ return this._loadingPromise;
330
+ }
325
331
  /**
326
332
  * Returns the class name
327
333
  * @returns "GaussianSplattingMesh"
@@ -355,11 +361,11 @@ export class GaussianSplattingMesh extends Mesh {
355
361
  _getCameraDirection(camera) {
356
362
  const cameraMatrix = camera.getViewMatrix();
357
363
  this.getWorldMatrix().multiplyToRef(cameraMatrix, this._modelViewMatrix);
358
- cameraMatrix.invertToRef(TmpVectors.Matrix[0]);
359
- this.getWorldMatrix().multiplyToRef(TmpVectors.Matrix[0], TmpVectors.Matrix[1]);
360
- Vector3.TransformNormalToRef(Vector3.Forward(this._scene.useRightHandedSystem), TmpVectors.Matrix[1], TmpVectors.Vector3[2]);
361
- TmpVectors.Vector3[2].normalize();
362
- return TmpVectors.Vector3[2];
364
+ // return vector used to compute distance to camera
365
+ const localDirection = TmpVectors.Vector3[1];
366
+ localDirection.set(this._modelViewMatrix.m[2], this._modelViewMatrix.m[6], this._modelViewMatrix.m[10]);
367
+ localDirection.normalize();
368
+ return localDirection;
363
369
  }
364
370
  /** @internal */
365
371
  _postToWorker(forced = false) {
@@ -692,10 +698,10 @@ export class GaussianSplattingMesh extends Mesh {
692
698
  shDegree = 3;
693
699
  }
694
700
  else if (value >= 64 /* PLYValue.SH_24 */) {
695
- shDegree = 2;
701
+ shDegree = Math.max(shDegree, 2);
696
702
  }
697
703
  else if (value >= 48 /* PLYValue.SH_8 */) {
698
- shDegree = 1;
704
+ shDegree = Math.max(shDegree, 1);
699
705
  }
700
706
  }
701
707
  const type = GaussianSplattingMesh._TypeNameToEnum(typeName);
@@ -1280,9 +1286,7 @@ export class GaussianSplattingMesh extends Mesh {
1280
1286
  const fBuffer = new Float32Array(uBuffer.buffer);
1281
1287
  if (this._keepInRam) {
1282
1288
  this._splatsData = data;
1283
- if (sh) {
1284
- this._sh = sh;
1285
- }
1289
+ // keep sh in ram too ?
1286
1290
  }
1287
1291
  const vertexCount = uBuffer.length / GaussianSplattingMesh._RowOutputLength;
1288
1292
  if (vertexCount != this._vertexCount) {
@@ -1404,7 +1408,7 @@ export class GaussianSplattingMesh extends Mesh {
1404
1408
  if (sh) {
1405
1409
  for (let i = 0; i < sh.length; i++) {
1406
1410
  const componentCount = 4;
1407
- const shView = new Uint8Array(this._sh[i].buffer, texelStart * componentCount, texelCount * componentCount);
1411
+ const shView = new Uint32Array(sh[i].buffer, texelStart * componentCount * 4, texelCount * componentCount);
1408
1412
  updateTextureFromData(this._shTextures[i], shView, textureSize.x, lineStart, lineCount);
1409
1413
  }
1410
1414
  }
@@ -1422,7 +1426,7 @@ export class GaussianSplattingMesh extends Mesh {
1422
1426
  const vertexCountPadded = (this._vertexCount + 15) & ~0xf;
1423
1427
  this._depthMix = new BigInt64Array(vertexCountPadded);
1424
1428
  const positions = Float32Array.from(this._splatPositions);
1425
- this._worker.postMessage({ positions, vertexCountPadded }, [positions.buffer]);
1429
+ this._worker.postMessage({ positions }, [positions.buffer]);
1426
1430
  this._worker.onmessage = (e) => {
1427
1431
  this._depthMix = e.data.depthMix;
1428
1432
  const cameraId = e.data.cameraId;
@@ -1491,7 +1495,6 @@ GaussianSplattingMesh._BatchSize = 16; // 16 splats per instance
1491
1495
  */
1492
1496
  GaussianSplattingMesh.ProgressiveUpdateAmount = 0;
1493
1497
  GaussianSplattingMesh._CreateWorker = function (self) {
1494
- let vertexCountPadded = 0;
1495
1498
  let positions;
1496
1499
  let depthMix;
1497
1500
  let indices;
@@ -1500,12 +1503,12 @@ GaussianSplattingMesh._CreateWorker = function (self) {
1500
1503
  // updated on init
1501
1504
  if (e.data.positions) {
1502
1505
  positions = e.data.positions;
1503
- vertexCountPadded = e.data.vertexCountPadded;
1504
1506
  }
1505
1507
  // udpate on view changed
1506
1508
  else {
1507
1509
  const cameraId = e.data.cameraId;
1508
1510
  const viewProj = e.data.view;
1511
+ const vertexCountPadded = (positions.length + 15) & ~0xf;
1509
1512
  if (!positions || !viewProj) {
1510
1513
  // Sanity check, it shouldn't happen!
1511
1514
  throw new Error("positions or view is not defined!");