wallhammer-web 0.0.0-stage → 0.4.1
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 +92 -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,99 @@
|
|
|
1
|
+
import type { OrthoFrame, Vec3 } from '../base/math.ts';
|
|
2
|
+
import type { CullVolume, Ray, View } from '../base/view.ts';
|
|
3
|
+
export interface CameraSetup {
|
|
4
|
+
/** Rotation around the vertical axis at rotation 0, in degrees. 0 = we look from the south to the north. */
|
|
5
|
+
yawDeg: number;
|
|
6
|
+
/** Elevation above the horizon for each zoom level, in degrees. */
|
|
7
|
+
pitchDegByZoom: readonly number[];
|
|
8
|
+
/** Scale for each level: CSS pixels per metre in the horizontal direction that the camera does not foreshorten. */
|
|
9
|
+
pxPerMeterByZoom: readonly number[];
|
|
10
|
+
}
|
|
11
|
+
export interface ViewState {
|
|
12
|
+
rotation: number;
|
|
13
|
+
zoom: number;
|
|
14
|
+
center: {
|
|
15
|
+
x: number;
|
|
16
|
+
z: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class SteppedOrthoRig implements View {
|
|
20
|
+
private _setup;
|
|
21
|
+
rotation: number;
|
|
22
|
+
zoom: number;
|
|
23
|
+
centerX: number;
|
|
24
|
+
centerZ: number;
|
|
25
|
+
/** Height of the plane along which the view centre moves. */
|
|
26
|
+
refHeight: number;
|
|
27
|
+
/** Canvas size in physical pixels. */
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
/** Physical pixels per one CSS pixel. */
|
|
31
|
+
dpr: number;
|
|
32
|
+
/** Limits of the view centre in the world. */
|
|
33
|
+
bounds: {
|
|
34
|
+
minX: number;
|
|
35
|
+
maxX: number;
|
|
36
|
+
minZ: number;
|
|
37
|
+
maxZ: number;
|
|
38
|
+
};
|
|
39
|
+
/** Scratch of the methods that take `out`, so they allocate nothing themselves. */
|
|
40
|
+
private readonly scratch;
|
|
41
|
+
private readonly scratchC;
|
|
42
|
+
/** The numbers the last `key` was made from (NaN: none yet) and that key. */
|
|
43
|
+
private readonly keyOf;
|
|
44
|
+
private keyText;
|
|
45
|
+
constructor(setup: CameraSetup);
|
|
46
|
+
private static checked;
|
|
47
|
+
get setup(): CameraSetup;
|
|
48
|
+
/** Replaces the angle and zoom tables at run time. The zoom level is clamped to the new table. */
|
|
49
|
+
setSetup(setup: CameraSetup): void;
|
|
50
|
+
get zoomLevels(): number;
|
|
51
|
+
get yaw(): number;
|
|
52
|
+
get pitch(): number;
|
|
53
|
+
/** Physical pixels per metre. */
|
|
54
|
+
get scale(): number;
|
|
55
|
+
/** View: rotation around the vertical axis in radians. */
|
|
56
|
+
get heading(): number;
|
|
57
|
+
/** View: metres per physical pixel; constant over the image since there is no perspective. */
|
|
58
|
+
get metresPerPixel(): number;
|
|
59
|
+
/** View: no perspective, the pixel size does not change with depth. */
|
|
60
|
+
readonly pixelGrowth = 0;
|
|
61
|
+
readonly refDepth = 0;
|
|
62
|
+
axes(out?: OrthoFrame): OrthoFrame;
|
|
63
|
+
/** View: rays through the image corners, starting in the camera plane through the unsnapped view centre. */
|
|
64
|
+
cornerRays(out?: Ray[]): Ray[];
|
|
65
|
+
/** View: the visible rectangle in the camera plane. */
|
|
66
|
+
cullVolume(): CullVolume;
|
|
67
|
+
/** View: changes whenever the image of a static scene would. */
|
|
68
|
+
key(): string;
|
|
69
|
+
/** The view's axes. With `out` its arrays are written and `out` is returned. */
|
|
70
|
+
frame(out?: OrthoFrame): OrthoFrame;
|
|
71
|
+
/** Horizontal direction "away from the viewer", along which the centre moves when dragging up and down. */
|
|
72
|
+
private forwardOnGround;
|
|
73
|
+
/**
|
|
74
|
+
* World → clip space matrix. The centre is snapped to whole pixels, so the image moves
|
|
75
|
+
* in whole pixels when panning and nothing shimmers. Depth is relative to the scene centre and does not depend on panning.
|
|
76
|
+
*/
|
|
77
|
+
viewProj(sceneCenter: Vec3, depthHalfRange: number, out?: Float32Array): Float32Array;
|
|
78
|
+
/** View centre in the camera plane snapped to whole pixels, same as in `viewProj`. */
|
|
79
|
+
private snappedCenter;
|
|
80
|
+
/**
|
|
81
|
+
* Ray under a screen point. `px`, `py` are physical canvas pixels from the top-left corner
|
|
82
|
+
* (pixel centre is +0.5). The origin lies in the camera plane through the view centre, the direction is
|
|
83
|
+
* the view direction: the camera has no perspective, all rays are parallel.
|
|
84
|
+
*/
|
|
85
|
+
screenRay(px: number, py: number): {
|
|
86
|
+
origin: Vec3;
|
|
87
|
+
dir: Vec3;
|
|
88
|
+
};
|
|
89
|
+
/** Where a world point lands on the canvas: physical pixels from the top-left corner. Inverse of `screenRay`. */
|
|
90
|
+
project(p: Vec3): [number, number];
|
|
91
|
+
/** Pan by screen pixels: the content follows the cursor. */
|
|
92
|
+
panPixels(dx: number, dy: number): void;
|
|
93
|
+
setZoom(z: number): void;
|
|
94
|
+
setRotation(r: number): void;
|
|
95
|
+
clampCenter(): void;
|
|
96
|
+
state(): ViewState;
|
|
97
|
+
/** Largest zoom level at which the world rectangle sizeX × sizeZ still fits entirely on the canvas. */
|
|
98
|
+
fitZoom(sizeX: number, sizeZ: number, heightSpan: number): number;
|
|
99
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Camera rig without perspective: 4 rotations by 90°, a table of fixed zoom levels, panning over a reference plane.
|
|
2
|
+
// It receives the angles and the zoom table from outside and holds no numbers itself. Implements `View` for the renderer.
|
|
3
|
+
import { DEG, clamp, crossInto, dot, orthoMatrix } from '../base/math.js';
|
|
4
|
+
export class SteppedOrthoRig {
|
|
5
|
+
_setup;
|
|
6
|
+
rotation = 0;
|
|
7
|
+
zoom = 0;
|
|
8
|
+
centerX = 0;
|
|
9
|
+
centerZ = 0;
|
|
10
|
+
/** Height of the plane along which the view centre moves. */
|
|
11
|
+
refHeight = 0;
|
|
12
|
+
/** Canvas size in physical pixels. */
|
|
13
|
+
width = 1;
|
|
14
|
+
height = 1;
|
|
15
|
+
/** Physical pixels per one CSS pixel. */
|
|
16
|
+
dpr = 1;
|
|
17
|
+
/** Limits of the view centre in the world. */
|
|
18
|
+
bounds = { minX: 0, maxX: 1, minZ: 0, maxZ: 1 };
|
|
19
|
+
/** Scratch of the methods that take `out`, so they allocate nothing themselves. */
|
|
20
|
+
scratch = { right: [0, 0, 0], up: [0, 0, 0], forward: [0, 0, 0] };
|
|
21
|
+
scratchC = [0, 0, 0];
|
|
22
|
+
/** The numbers the last `key` was made from (NaN: none yet) and that key. */
|
|
23
|
+
keyOf = new Float64Array(6).fill(NaN);
|
|
24
|
+
keyText = '';
|
|
25
|
+
constructor(setup) {
|
|
26
|
+
this._setup = SteppedOrthoRig.checked(setup);
|
|
27
|
+
}
|
|
28
|
+
static checked(setup) {
|
|
29
|
+
if (setup.pitchDegByZoom.length !== setup.pxPerMeterByZoom.length) {
|
|
30
|
+
throw new Error('The pitch table and the scale table must have the same number of levels');
|
|
31
|
+
}
|
|
32
|
+
return setup;
|
|
33
|
+
}
|
|
34
|
+
get setup() {
|
|
35
|
+
return this._setup;
|
|
36
|
+
}
|
|
37
|
+
/** Replaces the angle and zoom tables at run time. The zoom level is clamped to the new table. */
|
|
38
|
+
setSetup(setup) {
|
|
39
|
+
this._setup = SteppedOrthoRig.checked(setup);
|
|
40
|
+
this.zoom = Math.max(0, Math.min(this.zoomLevels - 1, this.zoom));
|
|
41
|
+
}
|
|
42
|
+
get zoomLevels() {
|
|
43
|
+
return this.setup.pxPerMeterByZoom.length;
|
|
44
|
+
}
|
|
45
|
+
get yaw() {
|
|
46
|
+
return (this.setup.yawDeg + 90 * this.rotation) * DEG;
|
|
47
|
+
}
|
|
48
|
+
get pitch() {
|
|
49
|
+
return this.setup.pitchDegByZoom[this.zoom] * DEG;
|
|
50
|
+
}
|
|
51
|
+
/** Physical pixels per metre. */
|
|
52
|
+
get scale() {
|
|
53
|
+
return this.setup.pxPerMeterByZoom[this.zoom] * this.dpr;
|
|
54
|
+
}
|
|
55
|
+
/** View: rotation around the vertical axis in radians. */
|
|
56
|
+
get heading() {
|
|
57
|
+
return this.yaw;
|
|
58
|
+
}
|
|
59
|
+
/** View: metres per physical pixel; constant over the image since there is no perspective. */
|
|
60
|
+
get metresPerPixel() {
|
|
61
|
+
return 1 / this.scale;
|
|
62
|
+
}
|
|
63
|
+
/** View: no perspective, the pixel size does not change with depth. */
|
|
64
|
+
pixelGrowth = 0;
|
|
65
|
+
refDepth = 0;
|
|
66
|
+
axes(out) {
|
|
67
|
+
return this.frame(out);
|
|
68
|
+
}
|
|
69
|
+
/** View: rays through the image corners, starting in the camera plane through the unsnapped view centre. */
|
|
70
|
+
cornerRays(out) {
|
|
71
|
+
const cam = this.frame(out ? this.scratch : undefined);
|
|
72
|
+
const hw = this.width / (2 * this.scale);
|
|
73
|
+
const hh = this.height / (2 * this.scale);
|
|
74
|
+
const c0 = this.centerX;
|
|
75
|
+
const c1 = this.refHeight;
|
|
76
|
+
const c2 = this.centerZ;
|
|
77
|
+
const rays = out ?? [];
|
|
78
|
+
let i = 0;
|
|
79
|
+
for (let a = 0; a < 2; a++) {
|
|
80
|
+
const sx = a === 0 ? -1 : 1;
|
|
81
|
+
for (let b = 0; b < 2; b++) {
|
|
82
|
+
const sy = b === 0 ? -1 : 1;
|
|
83
|
+
// right[1] is always 0 for this rig, so it is left out of the height.
|
|
84
|
+
const x = c0 + cam.right[0] * hw * sx + cam.up[0] * hh * sy;
|
|
85
|
+
const y = c1 + cam.up[1] * hh * sy;
|
|
86
|
+
const z = c2 + cam.right[2] * hw * sx + cam.up[2] * hh * sy;
|
|
87
|
+
if (out) {
|
|
88
|
+
const r = out[i];
|
|
89
|
+
r.origin[0] = x;
|
|
90
|
+
r.origin[1] = y;
|
|
91
|
+
r.origin[2] = z;
|
|
92
|
+
r.dir[0] = cam.forward[0];
|
|
93
|
+
r.dir[1] = cam.forward[1];
|
|
94
|
+
r.dir[2] = cam.forward[2];
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
rays.push({ origin: [x, y, z], dir: cam.forward });
|
|
98
|
+
i++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return rays;
|
|
102
|
+
}
|
|
103
|
+
/** View: the visible rectangle in the camera plane. */
|
|
104
|
+
cullVolume() {
|
|
105
|
+
const cam = this.frame();
|
|
106
|
+
const s = this.scale;
|
|
107
|
+
const c = [this.centerX, this.refHeight, this.centerZ];
|
|
108
|
+
return { kind: 'box', axes: cam, cx: dot(cam.right, c), cy: dot(cam.up, c), halfW: this.width / (2 * s), halfH: this.height / (2 * s) };
|
|
109
|
+
}
|
|
110
|
+
/** View: changes whenever the image of a static scene would. */
|
|
111
|
+
key() {
|
|
112
|
+
// The string is made again only when a number in it changed, so a still view allocates nothing.
|
|
113
|
+
const k = this.keyOf;
|
|
114
|
+
if (k[0] === this.rotation && k[1] === this.zoom && k[2] === this.centerX && k[3] === this.centerZ && k[4] === this.width && k[5] === this.height)
|
|
115
|
+
return this.keyText;
|
|
116
|
+
k[0] = this.rotation;
|
|
117
|
+
k[1] = this.zoom;
|
|
118
|
+
k[2] = this.centerX;
|
|
119
|
+
k[3] = this.centerZ;
|
|
120
|
+
k[4] = this.width;
|
|
121
|
+
k[5] = this.height;
|
|
122
|
+
this.keyText = `${this.rotation}|${this.zoom}|${this.centerX.toFixed(3)}|${this.centerZ.toFixed(3)}|${this.width}x${this.height}`;
|
|
123
|
+
return this.keyText;
|
|
124
|
+
}
|
|
125
|
+
/** The view's axes. With `out` its arrays are written and `out` is returned. */
|
|
126
|
+
frame(out) {
|
|
127
|
+
const yaw = this.yaw;
|
|
128
|
+
const p = this.pitch;
|
|
129
|
+
const f = out ?? { right: [0, 0, 0], up: [0, 0, 0], forward: [0, 0, 0] };
|
|
130
|
+
f.right[0] = Math.cos(yaw);
|
|
131
|
+
f.right[1] = 0;
|
|
132
|
+
f.right[2] = -Math.sin(yaw);
|
|
133
|
+
f.forward[0] = -Math.sin(yaw) * Math.cos(p);
|
|
134
|
+
f.forward[1] = -Math.sin(p);
|
|
135
|
+
f.forward[2] = -Math.cos(yaw) * Math.cos(p);
|
|
136
|
+
crossInto(f.right, f.forward, f.up);
|
|
137
|
+
return f;
|
|
138
|
+
}
|
|
139
|
+
/** Horizontal direction "away from the viewer", along which the centre moves when dragging up and down. */
|
|
140
|
+
forwardOnGround() {
|
|
141
|
+
const yaw = this.yaw;
|
|
142
|
+
return [-Math.sin(yaw), 0, -Math.cos(yaw)];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* World → clip space matrix. The centre is snapped to whole pixels, so the image moves
|
|
146
|
+
* in whole pixels when panning and nothing shimmers. Depth is relative to the scene centre and does not depend on panning.
|
|
147
|
+
*/
|
|
148
|
+
viewProj(sceneCenter, depthHalfRange, out) {
|
|
149
|
+
const f = this.frame(out ? this.scratch : undefined);
|
|
150
|
+
const s = this.scale;
|
|
151
|
+
const c = this.scratchC;
|
|
152
|
+
c[0] = this.centerX;
|
|
153
|
+
c[1] = this.refHeight;
|
|
154
|
+
c[2] = this.centerZ;
|
|
155
|
+
const cx = Math.round(dot(f.right, c) * s) / s;
|
|
156
|
+
const cy = Math.round(dot(f.up, c) * s) / s;
|
|
157
|
+
return orthoMatrix(f, cx, cy, dot(f.forward, sceneCenter), this.width / (2 * s), this.height / (2 * s), depthHalfRange, out);
|
|
158
|
+
}
|
|
159
|
+
/** View centre in the camera plane snapped to whole pixels, same as in `viewProj`. */
|
|
160
|
+
snappedCenter(f) {
|
|
161
|
+
const s = this.scale;
|
|
162
|
+
const c = [this.centerX, this.refHeight, this.centerZ];
|
|
163
|
+
return { cx: Math.round(dot(f.right, c) * s) / s, cy: Math.round(dot(f.up, c) * s) / s };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Ray under a screen point. `px`, `py` are physical canvas pixels from the top-left corner
|
|
167
|
+
* (pixel centre is +0.5). The origin lies in the camera plane through the view centre, the direction is
|
|
168
|
+
* the view direction: the camera has no perspective, all rays are parallel.
|
|
169
|
+
*/
|
|
170
|
+
screenRay(px, py) {
|
|
171
|
+
const f = this.frame();
|
|
172
|
+
const s = this.scale;
|
|
173
|
+
const { cx, cy } = this.snappedCenter(f);
|
|
174
|
+
const a = cx + (px - this.width / 2) / s;
|
|
175
|
+
const b = cy - (py - this.height / 2) / s;
|
|
176
|
+
const d = dot(f.forward, [this.centerX, this.refHeight, this.centerZ]);
|
|
177
|
+
return {
|
|
178
|
+
origin: [f.right[0] * a + f.up[0] * b + f.forward[0] * d, f.right[1] * a + f.up[1] * b + f.forward[1] * d, f.right[2] * a + f.up[2] * b + f.forward[2] * d],
|
|
179
|
+
dir: f.forward,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/** Where a world point lands on the canvas: physical pixels from the top-left corner. Inverse of `screenRay`. */
|
|
183
|
+
project(p) {
|
|
184
|
+
const f = this.frame();
|
|
185
|
+
const s = this.scale;
|
|
186
|
+
const { cx, cy } = this.snappedCenter(f);
|
|
187
|
+
return [(dot(f.right, p) - cx) * s + this.width / 2, this.height / 2 - (dot(f.up, p) - cy) * s];
|
|
188
|
+
}
|
|
189
|
+
/** Pan by screen pixels: the content follows the cursor. */
|
|
190
|
+
panPixels(dx, dy) {
|
|
191
|
+
const f = this.frame();
|
|
192
|
+
const g = this.forwardOnGround();
|
|
193
|
+
const s = this.scale;
|
|
194
|
+
const along = dy / (s * Math.sin(this.pitch));
|
|
195
|
+
this.centerX += (-f.right[0] * dx) / s + g[0] * along;
|
|
196
|
+
this.centerZ += (-f.right[2] * dx) / s + g[2] * along;
|
|
197
|
+
this.clampCenter();
|
|
198
|
+
}
|
|
199
|
+
setZoom(z) {
|
|
200
|
+
this.zoom = clamp(Math.round(z), 0, this.zoomLevels - 1);
|
|
201
|
+
}
|
|
202
|
+
setRotation(r) {
|
|
203
|
+
this.rotation = ((Math.round(r) % 4) + 4) % 4;
|
|
204
|
+
}
|
|
205
|
+
clampCenter() {
|
|
206
|
+
this.centerX = clamp(this.centerX, this.bounds.minX, this.bounds.maxX);
|
|
207
|
+
this.centerZ = clamp(this.centerZ, this.bounds.minZ, this.bounds.maxZ);
|
|
208
|
+
}
|
|
209
|
+
state() {
|
|
210
|
+
return { rotation: this.rotation, zoom: this.zoom, center: { x: this.centerX, z: this.centerZ } };
|
|
211
|
+
}
|
|
212
|
+
/** Largest zoom level at which the world rectangle sizeX × sizeZ still fits entirely on the canvas. */
|
|
213
|
+
fitZoom(sizeX, sizeZ, heightSpan) {
|
|
214
|
+
const keepRotation = this.zoom;
|
|
215
|
+
let best = 0;
|
|
216
|
+
for (let z = 0; z < this.zoomLevels; z++) {
|
|
217
|
+
this.zoom = z;
|
|
218
|
+
const f = this.frame();
|
|
219
|
+
const s = this.scale;
|
|
220
|
+
const w = (Math.abs(f.right[0]) * sizeX + Math.abs(f.right[2]) * sizeZ) * s;
|
|
221
|
+
const h = (Math.abs(f.up[0]) * sizeX + Math.abs(f.up[2]) * sizeZ + f.up[1] * heightSpan) * s;
|
|
222
|
+
if (w <= this.width && h <= this.height)
|
|
223
|
+
best = z;
|
|
224
|
+
}
|
|
225
|
+
this.zoom = keepRotation;
|
|
226
|
+
return best;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { OrthoFrame, Vec3 } from '../base/math.ts';
|
|
2
|
+
import type { CullFrustum, Ray, View } from '../base/view.ts';
|
|
3
|
+
/**
|
|
4
|
+
* How far the boom may reach from the pivot (ox, oy, oz) along the unit direction (dx, dy, dz), at most `maxDist`.
|
|
5
|
+
* Return `maxDist` where the way is free. Close over the radius of the sphere you cast, so the near plane stays clear.
|
|
6
|
+
*/
|
|
7
|
+
export type BoomClearance = (ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, maxDist: number) => number;
|
|
8
|
+
export interface FollowSetup {
|
|
9
|
+
/** Vertical field of view in degrees. */
|
|
10
|
+
fovDeg: number;
|
|
11
|
+
/** Near and far plane in metres. The scene's depth range may pull them closer together, never apart. */
|
|
12
|
+
near: number;
|
|
13
|
+
far: number;
|
|
14
|
+
/** Boom length limits, metres; 0 is the view from the pivot itself (first person). */
|
|
15
|
+
minDistance: number;
|
|
16
|
+
maxDistance: number;
|
|
17
|
+
/** Pitch limits in degrees; positive looks down from above the pivot. */
|
|
18
|
+
minPitchDeg: number;
|
|
19
|
+
maxPitchDeg: number;
|
|
20
|
+
/** Pivot above the followed point, metres. */
|
|
21
|
+
pivotHeight: number;
|
|
22
|
+
/** Seconds in which the pivot closes most (95 %) of the gap to the followed point; 0 follows rigidly. */
|
|
23
|
+
followLag: number;
|
|
24
|
+
/** Seconds in which a shortened boom regains most (95 %) of its length; 0 springs back at once. */
|
|
25
|
+
boomReturn: number;
|
|
26
|
+
/** Radians of turn per CSS pixel of pointer movement. */
|
|
27
|
+
turnPerPx: number;
|
|
28
|
+
/** Smallest distance in front of the eye that counts as the centre of the view (`metresPerPixel`, `refDepth`). */
|
|
29
|
+
minFocus: number;
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_FOLLOW: FollowSetup;
|
|
32
|
+
export interface FollowOptions {
|
|
33
|
+
/** Shortens the boom where something blocks it. Without it the boom always has its full length. */
|
|
34
|
+
clearance?: BoomClearance;
|
|
35
|
+
}
|
|
36
|
+
export declare class FollowRig implements View {
|
|
37
|
+
readonly setup: FollowSetup;
|
|
38
|
+
/** Heading in degrees; 0 looks toward −z, positive turns left. */
|
|
39
|
+
yawDeg: number;
|
|
40
|
+
/** Pitch in degrees; positive looks down. Kept within the setup's limits by the methods, not on assignment. */
|
|
41
|
+
pitchDeg: number;
|
|
42
|
+
/** Wanted boom length in metres; 0 is the view from the pivot. The drawn length is `boom`. */
|
|
43
|
+
distance: number;
|
|
44
|
+
/** Shortens the boom; may be replaced at any time. */
|
|
45
|
+
clearance: BoomClearance | null;
|
|
46
|
+
/** Canvas size in physical pixels and physical pixels per CSS pixel. */
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
dpr: number;
|
|
50
|
+
/** The followed point as last given to `follow`. */
|
|
51
|
+
readonly target: Vec3;
|
|
52
|
+
/** The smoothed pivot the boom turns around (followed point raised by `pivotHeight`, trailing it by `followLag`). */
|
|
53
|
+
readonly pivot: Vec3;
|
|
54
|
+
/** The boom length drawn: `distance`, shortened by the clearance and growing back smoothly. */
|
|
55
|
+
private _boom;
|
|
56
|
+
/** False until the first `follow`: the pivot then jumps to the target instead of trailing it from the origin. */
|
|
57
|
+
private placed;
|
|
58
|
+
private readonly scratch;
|
|
59
|
+
private readonly scratchVp;
|
|
60
|
+
private readonly scratchEye;
|
|
61
|
+
/** The numbers the last `key` was made from (NaN: none yet) and that key. */
|
|
62
|
+
private readonly keyOf;
|
|
63
|
+
private keyText;
|
|
64
|
+
constructor(setup?: Partial<FollowSetup>, options?: FollowOptions);
|
|
65
|
+
/** The boom length drawn this frame, metres. */
|
|
66
|
+
get boom(): number;
|
|
67
|
+
/** Sets the followed point (the walker's render position). The first call places the pivot there at once. */
|
|
68
|
+
follow(x: number, y: number, z: number): void;
|
|
69
|
+
/** Puts the pivot on the followed point and the boom at its wanted length at once (after a jump, a cut). */
|
|
70
|
+
snap(): void;
|
|
71
|
+
/** Smooths the pivot and shortens the boom by `clearance`; call once per frame with the real seconds since the last. */
|
|
72
|
+
update(dt: number): void;
|
|
73
|
+
/** The length a boom of `wanted` metres may have now: the clearance along the boom's direction from the pivot. */
|
|
74
|
+
private reach;
|
|
75
|
+
/** Turns by pointer movement in physical pixels: right turns the view right, down turns it down. */
|
|
76
|
+
turnPixels(dx: number, dy: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* Multiplies the wanted boom length (below 1 comes closer), within `minDistance` … `maxDistance`. With
|
|
79
|
+
* `minDistance` 0 a boom shorter than half a metre becomes 0, the view from the pivot; zooming out from 0 starts at
|
|
80
|
+
* `max(minDistance, 0.5)`.
|
|
81
|
+
*/
|
|
82
|
+
zoomBy(factor: number): void;
|
|
83
|
+
/** Unit direction on the ground plane the view looks along, for turning input into world movement. Written to `out`. */
|
|
84
|
+
forward(out: number[]): number[];
|
|
85
|
+
/** View: rotation around the vertical axis in radians. */
|
|
86
|
+
get heading(): number;
|
|
87
|
+
private get tanHalfY();
|
|
88
|
+
/** Distance in front of the eye that counts as the centre of the view: the pivot, or `minFocus` when closer. */
|
|
89
|
+
private get focus();
|
|
90
|
+
/** View: pixel size at the centre of the view. */
|
|
91
|
+
get metresPerPixel(): number;
|
|
92
|
+
/** View: metres per pixel gained per metre of depth. */
|
|
93
|
+
get pixelGrowth(): number;
|
|
94
|
+
/** View: depth of the centre of the view along the view direction. */
|
|
95
|
+
get refDepth(): number;
|
|
96
|
+
/** View: screen right, screen up and the view direction. With `out` its arrays are written and `out` is returned. */
|
|
97
|
+
axes(out?: OrthoFrame): OrthoFrame;
|
|
98
|
+
/** The eye: the pivot moved back along the view direction by the drawn boom. With `out` it is written there. */
|
|
99
|
+
eye(out?: Vec3): Vec3;
|
|
100
|
+
/**
|
|
101
|
+
* World → clip matrix. The near and far planes are the setup's, pulled in to the sphere of `depthHalfRange` around
|
|
102
|
+
* `sceneCenter` where it is smaller (never pushed out).
|
|
103
|
+
*/
|
|
104
|
+
viewProj(sceneCenter: Vec3, depthHalfRange: number, out?: Float32Array): Float32Array;
|
|
105
|
+
/** Direction through a point in normalised screen coordinates (−1…1, y up) for the axes `ax`, written into `out`. */
|
|
106
|
+
private dirInto;
|
|
107
|
+
/**
|
|
108
|
+
* View: rays from the eye through the image corners (left-bottom, left-top, right-bottom, right-top). With `out`
|
|
109
|
+
* (see `newCornerRays`) each ray's own arrays are written and `out` is returned.
|
|
110
|
+
*/
|
|
111
|
+
cornerRays(out?: Ray[]): Ray[];
|
|
112
|
+
/** View: the four side planes through the eye and the plane of the eye itself, normals inward. */
|
|
113
|
+
cullVolume(): CullFrustum;
|
|
114
|
+
/** View: changes whenever the image of a static scene would. */
|
|
115
|
+
key(): string;
|
|
116
|
+
/** Ray under a screen point in physical pixels from the top-left corner. */
|
|
117
|
+
screenRay(px: number, py: number): Ray;
|
|
118
|
+
/** Where a world point lands on the canvas, in physical pixels from the top-left corner. */
|
|
119
|
+
project(p: Vec3): [number, number];
|
|
120
|
+
}
|