@adatechnology/game-destruction-three 0.24.4 → 0.26.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/README.md +95 -1
- package/dist/ground-worker.global.js +826 -0
- package/dist/ground-worker.global.js.map +1 -0
- package/dist/ground-worker.js +823 -0
- package/dist/ground-worker.js.map +1 -0
- package/dist/index.d.ts +681 -6
- package/dist/index.global.js +18362 -2934
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7132 -503
- package/dist/index.js.map +1 -1
- package/dist/worker-kinds.d.ts +99 -0
- package/dist/worker-kinds.js +924 -0
- package/dist/worker-kinds.js.map +1 -0
- package/package.json +22 -8
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { TaskKind } from '@adatechnology/game-contracts';
|
|
2
|
+
import { HeightPatch } from '@adatechnology/game-terrain';
|
|
3
|
+
import { Vec3 } from '@adatechnology/game-destruction';
|
|
4
|
+
import { Quat } from '@adatechnology/game-physics';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A tile of the engine's ground as plain data, so it can be made off the main thread (`engine-ground-port`): the main thread reads the tile's samples and the band of ground
|
|
8
|
+
* past its edges its solid may read (`readGroundBand`), and the tile is a pure function of those (`computeGroundTile`), the same bits wherever it runs. Nothing here calls back
|
|
9
|
+
* into the host: a worker has no `groundAt`.
|
|
10
|
+
*/
|
|
11
|
+
/** What a tile is made from: its samples (`readGround`) and the band past its edges (`readGroundBand`), both read on the main thread at the frame it was asked for. */
|
|
12
|
+
interface GroundTileJob {
|
|
13
|
+
readonly id: number;
|
|
14
|
+
readonly x0: number;
|
|
15
|
+
readonly z0: number;
|
|
16
|
+
readonly size: number;
|
|
17
|
+
/** Whether the tile collided on the coarse field before (`collisionFieldOf`). */
|
|
18
|
+
readonly wasCoarse: boolean;
|
|
19
|
+
/** Empty in a patch job (`patch`), whose samples and band are made where the tile is. */
|
|
20
|
+
readonly samples: Float64Array;
|
|
21
|
+
readonly band: Float64Array;
|
|
22
|
+
/**
|
|
23
|
+
* The terrain's vertices under the tile and its ring (`readGroundPatch`), in place of the samples and the band: about 26 x 26 numbers instead of 60 000. The tile is made from
|
|
24
|
+
* the samples and band the patch gives (`heightPatchGrid`, the terrain's own blend), the same bits as read from the terrain on the main thread.
|
|
25
|
+
*/
|
|
26
|
+
readonly patch?: HeightPatch;
|
|
27
|
+
}
|
|
28
|
+
/** A tile made from a job, as arrays that cross threads; `samples` and `band` are the job's own, handed back for the next job. */
|
|
29
|
+
interface GroundTileResult {
|
|
30
|
+
readonly id: number;
|
|
31
|
+
readonly cells: number;
|
|
32
|
+
readonly collisionCells: number;
|
|
33
|
+
readonly level: number | null;
|
|
34
|
+
readonly heights: Float32Array;
|
|
35
|
+
readonly collision: Float32Array;
|
|
36
|
+
readonly boxes: Float64Array;
|
|
37
|
+
readonly solid: Float64Array;
|
|
38
|
+
readonly ring: Float64Array;
|
|
39
|
+
readonly samples: Float64Array;
|
|
40
|
+
readonly band: Float64Array;
|
|
41
|
+
/** A patch job's vertex heights, handed back for the next job. */
|
|
42
|
+
readonly patch?: Float64Array;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The triangles of a fixed drawn part where no box fits it (world space, three indices a triangle). */
|
|
46
|
+
interface StaticMesh {
|
|
47
|
+
readonly vertices: Float32Array;
|
|
48
|
+
readonly indices: Uint32Array;
|
|
49
|
+
}
|
|
50
|
+
/** A fixed box of what does not move, as it is drawn: centre, half sizes and rotation (world). With `mesh` the part is those triangles, and the box is the one around them. */
|
|
51
|
+
interface StaticSolid {
|
|
52
|
+
readonly center: Vec3;
|
|
53
|
+
readonly half: Vec3;
|
|
54
|
+
readonly rotation: Quat;
|
|
55
|
+
readonly mesh?: StaticMesh;
|
|
56
|
+
/** Names the part across lists (a part measured again is the same part): without it, the place in the list. */
|
|
57
|
+
readonly key?: string;
|
|
58
|
+
/** The Coulomb friction and rolling resistance of the part's material; without it the body has the ground's. */
|
|
59
|
+
readonly friction?: {
|
|
60
|
+
readonly static: number;
|
|
61
|
+
readonly dynamic: number;
|
|
62
|
+
readonly rolling: number;
|
|
63
|
+
readonly rollingDamping?: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* One fixed drawn part to measure (`measureStaticPart`): plain arrays, so it crosses to a worker (`destruction.static-colliders`). The main thread reads the vertices,
|
|
69
|
+
* the triangles and the mesh's world matrix (with three's own `decompose` of it); the measuring is here.
|
|
70
|
+
*/
|
|
71
|
+
interface StaticPartJob {
|
|
72
|
+
/** The part's vertices in the mesh's frame, three numbers each, with what another drawing collapses there already collapsed. */
|
|
73
|
+
readonly points: Float64Array;
|
|
74
|
+
/** The mesh's world matrix (16 numbers, column major). */
|
|
75
|
+
readonly matrix: Float64Array;
|
|
76
|
+
/** The world matrix decomposed (three's `Matrix4.decompose`): position, quaternion (x, y, z, w) and scale. */
|
|
77
|
+
readonly position: readonly [number, number, number];
|
|
78
|
+
readonly quaternion: readonly [number, number, number, number];
|
|
79
|
+
readonly scale: readonly [number, number, number];
|
|
80
|
+
/** The triangles of the part as vertex numbers of the host (three each), `from` its first vertex. */
|
|
81
|
+
readonly found: Uint32Array;
|
|
82
|
+
readonly from: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The engine's ground tiles as a task kind of the worker coordinator (`destruction.ground-tiles`, CLAUDE.md §14): a tile is a pure function
|
|
87
|
+
* of the samples and the band read at the update it was asked for, so the worker and the main thread give the same bits. The engine's
|
|
88
|
+
* `GroundSchedule` applies it at its update whatever the worker does (`createCoordinatorGroundPort`). No three.js here: a game's worker file
|
|
89
|
+
* imports it from `@adatechnology/game-destruction-three/worker-kinds`.
|
|
90
|
+
*/
|
|
91
|
+
declare const groundTilesKind: TaskKind<GroundTileJob, GroundTileResult>;
|
|
92
|
+
/**
|
|
93
|
+
* The fixed colliders measured from what is drawn (`destruction.static-colliders`, lane `build`, CLAUDE.md §14): a part of a house, a table, a wall measured anew is a
|
|
94
|
+
* pure function of its vertices, its triangles and its world matrix (`measureStaticPart`), so the worker and the main thread give the same bits. The renderer hands its
|
|
95
|
+
* parts to it when it has a coordinator (`RendererOptions.workers`); the object waits for the answer as a part out of turns waits for the next update.
|
|
96
|
+
*/
|
|
97
|
+
declare const staticCollidersKind: TaskKind<StaticPartJob, StaticSolid[]>;
|
|
98
|
+
|
|
99
|
+
export { groundTilesKind, staticCollidersKind };
|