@korial29/tiny-fps 0.8.0 → 0.10.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.
@@ -29,6 +29,17 @@ export interface Blast {
29
29
  r: number;
30
30
  t: number;
31
31
  }
32
+ /** A puff of smoke: it rises and drifts, swells, then shrinks away over `life` seconds. */
33
+ export interface Puff {
34
+ p: Vec3;
35
+ v: Vec3;
36
+ /** Half the side of its cube at its biggest, metres. */
37
+ r: number;
38
+ yaw: number;
39
+ /** Age and lifetime, seconds. */
40
+ t: number;
41
+ life: number;
42
+ }
32
43
  /** What the client keeps of each monster it has drawn. */
33
44
  export interface Walker {
34
45
  x: number;
@@ -57,6 +68,9 @@ export interface Effects {
57
68
  sparks: Spark[];
58
69
  gibs: Gib[];
59
70
  blasts: Blast[];
71
+ smoke: Puff[];
72
+ /** Dust motes, x y z each, in a box around the own eye; `lit` says which the flashlight shows. */
73
+ motes: Float32Array;
60
74
  /** Seconds of the red hurt tint left. */
61
75
  hurt: number;
62
76
  /** Seconds left of the fade of a picked-up item's colour, and that colour (0 to 1 each). */
@@ -91,12 +105,23 @@ export interface Effects {
91
105
  /** A host event, once delayed to line up with the drawn monsters; `you` is the own player id. */
92
106
  event(e: GameEvent, you: number): void;
93
107
  }
108
+ /** Motes, and the half sides of the box they live in: they wrap round it as the eye moves. */
109
+ export declare const MOTES = 128;
94
110
  export declare const BLAST = 0.3;
95
111
  /** Seconds the hit vignette and the pickup fade take to go out. */
96
112
  export declare const HURT = 0.45;
97
113
  export declare const GAIN = 0.4;
98
114
  /** Half the side of an explosion's glow: it swells fast, then shrinks to nothing as it ends. */
99
115
  export declare const glow: ({ r, t }: Blast) => number;
116
+ /** Half the side of a puff of smoke: it starts at a third, swells for half its life, then shrinks to nothing. */
117
+ export declare const puff: ({ r, t, life }: Puff) => number;
118
+ /** How opaque a puff of smoke is, 0 to 1: it comes in over a tenth of its life, then thins out to nothing. */
119
+ export declare const fade: ({ t, life }: Puff) => number;
120
+ /**
121
+ * The motes the own flashlight shows, from the eye along the unit view direction f: x, y, z and a
122
+ * brightness in (0, 1] each, fuller near the axis and the eye. None while the own player is dead.
123
+ */
124
+ export declare const lit: (fx: Effects, eye: Vec3, f: Vec3) => number[];
100
125
  /**
101
126
  * Holds what the host reported at `now` for INTERP_DELAY ms, so it fires in step with the others,
102
127
  * who are drawn that far in the past. Keeps at most `max`: a hidden tab does not grow it.
@@ -43,5 +43,13 @@ export interface Scene {
43
43
  /** Seconds, for pulsing lights. */
44
44
  t: number;
45
45
  }
46
+ /** The lava sector's light: its centre, two metres above the floor, and how far it reaches. */
47
+ interface Pool {
48
+ p: Vec3;
49
+ range: number;
50
+ }
51
+ /** The lava sectors of a level, derived once per Level object: they never change. */
52
+ export declare const lava: (lvl: Level) => Pool[];
46
53
  /** The lights of this frame, most important first. */
47
54
  export declare const gather: ({ eye, yaw, pitch, dead, others, fx, bullets, lvl, t }: Scene) => Light[];
55
+ export {};
@@ -2,6 +2,10 @@ import type { Bullet, Edge, Item, Level, Monster, PlayerState } from '../shared/
2
2
  import type { Effects } from './effects';
3
3
  import type { Light } from './lights';
4
4
  import type { Vec3 } from './mesh';
5
+ /** MapDef.fog when a map sets none: the clear colour and what distance fog fades to, then its density. Dark, the map is indoors. */
6
+ export declare const FOG: number[];
7
+ /** Tints a level can use at once, white included (see palette). */
8
+ export declare const MAX_TINTS = 16;
5
9
  /**
6
10
  * Blinn-Phong strength and exponent: a row per TEX id in order (brick, tile, lava, stone, metal, wood,
7
11
  * moss, grate), then the flat bodies. Lava and glows never get here: they light themselves.
@@ -34,7 +38,13 @@ export declare const pack: (lights: Light[]) => {
34
38
  };
35
39
  /** Vertical spans [y0, y1] an edge draws on its own side: the wall, or the steps of a portal. */
36
40
  export declare const spans: ({ map }: Level, { front, back }: Edge) => [number, number][];
37
- /** Floors and ceilings as fans, then every edge's walls as quads, in the vertex format above. */
41
+ /** The tints of a level's sectors, white first and each once: the shader's palette, MAX_TINTS at most. */
42
+ export declare const palette: ({ map }: Level) => Vec3[];
43
+ /**
44
+ * Floors and ceilings as fans, then every edge's walls as quads, in the vertex format above. A
45
+ * sector's light is packed with its palette index as 2 * index + light: light is at most 1, so
46
+ * the shader takes the index from floor(w / 2) and keeps the vertex at 10 floats.
47
+ */
38
48
  export declare const levelVerts: (lvl: Level) => number[];
39
49
  export interface Renderer {
40
50
  /**
@@ -185,10 +185,14 @@ export interface Sector {
185
185
  ct: number;
186
186
  /** Light level multiplied into the shading, 0 to 1. Absent: 1. */
187
187
  light?: number;
188
+ /** Colour of the sector's ambient light, linear RGB 0 to 1 (a cold blue cellar, a warm furnace). Absent: white. */
189
+ tint?: [r: number, g: number, b: number];
188
190
  }
189
191
  export interface MapDef {
190
192
  /** Shown on the title screen after the level number. */
191
193
  name?: string;
194
+ /** Fog colour (linear RGB 0 to 1) and density per metre (0.02 is the default haze). Absent: the default. */
195
+ fog?: [r: number, g: number, b: number, density: number];
192
196
  sectors: Sector[];
193
197
  /** Spawn points: feet x, z (inside a sector, standing on its floor) and the yaw to face. */
194
198
  spawns: [x: number, z: number, yaw: number][];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@korial29/tiny-fps",
3
3
  "description": "Tiny multiplayer first-person shooter for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
4
4
  "license": "Apache-2.0",
5
- "version": "0.8.0",
5
+ "version": "0.10.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"