@jdultra/threedtiles 14.0.25 → 14.0.26

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PointsManager.worker-CsuBSjAh.js","sources":["../src/splats/radix/wasm_sorter.js","../src/splats/PointsManager.js","../src/splats/PointsManager.worker.js"],"sourcesContent":["let wasm;\n\nlet cachedUint32ArrayMemory0 = null;\n\nfunction getUint32ArrayMemory0() {\n if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {\n cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);\n }\n return cachedUint32ArrayMemory0;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nfunction passArray32ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 4, 4) >>> 0;\n getUint32ArrayMemory0().set(arg, ptr / 4);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction getArrayU32FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);\n}\n/**\n * Radix Sort implementation for sorting indices based on distances.\n * Both `indices` and `distances` should have the same length.\n * Returns a new vector of sorted indices in descending order based on distances.\n * @param {Uint32Array} indices\n * @param {Uint32Array} distances\n * @returns {Uint32Array}\n */\nexport function radix_sort_indices(indices, distances) {\n const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray32ToWasm0(distances, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.radix_sort_indices(ptr0, len0, ptr1, len1);\n var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);\n return v3;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbindgen_init_externref_table = function() {\n const table = wasm.__wbindgen_export_0;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n ;\n };\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedUint32ArrayMemory0 = null;\n\n\n wasm.__wbindgen_start();\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('wasm_sorter_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\n","import init, { radix_sort_indices } from './radix/wasm_sorter.js';\r\n\r\nconst buffer = new ArrayBuffer(4);\r\nconst floatView = new Float32Array(buffer);\r\nconst uintView = new Uint32Array(buffer);\r\n\r\nclass PointsManager {\r\n constructor(sortCallback) {\r\n this.points = new Float32Array(4096 * 3);\r\n this.distances = new Uint32Array(4096);\r\n this.indexes = new Uint32Array(4096);\r\n this.pointSets = new Map(); // Map<number, object>\r\n this.numUsed = 0;\r\n this.sortOngoing = false;\r\n this.sortCallback = sortCallback;\r\n this.sortPromise = Promise.resolve();\r\n }\r\n\r\n\r\n\r\n hidePoints(insertionIndex) {\r\n //console.log(\"hide\");\r\n const pointSet = this.pointSets.get(insertionIndex);\r\n if (pointSet.used) {\r\n pointSet.used = false;\r\n }\r\n }\r\n removePoints(insertionIndex) {\r\n /* console.log(\"remove\"); */\r\n const pointSet = this.pointSets.get(insertionIndex);\r\n if (pointSet.used) {\r\n pointSet.used = false;\r\n }\r\n\r\n this.pointSets.delete(insertionIndex);\r\n\r\n // Determine newLength based on remaining points\r\n let newLength = 0;\r\n for (const [key, aPointSet] of this.pointSets.entries()) {\r\n if (key + aPointSet.length > newLength) {\r\n newLength = key + aPointSet.length;\r\n }\r\n }\r\n\r\n }\r\n showPoints(insertionIndex) {\r\n /* console.log(\"show\"); */\r\n const pointSet = this.pointSets.get(insertionIndex);\r\n if (!pointSet.used) {\r\n pointSet.used = true;\r\n }\r\n\r\n }\r\n\r\n resizeArrays(newLength) {\r\n\r\n if (isNaN(newLength)) {\r\n console.log(\"hit max splats\")\r\n }\r\n //console.log(newLength)\r\n if (newLength > this.points.length) {\r\n newLength = Math.max(this.points.length * 2, newLength);\r\n // Resize points array\r\n const newPoints = new Float32Array(newLength);\r\n newPoints.set(this.points, 0);\r\n this.points = newPoints;\r\n\r\n // Resize distances array\r\n const newNumPoints = Math.floor(newLength / 3);\r\n const newDistances = new Uint32Array(newNumPoints);\r\n newDistances.set(this.distances, 0);\r\n this.distances = newDistances;\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n addBatchesOffsetStrideCount(positions, insertionIndexes, offset, stride, batchSize) {\r\n\r\n const newLength = Math.max(this.points.length, insertionIndexes[insertionIndexes.length - 1] + batchSize * 3);\r\n\r\n this.resizeArrays(newLength);\r\n for (let batchIndex = 0; batchIndex < insertionIndexes.length; batchIndex++) {\r\n\r\n const insertionIndex = insertionIndexes[batchIndex];\r\n const start = Math.floor(insertionIndex / 3);\r\n const batchPositionStartIndex = batchIndex * batchSize * stride;\r\n const batchNumPoints = Math.min((positions.length - batchPositionStartIndex) / stride, batchSize);\r\n\r\n\r\n for (let i = 0; i < batchNumPoints; i++) {\r\n\r\n this.points[insertionIndex + i * 3] = positions[i * stride + offset + batchPositionStartIndex]\r\n this.points[insertionIndex + i * 3 + 1] = positions[i * stride + offset + batchPositionStartIndex + 1]\r\n this.points[insertionIndex + i * 3 + 2] = positions[i * stride + offset + batchPositionStartIndex + 2]\r\n\r\n }\r\n this.pointSets.set(insertionIndex, { length: batchNumPoints * 3, used: false });\r\n\r\n\r\n }\r\n\r\n\r\n }\r\n\r\n\r\n getFrustumPlanes(viewProj, margin = 1.2) { \r\n const p = new Float32Array(24);\r\n let i = 0;\r\n \r\n const emit = (a, b, c, d, useMargin) => {\r\n const invLen = 1 / Math.hypot(a, b, c);\r\n p[i++] = a * invLen; // Nx\r\n p[i++] = b * invLen; // Ny\r\n p[i++] = c * invLen; // Nz\r\n \r\n let d_normalized = d * invLen; // D_orig\r\n \r\n if (useMargin && margin !== 1.0) {\r\n const shift_amount = (1.0-margin);\r\n d_normalized -= shift_amount; // D_new = D_orig - shift_amount\r\n }\r\n p[i++] = d_normalized; // Store the (potentially shifted) D\r\n };\r\n \r\n // a,b,c,d args useMargin\r\n emit(viewProj[3] + viewProj[0], viewProj[7] + viewProj[4], viewProj[11] + viewProj[8], viewProj[15] + viewProj[12], true); // left\r\n emit(viewProj[3] - viewProj[0], viewProj[7] - viewProj[4], viewProj[11] - viewProj[8], viewProj[15] - viewProj[12], true); // right\r\n emit(viewProj[3] + viewProj[1], viewProj[7] + viewProj[5], viewProj[11] + viewProj[9], viewProj[15] + viewProj[13], true); // bottom\r\n emit(viewProj[3] - viewProj[1], viewProj[7] - viewProj[5], viewProj[11] - viewProj[9], viewProj[15] - viewProj[13], true); // top\r\n emit(viewProj[3] + viewProj[2], viewProj[7] + viewProj[6], viewProj[11] + viewProj[10], viewProj[15] + viewProj[14], false); // near\r\n emit(viewProj[3] - viewProj[2], viewProj[7] - viewProj[6], viewProj[11] - viewProj[10], viewProj[15] + viewProj[14], false); // far\r\n \r\n return p;\r\n }\r\n\r\n computeDistances(x, y, z,vpm) {\r\n \r\n // Determine how many points are used across visible sets to size working arrays\r\n const keys = Array.from(this.pointSets.keys());\r\n const numKeys = keys.length;\r\n let planes;\r\n if(!!vpm){\r\n planes = this.getFrustumPlanes(vpm);\r\n }\r\n let needed = 0;\r\n for (let i = 0; i < numKeys; i++) {\r\n const key = keys[i];\r\n const pointSet = this.pointSets.get(key);\r\n if (!pointSet.used) continue;\r\n needed += Math.floor(pointSet.length / 3);\r\n }\r\n \r\n // Ensure capacity without excessive reallocation (grow to next power-of-two)\r\n const ensureCapacity = (arr, min) => {\r\n if (!arr || arr.length < min) {\r\n let cap = arr ? arr.length : 0;\r\n cap = Math.max(1024, cap);\r\n while (cap < min) cap <<= 1;\r\n return new Uint32Array(cap);\r\n }\r\n return arr;\r\n };\r\n this.indexes = ensureCapacity(this.indexes, needed);\r\n this.distances = ensureCapacity(this.distances, needed);\r\n \r\n // Fill working arrays for actually visible points\r\n let c = 0;\r\n for (let i = 0; i < numKeys; i++) {\r\n const key = keys[i];\r\n const keyBase = Math.floor(key / 3);\r\n const pointSet = this.pointSets.get(key);\r\n if (!pointSet.used) continue;\r\n const length = Math.floor(pointSet.length / 3);\r\n \r\n for (let j = 0; j < length; j++) {\r\n const idx = key + (j * 3);\r\n const vx = this.points[idx];\r\n const vy = this.points[idx + 1];\r\n const vz = this.points[idx + 2];\r\n \r\n // frustum culling //\r\n if(planes){\r\n let visible = true;\r\n for (let p = 0; p < 24; p += 4) {\r\n if (vx * planes[p] +\r\n vy * planes[p + 1] +\r\n vz * planes[p + 2] +\r\n planes[p + 3] < 0) {\r\n visible = false;\r\n break;\r\n }\r\n }\r\n if (!visible) continue;\r\n }\r\n \r\n const dx = x - vx;\r\n const dy = y - vy;\r\n const dz = z - vz;\r\n const d = dx * dx + dy * dy + dz * dz;\r\n floatView[0] = d;\r\n this.distances[c] = uintView[0];\r\n this.indexes[c++] = keyBase + j;\r\n }\r\n }\r\n this.numUsed = c;\r\n // Note: keep full-capacity arrays; we will pass subarray views during sort to avoid reallocations.\r\n }\r\n\r\n sort(xyz, vpm, id) {\r\n // Always store the latest sort request\r\n this.pendingSort = { xyz, vpm };\r\n this.pendingID = id;\r\n //console.log(`Received sort request with ID: ${id}`);\r\n\r\n // If no sort is currently ongoing, start processing\r\n if (!this.sortOngoing) {\r\n this.sortOngoing = true;\r\n this.processSortQueue();\r\n }\r\n }\r\n\r\n // Asynchronous loop to process sort requests sequentially\r\n async processSortQueue() {\r\n if (!this.initialized) {\r\n // Prefer an explicit wasm URL provided by the main thread when the worker is inlined.\r\n const wasmUrl = (typeof globalThis !== 'undefined' && globalThis.__WASM_SORTER_URL__) ? globalThis.__WASM_SORTER_URL__ : undefined;\r\n await init(wasmUrl);\r\n this.initialized = true;\r\n }\r\n while (this.pendingSort) {\r\n const { xyz, vpm } = this.pendingSort;\r\n const currentID = this.pendingID;\r\n\r\n // Clear the pending sort to capture any new requests during processing\r\n this.pendingSort = null;\r\n this.pendingID = null;\r\n\r\n //console.log(`Starting sort with ID: ${currentID}`);\r\n\r\n \r\n\r\n // Perform the synchronous sort operations\r\n\r\n this.computeDistances(xyz[0], xyz[1], xyz[2], vpm);\r\n //console.log((performance.now() - start)+' ms');\r\n\r\n //console.log(this.indexes.length)\r\n const start = performance.now();\r\n // Sort only the used portion to minimize memory and avoid allocating giant arrays\r\n const sorted = radix_sort_indices(\r\n this.indexes.subarray(0, this.numUsed),\r\n this.distances.subarray(0, this.numUsed)\r\n );\r\n this.indexes = sorted;\r\n \r\n \r\n const duration = performance.now() - start;\r\n //console.log(`Sort with ID: ${currentID} completed in ${duration.toFixed(2)}ms`);\r\n \r\n // Callback after sorting is done\r\n this.sortCallback(this.indexes, this.numUsed, currentID, duration);\r\n\r\n // Yield control to the event loop to handle new incoming sort requests\r\n await new Promise(resolve => setTimeout(resolve, 0));\r\n }\r\n\r\n // No more pending sorts\r\n this.sortOngoing = false;\r\n //console.log(\"No more pending sorts. SortWorker is idle.\");\r\n }\r\n} export { PointsManager }\r\n","import { PointsManager } from \"./PointsManager\";\r\n\r\n/**\r\n * Important: radix_sort_indices returns a Uint32Array view into WebAssembly.Memory.\r\n * You cannot transfer a view backed by WASM memory (detaching it would break the module).\r\n * Therefore we must copy into a standalone ArrayBuffer before postMessage with transfer.\r\n */\r\nconst sortCallback = ((array, numUsed, id, sortPerf) => {\r\n // Copy only the used portion (array should already be length==numUsed)\r\n const copy = new Uint32Array(array.length);\r\n copy.set(array);\r\n postMessage({\r\n order: copy.buffer,\r\n count: numUsed,\r\n id: id,\r\n sortPerf: sortPerf\r\n }, [copy.buffer]);\r\n});\r\nlet pointsManager;\r\nself.onmessage = function (e) {\r\n\r\n try {\r\n\r\n switch (e.data.method) {\r\n \r\n case \"addBatches\":\r\n if (!pointsManager) {\r\n pointsManager = new PointsManager(sortCallback);\r\n }\r\n pointsManager.addBatchesOffsetStrideCount(new Float32Array(e.data.positions), e.data.insertionIndexes, e.data.offset, e.data.stride, e.data.batchSize);\r\n break\r\n case \"hide\":\r\n\r\n if (!!pointsManager) {\r\n pointsManager.hidePoints(e.data.insertionIndex);\r\n }\r\n\r\n break\r\n case \"hideBatches\":\r\n\r\n if (!!pointsManager) {\r\n e.data.insertionIndexes.forEach(insertionIndex => {\r\n pointsManager.hidePoints(insertionIndex);\r\n });\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"show\":\r\n if (!!pointsManager) {\r\n pointsManager.showPoints(e.data.insertionIndex);\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break;\r\n case \"showBatches\":\r\n\r\n if (!!pointsManager) {\r\n e.data.insertionIndexes.forEach(insertionIndex => {\r\n pointsManager.showPoints(insertionIndex);\r\n });\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"remove\":\r\n if (!!pointsManager) {\r\n pointsManager.removePoints(e.data.insertionIndex);\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"removeBatches\":\r\n\r\n if (!!pointsManager) {\r\n e.data.insertionIndexes.forEach(insertionIndex => {\r\n pointsManager.removePoints(insertionIndex);\r\n });\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"sort\":\r\n \r\n if (!!pointsManager) {\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n break\r\n default:\r\n throw new Error(`No method with name ${e.data.method}`)\r\n }\r\n } catch (error) {\r\n postMessage({ error: error.message })\r\n }\r\n}"],"names":["wasm","cachedUint32ArrayMemory0","getUint32ArrayMemory0","WASM_VECTOR_LEN","passArray32ToWasm0","arg","malloc","ptr","getArrayU32FromWasm0","len","radix_sort_indices","indices","distances","ptr0","len0","ptr1","len1","ret","v3","__wbg_load","module","imports","e","bytes","instance","__wbg_get_imports","table","offset","__wbg_finalize_init","__wbg_init","module_or_path","buffer","floatView","uintView","PointsManager","sortCallback","insertionIndex","pointSet","newLength","key","aPointSet","newPoints","newNumPoints","newDistances","positions","insertionIndexes","stride","batchSize","batchIndex","batchPositionStartIndex","batchNumPoints","i","viewProj","margin","p","emit","a","b","c","d","useMargin","invLen","d_normalized","shift_amount","x","y","z","vpm","keys","numKeys","planes","needed","ensureCapacity","arr","min","cap","keyBase","length","j","idx","vx","vy","vz","visible","dx","dy","dz","xyz","id","wasmUrl","init","currentID","start","sorted","duration","resolve","array","numUsed","sortPerf","copy","pointsManager","error"],"mappings":"AAAA,IAAIA,GAEAC,IAA2B;AAE/B,SAASC,IAAwB;AAC7B,UAAID,MAA6B,QAAQA,EAAyB,eAAe,OAC7EA,IAA2B,IAAI,YAAYD,EAAK,OAAO,MAAM,IAE1DC;AACX;AAEA,IAAIE,IAAkB;AAEtB,SAASC,EAAmBC,GAAKC,GAAQ;AACrC,QAAMC,IAAMD,EAAOD,EAAI,SAAS,GAAG,CAAC,MAAM;AAC1C,SAAAH,EAAqB,EAAG,IAAIG,GAAKE,IAAM,CAAC,GACxCJ,IAAkBE,EAAI,QACfE;AACX;AAEA,SAASC,EAAqBD,GAAKE,GAAK;AACpC,SAAAF,IAAMA,MAAQ,GACPL,EAAqB,EAAG,SAASK,IAAM,GAAGA,IAAM,IAAIE,CAAG;AAClE;AASO,SAASC,EAAmBC,GAASC,GAAW;AACnD,QAAMC,IAAOT,EAAmBO,GAASX,EAAK,iBAAiB,GACzDc,IAAOX,GACPY,IAAOX,EAAmBQ,GAAWZ,EAAK,iBAAiB,GAC3DgB,IAAOb,GACPc,IAAMjB,EAAK,mBAAmBa,GAAMC,GAAMC,GAAMC,CAAI;AAC1D,MAAIE,IAAKV,EAAqBS,EAAI,CAAC,GAAGA,EAAI,CAAC,CAAC,EAAE,MAAK;AACnD,SAAAjB,EAAK,gBAAgBiB,EAA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AAK;AAED,QAAM8E,KACFA,EAAc,KAAK9E,EAAE,KAAK,KAAKA,EAAE,KAAK,KAAKA,EAAE,KAAK,EAAE;AAExD;AAAA,MACJ;AACI,cAAM,IAAI,MAAM,uBAAuBA,EAAE,KAAK,MAAM,EAAE;AAAA,IACtE;AAAA,EACI,SAAS+E,GAAO;AACZ,gBAAY,EAAE,OAAOA,EAAM,QAAO,CAAE;AAAA,EACxC;AACJ;"}
1
+ {"version":3,"file":"PointsManager.worker-DhBxD-lq.js","sources":["../src/splats/radix/wasm_sorter.js","../src/splats/PointsManager.js","../src/splats/PointsManager.worker.js"],"sourcesContent":["let wasm;\n\nlet cachedUint32ArrayMemory0 = null;\n\nfunction getUint32ArrayMemory0() {\n if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {\n cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);\n }\n return cachedUint32ArrayMemory0;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nfunction passArray32ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 4, 4) >>> 0;\n getUint32ArrayMemory0().set(arg, ptr / 4);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction getArrayU32FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);\n}\n/**\n * Radix Sort implementation for sorting indices based on distances.\n * Both `indices` and `distances` should have the same length.\n * Returns a new vector of sorted indices in descending order based on distances.\n * @param {Uint32Array} indices\n * @param {Uint32Array} distances\n * @returns {Uint32Array}\n */\nexport function radix_sort_indices(indices, distances) {\n const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray32ToWasm0(distances, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.radix_sort_indices(ptr0, len0, ptr1, len1);\n var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);\n return v3;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbindgen_init_externref_table = function() {\n const table = wasm.__wbindgen_export_0;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n ;\n };\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedUint32ArrayMemory0 = null;\n\n\n wasm.__wbindgen_start();\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('wasm_sorter_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\n","import init, { radix_sort_indices } from './radix/wasm_sorter.js';\r\n\r\nconst buffer = new ArrayBuffer(4);\r\nconst floatView = new Float32Array(buffer);\r\nconst uintView = new Uint32Array(buffer);\r\n\r\nclass PointsManager {\r\n constructor(sortCallback) {\r\n this.points = new Float32Array(4096 * 3);\r\n this.distances = new Uint32Array(4096);\r\n this.indexes = new Uint32Array(4096);\r\n this.pointSets = new Map(); // Map<number, object>\r\n this.numUsed = 0;\r\n this.sortOngoing = false;\r\n this.sortCallback = sortCallback;\r\n this.sortPromise = Promise.resolve();\r\n }\r\n\r\n\r\n\r\n hidePoints(insertionIndex) {\r\n //console.log(\"hide\");\r\n const pointSet = this.pointSets.get(insertionIndex);\r\n if (pointSet.used) {\r\n pointSet.used = false;\r\n }\r\n }\r\n removePoints(insertionIndex) {\r\n /* console.log(\"remove\"); */\r\n const pointSet = this.pointSets.get(insertionIndex);\r\n if (pointSet.used) {\r\n pointSet.used = false;\r\n }\r\n\r\n this.pointSets.delete(insertionIndex);\r\n\r\n // Determine newLength based on remaining points\r\n let newLength = 0;\r\n for (const [key, aPointSet] of this.pointSets.entries()) {\r\n if (key + aPointSet.length > newLength) {\r\n newLength = key + aPointSet.length;\r\n }\r\n }\r\n\r\n }\r\n showPoints(insertionIndex) {\r\n /* console.log(\"show\"); */\r\n const pointSet = this.pointSets.get(insertionIndex);\r\n if (!pointSet.used) {\r\n pointSet.used = true;\r\n }\r\n\r\n }\r\n\r\n resizeArrays(newLength) {\r\n\r\n if (isNaN(newLength)) {\r\n console.log(\"hit max splats\")\r\n }\r\n //console.log(newLength)\r\n if (newLength > this.points.length) {\r\n newLength = Math.max(this.points.length * 2, newLength);\r\n // Resize points array\r\n const newPoints = new Float32Array(newLength);\r\n newPoints.set(this.points, 0);\r\n this.points = newPoints;\r\n\r\n // Resize distances array\r\n const newNumPoints = Math.floor(newLength / 3);\r\n const newDistances = new Uint32Array(newNumPoints);\r\n newDistances.set(this.distances, 0);\r\n this.distances = newDistances;\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n addBatchesOffsetStrideCount(positions, insertionIndexes, offset, stride, batchSize) {\r\n\r\n const newLength = Math.max(this.points.length, insertionIndexes[insertionIndexes.length - 1] + batchSize * 3);\r\n\r\n this.resizeArrays(newLength);\r\n for (let batchIndex = 0; batchIndex < insertionIndexes.length; batchIndex++) {\r\n\r\n const insertionIndex = insertionIndexes[batchIndex];\r\n const start = Math.floor(insertionIndex / 3);\r\n const batchPositionStartIndex = batchIndex * batchSize * stride;\r\n const batchNumPoints = Math.min((positions.length - batchPositionStartIndex) / stride, batchSize);\r\n\r\n\r\n for (let i = 0; i < batchNumPoints; i++) {\r\n\r\n this.points[insertionIndex + i * 3] = positions[i * stride + offset + batchPositionStartIndex]\r\n this.points[insertionIndex + i * 3 + 1] = positions[i * stride + offset + batchPositionStartIndex + 1]\r\n this.points[insertionIndex + i * 3 + 2] = positions[i * stride + offset + batchPositionStartIndex + 2]\r\n\r\n }\r\n this.pointSets.set(insertionIndex, { length: batchNumPoints * 3, used: false });\r\n\r\n\r\n }\r\n\r\n\r\n }\r\n\r\n\r\n getFrustumPlanes(viewProj, margin = 1.2) { \r\n const p = new Float32Array(24);\r\n let i = 0;\r\n \r\n const emit = (a, b, c, d, useMargin) => {\r\n const invLen = 1 / Math.hypot(a, b, c);\r\n p[i++] = a * invLen; // Nx\r\n p[i++] = b * invLen; // Ny\r\n p[i++] = c * invLen; // Nz\r\n \r\n let d_normalized = d * invLen; // D_orig\r\n \r\n if (useMargin && margin !== 1.0) {\r\n const shift_amount = (1.0-margin);\r\n d_normalized -= shift_amount; // D_new = D_orig - shift_amount\r\n }\r\n p[i++] = d_normalized; // Store the (potentially shifted) D\r\n };\r\n \r\n // a,b,c,d args useMargin\r\n emit(viewProj[3] + viewProj[0], viewProj[7] + viewProj[4], viewProj[11] + viewProj[8], viewProj[15] + viewProj[12], true); // left\r\n emit(viewProj[3] - viewProj[0], viewProj[7] - viewProj[4], viewProj[11] - viewProj[8], viewProj[15] - viewProj[12], true); // right\r\n emit(viewProj[3] + viewProj[1], viewProj[7] + viewProj[5], viewProj[11] + viewProj[9], viewProj[15] + viewProj[13], true); // bottom\r\n emit(viewProj[3] - viewProj[1], viewProj[7] - viewProj[5], viewProj[11] - viewProj[9], viewProj[15] - viewProj[13], true); // top\r\n emit(viewProj[3] + viewProj[2], viewProj[7] + viewProj[6], viewProj[11] + viewProj[10], viewProj[15] + viewProj[14], false); // near\r\n emit(viewProj[3] - viewProj[2], viewProj[7] - viewProj[6], viewProj[11] - viewProj[10], viewProj[15] + viewProj[14], false); // far\r\n \r\n return p;\r\n }\r\n\r\n computeDistances(x, y, z,vpm) {\r\n \r\n // Determine how many points are used across visible sets to size working arrays\r\n const keys = Array.from(this.pointSets.keys());\r\n const numKeys = keys.length;\r\n let planes;\r\n if(!!vpm){\r\n planes = this.getFrustumPlanes(vpm);\r\n }\r\n let needed = 0;\r\n for (let i = 0; i < numKeys; i++) {\r\n const key = keys[i];\r\n const pointSet = this.pointSets.get(key);\r\n if (!pointSet.used) continue;\r\n needed += Math.floor(pointSet.length / 3);\r\n }\r\n \r\n // Ensure capacity without excessive reallocation (grow to next power-of-two)\r\n const ensureCapacity = (arr, min) => {\r\n if (!arr || arr.length < min) {\r\n let cap = arr ? arr.length : 0;\r\n cap = Math.max(1024, cap);\r\n while (cap < min) cap <<= 1;\r\n return new Uint32Array(cap);\r\n }\r\n return arr;\r\n };\r\n this.indexes = ensureCapacity(this.indexes, needed);\r\n this.distances = ensureCapacity(this.distances, needed);\r\n \r\n // Fill working arrays for actually visible points\r\n let c = 0;\r\n for (let i = 0; i < numKeys; i++) {\r\n const key = keys[i];\r\n const keyBase = Math.floor(key / 3);\r\n const pointSet = this.pointSets.get(key);\r\n if (!pointSet.used) continue;\r\n const length = Math.floor(pointSet.length / 3);\r\n \r\n for (let j = 0; j < length; j++) {\r\n const idx = key + (j * 3);\r\n const vx = this.points[idx];\r\n const vy = this.points[idx + 1];\r\n const vz = this.points[idx + 2];\r\n \r\n // frustum culling //\r\n if(planes){\r\n let visible = true;\r\n for (let p = 0; p < 24; p += 4) {\r\n if (vx * planes[p] +\r\n vy * planes[p + 1] +\r\n vz * planes[p + 2] +\r\n planes[p + 3] < 0) {\r\n visible = false;\r\n break;\r\n }\r\n }\r\n if (!visible) continue;\r\n }\r\n \r\n const dx = x - vx;\r\n const dy = y - vy;\r\n const dz = z - vz;\r\n const d = dx * dx + dy * dy + dz * dz;\r\n floatView[0] = d;\r\n this.distances[c] = uintView[0];\r\n this.indexes[c++] = keyBase + j;\r\n }\r\n }\r\n this.numUsed = c;\r\n // Note: keep full-capacity arrays; we will pass subarray views during sort to avoid reallocations.\r\n }\r\n\r\n sort(xyz, vpm, id) {\r\n // Always store the latest sort request\r\n this.pendingSort = { xyz, vpm };\r\n this.pendingID = id;\r\n //console.log(`Received sort request with ID: ${id}`);\r\n\r\n // If no sort is currently ongoing, start processing\r\n if (!this.sortOngoing) {\r\n this.sortOngoing = true;\r\n this.processSortQueue();\r\n }\r\n }\r\n\r\n // Asynchronous loop to process sort requests sequentially\r\n async processSortQueue() {\r\n if (!this.initialized) {\r\n // Prefer an explicit wasm URL provided by the main thread when the worker is inlined.\r\n const wasmUrl = (typeof globalThis !== 'undefined' && globalThis.__WASM_SORTER_URL__) ? globalThis.__WASM_SORTER_URL__ : undefined;\r\n await init(wasmUrl);\r\n this.initialized = true;\r\n }\r\n while (this.pendingSort) {\r\n const { xyz, vpm } = this.pendingSort;\r\n const currentID = this.pendingID;\r\n\r\n // Clear the pending sort to capture any new requests during processing\r\n this.pendingSort = null;\r\n this.pendingID = null;\r\n\r\n //console.log(`Starting sort with ID: ${currentID}`);\r\n\r\n \r\n\r\n // Perform the synchronous sort operations\r\n\r\n this.computeDistances(xyz[0], xyz[1], xyz[2], vpm);\r\n //console.log((performance.now() - start)+' ms');\r\n\r\n //console.log(this.indexes.length)\r\n const start = performance.now();\r\n // Sort only the used portion to minimize memory and avoid allocating giant arrays\r\n const sorted = radix_sort_indices(\r\n this.indexes.subarray(0, this.numUsed),\r\n this.distances.subarray(0, this.numUsed)\r\n );\r\n this.indexes = sorted;\r\n \r\n \r\n const duration = performance.now() - start;\r\n //console.log(`Sort with ID: ${currentID} completed in ${duration.toFixed(2)}ms`);\r\n \r\n // Callback after sorting is done\r\n this.sortCallback(this.indexes, this.numUsed, currentID, duration);\r\n\r\n // Yield control to the event loop to handle new incoming sort requests\r\n await new Promise(resolve => setTimeout(resolve, 0));\r\n }\r\n\r\n // No more pending sorts\r\n this.sortOngoing = false;\r\n //console.log(\"No more pending sorts. SortWorker is idle.\");\r\n }\r\n} export { PointsManager }\r\n","import { PointsManager } from \"./PointsManager\";\r\n\r\n/**\r\n * Important: radix_sort_indices returns a Uint32Array view into WebAssembly.Memory.\r\n * You cannot transfer a view backed by WASM memory (detaching it would break the module).\r\n * Therefore we must copy into a standalone ArrayBuffer before postMessage with transfer.\r\n */\r\nconst sortCallback = ((array, numUsed, id, sortPerf) => {\r\n // Copy only the used portion (array should already be length==numUsed)\r\n const copy = new Uint32Array(array.length);\r\n copy.set(array);\r\n postMessage({\r\n order: copy.buffer,\r\n count: numUsed,\r\n id: id,\r\n sortPerf: sortPerf\r\n }, [copy.buffer]);\r\n});\r\nlet pointsManager;\r\nself.onmessage = function (e) {\r\n\r\n try {\r\n\r\n switch (e.data.method) {\r\n \r\n case \"addBatches\":\r\n if (!pointsManager) {\r\n pointsManager = new PointsManager(sortCallback);\r\n }\r\n pointsManager.addBatchesOffsetStrideCount(new Float32Array(e.data.positions), e.data.insertionIndexes, e.data.offset, e.data.stride, e.data.batchSize);\r\n break\r\n case \"hide\":\r\n\r\n if (!!pointsManager) {\r\n pointsManager.hidePoints(e.data.insertionIndex);\r\n }\r\n\r\n break\r\n case \"hideBatches\":\r\n\r\n if (!!pointsManager) {\r\n e.data.insertionIndexes.forEach(insertionIndex => {\r\n pointsManager.hidePoints(insertionIndex);\r\n });\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"show\":\r\n if (!!pointsManager) {\r\n pointsManager.showPoints(e.data.insertionIndex);\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break;\r\n case \"showBatches\":\r\n\r\n if (!!pointsManager) {\r\n e.data.insertionIndexes.forEach(insertionIndex => {\r\n pointsManager.showPoints(insertionIndex);\r\n });\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"remove\":\r\n if (!!pointsManager) {\r\n pointsManager.removePoints(e.data.insertionIndex);\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"removeBatches\":\r\n\r\n if (!!pointsManager) {\r\n e.data.insertionIndexes.forEach(insertionIndex => {\r\n pointsManager.removePoints(insertionIndex);\r\n });\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n\r\n break\r\n case \"sort\":\r\n \r\n if (!!pointsManager) {\r\n pointsManager.sort(e.data.xyz, e.data.vpm, e.data.id)\r\n }\r\n break\r\n default:\r\n throw new Error(`No method with name ${e.data.method}`)\r\n }\r\n } catch (error) {\r\n postMessage({ error: error.message })\r\n }\r\n}"],"names":["wasm","cachedUint32ArrayMemory0","getUint32ArrayMemory0","WASM_VECTOR_LEN","passArray32ToWasm0","arg","malloc","ptr","getArrayU32FromWasm0","len","radix_sort_indices","indices","distances","ptr0","len0","ptr1","len1","ret","v3","__wbg_load","module","imports","e","bytes","instance","__wbg_get_imports","table","offset","__wbg_finalize_init","__wbg_init","module_or_path","buffer","floatView","uintView","PointsManager","sortCallback","insertionIndex","pointSet","newLength","key","aPointSet","newPoints","newNumPoints","newDistances","positions","insertionIndexes","stride","batchSize","batchIndex","batchPositionStartIndex","batchNumPoints","i","viewProj","margin","p","emit","a","b","c","d","useMargin","invLen","d_normalized","shift_amount","x","y","z","vpm","keys","numKeys","planes","needed","ensureCapacity","arr","min","cap","keyBase","length","j","idx","vx","vy","vz","visible","dx","dy","dz","xyz","id","wasmUrl","init","currentID","start","sorted","duration","resolve","array","numUsed","sortPerf","copy","pointsManager","error"],"mappings":"AAAA,IAAIA,GAEAC,IAA2B;AAE/B,SAASC,IAAwB;AAC7B,UAAID,MAA6B,QAAQA,EAAyB,eAAe,OAC7EA,IAA2B,IAAI,YAAYD,EAAK,OAAO,MAAM,IAE1DC;AACX;AAEA,IAAIE,IAAkB;AAEtB,SAASC,EAAmBC,GAAKC,GAAQ;AACrC,QAAMC,IAAMD,EAAOD,EAAI,SAAS,GAAG,CAAC,MAAM;AAC1C,SAAAH,EAAqB,EAAG,IAAIG,GAAKE,IAAM,CAAC,GACxCJ,IAAkBE,EAAI,QACfE;AACX;AAEA,SAASC,EAAqBD,GAAKE,GAAK;AACpC,SAAAF,IAAMA,MAAQ,GACPL,EAAqB,EAAG,SAASK,IAAM,GAAGA,IAAM,IAAIE,CAAG;AAClE;AASO,SAASC,EAAmBC,GAASC,GAAW;AACnD,QAAMC,IAAOT,EAAmBO,GAASX,EAAK,iBAAiB,GACzDc,IAAOX,GACPY,IAAOX,EAAmBQ,GAAWZ,EAAK,iBAAiB,GAC3DgB,IAAOb,GACPc,IAAMjB,EAAK,mBAAm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UAAAgE,EAAc,aAAahE,CAAc;AAAA,QAC7C,CAAC,GACDgE,EAAc,KAAK9E,EAAE,KAAK,KAAKA,EAAE,KAAK,KAAKA,EAAE,KAAK,EAAE;AAGxD;AAAA,MACJ,KAAK;AAED,QAAM8E,KACFA,EAAc,KAAK9E,EAAE,KAAK,KAAKA,EAAE,KAAK,KAAKA,EAAE,KAAK,EAAE;AAExD;AAAA,MACJ;AACI,cAAM,IAAI,MAAM,uBAAuBA,EAAE,KAAK,MAAM,EAAE;AAAA,IACtE;AAAA,EACI,SAAS+E,GAAO;AACZ,gBAAY,EAAE,OAAOA,EAAM,QAAO,CAAE;AAAA,EACxC;AACJ;"}
@@ -19,19 +19,13 @@ function f(n, e) {
19
19
  self.addEventListener("message", (n) => {
20
20
  const e = n.data || {}, t = typeof e._envId < "u" ? e._envId : typeof e.replyTo < "u" ? e.replyTo : e.id;
21
21
  try {
22
- switch (e.type) {
23
- case "computeConvexHull": {
24
- const s = e.positions instanceof Float32Array ? e.positions : new Float32Array(e.positions?.buffer || e.positions), r = e.localScale || e.scale || e.local?.s || [1, 1, 1], { hullVertices: o, hullIndices: i } = f(s, r), c = [];
25
- o?.buffer && c.push(o.buffer), i?.buffer, u(t, { vertices: o, indices: i }, c);
26
- break;
27
- }
28
- default: {
29
- u(t, { ok: !1, reason: "unknown message type" });
30
- break;
31
- }
32
- }
22
+ if (e.type === "computeConvexHull") {
23
+ const s = e.positions instanceof Float32Array ? e.positions : new Float32Array(e.positions?.buffer || e.positions), r = e.localScale || e.scale || e.local?.s || [1, 1, 1], { hullVertices: o, hullIndices: i } = f(s, r), c = [];
24
+ o?.buffer && c.push(o.buffer), i?.buffer, u(t, { vertices: o, indices: i }, c);
25
+ } else
26
+ u(t, { ok: !1, reason: "unknown message type" });
33
27
  } catch (s) {
34
28
  a(t, s);
35
29
  }
36
30
  });
37
- //# sourceMappingURL=physicsHelper.worker-Cr8S3sZk.js.map
31
+ //# sourceMappingURL=physicsHelper.worker-D0W6nk9c.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"physicsHelper.worker-Cr8S3sZk.js","sources":["../src/simulation/physicsHelper.worker.js"],"sourcesContent":["// physicsHelper.worker.js\r\n// Helper worker that computes a convex hull from mesh geometry using three.js's ConvexHull.\r\n// - Receives Float32Array positions (and optional Uint32Array indices - not required for hull).\r\n// - Applies optional non-uniform localScale [sx,sy,sz] to vertex positions in-place.\r\n// - Computes convex hull and returns hull vertices (Float32Array) and indices (Uint32Array) to the main thread.\r\n// - Buffer ownership is transferred back to main to minimize memory usage.\r\n\r\n/* No external imports required */\r\n\r\n// Simple reply helpers for request/reply correlation with _envId\r\nfunction ack(id, result = null, transfer = []) {\r\n if (id == null) return;\r\n // Always include replyTo to match main thread envelope handling\r\n postMessage({ replyTo: id, result }, transfer);\r\n}\r\nfunction nack(id, error) {\r\n if (id == null) return;\r\n postMessage({ replyTo: id, error: (error && (error.message || String(error))) || String(error) });\r\n}\r\n\r\n// Compute convex hull input for Rapier from points (Float32Array positions).\r\n// Rapier's ColliderDesc.convexHull computes the hull internally from an arbitrary point cloud,\r\n// so we only need to return a scaled vertex array. No triangle faces are required.\r\nfunction computeHullFromPositions(positions, scale) {\r\n if (!(positions instanceof Float32Array)) {\r\n throw new Error('positions must be a Float32Array');\r\n }\r\n const n = positions.length;\r\n if (n % 3 !== 0) {\r\n throw new Error('positions length must be a multiple of 3');\r\n }\r\n\r\n // Apply in-place scaling to avoid additional copies (positions buffer is owned by this worker).\r\n const sx = (scale && +scale[0]) || 1.0;\r\n const sy = (scale && +scale[1]) || 1.0;\r\n const sz = (scale && +scale[2]) || 1.0;\r\n if (sx !== 1 || sy !== 1 || sz !== 1) {\r\n for (let i = 0; i < n; i += 3) {\r\n positions[i + 0] *= sx;\r\n positions[i + 1] *= sy;\r\n positions[i + 2] *= sz;\r\n }\r\n }\r\n\r\n // Return the scaled point cloud directly; indices are unnecessary for Rapier's convexHull.\r\n const hullVertices = positions;\r\n const hullIndices = null;\r\n return { hullVertices, hullIndices };\r\n}\r\n\r\nself.addEventListener('message', (e) => {\r\n const msg = e.data || {};\r\n const replyId = (typeof msg._envId !== 'undefined') ? msg._envId : (typeof msg.replyTo !== 'undefined' ? msg.replyTo : msg.id);\r\n try {\r\n switch (msg.type) {\r\n case 'computeConvexHull': {\r\n const positions = msg.positions instanceof Float32Array ? msg.positions : new Float32Array(msg.positions?.buffer || msg.positions);\r\n // indices are not strictly needed for hull generation with ConvexHull; accept but ignore for computation.\r\n // If provided and transferred, they will be garbage collected afterward.\r\n const scale = msg.localScale || msg.scale || msg.local?.s || [1, 1, 1];\r\n\r\n const { hullVertices, hullIndices } = computeHullFromPositions(positions, scale);\r\n\r\n // Transfer results back, release incoming buffers by letting them go out of scope.\r\n const transfer = [];\r\n if (hullVertices?.buffer) transfer.push(hullVertices.buffer);\r\n if (hullIndices?.buffer) transfer.push(hullIndices.buffer);\r\n\r\n ack(replyId, { vertices: hullVertices, indices: hullIndices }, transfer);\r\n break;\r\n }\r\n\r\n default: {\r\n ack(replyId, { ok: false, reason: 'unknown message type' });\r\n break;\r\n }\r\n }\r\n } catch (err) {\r\n nack(replyId, err);\r\n }\r\n});"],"names":["ack","id","result","transfer","nack","error","computeHullFromPositions","positions","scale","n","sx","sy","sz","i","e","msg","replyId","hullVertices","hullIndices","err"],"mappings":"AAUA,SAASA,EAAIC,GAAIC,IAAS,MAAMC,IAAW,CAAA,GAAI;AAC7C,EAAIF,KAAM,QAEV,YAAY,EAAE,SAASA,GAAI,QAAAC,EAAM,GAAIC,CAAQ;AAC/C;AACA,SAASC,EAAKH,GAAII,GAAO;AACvB,EAAIJ,KAAM,QACV,YAAY,EAAE,SAASA,GAAI,OAAQI,MAAUA,EAAM,WAAW,OAAOA,CAAK,MAAO,OAAOA,CAAK,EAAC,CAAE;AAClG;AAKA,SAASC,EAAyBC,GAAWC,GAAO;AAClD,MAAI,EAAED,aAAqB;AACzB,UAAM,IAAI,MAAM,kCAAkC;AAEpD,QAAME,IAAIF,EAAU;AAC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,GAAK;AACZ,IAAAf,EAAKY,GAASG,CAAG;AAAA,EACnB;AACF,CAAC;"}
1
+ {"version":3,"file":"physicsHelper.worker-D0W6nk9c.js","sources":["../src/simulation/physicsHelper.worker.js"],"sourcesContent":["// physicsHelper.worker.js\r\n// Helper worker that computes a convex hull from mesh geometry using three.js's ConvexHull.\r\n// - Receives Float32Array positions (and optional Uint32Array indices - not required for hull).\r\n// - Applies optional non-uniform localScale [sx,sy,sz] to vertex positions in-place.\r\n// - Computes convex hull and returns hull vertices (Float32Array) and indices (Uint32Array) to the main thread.\r\n// - Buffer ownership is transferred back to main to minimize memory usage.\r\n\r\n/* No external imports required */\r\n\r\n// Simple reply helpers for request/reply correlation with _envId\r\nfunction ack(id, result = null, transfer = []) {\r\n if (id == null) return;\r\n // Always include replyTo to match main thread envelope handling\r\n postMessage({ replyTo: id, result }, transfer);\r\n}\r\nfunction nack(id, error) {\r\n if (id == null) return;\r\n postMessage({ replyTo: id, error: (error && (error.message || String(error))) || String(error) });\r\n}\r\n\r\n// Compute convex hull input for Rapier from points (Float32Array positions).\r\n// Rapier's ColliderDesc.convexHull computes the hull internally from an arbitrary point cloud,\r\n// so we only need to return a scaled vertex array. No triangle faces are required.\r\nfunction computeHullFromPositions(positions, scale) {\r\n if (!(positions instanceof Float32Array)) {\r\n throw new Error('positions must be a Float32Array');\r\n }\r\n const n = positions.length;\r\n if (n % 3 !== 0) {\r\n throw new Error('positions length must be a multiple of 3');\r\n }\r\n\r\n // Apply in-place scaling to avoid additional copies (positions buffer is owned by this worker).\r\n const sx = (scale && +scale[0]) || 1.0;\r\n const sy = (scale && +scale[1]) || 1.0;\r\n const sz = (scale && +scale[2]) || 1.0;\r\n if (sx !== 1 || sy !== 1 || sz !== 1) {\r\n for (let i = 0; i < n; i += 3) {\r\n positions[i + 0] *= sx;\r\n positions[i + 1] *= sy;\r\n positions[i + 2] *= sz;\r\n }\r\n }\r\n\r\n // Return the scaled point cloud directly; indices are unnecessary for Rapier's convexHull.\r\n const hullVertices = positions;\r\n const hullIndices = null;\r\n return { hullVertices, hullIndices };\r\n}\r\n\r\nself.addEventListener('message', (e) => {\r\n const msg = e.data || {};\r\n const replyId = (typeof msg._envId !== 'undefined') ? msg._envId : (typeof msg.replyTo !== 'undefined' ? msg.replyTo : msg.id);\r\n try {\r\n switch (msg.type) {\r\n case 'computeConvexHull': {\r\n const positions = msg.positions instanceof Float32Array ? msg.positions : new Float32Array(msg.positions?.buffer || msg.positions);\r\n // indices are not strictly needed for hull generation with ConvexHull; accept but ignore for computation.\r\n // If provided and transferred, they will be garbage collected afterward.\r\n const scale = msg.localScale || msg.scale || msg.local?.s || [1, 1, 1];\r\n\r\n const { hullVertices, hullIndices } = computeHullFromPositions(positions, scale);\r\n\r\n // Transfer results back, release incoming buffers by letting them go out of scope.\r\n const transfer = [];\r\n if (hullVertices?.buffer) transfer.push(hullVertices.buffer);\r\n if (hullIndices?.buffer) transfer.push(hullIndices.buffer);\r\n\r\n ack(replyId, { vertices: hullVertices, indices: hullIndices }, transfer);\r\n break;\r\n }\r\n\r\n default: {\r\n ack(replyId, { ok: false, reason: 'unknown message type' });\r\n break;\r\n }\r\n }\r\n } catch (err) {\r\n nack(replyId, err);\r\n }\r\n});"],"names":["ack","id","result","transfer","nack","error","computeHullFromPositions","positions","scale","n","sx","sy","sz","i","e","msg","replyId","hullVertices","hullIndices","err"],"mappings":"AAUA,SAASA,EAAIC,GAAIC,IAAS,MAAMC,IAAW,CAAA,GAAI;AAC7C,EAAIF,KAAM,QAEV,YAAY,EAAE,SAASA,GAAI,QAAAC,EAAM,GAAIC,CAAQ;AAC/C;AACA,SAASC,EAAKH,GAAII,GAAO;AACvB,EAAIJ,KAAM,QACV,YAAY,EAAE,SAASA,GAAI,OAAQI,MAAUA,EAAM,WAAW,OAAOA,CAAK,MAAO,OAAOA,CAAK,EAAC,CAAE;AAClG;AAKA,SAASC,EAAyBC,GAAWC,GAAO;AAClD,MAAI,EAAED,aAAqB;AACzB,UAAM,IAA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