@adatechnology/game-vehicles-three 0.6.4 → 0.8.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-MRUPKE7J.js → chunk-NPS4X64L.js} +864 -60
- package/dist/chunk-NPS4X64L.js.map +1 -0
- package/dist/index.d.ts +267 -14
- package/dist/index.global.js +2057 -401
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -1
- package/dist/{testing-C-BgV7gj.d.ts → testing-Cb10i9fm.d.ts} +23 -9
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-MRUPKE7J.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-
|
|
3
|
-
import { EffectSink, Vec3, AudioSink } from '@adatechnology/game-contracts';
|
|
4
|
-
import { CabinSource } from '@adatechnology/game-vehicles';
|
|
5
|
-
import { LoopRecipe, Falloff, SoundRecipe, SoundBank } from '@adatechnology/game-audio';
|
|
6
|
-
import
|
|
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
|
+
import { EffectSink, Vec3, AudioSink, AnimationClipSpec } from '@adatechnology/game-contracts';
|
|
4
|
+
import { CabinSource, VehicleContext } from '@adatechnology/game-vehicles';
|
|
5
|
+
import { LoopRecipe, Falloff, SampleAlias, SoundRecipe, SoundBank } from '@adatechnology/game-audio';
|
|
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
|
/**
|
|
@@ -33,8 +35,62 @@ declare const VEHICLE_LOOP_FALLOFF: Falloff;
|
|
|
33
35
|
declare const VEHICLE_LOOPS: readonly LoopRecipe[];
|
|
34
36
|
/** The one-shots: the starter, the engine stopping, crashes by speed, and the doors, trunk and hood of a car. */
|
|
35
37
|
declare const VEHICLE_SOUNDS: readonly SoundRecipe[];
|
|
38
|
+
/**
|
|
39
|
+
* The RPM each car recording runs at, measured on the files (the crank turning at 16.7 and 42 Hz, the firing at four times that: a V8). A layer
|
|
40
|
+
* plays its file at `rpm / recorded rpm`.
|
|
41
|
+
*/
|
|
42
|
+
declare const CAR_RECORDED_RPM: {
|
|
43
|
+
readonly idle: 1000;
|
|
44
|
+
readonly high: 2520;
|
|
45
|
+
};
|
|
46
|
+
/** Where the start and the stop sit in the recording of a car starting, running and stopping (`engine_start_run_stop`), in seconds. */
|
|
47
|
+
declare const CAR_START_RUN_STOP: {
|
|
48
|
+
/** The take the times below were measured on. */
|
|
49
|
+
readonly take: "_01.";
|
|
50
|
+
/** The starter and the engine catching (at 0.58 s) and flaring; the loops take over at the crank time of the vehicle. */
|
|
51
|
+
readonly start: {
|
|
52
|
+
readonly offset: 0;
|
|
53
|
+
readonly duration: 1.3;
|
|
54
|
+
};
|
|
55
|
+
/** The ignition off: the engine running down to the end of the file. */
|
|
56
|
+
readonly stop: {
|
|
57
|
+
readonly offset: 9.96;
|
|
58
|
+
readonly duration: 0.64;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The vehicle ids answered by the recordings of the kit's manifest (files kept by the game, never in the SDK): the car engine layers by RPM, the
|
|
63
|
+
* start and the stop cut out of one recording, the door and the trunk. Each recipe above stays as the fallback while the files load or where the
|
|
64
|
+
* game has none. `car_door_open` is a file id of its own and needs no alias; the hood, the truck, the bike, the tyres, crashes and horns have no
|
|
65
|
+
* recording yet.
|
|
66
|
+
*/
|
|
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[];
|
|
36
70
|
declare const VEHICLE_SOUND_BANK: SoundBank;
|
|
37
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
|
+
|
|
38
94
|
/** What one engine loop is set to this frame. `frequency` is absent for the load layer (noise has no pitch). */
|
|
39
95
|
type EngineLayerSetting = {
|
|
40
96
|
readonly sound: string;
|
|
@@ -80,6 +136,12 @@ type VehicleSoundFrame = {
|
|
|
80
136
|
readonly slip?: number;
|
|
81
137
|
/** What the tyres are on: `dirt` for earth, gravel, sand or grass; anything else squeals as asphalt. */
|
|
82
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;
|
|
83
145
|
};
|
|
84
146
|
type VehicleSoundOptions = {
|
|
85
147
|
readonly profile?: EngineProfile;
|
|
@@ -87,6 +149,8 @@ type VehicleSoundOptions = {
|
|
|
87
149
|
readonly sounds?: Partial<VehicleSoundKeys>;
|
|
88
150
|
/** Seconds the starter turns before the engine catches (the `engine_start` recipe catches at 0.75 s). */
|
|
89
151
|
readonly crankSeconds?: number;
|
|
152
|
+
/** Shared by the vehicles of a scene: only the nearest few keep their loops (`createEngineBudget`). */
|
|
153
|
+
readonly budget?: EngineBudget;
|
|
90
154
|
};
|
|
91
155
|
/** What was asked of the sink, for the checks and the bench: the RPM in use and the level of each loop. */
|
|
92
156
|
type VehicleSoundReading = {
|
|
@@ -103,6 +167,8 @@ type VehicleSound = {
|
|
|
103
167
|
stop(position: Vec3): void;
|
|
104
168
|
/** A hit at `speed` m/s: light, medium or heavy by speed, louder with it. */
|
|
105
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;
|
|
106
172
|
update(frame: VehicleSoundFrame): void;
|
|
107
173
|
readonly reading: VehicleSoundReading;
|
|
108
174
|
dispose(): void;
|
|
@@ -118,11 +184,30 @@ declare function createVehicleSound(audio: AudioSink | undefined, options?: Vehi
|
|
|
118
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,
|
|
119
185
|
* 0.25 and 0.45 emissive) and the colours are the team's.
|
|
120
186
|
*/
|
|
187
|
+
|
|
188
|
+
type Three = typeof THREE_NS;
|
|
121
189
|
/** The six classes of a fused vehicle, in the order they are added to the group. */
|
|
122
190
|
declare const LITE_CLASSES: readonly ["paint", "trim", "metal", "glass", "light", "plate"];
|
|
123
191
|
type LiteClass = (typeof LITE_CLASSES)[number];
|
|
124
192
|
/** Smallest extent in metres a piece needs to survive the fusion (the plate is always kept). */
|
|
125
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;
|
|
126
211
|
interface Accumulator {
|
|
127
212
|
P: number[];
|
|
128
213
|
N: number[];
|
|
@@ -132,25 +217,25 @@ interface Accumulator {
|
|
|
132
217
|
nv: number;
|
|
133
218
|
alpha: boolean;
|
|
134
219
|
uv: boolean;
|
|
135
|
-
map:
|
|
220
|
+
map: Texture | null | undefined;
|
|
136
221
|
}
|
|
137
222
|
interface LiteFusion {
|
|
138
223
|
acc: Record<LiteClass, Accumulator>;
|
|
139
224
|
pruned: number;
|
|
140
225
|
}
|
|
141
226
|
/** Which class a material belongs to, or `null` when it is left out. */
|
|
142
|
-
declare function classify(mat:
|
|
227
|
+
declare function classify(mat: LiteSourceMaterial, mesh: Object3D, c: LiteSource): LiteClass | null;
|
|
143
228
|
/** The vertex colour of a piece of a class. `paintColor` replaces the primary paint. */
|
|
144
|
-
declare function classColor(mat:
|
|
229
|
+
declare function classColor(mat: LiteSourceMaterial, cls: LiteClass, primary: Material | null | undefined, paintColor: Color | null | undefined, out: Color): Color;
|
|
145
230
|
/** The material of each class (vertex colours; glass blends; light is unlit; the plate keeps its canvas texture). */
|
|
146
|
-
declare function liteMaterials(THREE:
|
|
231
|
+
declare function liteMaterials(THREE: Three, environment: Texture | null): Record<LiteClass, LiteMaterial>;
|
|
147
232
|
/**
|
|
148
233
|
* Walks the built vehicle and collects every visible mesh, in the frame of `pivot`, into one set of arrays per class.
|
|
149
234
|
* `hidden` is the set of materials nobody sees from outside (`kit.lodHiddenMaterials()`).
|
|
150
235
|
*/
|
|
151
|
-
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;
|
|
152
237
|
/** One mesh per class that has triangles. */
|
|
153
|
-
declare function liteMeshes(THREE:
|
|
238
|
+
declare function liteMeshes(THREE: Three, fusion: LiteFusion, materials: Record<LiteClass, LiteMaterial>): Mesh[];
|
|
154
239
|
|
|
155
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. */
|
|
156
241
|
declare const VEHICLE_LOD_DISTANCE = 14;
|
|
@@ -164,8 +249,14 @@ type VehicleLod = {
|
|
|
164
249
|
readonly fused: boolean;
|
|
165
250
|
dispose(): void;
|
|
166
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
|
+
};
|
|
167
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. */
|
|
168
|
-
declare function createVehicleLod(kit:
|
|
259
|
+
declare function createVehicleLod(kit: VehicleLodKit, context: VehicleContext, root: Object3D, full: Object3D, options?: VehicleLodOptions): VehicleLod;
|
|
169
260
|
|
|
170
261
|
type LampSwitch = {
|
|
171
262
|
mode: 'off' | 'position' | 'low' | 'high';
|
|
@@ -176,6 +267,8 @@ type LampSwitch = {
|
|
|
176
267
|
/** Indicator lamps lit this instant (the controls blink them). */
|
|
177
268
|
left: boolean;
|
|
178
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;
|
|
179
272
|
};
|
|
180
273
|
/** Glow of the lamp glass by switch, as a share of what the kit drew (the kit draws them lit), and the beams. */
|
|
181
274
|
declare const LAMP_RULES: {
|
|
@@ -199,6 +292,11 @@ declare const LAMP_RULES: {
|
|
|
199
292
|
readonly off: 0.1;
|
|
200
293
|
readonly on: 2.2;
|
|
201
294
|
};
|
|
295
|
+
readonly beacon: {
|
|
296
|
+
readonly off: 0.35;
|
|
297
|
+
readonly dark: 0.12;
|
|
298
|
+
readonly lit: 2.8;
|
|
299
|
+
};
|
|
202
300
|
};
|
|
203
301
|
readonly low: {
|
|
204
302
|
readonly color: 16773584;
|
|
@@ -247,6 +345,7 @@ interface VehicleLamps {
|
|
|
247
345
|
tail: boolean;
|
|
248
346
|
fog: boolean;
|
|
249
347
|
indicators: boolean;
|
|
348
|
+
beacon: boolean;
|
|
250
349
|
};
|
|
251
350
|
set(lamps: LampSwitch): void;
|
|
252
351
|
readonly state: LampSwitch;
|
|
@@ -259,6 +358,112 @@ declare function createVehicleLamps(THREE: {
|
|
|
259
358
|
owner?: string;
|
|
260
359
|
}): VehicleLamps;
|
|
261
360
|
|
|
361
|
+
/**
|
|
362
|
+
* The openings of a built vehicle worked by hand: each door, the hood and the trunk lid swing on the hinges the vehicle destructible draws (their open
|
|
363
|
+
* pose is the one of its `open_*` clips, so the door takes its skin, glass and trim with it), each side window slides down into its door, a sunroof
|
|
364
|
+
* slides back when the model has one, the wiper blades sweep, and the central locking keeps the doors and the lid shut. It moves only what the kit
|
|
365
|
+
* drew and puts every part back on `dispose`.
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
type Vec$1 = {
|
|
369
|
+
x: number;
|
|
370
|
+
y: number;
|
|
371
|
+
z: number;
|
|
372
|
+
copy(v: Vec$1): Vec$1;
|
|
373
|
+
clone(): Vec$1;
|
|
374
|
+
sub(v: Vec$1): Vec$1;
|
|
375
|
+
add(v: Vec$1): Vec$1;
|
|
376
|
+
applyQuaternion(q: Quat$1): Vec$1;
|
|
377
|
+
};
|
|
378
|
+
type Quat$1 = {
|
|
379
|
+
copy(q: Quat$1): Quat$1;
|
|
380
|
+
clone(): Quat$1;
|
|
381
|
+
setFromAxisAngle(axis: Vec$1, angle: number): Quat$1;
|
|
382
|
+
multiply(q: Quat$1): Quat$1;
|
|
383
|
+
};
|
|
384
|
+
/** What the body needs of three.js: vectors and quaternions to turn a wiper about its spindle. */
|
|
385
|
+
type BodyThree = {
|
|
386
|
+
Vector3: new (x?: number, y?: number, z?: number) => Vec$1;
|
|
387
|
+
Quaternion: new () => Quat$1;
|
|
388
|
+
};
|
|
389
|
+
/** A side window by where it sits: `front_left`, `rear_right`... */
|
|
390
|
+
type WindowId = `${'front' | 'rear'}_${'left' | 'right'}`;
|
|
391
|
+
type BodyEvent = {
|
|
392
|
+
type: 'sound';
|
|
393
|
+
key: string;
|
|
394
|
+
part: string;
|
|
395
|
+
} | {
|
|
396
|
+
type: 'refused';
|
|
397
|
+
part: string;
|
|
398
|
+
reason: 'locked' | 'missing';
|
|
399
|
+
};
|
|
400
|
+
interface VehicleBodyOptions {
|
|
401
|
+
THREE: BodyThree;
|
|
402
|
+
/** The open and close clips of the vehicle destructible (`animations()`): the open pose of each door, the hood and the lid. */
|
|
403
|
+
clips: readonly AnimationClipSpec[];
|
|
404
|
+
/** Seconds a door, the hood or the lid takes to open. Default 1.2 (the clips'). */
|
|
405
|
+
swingSeconds?: number;
|
|
406
|
+
/** Seconds a window takes from shut to open. Default 3.5. */
|
|
407
|
+
windowSeconds?: number;
|
|
408
|
+
/** Share of the pane's height that goes into the door. Default 0.92 (the top edge stays in the seal). */
|
|
409
|
+
windowTravel?: number;
|
|
410
|
+
}
|
|
411
|
+
interface VehicleBody {
|
|
412
|
+
/** Part ids the body can open: `door_front_left`..., `hood`, `lid`. */
|
|
413
|
+
readonly parts: readonly string[];
|
|
414
|
+
readonly windows: readonly WindowId[];
|
|
415
|
+
readonly hasSunroof: boolean;
|
|
416
|
+
readonly wipers: number;
|
|
417
|
+
readonly locked: boolean;
|
|
418
|
+
/** 0 shut to 1 open. */
|
|
419
|
+
openness(part: string): number;
|
|
420
|
+
/** Opens a shut part or shuts an open one. Locked doors and lid refuse. */
|
|
421
|
+
toggle(part: string): BodyEvent[];
|
|
422
|
+
/** Window opening, 0 shut to 1 down. */
|
|
423
|
+
window(id: WindowId): number;
|
|
424
|
+
toggleWindow(id: WindowId): void;
|
|
425
|
+
setWindow(id: WindowId, open: number): void;
|
|
426
|
+
toggleSunroof(): void;
|
|
427
|
+
/** Locks or unlocks the doors and the lid (the key or the remote). */
|
|
428
|
+
lock(locked: boolean): BodyEvent[];
|
|
429
|
+
/** Advances the moving parts; `wipe` is the wipers' sweeps per second (0 parked). */
|
|
430
|
+
update(dt: number, wipe?: number): BodyEvent[];
|
|
431
|
+
dispose(): void;
|
|
432
|
+
}
|
|
433
|
+
declare function createVehicleBody(built: BuiltVehicle, options: VehicleBodyOptions): VehicleBody;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* The wheels of a built vehicle turning as it moves: each wheel the kit drew (`context.wheels`) rolls about its axle by the distance travelled over
|
|
437
|
+
* its radius, and the front ones turn with the steering. The turn is applied over the wheel's own rest pose, so a mirrored or tilted wheel rolls the
|
|
438
|
+
* right way, and `dispose` puts every wheel back exactly as it was drawn.
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
type Vec = {
|
|
442
|
+
x: number;
|
|
443
|
+
y: number;
|
|
444
|
+
z: number;
|
|
445
|
+
};
|
|
446
|
+
type Quat = {
|
|
447
|
+
copy(q: Quat): Quat;
|
|
448
|
+
clone(): Quat;
|
|
449
|
+
setFromAxisAngle(axis: Vec, angle: number): Quat;
|
|
450
|
+
multiply(q: Quat): Quat;
|
|
451
|
+
premultiply(q: Quat): Quat;
|
|
452
|
+
};
|
|
453
|
+
/** What the wheels need of three.js. */
|
|
454
|
+
type WheelRollThree = {
|
|
455
|
+
Vector3: new (x?: number, y?: number, z?: number) => Vec;
|
|
456
|
+
Quaternion: new () => Quat;
|
|
457
|
+
};
|
|
458
|
+
interface WheelRoll {
|
|
459
|
+
/** Wheels found on the vehicle. */
|
|
460
|
+
readonly count: number;
|
|
461
|
+
/** The vehicle went `distance` metres forward (negative backwards) with the front wheels steered `steer` radians (positive to the left). */
|
|
462
|
+
roll(distance: number, steer: number): void;
|
|
463
|
+
dispose(): void;
|
|
464
|
+
}
|
|
465
|
+
declare function createWheelRoll(THREE: WheelRollThree, built: BuiltVehicle): WheelRoll;
|
|
466
|
+
|
|
262
467
|
/** What the cluster shows this instant. */
|
|
263
468
|
type DashboardReading = {
|
|
264
469
|
kmh: number;
|
|
@@ -279,6 +484,15 @@ type DashboardReading = {
|
|
|
279
484
|
temperature?: number;
|
|
280
485
|
/** Fuel, 0 (empty) to 1 (full); leave out while the vehicle has no fuel model. */
|
|
281
486
|
fuel?: number;
|
|
487
|
+
/** Cruise control holding a speed. */
|
|
488
|
+
cruise?: boolean;
|
|
489
|
+
/** Drive profile shown by its letter (E economy, S sport; nothing for normal). */
|
|
490
|
+
profile?: 'eco' | 'normal' | 'sport';
|
|
491
|
+
/** The aids switched off light their amber lamps. */
|
|
492
|
+
tractionOff?: boolean;
|
|
493
|
+
absOff?: boolean;
|
|
494
|
+
/** The alternator does not keep up (the battery drains with the engine running). */
|
|
495
|
+
charging?: boolean;
|
|
282
496
|
};
|
|
283
497
|
/** The scale of the dials and how often the faces are redrawn. */
|
|
284
498
|
type DashboardOptions = {
|
|
@@ -331,4 +545,43 @@ declare const DASHBOARD_LOOK: {
|
|
|
331
545
|
};
|
|
332
546
|
declare function createVehicleDashboard(THREE: ThreeLib, built: BuiltVehicle, options: DashboardOptions): VehicleDashboard;
|
|
333
547
|
|
|
334
|
-
|
|
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 };
|