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,62 @@
|
|
|
1
|
+
import type { MaterialDesc, MeshData, RGB, Vec3, VertexLayout } from '../../base/index.ts';
|
|
2
|
+
import type { CodeStamp } from '../../gen-tex/index.ts';
|
|
3
|
+
import type { BuildingSpec } from './buildings.ts';
|
|
4
|
+
import type { ArchMeshDims, ArchShadeDims } from './dims.ts';
|
|
5
|
+
export declare const MASSING_ATTRIBS: {
|
|
6
|
+
readonly a_pos: 0;
|
|
7
|
+
readonly a_up: 1;
|
|
8
|
+
readonly a_normal: 2;
|
|
9
|
+
readonly a_mat: 3;
|
|
10
|
+
readonly a_seed: 4;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Vertex layout of the massing mesh: position, height above the ground the storeys are counted from, normal with the
|
|
14
|
+
* kind of surface in its fourth component (wall 0, top of a pitched roof 1, top of a flat roof 2), palette rows of
|
|
15
|
+
* wall and roof with the window style and the glazed share of the wall (0–255), and the structure's 24-bit tint seed
|
|
16
|
+
* (the same number the full shader derives from the structure hash).
|
|
17
|
+
*/
|
|
18
|
+
export declare const MASSING_LAYOUT: VertexLayout;
|
|
19
|
+
export interface MassingOptions {
|
|
20
|
+
/** Emit only the structures at these indices of `specs`. */
|
|
21
|
+
only?: ReadonlySet<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Positions are written relative to this point (a tile origin), so they stay exact far from the world origin. Draw
|
|
24
|
+
* the mesh with `u_cellOffset` = origin − render origin. Default [0, 0, 0]: world positions, no offset needed.
|
|
25
|
+
*/
|
|
26
|
+
origin?: Vec3;
|
|
27
|
+
}
|
|
28
|
+
export interface MassingMesh {
|
|
29
|
+
mesh: MeshData;
|
|
30
|
+
/** First vertex of every structure of `specs` in the mesh; the last entry is the vertex count. */
|
|
31
|
+
spans: Uint32Array;
|
|
32
|
+
/** Lowest and highest point (world heights). Both 0 when nothing was emitted. */
|
|
33
|
+
minY: number;
|
|
34
|
+
maxY: number;
|
|
35
|
+
/** Structures emitted. */
|
|
36
|
+
structures: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Builds the massing mesh: one prism per structure, from below the ground to the roof (see `massingTop`), all in one
|
|
40
|
+
* indexed mesh. Walls carry flat normals, the top is the triangulated footprint with its holes. About 3 triangles per
|
|
41
|
+
* footprint point. Deterministic; the vertices of a structure are consecutive (`spans`), so one structure can be
|
|
42
|
+
* hidden by overwriting its vertices with zeros.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildMassingMesh(specs: readonly BuildingSpec[], dims: ArchMeshDims, options?: MassingOptions): MassingMesh;
|
|
45
|
+
/**
|
|
46
|
+
* Material of the massing mesh. Uniforms: `u_rows` as the full material (`structureUniforms`), `u_fade` (x share of
|
|
47
|
+
* fragments left out, y pattern side; unset = fully drawn) and `u_cellOffset` (unset = positions are world positions).
|
|
48
|
+
* The shadow thins out with the same fade. Needs the includes and frame slots the full structure material needs.
|
|
49
|
+
*/
|
|
50
|
+
export declare function massingMaterial(dims: ArchShadeDims): MaterialDesc;
|
|
51
|
+
/**
|
|
52
|
+
* Stamps the footprints into a class raster: every structure with the code `codeOf` gives it (for example one class
|
|
53
|
+
* per roof covering). Structures smaller than a raster cell keep their total area (see `CodeStamp`). Returns the cells
|
|
54
|
+
* stamped. With `only`, just the structures at these indices of `specs`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function stampFootprints(stamp: CodeStamp, specs: readonly BuildingSpec[], codeOf: (b: BuildingSpec) => number, only?: ReadonlySet<number>): number;
|
|
57
|
+
/**
|
|
58
|
+
* Three tones of a roof covering for a ground class that stands for roofs seen from far above: the span of the
|
|
59
|
+
* per-structure tint of the full shader. `albedoScale` is what the ground bake multiplies its colours by; the tones are
|
|
60
|
+
* divided by it, so the baked ground comes out as bright as the roofs were.
|
|
61
|
+
*/
|
|
62
|
+
export declare function roofTones(color: RGB, albedoScale?: number): [RGB, RGB, RGB];
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// Distant levels of structures, for views where a house is a few pixels.
|
|
2
|
+
//
|
|
3
|
+
// Middle level (massing): every structure is an upright prism over its footprint with a flat top, all structures of a
|
|
4
|
+
// tile merged into one indexed mesh with a small vertex. Its material shades with the same light, weather and snow as
|
|
5
|
+
// the full one and takes the means of what the full shader draws: the wall tint with its share of glass, the mean
|
|
6
|
+
// glow of lit windows, the roof covering. It fades by `u_fade` (core/level-fade.ts) in the colour and the shadow pass,
|
|
7
|
+
// so it can be cross-faded with the full mesh and thinned out towards the far level.
|
|
8
|
+
//
|
|
9
|
+
// Far level (imprint): nothing is drawn. The footprints are stamped into the ground class raster with the code of
|
|
10
|
+
// their roof covering (gen-tex/code-stamp.ts) and the ground bake paints them like any other surface class.
|
|
11
|
+
//
|
|
12
|
+
// Both work per tile: the mesh can be written relative to a tile origin (drawn with `u_cellOffset`), and a stamp works
|
|
13
|
+
// on a rectangle of the raster.
|
|
14
|
+
import earcut from 'earcut';
|
|
15
|
+
import { FADE_GLSL } from '../../core/index.js';
|
|
16
|
+
import { ringSignedArea, unit } from '../../gen-core/index.js';
|
|
17
|
+
import { KIND } from './writer.js';
|
|
18
|
+
// --- Middle level: massing mesh ------------------------------------------------------------------------------------
|
|
19
|
+
export const MASSING_ATTRIBS = { a_pos: 0, a_up: 1, a_normal: 2, a_mat: 3, a_seed: 4 };
|
|
20
|
+
const STRIDE = 28;
|
|
21
|
+
/**
|
|
22
|
+
* Vertex layout of the massing mesh: position, height above the ground the storeys are counted from, normal with the
|
|
23
|
+
* kind of surface in its fourth component (wall 0, top of a pitched roof 1, top of a flat roof 2), palette rows of
|
|
24
|
+
* wall and roof with the window style and the glazed share of the wall (0–255), and the structure's 24-bit tint seed
|
|
25
|
+
* (the same number the full shader derives from the structure hash).
|
|
26
|
+
*/
|
|
27
|
+
export const MASSING_LAYOUT = {
|
|
28
|
+
stride: STRIDE,
|
|
29
|
+
attribs: [
|
|
30
|
+
{ name: 'a_pos', size: 3, type: 'f32', offset: 0 },
|
|
31
|
+
{ name: 'a_up', size: 1, type: 'f32', offset: 12 },
|
|
32
|
+
{ name: 'a_normal', size: 4, type: 'i8', offset: 16 },
|
|
33
|
+
{ name: 'a_mat', size: 4, type: 'u8', integer: true, offset: 20 },
|
|
34
|
+
{ name: 'a_seed', size: 4, type: 'u8', integer: true, offset: 24 },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
/** Top of the prism: the roof surface of a flat roof, halfway up a pitched one (about the same volume). */
|
|
38
|
+
function massingTop(b, dims) {
|
|
39
|
+
if (b.roof === 'flat')
|
|
40
|
+
return b.eaveY;
|
|
41
|
+
const eave = Math.max(b.eaveY, b.groundRef + dims.minWallHeight);
|
|
42
|
+
return Math.max(eave, 0.5 * (eave + b.ridgeY));
|
|
43
|
+
}
|
|
44
|
+
/** Mean share of a wall that is glass, as the full shader draws it (0–1). */
|
|
45
|
+
function glazedShare(b) {
|
|
46
|
+
if (b.facade) {
|
|
47
|
+
const w = b.facade.window;
|
|
48
|
+
return Math.min(0.5, Math.max(0, (w.width * w.height) / Math.max(1, b.bayWidth * b.floorHeightNominal)));
|
|
49
|
+
}
|
|
50
|
+
// Window width × height as shares of a bay and a storey (building-shader.ts, wallColor).
|
|
51
|
+
if (b.windowStyle === 2)
|
|
52
|
+
return 0.8 * 0.48;
|
|
53
|
+
if (b.windowStyle === 3)
|
|
54
|
+
return 0.36 * 0.3;
|
|
55
|
+
if (b.windowStyle === 0)
|
|
56
|
+
return 0;
|
|
57
|
+
const ww = Math.min(0.66, Math.max(0.38, 1.5 / Math.max(b.bayWidth, 0.1)));
|
|
58
|
+
const wh = Math.min(0.62, Math.max(0.3, 1.65 / Math.max(b.floorHeightNominal, 0.1)));
|
|
59
|
+
return ww * wh;
|
|
60
|
+
}
|
|
61
|
+
/** A ring as point indices in the order that gives the wanted winding (outer ring positive area, holes negative). */
|
|
62
|
+
function ringOrder(ring, hole) {
|
|
63
|
+
const n = ring.length >> 1;
|
|
64
|
+
const forward = ringSignedArea(ring) > 0 !== hole;
|
|
65
|
+
const order = [];
|
|
66
|
+
for (let i = 0; i < n; i++)
|
|
67
|
+
order.push(forward ? i : n - 1 - i);
|
|
68
|
+
return order;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Builds the massing mesh: one prism per structure, from below the ground to the roof (see `massingTop`), all in one
|
|
72
|
+
* indexed mesh. Walls carry flat normals, the top is the triangulated footprint with its holes. About 3 triangles per
|
|
73
|
+
* footprint point. Deterministic; the vertices of a structure are consecutive (`spans`), so one structure can be
|
|
74
|
+
* hidden by overwriting its vertices with zeros.
|
|
75
|
+
*/
|
|
76
|
+
export function buildMassingMesh(specs, dims, options = {}) {
|
|
77
|
+
const origin = options.origin ?? [0, 0, 0];
|
|
78
|
+
const spans = new Uint32Array(specs.length + 1);
|
|
79
|
+
let points = 0;
|
|
80
|
+
specs.forEach((b, self) => {
|
|
81
|
+
if (options.only && !options.only.has(self))
|
|
82
|
+
return;
|
|
83
|
+
for (const r of b.rings)
|
|
84
|
+
points += r.length >> 1;
|
|
85
|
+
});
|
|
86
|
+
const buf = new ArrayBuffer(points * 5 * STRIDE);
|
|
87
|
+
const f32 = new Float32Array(buf);
|
|
88
|
+
const i8 = new Int8Array(buf);
|
|
89
|
+
const u8 = new Uint8Array(buf);
|
|
90
|
+
const indices = [];
|
|
91
|
+
let count = 0;
|
|
92
|
+
let minY = Infinity;
|
|
93
|
+
let maxY = -Infinity;
|
|
94
|
+
let structures = 0;
|
|
95
|
+
specs.forEach((b, self) => {
|
|
96
|
+
spans[self] = count;
|
|
97
|
+
if (options.only && !options.only.has(self))
|
|
98
|
+
return;
|
|
99
|
+
const baseY = b.groundMin - dims.wallBelowGround;
|
|
100
|
+
const topY = Math.max(massingTop(b, dims), baseY + 0.5);
|
|
101
|
+
// The seed exactly as the full shader gets it: a float attribute of the hash, scaled to 24 bits.
|
|
102
|
+
const seed = Math.trunc(Math.fround(Math.fround(unit(b.hash)) * 16777215));
|
|
103
|
+
const glass = Math.round(glazedShare(b) * 255);
|
|
104
|
+
const topKind = b.roof === 'flat' ? KIND.roofFlat : KIND.roofPitched;
|
|
105
|
+
const push = (x, y, z, nx, ny, nz, kind) => {
|
|
106
|
+
const o = count * STRIDE;
|
|
107
|
+
const f = o / 4;
|
|
108
|
+
f32[f] = x - origin[0];
|
|
109
|
+
f32[f + 1] = y - origin[1];
|
|
110
|
+
f32[f + 2] = z - origin[2];
|
|
111
|
+
f32[f + 3] = y - b.groundRef;
|
|
112
|
+
i8[o + 16] = Math.round(nx * 127);
|
|
113
|
+
i8[o + 17] = Math.round(ny * 127);
|
|
114
|
+
i8[o + 18] = Math.round(nz * 127);
|
|
115
|
+
i8[o + 19] = kind;
|
|
116
|
+
u8[o + 20] = b.wallColor;
|
|
117
|
+
u8[o + 21] = b.roofColor;
|
|
118
|
+
u8[o + 22] = b.windowStyle;
|
|
119
|
+
u8[o + 23] = glass;
|
|
120
|
+
u8[o + 24] = seed & 255;
|
|
121
|
+
u8[o + 25] = (seed >> 8) & 255;
|
|
122
|
+
u8[o + 26] = (seed >> 16) & 255;
|
|
123
|
+
u8[o + 27] = 0;
|
|
124
|
+
return count++;
|
|
125
|
+
};
|
|
126
|
+
// Top: the footprint triangulated with its holes, facing up.
|
|
127
|
+
const coords = [];
|
|
128
|
+
const holes = [];
|
|
129
|
+
const orders = [];
|
|
130
|
+
for (const ring of b.rings) {
|
|
131
|
+
if (ring.length < 6)
|
|
132
|
+
continue;
|
|
133
|
+
if (coords.length > 0)
|
|
134
|
+
holes.push(coords.length / 2);
|
|
135
|
+
const order = ringOrder(ring, coords.length > 0);
|
|
136
|
+
orders.push(order);
|
|
137
|
+
for (const i of order)
|
|
138
|
+
coords.push(ring[i * 2], ring[i * 2 + 1]);
|
|
139
|
+
}
|
|
140
|
+
if (coords.length < 6)
|
|
141
|
+
return;
|
|
142
|
+
structures++;
|
|
143
|
+
const top0 = count;
|
|
144
|
+
for (let i = 0; i < coords.length; i += 2)
|
|
145
|
+
push(coords[i], topY, coords[i + 1], 0, 1, 0, topKind);
|
|
146
|
+
const tris = earcut(coords, holes, 2);
|
|
147
|
+
for (let t = 0; t + 2 < tris.length; t += 3) {
|
|
148
|
+
const a = tris[t];
|
|
149
|
+
let p = tris[t + 1];
|
|
150
|
+
let q = tris[t + 2];
|
|
151
|
+
const area2 = (coords[p * 2] - coords[a * 2]) * (coords[q * 2 + 1] - coords[a * 2 + 1]) - (coords[q * 2] - coords[a * 2]) * (coords[p * 2 + 1] - coords[a * 2 + 1]);
|
|
152
|
+
// Facing up means a negative turn in the x–z plane.
|
|
153
|
+
if (area2 > 0)
|
|
154
|
+
[p, q] = [q, p];
|
|
155
|
+
indices.push(top0 + a, top0 + p, top0 + q);
|
|
156
|
+
}
|
|
157
|
+
// Walls: one quad per footprint edge, the outward normal to the right of the edge direction.
|
|
158
|
+
let at = 0;
|
|
159
|
+
for (const order of orders) {
|
|
160
|
+
const n = order.length;
|
|
161
|
+
for (let i = 0; i < n; i++) {
|
|
162
|
+
const j = (i + 1) % n;
|
|
163
|
+
const ax = coords[(at + i) * 2];
|
|
164
|
+
const az = coords[(at + i) * 2 + 1];
|
|
165
|
+
const bx = coords[(at + j) * 2];
|
|
166
|
+
const bz = coords[(at + j) * 2 + 1];
|
|
167
|
+
const len = Math.hypot(bx - ax, bz - az);
|
|
168
|
+
if (len < 1e-3)
|
|
169
|
+
continue;
|
|
170
|
+
const nx = (bz - az) / len;
|
|
171
|
+
const nz = -(bx - ax) / len;
|
|
172
|
+
const v0 = push(ax, baseY, az, nx, 0, nz, KIND.wall);
|
|
173
|
+
const v1 = push(ax, topY, az, nx, 0, nz, KIND.wall);
|
|
174
|
+
const v2 = push(bx, topY, bz, nx, 0, nz, KIND.wall);
|
|
175
|
+
const v3 = push(bx, baseY, bz, nx, 0, nz, KIND.wall);
|
|
176
|
+
indices.push(v0, v2, v3, v0, v1, v2);
|
|
177
|
+
}
|
|
178
|
+
at += n;
|
|
179
|
+
}
|
|
180
|
+
if (baseY < minY)
|
|
181
|
+
minY = baseY;
|
|
182
|
+
if (topY > maxY)
|
|
183
|
+
maxY = topY;
|
|
184
|
+
});
|
|
185
|
+
spans[specs.length] = count;
|
|
186
|
+
const vertices = new Uint8Array(buf, 0, count * STRIDE);
|
|
187
|
+
const mesh = {
|
|
188
|
+
layout: MASSING_LAYOUT,
|
|
189
|
+
vertices,
|
|
190
|
+
indices: count <= 65535 ? Uint16Array.from(indices) : Uint32Array.from(indices),
|
|
191
|
+
count: indices.length,
|
|
192
|
+
};
|
|
193
|
+
return { mesh, spans, minY: structures > 0 ? minY : 0, maxY: structures > 0 ? maxY : 0, structures };
|
|
194
|
+
}
|
|
195
|
+
const MASSING_VS = /* glsl */ `#include <header>
|
|
196
|
+
uniform vec3 u_cellOffset;
|
|
197
|
+
in vec3 a_pos;
|
|
198
|
+
in float a_up;
|
|
199
|
+
in vec4 a_normal;
|
|
200
|
+
in uvec4 a_mat;
|
|
201
|
+
in uvec4 a_seed;
|
|
202
|
+
out vec3 v_world;
|
|
203
|
+
out float v_up;
|
|
204
|
+
flat out vec3 v_normal;
|
|
205
|
+
flat out int v_kind;
|
|
206
|
+
flat out uvec4 v_mat;
|
|
207
|
+
flat out uint v_seed;
|
|
208
|
+
void main() {
|
|
209
|
+
vec3 pos = a_pos + u_cellOffset;
|
|
210
|
+
v_world = pos;
|
|
211
|
+
v_up = a_up;
|
|
212
|
+
v_normal = normalize(a_normal.xyz + vec3(0.0, 1e-4, 0.0));
|
|
213
|
+
v_kind = int(a_normal.w);
|
|
214
|
+
v_mat = a_mat;
|
|
215
|
+
v_seed = a_seed.x | (a_seed.y << 8) | (a_seed.z << 16);
|
|
216
|
+
gl_Position = u_viewProj * vec4(pos, 1.0);
|
|
217
|
+
}`;
|
|
218
|
+
const f = (v) => v.toFixed(3);
|
|
219
|
+
/** Means of the full structure shading (building-shader.ts): keep the tint formulas in step with it. */
|
|
220
|
+
const massingFs = (dims) => /* glsl */ `#include <header>
|
|
221
|
+
#include <noise>
|
|
222
|
+
#include <lighting>
|
|
223
|
+
#include <snow>
|
|
224
|
+
uniform ivec4 u_rows; // palette rows: glass, glass with sky reflection (the rest unused here)
|
|
225
|
+
in vec3 v_world;
|
|
226
|
+
in float v_up;
|
|
227
|
+
flat in vec3 v_normal;
|
|
228
|
+
flat in int v_kind;
|
|
229
|
+
flat in uvec4 v_mat;
|
|
230
|
+
flat in uint v_seed;
|
|
231
|
+
out vec4 o_color;
|
|
232
|
+
${FADE_GLSL}
|
|
233
|
+
void main() {
|
|
234
|
+
if (fadeHidden(gl_FragCoord.xy)) discard;
|
|
235
|
+
vec3 n = v_normal;
|
|
236
|
+
uint seed = v_seed;
|
|
237
|
+
vec3 col;
|
|
238
|
+
vec3 glow = vec3(0.0);
|
|
239
|
+
float ao = 1.0;
|
|
240
|
+
if (v_kind == 0) {
|
|
241
|
+
// Wall: the structure's tint, with the mean glass tone over the glazed share.
|
|
242
|
+
vec3 wall = u_palette[v_mat.x].rgb * (0.88 + 0.22 * hash1(seed + 1u));
|
|
243
|
+
wall *= mix(vec3(1.0), vec3(1.05, 1.0, 0.9), hash1(seed + 2u));
|
|
244
|
+
float glass = float(v_mat.w) / 255.0;
|
|
245
|
+
vec3 glassCol = mix(u_palette[u_rows.x].rgb, u_palette[u_rows.y].rgb, 0.23);
|
|
246
|
+
col = mix(wall, glassCol, glass);
|
|
247
|
+
// The wall darkens at its foot, so the house sits on the ground.
|
|
248
|
+
ao = mix(0.5, 1.0, smoothstep(-0.3, ${f(dims.wallBaseShadeHeight)}, v_up));
|
|
249
|
+
if (u_time.z > 0.0) {
|
|
250
|
+
// Lit windows merged into their mean: the share lit tonight in this house times the glazed share.
|
|
251
|
+
float habit = 0.35 + 1.3 * hash1(seed + 9u);
|
|
252
|
+
float lit = clamp(u_time.w * habit * (v_mat.z == 1u ? 1.0 : 0.55), 0.0, 0.95);
|
|
253
|
+
glow = vec3(0.975, 0.77, 0.46) * (glass * lit * u_time.z / u_warmTint.a);
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
// Roof covering; a pitched roof is a little darker by its courses.
|
|
257
|
+
col = u_palette[v_mat.y].rgb * (0.82 + 0.18 * hash1(seed + 3u)) * (v_kind == 1 ? 0.95 : 1.0);
|
|
258
|
+
}
|
|
259
|
+
col *= 1.0 - u_weather.y * (v_kind == 0 ? 0.1 : 0.22);
|
|
260
|
+
if (v_kind != 0) {
|
|
261
|
+
float snow = snowOn(v_world, n, v_kind == 2 ? 0.18 : 0.06);
|
|
262
|
+
col = mix(col, u_snow.rgb * (0.97 + 0.06 * hash1(seed + 5u)), snow);
|
|
263
|
+
}
|
|
264
|
+
float sun = sunVisibility(v_world, n, 1.6);
|
|
265
|
+
vec3 light = lightOn(n, sun, ao) * mix(0.78, 1.0, ao);
|
|
266
|
+
o_color = vec4(applyFog(toDisplay(col * u_warmTint.rgb * light + glow), v_world), 1.0);
|
|
267
|
+
}`;
|
|
268
|
+
const MASSING_DEPTH_VS = /* glsl */ `#include <header>
|
|
269
|
+
uniform mat4 u_lightRender;
|
|
270
|
+
uniform vec3 u_cellOffset;
|
|
271
|
+
in vec3 a_pos;
|
|
272
|
+
void main() {
|
|
273
|
+
gl_Position = u_lightRender * vec4(a_pos + u_cellOffset, 1.0);
|
|
274
|
+
}`;
|
|
275
|
+
const MASSING_DEPTH_FS = /* glsl */ `#version 300 es
|
|
276
|
+
precision highp float;
|
|
277
|
+
${FADE_GLSL}
|
|
278
|
+
void main() {
|
|
279
|
+
if (fadeHidden(gl_FragCoord.xy)) discard;
|
|
280
|
+
}`;
|
|
281
|
+
/**
|
|
282
|
+
* Material of the massing mesh. Uniforms: `u_rows` as the full material (`structureUniforms`), `u_fade` (x share of
|
|
283
|
+
* fragments left out, y pattern side; unset = fully drawn) and `u_cellOffset` (unset = positions are world positions).
|
|
284
|
+
* The shadow thins out with the same fade. Needs the includes and frame slots the full structure material needs.
|
|
285
|
+
*/
|
|
286
|
+
export function massingMaterial(dims) {
|
|
287
|
+
return {
|
|
288
|
+
name: 'structures-massing',
|
|
289
|
+
attribs: MASSING_ATTRIBS,
|
|
290
|
+
passes: { shadow: { vs: MASSING_DEPTH_VS, fs: MASSING_DEPTH_FS }, color: { vs: MASSING_VS, fs: massingFs(dims) } },
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
// --- Far level: imprint into the ground class raster ---------------------------------------------------------------
|
|
294
|
+
/**
|
|
295
|
+
* Stamps the footprints into a class raster: every structure with the code `codeOf` gives it (for example one class
|
|
296
|
+
* per roof covering). Structures smaller than a raster cell keep their total area (see `CodeStamp`). Returns the cells
|
|
297
|
+
* stamped. With `only`, just the structures at these indices of `specs`.
|
|
298
|
+
*/
|
|
299
|
+
export function stampFootprints(stamp, specs, codeOf, only) {
|
|
300
|
+
let n = 0;
|
|
301
|
+
specs.forEach((b, self) => {
|
|
302
|
+
if (only && !only.has(self))
|
|
303
|
+
return;
|
|
304
|
+
n += stamp.polygon(b.rings, codeOf(b), b.hash);
|
|
305
|
+
});
|
|
306
|
+
return n;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Three tones of a roof covering for a ground class that stands for roofs seen from far above: the span of the
|
|
310
|
+
* per-structure tint of the full shader. `albedoScale` is what the ground bake multiplies its colours by; the tones are
|
|
311
|
+
* divided by it, so the baked ground comes out as bright as the roofs were.
|
|
312
|
+
*/
|
|
313
|
+
export function roofTones(color, albedoScale = 1) {
|
|
314
|
+
const tone = (k) => [Math.min(1, (color[0] * k) / albedoScale), Math.min(1, (color[1] * k) / albedoScale), Math.min(1, (color[2] * k) / albedoScale)];
|
|
315
|
+
return [tone(0.84), tone(0.91), tone(0.98)];
|
|
316
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EnvSlot } from '../../base/index.ts';
|
|
2
|
+
/** Lit windows at night. */
|
|
3
|
+
export interface WindowLight {
|
|
4
|
+
/** Share of lit windows by hour: pairs [hour, share], blended linearly between them. */
|
|
5
|
+
shareByHour: readonly (readonly [number, number])[];
|
|
6
|
+
/** Glow strength. */
|
|
7
|
+
strength: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WindowLightState {
|
|
10
|
+
/** Glow 0–1 (0 in daylight and in studio light) and share of lit windows. */
|
|
11
|
+
glow: number;
|
|
12
|
+
share: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_WINDOWS: WindowLight;
|
|
15
|
+
/** Share of lit windows at a given hour. */
|
|
16
|
+
export declare function windowShare(hour: number, table?: WindowLight['shareByHour']): number;
|
|
17
|
+
/** Window light slot: fills the free lanes of the engine's `u_time` member. Nothing glows in studio or fixed light. */
|
|
18
|
+
export declare function windowLightSlot(windows?: Partial<WindowLight>): EnvSlot<WindowLight, WindowLightState>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Environment slot of this package: lit windows at night. The app registers it with the engine
|
|
2
|
+
// (`assembleFrameBlock`); the structure shader reads `u_time.z` (glow) and `u_time.w` (share of lit windows).
|
|
3
|
+
import { lerp, smoothstep } from '../../base/index.js';
|
|
4
|
+
export const DEFAULT_WINDOWS = {
|
|
5
|
+
shareByHour: [
|
|
6
|
+
[0, 0.12],
|
|
7
|
+
[2, 0.04],
|
|
8
|
+
[4.5, 0.04],
|
|
9
|
+
[6, 0.2],
|
|
10
|
+
[7.5, 0.28],
|
|
11
|
+
[16, 0.28],
|
|
12
|
+
[18, 0.42],
|
|
13
|
+
[20, 0.58],
|
|
14
|
+
[21.5, 0.62],
|
|
15
|
+
[22.5, 0.46],
|
|
16
|
+
[23.5, 0.22],
|
|
17
|
+
[24, 0.12],
|
|
18
|
+
],
|
|
19
|
+
strength: 1.0,
|
|
20
|
+
};
|
|
21
|
+
/** Windows light up at dusk: sun heights in degrees between which the glow fades out. */
|
|
22
|
+
const GLOW_FROM = -4;
|
|
23
|
+
const GLOW_TO = 8;
|
|
24
|
+
/** Share of lit windows at a given hour. */
|
|
25
|
+
export function windowShare(hour, table = DEFAULT_WINDOWS.shareByHour) {
|
|
26
|
+
if (table.length === 0)
|
|
27
|
+
return 0;
|
|
28
|
+
for (let i = 0; i + 1 < table.length; i++) {
|
|
29
|
+
const [h0, s0] = table[i];
|
|
30
|
+
const [h1, s1] = table[i + 1];
|
|
31
|
+
if (hour >= h0 && hour <= h1)
|
|
32
|
+
return h1 > h0 ? lerp(s0, s1, (hour - h0) / (h1 - h0)) : s1;
|
|
33
|
+
}
|
|
34
|
+
return hour < table[0][0] ? table[0][1] : table[table.length - 1][1];
|
|
35
|
+
}
|
|
36
|
+
/** Window light slot: fills the free lanes of the engine's `u_time` member. Nothing glows in studio or fixed light. */
|
|
37
|
+
export function windowLightSlot(windows = {}) {
|
|
38
|
+
return {
|
|
39
|
+
name: 'window-light',
|
|
40
|
+
params: { ...DEFAULT_WINDOWS, ...windows },
|
|
41
|
+
fields: [{ member: 'u_time', lanes: 'zw', doc: 'z window glow 0–1, w share of lit windows' }],
|
|
42
|
+
compute: (env, p) => env.mode !== 'day'
|
|
43
|
+
? { glow: 0, share: 0 }
|
|
44
|
+
: { glow: (1 - smoothstep(GLOW_FROM, GLOW_TO, env.sunElevationDeg)) * p.strength, share: windowShare(env.hour, p.shareByHour) },
|
|
45
|
+
lanes: (s) => [s.glow, s.share],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { Ring } from '../../gen-core/index.ts';
|
|
2
|
+
/** How the ground floor differs from the floors above. */
|
|
3
|
+
export declare const GROUND_FLOOR: {
|
|
4
|
+
/** Same windows as the floors above. */
|
|
5
|
+
readonly windows: 0;
|
|
6
|
+
/** Large glazing (lobby, shop, university entrance hall). */
|
|
7
|
+
readonly glazed: 1;
|
|
8
|
+
/** Small high windows (utility rooms, garages, halls). */
|
|
9
|
+
readonly high: 2;
|
|
10
|
+
/** No windows. */
|
|
11
|
+
readonly blind: 3;
|
|
12
|
+
};
|
|
13
|
+
export type GroundFloorKind = (typeof GROUND_FLOOR)[keyof typeof GROUND_FLOOR];
|
|
14
|
+
/** Kind of opening an entrance gets. Codes are what the shader reads. */
|
|
15
|
+
export declare const DOOR_KIND: {
|
|
16
|
+
readonly none: 0;
|
|
17
|
+
readonly door: 1;
|
|
18
|
+
readonly garage: 2;
|
|
19
|
+
readonly portal: 3;
|
|
20
|
+
readonly arch: 4;
|
|
21
|
+
};
|
|
22
|
+
/** `arch`: a leaf with a half-round head, as wide as the entrance; its height follows the width (`FACADE_DIM.archHeightPerWidth`). */
|
|
23
|
+
export type DoorKind = 'door' | 'garage' | 'portal' | 'arch';
|
|
24
|
+
export interface WindowRecipe {
|
|
25
|
+
/** Size of the standard window in metres and its sill height above the floor. */
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
sill: number;
|
|
29
|
+
/** Vertical glazing bars: 0, 1 (centre) or 2 (thirds). */
|
|
30
|
+
mullions: 0 | 1 | 2;
|
|
31
|
+
/** Horizontal bar in the upper part of the window (older casement windows). */
|
|
32
|
+
transom: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Four-bit mask over a period of four window columns: a set bit makes that column a narrow window
|
|
35
|
+
* (kitchen, bathroom, stairs side). 0 = all columns the same.
|
|
36
|
+
*/
|
|
37
|
+
narrowMask: number;
|
|
38
|
+
/**
|
|
39
|
+
* Half-round head as wide as the window (the height includes it). Such a window may be taller than an ordinary one
|
|
40
|
+
* (up to 20.4 m instead of 5.1 m). Interior and damaged openings stay rectangles of the full height.
|
|
41
|
+
*/
|
|
42
|
+
arch?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A shutter leaf on each side of every window, each 0.45 × the window width, in the `accent` row. Drawn by the
|
|
45
|
+
* `finishes` variant of the structure material only.
|
|
46
|
+
*/
|
|
47
|
+
shutters?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface BalconyRecipe {
|
|
50
|
+
/** balcony: a slab with a solid parapet standing out of the wall; loggia: a shallow parapet with a dark recess behind. */
|
|
51
|
+
kind: 'balcony' | 'loggia';
|
|
52
|
+
/** How far the parapet stands out of the wall. */
|
|
53
|
+
depth: number;
|
|
54
|
+
/** Four-bit mask over a period of four window columns: which columns carry a balcony. */
|
|
55
|
+
columnMask: number;
|
|
56
|
+
/** Walls shorter than this get none. */
|
|
57
|
+
minWallLength: number;
|
|
58
|
+
/** Keep walls with an entrance free of balconies (typical for small houses with one door). */
|
|
59
|
+
avoidEntranceWalls?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface CorniceRecipe {
|
|
62
|
+
/** Height of the moulding band under the eave and how far it stands out. */
|
|
63
|
+
height: number;
|
|
64
|
+
projection: number;
|
|
65
|
+
/** The band also gets its face looking down (an overhang above it is then closed). */
|
|
66
|
+
underside?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** One entrance. The application gives a preferred point; the engine picks the nearest free wall. */
|
|
69
|
+
export interface EntranceSpec {
|
|
70
|
+
x: number;
|
|
71
|
+
z: number;
|
|
72
|
+
kind: DoorKind;
|
|
73
|
+
/** Clear width of the opening. */
|
|
74
|
+
width: number;
|
|
75
|
+
/** Threshold height above the terrain in front of the door. Steps fill the difference. */
|
|
76
|
+
raise: number;
|
|
77
|
+
/** Depth of the canopy above the door, 0 = none. */
|
|
78
|
+
canopy: number;
|
|
79
|
+
}
|
|
80
|
+
/** A superstructure box with absolute top height (metres above sea level), e.g. measured by lidar. */
|
|
81
|
+
export interface RoofBoxSpec {
|
|
82
|
+
cx: number;
|
|
83
|
+
cz: number;
|
|
84
|
+
ux: number;
|
|
85
|
+
uz: number;
|
|
86
|
+
halfL: number;
|
|
87
|
+
halfW: number;
|
|
88
|
+
topY: number;
|
|
89
|
+
}
|
|
90
|
+
export interface FacadeRecipe {
|
|
91
|
+
/** Ground floor height; the floors above share the rest of the wall. 0 = same as the floors above. */
|
|
92
|
+
groundFloorHeight: number;
|
|
93
|
+
groundFloor: GroundFloorKind;
|
|
94
|
+
plinthHeight: number;
|
|
95
|
+
window: WindowRecipe;
|
|
96
|
+
/** Share of windows with curtains and with lowered blinds (0–1, chosen per window by hash). */
|
|
97
|
+
curtainShare: number;
|
|
98
|
+
blindShare: number;
|
|
99
|
+
/** Prefab panel joints along floors and window columns, with a slight tone per panel. */
|
|
100
|
+
panelJoints: boolean;
|
|
101
|
+
/** On an elongated building, end walls shorter than this have no windows (blind gables). 0 = off. */
|
|
102
|
+
blindEndWalls: number;
|
|
103
|
+
balconies: BalconyRecipe | null;
|
|
104
|
+
cornice: CorniceRecipe | null;
|
|
105
|
+
entrances: EntranceSpec[];
|
|
106
|
+
/** Stairwell window strip above each door (landing windows offset by half a floor). */
|
|
107
|
+
stairStrip: boolean;
|
|
108
|
+
/** Chimneys on a pitched roof, 0 = none. */
|
|
109
|
+
chimneys: number;
|
|
110
|
+
/** Superstructures on a flat roof. null = the engine places procedural ones, [] = none. */
|
|
111
|
+
roofBoxes: RoofBoxSpec[] | null;
|
|
112
|
+
/** Palette rows. */
|
|
113
|
+
colors: {
|
|
114
|
+
frame: number;
|
|
115
|
+
plinth: number;
|
|
116
|
+
door: number;
|
|
117
|
+
accent: number;
|
|
118
|
+
chimney: number;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Distances and sizes for façade geometry. */
|
|
122
|
+
export declare const FACADE_DIM: {
|
|
123
|
+
/** Door height above the threshold, garage door and glazed portal. */
|
|
124
|
+
readonly doorHeight: 2.25;
|
|
125
|
+
readonly garageDoorHeight: 2.1;
|
|
126
|
+
readonly portalHeight: 2.7;
|
|
127
|
+
/** One step: rise and tread. */
|
|
128
|
+
readonly stepRise: 0.16;
|
|
129
|
+
readonly stepTread: 0.3;
|
|
130
|
+
/** Landing in front of the door. */
|
|
131
|
+
readonly landingDepth: 1;
|
|
132
|
+
/** Below this difference between threshold and terrain no steps are built. */
|
|
133
|
+
readonly minStepHeight: 0.1;
|
|
134
|
+
readonly maxSteps: 7;
|
|
135
|
+
/** How deep the steps reach under the terrain so they never float on a slope. */
|
|
136
|
+
readonly stepSink: 0.3;
|
|
137
|
+
/** Canopy: gap above the door, slab thickness and how much wider than the door it is. */
|
|
138
|
+
readonly canopyGap: 0.25;
|
|
139
|
+
readonly canopyThickness: 0.16;
|
|
140
|
+
readonly canopyExtraWidth: 0.9;
|
|
141
|
+
/** Distance from a wall end to the nearest door or balcony edge. */
|
|
142
|
+
readonly wallEndMargin: 0.45;
|
|
143
|
+
/** Balcony slab thickness and parapet height above the floor. */
|
|
144
|
+
readonly balconySlab: 0.16;
|
|
145
|
+
readonly balconyParapet: 1.05;
|
|
146
|
+
/** Balcony width as a share of the window column, and its cap in metres. */
|
|
147
|
+
readonly balconyColumnShare: 0.84;
|
|
148
|
+
readonly balconyMaxWidth: 3.8;
|
|
149
|
+
/** Cornice top sits this much under the wall top so it never shares a plane with a parapet. */
|
|
150
|
+
readonly corniceTopGap: 0.04;
|
|
151
|
+
/** Chimney size and how far it stands above the ridge. */
|
|
152
|
+
readonly chimneySize: readonly [0.55, 0.75];
|
|
153
|
+
readonly chimneyAboveRidge: 0.85;
|
|
154
|
+
/** Sample offset in front of a wall when testing whether a neighbour stands there. */
|
|
155
|
+
readonly partyProbe: 0.3;
|
|
156
|
+
/** Share of a wall covered by a neighbour from which the wall counts as a shared (party) wall. */
|
|
157
|
+
readonly partyShare: 0.5;
|
|
158
|
+
/** Superstructures keep this distance from the roof edge (parapet thickness included). */
|
|
159
|
+
readonly roofBoxMargin: 0.45;
|
|
160
|
+
/** Lowest superstructure worth drawing. */
|
|
161
|
+
readonly roofBoxMinHeight: 0.4;
|
|
162
|
+
/** Height of an arch door as a multiple of its width (the head included). */
|
|
163
|
+
readonly archHeightPerWidth: 1.5;
|
|
164
|
+
};
|
|
165
|
+
/** Bits of the per-vertex façade flags (`a_bits.x`). The building shader reads the same numbers. */
|
|
166
|
+
export declare const FACADE_FLAG: {
|
|
167
|
+
readonly recipe: 1;
|
|
168
|
+
readonly blind: 2;
|
|
169
|
+
readonly panelJoints: 4;
|
|
170
|
+
readonly stairStrip: 8;
|
|
171
|
+
readonly transom: 16;
|
|
172
|
+
readonly balconies: 32;
|
|
173
|
+
readonly loggia: 64;
|
|
174
|
+
readonly cornice: 128;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Footprints of all buildings with a coarse grid, for "does another building stand here" queries:
|
|
178
|
+
* shared walls, and façade elements that would poke into a neighbour.
|
|
179
|
+
*/
|
|
180
|
+
export declare class FootprintIndex {
|
|
181
|
+
private readonly cell;
|
|
182
|
+
private readonly grid;
|
|
183
|
+
private readonly rings;
|
|
184
|
+
constructor(rings: Ring[][]);
|
|
185
|
+
/** Is the point inside a building other than `self` (and other than those `skip` names)? */
|
|
186
|
+
occupied(x: number, z: number, self: number, skip?: (i: number) => boolean): boolean;
|
|
187
|
+
/** Is any of the points inside another building? Points as flat x, z pairs. */
|
|
188
|
+
anyOccupied(pts: readonly number[], self: number, skip?: (i: number) => boolean): boolean;
|
|
189
|
+
}
|
|
190
|
+
/** Share of the wall from a to b that has another building (not one `skip` names) right in front of it. */
|
|
191
|
+
export declare function partyShare(index: FootprintIndex, self: number, ax: number, az: number, bx: number, bz: number, skip?: (i: number) => boolean): number;
|
|
192
|
+
/** Corners of a box standing in front of a wall: from `u0` to `u1` along the wall, `d0` to `d1` out of it. */
|
|
193
|
+
export declare function wallBoxCorners(ax: number, az: number, dx: number, dz: number, u0: number, u1: number, d0: number, d1: number): number[];
|