Files
mandy/viewer
cxchhh 99a40c54b1 world_build: instanced placements with bounded memory, and LOD chunk sets
--placements used to copy a model's geometry into every placement and keep
all copies until chunking (#1183 review: 22 GB for a 700 m box). Now each
model's OBJ is parsed once into a packed cache file, each chunk stores every
model it uses once, and the placements are instance transforms:
EXT_mesh_gpu_instancing by default (three.js GLTFLoader reads it), one plain
glTF node per placement with --instancing nodes, or the old baked copies
with --instancing bake. Chunks are written as soon as they are built; with
--jobs N, packing and chunk writing run in N processes, at most 4N jobs in
flight. Memory is about 100 bytes per placement plus the models of the
chunks being written.

Every instance TRS has a positive determinant. A negative XY scale is folded
into the rotation; a negative Z scale draws a mirrored copy of the mesh
(glTF Y negated, winding reversed). Zero-scale placements are counted as
degenerate_scale. iter_placements streams the rows load_placements selects,
with the same checks (load_placements is unchanged).

--lod-sets builds one chunk set per lodLevel tier (c_<tier>_<x>_<z>, with
the tier and grid cell in each chunk record) and writes lod_bands to
world.json: a camera-distance band per tier from the entities' median
childLodDist/lodDist. The viewer loads a tiered chunk while the horizontal
distance to its cell is in the band (32 m slack before unloading), so each
cell shows one tier; worlds without lod_bands stream as before, and the
manifest check rejects unknown tiers, unordered bands and missing cells.

glb_writer: pack_primitive and _MaterialTable are factored out of build_glb
(output unchanged), plus build_instanced_glb / write_instanced_glb and
instance_bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:02:54 +00:00
..