@adatechnology/game-crowd-three 0.3.8 → 0.4.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/chunk-PXT6DYGJ.js +1707 -0
- package/dist/chunk-PXT6DYGJ.js.map +1 -0
- package/dist/index.d.ts +12 -291
- package/dist/index.global.js +8899 -4990
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +30 -1075
- package/dist/index.js.map +1 -1
- package/dist/testing-sTAa84Ib.d.ts +442 -0
- package/dist/testing.d.ts +7 -0
- package/dist/testing.js +19 -0
- package/dist/testing.js.map +1 -0
- package/package.json +14 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,301 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { BodyVariant, BakeBuilders, BakeSpec, Three } from '@adatechnology/game-characters-three';
|
|
4
|
-
import * as THREE_NS from 'three';
|
|
1
|
+
import { C as CrowdInstance, V as VariantSize } from './testing-sTAa84Ib.js';
|
|
2
|
+
export { A as AnimalDrawer, a as CROWD_AREA_ID, b as CROWD_EFFECTS, c as CROWD_RENDER_DEFAULTS, d as CrowdBenchSpecies, e as CrowdBenchText, f as CrowdEffectMap, g as CrowdFrame, h as CrowdInstanceSink, i as CrowdInstances, j as CrowdInstancesOptions, k as CrowdPoseMap, l as CrowdRenderNumbers, m as CrowdRenderer, n as CrowdRendererOptions, o as CrowdRendererVariety, p as CrowdScenarioLike, q as CrowdTestModule, r as CrowdTestModuleOptions, s as CrowdVarietyNumbers, D as DrawnAnimal, H as HerdView, t as HerdViewOptions, P as PlainCorpseSink, u as VARIETY_DEFAULTS, v as createCrowdInstances, w as createCrowdRenderer, x as createCrowdTestModule, y as createHerdView, z as crowdBenchTextOf, B as lookOfAgent } from './testing-sTAa84Ib.js';
|
|
5
3
|
import { SoundBank } from '@adatechnology/game-audio';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import '@adatechnology/game-crowd';
|
|
5
|
+
import '@adatechnology/game-characters-three';
|
|
6
|
+
import '@adatechnology/game-contracts';
|
|
7
|
+
import '@adatechnology/game-player';
|
|
8
|
+
import 'three';
|
|
9
|
+
import '@adatechnology/game-characters';
|
|
8
10
|
|
|
9
|
-
var numbers = {
|
|
10
|
-
lodDistances: [
|
|
11
|
-
18,
|
|
12
|
-
55
|
|
13
|
-
],
|
|
14
|
-
lodHysteresis: 1.5,
|
|
15
|
-
behindFrom: 30,
|
|
16
|
-
behindFactor: 0.35,
|
|
17
|
-
behindMargin: 3,
|
|
18
|
-
farCull: 200,
|
|
19
|
-
gaitMax: 1.4,
|
|
20
|
-
attackEnter: 2.56,
|
|
21
|
-
attackLeave: 4.84,
|
|
22
|
-
swell: 0.9,
|
|
23
|
-
swellPivot: 0.5,
|
|
24
|
-
ageBase: 0.75,
|
|
25
|
-
agePer: 0.08,
|
|
26
|
-
armBase: 1,
|
|
27
|
-
armPer: 0.4,
|
|
28
|
-
corpseNear: 18,
|
|
29
|
-
corpseFade: 60,
|
|
30
|
-
corpseDarken: 0.7,
|
|
31
|
-
corpseRise: 1.8,
|
|
32
|
-
corpseAgeBase: 0.8,
|
|
33
|
-
corpseAgeDark: 0.2,
|
|
34
|
-
childHeight: 0.66,
|
|
35
|
-
childBuild: 0.75,
|
|
36
|
-
bittenLook: 0.3,
|
|
37
|
-
civilianSkinStep: 0.25,
|
|
38
|
-
civilianBake: 0.8,
|
|
39
|
-
civilianBatch: 4
|
|
40
|
-
};
|
|
41
|
-
var poses = {
|
|
42
|
-
dormant: "fallen",
|
|
43
|
-
airborne: "leap",
|
|
44
|
-
eating: "eat",
|
|
45
|
-
pileStep: "attack",
|
|
46
|
-
swing: "scream",
|
|
47
|
-
crawl: "crawl",
|
|
48
|
-
grab: "attack",
|
|
49
|
-
calling: "scream",
|
|
50
|
-
"default": "walk",
|
|
51
|
-
corpse: "fallen",
|
|
52
|
-
civilian: "walk"
|
|
53
|
-
};
|
|
54
|
-
var defaults = {
|
|
55
|
-
numbers: numbers,
|
|
56
|
-
poses: poses
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
type CrowdRenderNumbers = typeof defaults.numbers;
|
|
60
|
-
type CrowdPoseMap = {
|
|
61
|
-
readonly [K in keyof typeof defaults.poses]: InstancePose;
|
|
62
|
-
};
|
|
63
|
-
/** The game's numbers for the drawing (G 67098 `hordeRender`, G 70177 `npcRender`) and the instance pose of each state. */
|
|
64
|
-
declare const CROWD_RENDER_DEFAULTS: {
|
|
65
|
-
readonly sources: Readonly<Record<string, string>>;
|
|
66
|
-
readonly numbers: CrowdRenderNumbers;
|
|
67
|
-
readonly poses: CrowdPoseMap;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* One body for a batch: the 12 numbers of the shader's `iA`, `iB` and `iC` (`a`: x, z, yaw, phase; `b`: height and build over the variant's,
|
|
71
|
-
* stride, pose; `c`: missing parts, age look, arms, skin), the shirt colour as hex with the shade it is multiplied by, the eye colour (none:
|
|
72
|
-
* no glow) and the ground height.
|
|
73
|
-
*/
|
|
74
|
-
type CrowdInstance = {
|
|
75
|
-
readonly a: readonly [number, number, number, number];
|
|
76
|
-
readonly b: readonly [number, number, number, number];
|
|
77
|
-
readonly c: readonly [number, number, number, number];
|
|
78
|
-
readonly color: number;
|
|
79
|
-
readonly shade: number;
|
|
80
|
-
readonly eye: number | null;
|
|
81
|
-
readonly y: number;
|
|
82
|
-
};
|
|
83
|
-
/** A baked variant as the drawing reads it: its own height and build (the instance scales the agent's against them). */
|
|
84
|
-
type VariantSize = {
|
|
85
|
-
readonly s: number;
|
|
86
|
-
readonly bulk: number;
|
|
87
|
-
};
|
|
88
|
-
/** Where the frame is seen from. `target` is who the agents attack (the attack pose); `hidden` leaves an agent out (a floor the viewer is not on). */
|
|
89
|
-
type CrowdFrame = {
|
|
90
|
-
readonly camera: {
|
|
91
|
-
readonly x: number;
|
|
92
|
-
readonly z: number;
|
|
93
|
-
};
|
|
94
|
-
/** The view's yaw: forward is `(-sin, -cos)`. */
|
|
95
|
-
readonly viewYaw: number;
|
|
96
|
-
readonly target?: {
|
|
97
|
-
readonly x: number;
|
|
98
|
-
readonly z: number;
|
|
99
|
-
readonly alive: boolean;
|
|
100
|
-
} | null;
|
|
101
|
-
readonly hidden?: (i: number) => boolean;
|
|
102
|
-
};
|
|
103
|
-
/** Takes one instance for the batch of `variant` at level `level` (0 near, 1 middle, 2 far). */
|
|
104
|
-
type CrowdInstanceSink = (variant: number, level: number, instance: CrowdInstance) => void;
|
|
105
|
-
/** Takes one body on the ground that was not an agent (a civilian killed outright): the plain body batch. */
|
|
106
|
-
type PlainCorpseSink = (instance: CrowdInstance) => void;
|
|
107
|
-
type CrowdInstancesOptions = {
|
|
108
|
-
readonly numbers?: Partial<CrowdRenderNumbers>;
|
|
109
|
-
readonly poses?: Partial<CrowdPoseMap>;
|
|
110
|
-
/** The eye colour of each crowd type, by type index (G `_eye`); null for a type that has none. */
|
|
111
|
-
readonly eyes: readonly (number | null)[];
|
|
112
|
-
};
|
|
113
|
-
type CrowdInstances = {
|
|
114
|
-
readonly numbers: CrowdRenderNumbers;
|
|
115
|
-
/** Writes the agents seen this frame, keeps each one's level of detail and attack pose in the store (`lod`, `attackPose`) and returns how many went out. */
|
|
116
|
-
agents(store: CrowdStore, variants: readonly VariantSize[], frame: CrowdFrame, sink: CrowdInstanceSink): number;
|
|
117
|
-
/** Writes the bodies on the ground: an agent's on its variant, the others on the plain batch. `life` is the seconds a body lasts (the crowd's `corpseSeconds`). */
|
|
118
|
-
corpses(entries: readonly {
|
|
119
|
-
readonly age: number;
|
|
120
|
-
readonly data: Corpse;
|
|
121
|
-
}[], variants: readonly VariantSize[], frame: CrowdFrame, life: number, sink: CrowdInstanceSink, plain: PlainCorpseSink): void;
|
|
122
|
-
/** Writes the civilians that are still people (not dead, turned or gone); `colorOf` gives each one's shirt. */
|
|
123
|
-
civilians(list: readonly Civilian[], colorOf: (civilian: Civilian) => number, sink: (civilian: Civilian, instance: CrowdInstance) => void): void;
|
|
124
|
-
};
|
|
125
11
|
/**
|
|
126
|
-
* The
|
|
127
|
-
*
|
|
12
|
+
* The look of an instance as one number: type, variant, shirt, trousers, size, wounds and accessories (the signature of the variety test, T4b.9).
|
|
13
|
+
* Two instances with the same signature look the same to the eye.
|
|
128
14
|
*/
|
|
129
|
-
declare
|
|
130
|
-
|
|
131
|
-
type CrowdRendererOptions = {
|
|
132
|
-
readonly crowd: Crowd;
|
|
133
|
-
/** The rich builders the bodies are baked from (`game-characters-three`: the Bestiário builder, optionally the survivors'). */
|
|
134
|
-
readonly builders: BakeBuilders;
|
|
135
|
-
/** The name the rich builder knows a crowd type by (default its id). */
|
|
136
|
-
readonly typeName?: (type: CrowdType, index: number) => string;
|
|
137
|
-
/** The civilians to draw and the body each one is baked from (G 68469 `PB`: a human spec or a portrait). Without it no civilian is drawn. */
|
|
138
|
-
readonly civilians?: {
|
|
139
|
-
readonly list: () => readonly Civilian[];
|
|
140
|
-
readonly body: (civilian: Civilian) => BakeSpec;
|
|
141
|
-
readonly color?: (civilian: Civilian) => number;
|
|
142
|
-
};
|
|
143
|
-
/** The plain body for bodies on the ground that were not agents (default the instanced body at the middle level, G `BODY_LOD[1]`). */
|
|
144
|
-
readonly plainBody?: THREE_NS.BufferGeometry;
|
|
145
|
-
/** Whether the bodies on the ground are drawn this frame (default always). */
|
|
146
|
-
readonly drawCorpses?: () => boolean;
|
|
147
|
-
readonly numbers?: Partial<CrowdRenderNumbers>;
|
|
148
|
-
readonly poses?: Partial<CrowdPoseMap>;
|
|
149
|
-
};
|
|
150
|
-
type CrowdRenderer = {
|
|
151
|
-
/** Holds every batch; add it to the scene. */
|
|
152
|
-
readonly group: THREE_NS.Group;
|
|
153
|
-
readonly instances: CrowdInstances;
|
|
154
|
-
/** Bakes every type's variants now (otherwise a type is baked the first time one of its bodies is drawn). */
|
|
155
|
-
bake(): void;
|
|
156
|
-
/** Draws the frame: the agents, the bodies on the ground and the civilians. */
|
|
157
|
-
update(dt: number, frame: CrowdFrame): void;
|
|
158
|
-
/** Agents drawn at each level of detail in the last frame (G `lodCounts`). */
|
|
159
|
-
readonly lodCounts: readonly [number, number, number];
|
|
160
|
-
/** Batches with something to draw. */
|
|
161
|
-
readonly drawCalls: number;
|
|
162
|
-
readonly bakeMs: number;
|
|
163
|
-
readonly variants: readonly BodyVariant[];
|
|
164
|
-
dispose(): void;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* The crowd drawn on the instanced path: every type's variants baked at the three levels of detail (G 67079 `ZVAR`, the variants and seeds of
|
|
168
|
-
* `game-characters`), a few draw calls for thousands of agents, the bodies on the ground and the civilians. The instances are `createCrowdInstances`
|
|
169
|
-
* (the port of `hordeRender` and `npcRender`); the batches are `game-characters-three`'s.
|
|
170
|
-
*/
|
|
171
|
-
declare function createCrowdRenderer(three: Three, options: CrowdRendererOptions): CrowdRenderer;
|
|
172
|
-
|
|
173
|
-
/** One drawn animal, as `game-animals-three` builds it (structural: this package does not depend on it). */
|
|
174
|
-
type DrawnAnimal = {
|
|
175
|
-
readonly root: THREE_NS.Object3D;
|
|
176
|
-
readonly wings: readonly {
|
|
177
|
-
readonly shoulder: THREE_NS.Object3D;
|
|
178
|
-
readonly elbow: THREE_NS.Object3D;
|
|
179
|
-
readonly side: number;
|
|
180
|
-
}[];
|
|
181
|
-
phase: number;
|
|
182
|
-
};
|
|
183
|
-
/** What draws the animals: `game-animals-three`'s `createAnimalsThree(THREE)` is one as it is. */
|
|
184
|
-
type AnimalDrawer<TSpecies = unknown> = {
|
|
185
|
-
build(species: TSpecies, options?: {
|
|
186
|
-
readonly phase?: number;
|
|
187
|
-
}): DrawnAnimal;
|
|
188
|
-
animate(rig: DrawnAnimal, params: {
|
|
189
|
-
readonly time: number;
|
|
190
|
-
readonly delta: number;
|
|
191
|
-
readonly clip: string;
|
|
192
|
-
}): void;
|
|
193
|
-
setVisualState?(rig: DrawnAnimal, state: 'alive' | 'infected' | 'dead'): void;
|
|
194
|
-
};
|
|
195
|
-
type HerdViewOptions<TSpecies> = {
|
|
196
|
-
readonly herd: Herd;
|
|
197
|
-
readonly drawer: AnimalDrawer<TSpecies>;
|
|
198
|
-
/** The species card of an animal's species id (`game-animals-species` `getSpecies`). */
|
|
199
|
-
readonly species: (id: string) => TSpecies | undefined;
|
|
200
|
-
/** The vultures: the flock that moves the herd's sky animals, in the order they were added. */
|
|
201
|
-
readonly flock?: Flock;
|
|
202
|
-
};
|
|
203
|
-
type HerdView = {
|
|
204
|
-
readonly group: THREE_NS.Group;
|
|
205
|
-
/** Builds what is new in the herd and moves every drawn animal to its place this frame (G 66697-66708). */
|
|
206
|
-
update(dt: number): void;
|
|
207
|
-
readonly count: number;
|
|
208
|
-
clear(): void;
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* The herd drawn with the animals' own rigs: each animal where `game-crowd`'s herd put it, turned to its heading and animated with its clip (G 66697
|
|
212
|
-
* `E.pele.mesh.position.set(E.x, 0, E.z)`, `animQuad`); the vultures where the flock puts them, gliding with the wings half open (G 66704-66708).
|
|
213
|
-
*/
|
|
214
|
-
declare function createHerdView<TSpecies>(three: {
|
|
215
|
-
readonly Group: new () => THREE_NS.Group;
|
|
216
|
-
}, options: HerdViewOptions<TSpecies>): HerdView;
|
|
15
|
+
declare const appearanceSignature: (typeIndex: number, variant: number, instance: CrowdInstance, size: VariantSize) => number;
|
|
217
16
|
|
|
218
17
|
/** The crowd's sound bank: register it in the host's engine (`host.audio.register`) and the crowd's and the herd's sound ids play. */
|
|
219
18
|
declare const CROWD_SOUND_BANK: SoundBank;
|
|
220
19
|
/** The herd's sound ids (`HERD_ROLES`) to the bank's recipes; the crowd's own ids (`groan`, `runner_groan`, `scream_hoarse`) are the recipes' ids already. */
|
|
221
20
|
declare const HERD_SOUND_IDS: Readonly<Record<string, string>>;
|
|
222
21
|
|
|
223
|
-
|
|
224
|
-
/** The species card the bench reads: the gait rates (`game-animals-species` cards are these). */
|
|
225
|
-
type CrowdBenchSpecies = {
|
|
226
|
-
readonly walkHz: number;
|
|
227
|
-
readonly runHz: number;
|
|
228
|
-
};
|
|
229
|
-
/** What a crowd effect is in the host's effect catalogue (`host.effects`): its id and, optionally, the option it plays with. */
|
|
230
|
-
type CrowdEffectMap = Readonly<Record<string, {
|
|
231
|
-
readonly effect: string;
|
|
232
|
-
readonly param?: number | string;
|
|
233
|
-
} | null>>;
|
|
234
|
-
/** The room's effects for the crowd's (the Oficina de VFX recipes of `game-vfx`): blood on a hit, a severed limb, the bloater's cloud, a spark, dust. */
|
|
235
|
-
declare const CROWD_EFFECTS: CrowdEffectMap;
|
|
236
|
-
type CrowdTestModuleOptions = {
|
|
237
|
-
readonly locale?: string;
|
|
238
|
-
/** The bodies the crowd draws from (types, ages, outfits): the host's content (`game-characters-undead` `undeadCrowdPack()`, or a game's own). */
|
|
239
|
-
readonly pack: CrowdPack;
|
|
240
|
-
/** The rich builders the bodies are baked from, made once three.js is lent. Without it the crowd runs and nothing is drawn. */
|
|
241
|
-
readonly builders?: (three: Three) => BakeBuilders;
|
|
242
|
-
/** The name the rich builder knows a type by (default its id). */
|
|
243
|
-
readonly typeName?: (type: CrowdType, index: number) => string;
|
|
244
|
-
/** The bench's name of a type (default its id). */
|
|
245
|
-
readonly typeLabel?: (type: CrowdType, locale: string) => string;
|
|
246
|
-
/** The bodies of the civilians (baked human specs), one per civilian, in order; without them the civilians run but are not drawn. */
|
|
247
|
-
readonly civilianBodies?: readonly BakeSpec[];
|
|
248
|
-
/** The animals: the species card of an id, its size (`game-animals` `quadrupedLayout(body).size`, `birdSize(body)`) and, optionally, what draws them. */
|
|
249
|
-
readonly animals?: {
|
|
250
|
-
readonly species: (id: string) => CrowdBenchSpecies | undefined;
|
|
251
|
-
readonly size: (species: CrowdBenchSpecies) => number;
|
|
252
|
-
readonly drawer?: (three: Three) => AnimalDrawer<CrowdBenchSpecies>;
|
|
253
|
-
};
|
|
254
|
-
/** A region model to bring agents from (`game-infection` `create(...)`) and the region the area is in. */
|
|
255
|
-
readonly infection?: {
|
|
256
|
-
readonly create: () => InfectionModelLike;
|
|
257
|
-
readonly region: string;
|
|
258
|
-
readonly active?: (model: InfectionModelLike) => number;
|
|
259
|
-
};
|
|
260
|
-
/** The effect ids of the host for the crowd's effects (default `CROWD_EFFECTS`; null leaves one out). */
|
|
261
|
-
readonly effects?: CrowdEffectMap;
|
|
262
|
-
readonly seed?: number;
|
|
263
|
-
/** Agents when the area opens (default 0, so a room that only carries the module stays calm). */
|
|
264
|
-
readonly startCount?: number;
|
|
265
|
-
/** Where the crowd is born around (default 0, -45: in front of the room's start). */
|
|
266
|
-
readonly center?: readonly [number, number];
|
|
267
|
-
};
|
|
268
|
-
/** What the scenarios use of the context the test room passes. */
|
|
269
|
-
interface CrowdScenarioLike {
|
|
270
|
-
expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
|
|
271
|
-
}
|
|
272
|
-
type CrowdTestModule = TestableModule<CrowdScenarioLike> & {
|
|
273
|
-
readonly crowd: Crowd;
|
|
274
|
-
readonly player: Player;
|
|
275
|
-
readonly renderer: CrowdRenderer | null;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* The crowd area of a test room, against the generic contracts only: a horde of any pack drawn on the instanced path (the baked variants of
|
|
279
|
-
* `game-characters-three`), the room's camera as the `game-player` body it hunts, civilians, the herd and the vultures, and a bridge to a region
|
|
280
|
-
* model. Sounds go to `host.audio` (the crowd's bank is registered there), effects to `host.effects`. The pack and the bodies come in by option:
|
|
281
|
-
* this package knows no game.
|
|
282
|
-
*/
|
|
283
|
-
declare function createCrowdTestModule(options: CrowdTestModuleOptions): CrowdTestModule;
|
|
284
|
-
|
|
285
|
-
type Keys<K extends string> = Readonly<Record<K, string>>;
|
|
286
|
-
type CrowdBenchText = {
|
|
287
|
-
readonly group: string;
|
|
288
|
-
readonly name: string;
|
|
289
|
-
readonly mix: string;
|
|
290
|
-
readonly controls: Keys<'count' | 'type' | 'night' | 'seed' | 'spawn' | 'noise' | 'hit' | 'kill_all' | 'join' | 'flee' | 'herd' | 'materialize' | 'push' | 'reset'>;
|
|
291
|
-
readonly hints: Keys<'count' | 'type' | 'night' | 'noise' | 'hit' | 'join' | 'flee' | 'herd' | 'materialize' | 'push'>;
|
|
292
|
-
readonly layers: Keys<'corpses' | 'civilians' | 'animals'>;
|
|
293
|
-
readonly metrics: Keys<'agents' | 'drawn' | 'lod_near' | 'lod_middle' | 'lod_far' | 'draw_calls' | 'bake_ms' | 'active' | 'kills' | 'corpses' | 'civilians' | 'health' | 'grabbed' | 'message'>;
|
|
294
|
-
readonly scenarios: Keys<'relevance' | 'lod' | 'attack_pose' | 'corpse_darkens' | 'civilians_flee' | 'herd_calls' | 'vultures' | 'infection' | 'determinism'>;
|
|
295
|
-
readonly messages: Keys<'called' | 'burst_hit' | 'swing_knock' | 'pounce_knock' | 'migration' | 'door_broken' | 'alarm' | 'bark' | 'growl' | 'bitten' | 'turned' | 'died'>;
|
|
296
|
-
readonly yes: string;
|
|
297
|
-
readonly no: string;
|
|
298
|
-
};
|
|
299
|
-
declare const crowdBenchTextOf: (locale: string) => CrowdBenchText;
|
|
300
|
-
|
|
301
|
-
export { type AnimalDrawer, CROWD_AREA_ID, CROWD_EFFECTS, CROWD_RENDER_DEFAULTS, CROWD_SOUND_BANK, type CrowdBenchSpecies, type CrowdBenchText, type CrowdEffectMap, type CrowdFrame, type CrowdInstance, type CrowdInstanceSink, type CrowdInstances, type CrowdInstancesOptions, type CrowdPoseMap, type CrowdRenderNumbers, type CrowdRenderer, type CrowdRendererOptions, type CrowdScenarioLike, type CrowdTestModule, type CrowdTestModuleOptions, type DrawnAnimal, HERD_SOUND_IDS, type HerdView, type HerdViewOptions, type PlainCorpseSink, type VariantSize, createCrowdInstances, createCrowdRenderer, createCrowdTestModule, createHerdView, crowdBenchTextOf };
|
|
22
|
+
export { CROWD_SOUND_BANK, CrowdInstance, HERD_SOUND_IDS, VariantSize, appearanceSignature };
|