@onerjs/core 8.50.1 → 8.50.3

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 (106) hide show
  1. package/Engines/abstractEngine.js +2 -2
  2. package/Engines/abstractEngine.js.map +1 -1
  3. package/Engines/engine.d.ts +49 -1118
  4. package/FlowGraph/flowGraph.d.ts +11 -0
  5. package/FlowGraph/flowGraph.js +20 -0
  6. package/FlowGraph/flowGraph.js.map +1 -1
  7. package/FlowGraph/flowGraphContext.d.ts +30 -0
  8. package/FlowGraph/flowGraphContext.js +42 -0
  9. package/FlowGraph/flowGraphContext.js.map +1 -1
  10. package/FlowGraph/flowGraphParser.js +13 -0
  11. package/FlowGraph/flowGraphParser.js.map +1 -1
  12. package/FlowGraph/typeDefinitions.d.ts +16 -0
  13. package/FlowGraph/typeDefinitions.js.map +1 -1
  14. package/Layers/thinSelectionOutlineLayer.js +25 -1
  15. package/Layers/thinSelectionOutlineLayer.js.map +1 -1
  16. package/Lights/light.d.ts +6 -0
  17. package/Lights/light.js +8 -0
  18. package/Lights/light.js.map +1 -1
  19. package/Lights/spotLight.d.ts +2 -0
  20. package/Lights/spotLight.js +10 -0
  21. package/Lights/spotLight.js.map +1 -1
  22. package/Materials/Background/backgroundMaterial.js +4 -1
  23. package/Materials/Background/backgroundMaterial.js.map +1 -1
  24. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +18 -0
  25. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +123 -3
  26. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  27. package/Materials/Node/Blocks/Dual/lightBlock.d.ts +8 -0
  28. package/Materials/Node/Blocks/Dual/lightBlock.js +16 -0
  29. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  30. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +3 -0
  31. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  32. package/Materials/Node/nodeMaterial.js +4 -1
  33. package/Materials/Node/nodeMaterial.js.map +1 -1
  34. package/Materials/PBR/openpbrMaterial.js +4 -1
  35. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  36. package/Materials/PBR/pbrBaseMaterial.js +4 -1
  37. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  38. package/Materials/Textures/baseTexture.d.ts +1 -0
  39. package/Materials/Textures/baseTexture.js +1 -0
  40. package/Materials/Textures/baseTexture.js.map +1 -1
  41. package/Materials/Textures/texture.d.ts +1 -1
  42. package/Materials/Textures/texture.js.map +1 -1
  43. package/Materials/materialHelper.functions.d.ts +12 -0
  44. package/Materials/materialHelper.functions.js +24 -0
  45. package/Materials/materialHelper.functions.js.map +1 -1
  46. package/Materials/standardMaterial.js +4 -1
  47. package/Materials/standardMaterial.js.map +1 -1
  48. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +5 -1
  49. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +14 -4
  50. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  51. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.d.ts +61 -3
  52. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +235 -20
  53. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
  54. package/Misc/tools.js +1 -1
  55. package/Misc/tools.js.map +1 -1
  56. package/Particles/IParticleSystem.d.ts +7 -1
  57. package/Particles/IParticleSystem.js.map +1 -1
  58. package/Particles/baseParticleSystem.d.ts +18 -2
  59. package/Particles/baseParticleSystem.js +53 -11
  60. package/Particles/baseParticleSystem.js.map +1 -1
  61. package/Particles/computeShaderParticleSystem.js +16 -0
  62. package/Particles/computeShaderParticleSystem.js.map +1 -1
  63. package/Particles/gpuParticleSystem.d.ts +14 -72
  64. package/Particles/gpuParticleSystem.js +130 -106
  65. package/Particles/gpuParticleSystem.js.map +1 -1
  66. package/Particles/particleSystem.d.ts +0 -80
  67. package/Particles/particleSystem.functions.d.ts +16 -0
  68. package/Particles/particleSystem.functions.js +18 -0
  69. package/Particles/particleSystem.functions.js.map +1 -1
  70. package/Particles/particleSystem.js +0 -114
  71. package/Particles/particleSystem.js.map +1 -1
  72. package/Particles/webgl2ParticleSystem.js +12 -0
  73. package/Particles/webgl2ParticleSystem.js.map +1 -1
  74. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +17 -0
  75. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  76. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +10 -0
  77. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +146 -24
  78. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  79. package/Rendering/objectRenderer.d.ts +2 -0
  80. package/Rendering/objectRenderer.js +10 -0
  81. package/Rendering/objectRenderer.js.map +1 -1
  82. package/Shaders/ShadersInclude/gaussianSplatting.js +46 -5
  83. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  84. package/Shaders/gaussianSplatting.vertex.js +3 -0
  85. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  86. package/Shaders/gaussianSplattingVoxel.fragment.d.ts +5 -0
  87. package/Shaders/gaussianSplattingVoxel.fragment.js +27 -0
  88. package/Shaders/gaussianSplattingVoxel.fragment.js.map +1 -0
  89. package/Shaders/gaussianSplattingVoxel.vertex.d.ts +8 -0
  90. package/Shaders/gaussianSplattingVoxel.vertex.js +31 -0
  91. package/Shaders/gaussianSplattingVoxel.vertex.js.map +1 -0
  92. package/Shaders/gpuUpdateParticles.vertex.js +13 -0
  93. package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
  94. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +58 -6
  95. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  96. package/ShadersWGSL/gaussianSplatting.vertex.js +3 -0
  97. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  98. package/ShadersWGSL/gaussianSplattingVoxel.fragment.d.ts +5 -0
  99. package/ShadersWGSL/gaussianSplattingVoxel.fragment.js +22 -0
  100. package/ShadersWGSL/gaussianSplattingVoxel.fragment.js.map +1 -0
  101. package/ShadersWGSL/gaussianSplattingVoxel.vertex.d.ts +8 -0
  102. package/ShadersWGSL/gaussianSplattingVoxel.vertex.js +42 -0
  103. package/ShadersWGSL/gaussianSplattingVoxel.vertex.js.map +1 -0
  104. package/ShadersWGSL/gpuUpdateParticles.compute.js +19 -0
  105. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  106. package/package.json +1 -1
