tosijs-3d 0.8.1 → 0.8.2
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/CHANGELOG.md +55 -0
- package/README.md +50 -9
- package/dist/aim.d.ts +157 -0
- package/dist/aim.d.ts.map +1 -0
- package/dist/aim.js +399 -0
- package/dist/aim.js.map +1 -0
- package/dist/animation-layers.d.ts +44 -0
- package/dist/animation-layers.d.ts.map +1 -0
- package/dist/animation-layers.js +273 -0
- package/dist/animation-layers.js.map +1 -0
- package/dist/asset-url.d.ts +27 -1
- package/dist/asset-url.d.ts.map +1 -1
- package/dist/asset-url.js +29 -2
- package/dist/asset-url.js.map +1 -1
- package/dist/atmosphere.d.ts +15 -0
- package/dist/atmosphere.d.ts.map +1 -1
- package/dist/atmosphere.js.map +1 -1
- package/dist/b3d-aircraft.d.ts +28 -0
- package/dist/b3d-aircraft.d.ts.map +1 -1
- package/dist/b3d-aircraft.js +91 -1
- package/dist/b3d-aircraft.js.map +1 -1
- package/dist/b3d-biped.d.ts +273 -1
- package/dist/b3d-biped.d.ts.map +1 -1
- package/dist/b3d-biped.js +1090 -25
- package/dist/b3d-biped.js.map +1 -1
- package/dist/b3d-cloud-deck.d.ts +535 -0
- package/dist/b3d-cloud-deck.d.ts.map +1 -0
- package/dist/b3d-cloud-deck.js +2098 -0
- package/dist/b3d-cloud-deck.js.map +1 -0
- package/dist/b3d-clouds.d.ts +2 -0
- package/dist/b3d-clouds.d.ts.map +1 -1
- package/dist/b3d-clouds.js +36 -4
- package/dist/b3d-clouds.js.map +1 -1
- package/dist/b3d-crowd.d.ts +399 -0
- package/dist/b3d-crowd.d.ts.map +1 -0
- package/dist/b3d-crowd.js +2264 -0
- package/dist/b3d-crowd.js.map +1 -0
- package/dist/b3d-elevator.d.ts +70 -0
- package/dist/b3d-elevator.d.ts.map +1 -0
- package/dist/b3d-elevator.js +243 -0
- package/dist/b3d-elevator.js.map +1 -0
- package/dist/b3d-exploder.d.ts.map +1 -1
- package/dist/b3d-exploder.js +4 -9
- package/dist/b3d-exploder.js.map +1 -1
- package/dist/b3d-fog.js +1 -1
- package/dist/b3d-fog.js.map +1 -1
- package/dist/b3d-galaxy.d.ts +45 -0
- package/dist/b3d-galaxy.d.ts.map +1 -1
- package/dist/b3d-galaxy.js +309 -14
- package/dist/b3d-galaxy.js.map +1 -1
- package/dist/b3d-input-focus.d.ts.map +1 -1
- package/dist/b3d-input-focus.js +50 -6
- package/dist/b3d-input-focus.js.map +1 -1
- package/dist/b3d-interactive.d.ts.map +1 -1
- package/dist/b3d-interactive.js +27 -3
- package/dist/b3d-interactive.js.map +1 -1
- package/dist/b3d-launcher.d.ts +127 -0
- package/dist/b3d-launcher.d.ts.map +1 -1
- package/dist/b3d-launcher.js +526 -6
- package/dist/b3d-launcher.js.map +1 -1
- package/dist/b3d-light.d.ts +1 -0
- package/dist/b3d-light.d.ts.map +1 -1
- package/dist/b3d-light.js +11 -0
- package/dist/b3d-light.js.map +1 -1
- package/dist/b3d-manipulator.d.ts +16 -0
- package/dist/b3d-manipulator.d.ts.map +1 -1
- package/dist/b3d-manipulator.js +93 -7
- package/dist/b3d-manipulator.js.map +1 -1
- package/dist/b3d-physics.d.ts.map +1 -1
- package/dist/b3d-physics.js +4 -9
- package/dist/b3d-physics.js.map +1 -1
- package/dist/b3d-primitives.d.ts +66 -0
- package/dist/b3d-primitives.d.ts.map +1 -1
- package/dist/b3d-primitives.js +179 -9
- package/dist/b3d-primitives.js.map +1 -1
- package/dist/b3d-shadows.d.ts.map +1 -1
- package/dist/b3d-shadows.js +20 -1
- package/dist/b3d-shadows.js.map +1 -1
- package/dist/b3d-skybox.d.ts +168 -0
- package/dist/b3d-skybox.d.ts.map +1 -1
- package/dist/b3d-skybox.js +1505 -8
- package/dist/b3d-skybox.js.map +1 -1
- package/dist/b3d-sound.d.ts.map +1 -1
- package/dist/b3d-sound.js +5 -7
- package/dist/b3d-sound.js.map +1 -1
- package/dist/b3d-star-system.d.ts.map +1 -1
- package/dist/b3d-star-system.js +5 -2
- package/dist/b3d-star-system.js.map +1 -1
- package/dist/b3d-terrain.d.ts +5 -0
- package/dist/b3d-terrain.d.ts.map +1 -1
- package/dist/b3d-terrain.js +130 -22
- package/dist/b3d-terrain.js.map +1 -1
- package/dist/b3d-trigger.d.ts.map +1 -1
- package/dist/b3d-trigger.js +8 -1
- package/dist/b3d-trigger.js.map +1 -1
- package/dist/b3d-utils.d.ts +77 -0
- package/dist/b3d-utils.d.ts.map +1 -1
- package/dist/b3d-utils.js +164 -4
- package/dist/b3d-utils.js.map +1 -1
- package/dist/bone-mask.d.ts +96 -0
- package/dist/bone-mask.d.ts.map +1 -0
- package/dist/bone-mask.js +207 -0
- package/dist/bone-mask.js.map +1 -0
- package/dist/box.d.ts.map +1 -1
- package/dist/box.js +11 -3
- package/dist/box.js.map +1 -1
- package/dist/camera-fit.d.ts +119 -0
- package/dist/camera-fit.d.ts.map +1 -0
- package/dist/camera-fit.js +154 -0
- package/dist/camera-fit.js.map +1 -0
- package/dist/cloud-field.d.ts +40 -0
- package/dist/cloud-field.d.ts.map +1 -0
- package/dist/cloud-field.js +232 -0
- package/dist/cloud-field.js.map +1 -0
- package/dist/cloud-shadows.d.ts +13 -0
- package/dist/cloud-shadows.d.ts.map +1 -1
- package/dist/cloud-shadows.js +32 -2
- package/dist/cloud-shadows.js.map +1 -1
- package/dist/control-input.d.ts +9 -0
- package/dist/control-input.d.ts.map +1 -1
- package/dist/control-input.js +3 -0
- package/dist/control-input.js.map +1 -1
- package/dist/galaxy-data.d.ts +59 -2
- package/dist/galaxy-data.d.ts.map +1 -1
- package/dist/galaxy-data.js +229 -24
- package/dist/galaxy-data.js.map +1 -1
- package/dist/game-controller.d.ts +51 -0
- package/dist/game-controller.d.ts.map +1 -1
- package/dist/game-controller.js +195 -4
- package/dist/game-controller.js.map +1 -1
- package/dist/icon-grid.d.ts.map +1 -1
- package/dist/icon-grid.js +12 -2
- package/dist/icon-grid.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/interactive-behavior.d.ts +14 -0
- package/dist/interactive-behavior.d.ts.map +1 -1
- package/dist/interactive-behavior.js +23 -1
- package/dist/interactive-behavior.js.map +1 -1
- package/dist/landform.d.ts +77 -7
- package/dist/landform.d.ts.map +1 -1
- package/dist/landform.js +162 -10
- package/dist/landform.js.map +1 -1
- package/dist/mersenne-twister.d.ts +32 -2
- package/dist/mersenne-twister.d.ts.map +1 -1
- package/dist/mersenne-twister.js +56 -2
- package/dist/mersenne-twister.js.map +1 -1
- package/dist/model-transform.d.ts +10 -0
- package/dist/model-transform.d.ts.map +1 -1
- package/dist/model-transform.js +8 -1
- package/dist/model-transform.js.map +1 -1
- package/dist/perf-probe.d.ts +6 -0
- package/dist/perf-probe.d.ts.map +1 -1
- package/dist/perf-probe.js +3 -0
- package/dist/perf-probe.js.map +1 -1
- package/dist/playground.d.ts +18 -0
- package/dist/playground.d.ts.map +1 -0
- package/dist/playground.js +525 -0
- package/dist/playground.js.map +1 -0
- package/dist/png.d.ts +12 -0
- package/dist/png.d.ts.map +1 -0
- package/dist/png.js +105 -0
- package/dist/png.js.map +1 -0
- package/dist/rocket-ascent.d.ts +20 -0
- package/dist/rocket-ascent.d.ts.map +1 -0
- package/dist/rocket-ascent.js +410 -0
- package/dist/rocket-ascent.js.map +1 -0
- package/dist/scene-schemas.d.ts.map +1 -1
- package/dist/scene-schemas.js +28 -1
- package/dist/scene-schemas.js.map +1 -1
- package/dist/skybox-baker.d.ts +213 -0
- package/dist/skybox-baker.d.ts.map +1 -0
- package/dist/skybox-baker.js +540 -0
- package/dist/skybox-baker.js.map +1 -0
- package/dist/starfield-codec.d.ts +162 -0
- package/dist/starfield-codec.d.ts.map +1 -0
- package/dist/starfield-codec.js +554 -0
- package/dist/starfield-codec.js.map +1 -0
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +6 -2
- package/dist/surface.js.map +1 -1
- package/dist/surroundings-probe.d.ts +69 -0
- package/dist/surroundings-probe.d.ts.map +1 -0
- package/dist/surroundings-probe.js +164 -0
- package/dist/surroundings-probe.js.map +1 -0
- package/dist/surroundings.d.ts +162 -0
- package/dist/surroundings.d.ts.map +1 -0
- package/dist/surroundings.js +508 -0
- package/dist/surroundings.js.map +1 -0
- package/dist/tosi-b3d.d.ts +100 -0
- package/dist/tosi-b3d.d.ts.map +1 -1
- package/dist/tosi-b3d.js +321 -33
- package/dist/tosi-b3d.js.map +1 -1
- package/dist/vector-field.d.ts.map +1 -1
- package/dist/vector-field.js +6 -2
- package/dist/vector-field.js.map +1 -1
- package/dist/vertex-animation.d.ts +126 -0
- package/dist/vertex-animation.d.ts.map +1 -0
- package/dist/vertex-animation.js +215 -0
- package/dist/vertex-animation.js.map +1 -0
- package/dist/virtual-gamepad.d.ts +5 -1
- package/dist/virtual-gamepad.d.ts.map +1 -1
- package/dist/virtual-gamepad.js +64 -9
- package/dist/virtual-gamepad.js.map +1 -1
- package/dist/weapon-fit.d.ts +2 -0
- package/dist/weapon-fit.d.ts.map +1 -0
- package/dist/weapon-fit.js +212 -0
- package/dist/weapon-fit.js.map +1 -0
- package/dist/widget-box.d.ts.map +1 -1
- package/dist/widget-box.js +5 -1
- package/dist/widget-box.js.map +1 -1
- package/dist/widgets3d-layout.d.ts +24 -0
- package/dist/widgets3d-layout.d.ts.map +1 -1
- package/dist/widgets3d-layout.js +47 -0
- package/dist/widgets3d-layout.js.map +1 -1
- package/dist/widgets3d.d.ts +31 -0
- package/dist/widgets3d.d.ts.map +1 -1
- package/dist/widgets3d.js +294 -55
- package/dist/widgets3d.js.map +1 -1
- package/dist/world-sim.d.ts +2 -0
- package/dist/world-sim.d.ts.map +1 -0
- package/dist/world-sim.js +197 -0
- package/dist/world-sim.js.map +1 -0
- package/package.json +4 -1
- package/static/attributes.json +498 -3
- package/static/attributes.txt +118 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,61 @@ All notable changes to **tosijs-3d**. This project is pre-1.0 (`0.x`), so minor
|
|
|
6
6
|
versions may carry breaking peer-dependency changes — each is called out in a
|
|
7
7
|
**⚠️ Breaking** block in its version section below, with what a consumer must do.
|
|
8
8
|
|
|
9
|
+
## 0.8.2
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **The encoded sky** — `starfield-codec` + `skybox-baker`. A starfield is data,
|
|
14
|
+
not a picture: six small RGBA faces carry sub-texel position, gamma brightness
|
|
15
|
+
and a spectral A-byte, decoded in the sky shader into points that stay points
|
|
16
|
+
at any zoom. The shipped pair (256 smooth + 1024 data) renders a 100k-star
|
|
17
|
+
galaxy at 25 MiB of VRAM and 0.4 MB on disk, against the 2.3 MB / 96 MiB
|
|
18
|
+
raster it replaces. The A-byte spends precision where the eye is: faint stars
|
|
19
|
+
are warm yellow, bright stars carry a 224-step spectral ramp, galaxy discs
|
|
20
|
+
their size.
|
|
21
|
+
- **`png.ts`** — a lossless PNG encoder — and with it the package's first
|
|
22
|
+
runtime dependency: **`fflate` (`^0.8.3`)** supplies the deflate, because
|
|
23
|
+
Chrome's `CompressionStream` output is rejected by Chrome's own PNG decoder
|
|
24
|
+
and the packed fields must survive byte-exact. The packed fields must survive
|
|
25
|
+
byte-exact, and both the canvas path (premultiplied backing store) and
|
|
26
|
+
Chrome's `CompressionStream` deflate destroy them; the encoder writes the
|
|
27
|
+
bytes directly and a test round-trips through real inflate.
|
|
28
|
+
- **Distant dim stars** (`distantStars`, default 3000) — isotropic points
|
|
29
|
+
outside the disc, so the off-band sky has texture instead of blankness.
|
|
30
|
+
- **`b3d-cloud-deck`** — the cloud DECK: a tiled field shader with one
|
|
31
|
+
coverage dial driving transmission, gloom and depth; orographic clouds that
|
|
32
|
+
ask the terrain for its own height sampler; a shared cloud shadow.
|
|
33
|
+
- **The `world-sim` page** — the kitchen sink: live-dialed terrain (sea level
|
|
34
|
+
as a fraction of v-size), weather, and the encoded sky, under Demos.
|
|
35
|
+
- **`spectralGlsl`/`spectralRamp`/`spectralValue`** and the `generatePlanets`
|
|
36
|
+
galaxy option — the colour follows the class, and planets (71% of galaxy
|
|
37
|
+
generation time) are computed on demand via `generateStarSystem`.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- **Galaxy generation is ~70× faster** — names derive from each star's own
|
|
42
|
+
seed via a cheap PRNG (no collision retries, no name table), planets are
|
|
43
|
+
on-demand, and the core nebulae are a fixed budget rather than a fraction.
|
|
44
|
+
- **The sky is one rigid frame** — the dome's rotation carries the gradient,
|
|
45
|
+
the sun, the moon and the stars together; the star fade dies by gamma at the
|
|
46
|
+
first hint of daylight, and the golden hour has two stops (amber, then a
|
|
47
|
+
pink-red at the horizon crossing) feeding the deck's fringe and the fog
|
|
48
|
+
through the light's colour.
|
|
49
|
+
- **The baker downloads ONE zip** — twelve separate downloads got silently
|
|
50
|
+
dropped by the browser mid-burst.
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- The biome classifier's sea level and lapse rate are LIVE dials — they
|
|
55
|
+
move the snow line without re-cutting the tile pool (the shader reads the
|
|
56
|
+
plugin params every bind; the old spelling regenerated the world for a
|
|
57
|
+
value the shader never saw).
|
|
58
|
+
- The cloud-deck shadow survived field re-bakes (the shadow's sampler was
|
|
59
|
+
left pointing at a disposed texture).
|
|
60
|
+
- The cloud-deck's core glow no longer blows out at high star counts.
|
|
61
|
+
- The sky shader compiles under the strictest decoders — floats in the
|
|
62
|
+
generated GLSL now LOOK like floats.
|
|
63
|
+
|
|
9
64
|
## 0.8.1
|
|
10
65
|
|
|
11
66
|
### ⚠️ Breaking
|
package/README.md
CHANGED
|
@@ -6,12 +6,56 @@
|
|
|
6
6
|
<img style="width: 280px; height: 280px;" alt="tosijs-3d logo" src="https://3d.tosijs.net/favicon.svg">
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
**tosijs-3d is a library for building 3D web apps** — and standalone apps, if
|
|
10
|
+
that is what you want. Under the hood it uses Babylon.js for rendering, glTF/GLB
|
|
11
|
+
for models and the usual bitmap formats for textures — but it also leans on
|
|
12
|
+
**SVG**, for textures and for the entire user interface.
|
|
13
|
+
|
|
14
|
+
Free and open source, and light for what it is (Babylon is not small; this
|
|
15
|
+
adds little to it). Scenes are composed from **web components**, so a world is
|
|
16
|
+
markup you can read:
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
b3d(
|
|
20
|
+
b3dSun({ shadowCascading: true }),
|
|
21
|
+
b3dSkybox({ timeOfDay: 6 }),
|
|
22
|
+
b3dLoader({ url: './scene.glb' }),
|
|
23
|
+
b3dWater({ y: -0.2 })
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
See the [b3d](?tosi-b3d.ts) page for that running, and every page here carries a
|
|
28
|
+
live demo you can edit in place.
|
|
29
|
+
|
|
30
|
+
## Four things you may not have seen in a 3D library
|
|
31
|
+
|
|
32
|
+
**Flat 3D and VR are the same app.** You can enter and leave an immersive
|
|
33
|
+
session without the simulation resetting — the scene, the physics and your
|
|
34
|
+
place in the world all survive the transition, because nothing is torn down to
|
|
35
|
+
make it.
|
|
36
|
+
|
|
37
|
+
**One user interface, in three places.** The SVG-powered widget set renders
|
|
38
|
+
identically as a DOM overlay, on a plane inside a 3D scene, and in VR. Not three
|
|
39
|
+
implementations that drift — one, with three presentations, where any divergence
|
|
40
|
+
is treated as a bug.
|
|
41
|
+
|
|
42
|
+
**One control system, every input.** Keyboard and mouse, gamepads, VR
|
|
43
|
+
controllers and touch all arrive as the same `ControlInput`. You write the
|
|
44
|
+
behaviour once; supporting a new device is a new provider, not a rewrite.
|
|
45
|
+
|
|
46
|
+
**The simulation is testable without a GPU.** The flight model, the combat
|
|
47
|
+
maths, the world state and the layout engine are deliberately Babylon-free,
|
|
48
|
+
deterministic, and unit-tested — so the interesting logic can be exercised in
|
|
49
|
+
milliseconds rather than in a browser.
|
|
50
|
+
|
|
51
|
+
## Finding things
|
|
52
|
+
|
|
53
|
+
**Search the [attribute index](https://3d.tosijs.net/attributes.txt)** before
|
|
54
|
+
assuming a capability does not exist — one greppable line per attribute,
|
|
55
|
+
generated from source on every build. There is a [JSON
|
|
56
|
+
form](https://3d.tosijs.net/attributes.json) for tools, and both ship **inside
|
|
57
|
+
the package**, so an agent already in a consumer project reads
|
|
58
|
+
`node_modules/tosijs-3d/static/attributes.txt` with no network.
|
|
15
59
|
|
|
16
60
|
It exists because the recurring adopter failure is not a missing feature, it is
|
|
17
61
|
a feature that ships, is documented, and cannot be found: three issues in one
|
|
@@ -22,9 +66,6 @@ week turned out to be capability that was already there. One `grep water` finds
|
|
|
22
66
|
what to do about them, and [CHANGELOG.md](./CHANGELOG.md) for the full detail.
|
|
23
67
|
Both ship inside the package, so they work from `node_modules` too.
|
|
24
68
|
|
|
25
|
-
Declarative 3D/XR framework built on Babylon.js and tosijs. Compose 3D scenes with web components.
|
|
26
|
-
See the [b3d](?tosi-b3d.ts) page for a live interactive demo.
|
|
27
|
-
|
|
28
69
|
```javascript
|
|
29
70
|
import {
|
|
30
71
|
b3d,
|
package/dist/aim.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/** A plain direction. Babylon's `Vector3` satisfies it structurally. */
|
|
2
|
+
export interface AimVec {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
z: number;
|
|
6
|
+
}
|
|
7
|
+
/** Yaw and pitch in degrees — yaw RELATIVE to the body, pitch absolute. */
|
|
8
|
+
export interface Aim {
|
|
9
|
+
/** Twist from the body's facing. Positive is to the character's right. */
|
|
10
|
+
yawDeg: number;
|
|
11
|
+
/** Positive is DOWN, matching `swim-aim` and `RotationYawPitchRoll`. */
|
|
12
|
+
pitchDeg: number;
|
|
13
|
+
}
|
|
14
|
+
export interface AimLimits {
|
|
15
|
+
/** Twist held with the feet planted. Beyond it, the body starts to come round. */
|
|
16
|
+
yawFree: number;
|
|
17
|
+
/** The spine's limit. The body is dragged rather than letting this be exceeded. */
|
|
18
|
+
yawMax: number;
|
|
19
|
+
/** How far up the character can aim (a positive magnitude). */
|
|
20
|
+
pitchUp: number;
|
|
21
|
+
/** How far down (a positive magnitude). Usually larger — looking down is easier. */
|
|
22
|
+
pitchDown: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Human-ish defaults, and each one is a posture rather than a round number.
|
|
26
|
+
*
|
|
27
|
+
* 45° is about what you can twist without moving your feet; 90° is a hard
|
|
28
|
+
* shoulder check. Down beats up because looking down is mostly the neck while
|
|
29
|
+
* looking up fights the spine — and because the thing you are aiming at is more
|
|
30
|
+
* often below you than above.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DEFAULT_AIM_LIMITS: AimLimits;
|
|
33
|
+
/**
|
|
34
|
+
* Wrap to (−180, 180].
|
|
35
|
+
*
|
|
36
|
+
* Everything that subtracts two yaws needs this, and forgetting it produces the
|
|
37
|
+
* single most recognisable aim bug: a character that turns 350° to the left
|
|
38
|
+
* instead of 10° to the right. Exported because callers holding a body yaw need
|
|
39
|
+
* the same operation.
|
|
40
|
+
*/
|
|
41
|
+
export declare function wrapDeg(deg: number): number;
|
|
42
|
+
/** Hold an aim inside what a body can do. Yaw is clamped at the HARD limit. */
|
|
43
|
+
export declare function clampAim2(aim: Aim, limits?: AimLimits): Aim;
|
|
44
|
+
/**
|
|
45
|
+
* The aim that points a body at a world direction.
|
|
46
|
+
*
|
|
47
|
+
* This is the join between "where should I shoot" and "what can my body do".
|
|
48
|
+
* `dir` need not be normalised — only its proportions matter — and a zero
|
|
49
|
+
* vector returns a level, forward aim rather than `NaN`, because a degenerate
|
|
50
|
+
* direction is a thing that happens (a target at the muzzle) and a character
|
|
51
|
+
* frozen at `NaN` is unrecoverable.
|
|
52
|
+
*/
|
|
53
|
+
export declare function aimToward(bodyYawDeg: number, dir: AimVec, limits?: AimLimits): Aim;
|
|
54
|
+
/** The world direction an aim points, given the body's facing. */
|
|
55
|
+
export declare function aimDirection(bodyYawDeg: number, aim: Aim): AimVec;
|
|
56
|
+
export interface AimStep {
|
|
57
|
+
/** Degrees per second the aim may move. The skill dial — see the module doc. */
|
|
58
|
+
slewDeg?: number;
|
|
59
|
+
limits?: AimLimits;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Move an aim toward a target, at a limited RATE.
|
|
63
|
+
*
|
|
64
|
+
* A rate limit rather than an ease, and the difference matters more than it
|
|
65
|
+
* looks. An ease closes a fraction of the gap per second, so it never quite
|
|
66
|
+
* arrives and its lag depends on how far away the target was — which makes a
|
|
67
|
+
* shooter's accuracy a function of the target's distance from where he was
|
|
68
|
+
* already looking, in a way nobody can tune. A slew arrives in a knowable time
|
|
69
|
+
* and its lag is a speed you can put in a table.
|
|
70
|
+
*
|
|
71
|
+
* Yaw takes the SHORT way round. Pitch cannot wrap, so it does not need to.
|
|
72
|
+
*/
|
|
73
|
+
export declare function stepAim(current: Aim, target: Aim, dt: number, options?: AimStep): Aim;
|
|
74
|
+
export interface BodyCatchUp {
|
|
75
|
+
/** Degrees the BODY should turn this frame. Positive is to its right. */
|
|
76
|
+
bodyTurnDeg: number;
|
|
77
|
+
/** The twist that remains once it has. Feed this back as the stored aim. */
|
|
78
|
+
yawDeg: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* How far the body comes round to face what the character is aiming at.
|
|
82
|
+
*
|
|
83
|
+
* Returns BOTH halves because they are one decision. A caller that turned the
|
|
84
|
+
* body and then re-derived the twist separately would have two sources for one
|
|
85
|
+
* number, and they would disagree on the frame the clamp fires — which is
|
|
86
|
+
* exactly the frame you would be looking at.
|
|
87
|
+
*
|
|
88
|
+
* Three regimes, no state:
|
|
89
|
+
*
|
|
90
|
+
* | twist | what happens |
|
|
91
|
+
* | --- | --- |
|
|
92
|
+
* | under `yawFree` | nothing. Feet planted, shoulders turned. |
|
|
93
|
+
* | `yawFree`..`yawMax` | the body turns at `rateDeg`, unwinding the excess |
|
|
94
|
+
* | over `yawMax` | the body is DRAGGED — at least enough to restore the limit |
|
|
95
|
+
*
|
|
96
|
+
* The third is a floor on the turn rather than a separate mode, so a stick
|
|
97
|
+
* yanked to the side produces a fast turn rather than a broken neck, and it
|
|
98
|
+
* blends back into the second regime as soon as the excess is gone.
|
|
99
|
+
*/
|
|
100
|
+
export declare function bodyCatchUp(yawDeg: number, dt: number, rateDeg?: number, limits?: AimLimits): BodyCatchUp;
|
|
101
|
+
/**
|
|
102
|
+
* Unwind an aim toward neutral when nobody is driving it.
|
|
103
|
+
*
|
|
104
|
+
* Holstering, going idle, or simply letting go should return the character to
|
|
105
|
+
* facing where it walks — and it should do so on the same clock as everything
|
|
106
|
+
* else, so it is the same slew rather than a tween. `swim-aim`'s `aimTarget`
|
|
107
|
+
* makes the same argument for pitch: one branch here rather than an `if` at
|
|
108
|
+
* every call site.
|
|
109
|
+
*/
|
|
110
|
+
export declare function relaxAim(current: Aim, dt: number, slewDeg?: number, limits?: AimLimits): Aim;
|
|
111
|
+
/** Weights for a three-pose aim set, summing to 1. */
|
|
112
|
+
export interface AimPoseWeights {
|
|
113
|
+
up: number;
|
|
114
|
+
level: number;
|
|
115
|
+
down: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Turn a pitch into weights over an **aim-up / aim-level / aim-down** clip set.
|
|
119
|
+
*
|
|
120
|
+
* This is the shape [[animation-layers]] can actually play. Babylon has no
|
|
121
|
+
* additive layer, so "point the gun 30° down" is not a bone rotation you can
|
|
122
|
+
* add — it is a blend between poses somebody authored, and a blend is weights.
|
|
123
|
+
* Two of the three are always zero, which is not a waste: it means a caller can
|
|
124
|
+
* hand the same three numbers to three groups every frame and never branch.
|
|
125
|
+
*
|
|
126
|
+
* Falls back to pure `level` when a limit is zero, rather than dividing by it.
|
|
127
|
+
*/
|
|
128
|
+
export declare function aimPoseWeights(pitchDeg: number, limits?: AimLimits): AimPoseWeights;
|
|
129
|
+
/**
|
|
130
|
+
* How much authority the aim layer should have, `0`..`1`.
|
|
131
|
+
*
|
|
132
|
+
* An aim that matches where the body already points needs no layer at all — the
|
|
133
|
+
* locomotion is already doing it, and overriding it with a "forward" aim pose
|
|
134
|
+
* costs you the walk's arm swing for no gain. Authority rises with the twist,
|
|
135
|
+
* so the layer fades in exactly as it starts to say something the base clip
|
|
136
|
+
* does not.
|
|
137
|
+
*
|
|
138
|
+
* Multiply it into the mask's weights, which is why this returns a scalar and
|
|
139
|
+
* not a mask: [[bone-mask]] owns WHICH bones, this owns HOW MUCH.
|
|
140
|
+
*/
|
|
141
|
+
export declare function aimAuthority(aim: Aim, limits?: AimLimits): number;
|
|
142
|
+
/**
|
|
143
|
+
* A deterministic wander, for a shooter who cannot hold still.
|
|
144
|
+
*
|
|
145
|
+
* `AI-DESIGN.md`: invest in the LOW end of the skill dial. A bad shot does not
|
|
146
|
+
* miss by rolling badly at the moment of firing — that is invisible, and it
|
|
147
|
+
* reads as the game cheating. A bad shot's aim visibly *drifts*, so you can
|
|
148
|
+
* watch it wander off you and back, and shooting the instant it wanders is a
|
|
149
|
+
* skill the player can acquire.
|
|
150
|
+
*
|
|
151
|
+
* Two frequencies at an irrational-ish ratio rather than one, because a single
|
|
152
|
+
* sine reads as a machine sweeping. No RNG: it is a function of time, so a
|
|
153
|
+
* replay of the same fight produces the same misses, which is the rule the
|
|
154
|
+
* whole `world-store` is built on.
|
|
155
|
+
*/
|
|
156
|
+
export declare function aimWobble(seconds: number, amplitudeDeg: number, hz?: number, phase?: number): Aim;
|
|
157
|
+
//# sourceMappingURL=aim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aim.d.ts","sourceRoot":"","sources":["../src/aim.ts"],"names":[],"mappings":"AAgMA,wEAAwE;AACxE,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,M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