@babylonjs/core 6.46.0 → 6.46.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.
Files changed (41) hide show
  1. package/Animations/animationGroup.d.ts +5 -3
  2. package/Animations/animationGroup.js +19 -4
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/BakedVertexAnimation/vertexAnimationBaker.d.ts +4 -2
  5. package/BakedVertexAnimation/vertexAnimationBaker.js +25 -17
  6. package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
  7. package/Bones/skeleton.d.ts +1 -1
  8. package/Bones/skeleton.js +3 -0
  9. package/Bones/skeleton.js.map +1 -1
  10. package/Cameras/arcRotateCamera.d.ts +3 -3
  11. package/Cameras/arcRotateCamera.js +3 -3
  12. package/Cameras/arcRotateCamera.js.map +1 -1
  13. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  14. package/Engines/Native/nativeInterfaces.d.ts +4 -4
  15. package/Engines/Native/nativeInterfaces.js.map +1 -1
  16. package/Engines/nativeEngine.d.ts +1 -1
  17. package/Engines/nativeEngine.js +4 -3
  18. package/Engines/nativeEngine.js.map +1 -1
  19. package/Engines/thinEngine.js +2 -2
  20. package/Engines/thinEngine.js.map +1 -1
  21. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +1 -1
  22. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  23. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +1 -1
  24. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  25. package/Gizmos/gizmo.d.ts +1 -1
  26. package/Gizmos/gizmo.js.map +1 -1
  27. package/Materials/Node/nodeMaterial.js +2 -0
  28. package/Materials/Node/nodeMaterial.js.map +1 -1
  29. package/Meshes/Compression/dracoCompressionWorker.d.ts +1 -2
  30. package/Meshes/Compression/dracoCompressionWorker.js +1 -1
  31. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  32. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +10 -3
  33. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  34. package/Physics/castingResult.d.ts +1 -1
  35. package/Physics/castingResult.js.map +1 -1
  36. package/XR/features/WebXRControllerTeleportation.d.ts +4 -0
  37. package/XR/features/WebXRControllerTeleportation.js +33 -1
  38. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  39. package/XR/features/WebXRNearInteraction.js +11 -1
  40. package/XR/features/WebXRNearInteraction.js.map +1 -1
  41. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- import type { DecoderModule } from "draco3dgltf";
