@babylonjs/loaders 7.27.3 → 7.29.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,10 +4,11 @@ import { GaussianSplattingMesh } from "@babylonjs/core/Meshes/GaussianSplatting/
4
4
  import { AssetContainer } from "@babylonjs/core/assetContainer.js";
5
5
  import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
6
6
  import { Logger } from "@babylonjs/core/Misc/logger.js";
7
- import { Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
7
+ import { Quaternion, TmpVectors, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
8
8
  import { PointsCloudSystem } from "@babylonjs/core/Particles/pointsCloudSystem.js";
9
9
  import { Color4 } from "@babylonjs/core/Maths/math.color.js";
10
10
  import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
11
+ import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
11
12
  /**
12
13
  * Indicator of the parsed ply buffer. A standard ready to use splat or an array of positions for a point cloud
13
14
  */
@@ -17,6 +18,12 @@ var Mode;
17
18
  Mode[Mode["PointCloud"] = 1] = "PointCloud";
18
19
  Mode[Mode["Mesh"] = 2] = "Mesh";
19
20
  })(Mode || (Mode = {}));
21
+ /** @internal */
22
+ var ElementMode;
23
+ (function (ElementMode) {
24
+ ElementMode[ElementMode["Vertex"] = 0] = "Vertex";
25
+ ElementMode[ElementMode["Chunk"] = 1] = "Chunk";
26
+ })(ElementMode || (ElementMode = {}));
20
27
  /**
21
28
  * @experimental
22
29
  * SPLAT file type loader.
@@ -216,11 +223,17 @@ export class SPLATFileLoader {
216
223
  }
217
224
  const vertexCount = parseInt(/element vertex (\d+)\n/.exec(header)[1]);
218
225
  const faceElement = /element face (\d+)\n/.exec(header);
226
+ const chunkElement = /element chunk (\d+)\n/.exec(header);
219
227
  let faceCount = 0;
228
+ let chunkCount = 0;
220
229
  if (faceElement) {
221
230
  faceCount = parseInt(faceElement[1]);
222
231
  }
223
- let rowOffset = 0;
232
+ if (chunkElement) {
233
+ chunkCount = parseInt(chunkElement[1]);
234
+ }
235
+ let rowVertexOffset = 0;
236
+ let rowChunkOffset = 0;
224
237
  const offsets = {
225
238
  double: 8,
226
239
  int: 4,
@@ -231,59 +244,201 @@ export class SPLATFileLoader {
231
244
  uchar: 1,
232
245
  list: 0,
233
246
  };
234
- const properties = [];
235
- const filtered = header
236
- .slice(0, headerEndIndex)
237
- .split("\n")
238
- .filter((k) => k.startsWith("property "));
247
+ let chunkMode = 1 /* ElementMode.Chunk */;
248
+ const vertexProperties = [];
249
+ const chunkProperties = [];
250
+ const filtered = header.slice(0, headerEndIndex).split("\n");
239
251
  for (const prop of filtered) {
240
- const [, type, name] = prop.split(" ");
241
- properties.push({ name, type, offset: rowOffset });
242
- if (offsets[type]) {
243
- rowOffset += offsets[type];
252
+ if (prop.startsWith("property ")) {
253
+ const [, type, name] = prop.split(" ");
254
+ if (chunkMode == 1 /* ElementMode.Chunk */) {
255
+ chunkProperties.push({ name, type, offset: rowChunkOffset });
256
+ rowChunkOffset += offsets[type];
257
+ }
258
+ else if (chunkMode == 0 /* ElementMode.Vertex */) {
259
+ vertexProperties.push({ name, type, offset: rowVertexOffset });
260
+ rowVertexOffset += offsets[type];
261
+ }
262
+ if (!offsets[type]) {
263
+ Logger.Warn(`Unsupported property type: ${type}.`);
264
+ }
244
265
  }
245
- else {
246
- Logger.Warn(`Unsupported property type: ${type}.`);
266
+ else if (prop.startsWith("element ")) {
267
+ const [, type] = prop.split(" ");
268
+ if (type == "chunk") {
269
+ chunkMode = 1 /* ElementMode.Chunk */;
270
+ }
271
+ else if (type == "vertex") {
272
+ chunkMode = 0 /* ElementMode.Vertex */;
273
+ }
247
274
  }
248
275
  }
249
- const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
276
+ const rowVertexLength = rowVertexOffset;
277
+ const rowChunkLength = rowChunkOffset;
278
+ const rowOutputLength = 3 * 4 + 3 * 4 + 4 + 4; // Vector3 position, Vector3 scale, 1 u8 quaternion, 1 color with alpha
250
279
  const SH_C0 = 0.28209479177387814;
280
+ let offset = 0;
251
281
  const dataView = new DataView(data, headerEndIndex + headerEnd.length);
252
- const buffer = new ArrayBuffer(rowLength * vertexCount);
282
+ const buffer = new ArrayBuffer(rowOutputLength * vertexCount);
253
283
  const q = new Quaternion();
284
+ const temp3 = TmpVectors.Vector3[0];
285
+ const unpackUnorm = (value, bits) => {
286
+ const t = (1 << bits) - 1;
287
+ return (value & t) / t;
288
+ };
289
+ const unpack111011 = (value, result) => {
290
+ result.x = unpackUnorm(value >>> 21, 11);
291
+ result.y = unpackUnorm(value >>> 11, 10);
292
+ result.z = unpackUnorm(value, 11);
293
+ };
294
+ const unpack8888 = (value, result) => {
295
+ result[0] = unpackUnorm(value >>> 24, 8) * 255;
296
+ result[1] = unpackUnorm(value >>> 16, 8) * 255;
297
+ result[2] = unpackUnorm(value >>> 8, 8) * 255;
298
+ result[3] = unpackUnorm(value, 8) * 255;
299
+ };
300
+ // unpack quaternion with 2,10,10,10 format (largest element, 3x10bit element)
301
+ const unpackRot = (value, result) => {
302
+ const norm = 1.0 / (Math.sqrt(2) * 0.5);
303
+ const a = (unpackUnorm(value >>> 20, 10) - 0.5) * norm;
304
+ const b = (unpackUnorm(value >>> 10, 10) - 0.5) * norm;
305
+ const c = (unpackUnorm(value, 10) - 0.5) * norm;
306
+ const m = Math.sqrt(1.0 - (a * a + b * b + c * c));
307
+ switch (value >>> 30) {
308
+ case 0:
309
+ result.set(m, a, b, c);
310
+ break;
311
+ case 1:
312
+ result.set(a, m, b, c);
313
+ break;
314
+ case 2:
315
+ result.set(a, b, m, c);
316
+ break;
317
+ case 3:
318
+ result.set(a, b, c, m);
319
+ break;
320
+ }
321
+ };
322
+ const compressedChunks = new Array(chunkCount);
323
+ for (let i = 0; i < chunkCount; i++) {
324
+ const currentChunk = { min: new Vector3(), max: new Vector3(), minScale: new Vector3(), maxScale: new Vector3() };
325
+ compressedChunks[i] = currentChunk;
326
+ for (let propertyIndex = 0; propertyIndex < chunkProperties.length; propertyIndex++) {
327
+ const property = chunkProperties[propertyIndex];
328
+ let value;
329
+ switch (property.type) {
330
+ case "float":
331
+ value = dataView.getFloat32(property.offset + offset, true);
332
+ break;
333
+ default:
334
+ //throw new Error(`Unsupported property type: ${property.type}`);
335
+ continue;
336
+ }
337
+ switch (property.name) {
338
+ case "min_x":
339
+ currentChunk.min.x = value;
340
+ break;
341
+ case "min_y":
342
+ currentChunk.min.y = value;
343
+ break;
344
+ case "min_z":
345
+ currentChunk.min.z = value;
346
+ break;
347
+ case "max_x":
348
+ currentChunk.max.x = value;
349
+ break;
350
+ case "max_y":
351
+ currentChunk.max.y = value;
352
+ break;
353
+ case "max_z":
354
+ currentChunk.max.z = value;
355
+ break;
356
+ case "min_scale_x":
357
+ currentChunk.minScale.x = value;
358
+ break;
359
+ case "min_scale_y":
360
+ currentChunk.minScale.y = value;
361
+ break;
362
+ case "min_scale_z":
363
+ currentChunk.minScale.z = value;
364
+ break;
365
+ case "max_scale_x":
366
+ currentChunk.maxScale.x = value;
367
+ break;
368
+ case "max_scale_y":
369
+ currentChunk.maxScale.y = value;
370
+ break;
371
+ case "max_scale_z":
372
+ currentChunk.maxScale.z = value;
373
+ break;
374
+ }
375
+ }
376
+ offset += rowChunkLength;
377
+ }
254
378
  for (let i = 0; i < vertexCount; i++) {
255
- const position = new Float32Array(buffer, i * rowLength, 3);
256
- const scale = new Float32Array(buffer, i * rowLength + 12, 3);
257
- const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);
258
- const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);
379
+ const position = new Float32Array(buffer, i * rowOutputLength, 3);
380
+ const scale = new Float32Array(buffer, i * rowOutputLength + 12, 3);
381
+ const rgba = new Uint8ClampedArray(buffer, i * rowOutputLength + 24, 4);
382
+ const rot = new Uint8ClampedArray(buffer, i * rowOutputLength + 28, 4);
383
+ const chunkIndex = i >> 8;
259
384
  let r0 = 255;
260
385
  let r1 = 0;
261
386
  let r2 = 0;
262
387
  let r3 = 0;
263
- for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {
264
- const property = properties[propertyIndex];
388
+ for (let propertyIndex = 0; propertyIndex < vertexProperties.length; propertyIndex++) {
389
+ const property = vertexProperties[propertyIndex];
265
390
  let value;
266
391
  switch (property.type) {
267
392
  case "float":
268
- value = dataView.getFloat32(property.offset + i * rowOffset, true);
393
+ value = dataView.getFloat32(offset + property.offset, true);
269
394
  break;
270
395
  case "int":
271
- value = dataView.getInt32(property.offset + i * rowOffset, true);
396
+ value = dataView.getInt32(offset + property.offset, true);
272
397
  break;
273
398
  case "uint":
274
- value = dataView.getUint32(property.offset + i * rowOffset, true);
399
+ value = dataView.getUint32(offset + property.offset, true);
275
400
  break;
276
401
  case "double":
277
- value = dataView.getFloat64(property.offset + i * rowOffset, true);
402
+ value = dataView.getFloat64(offset + property.offset, true);
278
403
  break;
279
404
  case "uchar":
280
- value = dataView.getUint8(property.offset + i * rowOffset);
405
+ value = dataView.getUint8(offset + property.offset);
281
406
  break;
282
407
  default:
283
408
  //throw new Error(`Unsupported property type: ${property.type}`);
284
409
  continue;
285
410
  }
286
411
  switch (property.name) {
412
+ case "packed_position":
413
+ {
414
+ const compressedChunk = compressedChunks[chunkIndex];
415
+ unpack111011(value, temp3);
416
+ position[0] = Scalar.Lerp(compressedChunk.min.x, compressedChunk.max.x, temp3.x);
417
+ position[1] = -Scalar.Lerp(compressedChunk.min.y, compressedChunk.max.y, temp3.y);
418
+ position[2] = Scalar.Lerp(compressedChunk.min.z, compressedChunk.max.z, temp3.z);
419
+ }
420
+ break;
421
+ case "packed_rotation":
422
+ {
423
+ unpackRot(value, q);
424
+ r0 = q.w;
425
+ r1 = q.z;
426
+ r2 = q.y;
427
+ r3 = q.x;
428
+ }
429
+ break;
430
+ case "packed_scale":
431
+ {
432
+ const compressedChunk = compressedChunks[chunkIndex];
433
+ unpack111011(value, temp3);
434
+ scale[0] = Math.exp(Scalar.Lerp(compressedChunk.minScale.x, compressedChunk.maxScale.x, temp3.x));
435
+ scale[1] = Math.exp(Scalar.Lerp(compressedChunk.minScale.y, compressedChunk.maxScale.y, temp3.y));
436
+ scale[2] = Math.exp(Scalar.Lerp(compressedChunk.minScale.z, compressedChunk.maxScale.z, temp3.z));
437
+ }
438
+ break;
439
+ case "packed_color":
440
+ unpack8888(value, rgba);
441
+ break;
287
442
  case "x":
288
443
  position[0] = value;
289
444
  break;
@@ -349,11 +504,11 @@ export class SPLATFileLoader {
349
504
  rot[1] = q.x * 128 + 128;
350
505
  rot[2] = q.y * 128 + 128;
351
506
  rot[3] = q.z * 128 + 128;
507
+ offset += rowVertexLength;
352
508
  }
353
509
  // faces
354
510
  const faces = [];
355
511
  if (faceCount) {
356
- let offset = rowOffset * vertexCount;
357
512
  for (let i = 0; i < faceCount; i++) {
358
513
  const faceVertexCount = dataView.getUint8(offset);
359
514
  if (faceVertexCount != 3) {
@@ -367,14 +522,18 @@ export class SPLATFileLoader {
367
522
  offset += 12;
368
523
  }
369
524
  }
525
+ // early exit for chunked/quantized ply
526
+ if (chunkCount) {
527
+ return { mode: 0 /* Mode.Splat */, data: buffer, faces: faces, hasVertexColors: false };
528
+ }
370
529
  // count available properties. if all necessary are present then it's a splat. Otherwise, it's a point cloud
371
530
  // if faces are found, then it's a standard mesh
372
531
  let propertyCount = 0;
373
532
  let propertyColorCount = 0;
374
533
  const splatProperties = ["x", "y", "z", "scale_0", "scale_1", "scale_2", "opacity", "rot_0", "rot_1", "rot_2", "rot_3"];
375
534
  const splatColorProperties = ["red", "green", "blue", "f_dc_0", "f_dc_1", "f_dc_2"];
376
- for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {
377
- const property = properties[propertyIndex];
535
+ for (let propertyIndex = 0; propertyIndex < vertexProperties.length; propertyIndex++) {
536
+ const property = vertexProperties[propertyIndex];
378
537
  if (splatProperties.includes(property.name)) {
379
538
  propertyCount++;
380
539
  }
@@ -1 +1 @@
1
- {"version":3,"file":"splatFileLoader.js","sourceRoot":"","sources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C,CAAC,sBAAsB,CAAC,CAAC,oBAAY,CAAC,wBAAgB,CAAC;QAClG,2CAA2C;QAC3C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACpG,CAAC;;AArYuB,sCAAsB,GAAG;IAC7C,SAAS,EAAE,KAAK;CACoB,AAFM,CAEL;AAsY7C,2CAA2C;AAC3C,yBAAyB,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC","sourcesContent":["import type { ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderAsyncResult, ISceneLoaderProgressEvent, SceneLoaderPluginOptions } from \"core/Loading/sceneLoader\";\r\nimport { registerSceneLoaderPlugin } from \"core/Loading/sceneLoader\";\r\nimport { SPLATFileLoaderMetadata } from \"./splatFileLoader.metadata\";\r\nimport { GaussianSplattingMesh } from \"core/Meshes/GaussianSplatting/gaussianSplattingMesh\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport { PointsCloudSystem } from \"core/Particles/pointsCloudSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { SPLATLoadingOptions } from \"./splatLoadingOptions\";\r\n\r\ndeclare module \"core/Loading/sceneLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface SceneLoaderPluginOptions {\r\n /**\r\n * Defines options for the splat loader.\r\n */\r\n [SPLATFileLoaderMetadata.name]: Partial<SPLATLoadingOptions>;\r\n }\r\n}\r\n\r\n/**\r\n * Indicator of the parsed ply buffer. A standard ready to use splat or an array of positions for a point cloud\r\n */\r\nconst enum Mode {\r\n Splat = 0,\r\n PointCloud = 1,\r\n Mesh = 2,\r\n}\r\n\r\n/**\r\n * A parsed buffer and how to use it\r\n */\r\ninterface ParsedPLY {\r\n data: ArrayBuffer;\r\n mode: Mode;\r\n faces?: number[];\r\n hasVertexColors?: boolean;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * SPLAT file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class SPLATFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public readonly name = SPLATFileLoaderMetadata.name;\r\n\r\n private _assetContainer: Nullable<AssetContainer> = null;\r\n\r\n private readonly _loadingOptions: Readonly<SPLATLoadingOptions>;\r\n /**\r\n * Defines the extensions the splat loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n */\r\n public readonly extensions = SPLATFileLoaderMetadata.extensions;\r\n\r\n /**\r\n * Creates loader for gaussian splatting files\r\n * @param loadingOptions options for loading and parsing splat and PLY files.\r\n */\r\n constructor(loadingOptions: Partial<Readonly<SPLATLoadingOptions>> = SPLATFileLoader._DefaultLoadingOptions) {\r\n this._loadingOptions = loadingOptions;\r\n }\r\n\r\n private static readonly _DefaultLoadingOptions = {\r\n keepInRam: false,\r\n } as const satisfies SPLATLoadingOptions;\r\n\r\n /** @internal */\r\n createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync {\r\n return new SPLATFileLoader(options[SPLATFileLoaderMetadata.name]);\r\n }\r\n\r\n /**\r\n * Imports from the loaded gaussian splatting data and adds them to the scene\r\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\r\n * @param scene the scene the meshes should be added to\r\n * @param data the gaussian splatting data to load\r\n * @param rootUrl root url to load from\r\n * @param onProgress callback called while file is loading\r\n * @param fileName Defines the name of the file to load\r\n * @returns a promise containing the loaded meshes, particles, skeletons and animations\r\n */\r\n public async importMeshAsync(\r\n meshesNames: any,\r\n scene: Scene,\r\n data: any,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ): Promise<ISceneLoaderAsyncResult> {\r\n return this._parse(meshesNames, scene, data, rootUrl).then((meshes) => {\r\n return {\r\n meshes: meshes,\r\n particleSystems: [],\r\n skeletons: [],\r\n animationGroups: [],\r\n transformNodes: [],\r\n geometries: [],\r\n lights: [],\r\n spriteManagers: [],\r\n };\r\n });\r\n }\r\n\r\n private static _BuildPointCloud(pointcloud: PointsCloudSystem, data: ArrayBuffer): boolean {\r\n if (!data.byteLength) {\r\n return false;\r\n }\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(data);\r\n\r\n // parsed array contains room for position(3floats), normal(3floats), color (4b), quantized quaternion (4b)\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n const pointcloudfunc = function (particle: any, i: number) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n particle.position = new Vector3(x, y, z);\r\n\r\n const r = uBuffer[rowLength * i + 24 + 0] / 255;\r\n const g = uBuffer[rowLength * i + 24 + 1] / 255;\r\n const b = uBuffer[rowLength * i + 24 + 2] / 255;\r\n particle.color = new Color4(r, g, b, 1);\r\n };\r\n\r\n pointcloud.addPoints(vertexCount, pointcloudfunc);\r\n return true;\r\n }\r\n\r\n private static _BuildMesh(scene: Scene, parsedPLY: ParsedPLY): Mesh {\r\n const mesh = new Mesh(\"PLYMesh\", scene);\r\n\r\n const uBuffer = new Uint8Array(parsedPLY.data);\r\n const fBuffer = new Float32Array(parsedPLY.data);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n const positions = [];\r\n\r\n const vertexData = new VertexData();\r\n for (let i = 0; i < vertexCount; i++) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n positions.push(x, y, z);\r\n }\r\n\r\n if (parsedPLY.hasVertexColors) {\r\n const colors = new Float32Array(vertexCount * 4);\r\n for (let i = 0; i < vertexCount; i++) {\r\n const r = uBuffer[rowLength * i + 24 + 0] / 255;\r\n const g = uBuffer[rowLength * i + 24 + 1] / 255;\r\n const b = uBuffer[rowLength * i + 24 + 2] / 255;\r\n colors[i * 4 + 0] = r;\r\n colors[i * 4 + 1] = g;\r\n colors[i * 4 + 2] = b;\r\n colors[i * 4 + 3] = 1;\r\n }\r\n vertexData.colors = colors;\r\n }\r\n\r\n vertexData.positions = positions;\r\n vertexData.indices = parsedPLY.faces!;\r\n\r\n vertexData.applyToMesh(mesh);\r\n return mesh;\r\n }\r\n\r\n private _parse(meshesNames: any, scene: Scene, data: any, rootUrl: string): Promise<Array<AbstractMesh>> {\r\n const babylonMeshesArray: Array<Mesh> = []; //The mesh for babylon\r\n const parsedPLY = SPLATFileLoader._ConvertPLYToSplat(data as ArrayBuffer);\r\n switch (parsedPLY.mode) {\r\n case Mode.Splat:\r\n {\r\n const gaussianSplatting = new GaussianSplattingMesh(\"GaussianSplatting\", null, scene, this._loadingOptions.keepInRam);\r\n gaussianSplatting._parentContainer = this._assetContainer;\r\n babylonMeshesArray.push(gaussianSplatting);\r\n gaussianSplatting.loadDataAsync(parsedPLY.data);\r\n }\r\n break;\r\n case Mode.PointCloud:\r\n {\r\n const pointcloud = new PointsCloudSystem(\"PointCloud\", 1, scene);\r\n if (SPLATFileLoader._BuildPointCloud(pointcloud, parsedPLY.data)) {\r\n return Promise.all([pointcloud.buildMeshAsync()]).then((mesh) => {\r\n babylonMeshesArray.push(mesh[0]);\r\n return babylonMeshesArray;\r\n });\r\n } else {\r\n pointcloud.dispose();\r\n }\r\n }\r\n break;\r\n case Mode.Mesh:\r\n {\r\n if (parsedPLY.faces) {\r\n babylonMeshesArray.push(SPLATFileLoader._BuildMesh(scene, parsedPLY));\r\n } else {\r\n throw new Error(\"PLY mesh doesn't contain face informations.\");\r\n }\r\n }\r\n break;\r\n default:\r\n throw new Error(\"Unsupported Splat mode\");\r\n }\r\n return Promise.resolve(babylonMeshesArray);\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string): Promise<AssetContainer> {\r\n const container = new AssetContainer(scene);\r\n this._assetContainer = container;\r\n\r\n return this.importMeshAsync(null, scene, data, rootUrl)\r\n .then((result) => {\r\n result.meshes.forEach((mesh) => container.meshes.push(mesh));\r\n // mesh material will be null before 1st rendered frame.\r\n this._assetContainer = null;\r\n return container;\r\n })\r\n .catch((ex) => {\r\n this._assetContainer = null;\r\n throw ex;\r\n });\r\n }\r\n\r\n /**\r\n * Imports all objects from the loaded OBJ data and adds them to the scene\r\n * @param scene the scene the objects should be added to\r\n * @param data the OBJ data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise which completes when objects have been loaded to the scene\r\n */\r\n public loadAsync(scene: Scene, data: string, rootUrl: string): Promise<void> {\r\n //Get the 3D model\r\n return this.importMeshAsync(null, scene, data, rootUrl).then(() => {\r\n // return void\r\n });\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Converts a .ply data array buffer to splat\r\n * if data array buffer is not ply, returns the original buffer\r\n * @param data the .ply data to load\r\n * @returns the loaded splat buffer\r\n */\r\n private static _ConvertPLYToSplat(data: ArrayBuffer): ParsedPLY {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n // standard splat\r\n return { mode: Mode.Splat, data: data };\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n const faceElement = /element face (\\d+)\\n/.exec(header);\r\n let faceCount = 0;\r\n if (faceElement) {\r\n faceCount = parseInt(faceElement[1]);\r\n }\r\n let rowOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n list: 0,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n const properties: PlyProperty[] = [];\r\n const filtered = header\r\n .slice(0, headerEndIndex)\r\n .split(\"\\n\")\r\n .filter((k) => k.startsWith(\"property \"));\r\n for (const prop of filtered) {\r\n const [, type, name] = prop.split(\" \");\r\n properties.push({ name, type, offset: rowOffset });\r\n if (offsets[type]) {\r\n rowOffset += offsets[type];\r\n } else {\r\n Logger.Warn(`Unsupported property type: ${type}.`);\r\n }\r\n }\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const SH_C0 = 0.28209479177387814;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowLength * vertexCount);\r\n const q = new Quaternion();\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowLength, 3);\r\n const scale = new Float32Array(buffer, i * rowLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);\r\n\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"uint\":\r\n value = dataView.getUint32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"double\":\r\n value = dataView.getFloat64(property.offset + i * rowOffset, true);\r\n break;\r\n case \"uchar\":\r\n value = dataView.getUint8(property.offset + i * rowOffset);\r\n break;\r\n default:\r\n //throw new Error(`Unsupported property type: ${property.type}`);\r\n continue;\r\n }\r\n\r\n switch (property.name) {\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"diffuse_red\":\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"diffuse_green\":\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"diffuse_blue\":\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n }\r\n\r\n // faces\r\n const faces = [];\r\n if (faceCount) {\r\n let offset = rowOffset * vertexCount;\r\n for (let i = 0; i < faceCount; i++) {\r\n const faceVertexCount = dataView.getUint8(offset);\r\n if (faceVertexCount != 3) {\r\n continue; // only support triangles\r\n }\r\n offset += 1;\r\n\r\n for (let j = 0; j < faceVertexCount; j++) {\r\n const vertexIndex = dataView.getUint32(offset + (2 - j) * 4, true); // change face winding\r\n faces.push(vertexIndex);\r\n }\r\n offset += 12;\r\n }\r\n }\r\n\r\n // count available properties. if all necessary are present then it's a splat. Otherwise, it's a point cloud\r\n // if faces are found, then it's a standard mesh\r\n let propertyCount = 0;\r\n let propertyColorCount = 0;\r\n const splatProperties = [\"x\", \"y\", \"z\", \"scale_0\", \"scale_1\", \"scale_2\", \"opacity\", \"rot_0\", \"rot_1\", \"rot_2\", \"rot_3\"];\r\n const splatColorProperties = [\"red\", \"green\", \"blue\", \"f_dc_0\", \"f_dc_1\", \"f_dc_2\"];\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n if (splatProperties.includes(property.name)) {\r\n propertyCount++;\r\n }\r\n if (splatColorProperties.includes(property.name)) {\r\n propertyColorCount++;\r\n }\r\n }\r\n const hasMandatoryProperties = propertyCount == splatProperties.length && propertyColorCount == 3;\r\n const currentMode = faceCount ? Mode.Mesh : hasMandatoryProperties ? Mode.Splat : Mode.PointCloud;\r\n // parsed ready ready to be used as a splat\r\n return { mode: currentMode, data: buffer, faces: faces, hasVertexColors: !!propertyColorCount };\r\n }\r\n}\r\n\r\n// Add this loader into the register plugin\r\nregisterSceneLoaderPlugin(new SPLATFileLoader());\r\n"]}
1
+ {"version":3,"file":"splatFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/SPLAT/splatFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,+CAAiC;AACrE,OAAO,EAAE,uB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C","sourcesContent":["import type { ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderAsyncResult, ISceneLoaderProgressEvent, SceneLoaderPluginOptions } from \"core/Loading/sceneLoader\";\r\nimport { registerSceneLoaderPlugin } from \"core/Loading/sceneLoader\";\r\nimport { SPLATFileLoaderMetadata } from \"./splatFileLoader.metadata\";\r\nimport { GaussianSplattingMesh } from \"core/Meshes/GaussianSplatting/gaussianSplattingMesh\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\nimport { PointsCloudSystem } from \"core/Particles/pointsCloudSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { SPLATLoadingOptions } from \"./splatLoadingOptions\";\r\nimport { Scalar } from \"core/Maths/math.scalar\";\r\n\r\ndeclare module \"core/Loading/sceneLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface SceneLoaderPluginOptions {\r\n /**\r\n * Defines options for the splat loader.\r\n */\r\n [SPLATFileLoaderMetadata.name]: Partial<SPLATLoadingOptions>;\r\n }\r\n}\r\n\r\n/**\r\n * Indicator of the parsed ply buffer. A standard ready to use splat or an array of positions for a point cloud\r\n */\r\nconst enum Mode {\r\n Splat = 0,\r\n PointCloud = 1,\r\n Mesh = 2,\r\n}\r\n\r\n/**\r\n * A parsed buffer and how to use it\r\n */\r\ninterface ParsedPLY {\r\n data: ArrayBuffer;\r\n mode: Mode;\r\n faces?: number[];\r\n hasVertexColors?: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface CompressedPLYChunk {\r\n min: Vector3;\r\n max: Vector3;\r\n minScale: Vector3;\r\n maxScale: Vector3;\r\n}\r\n\r\n/** @internal */\r\nconst enum ElementMode {\r\n Vertex = 0,\r\n Chunk = 1,\r\n}\r\n\r\n/**\r\n * @experimental\r\n * SPLAT file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class SPLATFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public readonly name = SPLATFileLoaderMetadata.name;\r\n\r\n private _assetContainer: Nullable<AssetContainer> = null;\r\n\r\n private readonly _loadingOptions: Readonly<SPLATLoadingOptions>;\r\n /**\r\n * Defines the extensions the splat loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n */\r\n public readonly extensions = SPLATFileLoaderMetadata.extensions;\r\n\r\n /**\r\n * Creates loader for gaussian splatting files\r\n * @param loadingOptions options for loading and parsing splat and PLY files.\r\n */\r\n constructor(loadingOptions: Partial<Readonly<SPLATLoadingOptions>> = SPLATFileLoader._DefaultLoadingOptions) {\r\n this._loadingOptions = loadingOptions;\r\n }\r\n\r\n private static readonly _DefaultLoadingOptions = {\r\n keepInRam: false,\r\n } as const satisfies SPLATLoadingOptions;\r\n\r\n /** @internal */\r\n createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync {\r\n return new SPLATFileLoader(options[SPLATFileLoaderMetadata.name]);\r\n }\r\n\r\n /**\r\n * Imports from the loaded gaussian splatting data and adds them to the scene\r\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\r\n * @param scene the scene the meshes should be added to\r\n * @param data the gaussian splatting data to load\r\n * @param rootUrl root url to load from\r\n * @param onProgress callback called while file is loading\r\n * @param fileName Defines the name of the file to load\r\n * @returns a promise containing the loaded meshes, particles, skeletons and animations\r\n */\r\n public async importMeshAsync(\r\n meshesNames: any,\r\n scene: Scene,\r\n data: any,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ): Promise<ISceneLoaderAsyncResult> {\r\n return this._parse(meshesNames, scene, data, rootUrl).then((meshes) => {\r\n return {\r\n meshes: meshes,\r\n particleSystems: [],\r\n skeletons: [],\r\n animationGroups: [],\r\n transformNodes: [],\r\n geometries: [],\r\n lights: [],\r\n spriteManagers: [],\r\n };\r\n });\r\n }\r\n\r\n private static _BuildPointCloud(pointcloud: PointsCloudSystem, data: ArrayBuffer): boolean {\r\n if (!data.byteLength) {\r\n return false;\r\n }\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(data);\r\n\r\n // parsed array contains room for position(3floats), normal(3floats), color (4b), quantized quaternion (4b)\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n const pointcloudfunc = function (particle: any, i: number) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n particle.position = new Vector3(x, y, z);\r\n\r\n const r = uBuffer[rowLength * i + 24 + 0] / 255;\r\n const g = uBuffer[rowLength * i + 24 + 1] / 255;\r\n const b = uBuffer[rowLength * i + 24 + 2] / 255;\r\n particle.color = new Color4(r, g, b, 1);\r\n };\r\n\r\n pointcloud.addPoints(vertexCount, pointcloudfunc);\r\n return true;\r\n }\r\n\r\n private static _BuildMesh(scene: Scene, parsedPLY: ParsedPLY): Mesh {\r\n const mesh = new Mesh(\"PLYMesh\", scene);\r\n\r\n const uBuffer = new Uint8Array(parsedPLY.data);\r\n const fBuffer = new Float32Array(parsedPLY.data);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n const positions = [];\r\n\r\n const vertexData = new VertexData();\r\n for (let i = 0; i < vertexCount; i++) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n positions.push(x, y, z);\r\n }\r\n\r\n if (parsedPLY.hasVertexColors) {\r\n const colors = new Float32Array(vertexCount * 4);\r\n for (let i = 0; i < vertexCount; i++) {\r\n const r = uBuffer[rowLength * i + 24 + 0] / 255;\r\n const g = uBuffer[rowLength * i + 24 + 1] / 255;\r\n const b = uBuffer[rowLength * i + 24 + 2] / 255;\r\n colors[i * 4 + 0] = r;\r\n colors[i * 4 + 1] = g;\r\n colors[i * 4 + 2] = b;\r\n colors[i * 4 + 3] = 1;\r\n }\r\n vertexData.colors = colors;\r\n }\r\n\r\n vertexData.positions = positions;\r\n vertexData.indices = parsedPLY.faces!;\r\n\r\n vertexData.applyToMesh(mesh);\r\n return mesh;\r\n }\r\n\r\n private _parse(meshesNames: any, scene: Scene, data: any, rootUrl: string): Promise<Array<AbstractMesh>> {\r\n const babylonMeshesArray: Array<Mesh> = []; //The mesh for babylon\r\n const parsedPLY = SPLATFileLoader._ConvertPLYToSplat(data as ArrayBuffer);\r\n switch (parsedPLY.mode) {\r\n case Mode.Splat:\r\n {\r\n const gaussianSplatting = new GaussianSplattingMesh(\"GaussianSplatting\", null, scene, this._loadingOptions.keepInRam);\r\n gaussianSplatting._parentContainer = this._assetContainer;\r\n babylonMeshesArray.push(gaussianSplatting);\r\n gaussianSplatting.loadDataAsync(parsedPLY.data);\r\n }\r\n break;\r\n case Mode.PointCloud:\r\n {\r\n const pointcloud = new PointsCloudSystem(\"PointCloud\", 1, scene);\r\n if (SPLATFileLoader._BuildPointCloud(pointcloud, parsedPLY.data)) {\r\n return Promise.all([pointcloud.buildMeshAsync()]).then((mesh) => {\r\n babylonMeshesArray.push(mesh[0]);\r\n return babylonMeshesArray;\r\n });\r\n } else {\r\n pointcloud.dispose();\r\n }\r\n }\r\n break;\r\n case Mode.Mesh:\r\n {\r\n if (parsedPLY.faces) {\r\n babylonMeshesArray.push(SPLATFileLoader._BuildMesh(scene, parsedPLY));\r\n } else {\r\n throw new Error(\"PLY mesh doesn't contain face informations.\");\r\n }\r\n }\r\n break;\r\n default:\r\n throw new Error(\"Unsupported Splat mode\");\r\n }\r\n return Promise.resolve(babylonMeshesArray);\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string): Promise<AssetContainer> {\r\n const container = new AssetContainer(scene);\r\n this._assetContainer = container;\r\n\r\n return this.importMeshAsync(null, scene, data, rootUrl)\r\n .then((result) => {\r\n result.meshes.forEach((mesh) => container.meshes.push(mesh));\r\n // mesh material will be null before 1st rendered frame.\r\n this._assetContainer = null;\r\n return container;\r\n })\r\n .catch((ex) => {\r\n this._assetContainer = null;\r\n throw ex;\r\n });\r\n }\r\n\r\n /**\r\n * Imports all objects from the loaded OBJ data and adds them to the scene\r\n * @param scene the scene the objects should be added to\r\n * @param data the OBJ data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise which completes when objects have been loaded to the scene\r\n */\r\n public loadAsync(scene: Scene, data: string, rootUrl: string): Promise<void> {\r\n //Get the 3D model\r\n return this.importMeshAsync(null, scene, data, rootUrl).then(() => {\r\n // return void\r\n });\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Converts a .ply data array buffer to splat\r\n * if data array buffer is not ply, returns the original buffer\r\n * @param data the .ply data to load\r\n * @returns the loaded splat buffer\r\n */\r\n private static _ConvertPLYToSplat(data: ArrayBuffer): ParsedPLY {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n // standard splat\r\n return { mode: Mode.Splat, data: data };\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n const faceElement = /element face (\\d+)\\n/.exec(header);\r\n const chunkElement = /element chunk (\\d+)\\n/.exec(header);\r\n let faceCount = 0;\r\n let chunkCount = 0;\r\n if (faceElement) {\r\n faceCount = parseInt(faceElement[1]);\r\n }\r\n if (chunkElement) {\r\n chunkCount = parseInt(chunkElement[1]);\r\n }\r\n let rowVertexOffset = 0;\r\n let rowChunkOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n list: 0,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n let chunkMode = ElementMode.Chunk;\r\n const vertexProperties: PlyProperty[] = [];\r\n const chunkProperties: PlyProperty[] = [];\r\n const filtered = header.slice(0, headerEndIndex).split(\"\\n\");\r\n for (const prop of filtered) {\r\n if (prop.startsWith(\"property \")) {\r\n const [, type, name] = prop.split(\" \");\r\n\r\n if (chunkMode == ElementMode.Chunk) {\r\n chunkProperties.push({ name, type, offset: rowChunkOffset });\r\n rowChunkOffset += offsets[type];\r\n } else if (chunkMode == ElementMode.Vertex) {\r\n vertexProperties.push({ name, type, offset: rowVertexOffset });\r\n rowVertexOffset += offsets[type];\r\n }\r\n\r\n if (!offsets[type]) {\r\n Logger.Warn(`Unsupported property type: ${type}.`);\r\n }\r\n } else if (prop.startsWith(\"element \")) {\r\n const [, type] = prop.split(\" \");\r\n if (type == \"chunk\") {\r\n chunkMode = ElementMode.Chunk;\r\n } else if (type == \"vertex\") {\r\n chunkMode = ElementMode.Vertex;\r\n }\r\n }\r\n }\r\n\r\n const rowVertexLength = rowVertexOffset;\r\n const rowChunkLength = rowChunkOffset;\r\n\r\n const rowOutputLength = 3 * 4 + 3 * 4 + 4 + 4; // Vector3 position, Vector3 scale, 1 u8 quaternion, 1 color with alpha\r\n const SH_C0 = 0.28209479177387814;\r\n let offset = 0;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowOutputLength * vertexCount);\r\n const q = new Quaternion();\r\n const temp3 = TmpVectors.Vector3[0];\r\n\r\n const unpackUnorm = (value: number, bits: number) => {\r\n const t = (1 << bits) - 1;\r\n return (value & t) / t;\r\n };\r\n\r\n const unpack111011 = (value: number, result: Vector3) => {\r\n result.x = unpackUnorm(value >>> 21, 11);\r\n result.y = unpackUnorm(value >>> 11, 10);\r\n result.z = unpackUnorm(value, 11);\r\n };\r\n\r\n const unpack8888 = (value: number, result: Uint8ClampedArray) => {\r\n result[0] = unpackUnorm(value >>> 24, 8) * 255;\r\n result[1] = unpackUnorm(value >>> 16, 8) * 255;\r\n result[2] = unpackUnorm(value >>> 8, 8) * 255;\r\n result[3] = unpackUnorm(value, 8) * 255;\r\n };\r\n\r\n // unpack quaternion with 2,10,10,10 format (largest element, 3x10bit element)\r\n const unpackRot = (value: number, result: Quaternion) => {\r\n const norm = 1.0 / (Math.sqrt(2) * 0.5);\r\n const a = (unpackUnorm(value >>> 20, 10) - 0.5) * norm;\r\n const b = (unpackUnorm(value >>> 10, 10) - 0.5) * norm;\r\n const c = (unpackUnorm(value, 10) - 0.5) * norm;\r\n const m = Math.sqrt(1.0 - (a * a + b * b + c * c));\r\n\r\n switch (value >>> 30) {\r\n case 0:\r\n result.set(m, a, b, c);\r\n break;\r\n case 1:\r\n result.set(a, m, b, c);\r\n break;\r\n case 2:\r\n result.set(a, b, m, c);\r\n break;\r\n case 3:\r\n result.set(a, b, c, m);\r\n break;\r\n }\r\n };\r\n\r\n const compressedChunks = new Array<CompressedPLYChunk>(chunkCount);\r\n for (let i = 0; i < chunkCount; i++) {\r\n const currentChunk = { min: new Vector3(), max: new Vector3(), minScale: new Vector3(), maxScale: new Vector3() };\r\n compressedChunks[i] = currentChunk;\r\n for (let propertyIndex = 0; propertyIndex < chunkProperties.length; propertyIndex++) {\r\n const property = chunkProperties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + offset, true);\r\n break;\r\n default:\r\n //throw new Error(`Unsupported property type: ${property.type}`);\r\n continue;\r\n }\r\n\r\n switch (property.name) {\r\n case \"min_x\":\r\n currentChunk.min.x = value;\r\n break;\r\n case \"min_y\":\r\n currentChunk.min.y = value;\r\n break;\r\n case \"min_z\":\r\n currentChunk.min.z = value;\r\n break;\r\n case \"max_x\":\r\n currentChunk.max.x = value;\r\n break;\r\n case \"max_y\":\r\n currentChunk.max.y = value;\r\n break;\r\n case \"max_z\":\r\n currentChunk.max.z = value;\r\n break;\r\n case \"min_scale_x\":\r\n currentChunk.minScale.x = value;\r\n break;\r\n case \"min_scale_y\":\r\n currentChunk.minScale.y = value;\r\n break;\r\n case \"min_scale_z\":\r\n currentChunk.minScale.z = value;\r\n break;\r\n case \"max_scale_x\":\r\n currentChunk.maxScale.x = value;\r\n break;\r\n case \"max_scale_y\":\r\n currentChunk.maxScale.y = value;\r\n break;\r\n case \"max_scale_z\":\r\n currentChunk.maxScale.z = value;\r\n break;\r\n }\r\n }\r\n offset += rowChunkLength;\r\n }\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowOutputLength, 3);\r\n const scale = new Float32Array(buffer, i * rowOutputLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowOutputLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowOutputLength + 28, 4);\r\n const chunkIndex = i >> 8;\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < vertexProperties.length; propertyIndex++) {\r\n const property = vertexProperties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(offset + property.offset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(offset + property.offset, true);\r\n break;\r\n case \"uint\":\r\n value = dataView.getUint32(offset + property.offset, true);\r\n break;\r\n case \"double\":\r\n value = dataView.getFloat64(offset + property.offset, true);\r\n break;\r\n case \"uchar\":\r\n value = dataView.getUint8(offset + property.offset);\r\n break;\r\n default:\r\n //throw new Error(`Unsupported property type: ${property.type}`);\r\n continue;\r\n }\r\n\r\n switch (property.name) {\r\n case \"packed_position\":\r\n {\r\n const compressedChunk = compressedChunks[chunkIndex];\r\n unpack111011(value, temp3);\r\n position[0] = Scalar.Lerp(compressedChunk.min.x, compressedChunk.max.x, temp3.x);\r\n position[1] = -Scalar.Lerp(compressedChunk.min.y, compressedChunk.max.y, temp3.y);\r\n position[2] = Scalar.Lerp(compressedChunk.min.z, compressedChunk.max.z, temp3.z);\r\n }\r\n break;\r\n case \"packed_rotation\":\r\n {\r\n unpackRot(value, q);\r\n r0 = q.w;\r\n r1 = q.z;\r\n r2 = q.y;\r\n r3 = q.x;\r\n }\r\n break;\r\n case \"packed_scale\":\r\n {\r\n const compressedChunk = compressedChunks[chunkIndex];\r\n unpack111011(value, temp3);\r\n scale[0] = Math.exp(Scalar.Lerp(compressedChunk.minScale.x, compressedChunk.maxScale.x, temp3.x));\r\n scale[1] = Math.exp(Scalar.Lerp(compressedChunk.minScale.y, compressedChunk.maxScale.y, temp3.y));\r\n scale[2] = Math.exp(Scalar.Lerp(compressedChunk.minScale.z, compressedChunk.maxScale.z, temp3.z));\r\n }\r\n break;\r\n case \"packed_color\":\r\n unpack8888(value, rgba);\r\n break;\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"diffuse_red\":\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"diffuse_green\":\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"diffuse_blue\":\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n offset += rowVertexLength;\r\n }\r\n\r\n // faces\r\n const faces = [];\r\n if (faceCount) {\r\n for (let i = 0; i < faceCount; i++) {\r\n const faceVertexCount = dataView.getUint8(offset);\r\n if (faceVertexCount != 3) {\r\n continue; // only support triangles\r\n }\r\n offset += 1;\r\n\r\n for (let j = 0; j < faceVertexCount; j++) {\r\n const vertexIndex = dataView.getUint32(offset + (2 - j) * 4, true); // change face winding\r\n faces.push(vertexIndex);\r\n }\r\n offset += 12;\r\n }\r\n }\r\n\r\n // early exit for chunked/quantized ply\r\n if (chunkCount) {\r\n return { mode: Mode.Splat, data: buffer, faces: faces, hasVertexColors: false };\r\n }\r\n // count available properties. if all necessary are present then it's a splat. Otherwise, it's a point cloud\r\n // if faces are found, then it's a standard mesh\r\n let propertyCount = 0;\r\n let propertyColorCount = 0;\r\n const splatProperties = [\"x\", \"y\", \"z\", \"scale_0\", \"scale_1\", \"scale_2\", \"opacity\", \"rot_0\", \"rot_1\", \"rot_2\", \"rot_3\"];\r\n const splatColorProperties = [\"red\", \"green\", \"blue\", \"f_dc_0\", \"f_dc_1\", \"f_dc_2\"];\r\n for (let propertyIndex = 0; propertyIndex < vertexProperties.length; propertyIndex++) {\r\n const property = vertexProperties[propertyIndex];\r\n if (splatProperties.includes(property.name)) {\r\n propertyCount++;\r\n }\r\n if (splatColorProperties.includes(property.name)) {\r\n propertyColorCount++;\r\n }\r\n }\r\n const hasMandatoryProperties = propertyCount == splatProperties.length && propertyColorCount == 3;\r\n const currentMode = faceCount ? Mode.Mesh : hasMandatoryProperties ? Mode.Splat : Mode.PointCloud;\r\n // parsed ready ready to be used as a splat\r\n return { mode: currentMode, data: buffer, faces: faces, hasVertexColors: !!propertyColorCount };\r\n }\r\n}\r\n\r\n// Add this loader into the register plugin\r\nregisterSceneLoaderPlugin(new SPLATFileLoader());\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/loaders",
3
- "version": "7.27.3",
3
+ "version": "7.29.0",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "devDependencies": {
21
- "@babylonjs/core": "^7.27.3",
21
+ "@babylonjs/core": "^7.29.0",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/loaders": "^1.0.0",
24
- "babylonjs-gltf2interface": "^7.27.3"
24
+ "babylonjs-gltf2interface": "^7.29.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@babylonjs/core": "^7.0.0",