@adatechnology/game-vehicles 0.7.2 → 0.8.1

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.
@@ -0,0 +1,90 @@
1
+ import { TaskKind } from '@adatechnology/game-contracts';
2
+
3
+ /** Points a hull is made of at most (design 10.1). */
4
+ declare const MAX_HULL_POINTS = 64;
5
+ /** A flat piece (thinner than twice this) gets this much (m) on each side of its plane. */
6
+ declare const FLAT_PAD = 0.0025;
7
+ /** The triangles of a drawn piece (or of several, merged) in the vehicle's frame. */
8
+ interface HullSoup {
9
+ readonly vertices: readonly number[];
10
+ readonly indices: readonly number[];
11
+ }
12
+ /**
13
+ * The one convex hull (at most `MAX_HULL_POINTS` points, x y z triples, every one a drawn vertex) of the drawn vertices of a piece (design 10.1, method B): `reducePoints` always keeps the
14
+ * extreme of each of the 26 directions, so the hull reaches the drawn surface where it reaches farthest. A piece flatter than `2 * FLAT_PAD` gets `FLAT_PAD` on each side of its plane
15
+ * (a line, on each side of its plane and across it): a hull with no volume is no shape. Null when the soup has fewer than three points.
16
+ */
17
+ declare const hullOf: (soup: HullSoup) => number[] | null;
18
+
19
+ /** A cut across one axis; the two halves it makes are cut again by `lo` and `hi`, or are leaves when those are null. */
20
+ interface CutNode {
21
+ readonly axis: 0 | 1 | 2;
22
+ readonly at: number;
23
+ lo: CutNode | null;
24
+ hi: CutNode | null;
25
+ }
26
+ /** A thin part that sticks out of a piece: its triangles (by number in the piece's soup), the soup of them, and its name in a piece (the number of its first triangle). */
27
+ interface Protrusion {
28
+ readonly id: number;
29
+ readonly triangles: readonly number[];
30
+ readonly soup: HullSoup;
31
+ }
32
+ /**
33
+ * Thin parts that may be taken off a piece (antenna, wiper, handle on a stalk, step): parts that stick out of it and have a hull of at most `THIN_VOLUME`. A part sticks out when it is a
34
+ * connected part (corners welded at `WELD`) of its own that is thin (both smaller sides of its box at most `THIN_SECTION`) and passes the box of what is not thin by `PROTRUSION_REACH`;
35
+ * or, welded to the body, when its triangles are the tail of the piece (`tailOf`).
36
+ */
37
+ declare const protrusionsOf: (soup: HullSoup) => Protrusion[];
38
+ /** The units of a piece when `taken` (the numbers of the protrusions the plan took off it) are the ones to take off: the body, named by `key`, then each protrusion, named by `key` and its number. */
39
+ declare const unitsOf: (key: string, soup: HullSoup, taken: ReadonlySet<number> | undefined) => Array<{
40
+ readonly key: string;
41
+ readonly soup: HullSoup;
42
+ }>;
43
+ /** The leaves of a unit under its cuts (the same cuts as when the car was whole): the soup of each, named by the unit's key and the path of the cuts. */
44
+ declare const leavesOf: (key: string, soup: HullSoup, node: CutNode | null, path?: string) => Array<{
45
+ readonly key: string;
46
+ readonly path: string;
47
+ readonly soup: HullSoup;
48
+ }>;
49
+
50
+ /** One thin piece of the intact car, named by its key: its triangles in the frame of the colliders. */
51
+ interface HullPlanPiece {
52
+ readonly key: string;
53
+ readonly vertices: Float64Array;
54
+ readonly indices: Uint32Array;
55
+ }
56
+ /** What the division of a car's pieces needs: the thin pieces, the pieces of the solid parts (one entry per piece, `key` the part: each part gets one hull of all its pieces) and the hulls the model may have besides the solid parts. */
57
+ interface HullPlanJob {
58
+ readonly pieces: readonly HullPlanPiece[];
59
+ readonly solids: readonly HullPlanPiece[];
60
+ readonly maxHulls: number;
61
+ }
62
+ /** The one hull of a solid part (empty `points` when it has none), named by the part. */
63
+ interface HullPlanSolid {
64
+ readonly key: string;
65
+ readonly points: Float32Array;
66
+ }
67
+ /** A hull the division made: the piece it is from (`unit`, with `~n` for a protrusion), the cuts that lead to it, its points and the drawn vertices it was made from. */
68
+ interface HullPlanLeaf {
69
+ readonly unit: string;
70
+ readonly path: string;
71
+ readonly points: Float32Array;
72
+ readonly vertices: Float64Array;
73
+ }
74
+ /** The plan of a car, as plain data (no `Map`, so two results compare byte for byte): the cuts and the protrusions taken off each piece, and the hulls they make. */
75
+ interface HullPlanResult {
76
+ readonly cuts: ReadonlyArray<readonly [string, CutNode]>;
77
+ readonly taken: ReadonlyArray<readonly [string, readonly number[]]>;
78
+ readonly leaves: readonly HullPlanLeaf[];
79
+ readonly solids: readonly HullPlanSolid[];
80
+ }
81
+ /** The whole division of an intact car (design 10.3): a pure function of the job, the same on the main thread and in a worker. */
82
+ declare const planHulls: (job: HullPlanJob) => HullPlanResult;
83
+ /**
84
+ * The division of a car's hulls as a task kind of the worker coordinator (`vehicles.hull-plan`, lane `build`, CLAUDE.md §14): the pieces of the intact car in (their buffers handed over, not copied: a car whose worker fails makes the job again), the plan and the hulls
85
+ * out, the buffers transferred back. It is made once per model and kept by `createHullPlanCache`; until it arrives the car collides as the pieces' boxes. A game's worker file lists it in
86
+ * `installWorkerHost`.
87
+ */
88
+ declare const hullPlanKind: TaskKind<HullPlanJob, HullPlanResult>;
89
+
90
+ export { type CutNode as C, FLAT_PAD as F, type HullSoup as H, MAX_HULL_POINTS as M, type HullPlanJob as a, type HullPlanLeaf as b, type HullPlanPiece as c, type HullPlanResult as d, hullPlanKind as e, protrusionsOf as f, hullOf as h, leavesOf as l, planHulls as p, unitsOf as u };
@@ -0,0 +1,2 @@
1
+ export { a as HullPlanJob, b as HullPlanLeaf, c as HullPlanPiece, d as HullPlanResult, e as hullPlanKind, p as planHulls } from './worker-kinds-DlhpT_p3.js';
2
+ import '@adatechnology/game-contracts';
@@ -0,0 +1,9 @@
1
+ import {
2
+ hullPlanKind,
3
+ planHulls
4
+ } from "./chunk-AQFQ246K.js";
5
+ export {
6
+ hullPlanKind,
7
+ planHulls
8
+ };
9
+ //# sourceMappingURL=worker-kinds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/game-vehicles",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "license": "MIT",
5
5
  "description": "Generic procedural 3D vehicle engine for three.js: body shells, glass, lights, interiors, hood and engine bay, zone-based damage in five bands, cracking glass, particles, fluids, rollover, explosions and a damage-map UI. Content (the fleet, fuels, scenarios, texts) comes from packs and plugins.",