2
1
  export interface AttributeData {
3
2
  kind: string;
4
3
  data: ArrayBufferView;
@@ -25,7 +24,7 @@ export type Message = InitDoneMessage | DecodeMeshDoneMessage | IndicesMessage |
25
24
  /**
26
25
  * @internal
27
26
  */
28
- export declare function decodeMesh(decoderModule: DecoderModule, data: Int8Array, attributes: {
27
+ export declare function decodeMesh(decoderModule: any, data: Int8Array, attributes: {
29
28
  [kind: string]: number;
30
29
  } | undefined, onIndicesData: (indices: Uint16Array | Uint32Array) => void, onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void): number;
31
30
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @internal
3
3
  */
4
- export function decodeMesh(decoderModule, data, attributes, onIndicesData, onAttributeData) {
4
+ export function decodeMesh(decoderModule /*DecoderModule*/, data, attributes, onIndicesData, onAttributeData) {
5
5
  let decoder = null;
6
6
  let buffer = null;
7
7
  let geometry = null;
@@ -1 +1 @@
1
- {"version":3,"file":"dracoCompressionWorker.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompressionWorker.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,aAA4B,EAC5B,IAAe,EACf,UAAkD,EAClD,aAA2D,EAC3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AAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,WAAW,CACd;YACI,EAAE,EAAE,MAAM;YACV,OAAO,EAAE;gBACL,GAAG,EAAE,SAAS;gBACd,UAAU,EAAE,KAAK;aACpB;SACJ,EACD,CAAC,KAAK,CAAC,CACV,CAAC;QACF,0FAA0F;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DecoderModule, DecoderBuffer, Decoder, Mesh, PointCloud, Status } from \"draco3dgltf\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\nexport interface AttributeData {\r\n kind: string;\r\n data: ArrayBufferView;\r\n size: number;\r\n byteOffset: number;\r\n byteStride: number;\r\n normalized: boolean;\r\n}\r\n\r\ninterface InitDoneMessage {\r\n id: \"initDone\";\r\n}\r\n\r\ninterface DecodeMeshDoneMessage {\r\n id: \"decodeMeshDone\";\r\n totalVertices: number;\r\n}\r\n\r\ninterface IndicesMessage {\r\n id: \"indices\";\r\n data: Uint16Array | Uint32Array;\r\n}\r\n\r\ninterface AttributeMessage extends AttributeData {\r\n id: \"attribute\";\r\n}\r\nexport type Message = InitDoneMessage | DecodeMeshDoneMessage | IndicesMessage | AttributeMessage;\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: Message, transfer?: any[]): void;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function decodeMesh(\r\n decoderModule: DecoderModule,\r\n data: Int8Array,\r\n attributes: { [kind: string]: number } | undefined,\r\n onIndicesData: (indices: Uint16Array | Uint32Array) => void,\r\n onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void\r\n): number {\r\n let decoder: Nullable<Decoder> = null;\r\n let buffer: Nullable<DecoderBuffer> = null;\r\n let geometry: Nullable<Mesh | PointCloud> = null;\r\n\r\n try {\r\n decoder = new decoderModule.Decoder();\r\n\r\n buffer = new decoderModule.DecoderBuffer();\r\n buffer.Init(data, data.byteLength);\r\n\r\n let status: Status;\r\n const type = decoder.GetEncodedGeometryType(buffer);\r\n switch (type) {\r\n case decoderModule.TRIANGULAR_MESH: {\r\n const mesh = new decoderModule.Mesh();\r\n status = decoder.DecodeBufferToMesh(buffer, mesh);\r\n if (!status.ok() || mesh.ptr === 0) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n const numFaces = mesh.num_faces();\r\n const numIndices = numFaces * 3;\r\n const byteLength = numIndices * 4;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetTrianglesUInt32Array(mesh, byteLength, ptr);\r\n const indices = new Uint32Array(numIndices);\r\n indices.set(new Uint32Array(decoderModule.HEAPF32.buffer, ptr, numIndices));\r\n onIndicesData(indices);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n\r\n geometry = mesh;\r\n break;\r\n }\r\n case decoderModule.POINT_CLOUD: {\r\n const pointCloud = new decoderModule.PointCloud();\r\n status = decoder.DecodeBufferToPointCloud(buffer, pointCloud);\r\n if (!status.ok() || !pointCloud.ptr) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n geometry = pointCloud;\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid geometry type ${type}`);\r\n }\r\n }\r\n\r\n const numPoints = geometry.num_points();\r\n\r\n const processAttribute = (decoder: Decoder, geometry: Mesh | PointCloud, kind: string, attribute: any) => {\r\n const dataType = attribute.data_type();\r\n const numComponents = attribute.num_components();\r\n const normalized = attribute.normalized();\r\n const byteStride = attribute.byte_stride();\r\n const byteOffset = attribute.byte_offset();\r\n\r\n const dataTypeInfo = {\r\n [decoderModule.DT_FLOAT32]: { typedArrayConstructor: Float32Array, heap: decoderModule.HEAPF32 },\r\n [decoderModule.DT_INT8]: { typedArrayConstructor: Int8Array, heap: decoderModule.HEAP8 },\r\n [decoderModule.DT_INT16]: { typedArrayConstructor: Int16Array, heap: decoderModule.HEAP16 },\r\n [decoderModule.DT_INT32]: { typedArrayConstructor: Int32Array, heap: decoderModule.HEAP32 },\r\n [decoderModule.DT_UINT8]: { typedArrayConstructor: Uint8Array, heap: decoderModule.HEAPU8 },\r\n [decoderModule.DT_UINT16]: { typedArrayConstructor: Uint16Array, heap: decoderModule.HEAPU16 },\r\n [decoderModule.DT_UINT32]: { typedArrayConstructor: Uint32Array, heap: decoderModule.HEAPU32 },\r\n };\r\n\r\n const info = dataTypeInfo[dataType];\r\n if (!info) {\r\n throw new Error(`Invalid data type ${dataType}`);\r\n }\r\n\r\n const numValues = numPoints * numComponents;\r\n const byteLength = numValues * info.typedArrayConstructor.BYTES_PER_ELEMENT;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);\r\n const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);\r\n onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n };\r\n\r\n if (attributes) {\r\n for (const kind in attributes) {\r\n const id = attributes[kind];\r\n const attribute = decoder.GetAttributeByUniqueId(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n } else {\r\n const dracoAttributeTypes: { [kind: string]: number } = {\r\n position: decoderModule.POSITION,\r\n normal: decoderModule.NORMAL,\r\n color: decoderModule.COLOR,\r\n uv: decoderModule.TEX_COORD,\r\n };\r\n\r\n for (const kind in dracoAttributeTypes) {\r\n const id = decoder.GetAttributeId(geometry, dracoAttributeTypes[kind]);\r\n if (id !== -1) {\r\n const attribute = decoder.GetAttribute(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n }\r\n }\r\n\r\n return numPoints;\r\n } finally {\r\n if (geometry) {\r\n decoderModule.destroy(geometry);\r\n }\r\n\r\n if (buffer) {\r\n decoderModule.destroy(buffer);\r\n }\r\n\r\n if (decoder) {\r\n decoderModule.destroy(decoder);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n * To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.\r\n */\r\nexport function workerFunction(): void {\r\n let decoderPromise: PromiseLike<any> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n const decoder = message.decoder;\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (decoder.url) {\r\n importScripts(decoder.url);\r\n }\r\n decoderPromise = DracoDecoderModule({ wasmBinary: decoder.wasmBinary });\r\n postMessage({ id: \"initDone\" });\r\n break;\r\n }\r\n case \"decodeMesh\": {\r\n if (!decoderPromise) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n decoderPromise.then((decoder) => {\r\n const numPoints = decodeMesh(\r\n decoder,\r\n message.dataView,\r\n message.attributes,\r\n (indices) => {\r\n postMessage({ id: \"indices\", data: indices }, [indices.buffer]);\r\n },\r\n (kind, data, size, offset, stride, normalized) => {\r\n postMessage({ id: \"attribute\", kind, data, size, byteOffset: offset, byteStride: stride, normalized }, [data.buffer]);\r\n }\r\n );\r\n postMessage({ id: \"decodeMeshDone\", totalVertices: numPoints });\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Initializes a worker that was created for the draco agent pool\r\n * @param worker The worker to initialize\r\n * @param decoderWasmBinary The wasm binary to load into the worker\r\n * @param moduleUrl The url to the draco decoder module (optional)\r\n * @returns A promise that resolves when the worker is initialized\r\n */\r\nexport function initializeWebWorker(worker: Worker, decoderWasmBinary: ArrayBuffer, moduleUrl?: string): Promise<Worker> {\r\n return new Promise<Worker>((resolve, reject) => {\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n if (event.data.id === \"initDone\") {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(worker);\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n // clone the array buffer to make it transferable\r\n const clone = decoderWasmBinary.slice(0);\r\n worker.postMessage(\r\n {\r\n id: \"init\",\r\n decoder: {\r\n url: moduleUrl,\r\n wasmBinary: clone,\r\n },\r\n },\r\n [clone]\r\n );\r\n // note: no transfer list as the ArrayBuffer is shared across main thread and pool workers\r\n });\r\n}\r\n"]}
1
+ {"version":3,"file":"dracoCompressionWorker.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompressionWorker.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,aAAkB,CAAC,iBAAiB,EACpC,IAAe,EACf,UAAkD,EAClD,aAA2D,EAC3D,eAAiI;IAEjI,IAAI,OAAO,GAAsB,IAAI,CAAC;IACtC,IAAI,MAAM,GAA4B,IAAI,CAAC;IAC3C,IAAI,QAAQ,GAAgC,IAAI,CAAC;IAEjD,IAAI;QACA,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,EAAa,CAAC;QAEjD,MAAM,GAAG,IAAI,aAAa,CAAC,aAAa,EAAmB,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEnC,IAAI,MAAc,CAAC;QACnB,MAAM,IAAI,GAAG,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACpD,QAAQ,IAAI,EAAE;YACV,KAAK,aAAa,CAAC,eAAe,CAAC,CAAC;gBAChC,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;gBACtC,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,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C,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACjD,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,KAA4B,EAAE,EAAE;YAC/C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,EAAE;gBAC9B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC7C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjD,OAAO,CAAC,MAAM,CAAC,CAAC;aACnB;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE9C,iDAAiD;QACjD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,WAAW,CACd;YACI,EAAE,EAAE,MAAM;YACV,OAAO,EAAE;gBACL,GAAG,EAAE,SAAS;gBACd,UAAU,EAAE,KAAK;aACpB;SACJ,EACD,CAAC,KAAK,CAAC,CACV,CAAC;QACF,0FAA0F;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DecoderBuffer, Decoder, Mesh, PointCloud, Status } from \"draco3dgltf\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\nexport interface AttributeData {\r\n kind: string;\r\n data: ArrayBufferView;\r\n size: number;\r\n byteOffset: number;\r\n byteStride: number;\r\n normalized: boolean;\r\n}\r\n\r\ninterface InitDoneMessage {\r\n id: \"initDone\";\r\n}\r\n\r\ninterface DecodeMeshDoneMessage {\r\n id: \"decodeMeshDone\";\r\n totalVertices: number;\r\n}\r\n\r\ninterface IndicesMessage {\r\n id: \"indices\";\r\n data: Uint16Array | Uint32Array;\r\n}\r\n\r\ninterface AttributeMessage extends AttributeData {\r\n id: \"attribute\";\r\n}\r\nexport type Message = InitDoneMessage | DecodeMeshDoneMessage | IndicesMessage | AttributeMessage;\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: Message, transfer?: any[]): void;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function decodeMesh(\r\n decoderModule: any /*DecoderModule*/,\r\n data: Int8Array,\r\n attributes: { [kind: string]: number } | undefined,\r\n onIndicesData: (indices: Uint16Array | Uint32Array) => void,\r\n onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void\r\n): number {\r\n let decoder: Nullable<Decoder> = null;\r\n let buffer: Nullable<DecoderBuffer> = null;\r\n let geometry: Nullable<Mesh | PointCloud> = null;\r\n\r\n try {\r\n decoder = new decoderModule.Decoder() as Decoder;\r\n\r\n buffer = new decoderModule.DecoderBuffer() as DecoderBuffer;\r\n buffer.Init(data, data.byteLength);\r\n\r\n let status: Status;\r\n const type = decoder.GetEncodedGeometryType(buffer);\r\n switch (type) {\r\n case decoderModule.TRIANGULAR_MESH: {\r\n const mesh = new decoderModule.Mesh();\r\n status = decoder.DecodeBufferToMesh(buffer, mesh);\r\n if (!status.ok() || mesh.ptr === 0) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n const numFaces = mesh.num_faces();\r\n const numIndices = numFaces * 3;\r\n const byteLength = numIndices * 4;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetTrianglesUInt32Array(mesh, byteLength, ptr);\r\n const indices = new Uint32Array(numIndices);\r\n indices.set(new Uint32Array(decoderModule.HEAPF32.buffer, ptr, numIndices));\r\n onIndicesData(indices);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n\r\n geometry = mesh as Mesh;\r\n break;\r\n }\r\n case decoderModule.POINT_CLOUD: {\r\n const pointCloud = new decoderModule.PointCloud();\r\n status = decoder.DecodeBufferToPointCloud(buffer, pointCloud);\r\n if (!status.ok() || !pointCloud.ptr) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n geometry = pointCloud as PointCloud;\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid geometry type ${type}`);\r\n }\r\n }\r\n\r\n const numPoints = geometry.num_points();\r\n\r\n const processAttribute = (decoder: Decoder, geometry: Mesh | PointCloud, kind: string, attribute: any) => {\r\n const dataType = attribute.data_type();\r\n const numComponents = attribute.num_components();\r\n const normalized = attribute.normalized();\r\n const byteStride = attribute.byte_stride();\r\n const byteOffset = attribute.byte_offset();\r\n\r\n const dataTypeInfo = {\r\n [decoderModule.DT_FLOAT32]: { typedArrayConstructor: Float32Array, heap: decoderModule.HEAPF32 },\r\n [decoderModule.DT_INT8]: { typedArrayConstructor: Int8Array, heap: decoderModule.HEAP8 },\r\n [decoderModule.DT_INT16]: { typedArrayConstructor: Int16Array, heap: decoderModule.HEAP16 },\r\n [decoderModule.DT_INT32]: { typedArrayConstructor: Int32Array, heap: decoderModule.HEAP32 },\r\n [decoderModule.DT_UINT8]: { typedArrayConstructor: Uint8Array, heap: decoderModule.HEAPU8 },\r\n [decoderModule.DT_UINT16]: { typedArrayConstructor: Uint16Array, heap: decoderModule.HEAPU16 },\r\n [decoderModule.DT_UINT32]: { typedArrayConstructor: Uint32Array, heap: decoderModule.HEAPU32 },\r\n };\r\n\r\n const info = dataTypeInfo[dataType];\r\n if (!info) {\r\n throw new Error(`Invalid data type ${dataType}`);\r\n }\r\n\r\n const numValues = numPoints * numComponents;\r\n const byteLength = numValues * info.typedArrayConstructor.BYTES_PER_ELEMENT;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);\r\n const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);\r\n onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n };\r\n\r\n if (attributes) {\r\n for (const kind in attributes) {\r\n const id = attributes[kind];\r\n const attribute = decoder.GetAttributeByUniqueId(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n } else {\r\n const dracoAttributeTypes: { [kind: string]: number } = {\r\n position: decoderModule.POSITION,\r\n normal: decoderModule.NORMAL,\r\n color: decoderModule.COLOR,\r\n uv: decoderModule.TEX_COORD,\r\n };\r\n\r\n for (const kind in dracoAttributeTypes) {\r\n const id = decoder.GetAttributeId(geometry, dracoAttributeTypes[kind]);\r\n if (id !== -1) {\r\n const attribute = decoder.GetAttribute(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n }\r\n }\r\n\r\n return numPoints;\r\n } finally {\r\n if (geometry) {\r\n decoderModule.destroy(geometry);\r\n }\r\n\r\n if (buffer) {\r\n decoderModule.destroy(buffer);\r\n }\r\n\r\n if (decoder) {\r\n decoderModule.destroy(decoder);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n * To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.\r\n */\r\nexport function workerFunction(): void {\r\n let decoderPromise: PromiseLike<any> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n const decoder = message.decoder;\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (decoder.url) {\r\n importScripts(decoder.url);\r\n }\r\n decoderPromise = DracoDecoderModule({ wasmBinary: decoder.wasmBinary });\r\n postMessage({ id: \"initDone\" });\r\n break;\r\n }\r\n case \"decodeMesh\": {\r\n if (!decoderPromise) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n decoderPromise.then((decoder) => {\r\n const numPoints = decodeMesh(\r\n decoder,\r\n message.dataView,\r\n message.attributes,\r\n (indices) => {\r\n postMessage({ id: \"indices\", data: indices }, [indices.buffer]);\r\n },\r\n (kind, data, size, offset, stride, normalized) => {\r\n postMessage({ id: \"attribute\", kind, data, size, byteOffset: offset, byteStride: stride, normalized }, [data.buffer]);\r\n }\r\n );\r\n postMessage({ id: \"decodeMeshDone\", totalVertices: numPoints });\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Initializes a worker that was created for the draco agent pool\r\n * @param worker The worker to initialize\r\n * @param decoderWasmBinary The wasm binary to load into the worker\r\n * @param moduleUrl The url to the draco decoder module (optional)\r\n * @returns A promise that resolves when the worker is initialized\r\n */\r\nexport function initializeWebWorker(worker: Worker, decoderWasmBinary: ArrayBuffer, moduleUrl?: string): Promise<Worker> {\r\n return new Promise<Worker>((resolve, reject) => {\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n if (event.data.id === \"initDone\") {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(worker);\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n // clone the array buffer to make it transferable\r\n const clone = decoderWasmBinary.slice(0);\r\n worker.postMessage(\r\n {\r\n id: \"init\",\r\n decoder: {\r\n url: moduleUrl,\r\n wasmBinary: clone,\r\n },\r\n },\r\n [clone]\r\n );\r\n // note: no transfer list as the ArrayBuffer is shared across main thread and pool workers\r\n });\r\n}\r\n"]}
@@ -139,9 +139,13 @@ export class GaussianSplattingMesh extends Mesh {
139
139
  for (const prop of filtered) {
140
140
  const [, type, name] = prop.split(" ");
141
141
  properties.push({ name, type, offset: rowOffset });
142
- if (!offsets[type])
143
- throw new Error(`Unsupported property type: ${type}`);
144
- rowOffset += offsets[type];
142
+ if (offsets[type]) {
143
+ rowOffset += offsets[type];
144
+ }
145
+ else {
146
+ Logger.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);
147
+ return new ArrayBuffer(0);
148
+ }
145
149
  }
146
150
  const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
147
151
  const SH_C0 = 0.28209479177387814;
@@ -274,6 +278,9 @@ export class GaussianSplattingMesh extends Mesh {
274
278
  super.dispose(doNotRecurse);
275
279
  }
276
280
  _loadData(data) {
281
+ if (!data.byteLength) {
282
+ return;
283
+ }
277
284
  // Parse the data
278
285
  const uBuffer = new Uint8Array(data);
279
286
  const fBuffer = new Float32Array(uBuffer.buffer);
@@ -1 +1 @@
1
- {"version":3,"file":"gaussianSplattingMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,4BAAwB;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAC1F,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAC1C,OAAO,EAAE,yBAAyB,EAAE,uEAAmE;AACvG,OAAO,EAAE,UAAU,EAAE,+CAA2C;AAChE,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAI;IAc3C;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAA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Q,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACjJ;YAED,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEhB,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SACrD;IACL,CAAC,CAAC;AACN,CAAC,AAvC2B,CAuC1B","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { DeepImmutable, Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { SubMesh } from \"../subMesh\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Class used to render a gaussian splatting mesh\r\n */\r\nexport class GaussianSplattingMesh extends Mesh {\r\n private _vertexCount = 0;\r\n private _worker: Nullable<Worker> = null;\r\n private _frameIdLastUpdate = -1;\r\n private _modelViewMatrix = Matrix.Identity();\r\n private _material: Nullable<GaussianSplattingMaterial> = null;\r\n private _depthMix: BigInt64Array;\r\n private _canPostToWorker = true;\r\n private _lastProj: DeepImmutable<Float32Array | number[]>;\r\n private _covariancesATexture: Nullable<BaseTexture> = null;\r\n private _covariancesBTexture: Nullable<BaseTexture> = null;\r\n private _centersTexture: Nullable<BaseTexture> = null;\r\n private _colorsTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets the covariancesA texture\r\n */\r\n public get covariancesATexture() {\r\n return this._covariancesATexture;\r\n }\r\n\r\n /**\r\n * Gets the covariancesB texture\r\n */\r\n public get covariancesBTexture() {\r\n return this._covariancesBTexture;\r\n }\r\n\r\n /**\r\n * Gets the centers texture\r\n */\r\n public get centersTexture() {\r\n return this._centersTexture;\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n public get colorsTexture() {\r\n return this._colorsTexture;\r\n }\r\n\r\n /**\r\n * Creates a new gaussian splatting mesh\r\n * @param name defines the name of the mesh\r\n * @param url defines the url to load from (optional)\r\n * @param scene defines the hosting scene (optional)\r\n */\r\n constructor(name: string, url: Nullable<string> = null, scene: Nullable<Scene> = null) {\r\n super(name, scene);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];\r\n vertexData.indices = [0, 1, 2, 0, 2, 3];\r\n vertexData.applyToMesh(this);\r\n\r\n this.subMeshes = [];\r\n new SubMesh(0, 0, 4, 0, 6, this);\r\n\r\n this.doNotSyncBoundingInfo = true;\r\n this.setEnabled(false);\r\n\r\n this._lastProj = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\r\n\r\n if (url) {\r\n this.loadFileAsync(url);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the class name\r\n * @returns \"GaussianSplattingMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GaussianSplattingMesh\";\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (splats) within the mesh\r\n * @returns the total number of vertices\r\n */\r\n public getTotalVertices(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager\r\n * @param subMesh defines the subMesh to render\r\n * @param enableAlphaMode defines if alpha mode can be changed\r\n * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering\r\n * @returns the current mesh\r\n */\r\n public render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh {\r\n if (!this.material) {\r\n this._material = new GaussianSplattingMaterial(this.name + \"_material\", this._scene);\r\n this.material = this._material;\r\n }\r\n\r\n const frameId = this.getScene().getFrameId();\r\n if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {\r\n this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);\r\n\r\n const dot = this._lastProj[2] * this._modelViewMatrix.m[2] + this._lastProj[6] * this._modelViewMatrix.m[6] + this._lastProj[10] * this._modelViewMatrix.m[10];\r\n if (Math.abs(dot - 1) >= 0.01) {\r\n this._frameIdLastUpdate = frameId;\r\n this._canPostToWorker = false;\r\n this._lastProj = this._modelViewMatrix.m.slice(0);\r\n this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix }, [this._depthMix.buffer]);\r\n }\r\n }\r\n\r\n return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);\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 public static ConvertPLYToSplat(data: ArrayBuffer): ArrayBuffer {\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 return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![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 };\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]) throw new Error(`Unsupported property type: ${type}`);\r\n rowOffset += offsets[type];\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 default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\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 \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\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 return buffer;\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian Splatting array buffer asynchronously\r\n * @param data arraybuffer containing splat file\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n\r\n public loadDataAsync(data: ArrayBuffer): Promise<void> {\r\n return Promise.resolve(this._loadData(data));\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian or .ply Splatting file asynchronously\r\n * @param url path to the splat file to load\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n public loadFileAsync(url: string): Promise<void> {\r\n return Tools.LoadFileAsync(url, true).then((data) => {\r\n this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));\r\n });\r\n }\r\n\r\n /**\r\n * Releases resources associated with this mesh.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n */\r\n public dispose(doNotRecurse?: boolean): void {\r\n this._covariancesATexture?.dispose();\r\n this._covariancesBTexture?.dispose();\r\n this._centersTexture?.dispose();\r\n this._colorsTexture?.dispose();\r\n\r\n this._covariancesATexture = null;\r\n this._covariancesBTexture = null;\r\n this._centersTexture = null;\r\n this._colorsTexture = null;\r\n\r\n this._material?.dispose(false, true);\r\n this._material = null;\r\n\r\n this._worker?.terminate();\r\n this._worker = null;\r\n\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n private static _CreateWorker = function (self: Worker) {\r\n let vertexCount = 0;\r\n let positions: Float32Array;\r\n let depthMix: BigInt64Array;\r\n let indices: Uint32Array;\r\n let floatMix: Float32Array;\r\n\r\n self.onmessage = (e: any) => {\r\n // updated on init\r\n if (e.data.positions) {\r\n positions = e.data.positions;\r\n vertexCount = e.data.vertexCount;\r\n }\r\n // udpate on view changed\r\n else {\r\n const viewProj = e.data.view;\r\n if (!positions || !viewProj) {\r\n // Sanity check, it shouldn't happen!\r\n throw new Error(\"positions or view is not defined!\");\r\n }\r\n\r\n depthMix = e.data.depthMix;\r\n indices = new Uint32Array(depthMix.buffer);\r\n floatMix = new Float32Array(depthMix.buffer);\r\n\r\n // Sort\r\n for (let j = 0; j < vertexCount; j++) {\r\n indices[2 * j] = j;\r\n }\r\n\r\n for (let j = 0; j < vertexCount; j++) {\r\n floatMix[2 * j + 1] = 10000 - (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]);\r\n }\r\n\r\n depthMix.sort();\r\n\r\n self.postMessage({ depthMix }, [depthMix.buffer]);\r\n }\r\n };\r\n };\r\n\r\n private _loadData(data: ArrayBuffer): void {\r\n // Parse the data\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(uBuffer.buffer);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n this._vertexCount = vertexCount;\r\n\r\n const textureSize = this._getTextureSize(vertexCount);\r\n const textureLength = textureSize.x * textureSize.y;\r\n\r\n const positions = new Float32Array(3 * textureLength);\r\n const covA = new Float32Array(3 * textureLength);\r\n const covB = new Float32Array(3 * textureLength);\r\n\r\n const matrixRotation = TmpVectors.Matrix[0];\r\n const matrixScale = TmpVectors.Matrix[1];\r\n const quaternion = TmpVectors.Quaternion[0];\r\n\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\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\r\n positions[3 * i + 0] = x;\r\n positions[3 * i + 1] = y;\r\n positions[3 * i + 2] = z;\r\n\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n\r\n quaternion.set(\r\n (uBuffer[32 * i + 28 + 1] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 2] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 3] - 128) / 128,\r\n -(uBuffer[32 * i + 28 + 0] - 128) / 128\r\n );\r\n quaternion.toRotationMatrix(matrixRotation);\r\n\r\n Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);\r\n\r\n const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;\r\n\r\n covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];\r\n covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];\r\n covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];\r\n covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];\r\n covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];\r\n covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];\r\n }\r\n\r\n // Update the mesh\r\n const binfo = this.getBoundingInfo();\r\n binfo.reConstruct(minimum, maximum, this.getWorldMatrix());\r\n binfo.isLocked = true;\r\n\r\n this.forcedInstanceCount = this._vertexCount;\r\n this.setEnabled(true);\r\n\r\n const splatIndex = new Float32Array(this._vertexCount * 1);\r\n\r\n this.thinInstanceSetBuffer(\"splatIndex\", splatIndex, 1, false);\r\n\r\n // Update the material\r\n const createTextureFromData = (data: Float32Array, width: number, height: number, format: number) => {\r\n return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);\r\n };\r\n\r\n const convertRgbToRgba = (rgb: Float32Array) => {\r\n const count = rgb.length / 3;\r\n const rgba = new Float32Array(count * 4);\r\n for (let i = 0; i < count; ++i) {\r\n rgba[i * 4 + 0] = rgb[i * 3 + 0];\r\n rgba[i * 4 + 1] = rgb[i * 3 + 1];\r\n rgba[i * 4 + 2] = rgb[i * 3 + 2];\r\n rgba[i * 4 + 3] = 1.0;\r\n }\r\n return rgba;\r\n };\r\n\r\n const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);\r\n for (let i = 0; i < this._vertexCount; ++i) {\r\n colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;\r\n colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;\r\n colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;\r\n colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;\r\n }\r\n\r\n this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._centersTexture = createTextureFromData(convertRgbToRgba(positions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n\r\n // Start the worker thread\r\n this._worker?.terminate();\r\n this._worker = new Worker(\r\n URL.createObjectURL(\r\n new Blob([\"(\", GaussianSplattingMesh._CreateWorker.toString(), \")(self)\"], {\r\n type: \"application/javascript\",\r\n })\r\n )\r\n );\r\n\r\n this._depthMix = new BigInt64Array(vertexCount);\r\n\r\n this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);\r\n\r\n this._worker.onmessage = (e) => {\r\n this._depthMix = e.data.depthMix;\r\n const indexMix = new Uint32Array(e.data.depthMix.buffer);\r\n for (let j = 0; j < this._vertexCount; j++) {\r\n splatIndex[j] = indexMix[2 * j];\r\n }\r\n this.thinInstanceBufferUpdated(\"splatIndex\");\r\n this._canPostToWorker = true;\r\n };\r\n }\r\n\r\n private _getTextureSize(length: number): Vector2 {\r\n const engine = this._scene.getEngine();\r\n const width = engine.getCaps().maxTextureSize;\r\n\r\n let height = 1;\r\n\r\n if (engine.webGLVersion === 1 && !engine.isWebGPU) {\r\n while (width * height < length) {\r\n height *= 2;\r\n }\r\n } else {\r\n height = Math.ceil(length / width);\r\n }\r\n\r\n if (height > width) {\r\n Logger.Error(\"GaussianSplatting texture size: (\" + width + \", \" + height + \"), maxTextureSize: \" + width);\r\n height = width;\r\n }\r\n\r\n return new Vector2(width, height);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"gaussianSplattingMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY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} from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { SubMesh } from \"../subMesh\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Class used to render a gaussian splatting mesh\r\n */\r\nexport class GaussianSplattingMesh extends Mesh {\r\n private _vertexCount = 0;\r\n private _worker: Nullable<Worker> = null;\r\n private _frameIdLastUpdate = -1;\r\n private _modelViewMatrix = Matrix.Identity();\r\n private _material: Nullable<GaussianSplattingMaterial> = null;\r\n private _depthMix: BigInt64Array;\r\n private _canPostToWorker = true;\r\n private _lastProj: DeepImmutable<Float32Array | number[]>;\r\n private _covariancesATexture: Nullable<BaseTexture> = null;\r\n private _covariancesBTexture: Nullable<BaseTexture> = null;\r\n private _centersTexture: Nullable<BaseTexture> = null;\r\n private _colorsTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets the covariancesA texture\r\n */\r\n public get covariancesATexture() {\r\n return this._covariancesATexture;\r\n }\r\n\r\n /**\r\n * Gets the covariancesB texture\r\n */\r\n public get covariancesBTexture() {\r\n return this._covariancesBTexture;\r\n }\r\n\r\n /**\r\n * Gets the centers texture\r\n */\r\n public get centersTexture() {\r\n return this._centersTexture;\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n public get colorsTexture() {\r\n return this._colorsTexture;\r\n }\r\n\r\n /**\r\n * Creates a new gaussian splatting mesh\r\n * @param name defines the name of the mesh\r\n * @param url defines the url to load from (optional)\r\n * @param scene defines the hosting scene (optional)\r\n */\r\n constructor(name: string, url: Nullable<string> = null, scene: Nullable<Scene> = null) {\r\n super(name, scene);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];\r\n vertexData.indices = [0, 1, 2, 0, 2, 3];\r\n vertexData.applyToMesh(this);\r\n\r\n this.subMeshes = [];\r\n new SubMesh(0, 0, 4, 0, 6, this);\r\n\r\n this.doNotSyncBoundingInfo = true;\r\n this.setEnabled(false);\r\n\r\n this._lastProj = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\r\n\r\n if (url) {\r\n this.loadFileAsync(url);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the class name\r\n * @returns \"GaussianSplattingMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GaussianSplattingMesh\";\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (splats) within the mesh\r\n * @returns the total number of vertices\r\n */\r\n public getTotalVertices(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager\r\n * @param subMesh defines the subMesh to render\r\n * @param enableAlphaMode defines if alpha mode can be changed\r\n * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering\r\n * @returns the current mesh\r\n */\r\n public render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh {\r\n if (!this.material) {\r\n this._material = new GaussianSplattingMaterial(this.name + \"_material\", this._scene);\r\n this.material = this._material;\r\n }\r\n\r\n const frameId = this.getScene().getFrameId();\r\n if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {\r\n this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);\r\n\r\n const dot = this._lastProj[2] * this._modelViewMatrix.m[2] + this._lastProj[6] * this._modelViewMatrix.m[6] + this._lastProj[10] * this._modelViewMatrix.m[10];\r\n if (Math.abs(dot - 1) >= 0.01) {\r\n this._frameIdLastUpdate = frameId;\r\n this._canPostToWorker = false;\r\n this._lastProj = this._modelViewMatrix.m.slice(0);\r\n this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix }, [this._depthMix.buffer]);\r\n }\r\n }\r\n\r\n return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);\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 public static ConvertPLYToSplat(data: ArrayBuffer): ArrayBuffer {\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 return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![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 };\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.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);\r\n return new ArrayBuffer(0);\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 default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\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 \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\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 return buffer;\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian Splatting array buffer asynchronously\r\n * @param data arraybuffer containing splat file\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n\r\n public loadDataAsync(data: ArrayBuffer): Promise<void> {\r\n return Promise.resolve(this._loadData(data));\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian or .ply Splatting file asynchronously\r\n * @param url path to the splat file to load\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n public loadFileAsync(url: string): Promise<void> {\r\n return Tools.LoadFileAsync(url, true).then((data) => {\r\n this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));\r\n });\r\n }\r\n\r\n /**\r\n * Releases resources associated with this mesh.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n */\r\n public dispose(doNotRecurse?: boolean): void {\r\n this._covariancesATexture?.dispose();\r\n this._covariancesBTexture?.dispose();\r\n this._centersTexture?.dispose();\r\n this._colorsTexture?.dispose();\r\n\r\n this._covariancesATexture = null;\r\n this._covariancesBTexture = null;\r\n this._centersTexture = null;\r\n this._colorsTexture = null;\r\n\r\n this._material?.dispose(false, true);\r\n this._material = null;\r\n\r\n this._worker?.terminate();\r\n this._worker = null;\r\n\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n private static _CreateWorker = function (self: Worker) {\r\n let vertexCount = 0;\r\n let positions: Float32Array;\r\n let depthMix: BigInt64Array;\r\n let indices: Uint32Array;\r\n let floatMix: Float32Array;\r\n\r\n self.onmessage = (e: any) => {\r\n // updated on init\r\n if (e.data.positions) {\r\n positions = e.data.positions;\r\n vertexCount = e.data.vertexCount;\r\n }\r\n // udpate on view changed\r\n else {\r\n const viewProj = e.data.view;\r\n if (!positions || !viewProj) {\r\n // Sanity check, it shouldn't happen!\r\n throw new Error(\"positions or view is not defined!\");\r\n }\r\n\r\n depthMix = e.data.depthMix;\r\n indices = new Uint32Array(depthMix.buffer);\r\n floatMix = new Float32Array(depthMix.buffer);\r\n\r\n // Sort\r\n for (let j = 0; j < vertexCount; j++) {\r\n indices[2 * j] = j;\r\n }\r\n\r\n for (let j = 0; j < vertexCount; j++) {\r\n floatMix[2 * j + 1] = 10000 - (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]);\r\n }\r\n\r\n depthMix.sort();\r\n\r\n self.postMessage({ depthMix }, [depthMix.buffer]);\r\n }\r\n };\r\n };\r\n\r\n private _loadData(data: ArrayBuffer): void {\r\n if (!data.byteLength) {\r\n return;\r\n }\r\n // Parse the data\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(uBuffer.buffer);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n this._vertexCount = vertexCount;\r\n\r\n const textureSize = this._getTextureSize(vertexCount);\r\n const textureLength = textureSize.x * textureSize.y;\r\n\r\n const positions = new Float32Array(3 * textureLength);\r\n const covA = new Float32Array(3 * textureLength);\r\n const covB = new Float32Array(3 * textureLength);\r\n\r\n const matrixRotation = TmpVectors.Matrix[0];\r\n const matrixScale = TmpVectors.Matrix[1];\r\n const quaternion = TmpVectors.Quaternion[0];\r\n\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\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\r\n positions[3 * i + 0] = x;\r\n positions[3 * i + 1] = y;\r\n positions[3 * i + 2] = z;\r\n\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n\r\n quaternion.set(\r\n (uBuffer[32 * i + 28 + 1] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 2] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 3] - 128) / 128,\r\n -(uBuffer[32 * i + 28 + 0] - 128) / 128\r\n );\r\n quaternion.toRotationMatrix(matrixRotation);\r\n\r\n Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);\r\n\r\n const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;\r\n\r\n covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];\r\n covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];\r\n covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];\r\n covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];\r\n covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];\r\n covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];\r\n }\r\n\r\n // Update the mesh\r\n const binfo = this.getBoundingInfo();\r\n binfo.reConstruct(minimum, maximum, this.getWorldMatrix());\r\n binfo.isLocked = true;\r\n\r\n this.forcedInstanceCount = this._vertexCount;\r\n this.setEnabled(true);\r\n\r\n const splatIndex = new Float32Array(this._vertexCount * 1);\r\n\r\n this.thinInstanceSetBuffer(\"splatIndex\", splatIndex, 1, false);\r\n\r\n // Update the material\r\n const createTextureFromData = (data: Float32Array, width: number, height: number, format: number) => {\r\n return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);\r\n };\r\n\r\n const convertRgbToRgba = (rgb: Float32Array) => {\r\n const count = rgb.length / 3;\r\n const rgba = new Float32Array(count * 4);\r\n for (let i = 0; i < count; ++i) {\r\n rgba[i * 4 + 0] = rgb[i * 3 + 0];\r\n rgba[i * 4 + 1] = rgb[i * 3 + 1];\r\n rgba[i * 4 + 2] = rgb[i * 3 + 2];\r\n rgba[i * 4 + 3] = 1.0;\r\n }\r\n return rgba;\r\n };\r\n\r\n const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);\r\n for (let i = 0; i < this._vertexCount; ++i) {\r\n colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;\r\n colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;\r\n colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;\r\n colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;\r\n }\r\n\r\n this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._centersTexture = createTextureFromData(convertRgbToRgba(positions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n\r\n // Start the worker thread\r\n this._worker?.terminate();\r\n this._worker = new Worker(\r\n URL.createObjectURL(\r\n new Blob([\"(\", GaussianSplattingMesh._CreateWorker.toString(), \")(self)\"], {\r\n type: \"application/javascript\",\r\n })\r\n )\r\n );\r\n\r\n this._depthMix = new BigInt64Array(vertexCount);\r\n\r\n this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);\r\n\r\n this._worker.onmessage = (e) => {\r\n this._depthMix = e.data.depthMix;\r\n const indexMix = new Uint32Array(e.data.depthMix.buffer);\r\n for (let j = 0; j < this._vertexCount; j++) {\r\n splatIndex[j] = indexMix[2 * j];\r\n }\r\n this.thinInstanceBufferUpdated(\"splatIndex\");\r\n this._canPostToWorker = true;\r\n };\r\n }\r\n\r\n private _getTextureSize(length: number): Vector2 {\r\n const engine = this._scene.getEngine();\r\n const width = engine.getCaps().maxTextureSize;\r\n\r\n let height = 1;\r\n\r\n if (engine.webGLVersion === 1 && !engine.isWebGPU) {\r\n while (width * height < length) {\r\n height *= 2;\r\n }\r\n } else {\r\n height = Math.ceil(length / width);\r\n }\r\n\r\n if (height > width) {\r\n Logger.Error(\"GaussianSplatting texture size: (\" + width + \", \" + height + \"), maxTextureSize: \" + width);\r\n height = width;\r\n }\r\n\r\n return new Vector2(width, height);\r\n }\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Vector3 } from "../Maths/math.vector";
2
- import type { PhysicsShape } from "./v2";
2
+ import type { PhysicsShape } from "./v2/physicsShape";
3
3
  import type { PhysicsBody } from "./v2/physicsBody";
4
4
  /**
5
5
  * Base class for results of casts.
@@ -1 +1 @@
1
- {"version":3,"file":"castingResult.js","sourceRoot":"","sources":["../../../../dev/core/src/Physics/castingResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAI/C;;GAEG;AACH,MAAM,OAAO,aAAa;IAA1B;QACY,YAAO,GAAY,KAAK,CAAC;QACvB,eAAU,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACrC,cAAS,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACtC,mBAAc,GAAW,CAAC,CAAC,CAAC;IAsExC,CAAC;IAtDG;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,SAAe,EAAE,QAAc,EAAE,aAAsB;QACrE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,cAAc,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;QAEzB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"../Maths/math.vector\";\r\nimport type { PhysicsShape } from \"./v2\";\r\nimport type { PhysicsBody } from \"./v2/physicsBody\";\r\n\r\n/**\r\n * Base class for results of casts.\r\n */\r\nexport class CastingResult {\r\n private _hasHit: boolean = false;\r\n protected _hitNormal: Vector3 = Vector3.Zero();\r\n protected _hitPoint: Vector3 = Vector3.Zero();\r\n private _triangleIndex: number = -1;\r\n\r\n /**\r\n * The Physics body that the query hit.\r\n */\r\n public body?: PhysicsBody;\r\n /**\r\n * The body Index in case the Physics body is using instances\r\n */\r\n public bodyIndex?: number;\r\n\r\n /**\r\n * The shape hit by the query.\r\n */\r\n public shape?: PhysicsShape;\r\n\r\n /**\r\n * Gets the hit point.\r\n */\r\n get hitPoint(): Vector3 {\r\n return this._hitPoint;\r\n }\r\n /**\r\n * Gets the hit normal.\r\n */\r\n get hitNormal(): Vector3 {\r\n return this._hitNormal;\r\n }\r\n /**\r\n * Gets if there was a hit\r\n */\r\n get hasHit(): boolean {\r\n return this._hasHit;\r\n }\r\n\r\n /*\r\n * The index of the original triangle which was hit. Will be -1 if contact point is not on a mesh shape\r\n */\r\n get triangleIndex(): number {\r\n return this._triangleIndex;\r\n }\r\n\r\n /**\r\n * Sets the hit data\r\n * @param hitNormal defines the normal in world space\r\n * @param hitPoint defines the point in world space\r\n * @param triangleIndex defines the index of the triangle in case of mesh shape\r\n */\r\n public setHitData(hitNormal: IXYZ, hitPoint: IXYZ, triangleIndex?: number) {\r\n this._hasHit = true;\r\n this._hitNormal.set(hitNormal.x, hitNormal.y, hitNormal.z);\r\n this._hitPoint.set(hitPoint.x, hitPoint.y, hitPoint.z);\r\n this._triangleIndex = triangleIndex ?? -1;\r\n }\r\n\r\n /**\r\n * Resets all the values to default\r\n */\r\n public reset() {\r\n this._hasHit = false;\r\n\r\n this._hitNormal.setAll(0);\r\n this._hitPoint.setAll(0);\r\n this._triangleIndex = -1;\r\n\r\n this.body = undefined;\r\n this.bodyIndex = undefined;\r\n\r\n this.shape = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Interface for the size containing width and height\r\n */\r\ninterface IXYZ {\r\n /**\r\n * X\r\n */\r\n x: number;\r\n\r\n /**\r\n * Y\r\n */\r\n y: number;\r\n\r\n /**\r\n * Z\r\n */\r\n z: number;\r\n}\r\n"]}
1
+ {"version":3,"file":"castingResult.js","sourceRoot":"","sources":["../../../../dev/core/src/Physics/castingResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAI/C;;GAEG;AACH,MAAM,OAAO,aAAa;IAA1B;QACY,YAAO,GAAY,KAAK,CAAC;QACvB,eAAU,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACrC,cAAS,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACtC,mBAAc,GAAW,CAAC,CAAC,CAAC;IAsExC,CAAC;IAtDG;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,SAAe,EAAE,QAAc,EAAE,aAAsB;QACrE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,cAAc,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;QAEzB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"../Maths/math.vector\";\r\nimport type { PhysicsShape } from \"./v2/physicsShape\";\r\nimport type { PhysicsBody } from \"./v2/physicsBody\";\r\n\r\n/**\r\n * Base class for results of casts.\r\n */\r\nexport class CastingResult {\r\n private _hasHit: boolean = false;\r\n protected _hitNormal: Vector3 = Vector3.Zero();\r\n protected _hitPoint: Vector3 = Vector3.Zero();\r\n private _triangleIndex: number = -1;\r\n\r\n /**\r\n * The Physics body that the query hit.\r\n */\r\n public body?: PhysicsBody;\r\n /**\r\n * The body Index in case the Physics body is using instances\r\n */\r\n public bodyIndex?: number;\r\n\r\n /**\r\n * The shape hit by the query.\r\n */\r\n public shape?: PhysicsShape;\r\n\r\n /**\r\n * Gets the hit point.\r\n */\r\n get hitPoint(): Vector3 {\r\n return this._hitPoint;\r\n }\r\n /**\r\n * Gets the hit normal.\r\n */\r\n get hitNormal(): Vector3 {\r\n return this._hitNormal;\r\n }\r\n /**\r\n * Gets if there was a hit\r\n */\r\n get hasHit(): boolean {\r\n return this._hasHit;\r\n }\r\n\r\n /*\r\n * The index of the original triangle which was hit. Will be -1 if contact point is not on a mesh shape\r\n */\r\n get triangleIndex(): number {\r\n return this._triangleIndex;\r\n }\r\n\r\n /**\r\n * Sets the hit data\r\n * @param hitNormal defines the normal in world space\r\n * @param hitPoint defines the point in world space\r\n * @param triangleIndex defines the index of the triangle in case of mesh shape\r\n */\r\n public setHitData(hitNormal: IXYZ, hitPoint: IXYZ, triangleIndex?: number) {\r\n this._hasHit = true;\r\n this._hitNormal.set(hitNormal.x, hitNormal.y, hitNormal.z);\r\n this._hitPoint.set(hitPoint.x, hitPoint.y, hitPoint.z);\r\n this._triangleIndex = triangleIndex ?? -1;\r\n }\r\n\r\n /**\r\n * Resets all the values to default\r\n */\r\n public reset() {\r\n this._hasHit = false;\r\n\r\n this._hitNormal.setAll(0);\r\n this._hitPoint.setAll(0);\r\n this._triangleIndex = -1;\r\n\r\n this.body = undefined;\r\n this.bodyIndex = undefined;\r\n\r\n this.shape = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Interface for the size containing width and height\r\n */\r\ninterface IXYZ {\r\n /**\r\n * X\r\n */\r\n x: number;\r\n\r\n /**\r\n * Y\r\n */\r\n y: number;\r\n\r\n /**\r\n * Z\r\n */\r\n z: number;\r\n}\r\n"]}
@@ -104,6 +104,10 @@ export interface IWebXRTeleportationOptions {
104
104
  * Meshes that the teleportation ray cannot go through
105
105
  */
106
106
  pickBlockerMeshes?: AbstractMesh[];
107
+ /**
108
+ * define an optional predicate to select which meshes should block the teleportation ray
109
+ */
110
+ blockerMeshesPredicate?: (mesh: AbstractMesh) => boolean;
107
111
  /**
108
112
  * Should the teleportation ray be blocked by all of the scene's pickable meshes?
109
113
  * Defaults to false
@@ -131,6 +131,8 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
131
131
  currentRotation: 0,
132
132
  baseRotation: 0,
133
133
  blocked: false,
134
+ initialHit: false,
135
+ mainComponentUsed: false,
134
136
  },
135
137
  };
136
138
  const controllerData = this._controllers[xrController.uniqueId];
@@ -147,6 +149,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
147
149
  if (!mainComponent) {
148
150
  return;
149
151
  }
152
+ controllerData.teleportationState.mainComponentUsed = true;
150
153
  controllerData.teleportationComponent = mainComponent;
151
154
  controllerData.onButtonChangedObserver = mainComponent.onButtonStateChangedObservable.add(() => {
152
155
  if (!this.teleportationEnabled) {
@@ -155,6 +158,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
155
158
  const teleportLocal = () => {
156
159
  // simulate "forward" thumbstick push
157
160
  controllerData.teleportationState.forward = true;
161
+ controllerData.teleportationState.initialHit = false;
158
162
  this._currentTeleportationControllerId = controllerData.xrController.uniqueId;
159
163
  controllerData.teleportationState.baseRotation = this._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y;
160
164
  controllerData.teleportationState.currentRotation = 0;
@@ -294,8 +298,12 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
294
298
  }
295
299
  }
296
300
  else {
301
+ controllerData.teleportationState.mainComponentUsed = true;
302
+ let breakObserver = false;
297
303
  const teleportLocal = () => {
304
+ this._currentTeleportationControllerId = controllerData.xrController.uniqueId;
298
305
  controllerData.teleportationState.forward = true;
306
+ controllerData.teleportationState.initialHit = false;
299
307
  controllerData.teleportationState.baseRotation = this._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y;
300
308
  controllerData.teleportationState.currentRotation = 0;
301
309
  const timeToSelect = this._options.timeToTeleport || 3000;
@@ -311,7 +319,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
311
319
  };
312
320
  this._xrSessionManager.scene.onPointerObservable.add((pointerInfo) => {
313
321
  if (pointerInfo.type === PointerEventTypes.POINTERDOWN) {
314
- this._currentTeleportationControllerId = controllerData.xrController.uniqueId;
322
+ breakObserver = false;
315
323
  // check if start time is defined
316
324
  if (this._options.timeToTeleportStart) {
317
325
  setAndStartTimer({
@@ -323,6 +331,13 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
323
331
  teleportLocal();
324
332
  }
325
333
  },
334
+ breakCondition: () => {
335
+ if (breakObserver) {
336
+ breakObserver = false;
337
+ return true;
338
+ }
339
+ return false;
340
+ },
326
341
  });
327
342
  }
328
343
  else {
@@ -330,6 +345,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
330
345
  }
331
346
  }
332
347
  else if (pointerInfo.type === PointerEventTypes.POINTERUP) {
348
+ breakObserver = true;
333
349
  controllerData.teleportationState.forward = false;
334
350
  this._currentTeleportationControllerId = "";
335
351
  }
@@ -511,6 +527,9 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
511
527
  // first check if direct ray possible
512
528
  // pick grounds that are LOWER only. upper will use parabolic path
513
529
  const pick = scene.pickWithRay(this._tmpRay, (o) => {
530
+ if (this._options.blockerMeshesPredicate && this._options.blockerMeshesPredicate(o)) {
531
+ return true;
532
+ }
514
533
  if (this._options.blockAllPickableMeshes && o.isPickable) {
515
534
  return true;
516
535
  }
@@ -526,12 +545,17 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
526
545
  });
527
546
  const floorMeshPicked = pick && pick.pickedMesh && this._floorMeshes.indexOf(pick.pickedMesh) !== -1;
528
547
  if (pick && pick.pickedMesh && !floorMeshPicked) {
548
+ if (controllerData.teleportationState.mainComponentUsed && !controllerData.teleportationState.initialHit) {
549
+ controllerData.teleportationState.forward = false;
550
+ return;
551
+ }
529
552
  controllerData.teleportationState.blocked = true;
530
553
  this._setTargetMeshVisibility(false, false, controlSelectionFeature);
531
554
  this._showParabolicPath(pick);
532
555
  return;
533
556
  }
534
557
  else if (pick && pick.pickedPoint) {
558
+ controllerData.teleportationState.initialHit = true;
535
559
  controllerData.teleportationState.blocked = false;
536
560
  hitPossible = true;
537
561
  this._setTargetMeshPosition(pick);
@@ -552,6 +576,9 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
552
576
  this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction);
553
577
  this._tmpRay.direction.normalize();
554
578
  const pick = scene.pickWithRay(this._tmpRay, (o) => {
579
+ if (this._options.blockerMeshesPredicate && this._options.blockerMeshesPredicate(o)) {
580
+ return true;
581
+ }
555
582
  if (this._options.blockAllPickableMeshes && o.isPickable) {
556
583
  return true;
557
584
  }
@@ -563,12 +590,17 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
563
590
  });
564
591
  const floorMeshPicked = pick && pick.pickedMesh && this._floorMeshes.indexOf(pick.pickedMesh) !== -1;
565
592
  if (pick && pick.pickedMesh && !floorMeshPicked) {
593
+ if (controllerData.teleportationState.mainComponentUsed && !controllerData.teleportationState.initialHit) {
594
+ controllerData.teleportationState.forward = false;
595
+ return;
596
+ }
566
597
  controllerData.teleportationState.blocked = true;
567
598
  this._setTargetMeshVisibility(false, false, controlSelectionFeature);
568
599
  this._showParabolicPath(pick);
569
600
  return;
570
601
  }
571
602
  else if (pick && pick.pickedPoint) {
603
+ controllerData.teleportationState.initialHit = true;
572
604
  controllerData.teleportationState.blocked = false;
573
605
  hitPossible = true;
574
606
  this._setTargetMeshPosition(pick);