@korial29/tiny-fps 0.95.0 → 0.97.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
@@ -171,6 +171,137 @@ var RULES = {
171
171
  timeLimit: 480,
172
172
  map: "highline"
173
173
  };
174
+ // src/shared/relief.ts
175
+ /** Integer hash of a lattice point to [0, 1): the same on every engine. */
176
+ var hash = (x, y, s) => {
177
+ let h = Math.imul(x, 374761393) + Math.imul(y, 668265263) + Math.imul(s, 144665) | 0;
178
+ h = Math.imul(h ^ h >>> 13, 1274126177);
179
+ return ((h ^ h >>> 16) >>> 0) / 4294967296;
180
+ };
181
+ /** Smooth value noise on the integer lattice, in [0, 1): flat across every lattice line, so a fold along one leaves no crease. */
182
+ var noise = (x, y, s) => {
183
+ const [i, j] = [Math.floor(x), Math.floor(y)];
184
+ const [u, v] = [x - i, y - j].map((t) => t * t * (3 - 2 * t));
185
+ const h = (a, b) => hash(i + a, j + b, s);
186
+ return (h(0, 0) * (1 - u) + h(1, 0) * u) * (1 - v) + (h(0, 1) * (1 - u) + h(1, 1) * u) * v;
187
+ };
188
+ var made = /* @__PURE__ */ new WeakMap();
189
+ /** Builds the lattice over the box of the bound, once per definition. */
190
+ var raise = (def) => {
191
+ const old = made.get(def);
192
+ if (old) return old;
193
+ const { hole, bound, cell, at } = def;
194
+ const [cx, cz, a, b] = bound;
195
+ const x0 = Math.floor((cx - a) / cell) * cell;
196
+ const z0 = Math.floor((cz - b) / cell) * cell;
197
+ const nx = Math.ceil((cx + a - x0) / cell) + 1;
198
+ const nz = Math.ceil((cz + b - z0) / cell) + 1;
199
+ const h = new Float32Array(nx * nz);
200
+ let top = -Infinity;
201
+ for (let j = 0; j < nz; j++) for (let i = 0; i < nx; i++) {
202
+ h[i + j * nx] = at(x0 + i * cell, z0 + j * cell);
203
+ top = Math.max(top, h[i + j * nx]);
204
+ }
205
+ const r = {
206
+ x0,
207
+ z0,
208
+ cell,
209
+ nx,
210
+ nz,
211
+ h,
212
+ hole,
213
+ bound,
214
+ top
215
+ };
216
+ made.set(def, r);
217
+ return r;
218
+ };
219
+ /**
220
+ * The height of the ground at (x, z), or -Infinity where there is none: a world without relief,
221
+ * and inside the hole. Each lattice square is two triangles split from node (i, j) to (i + 1, j + 1).
222
+ */
223
+ var ground = (w, x, z) => {
224
+ const r = w.relief;
225
+ if (!r || x > r.hole[0] && x < r.hole[2] && z > r.hole[1] && z < r.hole[3]) return -Infinity;
226
+ const u = Math.min(Math.max((x - r.x0) / r.cell, 0), r.nx - 1);
227
+ const v = Math.min(Math.max((z - r.z0) / r.cell, 0), r.nz - 1);
228
+ const i = Math.min(Math.floor(u), r.nx - 2);
229
+ const j = Math.min(Math.floor(v), r.nz - 2);
230
+ const [fu, fv] = [u - i, v - j];
231
+ const n = i + j * r.nx;
232
+ const [a, b, c, d] = [
233
+ r.h[n],
234
+ r.h[n + 1],
235
+ r.h[n + r.nx],
236
+ r.h[n + r.nx + 1]
237
+ ];
238
+ return fu >= fv ? a + (b - a) * fu + (d - b) * fv : a + (c - a) * fv + (d - c) * fu;
239
+ };
240
+ /** Keeps a body inside the bound: put back on the ellipse, its speed out of it taken away. */
241
+ var bound = (p, w) => {
242
+ if (!w.relief) return;
243
+ const [cx, cz, a, b] = w.relief.bound;
244
+ const [dx, dz] = [(p.x - cx) / a, (p.z - cz) / b];
245
+ const k = dx * dx + dz * dz;
246
+ if (k <= 1) return;
247
+ const s = 1 / Math.sqrt(k);
248
+ p.x = cx + dx * s * a;
249
+ p.z = cz + dz * s * b;
250
+ const [nx, nz] = [dx * s / a, dz * s / b];
251
+ const out = (p.vx * nx + p.vz * nz) / (nx * nx + nz * nz);
252
+ if (out > 0) {
253
+ p.vx -= out * nx;
254
+ p.vz -= out * nz;
255
+ }
256
+ };
257
+ /** Metres between two samples of a ray, and the halvings that then close in on the ground. */
258
+ var MARCH = 1;
259
+ var HALVINGS = 6;
260
+ /**
261
+ * Distance along the ray from o in the unit direction d to the ground, at most max: for ray(),
262
+ * after the brushes. A ray that starts under the ground hits at 0. With `grow`, the path of a
263
+ * sphere of that radius. Sampled every MARCH metres: a crest thinner than that is missed. The
264
+ * stretch over the hole is skipped: a ray that stays in the arena costs no sample.
265
+ */
266
+ var trace = (w, o, d, max, grow = 0) => {
267
+ const r = w.relief;
268
+ if (!r || Math.min(o[1], o[1] + d[1] * max) - grow > r.top) return max;
269
+ let [t0, t1] = [0, max];
270
+ for (const a of [0, 1]) {
271
+ const [p, v, lo, hi] = [
272
+ o[a * 2],
273
+ d[a * 2],
274
+ r.hole[a],
275
+ r.hole[a + 2]
276
+ ];
277
+ if (v) {
278
+ const [m, n] = [(lo - p) / v, (hi - p) / v];
279
+ t0 = Math.max(t0, Math.min(m, n));
280
+ t1 = Math.min(t1, Math.max(m, n));
281
+ } else if (p <= lo || p >= hi) t1 = -1;
282
+ }
283
+ const over = (t) => o[1] + d[1] * t - grow - ground(w, o[0] + d[0] * t, o[2] + d[2] * t);
284
+ if (!d[0] && !d[2]) {
285
+ const h = over(0);
286
+ return h < 0 ? 0 : d[1] < 0 ? Math.min(max, h / -d[1]) : max;
287
+ }
288
+ for (const [from, to] of t0 < t1 ? [[0, t0], [t1, max]] : [[0, max]]) {
289
+ if (from < to && over(from) < 0) return from;
290
+ for (let t = from; t < to; t += MARCH) {
291
+ const next = Math.min(t + MARCH, to);
292
+ if (over(next) < 0) {
293
+ let [lo, hi] = [t, next];
294
+ for (let n = 0; n < HALVINGS; n++) {
295
+ const mid = (lo + hi) / 2;
296
+ if (over(mid) < 0) hi = mid;
297
+ else lo = mid;
298
+ }
299
+ return lo;
300
+ }
301
+ }
302
+ }
303
+ return max;
304
+ };
174
305
  // src/shared/types.ts
