@adatechnology/game-vehicles-three 0.7.0 → 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.
- package/dist/{chunk-L63R2JQA.js → chunk-NPS4X64L.js} +335 -44
- package/dist/chunk-NPS4X64L.js.map +1 -0
- package/dist/index.d.ts +122 -12
- package/dist/index.global.js +782 -205
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +9 -1
- package/dist/{testing-DI0_R8dH.d.ts → testing-Cb10i9fm.d.ts} +19 -4
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-L63R2JQA.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { E as EngineProfile, V as VehicleSoundKeys, B as BuiltVehicle } from './testing-
|
|
2
|
-
export { a as BIKE_ENGINE, b as BuildVehicleOptions, C as CAR_ENGINE, c as CRASH_SPEEDS, D as DEFAULT_TEST_VEHICLES, d as DEFAULT_TEST_WRECKS, e as DEFAULT_VEHICLE_SOUND_KEYS, f as DocumentLike, g as ENGINE_PROFILES, h as EffectsLike, i as EngineLayer, j as EngineLoadLayer, F as FleetDims, M as ModuleRoomLike, P as PAGE_ITEM_ALIASES, k as PAGE_SCENARIO_ALIASES, l as PROVING_AREA_ID, m as PROVING_TEXT, n as ProvingModuleOptions, o as ProvingRoomLike, p as ProvingText, T as TRUCK_ENGINE, q as VEHICLES_AREA_ID, r as VEHICLE_SCENARIO_IDS, s as VehicleEffectIds, t as VehicleFleetContent, u as VehicleQuality, v as VehicleSoundIds, w as VehicleWreck, x as VehiclesContext, y as VehiclesRoom, z as VehiclesTestFleet, A as VehiclesTestOptions, G as VehiclesThree, H as VehiclesThreeOptions, I as createProvingModule, J as createVehiclesTestModule, K as createVehiclesThree, L as defaultEffectIds, N as defaultSoundIds, O as loadProvingModule, Q as loadVehiclesTestModule } from './testing-
|
|
1
|
+
import { E as EngineProfile, V as VehicleSoundKeys, B as BuiltVehicle } from './testing-Cb10i9fm.js';
|
|
2
|
+
export { a as BIKE_ENGINE, b as BuildVehicleOptions, C as CAR_ENGINE, c as CRASH_SPEEDS, D as DEFAULT_TEST_VEHICLES, d as DEFAULT_TEST_WRECKS, e as DEFAULT_VEHICLE_SOUND_KEYS, f as DocumentLike, g as ENGINE_PROFILES, h as EffectsLike, i as EngineLayer, j as EngineLoadLayer, F as FleetDims, M as ModuleRoomLike, P as PAGE_ITEM_ALIASES, k as PAGE_SCENARIO_ALIASES, l as PROVING_AREA_ID, m as PROVING_TEXT, n as ProvingModuleOptions, o as ProvingRoomLike, p as ProvingText, T as TRUCK_ENGINE, q as VEHICLES_AREA_ID, r as VEHICLE_SCENARIO_IDS, s as VehicleEffectIds, t as VehicleFleetContent, u as VehicleQuality, v as VehicleSoundIds, w as VehicleWreck, x as VehiclesContext, y as VehiclesRoom, z as VehiclesTestFleet, A as VehiclesTestOptions, G as VehiclesThree, H as VehiclesThreeOptions, I as createProvingModule, J as createVehiclesTestModule, K as createVehiclesThree, L as defaultEffectIds, N as defaultSoundIds, O as loadProvingModule, Q as loadVehiclesTestModule } from './testing-Cb10i9fm.js';
|
|
3
3
|
import { EffectSink, Vec3, AudioSink, AnimationClipSpec } from '@adatechnology/game-contracts';
|
|
4
|
-
import { CabinSource } from '@adatechnology/game-vehicles';
|
|
4
|
+
import { CabinSource, VehicleContext } from '@adatechnology/game-vehicles';
|
|
5
5
|
import { LoopRecipe, Falloff, SampleAlias, SoundRecipe, SoundBank } from '@adatechnology/game-audio';
|
|
6
|
-
import
|
|
6
|
+
import * as THREE_NS from 'three';
|
|
7
|
+
import { Texture, Material, Color, Object3D, Matrix4, MeshStandardMaterial, MeshBasicMaterial, Mesh, CanvasTexture, CircleGeometry, Vector3, BufferGeometry, Side } from 'three';
|
|
8
|
+
import '@adatechnology/game-vehicles-driving';
|
|
7
9
|
import '@adatechnology/game-vehicles-proving';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -43,6 +45,8 @@ declare const CAR_RECORDED_RPM: {
|
|
|
43
45
|
};
|
|
44
46
|
/** Where the start and the stop sit in the recording of a car starting, running and stopping (`engine_start_run_stop`), in seconds. */
|
|
45
47
|
declare const CAR_START_RUN_STOP: {
|
|
48
|
+
/** The take the times below were measured on. */
|
|
49
|
+
readonly take: "_01.";
|
|
46
50
|
/** The starter and the engine catching (at 0.58 s) and flaring; the loops take over at the crank time of the vehicle. */
|
|
47
51
|
readonly start: {
|
|
48
52
|
readonly offset: 0;
|
|
@@ -61,8 +65,32 @@ declare const CAR_START_RUN_STOP: {
|
|
|
61
65
|
* recording yet.
|
|
62
66
|
*/
|
|
63
67
|
declare const VEHICLE_SAMPLE_ALIASES: readonly SampleAlias[];
|
|
68
|
+
/** The ids a host should decode as the vehicles load (`AudioSink.preload`): every aliased recording and the door's own file id. */
|
|
69
|
+
declare const VEHICLE_PRELOAD_SOUNDS: readonly string[];
|
|
64
70
|
declare const VEHICLE_SOUND_BANK: SoundBank;
|
|
65
71
|
|
|
72
|
+
/** How many vehicles are heard at once: the nearest `max` to the listener keep their loops, the others are silent until they come closer. */
|
|
73
|
+
type EngineBudget = {
|
|
74
|
+
/** Reports where a vehicle is this frame; true when it is among the nearest `max` (it may sound). */
|
|
75
|
+
admit(vehicle: object, position: Vec3): boolean;
|
|
76
|
+
/** Forgets a vehicle (it left the scene). */
|
|
77
|
+
release(vehicle: object): void;
|
|
78
|
+
/** Vehicles being tracked. */
|
|
79
|
+
readonly size: number;
|
|
80
|
+
};
|
|
81
|
+
type EngineBudgetOptions = {
|
|
82
|
+
/** Default 6: a street of idling cars is a hum, not a wall of a hundred engines. */
|
|
83
|
+
readonly max?: number;
|
|
84
|
+
/** Where the listener is (the camera or the player). */
|
|
85
|
+
readonly listener: () => Vec3;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* A level of detail for vehicle sound, shared by every `createVehicleSound` of a scene (`VehicleSoundOptions.budget`): each vehicle reports its
|
|
89
|
+
* place every frame and only the nearest `max` keep their engine and tyre loops. A vehicle that falls out fades its loops to silence; its one-shots
|
|
90
|
+
* (a crash, the starter) still play, since they are rare and the engine's voice limiter already ranks them.
|
|
91
|
+
*/
|
|
92
|
+
declare function createEngineBudget(options: EngineBudgetOptions): EngineBudget;
|
|
93
|
+
|
|
66
94
|
/** What one engine loop is set to this frame. `frequency` is absent for the load layer (noise has no pitch). */
|
|
67
95
|
type EngineLayerSetting = {
|
|
68
96
|
readonly sound: string;
|
|
@@ -108,6 +136,12 @@ type VehicleSoundFrame = {
|
|
|
108
136
|
readonly slip?: number;
|
|
109
137
|
/** What the tyres are on: `dirt` for earth, gravel, sand or grass; anything else squeals as asphalt. */
|
|
110
138
|
readonly surface?: 'asphalt' | 'dirt';
|
|
139
|
+
/** 0..1, how hard the brakes are pressed: the pads squeal as the car comes to a stop without skidding. */
|
|
140
|
+
readonly brake?: number;
|
|
141
|
+
/** An emergency vehicle's siren: `wail` sweeps 650–1500 Hz in ~4 s, `yelp` in a quarter second; absent or `off`, silent. */
|
|
142
|
+
readonly siren?: 'off' | 'wail' | 'yelp';
|
|
143
|
+
/** 0..1, how fast a helicopter's rotor turns (the blades spool up and down with it). */
|
|
144
|
+
readonly rotor?: number;
|
|
111
145
|
};
|
|
112
146
|
type VehicleSoundOptions = {
|
|
113
147
|
readonly profile?: EngineProfile;
|
|
@@ -115,6 +149,8 @@ type VehicleSoundOptions = {
|
|
|
115
149
|
readonly sounds?: Partial<VehicleSoundKeys>;
|
|
116
150
|
/** Seconds the starter turns before the engine catches (the `engine_start` recipe catches at 0.75 s). */
|
|
117
151
|
readonly crankSeconds?: number;
|
|
152
|
+
/** Shared by the vehicles of a scene: only the nearest few keep their loops (`createEngineBudget`). */
|
|
153
|
+
readonly budget?: EngineBudget;
|
|
118
154
|
};
|
|
119
155
|
/** What was asked of the sink, for the checks and the bench: the RPM in use and the level of each loop. */
|
|
120
156
|
type VehicleSoundReading = {
|
|
@@ -131,6 +167,8 @@ type VehicleSound = {
|
|
|
131
167
|
stop(position: Vec3): void;
|
|
132
168
|
/** A hit at `speed` m/s: light, medium or heavy by speed, louder with it. */
|
|
133
169
|
crash(speed: number, position: Vec3): 'light' | 'medium' | 'heavy';
|
|
170
|
+
/** A body hit at `speed` m/s (a person, an animal; `sound` names another id, a zombie in a game), louder with the speed. */
|
|
171
|
+
hit(speed: number, position: Vec3, sound?: string): void;
|
|
134
172
|
update(frame: VehicleSoundFrame): void;
|
|
135
173
|
readonly reading: VehicleSoundReading;
|
|
136
174
|
dispose(): void;
|
|
@@ -146,11 +184,30 @@ declare function createVehicleSound(audio: AudioSink | undefined, options?: Vehi
|
|
|
146
184
|
* with the meshes nobody sees from outside left out. A literal port: the classes, the thresholds (3 cm prune, 0.99 opacity, 0.5 metalness,
|
|
147
185
|
* 0.25 and 0.45 emissive) and the colours are the team's.
|
|
148
186
|
*/
|
|
187
|
+
|
|
188
|
+
type Three = typeof THREE_NS;
|
|
149
189
|
/** The six classes of a fused vehicle, in the order they are added to the group. */
|
|
150
190
|
declare const LITE_CLASSES: readonly ["paint", "trim", "metal", "glass", "light", "plate"];
|
|
151
191
|
type LiteClass = (typeof LITE_CLASSES)[number];
|
|
152
192
|
/** Smallest extent in metres a piece needs to survive the fusion (the plate is always kept). */
|
|
153
193
|
declare const PRUNE_BELOW = 0.03;
|
|
194
|
+
/** A material of the built vehicle as the fusion reads it (standard, basic or line materials alike). */
|
|
195
|
+
type LiteSourceMaterial = Material & {
|
|
196
|
+
map?: Texture | null;
|
|
197
|
+
color: Color;
|
|
198
|
+
metalness?: number;
|
|
199
|
+
roughness?: number;
|
|
200
|
+
emissive?: Color;
|
|
201
|
+
emissiveIntensity?: number;
|
|
202
|
+
isMeshBasicMaterial?: boolean;
|
|
203
|
+
};
|
|
204
|
+
/** What the fusion reads of the built vehicle: its root and the paints (`c.paints`). */
|
|
205
|
+
interface LiteSource {
|
|
206
|
+
vehicle: Object3D;
|
|
207
|
+
paints?: ReadonlySet<Material> | null;
|
|
208
|
+
}
|
|
209
|
+
/** A material of the fused vehicle (`liteMaterials`). */
|
|
210
|
+
type LiteMaterial = MeshStandardMaterial | MeshBasicMaterial;
|
|
154
211
|
interface Accumulator {
|
|
155
212
|
P: number[];
|
|
156
213
|
N: number[];
|
|
@@ -160,25 +217,25 @@ interface Accumulator {
|
|
|
160
217
|
nv: number;
|
|
161
218
|
alpha: boolean;
|
|
162
219
|
uv: boolean;
|
|
163
|
-
map:
|
|
220
|
+
map: Texture | null | undefined;
|
|
164
221
|
}
|
|
165
222
|
interface LiteFusion {
|
|
166
223
|
acc: Record<LiteClass, Accumulator>;
|
|
167
224
|
pruned: number;
|
|
168
225
|
}
|
|
169
226
|
/** Which class a material belongs to, or `null` when it is left out. */
|
|
170
|
-
declare function classify(mat:
|
|
227
|
+
declare function classify(mat: LiteSourceMaterial, mesh: Object3D, c: LiteSource): LiteClass | null;
|
|
171
228
|
/** The vertex colour of a piece of a class. `paintColor` replaces the primary paint. */
|
|
172
|
-
declare function classColor(mat:
|
|
229
|
+
declare function classColor(mat: LiteSourceMaterial, cls: LiteClass, primary: Material | null | undefined, paintColor: Color | null | undefined, out: Color): Color;
|
|
173
230
|
/** The material of each class (vertex colours; glass blends; light is unlit; the plate keeps its canvas texture). */
|
|
174
|
-
declare function liteMaterials(THREE:
|
|
231
|
+
declare function liteMaterials(THREE: Three, environment: Texture | null): Record<LiteClass, LiteMaterial>;
|
|
175
232
|
/**
|
|
176
233
|
* Walks the built vehicle and collects every visible mesh, in the frame of `pivot`, into one set of arrays per class.
|
|
177
234
|
* `hidden` is the set of materials nobody sees from outside (`kit.lodHiddenMaterials()`).
|
|
178
235
|
*/
|
|
179
|
-
declare function fuse(THREE:
|
|
236
|
+
declare function fuse(THREE: Three, c: LiteSource, pivot: Matrix4, paintColor: Color | null, primary: Material | null | undefined, hidden: ReadonlySet<Material>): LiteFusion;
|
|
180
237
|
/** One mesh per class that has triangles. */
|
|
181
|
-
declare function liteMeshes(THREE:
|
|
238
|
+
declare function liteMeshes(THREE: Three, fusion: LiteFusion, materials: Record<LiteClass, LiteMaterial>): Mesh[];
|
|
182
239
|
|
|
183
240
|
/** Past this distance (m) an untouched vehicle draws fused: nobody sees a door seam from here, and the full model costs hundreds of draw calls. */
|
|
184
241
|
declare const VEHICLE_LOD_DISTANCE = 14;
|
|
@@ -192,8 +249,14 @@ type VehicleLod = {
|
|
|
192
249
|
readonly fused: boolean;
|
|
193
250
|
dispose(): void;
|
|
194
251
|
};
|
|
252
|
+
/** What the level of detail reads of the vehicle kit: its three.js, the materials nobody sees from outside and the studio environment. */
|
|
253
|
+
type VehicleLodKit = {
|
|
254
|
+
readonly THREE: typeof THREE_NS;
|
|
255
|
+
lodHiddenMaterials(): ReadonlySet<Material>;
|
|
256
|
+
studioEnvironment(): Texture | null;
|
|
257
|
+
};
|
|
195
258
|
/** Shows `full` near and the kit's fused light mode (one mesh per class of material) far, in `root`'s own space. Hit tests read the full model, visible or not. */
|
|
196
|
-
declare function createVehicleLod(kit:
|
|
259
|
+
declare function createVehicleLod(kit: VehicleLodKit, context: VehicleContext, root: Object3D, full: Object3D, options?: VehicleLodOptions): VehicleLod;
|
|
197
260
|
|
|
198
261
|
type LampSwitch = {
|
|
199
262
|
mode: 'off' | 'position' | 'low' | 'high';
|
|
@@ -204,6 +267,8 @@ type LampSwitch = {
|
|
|
204
267
|
/** Indicator lamps lit this instant (the controls blink them). */
|
|
205
268
|
left: boolean;
|
|
206
269
|
right: boolean;
|
|
270
|
+
/** The beacon: the side lit this instant (0 or 1), null with it off. Default off. */
|
|
271
|
+
beacon?: 0 | 1 | null;
|
|
207
272
|
};
|
|
208
273
|
/** Glow of the lamp glass by switch, as a share of what the kit drew (the kit draws them lit), and the beams. */
|
|
209
274
|
declare const LAMP_RULES: {
|
|
@@ -227,6 +292,11 @@ declare const LAMP_RULES: {
|
|
|
227
292
|
readonly off: 0.1;
|
|
228
293
|
readonly on: 2.2;
|
|
229
294
|
};
|
|
295
|
+
readonly beacon: {
|
|
296
|
+
readonly off: 0.35;
|
|
297
|
+
readonly dark: 0.12;
|
|
298
|
+
readonly lit: 2.8;
|
|
299
|
+
};
|
|
230
300
|
};
|
|
231
301
|
readonly low: {
|
|
232
302
|
readonly color: 16773584;
|
|
@@ -275,6 +345,7 @@ interface VehicleLamps {
|
|
|
275
345
|
tail: boolean;
|
|
276
346
|
fog: boolean;
|
|
277
347
|
indicators: boolean;
|
|
348
|
+
beacon: boolean;
|
|
278
349
|
};
|
|
279
350
|
set(lamps: LampSwitch): void;
|
|
280
351
|
readonly state: LampSwitch;
|
|
@@ -474,4 +545,43 @@ declare const DASHBOARD_LOOK: {
|
|
|
474
545
|
};
|
|
475
546
|
declare function createVehicleDashboard(THREE: ThreeLib, built: BuiltVehicle, options: DashboardOptions): VehicleDashboard;
|
|
476
547
|
|
|
477
|
-
|
|
548
|
+
/**
|
|
549
|
+
* The mist on the inside of a built vehicle's glass, drawn from the fog share of `createWindshieldFog` (`game-vehicles-driving`). Each pane the kit drew
|
|
550
|
+
* (`context.glass`) gets a thin pale film that follows it (a side window going down, a door swinging), on the pane's own geometry; the windshield shows
|
|
551
|
+
* the whole share and the other panes a little less, since the demister blows on the windshield first. The film is never hit by a shot (it has no
|
|
552
|
+
* raycast) and never writes depth. `dispose` takes the films away and frees their materials; the geometry is the pane's and stays.
|
|
553
|
+
*/
|
|
554
|
+
|
|
555
|
+
/** What the mist needs of three.js. */
|
|
556
|
+
type MistThree = {
|
|
557
|
+
Mesh: new (geometry: BufferGeometry, material: Material) => Mesh;
|
|
558
|
+
MeshBasicMaterial: new (parameters: {
|
|
559
|
+
color: number;
|
|
560
|
+
transparent: boolean;
|
|
561
|
+
opacity: number;
|
|
562
|
+
depthWrite: boolean;
|
|
563
|
+
side: Side;
|
|
564
|
+
polygonOffset: boolean;
|
|
565
|
+
polygonOffsetFactor: number;
|
|
566
|
+
polygonOffsetUnits: number;
|
|
567
|
+
}) => Material & {
|
|
568
|
+
opacity: number;
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
/** How the mist looks: its colour, how opaque full fog is, and the share of it on the side and rear panes. */
|
|
572
|
+
declare const MIST_RULES: {
|
|
573
|
+
readonly color: 15001836;
|
|
574
|
+
readonly opacity: 0.72;
|
|
575
|
+
readonly others: 0.8;
|
|
576
|
+
};
|
|
577
|
+
interface WindshieldMist {
|
|
578
|
+
/** Panes with a film. */
|
|
579
|
+
readonly panes: number;
|
|
580
|
+
/** Shows `fog` (0 clear to 1 misted over). */
|
|
581
|
+
set(fog: number): void;
|
|
582
|
+
readonly fog: number;
|
|
583
|
+
dispose(): void;
|
|
584
|
+
}
|
|
585
|
+
declare function createWindshieldMist(THREE: MistThree, built: BuiltVehicle): WindshieldMist;
|
|
586
|
+
|
|
587
|
+
export { type BodyEvent, type BodyThree, BuiltVehicle, CAR_RECORDED_RPM, CAR_START_RUN_STOP, type CabinSmoke, DASHBOARD_LOOK, type DashboardOptions, type DashboardReading, type EngineBudget, type EngineBudgetOptions, type EngineLayerSetting, type EngineMixInput, EngineProfile, LAMP_RULES, LITE_CLASSES, type LampSwitch, type LiteClass, type LiteFusion, MIST_RULES, type MistThree, PRUNE_BELOW, VEHICLE_LOD_DISTANCE, VEHICLE_LOOPS, VEHICLE_LOOP_FALLOFF, VEHICLE_PRELOAD_SOUNDS, VEHICLE_SAMPLE_ALIASES, VEHICLE_SOUNDS, VEHICLE_SOUND_BANK, type VehicleBody, type VehicleBodyOptions, type VehicleDashboard, type VehicleLamps, type VehicleLod, type VehicleLodKit, type VehicleSound, type VehicleSoundFrame, VehicleSoundKeys, type VehicleSoundOptions, type VehicleSoundReading, type WheelRoll, type WheelRollThree, type WindowId, type WindshieldMist, classColor, classify, createCabinSmoke, createEngineBudget, createGearGuess, createVehicleBody, createVehicleDashboard, createVehicleLamps, createVehicleLod, createVehicleSound, createWheelRoll, createWindshieldMist, engineMix, firingHz, fuse, layerWeight, liteMaterials, liteMeshes, rpmShare };
|