"""Prepare a Blender GLB export for the configurator. python tools/prepare_export.py path/to/edited.glb --out prepared Produces prepared/dum.glb and prepared/scene.json. Keeps the original complete catalogue texture library, rebinds material/node indices using loceniceId. It does not update floor polygons, collision volumes, windows or structural design. """ from pathlib import Path from copy import deepcopy import argparse, json, struct ROOT=Path(__file__).resolve().parent.parent def read_glb(path): data=Path(path).read_bytes() if len(data)<28 or struct.unpack_from('len(data):raise ValueError('Truncated GLB') chunk=data[offset+8:offset+8+size] if kind==0x4e4f534a:g=json.loads(chunk) elif kind==0x004e4942:b=chunk offset+=8+size if g is None or b is None:raise ValueError('Missing JSON or binary chunk') return g,b def write_glb(path,g,b): j=json.dumps(g,ensure_ascii=False,separators=(',',':')).encode();j+=b' '*((-len(j))%4) b=bytes(b);b+=b'\0'*((-len(b))%4) Path(path).write_bytes(struct.pack('