175
306
  /** Where a team's flag is: at its base, on a carrier's back, or on the ground where it was dropped. */
176
307
  var FLAG = {
@@ -211,7 +342,9 @@ var KEY = {
211
342
  /** Press to swap the battery or the capsule of the gun in hand (see GUN_MAG). */
212
343
  RELOAD: 4096,
213
344
  /** Set while the player wants the laser rifle in hand (4 or the wheel), with BLADE and RAIL clear. Ignored without it. */
214
- RIFLE: 8192
345
+ RIFLE: 8192,
346
+ /** Press to get into the rover at hand, or out of the one he rides. */
347
+ USE: 16384
215
348
  };
216
349
  /**
217
350
  * The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
@@ -258,7 +391,9 @@ var MODE = {
258
391
  /** Sliding on the ground, low. */
259
392
  SLIDE: 5,
260
393
  /** Walking low. */
261
- CROUCH: 6
394
+ CROUCH: 6,
395
+ /** Seated in a rover (rover.ts): the body follows the seat, move() leaves it there. */
396
+ RIDE: 7
262
397
  };
263
398
  /**
264
399
  * Which side of the player a wall or a ledge is on (PlayerState.wall). In the air it is the side
@@ -320,19 +455,24 @@ var OFF = 1024;
320
455
  /** The key of the cell with integer coordinates (cx, cz). */
321
456
  var key = (cx, cz) => (cx + OFF) * (2 * OFF) + cz + OFF;
322
457
  /** Integer cell coordinate of a metre value, clamped to the keyed range. */
323
- var at = (v, cell) => Math.min(Math.max(Math.floor(v / cell), -1024), 1023);
458
+ var at$1 = (v, cell) => Math.min(Math.max(Math.floor(v / cell), -1024), 1023);
324
459
  /** Builds the grid: each brush is listed in every cell its footprint covers. */
