#!/usr/bin/env python3 """Export convention-named terrain chunk collections to individual GLBs. Run through Blender rather than a standalone Python interpreter: blender --background terrain_chunks.blend \ --python tools/blender/export_terrain_chunks.py -- \ --output /path/to/terrain_chunks Collections use ``chunk_####_description`` and contain one primary terrain mesh named ``chunk_####``. Additional production objects may live in the same collection. Reusable procedural props use individual ``prop_description`` mesh objects. They may be arranged anywhere in the source file because each object's authored origin becomes the exported runtime anchor. A same-named ``prop_description`` collection remains supported for multi-object props. Unrelated objects and collections are ignored. """ from __future__ import annotations import argparse import hashlib import json import math import re import struct import sys from dataclasses import dataclass from pathlib import Path from typing import Iterable import bpy from mathutils import Vector CHUNK_SIZE_METERS = 10.0 # Match the runtime boundary analyzer's five-millimeter authoring tolerance. DEFAULT_TOLERANCE = 0.005 COLLECTION_PATTERN = re.compile( r"^chunk_(?P\d{4})(?:_(?P