MCPcopy Create free account
hub / github.com/sparkjsdev/spark / decodeExtSplat

Function decodeExtSplat

src/utils.ts:430–456  ·  view source on GitHub ↗
(
  extArrays: [Uint32Array, Uint32Array],
  index: number,
)

Source from the content-addressed store, hash-verified

428}
429
430export function decodeExtSplat(
431 extArrays: [Uint32Array, Uint32Array],
432 index: number,
433): {
434 center: THREE.Vector3;
435 scales: THREE.Vector3;
436 quaternion: THREE.Quaternion;
437 color: THREE.Color;
438 opacity: number;
439} {
440 // Returns a static object which is reused each time
441 const result = packedFields;
442 const i4 = index * 4;
443 const [extA, extB] = extArrays;
444 result.center.x = uintBitsToFloat(extA[i4]);
445 result.center.y = uintBitsToFloat(extA[i4 + 1]);
446 result.center.z = uintBitsToFloat(extA[i4 + 2]);
447 result.opacity = fromHalf(extA[i4 + 3] & 0xffff);
448 result.color.r = fromHalf(extB[i4] & 0xffff);
449 result.color.g = fromHalf(extB[i4] >>> 16);
450 result.color.b = fromHalf(extB[i4 + 1] & 0xffff);
451 result.scales.x = Math.exp(fromHalf(extB[i4 + 1] >>> 16));
452 result.scales.y = Math.exp(fromHalf(extB[i4 + 2] & 0xffff));
453 result.scales.z = Math.exp(fromHalf(extB[i4 + 2] >>> 16));
454 decodeQuatOctXy1010R12(extB[i4 + 3], result.quaternion);
455 return result;
456}
457
458// Encode a PackedSplat as 4 consecutive Uint32 elements in the packedSplats array.
459// The center coordinates x,y,z are encoded as float16, the scales x,y,z as a

Callers 3

getSplatMethod · 0.90
forEachSplatMethod · 0.90
forEachSplatMethod · 0.90

Calls 2

decodeQuatOctXy1010R12Function · 0.85
uintBitsToFloatFunction · 0.70

Tested by

no test coverage detected