@korial29/tiny-fps 1.5.0 → 1.6.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PlayerState } from '../shared/types';
|
|
2
2
|
import type { World } from '../shared/world';
|
|
3
|
+
import type { Plant } from './prints';
|
|
3
4
|
import type { Vec3 } from './mesh';
|
|
4
5
|
import { solve } from './rig';
|
|
5
6
|
import type { Pose, Quat } from './rig';
|
|
@@ -25,6 +26,8 @@ export interface Body {
|
|
|
25
26
|
/** Its gait's footsteps so far and stride phase (Gait.steps, Gait.phase): the sounds of its steps and the bob of the view go with its feet. */
|
|
26
27
|
readonly steps: number;
|
|
27
28
|
readonly phase: number;
|
|
29
|
+
/** Its gait's last footfall (Gait.plant), for the prints it leaves. Recreated with the gait. */
|
|
30
|
+
readonly plant: Plant;
|
|
28
31
|
/** The joints for a camera at `eye`; undefined without a player, or with the camera away from the body. */
|
|
29
32
|
pose(eye: Vec3, yaw: number, pitch: number, roll?: number): Solved | undefined;
|
|
30
33
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PlayerState } from '../shared/types';
|
|
2
2
|
import type { Vec3 } from './mesh';
|
|
3
|
+
import type { Plant } from './prints';
|
|
3
4
|
import type { Pose, Quat } from './rig';
|
|
4
5
|
/** The height of the ground at (x, z), for feet that stand on stairs and slopes. */
|
|
5
6
|
export type Floor = (x: number, z: number) => number;
|
|
@@ -23,6 +24,8 @@ export interface Gait {
|
|
|
23
24
|
readonly phase: number;
|
|
24
25
|
/** Footsteps so far: a foot set down, or along a wall each half of the stride. */
|
|
25
26
|
readonly steps: number;
|
|
27
|
+
/** The last foot set down flat (not along a wall): one object, rewritten at each footfall. */
|
|
28
|
+
readonly plant: Plant;
|
|
26
29
|
}
|
|
27
30
|
/** The rotation whose x axis is `x` and whose y axis points up the bone, opposite to `d`. */
|
|
28
31
|
export declare const frame: (x: Vec3, d: Vec3) => Quat;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { World } from '../shared/world';
|
|
2
|
+
/**
|
|
3
|
+
* Footprints in soft ground (Landfall's sand, the moon's regolith): a deformation map around the
|
|
4
|
+
* eye that the land shader reads to bend the ground's bump and darken it (PRINTS in render.ts).
|
|
5
|
+
* The ground stays flat: no vertex moves.
|
|
6
|
+
*
|
|
7
|
+
* The map is an RGBA8 texture of N² texels over SPAN metres, addressed toroidally (REPEAT): world
|
|
8
|
+
* texel i lives at texel i mod N, so when the eye moves only the strips that enter the window are
|
|
9
|
+
* cleared. R is the soil left (1 untouched, 0 pressed to the bottom), kept by MIN blending; A is the
|
|
10
|
+
* rim pushed up around a print, kept by MAX blending. G and B stay 1. On the beach a refill pass
|
|
11
|
+
* raises R and lowers A by one step of 1/255 every FILL / 255 seconds; the moon has no wind and
|
|
12
|
+
* keeps its prints until they leave the window.
|
|
13
|
+
*/
|
|
14
|
+
/** Texels a side: 1024 over SPAN 24 m is 2.3 cm a texel, fine enough for a boot's heel and ball. */
|
|
15
|
+
export declare const N = 1024;
|
|
16
|
+
/** Metres the map covers a side, centred on the eye. Its last 3 m fade out in the shader. */
|
|
17
|
+
export declare const SPAN = 24;
|
|
18
|
+
/** A gait's last footfall, as Gait.plant gives it. */
|
|
19
|
+
export interface Plant {
|
|
20
|
+
/** Footfalls so far: a new one is a new print. */
|
|
21
|
+
readonly n: number;
|
|
22
|
+
readonly x: number;
|
|
23
|
+
readonly y: number;
|
|
24
|
+
readonly z: number;
|
|
25
|
+
/** The foot's yaw: it points to (-sin yaw, -cos yaw). */
|
|
26
|
+
readonly yaw: number;
|
|
27
|
+
/** 1 for the right foot, -1 for the left. */
|
|
28
|
+
readonly side: number;
|
|
29
|
+
}
|
|
30
|
+
export interface Prints {
|
|
31
|
+
/** Queues a print for each new footfall of `plant`, if the foot stands on the relief. */
|
|
32
|
+
feed(plant: Plant): void;
|
|
33
|
+
/**
|
|
34
|
+
* Moves the window to (cx, cz), fills old prints back and stamps the queued ones. Leaves its own
|
|
35
|
+
* framebuffer, program and VAO bound, blending and scissor off: the caller binds its next target.
|
|
36
|
+
*/
|
|
37
|
+
pass(dt: number, cx: number, cz: number): void;
|
|
38
|
+
/** The texture, sampled by the land shader with REPEAT at world (x, z) / SPAN. */
|
|
39
|
+
readonly map: WebGLTexture;
|
|
40
|
+
/** The window's centre in world x and z, on the texel grid. */
|
|
41
|
+
readonly cx: number;
|
|
42
|
+
readonly cz: number;
|
|
43
|
+
}
|
|
44
|
+
/** The prints of `world`, or undefined on a map without soft ground. Built again with a lost context's GL. */
|
|
45
|
+
export declare const createPrints: (gl: WebGL2RenderingContext, world: World) => Prints | undefined;
|
|
@@ -209,6 +209,20 @@ export declare const stance: (r: Runner) => {
|
|
|
209
209
|
* (k 1) it points along his look.
|
|
210
210
|
*/
|
|
211
211
|
export declare const cannonOf: (chest: Vec3, q: Quat, p: Pick<PlayerState, "yaw" | "pitch">, k: number) => [Vec3, Quat];
|
|
212
|
+
/**
|
|
213
|
+
* The Hunter with all he finds on the racks carried and nothing in hand (`fists`: he has none, so
|
|
214
|
+
* no weapon is out): what his pictures on the menus show. In play his weapons are drawn on him
|
|
215
|
+
* only once he has found them.
|
|
216
|
+
*/
|
|
217
|
+
export declare const HUNTER_GEAR: {
|
|
218
|
+
ammo: number;
|
|
219
|
+
mag: number;
|
|
220
|
+
rail: number;
|
|
221
|
+
cap: number;
|
|
222
|
+
rifle: number;
|
|
223
|
+
side: number;
|
|
224
|
+
fists: boolean;
|
|
225
|
+
};
|
|
212
226
|
/** Build and index the Hunter models before they can be drawn during a match. */
|
|
213
227
|
export declare const warmHunter: () => void;
|
|
214
228
|
/** warmHunter() a level at a time, a step each (render.ts warmSteps()): some 150 ms each on an M2. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.6.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|