6
6
  "keywords": [
@@ -32,6 +32,10 @@
32
32
  "types": "./dist/index.d.ts",
33
33
  "import": "./dist/index.js"
34
34
  },
35
+ "./worker-kinds": {
36
+ "types": "./dist/worker-kinds.d.ts",
37
+ "import": "./dist/worker-kinds.js"
38
+ },
35
39
  "./global": "./dist/index.global.js"
36
40
  },
37
41
  "files": [
@@ -49,12 +53,12 @@
49
53
  "tsup": "^8.5.1",
50
54
  "typescript": "^5.7.3",
51
55
  "vitest": "^3.2.4",
52
- "@adatechnology/game-weapons": "^0.13.5",
53
- "@adatechnology/golden-tool": "^0.0.0"
56
+ "@adatechnology/golden-tool": "^0.0.0",
57
+ "@adatechnology/game-weapons": "^0.14.0"
54
58
  },
55
59
  "dependencies": {
56
- "@adatechnology/game-contracts": "^0.42.0",
57
- "@adatechnology/game-shapes-three": "^0.4.1"
60
+ "@adatechnology/game-contracts": "^0.44.0",
61
+ "@adatechnology/game-shapes-three": "^0.4.2"
58
62
  },
59
63
  "scripts": {
60
64
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsup",