Buildings and infrastructure
Copy objects/buildings intact and inject the chosen engine API. Units are metres, Y is up. Roots have position/rotation/quaternion/scale, properties, getBounds, serialize/restore and dispose. Every constructor accepts (api, options).
| Class | Options | Behavior |
|---|---|---|
| Building | style='cottage', width=12, depth=10, height=6, seed=1, name, lightsOn=false, foundationDepth=2 | Styles cottage, farmhouse, barn, warehouse, hangar and lighthouse. setLights(boolean), setDoorOpen(0–1), setFoundationDepth(metres), getCollisionShapes() |
| Bridge | span=210, width=12, height=15, name | Pier/arch/deck/railing structure. getDeckHeight() includes root elevation |
| Road | terrain, points:Vector3[], width=7, name | Terrain-conforming curved road with surface markings |
| FarmField | terrain, x,z,width=160,depth=210,crop='grain',seed=1 | Terrain-conforming cultivated surface; vegetables or grain coloring |
| Airfield | width=55,length=950,name | Runway, apron, lights, three hangars and control tower. setLights(boolean); structures lists child buildings |
The application chooses placement, samples the entire footprint and extends foundations below its lowest ground sample, checks slopes/water and registers collision shapes with SpatialWorld. Roots are movable but static mesh colliders must be re-registered after changing transforms. Terrain-conforming Road/FarmField geometry is built from the supplied terrain snapshot; rebuild after changing terrain. Buildings are exterior procedural models rather than explorable interiors. Door animation applies to buildings with a modeled door.
The package shares locally generated material libraries among objects created with the same injected API namespace. It reference-counts those resources; disposing one building does not release another building's textures. Dispose every object or own them through ResourceScope. Static material groups are consolidated while doors and nested airfield structures retain their state.
Generic restore preserves transforms/properties. Reconstruct from constructor properties to change dimensions/style; it does not remesh an existing building automatically. shell/world/settlement.js is application composition, not a dependency of this package.