From 3db673e12b60d759f7cb2477a9f62690d9897216 Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Tue, 22 Sep 2026 15:09:42 +0100 Subject: [PATCH] latest --- src/lib/index.ts | 2 +- src/lib/ops/index.ts | 2 +- src/lib/ops/morton-order.ts | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/index.ts b/src/lib/index.ts index 4b7b5508..7a454da1 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -12,7 +12,7 @@ export type { } from './chunk'; // Structural combinators (lazy views over sources) -export { bakeTransform, concatSource, selectLod, stackLods } from './ops'; +export { bakeTransform, concatSource, selectLod, stackLods, sortMortonColumns, sortMortonInterleaved } from './ops'; // How a scene was trained (carried on `ChunkSourceMetadata.model`). The per-format // spellings of the tag live with their reader/writer. diff --git a/src/lib/ops/index.ts b/src/lib/ops/index.ts index 9a459637..e487b3f1 100644 --- a/src/lib/ops/index.ts +++ b/src/lib/ops/index.ts @@ -1,7 +1,7 @@ // Tier-1 ops over a ChunkSource (views & passes). export { mapSource } from './map-source'; export { bakeTransform } from './bake-transform'; -export { mortonOrder, sortMortonColumns } from './morton-order'; +export { mortonOrder, sortMortonColumns, sortMortonInterleaved } from './morton-order'; export { permuteSource } from './permute-source'; export { stackLods } from './stack-lods'; export { selectLod, resolveLodLevels } from './select-lod'; diff --git a/src/lib/ops/morton-order.ts b/src/lib/ops/morton-order.ts index 30fc7246..47ff464c 100644 --- a/src/lib/ops/morton-order.ts +++ b/src/lib/ops/morton-order.ts @@ -124,11 +124,16 @@ const sortMortonStrided = ( * Sort `indices` in place into morton (Z-order) using interleaved positions * `[x, y, z, x, y, z, ...]` — the natural packing of the `position` layer. * - * @param positions - Interleaved xyz; gaussian `g` is at `positions[g*3 + {0,1,2}]`. + * `stride` lets the same call sort a wider record whose first three words are + * xyz, e.g. a packed `[x, y, z, w]` GPU texture row viewed as floats, without + * copying the positions out first. + * + * @param positions - Interleaved xyz; gaussian `g` is at `positions[g*stride + {0,1,2}]`. * @param indices - Indices to sort in place. + * @param stride - Words per gaussian in `positions` (default 3). */ -const sortMortonInterleaved = (positions: ArrayLike, indices: Uint32Array): void => { - sortMortonStrided(indices, positions, positions, positions, 3, 0, 1, 2); +const sortMortonInterleaved = (positions: ArrayLike, indices: Uint32Array, stride = 3): void => { + sortMortonStrided(indices, positions, positions, positions, stride, 0, 1, 2); }; /**