@@ -114,7 +114,34 @@ declare enum PLYValue {
114
114
  SH_42 = 82,
115
115
  SH_43 = 83,
116
116
  SH_44 = 84,
117
- UNDEFINED = 85
117
+ SH_45 = 85,
118
+ SH_46 = 86,
119
+ SH_47 = 87,
120
+ SH_48 = 88,
121
+ SH_49 = 89,
122
+ SH_50 = 90,
123
+ SH_51 = 91,
124
+ SH_52 = 92,
125
+ SH_53 = 93,
126
+ SH_54 = 94,
127
+ SH_55 = 95,
128
+ SH_56 = 96,
129
+ SH_57 = 97,
130
+ SH_58 = 98,
131
+ SH_59 = 99,
132
+ SH_60 = 100,
133
+ SH_61 = 101,
134
+ SH_62 = 102,
135
+ SH_63 = 103,
136
+ SH_64 = 104,
137
+ SH_65 = 105,
138
+ SH_66 = 106,
139
+ SH_67 = 107,
140
+ SH_68 = 108,
141
+ SH_69 = 109,
142
+ SH_70 = 110,
143
+ SH_71 = 111,
144
+ UNDEFINED = 112
118
145
  }
119
146
  /**
120
147
  * Property field found in PLY header
@@ -198,6 +225,13 @@ export declare class GaussianSplattingMeshBase extends Mesh {
198
225
  protected _covariancesBTexture: Nullable<BaseTexture>;
199
226
  protected _centersTexture: Nullable<BaseTexture>;
200
227
  protected _colorsTexture: Nullable<BaseTexture>;
228
+ protected _rotationsATexture: Nullable<BaseTexture>;
229
+ protected _rotationsBTexture: Nullable<BaseTexture>;
230
+ protected _rotationScaleTexture: Nullable<BaseTexture>;
231
+ private _rotationDataA;
232
+ private _rotationDataB;
233
+ private _rotationScaleData;
234
+ protected _needsRotationScaleTextures: boolean;
201
235
  protected _splatPositions: Nullable<Float32Array>;
202
236
  private _splatIndex;
203
237
  protected _shTextures: Nullable<BaseTexture[]>;
@@ -222,6 +256,7 @@ export declare class GaussianSplattingMeshBase extends Mesh {
222
256
  private static _PlyConversionBatchSize;
223
257
  /** @internal */
224
258
  _shDegree: number;
259
+ private _maxShDegree;
225
260
  private static readonly _BatchSize;
226
261
  private _cameraViewInfos;
227
262
  protected static readonly _DefaultViewUpdateThreshold = 0.0001;
