wallhammer-web 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +88 -2
- package/dist/base/data.d.ts +67 -0
- package/dist/base/data.js +10 -0
- package/dist/base/destructible.d.ts +167 -0
- package/dist/base/destructible.js +47 -0
- package/dist/base/env-slot.d.ts +101 -0
- package/dist/base/env-slot.js +8 -0
- package/dist/base/frames.d.ts +138 -0
- package/dist/base/frames.js +459 -0
- package/dist/base/index.d.ts +21 -0
- package/dist/base/index.js +11 -0
- package/dist/base/mat34.d.ts +46 -0
- package/dist/base/mat34.js +173 -0
- package/dist/base/material.d.ts +87 -0
- package/dist/base/material.js +6 -0
- package/dist/base/math.d.ts +27 -0
- package/dist/base/math.js +60 -0
- package/dist/base/progress.d.ts +38 -0
- package/dist/base/progress.js +81 -0
- package/dist/base/rig.d.ts +177 -0
- package/dist/base/rig.js +97 -0
- package/dist/base/trig.d.ts +29 -0
- package/dist/base/trig.js +169 -0
- package/dist/base/up.d.ts +26 -0
- package/dist/base/up.js +40 -0
- package/dist/base/view.d.ts +128 -0
- package/dist/base/view.js +136 -0
- package/dist/camera/camera.d.ts +99 -0
- package/dist/camera/camera.js +228 -0
- package/dist/camera/follow.d.ts +120 -0
- package/dist/camera/follow.js +320 -0
- package/dist/camera/free.d.ts +153 -0
- package/dist/camera/free.js +359 -0
- package/dist/camera/index.d.ts +10 -0
- package/dist/camera/index.js +6 -0
- package/dist/camera/orbit.d.ts +93 -0
- package/dist/camera/orbit.js +261 -0
- package/dist/camera/path.d.ts +48 -0
- package/dist/camera/path.js +179 -0
- package/dist/core/ballistic.d.ts +66 -0
- package/dist/core/ballistic.js +104 -0
- package/dist/core/bodies.d.ts +77 -0
- package/dist/core/bodies.js +125 -0
- package/dist/core/clock.d.ts +37 -0
- package/dist/core/clock.js +87 -0
- package/dist/core/cover-fade.d.ts +14 -0
- package/dist/core/cover-fade.js +38 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +8 -0
- package/dist/core/kepler.d.ts +74 -0
- package/dist/core/kepler.js +108 -0
- package/dist/core/level-fade.d.ts +66 -0
- package/dist/core/level-fade.js +123 -0
- package/dist/core/palette.d.ts +15 -0
- package/dist/core/palette.js +47 -0
- package/dist/env/atmosphere.d.ts +129 -0
- package/dist/env/atmosphere.js +707 -0
- package/dist/env/cloud-field.d.ts +44 -0
- package/dist/env/cloud-field.js +111 -0
- package/dist/env/environment.d.ts +217 -0
- package/dist/env/environment.js +441 -0
- package/dist/env/frame-block.d.ts +29 -0
- package/dist/env/frame-block.js +152 -0
- package/dist/env/glsl.d.ts +35 -0
- package/dist/env/glsl.js +246 -0
- package/dist/env/index.d.ts +13 -0
- package/dist/env/index.js +9 -0
- package/dist/env/sky.d.ts +48 -0
- package/dist/env/sky.js +227 -0
- package/dist/env/sun.d.ts +31 -0
- package/dist/env/sun.js +42 -0
- package/dist/gen-arch/build.d.ts +17 -0
- package/dist/gen-arch/build.js +414 -0
- package/dist/gen-arch/damage/damaged.d.ts +44 -0
- package/dist/gen-arch/damage/damaged.js +1119 -0
- package/dist/gen-arch/damage/fall-material.d.ts +10 -0
- package/dist/gen-arch/damage/fall-material.js +47 -0
- package/dist/gen-arch/damage/fall.d.ts +78 -0
- package/dist/gen-arch/damage/fall.js +797 -0
- package/dist/gen-arch/damage/rubble.d.ts +22 -0
- package/dist/gen-arch/damage/rubble.js +188 -0
- package/dist/gen-arch/index.d.ts +25 -0
- package/dist/gen-arch/index.js +16 -0
- package/dist/gen-arch/interior/interior-plan.d.ts +114 -0
- package/dist/gen-arch/interior/interior-plan.js +615 -0
- package/dist/gen-arch/interior/interior.d.ts +97 -0
- package/dist/gen-arch/interior/interior.js +966 -0
- package/dist/gen-arch/structure/building-shader.d.ts +25 -0
- package/dist/gen-arch/structure/building-shader.js +946 -0
- package/dist/gen-arch/structure/buildings.d.ts +248 -0
- package/dist/gen-arch/structure/buildings.js +294 -0
- package/dist/gen-arch/structure/dims.d.ts +77 -0
- package/dist/gen-arch/structure/dims.js +39 -0
- package/dist/gen-arch/structure/distant.d.ts +62 -0
- package/dist/gen-arch/structure/distant.js +316 -0
- package/dist/gen-arch/structure/env-slots.d.ts +18 -0
- package/dist/gen-arch/structure/env-slots.js +47 -0
- package/dist/gen-arch/structure/facade.d.ts +193 -0
- package/dist/gen-arch/structure/facade.js +159 -0
- package/dist/gen-arch/structure/parts.d.ts +31 -0
- package/dist/gen-arch/structure/parts.js +69 -0
- package/dist/gen-arch/structure/roof.d.ts +76 -0
- package/dist/gen-arch/structure/roof.js +568 -0
- package/dist/gen-arch/structure/structure-material.d.ts +23 -0
- package/dist/gen-arch/structure/structure-material.js +55 -0
- package/dist/gen-arch/structure/writer.d.ts +94 -0
- package/dist/gen-arch/structure/writer.js +195 -0
- package/dist/gen-core/cell.d.ts +138 -0
- package/dist/gen-core/cell.js +150 -0
- package/dist/gen-core/cube-sphere.d.ts +57 -0
- package/dist/gen-core/cube-sphere.js +159 -0
- package/dist/gen-core/field.d.ts +55 -0
- package/dist/gen-core/field.js +154 -0
- package/dist/gen-core/geometry.d.ts +31 -0
- package/dist/gen-core/geometry.js +231 -0
- package/dist/gen-core/hash.d.ts +18 -0
- package/dist/gen-core/hash.js +58 -0
- package/dist/gen-core/height-field.d.ts +33 -0
- package/dist/gen-core/height-field.js +137 -0
- package/dist/gen-core/index.d.ts +22 -0
- package/dist/gen-core/index.js +17 -0
- package/dist/gen-core/instance-cells.d.ts +37 -0
- package/dist/gen-core/instance-cells.js +72 -0
- package/dist/gen-core/near-scatter.d.ts +56 -0
- package/dist/gen-core/near-scatter.js +120 -0
- package/dist/gen-core/noise.d.ts +23 -0
- package/dist/gen-core/noise.js +72 -0
- package/dist/gen-core/occupancy.d.ts +21 -0
- package/dist/gen-core/occupancy.js +104 -0
- package/dist/gen-core/sphere-patch.d.ts +138 -0
- package/dist/gen-core/sphere-patch.js +544 -0
- package/dist/gen-core/strip-surface.d.ts +34 -0
- package/dist/gen-core/strip-surface.js +246 -0
- package/dist/gen-core/strip.d.ts +102 -0
- package/dist/gen-core/strip.js +817 -0
- package/dist/gen-ground/env-slots.d.ts +48 -0
- package/dist/gen-ground/env-slots.js +78 -0
- package/dist/gen-ground/ground.d.ts +78 -0
- package/dist/gen-ground/ground.js +208 -0
- package/dist/gen-ground/index.d.ts +9 -0
- package/dist/gen-ground/index.js +7 -0
- package/dist/gen-ground/markings.d.ts +46 -0
- package/dist/gen-ground/markings.js +124 -0
- package/dist/gen-ground/materials.d.ts +18 -0
- package/dist/gen-ground/materials.js +22 -0
- package/dist/gen-ground/terrain-shader.d.ts +5 -0
- package/dist/gen-ground/terrain-shader.js +151 -0
- package/dist/gen-mesh/bare-shapes.d.ts +194 -0
- package/dist/gen-mesh/bare-shapes.js +596 -0
- package/dist/gen-mesh/bisect-surface.d.ts +47 -0
- package/dist/gen-mesh/bisect-surface.js +261 -0
- package/dist/gen-mesh/box.d.ts +18 -0
- package/dist/gen-mesh/box.js +2 -0
- package/dist/gen-mesh/cell-morph-mesh.d.ts +52 -0
- package/dist/gen-mesh/cell-morph-mesh.js +258 -0
- package/dist/gen-mesh/cell-surface-mesh.d.ts +32 -0
- package/dist/gen-mesh/cell-surface-mesh.js +140 -0
- package/dist/gen-mesh/chunk-mesh.d.ts +25 -0
- package/dist/gen-mesh/chunk-mesh.js +112 -0
- package/dist/gen-mesh/drape-mesh.d.ts +36 -0
- package/dist/gen-mesh/drape-mesh.js +98 -0
- package/dist/gen-mesh/height-field-mesh.d.ts +14 -0
- package/dist/gen-mesh/height-field-mesh.js +98 -0
- package/dist/gen-mesh/index.d.ts +26 -0
- package/dist/gen-mesh/index.js +15 -0
- package/dist/gen-mesh/line-mesh.d.ts +25 -0
- package/dist/gen-mesh/line-mesh.js +62 -0
- package/dist/gen-mesh/mesh-builder.d.ts +115 -0
- package/dist/gen-mesh/mesh-builder.js +315 -0
- package/dist/gen-mesh/packed-mesh.d.ts +53 -0
- package/dist/gen-mesh/packed-mesh.js +205 -0
- package/dist/gen-mesh/prism-mesh.d.ts +33 -0
- package/dist/gen-mesh/prism-mesh.js +176 -0
- package/dist/gen-mesh/rig-mesh.d.ts +9 -0
- package/dist/gen-mesh/rig-mesh.js +135 -0
- package/dist/gen-mesh/strip-mesh.d.ts +45 -0
- package/dist/gen-mesh/strip-mesh.js +258 -0
- package/dist/gen-plan/drain.d.ts +58 -0
- package/dist/gen-plan/drain.js +270 -0
- package/dist/gen-plan/grid.d.ts +37 -0
- package/dist/gen-plan/grid.js +182 -0
- package/dist/gen-plan/horizon.d.ts +50 -0
- package/dist/gen-plan/horizon.js +185 -0
- package/dist/gen-plan/index.d.ts +15 -0
- package/dist/gen-plan/index.js +13 -0
- package/dist/gen-plan/line-tiles.d.ts +35 -0
- package/dist/gen-plan/line-tiles.js +190 -0
- package/dist/gen-plan/lines.d.ts +31 -0
- package/dist/gen-plan/lines.js +183 -0
- package/dist/gen-plan/plots.d.ts +40 -0
- package/dist/gen-plan/plots.js +282 -0
- package/dist/gen-plan/route.d.ts +55 -0
- package/dist/gen-plan/route.js +297 -0
- package/dist/gen-plan/sites.d.ts +32 -0
- package/dist/gen-plan/sites.js +209 -0
- package/dist/gen-tex/code-stamp.d.ts +31 -0
- package/dist/gen-tex/code-stamp.js +137 -0
- package/dist/gen-tex/index.d.ts +7 -0
- package/dist/gen-tex/index.js +5 -0
- package/dist/gen-tex/light-horizon.d.ts +47 -0
- package/dist/gen-tex/light-horizon.js +180 -0
- package/dist/gen-tex/textures.d.ts +8 -0
- package/dist/gen-tex/textures.js +49 -0
- package/dist/gen-tex/value-textures.d.ts +46 -0
- package/dist/gen-tex/value-textures.js +102 -0
- package/dist/gen-vegetation/env-slots.d.ts +20 -0
- package/dist/gen-vegetation/env-slots.js +29 -0
- package/dist/gen-vegetation/index.d.ts +8 -0
- package/dist/gen-vegetation/index.js +7 -0
- package/dist/gen-vegetation/materials.d.ts +7 -0
- package/dist/gen-vegetation/materials.js +17 -0
- package/dist/gen-vegetation/planting.d.ts +170 -0
- package/dist/gen-vegetation/planting.js +363 -0
- package/dist/gen-vegetation/tree-shader.d.ts +23 -0
- package/dist/gen-vegetation/tree-shader.js +229 -0
- package/dist/gen-vegetation/trees.d.ts +59 -0
- package/dist/gen-vegetation/trees.js +329 -0
- package/dist/gpu/device.d.ts +286 -0
- package/dist/gpu/device.js +1157 -0
- package/dist/gpu/gl.d.ts +134 -0
- package/dist/gpu/gl.js +276 -0
- package/dist/gpu/index.d.ts +4 -0
- package/dist/gpu/index.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -0
- package/dist/motion/graph.d.ts +244 -0
- package/dist/motion/graph.js +739 -0
- package/dist/motion/index.d.ts +8 -0
- package/dist/motion/index.js +8 -0
- package/dist/motion/pose-ops.d.ts +30 -0
- package/dist/motion/pose-ops.js +232 -0
- package/dist/motion/reach.d.ts +45 -0
- package/dist/motion/reach.js +264 -0
- package/dist/motion/skeleton.d.ts +49 -0
- package/dist/motion/skeleton.js +99 -0
- package/dist/platform/byte-store.d.ts +21 -0
- package/dist/platform/byte-store.js +137 -0
- package/dist/platform/canvas.d.ts +29 -0
- package/dist/platform/canvas.js +76 -0
- package/dist/platform/context-loss.d.ts +8 -0
- package/dist/platform/context-loss.js +17 -0
- package/dist/platform/free-input.d.ts +51 -0
- package/dist/platform/free-input.js +100 -0
- package/dist/platform/index.d.ts +18 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/input.d.ts +48 -0
- package/dist/platform/input.js +117 -0
- package/dist/platform/keys.d.ts +12 -0
- package/dist/platform/keys.js +29 -0
- package/dist/platform/loop.d.ts +41 -0
- package/dist/platform/loop.js +84 -0
- package/dist/platform/walk-input.d.ts +74 -0
- package/dist/platform/walk-input.js +226 -0
- package/dist/platform/worker.d.ts +51 -0
- package/dist/platform/worker.js +170 -0
- package/dist/render/bone-instances.d.ts +24 -0
- package/dist/render/bone-instances.js +74 -0
- package/dist/render/cells.d.ts +70 -0
- package/dist/render/cells.js +144 -0
- package/dist/render/glsl.d.ts +66 -0
- package/dist/render/glsl.js +173 -0
- package/dist/render/index.d.ts +26 -0
- package/dist/render/index.js +16 -0
- package/dist/render/instance-sets.d.ts +97 -0
- package/dist/render/instance-sets.js +241 -0
- package/dist/render/near-instances.d.ts +75 -0
- package/dist/render/near-instances.js +219 -0
- package/dist/render/particles.d.ts +63 -0
- package/dist/render/particles.js +215 -0
- package/dist/render/pieces.d.ts +57 -0
- package/dist/render/pieces.js +151 -0
- package/dist/render/point-lights.d.ts +97 -0
- package/dist/render/point-lights.js +243 -0
- package/dist/render/renderer.d.ts +447 -0
- package/dist/render/renderer.js +1100 -0
- package/dist/render/rig.d.ts +74 -0
- package/dist/render/rig.js +576 -0
- package/dist/render/shadow-areas.d.ts +49 -0
- package/dist/render/shadow-areas.js +125 -0
- package/dist/render/shadow-glsl.d.ts +12 -0
- package/dist/render/shadow-glsl.js +146 -0
- package/dist/render/transient.d.ts +61 -0
- package/dist/render/transient.js +213 -0
- package/dist/render/value-glsl.d.ts +17 -0
- package/dist/render/value-glsl.js +208 -0
- package/dist/render/value-layers.d.ts +180 -0
- package/dist/render/value-layers.js +333 -0
- package/dist/runtime/atmosphere.d.ts +37 -0
- package/dist/runtime/atmosphere.js +304 -0
- package/dist/runtime/cloud-shell.d.ts +29 -0
- package/dist/runtime/cloud-shell.js +158 -0
- package/dist/runtime/engine.d.ts +155 -0
- package/dist/runtime/engine.js +305 -0
- package/dist/runtime/environment-link.d.ts +22 -0
- package/dist/runtime/environment-link.js +49 -0
- package/dist/runtime/index.d.ts +13 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/precipitation-glsl.d.ts +2 -0
- package/dist/runtime/precipitation-glsl.js +70 -0
- package/dist/runtime/precipitation.d.ts +11 -0
- package/dist/runtime/precipitation.js +78 -0
- package/dist/runtime/sky.d.ts +30 -0
- package/dist/runtime/sky.js +114 -0
- package/dist/runtime/streaming.d.ts +245 -0
- package/dist/runtime/streaming.js +602 -0
- package/dist/sim/agenda.d.ts +167 -0
- package/dist/sim/agenda.js +425 -0
- package/dist/sim/bytes.d.ts +34 -0
- package/dist/sim/bytes.js +125 -0
- package/dist/sim/destruction/apply.d.ts +59 -0
- package/dist/sim/destruction/apply.js +243 -0
- package/dist/sim/destruction/cell-states.d.ts +54 -0
- package/dist/sim/destruction/cell-states.js +198 -0
- package/dist/sim/destruction/index.d.ts +11 -0
- package/dist/sim/destruction/index.js +10 -0
- package/dist/sim/destruction/int-geometry.d.ts +17 -0
- package/dist/sim/destruction/int-geometry.js +131 -0
- package/dist/sim/destruction/pick.d.ts +13 -0
- package/dist/sim/destruction/pick.js +59 -0
- package/dist/sim/destruction/rubble.d.ts +8 -0
- package/dist/sim/destruction/rubble.js +159 -0
- package/dist/sim/destruction/state.d.ts +15 -0
- package/dist/sim/destruction/state.js +83 -0
- package/dist/sim/destruction/structure.d.ts +30 -0
- package/dist/sim/destruction/structure.js +139 -0
- package/dist/sim/events.d.ts +37 -0
- package/dist/sim/events.js +106 -0
- package/dist/sim/fixed.d.ts +21 -0
- package/dist/sim/fixed.js +64 -0
- package/dist/sim/flow-probe.d.ts +58 -0
- package/dist/sim/flow-probe.js +158 -0
- package/dist/sim/flow.d.ts +257 -0
- package/dist/sim/flow.js +967 -0
- package/dist/sim/index.d.ts +28 -0
- package/dist/sim/index.js +20 -0
- package/dist/sim/interlock.d.ts +47 -0
- package/dist/sim/interlock.js +252 -0
- package/dist/sim/movers.d.ts +228 -0
- package/dist/sim/movers.js +1083 -0
- package/dist/sim/nav.d.ts +72 -0
- package/dist/sim/nav.js +292 -0
- package/dist/sim/paths.d.ts +80 -0
- package/dist/sim/paths.js +197 -0
- package/dist/sim/regions.d.ts +87 -0
- package/dist/sim/regions.js +517 -0
- package/dist/sim/simulation.d.ts +114 -0
- package/dist/sim/simulation.js +291 -0
- package/dist/sim/states.d.ts +23 -0
- package/dist/sim/states.js +54 -0
- package/dist/sim/table.d.ts +49 -0
- package/dist/sim/table.js +126 -0
- package/dist/sim/zones.d.ts +11 -0
- package/dist/sim/zones.js +196 -0
- package/dist/tools/collision-lines.d.ts +12 -0
- package/dist/tools/collision-lines.js +50 -0
- package/dist/tools/data-view-glsl.d.ts +3 -0
- package/dist/tools/data-view-glsl.js +63 -0
- package/dist/tools/data-view-layers.d.ts +20 -0
- package/dist/tools/data-view-layers.js +60 -0
- package/dist/tools/debug-view.d.ts +30 -0
- package/dist/tools/debug-view.js +4 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/mesh-checks.d.ts +67 -0
- package/dist/tools/mesh-checks.js +188 -0
- package/dist/tools/profile.d.ts +85 -0
- package/dist/tools/profile.js +173 -0
- package/dist/world/cell-cache.d.ts +32 -0
- package/dist/world/cell-cache.js +60 -0
- package/dist/world/cell-format.d.ts +25 -0
- package/dist/world/cell-format.js +232 -0
- package/dist/world/collide.d.ts +192 -0
- package/dist/world/collide.js +822 -0
- package/dist/world/index.d.ts +16 -0
- package/dist/world/index.js +12 -0
- package/dist/world/mesh-solids.d.ts +48 -0
- package/dist/world/mesh-solids.js +169 -0
- package/dist/world/pick.d.ts +34 -0
- package/dist/world/pick.js +177 -0
- package/dist/world/providers.d.ts +66 -0
- package/dist/world/providers.js +83 -0
- package/dist/world/sphere.d.ts +69 -0
- package/dist/world/sphere.js +271 -0
- package/dist/world/streaming.d.ts +288 -0
- package/dist/world/streaming.js +801 -0
- package/dist/world/walker.d.ts +145 -0
- package/dist/world/walker.js +502 -0
- package/docs/architecture.md +111 -0
- package/docs/cameras.md +302 -0
- package/docs/concepts.md +123 -0
- package/docs/destruction.md +127 -0
- package/docs/frames.md +199 -0
- package/docs/generators.md +575 -0
- package/docs/getting-started.md +123 -0
- package/docs/headless.md +50 -0
- package/docs/motion.md +160 -0
- package/docs/planet.md +152 -0
- package/docs/recipes.md +521 -0
- package/docs/reference.md +364 -0
- package/docs/rendering.md +823 -0
- package/docs/rigs.md +203 -0
- package/docs/simulation.md +235 -0
- package/docs/streaming.md +590 -0
- package/docs/system.md +166 -0
- package/docs/tools.md +175 -0
- package/docs/walking.md +262 -0
- package/package.json +131 -3
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { OrientedBox, Ring } from '../../gen-core/index.ts';
|
|
2
|
+
import type { PropBox } from '../../gen-mesh/index.ts';
|
|
3
|
+
export type { PropBox };
|
|
4
|
+
import { FootprintIndex } from './facade.ts';
|
|
5
|
+
import type { CorniceRecipe, EntranceSpec, FacadeRecipe } from './facade.ts';
|
|
6
|
+
import type { CreaseLine, RoofGeometry, RoofProfile } from './roof.ts';
|
|
7
|
+
import type { ArchMeshDims } from './dims.ts';
|
|
8
|
+
import { BUILDING_ATTRIBS, BUILDING_LAYOUT, VertexWriter } from './writer.ts';
|
|
9
|
+
import type { VertexMaterial, WallAttr } from './writer.ts';
|
|
10
|
+
import type { StructureState } from '../../base/index.ts';
|
|
11
|
+
export { BUILDING_ATTRIBS, BUILDING_LAYOUT };
|
|
12
|
+
/**
|
|
13
|
+
* Roof kinds. `apex` rises from every edge of a convex footprint to a point above the box centre (pyramid, or a tall
|
|
14
|
+
* pointed roof when the ridge height is large), `dome` is the same with a round profile, `mansard` is a hipped ridge
|
|
15
|
+
* roof with two slopes per face. `apex` and `dome` need a convex footprint without holes; otherwise the roof is flat.
|
|
16
|
+
*/
|
|
17
|
+
export type RoofKind = 'flat' | 'gable' | 'hip' | 'field' | 'apex' | 'dome' | 'mansard';
|
|
18
|
+
/**
|
|
19
|
+
* Options of the destructible structure model (damaged.ts). Without them the output is exactly the plain mesh; with an
|
|
20
|
+
* all-intact state it is byte for byte the same as without.
|
|
21
|
+
*/
|
|
22
|
+
export interface StructureOptions {
|
|
23
|
+
/** Also emit the destructible description (`StructureDesc`) of every structure. */
|
|
24
|
+
describe?: boolean;
|
|
25
|
+
/** Damage state per structure id. The per-part state vector is an explicit generator input. */
|
|
26
|
+
states?: ReadonlyMap<number, StructureState>;
|
|
27
|
+
/** Structures that events never change. */
|
|
28
|
+
keepOut?: ReadonlySet<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Emit only the structures at these indices of `specs` (and no props). The others still count as neighbours (shared
|
|
31
|
+
* walls, balconies), so a structure comes out exactly as it does in the full mesh.
|
|
32
|
+
*/
|
|
33
|
+
only?: ReadonlySet<number>;
|
|
34
|
+
/** Also return the interior plan of every emitted structure (`interiors`, by structure id). It never changes the mesh. */
|
|
35
|
+
interiors?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Draw every emitted structure part by part, as the damaged path does, even when it is intact: every triangle then
|
|
38
|
+
* lies within one part (for presentation that moves parts, see fall.ts). Off by default.
|
|
39
|
+
*/
|
|
40
|
+
byParts?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** How the shader draws windows on buildings without a façade recipe. */
|
|
43
|
+
export declare const WINDOW_STYLE: {
|
|
44
|
+
readonly none: 0;
|
|
45
|
+
readonly punched: 1;
|
|
46
|
+
readonly strip: 2;
|
|
47
|
+
readonly sparse: 3;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* How the walls are finished (`BuildingSpec.wallFinish`): plain render (today's look), a timber frame drawn over the
|
|
51
|
+
* render, coursed stone, upright boards. Drawn by the `finishes` variant of the structure material only.
|
|
52
|
+
*/
|
|
53
|
+
export declare const WALL_FINISH: {
|
|
54
|
+
readonly render: 0;
|
|
55
|
+
readonly frame: 1;
|
|
56
|
+
readonly stone: 2;
|
|
57
|
+
readonly boards: 3;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* How pitched roofs are covered (`BuildingSpec.roofCover`): plain courses (today's look), thatch, slate, shingle.
|
|
61
|
+
* Drawn by the `finishes` variant of the structure material only.
|
|
62
|
+
*/
|
|
63
|
+
export declare const ROOF_COVER: {
|
|
64
|
+
readonly courses: 0;
|
|
65
|
+
readonly thatch: 1;
|
|
66
|
+
readonly slate: 2;
|
|
67
|
+
readonly shingle: 3;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The material byte of a structure's vertices (`a_mat.z`): the window style in bits 0–1, the wall finish in bits 2–3,
|
|
71
|
+
* the roof cover in bits 4–5 and shutters in bit 6. A spec without finish, cover and shutters gives its window style.
|
|
72
|
+
*/
|
|
73
|
+
export declare function materialCode(b: BuildingSpec): number;
|
|
74
|
+
export interface BuildingSpec {
|
|
75
|
+
id: number;
|
|
76
|
+
/** Hash derived from the building ID. Drives the tint and all small details, so a building always looks the same. */
|
|
77
|
+
hash: number;
|
|
78
|
+
rings: Ring[];
|
|
79
|
+
box: OrientedBox;
|
|
80
|
+
/** Lowest terrain under the footprint. Walls reach a little below it. */
|
|
81
|
+
groundMin: number;
|
|
82
|
+
/** Terrain the floors are counted from (median under the footprint). */
|
|
83
|
+
groundRef: number;
|
|
84
|
+
/** Eave height from lidar; for a flat roof the roof surface. Metres above sea level. */
|
|
85
|
+
eaveY: number;
|
|
86
|
+
/** Ridge height; equal to the eave for a flat roof. */
|
|
87
|
+
ridgeY: number;
|
|
88
|
+
roof: RoofKind;
|
|
89
|
+
ridgeAcross: boolean;
|
|
90
|
+
/** Height profile of the roof faces; overrides the kind's own (read by gable, hip, apex, dome, mansard). */
|
|
91
|
+
roofProfile?: RoofProfile;
|
|
92
|
+
/**
|
|
93
|
+
* Structures with the same non-zero group are parts of one composition: their walls never count as shared or blind
|
|
94
|
+
* because of each other. A part standing on another part has `groundMin` and `groundRef` at the level it stands on.
|
|
95
|
+
*/
|
|
96
|
+
group?: number;
|
|
97
|
+
/**
|
|
98
|
+
* A member of a group that stands on other members of it. The footprint tests of entrances, steps, balconies and
|
|
99
|
+
* bands of the other members of the same non-zero group ignore it, so a part on top never blocks the walls under it.
|
|
100
|
+
*/
|
|
101
|
+
raised?: boolean;
|
|
102
|
+
/** Wall finish (`WALL_FINISH`), 0 when absent. */
|
|
103
|
+
wallFinish?: number;
|
|
104
|
+
/** Cover of a pitched roof (`ROOF_COVER`), 0 when absent. */
|
|
105
|
+
roofCover?: number;
|
|
106
|
+
/** Number of storeys from the registry, 0 = unknown. Used when it fits the height. */
|
|
107
|
+
levelsHint: number;
|
|
108
|
+
/** Usual storey height for this kind of building. */
|
|
109
|
+
floorHeightNominal: number;
|
|
110
|
+
bayWidth: number;
|
|
111
|
+
windowStyle: number;
|
|
112
|
+
parapetHeight: number;
|
|
113
|
+
/** Palette rows. */
|
|
114
|
+
wallColor: number;
|
|
115
|
+
roofColor: number;
|
|
116
|
+
trimColor: number;
|
|
117
|
+
/** Colour of superstructures on a flat roof. */
|
|
118
|
+
roofUnitColor: number;
|
|
119
|
+
/** Optional façade recipe. Without it the building is drawn the simple way (punched window grid). */
|
|
120
|
+
facade?: FacadeRecipe;
|
|
121
|
+
}
|
|
122
|
+
export interface BuildingMeshStats {
|
|
123
|
+
buildings: number;
|
|
124
|
+
tier1: number;
|
|
125
|
+
tier2: number;
|
|
126
|
+
tier3: number;
|
|
127
|
+
/** Buildings that should have had a pitched roof and ended flat because the check failed. */
|
|
128
|
+
roofFallbacks: number;
|
|
129
|
+
parapets: number;
|
|
130
|
+
/** Procedural superstructures on flat roofs. */
|
|
131
|
+
roofUnits: number;
|
|
132
|
+
/** Superstructures given by the application (lidar), and those dropped because they did not fit the roof. */
|
|
133
|
+
roofBoxes: number;
|
|
134
|
+
roofBoxesDropped: number;
|
|
135
|
+
/** Of the dropped ones: lower than FACADE_DIM.roofBoxMinHeight above the eave (the rest did not fit inside). */
|
|
136
|
+
roofBoxesLow: number;
|
|
137
|
+
props: number;
|
|
138
|
+
/** Façade detail: buildings with a recipe, entrances (and those with no free wall), balconies, cornice walls, chimneys, shared walls. */
|
|
139
|
+
withRecipe: number;
|
|
140
|
+
entrances: number;
|
|
141
|
+
entrancesDropped: number;
|
|
142
|
+
steps: number;
|
|
143
|
+
canopies: number;
|
|
144
|
+
balconies: number;
|
|
145
|
+
corniceWalls: number;
|
|
146
|
+
chimneys: number;
|
|
147
|
+
partyWalls: number;
|
|
148
|
+
blindWalls: number;
|
|
149
|
+
/** Triangles per building (walls, roof and its own detail), sorted. */
|
|
150
|
+
trianglesPerBuilding: number[];
|
|
151
|
+
}
|
|
152
|
+
export declare function buildRoof(b: BuildingSpec, dims: ArchMeshDims): {
|
|
153
|
+
roof: RoofGeometry;
|
|
154
|
+
fellBack: boolean;
|
|
155
|
+
};
|
|
156
|
+
/** Procedural superstructures on a flat roof: lift housing, ventilation. Placement from the building hash. */
|
|
157
|
+
export declare function roofUnits(b: BuildingSpec, dims: ArchMeshDims, roofY: number, area: number, scale?: number): PropBox[];
|
|
158
|
+
/** Points where a footprint edge must be split because a roof crease crosses it. Parameters 0–1, sorted. */
|
|
159
|
+
export declare function edgeSplits(ax: number, az: number, bx: number, bz: number, creases: CreaseLine[]): number[];
|
|
160
|
+
/** One footprint edge with what the façade needs to know about it. */
|
|
161
|
+
export interface Edge {
|
|
162
|
+
ring: number;
|
|
163
|
+
i: number;
|
|
164
|
+
ax: number;
|
|
165
|
+
az: number;
|
|
166
|
+
bx: number;
|
|
167
|
+
bz: number;
|
|
168
|
+
len: number;
|
|
169
|
+
/** Unit direction a → b and outward normal. */
|
|
170
|
+
dx: number;
|
|
171
|
+
dz: number;
|
|
172
|
+
nx: number;
|
|
173
|
+
nz: number;
|
|
174
|
+
/** Window columns: count and width. */
|
|
175
|
+
cols: number;
|
|
176
|
+
colW: number;
|
|
177
|
+
party: boolean;
|
|
178
|
+
blind: boolean;
|
|
179
|
+
balconies: boolean;
|
|
180
|
+
/** Is the wall top constant along the edge (eave edge, not a gable)? */
|
|
181
|
+
levelTop: boolean;
|
|
182
|
+
/** Is the corner at a / at b convex? */
|
|
183
|
+
convexA: boolean;
|
|
184
|
+
convexB: boolean;
|
|
185
|
+
doors: PlacedDoor[];
|
|
186
|
+
}
|
|
187
|
+
export interface PlacedDoor {
|
|
188
|
+
u: number;
|
|
189
|
+
width: number;
|
|
190
|
+
y: number;
|
|
191
|
+
kind: number;
|
|
192
|
+
spec: EntranceSpec;
|
|
193
|
+
}
|
|
194
|
+
export declare function footprintIndex(specs: readonly BuildingSpec[]): FootprintIndex | null;
|
|
195
|
+
/** A box the recipe places, with its path (edge index into `StructurePlan.edges`, column, storey, rule index). */
|
|
196
|
+
export interface PlannedBox {
|
|
197
|
+
edge: number;
|
|
198
|
+
c: number;
|
|
199
|
+
f: number;
|
|
200
|
+
k: number;
|
|
201
|
+
box: PropBox;
|
|
202
|
+
}
|
|
203
|
+
export interface PlannedCanopy {
|
|
204
|
+
/** Index of the entrance in the recipe. */
|
|
205
|
+
k: number;
|
|
206
|
+
edge: number;
|
|
207
|
+
/** Door position along the wall. */
|
|
208
|
+
u: number;
|
|
209
|
+
box: PropBox;
|
|
210
|
+
}
|
|
211
|
+
/** Everything the generator worked out for one structure; shared by the intact path, the description and damage. */
|
|
212
|
+
export interface StructurePlan {
|
|
213
|
+
b: BuildingSpec;
|
|
214
|
+
rec: FacadeRecipe | undefined;
|
|
215
|
+
roof: RoofGeometry;
|
|
216
|
+
flat: boolean;
|
|
217
|
+
baseY: number;
|
|
218
|
+
eaveY: number;
|
|
219
|
+
floors: number;
|
|
220
|
+
floorHeight: number;
|
|
221
|
+
groundFloorH: number;
|
|
222
|
+
floorBase: number;
|
|
223
|
+
parapet: number;
|
|
224
|
+
insets: (Ring | null)[];
|
|
225
|
+
wallTopExtra: number;
|
|
226
|
+
mat: VertexMaterial;
|
|
227
|
+
edges: Edge[];
|
|
228
|
+
/** Split parameters (0–1) of every edge: roof creases and the middles between doors, as the intact path splits. */
|
|
229
|
+
splits: number[][];
|
|
230
|
+
/** Base façade data per edge (null without a recipe). */
|
|
231
|
+
attrs: (WallAttr | null)[];
|
|
232
|
+
balconies: PlannedBox[];
|
|
233
|
+
cornice: CorniceRecipe | null;
|
|
234
|
+
tops: PlannedBox[];
|
|
235
|
+
chimneys: PlannedBox[];
|
|
236
|
+
canopies: PlannedCanopy[];
|
|
237
|
+
groundAt: (x: number, z: number) => number;
|
|
238
|
+
}
|
|
239
|
+
/** Per-wall façade data written into every vertex of the wall. */
|
|
240
|
+
export declare function wallAttr(rec: FacadeRecipe, e: Edge, groundFloorH: number, floorHeight: number): WallAttr;
|
|
241
|
+
/**
|
|
242
|
+
* Places the requested entrances on free walls: nearest wall to the preferred point that is not shared with a
|
|
243
|
+
* neighbour and is long enough; the door goes to the centre of the nearest window column. Builds the steps
|
|
244
|
+
* (when the threshold is above the terrain) and the canopy.
|
|
245
|
+
*/
|
|
246
|
+
export declare function placeEntrances(rec: FacadeRecipe, edges: Edge[], b: BuildingSpec, self: number, index: FootprintIndex, groundAt: (x: number, z: number) => number, stats: BuildingMeshStats, anchored: PropBox[], w: VertexWriter, canopies: PlannedCanopy[], keepCanopy: ((k: number) => boolean) | null, skip?: (i: number) => boolean): void;
|
|
247
|
+
/** Chimneys near the ridge of a pitched roof, with their index in the recipe's chimney rule. */
|
|
248
|
+
export declare function chimneyBoxes(b: BuildingSpec, rec: FacadeRecipe, roof: RoofGeometry): PlannedBox[];
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// Building specs and the parts of the building mesh: roofs by tier, superstructures on flat roofs, footprint edges,
|
|
2
|
+
// entrances with steps and canopies, chimneys, and the per-wall façade data for the shader. Windows, plinth and joints
|
|
3
|
+
// are not geometry: the generator writes the position on the wall into the vertices (metres along the wall, height
|
|
4
|
+
// above the floor base, height above the ground) and the shader draws the rest. The plan of one structure
|
|
5
|
+
// (`StructurePlan`) is defined here and shared by the intact mesh, the interior and the damage model. The mesh itself
|
|
6
|
+
// is assembled in the module root (../build.ts), which may use all three subfolders.
|
|
7
|
+
import { distToSegment, hashInts, unit } from '../../gen-core/index.js';
|
|
8
|
+
import { DOOR_KIND, FACADE_DIM, FACADE_FLAG, FootprintIndex, wallBoxCorners } from './facade.js';
|
|
9
|
+
import { ROOF_PROFILE, apexRoof, fieldRoof, flatRoof, ridgeRoof } from './roof.js';
|
|
10
|
+
import { ARCH_WINDOW_BIT, BUILDING_ATTRIBS, BUILDING_LAYOUT, VertexWriter, boxInside, pushBox, wallBox } from './writer.js';
|
|
11
|
+
export { BUILDING_ATTRIBS, BUILDING_LAYOUT };
|
|
12
|
+
/** How the shader draws windows on buildings without a façade recipe. */
|
|
13
|
+
export const WINDOW_STYLE = { none: 0, punched: 1, strip: 2, sparse: 3 };
|
|
14
|
+
/**
|
|
15
|
+
* How the walls are finished (`BuildingSpec.wallFinish`): plain render (today's look), a timber frame drawn over the
|
|
16
|
+
* render, coursed stone, upright boards. Drawn by the `finishes` variant of the structure material only.
|
|
17
|
+
*/
|
|
18
|
+
export const WALL_FINISH = { render: 0, frame: 1, stone: 2, boards: 3 };
|
|
19
|
+
/**
|
|
20
|
+
* How pitched roofs are covered (`BuildingSpec.roofCover`): plain courses (today's look), thatch, slate, shingle.
|
|
21
|
+
* Drawn by the `finishes` variant of the structure material only.
|
|
22
|
+
*/
|
|
23
|
+
export const ROOF_COVER = { courses: 0, thatch: 1, slate: 2, shingle: 3 };
|
|
24
|
+
/**
|
|
25
|
+
* The material byte of a structure's vertices (`a_mat.z`): the window style in bits 0–1, the wall finish in bits 2–3,
|
|
26
|
+
* the roof cover in bits 4–5 and shutters in bit 6. A spec without finish, cover and shutters gives its window style.
|
|
27
|
+
*/
|
|
28
|
+
export function materialCode(b) {
|
|
29
|
+
const finish = (b.wallFinish ?? 0) & 3;
|
|
30
|
+
const cover = (b.roofCover ?? 0) & 3;
|
|
31
|
+
const shutters = b.facade?.window.shutters ? 1 : 0;
|
|
32
|
+
if (finish === 0 && cover === 0 && shutters === 0)
|
|
33
|
+
return b.windowStyle;
|
|
34
|
+
return (b.windowStyle & 3) | (finish << 2) | (cover << 4) | (shutters << 6);
|
|
35
|
+
}
|
|
36
|
+
export function buildRoof(b, dims) {
|
|
37
|
+
let roof = null;
|
|
38
|
+
const pitch = {
|
|
39
|
+
ridgeY: b.ridgeY,
|
|
40
|
+
eaveWanted: b.eaveY,
|
|
41
|
+
minEaveY: b.groundRef + dims.minWallHeight,
|
|
42
|
+
minSlope: dims.roofSlopeMin,
|
|
43
|
+
maxSlope: dims.roofSlopeMax,
|
|
44
|
+
};
|
|
45
|
+
if (b.roof === 'gable' || b.roof === 'hip') {
|
|
46
|
+
const o = { box: b.box, ridgeAcross: b.ridgeAcross, hipped: b.roof === 'hip', pitch };
|
|
47
|
+
roof = ridgeRoof(b.rings, b.roofProfile ? { ...o, profile: b.roofProfile } : o);
|
|
48
|
+
}
|
|
49
|
+
else if (b.roof === 'field') {
|
|
50
|
+
roof = fieldRoof(b.rings, pitch, dims.fieldRoofMaxTriangles);
|
|
51
|
+
}
|
|
52
|
+
else if (b.roof === 'mansard') {
|
|
53
|
+
roof = ridgeRoof(b.rings, { box: b.box, ridgeAcross: b.ridgeAcross, hipped: true, pitch, profile: b.roofProfile ?? ROOF_PROFILE.mansard });
|
|
54
|
+
}
|
|
55
|
+
else if (b.roof === 'apex' || b.roof === 'dome') {
|
|
56
|
+
roof = apexRoof(b.rings, {
|
|
57
|
+
cx: b.box.cx,
|
|
58
|
+
cz: b.box.cz,
|
|
59
|
+
eaveY: Math.max(b.eaveY, b.groundRef + dims.minWallHeight),
|
|
60
|
+
topY: b.ridgeY,
|
|
61
|
+
profile: b.roofProfile ?? (b.roof === 'dome' ? ROOF_PROFILE.dome : ROOF_PROFILE.straight),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (roof)
|
|
65
|
+
return { roof, fellBack: false };
|
|
66
|
+
return { roof: flatRoof(b.rings, b.roof === 'flat' ? b.eaveY : b.ridgeY), fellBack: b.roof !== 'flat' };
|
|
67
|
+
}
|
|
68
|
+
/** Procedural superstructures on a flat roof: lift housing, ventilation. Placement from the building hash. */
|
|
69
|
+
export function roofUnits(b, dims, roofY, area, scale = 1) {
|
|
70
|
+
if (area < dims.roofUnitMinRoofArea)
|
|
71
|
+
return [];
|
|
72
|
+
const count = Math.min(dims.roofUnitMaxCount, Math.max(1, Math.floor(area / dims.roofUnitAreaPerUnit)));
|
|
73
|
+
const out = [];
|
|
74
|
+
const { box } = b;
|
|
75
|
+
const TRIES = 8;
|
|
76
|
+
/** Distance of a unit from the roof edge. */
|
|
77
|
+
const MARGIN = 1.2;
|
|
78
|
+
for (let k = 0; k < count; k++) {
|
|
79
|
+
for (let t = 0; t < TRIES; t++) {
|
|
80
|
+
const h = hashInts(b.hash, 500 + k, t);
|
|
81
|
+
const r = (i) => unit(hashInts(h, i));
|
|
82
|
+
const halfL = ((dims.roofUnitMinSize + (dims.roofUnitMaxSize - dims.roofUnitMinSize) * r(1) * r(1)) / 2) * scale;
|
|
83
|
+
const halfW = Math.max(dims.roofUnitMinSize / 2, halfL * (0.45 + 0.5 * r(2)));
|
|
84
|
+
const u = (r(3) * 2 - 1) * Math.max(0, box.halfL - halfL - MARGIN);
|
|
85
|
+
const v = (r(4) * 2 - 1) * Math.max(0, box.halfW - halfW - MARGIN);
|
|
86
|
+
const cx = box.cx + box.ux * u - box.uz * v;
|
|
87
|
+
const cz = box.cz + box.uz * u + box.ux * v;
|
|
88
|
+
const cand = { cx, cz, ux: box.ux, uz: box.uz, halfL, halfW };
|
|
89
|
+
// The whole unit including the margin must lie on the roof.
|
|
90
|
+
if (!boxInside(cand, b.rings, MARGIN))
|
|
91
|
+
continue;
|
|
92
|
+
if (out.some((o) => Math.hypot(o.cx - cx, o.cz - cz) < o.halfL + halfL + 1))
|
|
93
|
+
continue;
|
|
94
|
+
const big = halfL * 2 > 3;
|
|
95
|
+
const height = (dims.roofUnitMinHeight + (dims.roofUnitMaxHeight - dims.roofUnitMinHeight) * (big ? 0.5 + 0.5 * r(5) : 0.4 * r(5))) * (scale < 1 ? 0.6 : 1);
|
|
96
|
+
out.push({ cx, cz, baseY: roofY, ux: box.ux, uz: box.uz, halfL, halfW, height, slope: 0, color: big ? b.wallColor : b.roofUnitColor, hash: h });
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/** Points where a footprint edge must be split because a roof crease crosses it. Parameters 0–1, sorted. */
|
|
103
|
+
export function edgeSplits(ax, az, bx, bz, creases) {
|
|
104
|
+
const ts = [0, 1];
|
|
105
|
+
for (const c of creases) {
|
|
106
|
+
const sa = c.nx * ax + c.nz * az - c.off;
|
|
107
|
+
const sb = c.nx * bx + c.nz * bz - c.off;
|
|
108
|
+
if (sa * sb < 0) {
|
|
109
|
+
const t = sa / (sa - sb);
|
|
110
|
+
if (t > 1e-3 && t < 1 - 1e-3)
|
|
111
|
+
ts.push(t);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return ts.sort((p, q) => p - q);
|
|
115
|
+
}
|
|
116
|
+
const DOOR_CODE = { door: DOOR_KIND.door, garage: DOOR_KIND.garage, portal: DOOR_KIND.portal, arch: DOOR_KIND.arch };
|
|
117
|
+
/** Height of an opening by its kind code; an arch door's height follows its width. */
|
|
118
|
+
function doorHeight(kind, width) {
|
|
119
|
+
if (kind === DOOR_KIND.arch)
|
|
120
|
+
return width * FACADE_DIM.archHeightPerWidth;
|
|
121
|
+
return kind === DOOR_KIND.garage ? FACADE_DIM.garageDoorHeight : kind === DOOR_KIND.portal ? FACADE_DIM.portalHeight : FACADE_DIM.doorHeight;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Footprint index of a spec list, built once per list and reused by later calls with the same list (a damaged
|
|
125
|
+
* structure is regenerated with `only` against the full list many times). The cache keys on the array and checks
|
|
126
|
+
* that every spec's rings are still the same objects, so a list changed in place gets a new index.
|
|
127
|
+
*/
|
|
128
|
+
const footprintCache = new WeakMap();
|
|
129
|
+
export function footprintIndex(specs) {
|
|
130
|
+
const hit = footprintCache.get(specs);
|
|
131
|
+
if (hit && hit.rings.length === specs.length && hit.rings.every((r, i) => r === specs[i].rings))
|
|
132
|
+
return hit.index;
|
|
133
|
+
const rings = specs.map((s) => s.rings);
|
|
134
|
+
const index = specs.some((s) => s.facade) ? new FootprintIndex(rings) : null;
|
|
135
|
+
footprintCache.set(specs, { rings, index });
|
|
136
|
+
return index;
|
|
137
|
+
}
|
|
138
|
+
/** Per-wall façade data written into every vertex of the wall. */
|
|
139
|
+
export function wallAttr(rec, e, groundFloorH, floorHeight) {
|
|
140
|
+
let flags = FACADE_FLAG.recipe;
|
|
141
|
+
if (e.blind)
|
|
142
|
+
flags |= FACADE_FLAG.blind;
|
|
143
|
+
if (rec.panelJoints)
|
|
144
|
+
flags |= FACADE_FLAG.panelJoints;
|
|
145
|
+
if (rec.stairStrip)
|
|
146
|
+
flags |= FACADE_FLAG.stairStrip;
|
|
147
|
+
if (rec.window.transom)
|
|
148
|
+
flags |= FACADE_FLAG.transom;
|
|
149
|
+
if (e.balconies && rec.balconies) {
|
|
150
|
+
flags |= FACADE_FLAG.balconies;
|
|
151
|
+
if (rec.balconies.kind === 'loggia')
|
|
152
|
+
flags |= FACADE_FLAG.loggia;
|
|
153
|
+
}
|
|
154
|
+
if (rec.cornice)
|
|
155
|
+
flags |= FACADE_FLAG.cornice;
|
|
156
|
+
// Window size clamped so it fits the column and the storey.
|
|
157
|
+
const ww = Math.min(rec.window.width, e.colW * 0.7);
|
|
158
|
+
const wh = Math.min(rec.window.height, floorHeight - 0.55);
|
|
159
|
+
const sill = Math.min(rec.window.sill, Math.max(0.3, floorHeight - wh - 0.25));
|
|
160
|
+
const curtain = Math.round(Math.max(0, Math.min(1, rec.curtainShare)) * 15);
|
|
161
|
+
const blind = Math.round(Math.max(0, Math.min(1, rec.blindShare)) * 15);
|
|
162
|
+
const balconyMask = rec.balconies ? rec.balconies.columnMask & 15 : 0;
|
|
163
|
+
// An arched window stores its height on the tall scale (the writer reads the bit).
|
|
164
|
+
const arch = rec.window.arch ? ARCH_WINDOW_BIT : 0;
|
|
165
|
+
return {
|
|
166
|
+
doorU: -1e4,
|
|
167
|
+
doorW: 0,
|
|
168
|
+
doorY: 0,
|
|
169
|
+
groundFloorH,
|
|
170
|
+
win: [ww, wh, sill, rec.plinthHeight],
|
|
171
|
+
bits: [flags, rec.window.mullions | (rec.groundFloor << 2) | arch, curtain | (blind << 4), balconyMask | ((rec.window.narrowMask & 15) << 4)],
|
|
172
|
+
cols: [rec.colors.frame, rec.colors.plinth, rec.colors.door, rec.colors.accent],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Places the requested entrances on free walls: nearest wall to the preferred point that is not shared with a
|
|
177
|
+
* neighbour and is long enough; the door goes to the centre of the nearest window column. Builds the steps
|
|
178
|
+
* (when the threshold is above the terrain) and the canopy.
|
|
179
|
+
*/
|
|
180
|
+
export function placeEntrances(rec, edges, b, self, index, groundAt, stats, anchored, w, canopies, keepCanopy, skip) {
|
|
181
|
+
rec.entrances.forEach((ent, k) => {
|
|
182
|
+
let best = null;
|
|
183
|
+
let bestD = Infinity;
|
|
184
|
+
for (const e of edges) {
|
|
185
|
+
if (e.party || e.len < ent.width + 0.4)
|
|
186
|
+
continue;
|
|
187
|
+
// Prefer walls facing the point: a wall seen from behind gets a penalty.
|
|
188
|
+
const facing = (ent.x - (e.ax + e.bx) / 2) * e.nx + (ent.z - (e.az + e.bz) / 2) * e.nz;
|
|
189
|
+
const d = distToSegment(ent.x, ent.z, e.ax, e.az, e.bx, e.bz) + (facing < 0 ? 6 : 0);
|
|
190
|
+
if (d < bestD) {
|
|
191
|
+
bestD = d;
|
|
192
|
+
best = e;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (!best) {
|
|
196
|
+
stats.entrancesDropped++;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const e = best;
|
|
200
|
+
const along = (ent.x - e.ax) * e.dx + (ent.z - e.az) * e.dz;
|
|
201
|
+
const col = Math.max(0, Math.min(e.cols - 1, Math.floor(along / e.colW)));
|
|
202
|
+
let u = (col + 0.5) * e.colW;
|
|
203
|
+
const half = ent.width / 2;
|
|
204
|
+
const margin = Math.min(FACADE_DIM.wallEndMargin, (e.len - ent.width) / 2);
|
|
205
|
+
u = Math.max(margin + half, Math.min(e.len - margin - half, u));
|
|
206
|
+
if (e.doors.some((d) => Math.abs(d.u - u) < Math.max(e.colW, ent.width + 0.6)))
|
|
207
|
+
return;
|
|
208
|
+
const kind = DOOR_CODE[ent.kind];
|
|
209
|
+
// Threshold: terrain in front of the door plus the raise, never below the terrain at the wall itself.
|
|
210
|
+
const px = e.ax + e.dx * u;
|
|
211
|
+
const pz = e.az + e.dz * u;
|
|
212
|
+
const gWall = Math.max(groundAt(px - e.dx * half, pz - e.dz * half), groundAt(px + e.dx * half, pz + e.dz * half), groundAt(px, pz));
|
|
213
|
+
const gFront = groundAt(px + e.nx * 0.8, pz + e.nz * 0.8);
|
|
214
|
+
const y = Math.max(gWall + 0.02, gFront + ent.raise);
|
|
215
|
+
// Steps and canopy must not poke into a neighbour; when they would, the door goes elsewhere or nowhere.
|
|
216
|
+
const rise = y - gFront;
|
|
217
|
+
const nSteps = rise > FACADE_DIM.minStepHeight ? Math.min(FACADE_DIM.maxSteps, Math.ceil(rise / FACADE_DIM.stepRise) - 1) : -1;
|
|
218
|
+
const reach = Math.max(ent.canopy, nSteps >= 0 ? FACADE_DIM.landingDepth + nSteps * FACADE_DIM.stepTread : 0.3);
|
|
219
|
+
const extra = Math.max(FACADE_DIM.canopyExtraWidth, 0.6) / 2;
|
|
220
|
+
if (index.anyOccupied(wallBoxCorners(e.ax, e.az, e.dx, e.dz, u - half - extra, u + half + extra, 0.05, reach + 0.1), self, skip)) {
|
|
221
|
+
stats.entrancesDropped++;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
e.doors.push({ u, width: ent.width, y, kind, spec: ent });
|
|
225
|
+
e.doors.sort((p, q) => p.u - q.u);
|
|
226
|
+
stats.entrances++;
|
|
227
|
+
const h = hashInts(b.hash, 800, k);
|
|
228
|
+
if (nSteps >= 0) {
|
|
229
|
+
// Landing level with the threshold, then steps down; each lower step only covers its own tread, so no
|
|
230
|
+
// two boxes share a face. Every box reaches under the lowest terrain around it.
|
|
231
|
+
const sw = ent.width + 0.5;
|
|
232
|
+
for (let s = 0; s <= nSteps; s++) {
|
|
233
|
+
const d0 = s === 0 ? 0 : FACADE_DIM.landingDepth + (s - 1) * FACADE_DIM.stepTread;
|
|
234
|
+
const d1 = FACADE_DIM.landingDepth + s * FACADE_DIM.stepTread;
|
|
235
|
+
const top = y - s * FACADE_DIM.stepRise;
|
|
236
|
+
const corners = wallBoxCorners(e.ax, e.az, e.dx, e.dz, u - sw / 2, u + sw / 2, d0, d1);
|
|
237
|
+
let gMin = Infinity;
|
|
238
|
+
for (let c = 0; c < 8; c += 2)
|
|
239
|
+
gMin = Math.min(gMin, groundAt(corners[c], corners[c + 1]));
|
|
240
|
+
const bottom = Math.min(gMin, top) - FACADE_DIM.stepSink;
|
|
241
|
+
const box = wallBox(e.ax, e.az, e.dx, e.dz, u - sw / 2, u + sw / 2, d0, d1, bottom, top - bottom, rec.colors.plinth, hashInts(h, s));
|
|
242
|
+
pushBox(w, box);
|
|
243
|
+
anchored.push(box);
|
|
244
|
+
}
|
|
245
|
+
stats.steps++;
|
|
246
|
+
}
|
|
247
|
+
if (ent.canopy > 0) {
|
|
248
|
+
const cw = ent.width + FACADE_DIM.canopyExtraWidth;
|
|
249
|
+
const cy = y + doorHeight(kind, ent.width) + FACADE_DIM.canopyGap;
|
|
250
|
+
const box = wallBox(e.ax, e.az, e.dx, e.dz, u - cw / 2, u + cw / 2, 0, ent.canopy, cy, FACADE_DIM.canopyThickness, b.trimColor, hashInts(h, 99));
|
|
251
|
+
canopies.push({ k, edge: edges.indexOf(e), u, box });
|
|
252
|
+
if (!keepCanopy || keepCanopy(k))
|
|
253
|
+
pushBox(w, box);
|
|
254
|
+
stats.canopies++;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/** Chimneys near the ridge of a pitched roof, with their index in the recipe's chimney rule. */
|
|
259
|
+
export function chimneyBoxes(b, rec, roof) {
|
|
260
|
+
const { box } = b;
|
|
261
|
+
const along = b.ridgeAcross ? [-box.uz, box.ux] : [box.ux, box.uz];
|
|
262
|
+
const halfAlong = b.ridgeAcross ? box.halfW : box.halfL;
|
|
263
|
+
const across = [-along[1], along[0]];
|
|
264
|
+
const count = Math.max(1, Math.min(rec.chimneys, Math.round((halfAlong * 2) / 9)));
|
|
265
|
+
const [sx, sz] = FACADE_DIM.chimneySize;
|
|
266
|
+
const out = [];
|
|
267
|
+
for (let k = 0; k < count; k++) {
|
|
268
|
+
const h = hashInts(b.hash, 1000, k);
|
|
269
|
+
const r = (i) => unit(hashInts(h, i));
|
|
270
|
+
// Spread along the ridge, a little off it on a random side.
|
|
271
|
+
const t = count === 1 ? (r(1) - 0.5) * 0.6 : -0.6 + (1.2 * k) / (count - 1) + (r(1) - 0.5) * 0.15;
|
|
272
|
+
const off = (r(2) < 0.5 ? -1 : 1) * (0.4 + 0.9 * r(3));
|
|
273
|
+
const cx = box.cx + along[0] * t * halfAlong + across[0] * off;
|
|
274
|
+
const cz = box.cz + along[1] * t * halfAlong + across[1] * off;
|
|
275
|
+
const cand = { cx, cz, ux: along[0], uz: along[1], halfL: sz / 2, halfW: sx / 2 };
|
|
276
|
+
if (!boxInside(cand, b.rings, 0.6))
|
|
277
|
+
continue;
|
|
278
|
+
let low = Infinity;
|
|
279
|
+
let high = -Infinity;
|
|
280
|
+
for (const [su, sv] of [
|
|
281
|
+
[-1, -1],
|
|
282
|
+
[1, -1],
|
|
283
|
+
[1, 1],
|
|
284
|
+
[-1, 1],
|
|
285
|
+
]) {
|
|
286
|
+
const y = roof.topAt(cx + cand.ux * cand.halfL * su - cand.uz * cand.halfW * sv, cz + cand.uz * cand.halfL * su + cand.ux * cand.halfW * sv);
|
|
287
|
+
low = Math.min(low, y);
|
|
288
|
+
high = Math.max(high, y);
|
|
289
|
+
}
|
|
290
|
+
const top = Math.max(high + 0.5, roof.topAt(box.cx, box.cz) + FACADE_DIM.chimneyAboveRidge * (0.6 + 0.6 * r(4)));
|
|
291
|
+
out.push({ edge: -1, c: 0, f: 0, k, box: { ...cand, baseY: low - 0.1, height: top - low + 0.1, slope: 0, color: rec.colors.chimney, hash: h } });
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** Sizes the mesh generator needs. */
|
|
2
|
+
export interface ArchMeshDims {
|
|
3
|
+
/** Lowest wall above the highest ground point under the footprint. */
|
|
4
|
+
minWallHeight: number;
|
|
5
|
+
/** How far walls reach below the lowest ground point. */
|
|
6
|
+
wallBelowGround: number;
|
|
7
|
+
/** Range of believable storey heights; a levels hint outside it is ignored. */
|
|
8
|
+
floorHeightMin: number;
|
|
9
|
+
floorHeightMax: number;
|
|
10
|
+
/** Inset of the parapet ring on flat roofs. */
|
|
11
|
+
parapetThickness: number;
|
|
12
|
+
/** Pitched roof slope range (rise over run). */
|
|
13
|
+
roofSlopeMin: number;
|
|
14
|
+
roofSlopeMax: number;
|
|
15
|
+
/** Boxes on flat roofs: smallest roof that gets any, area per box, most boxes per roof, box size and height ranges. */
|
|
16
|
+
roofUnitMinRoofArea: number;
|
|
17
|
+
roofUnitAreaPerUnit: number;
|
|
18
|
+
roofUnitMaxCount: number;
|
|
19
|
+
roofUnitMinSize: number;
|
|
20
|
+
roofUnitMaxSize: number;
|
|
21
|
+
roofUnitMinHeight: number;
|
|
22
|
+
roofUnitMaxHeight: number;
|
|
23
|
+
/**
|
|
24
|
+
* Budget for one `field` roof. The roof is refined in rounds that halve every edge longer than 1.5 m; a round that
|
|
25
|
+
* would leave more than this many triangles is not taken, so a large footprint stops at coarser edges. The final
|
|
26
|
+
* roof can exceed the budget by the triangles added where planes meet (ridges, hips, valleys), typically a few
|
|
27
|
+
* per cent. Default: no budget (every edge refined to 1.5 m).
|
|
28
|
+
*/
|
|
29
|
+
fieldRoofMaxTriangles?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Sizes the structure shader bakes in as constants. */
|
|
32
|
+
export interface ArchShadeDims {
|
|
33
|
+
/** Height of the darker band at the wall foot. */
|
|
34
|
+
plinthHeight: number;
|
|
35
|
+
/** Height over which the wall foot brightens from its contact shadow. */
|
|
36
|
+
wallBaseShadeHeight: number;
|
|
37
|
+
/** Height of the parapet, for the shading on its inner side. */
|
|
38
|
+
parapetHeight: number;
|
|
39
|
+
}
|
|
40
|
+
export type ArchDims = ArchMeshDims & ArchShadeDims;
|
|
41
|
+
/** Sizes of the interior in metres. */
|
|
42
|
+
export declare const INTERIOR_DIM: {
|
|
43
|
+
/** Floor slab thickness (the roof keeps its own, `DESTRUCT_DIM.roofSlab`). */
|
|
44
|
+
readonly slab: 0.22;
|
|
45
|
+
/** Partition wall thickness. */
|
|
46
|
+
readonly partition: 0.12;
|
|
47
|
+
/** Door opening in a partition: width (the stair core gets a wider one) and height. */
|
|
48
|
+
readonly doorWidth: 0.9;
|
|
49
|
+
readonly coreDoorWidth: 1.1;
|
|
50
|
+
readonly doorHeight: 2.05;
|
|
51
|
+
/** Footprint depth from which a corridor runs along the long axis, and its width range. */
|
|
52
|
+
readonly corridorDepth: 10;
|
|
53
|
+
readonly corridorWidthMin: 1.7;
|
|
54
|
+
readonly corridorWidthMax: 2.2;
|
|
55
|
+
/** Room widths along the long axis: smallest, range of the seeded target, widest free span between cuts. */
|
|
56
|
+
readonly roomMin: 2.4;
|
|
57
|
+
readonly roomWidthMin: 3.2;
|
|
58
|
+
readonly roomWidthMax: 5.6;
|
|
59
|
+
readonly roomMax: 7;
|
|
60
|
+
/** Deepest row of rooms across the long axis. */
|
|
61
|
+
readonly rowMax: 7.5;
|
|
62
|
+
/** Below this area or width the whole storey is one room. */
|
|
63
|
+
readonly oneRoomArea: 28;
|
|
64
|
+
readonly oneRoomWidth: 4;
|
|
65
|
+
/** Dog-leg stair: width range, landing depth range, rise per step, tread range, gap between flights. */
|
|
66
|
+
readonly stairWidthMin: 2.2;
|
|
67
|
+
readonly stairWidthMax: 2.7;
|
|
68
|
+
readonly landingMin: 0.9;
|
|
69
|
+
readonly landingMax: 1.15;
|
|
70
|
+
readonly stairRise: 0.185;
|
|
71
|
+
readonly stairRiseMax: 0.23;
|
|
72
|
+
readonly treadMin: 0.21;
|
|
73
|
+
readonly treadMax: 0.29;
|
|
74
|
+
readonly flightGap: 0.14;
|
|
75
|
+
/** Cells smaller than this are empty. */
|
|
76
|
+
readonly minCellArea: 0.6;
|
|
77
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Dimensions the structure generator and shader take from the project (metres, unless noted), and the fixed sizes of
|
|
2
|
+
// the interior (`INTERIOR_DIM`), which the interior plan and the structure shader share.
|
|
3
|
+
/** Sizes of the interior in metres. */
|
|
4
|
+
export const INTERIOR_DIM = {
|
|
5
|
+
/** Floor slab thickness (the roof keeps its own, `DESTRUCT_DIM.roofSlab`). */
|
|
6
|
+
slab: 0.22,
|
|
7
|
+
/** Partition wall thickness. */
|
|
8
|
+
partition: 0.12,
|
|
9
|
+
/** Door opening in a partition: width (the stair core gets a wider one) and height. */
|
|
10
|
+
doorWidth: 0.9,
|
|
11
|
+
coreDoorWidth: 1.1,
|
|
12
|
+
doorHeight: 2.05,
|
|
13
|
+
/** Footprint depth from which a corridor runs along the long axis, and its width range. */
|
|
14
|
+
corridorDepth: 10,
|
|
15
|
+
corridorWidthMin: 1.7,
|
|
16
|
+
corridorWidthMax: 2.2,
|
|
17
|
+
/** Room widths along the long axis: smallest, range of the seeded target, widest free span between cuts. */
|
|
18
|
+
roomMin: 2.4,
|
|
19
|
+
roomWidthMin: 3.2,
|
|
20
|
+
roomWidthMax: 5.6,
|
|
21
|
+
roomMax: 7,
|
|
22
|
+
/** Deepest row of rooms across the long axis. */
|
|
23
|
+
rowMax: 7.5,
|
|
24
|
+
/** Below this area or width the whole storey is one room. */
|
|
25
|
+
oneRoomArea: 28,
|
|
26
|
+
oneRoomWidth: 4,
|
|
27
|
+
/** Dog-leg stair: width range, landing depth range, rise per step, tread range, gap between flights. */
|
|
28
|
+
stairWidthMin: 2.2,
|
|
29
|
+
stairWidthMax: 2.7,
|
|
30
|
+
landingMin: 0.9,
|
|
31
|
+
landingMax: 1.15,
|
|
32
|
+
stairRise: 0.185,
|
|
33
|
+
stairRiseMax: 0.23,
|
|
34
|
+
treadMin: 0.21,
|
|
35
|
+
treadMax: 0.29,
|
|
36
|
+
flightGap: 0.14,
|
|
37
|
+
/** Cells smaller than this are empty. */
|
|
38
|
+
minCellArea: 0.6,
|
|
39
|
+
};
|