325
460
  var build = (def, cell = CELL) => {
326
461
  const grid = /* @__PURE__ */ new Map();
327
462
  def.brushes.forEach(({ min, max }, i) => {
328
- for (let cx = at(min[0], cell); cx <= at(max[0], cell); cx++) for (let cz = at(min[2], cell); cz <= at(max[2], cell); cz++) {
463
+ for (let cx = at$1(min[0], cell); cx <= at$1(max[0], cell); cx++) for (let cz = at$1(min[2], cell); cz <= at$1(max[2], cell); cz++) {
329
464
  const k = key(cx, cz);
330
465
  const list = grid.get(k);
331
466
  if (list) list.push(i);
332
467
  else grid.set(k, [i]);
333
468
  }
334
469
  });
335
- return {
470
+ return def.relief ? {
471
+ def,
472
+ cell,
473
+ grid,
474
+ relief: raise(def.relief)
475
+ } : {
336
476
  def,
337
477
  cell,
338
478
  grid
@@ -344,24 +484,31 @@ var build = (def, cell = CELL) => {
344
484
  */
345
485
  var near = (w, x, z, r) => {
346
486
  const out = [];
347
- for (let cx = at(x - r, w.cell); cx <= at(x + r, w.cell); cx++) for (let cz = at(z - r, w.cell); cz <= at(z + r, w.cell); cz++) for (const i of w.grid.get(key(cx, cz)) ?? []) if (!out.includes(i)) out.push(i);
487
+ for (let cx = at$1(x - r, w.cell); cx <= at$1(x + r, w.cell); cx++) for (let cz = at$1(z - r, w.cell); cz <= at$1(z + r, w.cell); cz++) for (const i of w.grid.get(key(cx, cz)) ?? []) if (!out.includes(i)) out.push(i);
348
488
  return out;
349
489
  };
350
490
  /**
351
- * Distance along the ray from o in the unit direction d to the first brush face, at most max. A ray
352
- * that starts inside a brush hits at 0; one that starts on a face and moves away from it does not hit it.
491
+ * Distance along the ray from o in the unit direction d to the first brush face or to the ground of
492
+ * the relief, at most max. A ray that starts inside a brush hits at 0; one that starts on a face
493
+ * and moves away from it does not hit it.
353
494
  * With `grow`, every brush is that much bigger on each side: the path of a sphere of that radius
354
495
  * (its corners square, and a brush is only found in the cells the ray crosses).
355
- *
356
- * Walks the grid cells the ray crosses (Amanatides and Woo), testing the brushes of each against
357
- * the exact slab test, and stops once the next cell starts beyond the best hit or max. A brush
358
- * spanning several cells is tested in each: the hit is the same, and lists are short.
359
496
  */
360
497
  var ray = (w, o, d, max, grow = 0) => {
498
+ const hit = faces(w, o, d, max, grow);
499
+ return w.relief ? trace(w, o, d, hit, grow) : hit;
500
+ };
501
+ /**
502
+ * The brushes' share of ray(). Walks the grid cells the ray crosses (Amanatides and Woo), testing
503
+ * the brushes of each against the exact slab test, and stops once the next cell starts beyond the
504
+ * best hit or max. A brush spanning several cells is tested in each: the hit is the same, and
505
+ * lists are short.
506
+ */
507
+ var faces = (w, o, d, max, grow) => {
361
508
  const { cell, def } = w;
362
509
  let best = max;
363
- let cx = at(o[0], cell);
364
- let cz = at(o[2], cell);
510
+ let cx = at$1(o[0], cell);
511
+ let cz = at$1(o[2], cell);
365
512
  const sx = Math.sign(d[0]);
366
513
  const sz = Math.sign(d[2]);
367
514
  const nx = sx ? ((cx + (sx > 0 ? 1 : 0)) * cell - o[0]) / d[0] : Infinity;
@@ -545,10 +692,12 @@ var gap = (b, x, z) => [x - clamp(x, b.min[0], b.max[0]), z - clamp(z, b.min[2],
545
692
  * step of that size cannot bring the centre across one, however thin. The candidates come from
546
693
  * near() with twice PLAYER_R, enough for the one push of at most PLAYER_R that matters.
547
694
  */
548
- var push = (p, w, h) => {
695
+ var push = (p, w, h) => shove(p, w, h, PLAYER_R);
696
+ /** push() for a circle of radius r: a rover's body is a few of them. */
697
+ var shove = (p, w, h, r) => {
549
698
  const { brushes } = w.def;
550
- const ids = near(w, p.x, p.z, 2 * PLAYER_R);
551
- const reach = (PLAYER_R - EPS) ** 2;
699
+ const ids = near(w, p.x, p.z, 2 * r);
700
+ const reach = (r - EPS) ** 2;
552
701
  let [tx, tz] = [0, 0];
553
702
  for (let pass = 0; pass < 4; pass++) {
554
703
  let best = 0;
@@ -562,8 +711,8 @@ var push = (p, w, h) => {
562
711
  if (d2 >= reach) continue;
563
712
  if (d2) {
564
713
  const d = sqrt(d2);
565
- if (.4 - d > best) {
566
- best = PLAYER_R - d;
714
+ if (r - d > best) {
715
+ best = r - d;
567
716
  px = dx / d * best;
568
717
  pz = dz / d * best;
569
718
  }
@@ -591,8 +740,8 @@ var push = (p, w, h) => {
591
740
  1
592
741
  ]
593
742
  ].reduce((a, c) => c[0] < a[0] ? c : a);
594
- if (m + .4 > best) {
595
- best = m + PLAYER_R;
743
+ if (m + r > best) {
744
+ best = m + r;
596
745
  [px, pz] = [nx * best, nz * best];
597
746
  }
598
747
  }
@@ -615,7 +764,7 @@ var push = (p, w, h) => {
615
764
  var span = (p, w, h) => {
616
765
  const { brushes } = w.def;
617
766
  const reach = (PLAYER_R - EPS) ** 2;
618
- let floor = -Infinity;
767
+ let floor = ground(w, p.x, p.z);
619
768
  let ceil = Infinity;
620
769
  for (const i of near(w, p.x, p.z, PLAYER_R)) {
621
770
  const b = brushes[i];
@@ -724,13 +873,13 @@ var over = (p, w) => {
724
873
  });
725
874
  };
726
875
  /** The world's gravity: GRAVITY times the map's share (the moon's half gravity, the user, 2026-11-09). */
727
- var pull = (w) => 20 * (w.def.gravity ?? 1);
876
+ var gravity = (w) => 20 * (w.def.gravity ?? 1);
728
877
  /** Whether the player will be back on a floor within the jump buffer: a press now is kept for it. */
729
878
  var landingSoon = (p, w) => {
730
879
  if (p.vy >= 0) return false;
731
880
  const [floor] = span(p, w, PLAYER_H);
732
881
  const t = 6 * DT;
733
- return p.y - floor <= -p.vy * t + .5 * pull(w) * t * t;
882
+ return p.y - floor <= -p.vy * t + .5 * gravity(w) * t * t;
734
883
  };
735
884
  /** Changes the mode, and starts counting the time in it. */
736
885
  var enter = (p, mode) => {
@@ -753,7 +902,7 @@ var stumble = (p, dx, dz, ticks = 48, knock = 6) => {
753
902
  p.coyote = 0;
754
903
  p.buffer = 0;
755
904
  if (p.mode === MODE.HANG || p.mode === MODE.CLIMB) p.vy = 0;
756
- if (p.mode === MODE.HANG || p.mode === MODE.CLIMB || p.mode === MODE.WALLRUN) {
905
+ if (p.mode === MODE.HANG || p.mode === MODE.CLIMB || p.mode === MODE.WALLRUN || p.mode === MODE.RIDE) {
757
906
  enter(p, MODE.AIR);
758
907
  p.edge = 0;
759
908
  }
@@ -833,8 +982,9 @@ var fly$1 = (p, w, h, g, snap) => {
833
982
  p.vz -= into * cz / d;
834
983
  }
835
984
  }
985
+ bound(p, w);
836
986
  const [floor, ceil] = span(p, w, h);
837
- const vy = p.vy - g * pull(w) * DT;
987
+ const vy = p.vy - g * gravity(w) * DT;
838
988
  p.y += (p.vy + vy) / 2 * DT;
839
989
  p.vy = vy;
840
990
  if (p.y + h > ceil) {
@@ -1098,11 +1248,12 @@ var move = (p, i, w, team = 0) => {
1098
1248
  const [fx, fz] = forward(p.yaw);
1099
1249
  const pressed = (bit) => (i.keys & bit) !== 0 && (p.held & bit) === 0;
1100
1250
  const stumbling = p.stun > 0;
1251
+ const riding = p.mode === MODE.RIDE;
1101
1252
  const c = {
1102
1253
  keys: i.keys,
1103
1254
  stumble: stumbling,
1104
- jump: !stumbling && pressed(KEY.JUMP),
1105
- dash: !stumbling && pressed(KEY.DASH),
1255
+ jump: !stumbling && !riding && pressed(KEY.JUMP),
1256
+ dash: !stumbling && !riding && pressed(KEY.DASH),
1106
1257
  fwd: f > 0,
1107
1258
  wx: (fx * f - fz * s) / n,
1108
1259
  wz: (fz * f + fx * s) / n,
@@ -1120,7 +1271,7 @@ var move = (p, i, w, team = 0) => {
1120
1271
  }
1121
1272
  if (p.mode === MODE.HANG) hang(p, w, c);
1122
1273
  if (p.mode === MODE.CLIMB) climb(p, w);
1123
- else if (p.mode !== MODE.HANG) free(p, w, c);
1274
+ else if (p.mode !== MODE.HANG && !riding) free(p, w, c);
1124
1275
  if (p.slow) {
1125
1276
  p.slow--;
1126
1277
  cap(p, 3);
@@ -1129,7 +1280,7 @@ var move = (p, i, w, team = 0) => {
1129
1280
  p.t = p.mode === before ? Math.min(255, p.t + 1) : p.t;
1130
1281
  p.buffer = Math.max(0, p.buffer - 1);
1131
1282
  if (p.mode === MODE.AIR && before === MODE.AIR) p.coyote = Math.max(0, p.coyote - 1);
1132
- p.held = i.keys & (KEY.JUMP | KEY.DASH);
1283
+ p.held = i.keys & (KEY.JUMP | KEY.DASH | KEY.USE);
1133
1284
  p.ground = onFloor(p.mode);
1134
1285
  p.x = f32(p.x);
1135
1286
  p.y = f32(p.y);
@@ -1682,12 +1833,12 @@ var duel = (p, i) => {
1682
1833
  var powerOf = (ticks) => ticks < 10 ? 1 : 1 + Math.floor(4 * (ticks - 10) / 50);
1683
1834
  // src/shared/map.ts
1684
1835
  /** The bottom of every building: far below the kill floor, so nothing shows beneath a roof. */
1685
- var BASE = -30;
1836
+ var BASE$1 = -30;
1686
1837
  /** A building: the footprint x0..x1 by z0..z1 from the street up to a flat roof at `top`, white concrete over a facade. */
1687
1838
  var roof = (x0, z0, x1, z1, top, side = TEX.CONCRETE) => ({
1688
1839
  min: [
1689
1840
  x0,
1690
- BASE,
1841
+ BASE$1,
1691
1842
  z0
1692
1843
  ],
1693
1844
  max: [
@@ -1861,7 +2012,7 @@ var BLUE$1 = [
1861
2012
  ];
1862
2013
  /** The two team tints, red then blue. */
1863
2014
  var TEAM_TINT = [RED$1, BLUE$1];
1864
- var ORANGE = [
2015
+ var ORANGE$1 = [
1865
2016
  1,
1866
2017
  .42,
1867
2018
  .08
@@ -1885,7 +2036,7 @@ var pad = (x0, y0, z0, x1, y1, z1, tint) => box$1([
1885
2036
  * A column of stairs: from `a` to `b` along `axis` (0 for x, 2 for z), across `w0` to `w1` on the
1886
2037
  * other one, rising from `y` to `top` in steps of at most 0.46 m, each step a solid from `low`.
1887
2038
  */
1888
- var stairs$1 = (axis, a, b, w0, w1, y, top, low = BASE) => {
2039
+ var stairs$1 = (axis, a, b, w0, w1, y, top, low = BASE$1) => {
1889
2040
  const n = Math.ceil((top - y) / .46);
1890
2041
  return Array.from({ length: n }, (_, i) => {
1891
2042
  const [s0, s1] = [a + (b - a) * i / n, a + (b - a) * (i + 1) / n].sort((p, q) => p - q);
@@ -2101,7 +2252,7 @@ var half$1 = [
2101
2252
  ]
2102
2253
  ].map(([x0, z0, x1, z1, top]) => box$1([
2103
2254
  x0,
2104
- BASE,
2255
+ BASE$1,
2105
2256
  z0
2106
2257
  ], [
2107
2258
  x1,
@@ -2201,7 +2352,7 @@ var half$1 = [
2201
2352
  96,
2202
2353
  17.7,
2203
2354
  162
2204
- ], TEX.STEEL, TEX.PAINT, ORANGE),
2355
+ ], TEX.STEEL, TEX.PAINT, ORANGE$1),
2205
2356
  box$1([
2206
2357
  82,
2207
2358
  14.5,
@@ -2272,7 +2423,7 @@ var centre$1 = [
2272
2423
  17.2,
2273
2424
  128
2274
2425
  ], TEX.CONCRETE),
2275
- pad(38, 17.2, 116, 50, 17.3, 124, ORANGE),
2426
+ pad(38, 17.2, 116, 50, 17.3, 124, ORANGE$1),
2276
2427
  ...[
2277
2428
  [35, 113],
2278
2429
  [35, 126.2],
@@ -2661,8 +2812,8 @@ var HIGHLINE = {
2661
2812
  .0035
2662
2813
  ]
2663
2814
  };
2664
- var [RED, BLUE] = TEAM_TINT;
2665
- var { STONE, CONCRETE, METAL, STEEL, PAINT } = TEX;
2815
+ // src/shared/moonbase.ts
2816
+ var { CONCRETE: CONCRETE$1, METAL: METAL$1, STEEL: STEEL$1, PAINT: PAINT$1 } = TEX;
2666
2817
  /** A box, corners (x0, y0, z0) and (x1, y1, z1), tops and sides, a tint. */
2667
2818
  var box = (x0, y0, z0, x1, y1, z1, top, side = top, tint) => ({
2668
2819
  min: [
@@ -2697,13 +2848,11 @@ var bx = (x0, y0, z0, x1, y1, z1) => ({
2697
2848
  z1
2698
2849
  ]
2699
2850
  });
2700
- /** The twin of a box across the centre line. */
2701
- var mirror = ({ min, max }) => bx(min[0], min[1], 280 - max[2], max[0], max[1], 280 - min[2]);
2702
- /** The drawn dome (moonscape.ts): a drum of radius R up to y 5, then a shell to the apex at y 17. */
2851
+ /** The drawn dome (client/moonbase.ts): a drum of radius R up to y 5, then a shell to the apex at y 17. */
2703
2852
  var R = 22.4;
2704
2853
  var shell = (y) => y < 5 ? R : R * Math.sqrt(1 - ((y - 5) / 12) ** 2);
2705
2854
  var q = (v) => Math.round(v * 10) / 10;
2706
- /** Height bands of the ghost collision over the dome: the first is above a double jump from a module top. */
2855
+ /** Height bands of the ghost collision of the dome: the first is its wall, up past a double jump from a module top; the others its roof. */
2707
2856
  var BANDS = [
2708
2857
  0,
2709
2858
  10.5,
@@ -2722,17 +2871,224 @@ var around = (r) => [
2722
2871
  [.71, .93],
2723
2872
  [.39, 1]
2724
2873
  ].map(([a, b]) => [q(a * r), q(b * r)]);
2725
- var first = around(22.599999999999998);
2726
- /** The domes' centres, the landing pads (x, z, radius), the shuttles, the modules, the tubes and the masts (centres), red's then blue's: what the scenery draws on. */
2874
+ var [[A0, B0], [A1, B1]] = around(22.599999999999998);
2875
+ var [T, H] = [.4, 2.48];
2876
+ /** Red's dome (its centre: x, z), modules and tubes (each from its module to where they meet at the dome's wall, the second across the end of the first): what the scenery draws on. */
2727
2877
  var DOME = [80, 236];
2878
+ var MODULES = [bx(111, 0, 222, 125, 5, 230), bx(96, 0, 196, 110, 5, 204)];
2879
+ var TUBES = [bx(102, 0, 223.2, 111, 3.5, 227.2), bx(98, 0, 204, 102, 3.5, 227.2)];
2880
+ var [[TX0, , TZ0], [TX1, TY, TZ1], [UX0, , UZ0], [UX1]] = TUBES.flatMap((t) => [t.min, t.max]);
2881
+ var [[C0, D0], [C1, D1]] = [[19.8, 6.7], [16, 13.5]];
2882
+ /** The mouths in the hall's wall (x and z of the middle from the centre, half width, height, depth): the door toward the flag, the tubes. */
2883
+ var MOUTHS = [[
2884
+ 0,
2885
+ -C0,
2886
+ 2,
2887
+ 3,
2888
+ 2.8
2889
+ ], [
2890
+ C1,
2891
+ -10.8,
2892
+ 2,
2893
+ 3.5,
2894
+ 2
2895
+ ]];
2896
+ /** The rectangles (x0, z0, x1, z1), their mirrors and their quarter turns about the centre, each once. */
2897
+ var turns = (l) => [...new Map(l.flatMap(([x0, z0, x1, z1]) => [1, -1].flatMap((i) => [1, -1].flatMap((j) => [[
2898
+ x0,
2899
+ x1,
2900
+ z0,
2901
+ z1
2902
+ ], [
2903
+ z0,
2904
+ z1,
2905
+ x0,
2906
+ x1
2907
+ ]].map(([a, b, c, d]) => [
2908
+ Math.min(i * a, i * b),
2909
+ Math.min(j * c, j * d),
2910
+ Math.max(i * a, i * b),
2911
+ Math.max(j * c, j * d)
2912
+ ])))).map((p) => [`${p}`, p])).values()];
2913
+ /** A ghost box about the dome's centre, (x0, z0, x1, z1) from y0 to y1. */
2914
+ var ghost = ([x0, z0, x1, z1], y0, y1, top = CONCRETE$1, side = top) => ({
2915
+ ...box(DOME[0] + x0, y0, DOME[1] + z0, DOME[0] + x1, y1, DOME[1] + z1, top, side),
2916
+ ghost: true
2917
+ });
2918
+ /**
2919
+ * Stairs from `a` to `b` along z (axis 2) or x (0), across `w0` to `w1`, rising from `y` to `top`
2920
+ * in steps of at most 0.46 m, each a solid from `y`.
2921
+ */
2922
+ var stairs = (axis, a, b, w0, w1, y, top) => {
2923
+ const n = Math.ceil((top - y) / .46);
2924
+ return Array.from({ length: n }, (_, i) => {
2925
+ const [s, t] = [a + (b - a) * i / n, a + (b - a) * (i + 1) / n].sort((p, q) => p - q);
2926
+ const up = y + (top - y) * (i + 1) / n;
2927
+ return axis ? box(w0, y, s, w1, up, t, CONCRETE$1) : box(s, y, w0, t, up, w1, CONCRETE$1);
2928
+ });
2929
+ };
2930
+ /**
2931
+ * What stands in the hall, about the dome's centre: ghosts, since client/moonbase.ts draws them
2932
+ * with the hall (the sun's shadow map is 64 m wide, a brush across the hall would be drawn sunlit).
2933
+ * The mezzanine 3.5 m up along the walls (not over the door), the stairs up to it facing the door,
2934
+ * a console and two parapets on it, three crates on the floor.
2935
+ */
2936
+ var FIT = [
2937
+ ...turns([[
2938
+ 12,
2939
+ -D1,
2940
+ C1,
2941
+ D1
2942
+ ], [
2943
+ C1,
2944
+ -D0,
2945
+ C0,
2946
+ D0
2947
+ ]]).filter((p) => p[1] > -C0).map((p) => ghost(p, 3.1, 3.5, METAL$1, STEEL$1)),
2948
+ ...stairs(2, DOME[1] + 5.6, DOME[1] + 12, DOME[0] - 1.5, DOME[0] + 1.5, 0, 3.5).map((b) => ({
2949
+ ...b,
2950
+ ghost: true
2951
+ })),
2952
+ ghost([
2953
+ -3,
2954
+ 19,
2955
+ 3,
2956
+ C0
2957
+ ], 3.5, 4.6, STEEL$1, METAL$1),
2958
+ ghost([
2959
+ -9,
2960
+ 12,
2961
+ -2.5,
2962
+ 12.5
2963
+ ], 3.5, 4.6, STEEL$1, PAINT$1),
2964
+ ghost([
2965
+ 2.5,
2966
+ 12,
2967
+ 9,
2968
+ 12.5
2969
+ ], 3.5, 4.6, STEEL$1, PAINT$1),
2970
+ ghost([
2971
+ -6,
2972
+ -8,
2973
+ -4,
2974
+ -6
2975
+ ], 0, 1.4, STEEL$1),
2976
+ ghost([
2977
+ 4,
2978
+ -8,
2979
+ 6,
2980
+ -6
2981
+ ], 0, 1.4, STEEL$1),
2982
+ ghost([
2983
+ 5.5,
2984
+ 1.5,
2985
+ 8,
2986
+ 4
2987
+ ], 0, 2.4, STEEL$1)
2988
+ ];
2989
+ /**
2990
+ * A wall along the axis k from a to b, between p and q across, up to y: a doorway H high in each
2991
+ * gap (from, to). A gap of no width only cuts the wall in two: vision.ts stripes a wall of 8 m.
2992
+ */
2993
+ var wall = (k, a, b, p, q, y, gaps = []) => {
2994
+ const piece = (s, t, y0) => k ? box(p, y0, s, q, y, t, CONCRETE$1) : box(s, y0, p, t, y, q, CONCRETE$1);
2995
+ return [...gaps, [b, b]].flatMap(([s, t], i, l) => [piece(i ? l[i - 1][1] : a, s, 0), ...t > s ? [piece(s, t, H)] : []]);
2996
+ };
2997
+ /** A module: a roof slab on four walls, with the gaps of the walls at its low z, high z, low x and high x. */
2998
+ var room = ({ min: [x0, , z0], max: [x1, y, z1] }, gaps, crate) => [
2999
+ box(x0, 4, z0, x1, y, z1, METAL$1, CONCRETE$1),
3000
+ ...wall(0, x0, x1, z0, z0 + T, 4, gaps[0]),
3001
+ ...wall(0, x0, x1, z1 - T, z1, 4, gaps[1]),
3002
+ ...wall(2, z0 + T, z1 - T, x0, x0 + T, 4, gaps[2]),
3003
+ ...wall(2, z0 + T, z1 - T, x1 - T, x1, 4),
3004
+ crate
3005
+ ];
3006
+ var ORANGE = [
3007
+ 1,
3008
+ .42,
3009
+ .08
3010
+ ];
3011
+ /** Red's half of the base. */
3012
+ var BASE = [
3013
+ ...BANDS.slice(2).flatMap((y1, i) => around(shell(BANDS[i + 1]) + .2).map(([a, b]) => ghost([
3014
+ -a,
3015
+ -b,
3016
+ a,
3017
+ b
3018
+ ], BANDS[i + 1], y1))),
3019
+ ...turns([
3020
+ [
3021
+ C0,
3022
+ -B0,
3023
+ A0,
3024
+ B0
3025
+ ],
3026
+ [
3027
+ C1,
3028
+ D0,
3029
+ A1,
3030
+ B1
3031
+ ],
3032
+ [
3033
+ D1,
3034
+ D1,
3035
+ C1,
3036
+ C1
3037
+ ]
3038
+ ]).map((p) => ghost(p, MOUTHS.find(([x, z]) => p[0] <= x && x <= p[2] && p[1] <= z && z <= p[3])?.[3] ?? 0, BANDS[1])),
3039
+ ...[
3040
+ [
3041
+ -B0,
3042
+ -A0,
3043
+ -MOUTHS[0][2],
3044
+ -C0
3045
+ ],
3046
+ [
3047
+ MOUTHS[0][2],
3048
+ -A0,
3049
+ B0,
3050
+ -C0
3051
+ ],
3052
+ [
3053
+ C1,
3054
+ TZ1 - DOME[1],
3055
+ A1,
3056
+ -D0
3057
+ ],
3058
+ [
3059
+ C1,
3060
+ -B1,
3061
+ UX0 - DOME[0],
3062
+ TZ0 - DOME[1]
3063
+ ]
3064
+ ].map((p) => ghost(p, 0, BANDS[1])),
3065
+ ...FIT,
3066
+ ...room(MODULES[0], [
3067
+ [[118, 118]],
3068
+ [[116.8, 119.2]],
3069
+ [[TZ0 + T, TZ1 - T]]
3070
+ ], box(121.5, 0, 223.5, 123.5, 1.2, 225.5, PAINT$1, PAINT$1, ORANGE)),
3071
+ ...room(MODULES[1], [[[101.8, 104.2]], [[UX0 + T, UX1 - T], [105.8, 105.8]]], box(106, 0, 200.6, 108, 1.2, 202.6, PAINT$1, PAINT$1, ORANGE)),
3072
+ box(TX0, H, TZ0, TX1, TY, TZ1, STEEL$1, METAL$1),
3073
+ box(UX0, H, UZ0, UX1, TY, TZ1, STEEL$1, METAL$1),
3074
+ box(UX0, 0, TZ1 - T, TX1, H, TZ1, METAL$1),
3075
+ box(UX1 - T, 0, TZ0, TX1, H, TZ0 + T, METAL$1),
3076
+ box(UX0, 0, UZ0, UX0 + T, H, TZ0, METAL$1),
3077
+ box(UX1 - T, 0, UZ0, UX1, H, TZ0, METAL$1),
3078
+ ...stairs(2, 214, TZ0, 105, 109, 0, 3.5),
3079
+ ...stairs(0, 108, UX1, 206, 210, 0, 3.5)
3080
+ ];
3081
+ var [RED, BLUE] = TEAM_TINT;
3082
+ var { STONE, CONCRETE, METAL, STEEL, PAINT } = TEX;
3083
+ /** The twin of a box across the centre line. */
3084
+ var mirror = ({ min, max }) => bx(min[0], min[1], 280 - max[2], max[0], max[1], 280 - min[2]);
3085
+ /** The domes' centres, the landing pads (x, z, radius), the shuttles, the modules, the tubes and the masts (centres), red's then blue's: what the scenery draws on. */
2728
3086
  var PAD = [
2729
3087
  40,
2730
3088
  220,
2731
3089
  13
2732
3090
  ];
2733
3091
  var SHUTTLE = bx(33, .25, 218, 47, 3.25, 222);
2734
- var MODULES = [bx(111, 0, 222, 125, 5, 230), bx(96, 0, 196, 110, 5, 204)];
2735
- var TUBES = [bx(DOME[0] + first[1][0], 0, DOME[1] - first[0][1] - 4, 111, 3.5, DOME[1] - first[0][1]), bx(98, 0, 204, 102, 3.5, DOME[1] - first[1][1])];
2736
3092
  var MASTS = [
2737
3093
  [27.3, 207.3],
2738
3094
  [52.7, 207.3],
@@ -2741,19 +3097,173 @@ var MASTS = [
2741
3097
  [106.2, 230.4],
2742
3098
  [103.2, 212.4]
2743
3099
  ];
2744
- DOME[0], 280 - DOME[1], PAD[0], 280 - PAD[1], PAD[2], mirror(SHUTTLE), [...MODULES, ...MODULES.map(mirror)], [...TUBES, ...TUBES.map(mirror)], [...MASTS, ...MASTS.map(([x, z]) => [x, 280 - z])];
3100
+ var c1 = (t) => Math.min(Math.max(t, 0), 1);
3101
+ var sm = (t) => c1(t) * c1(t) * (3 - 2 * c1(t));
3102
+ var far = (a, b) => Math.sqrt(a * a + b * b);
3103
+ /** Craters, x, z, radius: a bowl 0.19 of the radius deep under a rim 0.06 of it high, flat for 4 m. The first is the Bowl. */
3104
+ var BOWLS = [
3105
+ [
3106
+ -100,
3107
+ 0,
3108
+ 46
3109
+ ],
3110
+ [
3111
+ 20,
3112
+ 215,
3113
+ 22
3114
+ ],
3115
+ [
3116
+ 110,
3117
+ 236,
3118
+ 16
3119
+ ],
3120
+ [
3121
+ -112,
3122
+ 108,
3123
+ 14
3124
+ ],
3125
+ [
3126
+ 236,
3127
+ 170,
3128
+ 13
3129
+ ],
3130
+ [
3131
+ -28,
3132
+ 228,
3133
+ 12
3134
+ ]
3135
+ ];
3136
+ /** Jump ramps, where the rise starts and the unit way up: 16 m long, 5.6 m high (19 degrees), 12 m wide, the lip flat for 4 m (no knife edge under a rover). */
3137
+ var RAMPS = [
3138
+ [
3139
+ -20,
3140
+ 0,
3141
+ -1,
3142
+ 0
3143
+ ],
3144
+ [
3145
+ 192,
3146
+ 124,
3147
+ 0,
3148
+ -1
3149
+ ],
3150
+ [
3151
+ 64,
3152
+ 236,
3153
+ 1,
3154
+ 0
3155
+ ],
3156
+ [
3157
+ -60,
3158
+ 100,
3159
+ 0,
3160
+ 1
3161
+ ]
3162
+ ];
3163
+ /** The ridge east of the arena (x, the z its crest ends at) and the antennas' hill south-east (x, z). */
3164
+ var [RIDGE, HILL] = [[248, 64], [180, 200]];
3165
+ /** The boulder field south-west: x, z, radius. */
3166
+ var FIELD = [
3167
+ [
3168
+ 0,
3169
+ 0,
3170
+ 4.5
3171
+ ],
3172
+ [
3173
+ -14,
3174
+ 6,
3175
+ 3
3176
+ ],
3177
+ [
3178
+ 10,
3179
+ -12,
3180
+ 3.5
3181
+ ],
3182
+ [
3183
+ 16,
3184
+ 10,
3185
+ 2.5
3186
+ ],
3187
+ [
3188
+ -8,
3189
+ -16,
3190
+ 2.2
3191
+ ],
3192
+ [
3193
+ -20,
3194
+ -8,
3195
+ 3.8
3196
+ ],
3197
+ [
3198
+ 6,
3199
+ 18,
3200
+ 3
3201
+ ],
3202
+ [
3203
+ 22,
3204
+ -4,
3205
+ 2
3206
+ ],
3207
+ [
3208
+ -12,
3209
+ 20,
3210
+ 2.4
3211
+ ]
3212
+ ].map(([x, z, r]) => [
3213
+ x - 50,
3214
+ z + 330,
3215
+ r
3216
+ ]);
3217
+ /** The three dishes on the hill and the lander wrecked in the Bowl. */
3218
+ var DISHES = [
3219
+ [180, 340],
3220
+ [173, 346],
3221
+ [186, 347]
3222
+ ];
3223
+ var WRECK = [BOWLS[0][0], 140];
2745
3224
  /**
2746
- * Stairs from `a` to `b` along z (axis 2) or x (0), across `w0` to `w1`, rising from `y` to `top`
2747
- * in steps of at most 0.46 m, each a solid from `y`.
3225
+ * The height of the crater floor round the arena. Only + - * /, Math.sqrt, Math.abs, min, max, floor
3226
+ * and the integer hash: every engine builds the same lattice. Exactly 0 for 12 m round the arena
3227
+ * (a rectangle on lattice lines, so between the nodes too); rolling hills, the pieces above, then the crater wall: it starts 0.78 of the way to the bound,
3228
+ * is 20 m high on it and, past it where nobody goes, climbs to a ragged crest of 60 to 95 m and
3229
+ * falls to the plain at 1.65 of the bound.
2748
3230
  */
2749
- var stairs = (axis, a, b, w0, w1, y, top) => {
2750
- const n = Math.ceil((top - y) / .46);
2751
- return Array.from({ length: n }, (_, i) => {
2752
- const [s, t] = [a + (b - a) * i / n, a + (b - a) * (i + 1) / n].sort((p, q) => p - q);
2753
- const up = y + (top - y) * (i + 1) / n;
2754
- return axis ? box(w0, y, s, w1, up, t, CONCRETE) : box(s, y, w0, t, up, w1, CONCRETE);
2755
- });
3231
+ var at = (x, z) => {
3232
+ z = Math.abs(z - 140);
3233
+ const k = far((x - 80) / 300, z / 360);
3234
+ const t = Math.max((k - .78) / .22, 0);
3235
+ let h = sm((Math.max(Math.abs(x - 80) - 80, z - 140) - 12) / 48) * (1 - .7 * sm(t)) * (16 * noise(x / 96, z / 96, 1) + 5 * noise(x / 36, z / 36, 2) + 1.4 * noise(x / 22, z / 22, 3) - 11.2);
3236
+ for (const [cx, cz, r] of BOWLS) {
3237
+ const q = far(x - cx, z - cz) / r;
3238
+ const s = 1 - c1((q - 1 - 4 / r) / .6);
3239
+ h += r * (q < 1 ? .25 * q * q - .19 : .06 * s * s);
3240
+ }
3241
+ for (const [rx, rz, ax, az] of RAMPS) {
3242
+ const [p, q] = [x - rx, z - rz];
3243
+ const a = p * ax + q * az;
3244
+ h += 5.6 * c1(Math.min(a / 16, (32 - a) / 12)) * c1((18 - Math.abs(p * az - q * ax)) / 12);
3245
+ }
3246
+ const d = c1(far(x - RIDGE[0], Math.max(z - RIDGE[1], 0)) / 36);
3247
+ h += 12 * (1 - d * d) * (1 - d * d) + 8 * sm((36 - far(x - HILL[0], z - HILL[1])) / 24);
3248
+ let w = 10 * t * (1 + t);
3249
+ if (k > 1) w = (w + (k - 1) * 60 * (Math.abs(2 * noise(x / 45, z / 45, 5) - 1) - .5)) * (1 + (k - 1) * (1.2 * noise(x / 90, z / 90, 7) - .6)) * (1 - sm((k - 1.25) / .4));
3250
+ return h + w;
2756
3251
  };
3252
+ /** The ghost under a drawn rock or mast: a box of half side s from under the ground to h above it. */
3253
+ var lump = (x, z, s, h) => ({
3254
+ ...box(x - s, at(x, z) - 6, z - s, x + s, at(x, z) + h, z + s, STONE),
3255
+ ghost: true
3256
+ });
3257
+ [...FIELD, ...FIELD.map(([x, z, r]) => [
3258
+ x,
3259
+ 280 - z,
3260
+ r
3261
+ ])], [...DISHES, ...DISHES.map(([x, z]) => [x, 280 - z])], RAMPS.flatMap(([x, z, ax, az]) => (z ? [1, -1] : [1]).map((m) => [
3262
+ x + 16 * ax,
3263
+ 140 + m * (z + 16 * az),
3264
+ ax,
3265
+ m * az + 0
3266
+ ])), DOME[0], 280 - DOME[1], PAD[0], 280 - PAD[1], PAD[2], mirror(SHUTTLE), [...MODULES, ...MODULES.map(mirror)], [...TUBES, ...TUBES.map(mirror)], [...MASTS, ...MASTS.map(([x, z]) => [x, 280 - z])];
2757
3267
  /** The twin of a brush, a point or a spawn across the centre line. */
2758
3268
  var flip = (b) => ({
2759
3269
  ...b,
@@ -2783,10 +3293,7 @@ var both = (l, ...mid) => [
2783
3293
  /** Red's half: z from 140 to 280. */
2784
3294
  var half = [
2785
3295
  box(0, -30, 148, 160, 0, 280, STONE),
2786
- ...BANDS.slice(1).flatMap((y1, i) => around(shell(BANDS[i]) + .2).map(([a, b]) => ({
2787
- ...box(DOME[0] - a, BANDS[i], DOME[1] - b, DOME[0] + a, y1, DOME[1] + b, CONCRETE),
2788
- ghost: true
2789
- }))),
3296
+ ...BASE,
2790
3297
  box(74, 0, 199, 86, .5, 211, PAINT, CONCRETE, RED),
2791
3298
  box(76, .5, 201, 84, 1, 209, PAINT, CONCRETE, RED),
2792
3299
  box(60, 0, 259, 70, 1.5, 265, STEEL, PAINT, RED),
@@ -2799,10 +3306,6 @@ var half = [
2799
3306
  .88
2800
3307
  ]
2801
3308
  },
2802
- ...MODULES.map((m) => fromBx(m, METAL, CONCRETE)),
2803
- ...TUBES.map((t) => fromBx(t, STEEL, METAL)),
2804
- ...stairs(2, 214, TUBES[0].min[2], 105, 109, 0, 3.5),
2805
- ...stairs(0, 108, 102, 206, 210, 0, 3.5),
2806
3309
  ...MASTS.map(([x, z]) => box(x - .2, x < 60 ? .25 : 0, z - .2, x + .2, x < 60 ? 10.25 : 10, z + .2, STEEL)),
2807
3310
  box(12, -30, 148 - 2.5 / 2, 24, 0, 148, PAINT, STONE, [
2808
3311
  1,
@@ -2852,9 +3355,11 @@ var half = [
2852
3355
  4,
2853
3356
  2.4
2854
3357
  ]
2855
- ].map(([x, z, w, d, h]) => box(x, 0, z, x + w, h, z + d, STONE))
3358
+ ].map(([x, z, w, d, h]) => box(x, 0, z, x + w, h, z + d, STONE)),
3359
+ ...FIELD.map(([x, z, r]) => lump(x, z, .6 * r, .6 * r)),
3360
+ ...DISHES.map(([x, z]) => lump(x, z, .4, 6))
2856
3361
  ];
2857
- /** What stands on the centre line, symmetric as written: the bridge, the stones and the rim. */
3362
+ /** What stands on the centre line, symmetric as written: the bridge, the stones, the rille's plugs and the wreck. */
2858
3363
  var centre = [
2859
3364
  box(74, -1.5, 132, 86, 0, 148, METAL, STEEL),
2860
3365
  box(74, 0, 132, 74.4, 1.1, 148, CONCRETE),
@@ -2862,15 +3367,15 @@ var centre = [
2862
3367
  box(126, -30, 143, 131, 1.2, 147, STONE),
2863
3368
  box(130, -30, 138.5, 135, 2.4, 141.5, STONE),
2864
3369
  box(126, -30, 133, 131, 1.2, 137, STONE),
2865
- ...[
2866
- box(-10, -30, -10, 0, 14, 290, STONE),
2867
- box(160, -30, -10, 170, 14, 290, STONE),
2868
- box(0, -30, -10, 160, 14, 0, STONE),
2869
- box(0, -30, 280, 160, 14, 290, STONE)
2870
- ].map((b) => ({
2871
- ...b,
3370
+ {
3371
+ ...box(-10, -30, 132, 0, 0, 148, STONE),
3372
+ ghost: true
3373
+ },
3374
+ {
3375
+ ...box(160, -30, 132, 170, 0, 148, STONE),
2872
3376
  ghost: true
2873
- }))
3377
+ },
3378
+ lump(WRECK[0], WRECK[1], 3, 3)
2874
3379
  ];
2875
3380
  /** Red's spawns behind the dome facing blue (yaw 0 looks toward -z): five in a row, three in front. */
2876
3381
  var SPAWNS = [...[
@@ -2945,6 +3450,11 @@ var MAPS = {
2945
3450
  30,
2946
3451
  0,
2947
3452
  185
3453
+ ],
3454
+ [
3455
+ 80,
3456
+ 3.5,
3457
+ 253.5
2948
3458
  ]
2949
3459
  ], [
2950
3460
  45,
@@ -2994,6 +3504,22 @@ var MAPS = {
2994
3504
  140
2995
3505
  ]),
2996
3506
  floor: -20,
3507
+ relief: {
3508
+ hole: [
3509
+ 0,
3510
+ 0,
3511
+ 160,
3512
+ 280
3513
+ ],
3514
+ bound: [
3515
+ 80,
3516
+ 140,
3517
+ 300,
3518
+ 360
3519
+ ],
3520
+ cell: 4,
3521
+ at
3522
+ },
2997
3523
  sun: {
2998
3524
  dir: [
2999
3525
  .87996,
@@ -3148,7 +3674,7 @@ var decodeInput = (buf) => {
3148
3674
  if (v.getUint8(0) !== 1) return null;
3149
3675
  return {
3150
3676
  seq: v.getUint16(1),
3151
- keys: v.getUint16(3) & 16383,
3677
+ keys: v.getUint16(3) & 32767,
3152
3678
  yaw: fromTurn(v.getUint16(5)),
3153
3679
  pitch: fromPitch(v.getInt16(7)),
3154
3680
  view: (v.getUint16(9) * 256 + v.getUint8(11)) / 256