@@ -285,6 +320,23 @@ export declare class GaussianSplattingMeshBase extends Mesh {
285
320
  * Gets the colors texture
286
321
  */
287
322
  get colorsTexture(): Nullable<BaseTexture>;
323
+ /**
324
+ * Gets the rotation matrix A texture (rotation elements m[0],m[1],m[2],m[4])
325
+ */
326
+ get rotationsATexture(): Nullable<BaseTexture>;
327
+ /**
328
+ * Gets the rotation matrix B texture (rotation elements m[5],m[6],m[8],m[9])
329
+ */
330
+ get rotationsBTexture(): Nullable<BaseTexture>;
331
+ /**
332
+ * Gets the rotation scale texture (rotation element m[10] followed by scale diagonal sx,sy,sz)
333
+ */
334
+ get rotationScaleTexture(): Nullable<BaseTexture>;
335
+ /**
336
+ * Enables or disables generation of rotation and scale matrix textures, required for voxel-based IBL shadows.
337
+ */
338
+ get needsRotationScaleTextures(): boolean;
339
+ set needsRotationScaleTextures(value: boolean);
288
340
  /**
289
341
  * Gets the SH textures
290
342
  */
@@ -370,9 +422,11 @@ export declare class GaussianSplattingMeshBase extends Mesh {
370
422
  static ConvertPLYWithSHToSplat(data: ArrayBuffer, useCoroutine?: boolean): Generator<undefined, {
371
423
  buffer: ArrayBuffer;
372
424
  sh?: undefined;
425
+ shDegree?: undefined;
373
426
  } | {
374
427
  buffer: ArrayBuffer;
375
428
  sh: Uint8Array<ArrayBuffer>[] | null;
429
+ shDegree: number;
376
430
  }, unknown>;
377
431
  /**
378
432
  * Converts a .ply data array buffer to splat
@@ -398,9 +452,11 @@ export declare class GaussianSplattingMeshBase extends Mesh {
398
452
  static ConvertPLYWithSHToSplatAsync(data: ArrayBuffer): Promise<{
399
453
  buffer: ArrayBuffer;
400
454
  sh?: undefined;
455
+ shDegree?: undefined;
401
456
  } | {
402
457
  buffer: ArrayBuffer;
403
458
  sh: Uint8Array<ArrayBuffer>[] | null;
459
+ shDegree: number;
404
460
  }>;
405
461
  /**
406
462
  * Loads a .splat Gaussian Splatting array buffer asynchronously
@@ -493,9 +549,10 @@ export declare class GaussianSplattingMeshBase extends Mesh {
493
549
  * @param data array buffer containing center, color, orientation and scale of splats
494
550
  * @param sh optional array of uint8 array for SH data
495
551
  * @param partIndices optional array of uint8 for rig node indices
552
+ * @param shDegree optional SH degree of the data
496
553
  * @returns a promise
497
554
  */
498
- updateDataAsync(data: ArrayBuffer, sh?: Uint8Array[], partIndices?: Uint8Array): Promise<void>;
555
+ updateDataAsync(data: ArrayBuffer, sh?: Uint8Array[], partIndices?: Uint8Array, shDegree?: number): Promise<void>;
499
556
  /**
500
557
  * @experimental
501
558
  * Update data from GS (position, orientation, color, scaling)
@@ -503,8 +560,9 @@ export declare class GaussianSplattingMeshBase extends Mesh {
503
560
  * @param sh optional array of uint8 array for SH data
504
561
  * @param options optional informations on how to treat data (needs to be 3rd for backward compatibility)
505
562
  * @param partIndices optional array of uint8 for rig node indices
563
+ * @param shDegree optional SH degree of the data
506
564
  */
507
- updateData(data: ArrayBuffer, sh?: Uint8Array[], options?: IUpdateOptions, partIndices?: Uint8Array): void;
565
+ updateData(data: ArrayBuffer, sh?: Uint8Array[], options?: IUpdateOptions, partIndices?: Uint8Array, shDegree?: number): void;
508
566
  /**
509
567
  * Refreshes the bounding info, taking into account all the thin instances defined
510
568
  * @returns the current Gaussian Splatting
@@ -157,7 +157,34 @@ var PLYValue;
157
157
  PLYValue[PLYValue["SH_42"] = 82] = "SH_42";
158
158
  PLYValue[PLYValue["SH_43"] = 83] = "SH_43";
159
159
  PLYValue[PLYValue["SH_44"] = 84] = "SH_44";
160
- PLYValue[PLYValue["UNDEFINED"] = 85] = "UNDEFINED";
160
+ PLYValue[PLYValue["SH_45"] = 85] = "SH_45";
161
+ PLYValue[PLYValue["SH_46"] = 86] = "SH_46";
162
+ PLYValue[PLYValue["SH_47"] = 87] = "SH_47";
163
+ PLYValue[PLYValue["SH_48"] = 88] = "SH_48";
164
+ PLYValue[PLYValue["SH_49"] = 89] = "SH_49";
165
+ PLYValue[PLYValue["SH_50"] = 90] = "SH_50";
166
+ PLYValue[PLYValue["SH_51"] = 91] = "SH_51";
167
+ PLYValue[PLYValue["SH_52"] = 92] = "SH_52";
168
+ PLYValue[PLYValue["SH_53"] = 93] = "SH_53";
169
+ PLYValue[PLYValue["SH_54"] = 94] = "SH_54";
170
+ PLYValue[PLYValue["SH_55"] = 95] = "SH_55";
171
+ PLYValue[PLYValue["SH_56"] = 96] = "SH_56";
172
+ PLYValue[PLYValue["SH_57"] = 97] = "SH_57";
173
+ PLYValue[PLYValue["SH_58"] = 98] = "SH_58";
174
+ PLYValue[PLYValue["SH_59"] = 99] = "SH_59";
175
+ PLYValue[PLYValue["SH_60"] = 100] = "SH_60";
176
+ PLYValue[PLYValue["SH_61"] = 101] = "SH_61";
177
+ PLYValue[PLYValue["SH_62"] = 102] = "SH_62";
178
+ PLYValue[PLYValue["SH_63"] = 103] = "SH_63";
179
+ PLYValue[PLYValue["SH_64"] = 104] = "SH_64";
180
+ PLYValue[PLYValue["SH_65"] = 105] = "SH_65";
181
+ PLYValue[PLYValue["SH_66"] = 106] = "SH_66";
182
+ PLYValue[PLYValue["SH_67"] = 107] = "SH_67";
183
+ PLYValue[PLYValue["SH_68"] = 108] = "SH_68";
184
+ PLYValue[PLYValue["SH_69"] = 109] = "SH_69";
185
+ PLYValue[PLYValue["SH_70"] = 110] = "SH_70";
186
+ PLYValue[PLYValue["SH_71"] = 111] = "SH_71";
187
+ PLYValue[PLYValue["UNDEFINED"] = 112] = "UNDEFINED";
161
188
  })(PLYValue || (PLYValue = {}));
162
189
  /**
163
190
  * Base class for Gaussian Splatting meshes. Contains all single-cloud rendering logic.
@@ -197,7 +224,7 @@ export class GaussianSplattingMeshBase extends Mesh {
197
224
  return this._shDegree;
198
225
  }
199
226
  set shDegree(value) {
200
- const maxDegree = this._shTextures?.length ?? 0;
227
+ const maxDegree = this._maxShDegree;
201
228
  const clamped = Math.max(0, Math.min(Math.round(value), maxDegree));
202
229
  if (this._shDegree === clamped) {
203
230
  return;
@@ -209,7 +236,7 @@ export class GaussianSplattingMeshBase extends Mesh {
209
236
  * Maximum SH degree available from the loaded data.
210
237
  */
211
238
  get maxShDegree() {
212
- return this._shTextures?.length ?? 0;
239
+ return this._maxShDegree;
213
240
  }
214
241
  /**
215
242
  * Number of splats in the mesh
@@ -255,6 +282,45 @@ export class GaussianSplattingMeshBase extends Mesh {
255
282
  get colorsTexture() {
256
283
  return this._colorsTexture;
257
284
  }
285
+ /**
286
+ * Gets the rotation matrix A texture (rotation elements m[0],m[1],m[2],m[4])
287
+ */
288
+ get rotationsATexture() {
289
+ return this._rotationsATexture;
290
+ }
291
+ /**
292
+ * Gets the rotation matrix B texture (rotation elements m[5],m[6],m[8],m[9])
293
+ */
294
+ get rotationsBTexture() {
295
+ return this._rotationsBTexture;
296
+ }
297
+ /**
298
+ * Gets the rotation scale texture (rotation element m[10] followed by scale diagonal sx,sy,sz)
299
+ */
300
+ get rotationScaleTexture() {
301
+ return this._rotationScaleTexture;
302
+ }
303
+ /**
304
+ * Enables or disables generation of rotation and scale matrix textures, required for voxel-based IBL shadows.
305
+ */
306
+ get needsRotationScaleTextures() {
307
+ return this._needsRotationScaleTextures;
308
+ }
309
+ set needsRotationScaleTextures(value) {
310
+ if (this._needsRotationScaleTextures === value) {
311
+ return;
312
+ }
313
+ this._needsRotationScaleTextures = value;
314
+ if (value && this._covariancesATexture) {
315
+ if (this._splatsData) {
316
+ this.updateData(this._splatsData, this._shData ?? undefined, { flipY: false });
317
+ }
318
+ else {
319
+ Logger.Error("GaussianSplattingMeshBase: needsRotationScaleTextures was enabled after the mesh was already loaded, but the splat data is not kept in RAM. " +
320
+ "The rotation and scale matrix textures cannot be initialized. Please reload the mesh data via updateData() or construct with keepInRam=true.");
321
+ }
322
+ }
323
+ }
258
324
  /**
259
325
  * Gets the SH textures
260
326
  */
@@ -331,6 +397,13 @@ export class GaussianSplattingMeshBase extends Mesh {
331
397
  this._covariancesBTexture = null;
332
398
  this._centersTexture = null;
333
399
  this._colorsTexture = null;
400
+ this._rotationsATexture = null;
401
+ this._rotationsBTexture = null;
402
+ this._rotationScaleTexture = null;
403
+ this._rotationDataA = null;
404
+ this._rotationDataB = null;
405
+ this._rotationScaleData = null;
406
+ this._needsRotationScaleTextures = false;
334
407
  this._splatPositions = null;
335
408
  this._splatIndex = null;
336
409
  this._shTextures = null;
@@ -352,6 +425,7 @@ export class GaussianSplattingMeshBase extends Mesh {
352
425
  this._cachedBoundingMax = null;
353
426
  /** @internal */
354
427
  this._shDegree = 0;
428
+ this._maxShDegree = 0;
355
429
  this._cameraViewInfos = new Map();
356
430
  /**
357
431
  * Cosine value of the angle threshold to update view dependent splat sorting. Default is 0.0001.
@@ -775,8 +849,62 @@ export class GaussianSplattingMeshBase extends Mesh {
775
849
  return 83 /* PLYValue.SH_43 */;
776
850
  case "f_rest_44":
777
851
  return 84 /* PLYValue.SH_44 */;
778
- }
779
- return 85 /* PLYValue.UNDEFINED */;
852
+ case "f_rest_45":
853
+ return 85 /* PLYValue.SH_45 */;
854
+ case "f_rest_46":
855
+ return 86 /* PLYValue.SH_46 */;
856
+ case "f_rest_47":
857
+ return 87 /* PLYValue.SH_47 */;
858
+ case "f_rest_48":
859
+ return 88 /* PLYValue.SH_48 */;
860
+ case "f_rest_49":
861
+ return 89 /* PLYValue.SH_49 */;
862
+ case "f_rest_50":
863
+ return 90 /* PLYValue.SH_50 */;
864
+ case "f_rest_51":
865
+ return 91 /* PLYValue.SH_51 */;
866
+ case "f_rest_52":
867
+ return 92 /* PLYValue.SH_52 */;
868
+ case "f_rest_53":
869
+ return 93 /* PLYValue.SH_53 */;
870
+ case "f_rest_54":
871
+ return 94 /* PLYValue.SH_54 */;
872
+ case "f_rest_55":
873
+ return 95 /* PLYValue.SH_55 */;
874
+ case "f_rest_56":
875
+ return 96 /* PLYValue.SH_56 */;
876
+ case "f_rest_57":
877
+ return 97 /* PLYValue.SH_57 */;
878
+ case "f_rest_58":
879
+ return 98 /* PLYValue.SH_58 */;
880
+ case "f_rest_59":
881
+ return 99 /* PLYValue.SH_59 */;
882
+ case "f_rest_60":
883
+ return 100 /* PLYValue.SH_60 */;
884
+ case "f_rest_61":
885
+ return 101 /* PLYValue.SH_61 */;
886
+ case "f_rest_62":
887
+ return 102 /* PLYValue.SH_62 */;
888
+ case "f_rest_63":
889
+ return 103 /* PLYValue.SH_63 */;
890
+ case "f_rest_64":
891
+ return 104 /* PLYValue.SH_64 */;
892
+ case "f_rest_65":
893
+ return 105 /* PLYValue.SH_65 */;
894
+ case "f_rest_66":
895
+ return 106 /* PLYValue.SH_66 */;
896
+ case "f_rest_67":
897
+ return 107 /* PLYValue.SH_67 */;
898
+ case "f_rest_68":
899
+ return 108 /* PLYValue.SH_68 */;
900
+ case "f_rest_69":
901
+ return 109 /* PLYValue.SH_69 */;
902
+ case "f_rest_70":
903
+ return 110 /* PLYValue.SH_70 */;
904
+ case "f_rest_71":
905
+ return 111 /* PLYValue.SH_71 */;
906
+ }
907
+ return 112 /* PLYValue.UNDEFINED */;
780
908
  }
781
909
  /**
782
910
  * Parse a PLY file header and returns metas infos on splats and chunks
@@ -826,12 +954,15 @@ export class GaussianSplattingMeshBase extends Mesh {
826
954
  if (prop.startsWith("property ")) {
827
955
  const [, typeName, name] = prop.split(" ");
828
956
  const value = GaussianSplattingMeshBase._ValueNameToEnum(name);
829
- if (value != 85 /* PLYValue.UNDEFINED */) {
830
- // SH degree 1,2 or 3 for 9, 24 or 45 values
831
- if (value >= 84 /* PLYValue.SH_44 */) {
832
- shDegree = 3;
957
+ if (value != 112 /* PLYValue.UNDEFINED */) {
958
+ // SH degree 1,2,3 or 4 for 9, 24, 45 or 72 values
959
+ if (value >= 111 /* PLYValue.SH_71 */) {
960
+ shDegree = 4;
961
+ }
962
+ else if (value >= 84 /* PLYValue.SH_44 */) {
963
+ shDegree = Math.max(shDegree, 3);
833
964
  }
834
- else if (value >= 64 /* PLYValue.SH_24 */) {
965
+ else if (value >= 63 /* PLYValue.SH_23 */) {
835
966
  shDegree = Math.max(shDegree, 2);
836
967
  }
837
968
  else if (value >= 48 /* PLYValue.SH_8 */) {
@@ -1115,7 +1246,7 @@ export class GaussianSplattingMeshBase extends Mesh {
1115
1246
  r3 = value;
1116
1247
  break;
1117
1248
  }
1118
- if (sh && property.value >= 40 /* PLYValue.SH_0 */ && property.value <= 84 /* PLYValue.SH_44 */) {
1249
+ if (sh && property.value >= 40 /* PLYValue.SH_0 */ && property.value <= 111 /* PLYValue.SH_71 */) {
1119
1250
  const shIndex = property.value - 40 /* PLYValue.SH_0 */;
1120
1251
  if (property.type == 4 /* PLYType.UCHAR */ && header.chunkCount) {
1121
1252
  // compressed ply. dataView points to beginning of vertex
@@ -1131,7 +1262,7 @@ export class GaussianSplattingMeshBase extends Mesh {
1131
1262
  }
1132
1263
  }
1133
1264
  if (sh) {
1134
- const shDim = header.shDegree == 1 ? 3 : header.shDegree == 2 ? 8 : 15;
1265
+ const shDim = header.shDegree == 1 ? 3 : header.shDegree == 2 ? 8 : header.shDegree == 3 ? 15 : 24;
1135
1266
  for (let j = 0; j < shDim; j++) {
1136
1267
  sh[j * 3 + 0] = plySH[j];
1137
1268
  sh[j * 3 + 1] = plySH[j + shDim];
@@ -1196,7 +1327,7 @@ export class GaussianSplattingMeshBase extends Mesh {
1196
1327
  }
1197
1328
  }
1198
1329
  }
1199
- return { buffer: header.buffer, sh: sh };
1330
+ return { buffer: header.buffer, sh: sh, shDegree: header.shDegree };
1200
1331
  }
1201
1332
  /**
1202
1333
  * Converts a .ply data array buffer to splat
@@ -1270,6 +1401,15 @@ export class GaussianSplattingMeshBase extends Mesh {
1270
1401
  shTexture.dispose();
1271
1402
  }
1272
1403
  }
1404
+ this._rotationsATexture?.dispose();
1405
+ this._rotationsBTexture?.dispose();
1406
+ this._rotationScaleTexture?.dispose();
1407
+ this._rotationsATexture = null;
1408
+ this._rotationsBTexture = null;
1409
+ this._rotationScaleTexture = null;
1410
+ this._rotationDataA = null;
1411
+ this._rotationDataB = null;
1412
+ this._rotationScaleData = null;
1273
1413
  this._covariancesATexture = null;
1274
1414
  this._covariancesBTexture = null;
1275
1415
  this._centersTexture = null;
@@ -1299,6 +1439,11 @@ export class GaussianSplattingMeshBase extends Mesh {
1299
1439
  this._shTextures?.push(shTexture.clone());
1300
1440
  }
1301
1441
  }
1442
+ if (source._rotationsATexture) {
1443
+ this._rotationsATexture = source._rotationsATexture.clone();
1444
+ this._rotationsBTexture = source._rotationsBTexture?.clone();
1445
+ this._rotationScaleTexture = source._rotationScaleTexture?.clone();
1446
+ }
1302
1447
  }
1303
1448
  /**
1304
1449
  * Returns a new Mesh object generated from the current mesh properties.
@@ -1367,6 +1512,30 @@ export class GaussianSplattingMeshBase extends Mesh {
1367
1512
  quaternion.normalize();
1368
1513
  quaternion.toRotationMatrix(matrixRotation);
1369
1514
  Matrix.ScalingToRef(fBuffer[8 * srcIndex + 3 + 0] * 2, fBuffer[8 * srcIndex + 3 + 1] * 2, fBuffer[8 * srcIndex + 3 + 2] * 2, matrixScale);
1515
+ if (this._needsRotationScaleTextures) {
1516
+ if (!this._rotationDataA || this._rotationDataA.length < covA.length) {
1517
+ this._rotationDataA = new Uint16Array(covA.length);
1518
+ this._rotationDataB = new Uint16Array(covA.length);
1519
+ this._rotationScaleData = new Uint16Array(covA.length);
1520
+ }
1521
+ const rotDataA = this._rotationDataA;
1522
+ const rotDataB = this._rotationDataB;
1523
+ const rotScaleData = this._rotationScaleData;
1524
+ const rm = matrixRotation.m;
1525
+ const sm = matrixScale.m;
1526
+ rotDataA[dstIndex * 4 + 0] = ToHalfFloat(rm[0]);
1527
+ rotDataA[dstIndex * 4 + 1] = ToHalfFloat(rm[1]);
1528
+ rotDataA[dstIndex * 4 + 2] = ToHalfFloat(rm[2]);
1529
+ rotDataA[dstIndex * 4 + 3] = ToHalfFloat(rm[4]);
1530
+ rotDataB[dstIndex * 4 + 0] = ToHalfFloat(rm[5]);
1531
+ rotDataB[dstIndex * 4 + 1] = ToHalfFloat(rm[6]);
1532
+ rotDataB[dstIndex * 4 + 2] = ToHalfFloat(rm[8]);
1533
+ rotDataB[dstIndex * 4 + 3] = ToHalfFloat(rm[9]);
1534
+ rotScaleData[dstIndex * 4 + 0] = ToHalfFloat(rm[10]);
1535
+ rotScaleData[dstIndex * 4 + 1] = ToHalfFloat(sm[0]);
1536
+ rotScaleData[dstIndex * 4 + 2] = ToHalfFloat(sm[5]);
1537
+ rotScaleData[dstIndex * 4 + 3] = ToHalfFloat(sm[10]);
1538
+ }
1370
1539
  const m = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;
1371
1540
  const covariances = this._tmpCovariances;
1372
1541
  covariances[0] = m[0] * m[0] + m[1] * m[1] + m[2] * m[2];
@@ -1459,6 +1628,25 @@ export class GaussianSplattingMeshBase extends Mesh {
1459
1628
  this._shTextures.push(shTexture);
1460
1629
  }
1461
1630
  }
1631
+ if (this._needsRotationScaleTextures && this._rotationDataA) {
1632
+ if (this._rotationsATexture) {
1633
+ this._updateTextureFromData(this._rotationsATexture, this._rotationDataA, textureSize.x, 0, textureSize.y);
1634
+ this._updateTextureFromData(this._rotationsBTexture, this._rotationDataB, textureSize.x, 0, textureSize.y);
1635
+ this._updateTextureFromData(this._rotationScaleTexture, this._rotationScaleData, textureSize.x, 0, textureSize.y);
1636
+ }
1637
+ else {
1638
+ // Rotation textures not yet created (needsRotationScaleTextures was enabled after initial load).
1639
+ this._rotationsATexture = createTextureFromDataF16(this._rotationDataA, textureSize.x, textureSize.y, 5);
1640
+ this._rotationsBTexture = createTextureFromDataF16(this._rotationDataB, textureSize.x, textureSize.y, 5);
1641
+ this._rotationScaleTexture = createTextureFromDataF16(this._rotationScaleData, textureSize.x, textureSize.y, 5);
1642
+ this._rotationsATexture.wrapU = 0;
1643
+ this._rotationsATexture.wrapV = 0;
1644
+ this._rotationsBTexture.wrapU = 0;
1645
+ this._rotationsBTexture.wrapV = 0;
1646
+ this._rotationScaleTexture.wrapU = 0;
1647
+ this._rotationScaleTexture.wrapV = 0;
1648
+ }
1649
+ }
1462
1650
  this._onUpdateTextures(textureSize);
1463
1651
  this._postToWorker(true);
1464
1652
  }
@@ -1478,6 +1666,23 @@ export class GaussianSplattingMeshBase extends Mesh {
1478
1666
  this._shTextures.push(shTexture);
1479
1667
  }
1480
1668
  }
1669
+ if (this._needsRotationScaleTextures) {
1670
+ const rotDataA = this._rotationDataA ?? new Uint16Array(covA.length);
1671
+ const rotDataB = this._rotationDataB ?? new Uint16Array(covA.length);
1672
+ const rotScaleData = this._rotationScaleData ?? new Uint16Array(covA.length);
1673
+ this._rotationsATexture?.dispose();
1674
+ this._rotationsBTexture?.dispose();
1675
+ this._rotationScaleTexture?.dispose();
1676
+ this._rotationsATexture = createTextureFromDataF16(rotDataA, textureSize.x, textureSize.y, 5);
1677
+ this._rotationsBTexture = createTextureFromDataF16(rotDataB, textureSize.x, textureSize.y, 5);
1678
+ this._rotationScaleTexture = createTextureFromDataF16(rotScaleData, textureSize.x, textureSize.y, 5);
1679
+ this._rotationsATexture.wrapU = 0;
1680
+ this._rotationsATexture.wrapV = 0;
1681
+ this._rotationsBTexture.wrapU = 0;
1682
+ this._rotationsBTexture.wrapV = 0;
1683
+ this._rotationScaleTexture.wrapU = 0;
1684
+ this._rotationScaleTexture.wrapV = 0;
1685
+ }
1481
1686
  this._onUpdateTextures(textureSize);
1482
1687
  if (firstTime) {
1483
1688
  this._instantiateWorker();
@@ -1527,7 +1732,7 @@ export class GaussianSplattingMeshBase extends Mesh {
1527
1732
  }
1528
1733
  this._sortIsDirty = true;
1529
1734
  }
1530
- *_updateData(data, isAsync, sh, partIndices, { flipY = false, previousVertexCount = 0 } = {}) {
1735
+ *_updateData(data, isAsync, sh, partIndices, { flipY = false, previousVertexCount = 0 } = {}, shDegree) {
1531
1736
  if (!this._covariancesATexture) {
1532
1737
  this._readyToDisplay = false;
1533
1738
  }
@@ -1551,8 +1756,8 @@ export class GaussianSplattingMeshBase extends Mesh {
1551
1756
  this._updateSplatIndexBuffer(vertexCount);
1552
1757
  }
1553
1758
  this._vertexCount = vertexCount;
1554
- // degree == 1 for 1 texture (3 terms), 2 for 2 textures (8 terms) and 3 for 3 textures (15 terms)
1555
- this._shDegree = sh ? sh.length : 0;
1759
+ this._maxShDegree = sh ? (shDegree ?? 0) : 0;
1760
+ this._shDegree = this._maxShDegree;
1556
1761
  const textureSize = this._getTextureSize(vertexCount);
1557
1762
  const textureLength = textureSize.x * textureSize.y;
1558
1763
  const lineCountUpdate = GaussianSplattingMeshBase.ProgressiveUpdateAmount ?? textureSize.y;
@@ -1657,10 +1862,11 @@ export class GaussianSplattingMeshBase extends Mesh {
1657
1862
  * @param data array buffer containing center, color, orientation and scale of splats
1658
1863
  * @param sh optional array of uint8 array for SH data
1659
1864
  * @param partIndices optional array of uint8 for rig node indices
1865
+ * @param shDegree optional SH degree of the data
1660
1866
  * @returns a promise
1661
1867
  */
1662
- async updateDataAsync(data, sh, partIndices) {
1663
- return await runCoroutineAsync(this._updateData(data, true, sh, partIndices), createYieldingScheduler());
1868
+ async updateDataAsync(data, sh, partIndices, shDegree) {
1869
+ return await runCoroutineAsync(this._updateData(data, true, sh, partIndices, undefined, shDegree), createYieldingScheduler());
1664
1870
  }
1665
1871
  /**
1666
1872
  * @experimental
@@ -1669,9 +1875,10 @@ export class GaussianSplattingMeshBase extends Mesh {
1669
1875
  * @param sh optional array of uint8 array for SH data
1670
1876
  * @param options optional informations on how to treat data (needs to be 3rd for backward compatibility)
1671
1877
  * @param partIndices optional array of uint8 for rig node indices
1878
+ * @param shDegree optional SH degree of the data
1672
1879
  */
1673
- updateData(data, sh, options = { flipY: true }, partIndices) {
1674
- runCoroutineSync(this._updateData(data, false, sh, partIndices, options));
1880
+ updateData(data, sh, options = { flipY: true }, partIndices, shDegree) {
1881
+ runCoroutineSync(this._updateData(data, false, sh, partIndices, options, shDegree));
1675
1882
  }
1676
1883
  /**
1677
1884
  * Refreshes the bounding info, taking into account all the thin instances defined
@@ -1713,6 +1920,14 @@ export class GaussianSplattingMeshBase extends Mesh {
1713
1920
  this._updateTextureFromData(this._covariancesBTexture, covBView, textureSize.x, lineStart, lineCount);
1714
1921
  this._updateTextureFromData(this._centersTexture, centersView, textureSize.x, lineStart, lineCount);
1715
1922
  this._updateTextureFromData(this._colorsTexture, colorsView, textureSize.x, lineStart, lineCount);
1923
+ if (this._rotationsATexture && this._rotationDataA) {
1924
+ const rotAView = new Uint16Array(this._rotationDataA.buffer, texelStart * 4 * Uint16Array.BYTES_PER_ELEMENT, texelCount * 4);
1925
+ const rotBView = new Uint16Array(this._rotationDataB.buffer, texelStart * 4 * Uint16Array.BYTES_PER_ELEMENT, texelCount * 4);
1926
+ const rotScaleView = new Uint16Array(this._rotationScaleData.buffer, texelStart * 4 * Uint16Array.BYTES_PER_ELEMENT, texelCount * 4);
1927
+ this._updateTextureFromData(this._rotationsATexture, rotAView, textureSize.x, lineStart, lineCount);
1928
+ this._updateTextureFromData(this._rotationsBTexture, rotBView, textureSize.x, lineStart, lineCount);
1929
+ this._updateTextureFromData(this._rotationScaleTexture, rotScaleView, textureSize.x, lineStart, lineCount);
1930
+ }
1716
1931
  if (sh) {
1717
1932
  for (let i = 0; i < sh.length; i++) {
1718
1933
  const componentCount = 4;