@korial29/tiny-fps 0.149.0 → 0.150.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/dist/server.js CHANGED
@@ -249,6 +249,17 @@ var VEHICLE = {
249
249
  GRAZE: 4,
250
250
  SKID: .92
251
251
  };
252
+ /**
253
+ * Space over the moon (the user, 2026-11-14): SEAM metres up is the edge of space, where a ship
254
+ * fights only ships. A shot that crosses it either way bursts there, so the ground and the sky never
255
+ * hit each other. TOP is the highest a ship climbs, under the 1024 m a ball's height has on the
256
+ * wire. Over the seam the moon is drawn as a globe seen from ALT metres at TOP (altitude()).
257
+ */
258
+ var ORBIT = {
259
+ SEAM: 300,
260
+ TOP: 960,
261
+ ALT: 25e4
262
+ };
252
263
  // src/shared/relief.ts
253
264
  /** Integer hash of a lattice point to [0, 1): the same on every engine. */
254
265
  var hash = (x, y, s) => {
@@ -4326,7 +4337,8 @@ var MOON = {
4326
4337
  doors: [...DOORS, ...DOORS.map(mirror$1)],
4327
4338
  scenery: "moon",
4328
4339
  helmets: true,
4329
- armor: true
4340
+ armor: true,
4341
+ seam: ORBIT.SEAM
4330
4342
  };
4331
4343
  // src/shared/routes.ts
4332
4344
  var go = (x, z, y, sprint = true) => ({
@@ -4868,6 +4880,34 @@ var build = (w) => {
4868
4880
  };
4869
4881
  };
4870
4882
  /**
4883
+ * The node a bot goes to, or from, when no straight walk joins it to the point `p`: among the nodes
4884
+ * `ok` takes, within NEAR, the best by `weigh` whose height off `p` a body manages (a stair, a
4885
+ * ledge to climb, a drop that does not hurt), `up` 1 when the bot goes from `p` to the node and -1
4886
+ * when it goes from the node to `p`; with nothing in the way of the head first, then even hidden.
4887
+ */
4888
+ var close = (w, nodes, p, ok, weigh, up) => {
4889
+ for (const clear of [true, false]) {
4890
+ let best = -1;
4891
+ let least = Infinity;
4892
+ for (let i = 0; i < nodes.length; i++) {
4893
+ const [d, dy] = [flat$1(p, nodes[i]), (nodes[i][1] - p[1]) * up];
4894
+ const [ux, uz] = [(nodes[i][0] - p[0]) / (d || 1), (nodes[i][2] - p[2]) / (d || 1)];
4895
+ const head = Math.max(p[1], nodes[i][1]) + 1.5;
4896
+ if (ok(i) && d < NEAR && dy <= ABOVE && dy >= -8 && weigh(d, i) < least && (!clear || ray(w, [
4897
+ p[0],
4898
+ head,
4899
+ p[2]
4900
+ ], [
4901
+ ux,
4902
+ 0,
4903
+ uz
4904
+ ], d) >= d)) [best, least] = [i, weigh(d, i)];
4905
+ }
4906
+ if (best >= 0) return best;
4907
+ }
4908
+ return -1;
4909
+ };
4910
+ /**
4871
4911
  * The cheapest way from the point `a` to the point `b`. No entry when `a` walks straight to `b`, or
4872
4912
  * when the map has no way. The legs of the routes other than `prefer` (an index of ROUTES) cost
4873
4913
  * more, so bots that prefer different ones spread over the map.
@@ -4881,23 +4921,9 @@ var path = (nav, w, a, b, prefer = -1) => {
4881
4921
  const back = new Array(n).fill(-1);
4882
4922
  const done = new Array(n).fill(false);
4883
4923
  for (let i = 0; i < n; i++) if (!runUp.has(i) && flat$1(a, nodes[i]) <= WALK && walkable(w, a, nodes[i])) cost[i] = flat$1(a, nodes[i]) / PACE;
4884
- for (const clear of [true, false]) {
4885
- if (cost.some((c) => c < Infinity)) break;
4886
- let near = -1;
4887
- for (let i = 0; i < n; i++) {
4888
- const [d, dy] = [flat$1(a, nodes[i]), nodes[i][1] - a[1]];
4889
- const [ux, uz] = [(nodes[i][0] - a[0]) / (d || 1), (nodes[i][2] - a[2]) / (d || 1)];
4890
- if (!runUp.has(i) && d < NEAR && dy <= ABOVE && dy >= -8 && (!clear || ray(w, [
4891
- a[0],
4892
- a[1] + 1.5,
4893
- a[2]
4894
- ], [
4895
- ux,
4896
- 0,
4897
- uz
4898
- ], d) >= d) && (near < 0 || d < flat$1(a, nodes[near]))) near = i;
4899
- }
4900
- if (near >= 0) cost[near] = flat$1(a, nodes[near]) / PACE;
4924
+ if (!cost.some((c) => c < Infinity)) {
4925
+ const first = close(w, nodes, a, (i) => !runUp.has(i), (d) => d, 1);
4926
+ if (first >= 0) cost[first] = flat$1(a, nodes[first]) / PACE;
4901
4927
  }
4902
4928
  for (;;) {
4903
4929
  let i = -1;
@@ -4919,6 +4945,7 @@ var path = (nav, w, a, b, prefer = -1) => {
4919
4945
  const c = cost[i] + flat$1(nodes[i], b) / PACE;
4920
4946
  if (cost[i] < Infinity && c < total && flat$1(nodes[i], b) <= WALK && walkable(w, nodes[i], b)) [best, total] = [i, c];
4921
4947
  }
4948
+ if (best < 0) best = close(w, nodes, b, (i) => cost[i] < Infinity, (d, i) => cost[i] + d / PACE, -1);
4922
4949
  const edges = [];
4923
4950
  let i = best;
4924
4951
  for (; i >= 0 && prev[i]; i = back[i]) edges.unshift(prev[i]);
@@ -5012,7 +5039,8 @@ var fly = (w, b, m, foes) => {
5012
5039
  b.dz
5013
5040
  ];
5014
5041
  const go = Math.min(m, b.left);
5015
- let t = ray(w, o, d, go, PLASMA_R);
5042
+ const seam = w.def.seam === void 0 || !d[1] ? Infinity : (w.def.seam - o[1]) / d[1];
5043
+ let t = ray(w, o, d, seam > 1e-6 ? Math.min(go, seam) : go, PLASMA_R);
5016
5044
  let hit;
5017
5045
  for (const f of foes) {
5018
5046
  const u = cylinder(o, d, f, PLAYER_R + (b.arc ? ARC_R : PLASMA_R), heightOf(f));
@@ -6522,8 +6550,8 @@ var SHIP = {
6522
6550
  SLIDE: .3,
6523
6551
  RMAX: .8,
6524
6552
  RRESP: 5,
6525
- /** The ceiling's height (y), the crater's bound shrunk to EDGE, and the depth over which the warning grows. */
6526
- CEIL: 120,
6553
+ /** The ceiling's height (y): the top of space; the crater's bound shrunk to EDGE, and the depth over which the warning grows. */
6554
+ CEIL: ORBIT.TOP,
6527
6555
  EDGE: .88,
6528
6556
  WARN: 20,
6529
6557
  /** Past a limit: the push back (m/s² per metre past it) and the brake on the speed out (1/s). */
@@ -151,6 +151,8 @@ export interface ShipPanel {
151
151
  }
152
152
  /** The warning of the nearest limit once one is within its last half of WARN, or ''. */
153
153
  export declare const warning: (up: number, out: number) => string;
154
+ /** The ship's height on its panel: metres under the edge of space, kilometres in orbit. */
155
+ export declare const height: (alt: number) => string;
154
156
  /** Milliseconds a banner stays, and a hit marker. */
155
157
  export declare const BANNER_MS = 2800;
156
158
  /** Milliseconds an own frag's name and award stay, and a line of the kill feed; the feed's lines. */
@@ -1,4 +1,7 @@
1
1
  import type { WorldDef } from '../shared/world';
2
+ import type { Vec3 } from './mesh';
3
+ /** The point the Earth is placed from, SKY m off: the eye, in render.ts. */
4
+ export declare const HEAVENS: Vec3;
2
5
  /**
3
6
  * Radius of the star dome and the Earth's distance, metres: past the crater wall (drawn to 1.65
4
7
  * of the bound) and, at most 360 m more from a spot on the bound, inside the far clip (FAR).
@@ -30,3 +33,5 @@ export declare const RANGES: number[][];
30
33
  export declare const RANGE_COLS = 480;
31
34
  /** The moon's scenery vertices, in the renderer's format. */
32
35
  export declare const moonscape: (def: WorldDef) => number[];
36
+ /** The Earth, drawn last: render.ts moves it with the eye from HEAVENS. The stars are drawn by the sky's shader. */
37
+ export declare const heavens: () => number[];
@@ -433,3 +433,14 @@ export declare const VEHICLE: {
433
433
  readonly GRAZE: 4;
434
434
  readonly SKID: 0.92;
435
435
  };
436
+ /**
437
+ * Space over the moon (the user, 2026-11-14): SEAM metres up is the edge of space, where a ship
438
+ * fights only ships. A shot that crosses it either way bursts there, so the ground and the sky never
439
+ * hit each other. TOP is the highest a ship climbs, under the 1024 m a ball's height has on the
440
+ * wire. Over the seam the moon is drawn as a globe seen from ALT metres at TOP (altitude()).
441
+ */
442
+ export declare const ORBIT: {
443
+ readonly SEAM: 300;
444
+ readonly TOP: 960;
445
+ readonly ALT: 250000;
446
+ };
@@ -35,8 +35,8 @@ export declare const SHIP: {
35
35
  readonly SLIDE: 0.3;
36
36
  readonly RMAX: 0.8;
37
37
  readonly RRESP: 5;
38
- /** The ceiling's height (y), the crater's bound shrunk to EDGE, and the depth over which the warning grows. */
39
- readonly CEIL: 120;
38
+ /** The ceiling's height (y): the top of space; the crater's bound shrunk to EDGE, and the depth over which the warning grows. */
39
+ readonly CEIL: 960;
40
40
  readonly EDGE: 0.88;
41
41
  readonly WARN: 20;
42
42
  /** Past a limit: the push back (m/s² per metre past it) and the brake on the speed out (1/s). */
@@ -95,6 +95,11 @@ export declare const shipHull: (r: Rover) => Body;
95
95
  export declare const wings: (r: Rover) => Body[];
96
96
  /** Every solid of the ship: its hull, then its wings. */
97
97
  export declare const shipBodies: (r: Rover) => Body[];
98
+ /**
99
+ * The height `y` as it is drawn and shown: itself up to the seam, then growing as a power of the
100
+ * height over it, to ORBIT.ALT at ORBIT.TOP. Space is small to fly through and looks high.
101
+ */
102
+ export declare const altitude: (y: number) => number;
98
103
  /**
99
104
  * How near the ship is to its limits, each 0 inside and 1 at the limit (more past it): the ceiling
100
105
  * and the edge of the crater. For the HUD.
@@ -79,6 +79,8 @@ export interface WorldDef {
79
79
  ships?: Spawn[];
80
80
  /** The automatic doors (doors.ts). Absent: none. */
81
81
  doors?: Door[];
82
+ /** The height of the edge of space (ORBIT.SEAM): a shot that crosses it either way bursts there. Absent: none. */
83
+ seam?: number;
82
84
  }
83
85
  /** A world ready for physics and drawing: the definition and a grid of brushes on the floor plane. */
84
86
  export interface World {
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": "0.149.0",
5
+ "version": "0.150.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"