@bendyline/molen-client 0.0.11 → 0.0.13

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,468 @@
1
+ import { t as createModelSignalVisual } from "./model-signals-DLgvjBeZ.mjs";
2
+ import * as THREE from "three";
3
+ //#region src/aircraft-damage.ts
4
+ function createAircraftDamageVisual(model, spec) {
5
+ model.updateWorldMatrix(true, true);
6
+ const modelInverse = new THREE.Matrix4().copy(model.matrixWorld).invert();
7
+ const sections = (spec.collisionParts ?? []).map((part) => {
8
+ const nodes = [];
9
+ model.traverse((node) => {
10
+ if (part.nodes.includes(node.userData.name ?? node.name)) nodes.push(node);
11
+ });
12
+ return {
13
+ part,
14
+ nodes: nodes.filter((node) => {
15
+ for (let parent = node.parent; parent && parent !== model; parent = parent.parent) if (nodes.includes(parent)) return false;
16
+ return true;
17
+ })
18
+ };
19
+ });
20
+ const shared = [];
21
+ const fragments = [];
22
+ model.traverse((node) => {
23
+ if (node instanceof THREE.Mesh && sections.some(({ part }) => part.fragments?.nodes.includes(node.userData.name ?? node.name))) shared.push(node);
24
+ });
25
+ const vertex = new THREE.Vector3(), centroid = new THREE.Vector3();
26
+ for (const mesh of shared) {
27
+ const matching = sections.filter(({ part }) => part.fragments?.nodes.includes(mesh.userData.name ?? mesh.name));
28
+ const matrix = new THREE.Matrix4().multiplyMatrices(modelInverse, mesh.matrixWorld);
29
+ const source = mesh.geometry, positions = source.getAttribute("position");
30
+ const count = source.index?.count ?? positions.count;
31
+ const buckets = /* @__PURE__ */ new Map();
32
+ for (let i = 0; i < count; i += 3) {
33
+ centroid.set(0, 0, 0);
34
+ const indices = [
35
+ 0,
36
+ 1,
37
+ 2
38
+ ].map((j) => source.index?.getX(i + j) ?? i + j);
39
+ for (const index of indices) centroid.add(vertex.fromBufferAttribute(positions, index));
40
+ centroid.multiplyScalar(1 / 3).applyMatrix4(matrix);
41
+ const key = matching.find(({ part }) => {
42
+ const bounds = part.fragments;
43
+ return bounds && centroid.x >= bounds.min[0] && centroid.x <= bounds.max[0] && centroid.y >= bounds.min[1] && centroid.y <= bounds.max[1] && centroid.z >= bounds.min[2] && centroid.z <= bounds.max[2];
44
+ })?.part.id ?? "";
45
+ let bucket = buckets.get(key);
46
+ if (!bucket) {
47
+ bucket = {
48
+ indices: [],
49
+ groups: []
50
+ };
51
+ buckets.set(key, bucket);
52
+ }
53
+ const materialIndex = source.groups.find((group) => i >= group.start && i < group.start + group.count)?.materialIndex ?? 0;
54
+ const last = bucket.groups.at(-1);
55
+ if (last?.materialIndex === materialIndex) last.count += 3;
56
+ else bucket.groups.push({
57
+ start: bucket.indices.length,
58
+ count: 3,
59
+ materialIndex
60
+ });
61
+ bucket.indices.push(...indices);
62
+ }
63
+ for (const [key, bucket] of buckets) {
64
+ const fragment = mesh.clone(false);
65
+ fragment.name = `section:${key || "body"}:${mesh.name}`;
66
+ fragment.geometry = source.clone();
67
+ fragment.geometry.setIndex(bucket.indices);
68
+ fragment.geometry.clearGroups();
69
+ for (const group of bucket.groups) fragment.geometry.addGroup(group.start, group.count, group.materialIndex);
70
+ mesh.parent?.add(fragment);
71
+ fragments.push({
72
+ source: mesh,
73
+ fragment
74
+ });
75
+ sections.find(({ part }) => part.id === key)?.nodes.push(fragment);
76
+ }
77
+ mesh.visible = false;
78
+ }
79
+ const hidden = /* @__PURE__ */ new Map();
80
+ const pieces = /* @__PURE__ */ new Map();
81
+ const inverse = new THREE.Matrix4();
82
+ const pose = new THREE.Matrix4();
83
+ const position = new THREE.Vector3();
84
+ const rotation = new THREE.Quaternion();
85
+ const unit = new THREE.Vector3(1, 1, 1);
86
+ const reset = () => {
87
+ for (const [node, visible] of hidden) node.visible = visible;
88
+ hidden.clear();
89
+ for (const { source, fragment } of fragments) fragment.material = source.material;
90
+ for (const piece of pieces.values()) piece.removeFromParent();
91
+ pieces.clear();
92
+ };
93
+ return {
94
+ reset,
95
+ update(state) {
96
+ if (!state.damage && hidden.size === 0 && pieces.size === 0) return;
97
+ for (const [node, visible] of hidden) if (!sections.some(({ part, nodes }) => state.damage?.[part.id]?.detached && nodes.includes(node))) {
98
+ node.visible = visible;
99
+ hidden.delete(node);
100
+ }
101
+ model.updateWorldMatrix(true, true);
102
+ model.updateMatrix();
103
+ inverse.copy(model.matrix).invert();
104
+ for (const { part, nodes } of sections) {
105
+ const detached = state.damage?.[part.id]?.detached;
106
+ const debris = detached ? state.debris?.find((piece) => piece.part === part.id) : void 0;
107
+ let group = pieces.get(part.id);
108
+ if (!debris && group) {
109
+ group.removeFromParent();
110
+ pieces.delete(part.id);
111
+ group = void 0;
112
+ }
113
+ if (debris && !group) {
114
+ group = new THREE.Group();
115
+ group.name = `debris:${part.id}`;
116
+ const local = new THREE.Matrix4().copy(model.matrixWorld).invert();
117
+ const offset = new THREE.Matrix4().makeTranslation(-part.center[0], -part.center[1], -part.center[2]);
118
+ for (const node of nodes) {
119
+ const clone = node.clone(true);
120
+ const others = new Set(sections.filter((section) => section.part.id !== part.id).flatMap((section) => section.part.nodes));
121
+ const remove = [];
122
+ clone.traverse((child) => {
123
+ if (child !== clone && others.has(child.userData.name ?? child.name)) remove.push(child);
124
+ });
125
+ for (const child of remove) child.removeFromParent();
126
+ clone.matrixAutoUpdate = false;
127
+ clone.matrix.copy(offset).multiply(local).multiply(node.matrixWorld);
128
+ clone.visible = hidden.get(node) ?? node.visible;
129
+ group.add(clone);
130
+ }
131
+ model.add(group);
132
+ pieces.set(part.id, group);
133
+ }
134
+ if (debris && group) {
135
+ group.matrixAutoUpdate = false;
136
+ pose.compose(position.fromArray(debris.pos), rotation.fromArray(debris.rot), unit);
137
+ group.matrix.copy(inverse).multiply(pose);
138
+ group.matrixWorldNeedsUpdate = true;
139
+ }
140
+ for (const node of nodes) if (detached) {
141
+ if (!hidden.has(node)) hidden.set(node, node.visible);
142
+ node.visible = false;
143
+ }
144
+ }
145
+ }
146
+ };
147
+ }
148
+ //#endregion
149
+ //#region src/aircraft-disc.ts
150
+ /** Finite cylinder against a triangle: clip to the axial slab, then test the full disc.
151
+ * No angular samples, bounding-sphere hits or holes between blade-tip probes.
152
+ */
153
+ function discTriangleContact(probe, triangle) {
154
+ const disc = probe.disc;
155
+ if (!disc) return void 0;
156
+ const center = new THREE.Vector3().fromArray(probe.center);
157
+ const axis = new THREE.Vector3().fromArray(disc.normal);
158
+ let polygon = [
159
+ triangle.a,
160
+ triangle.b,
161
+ triangle.c
162
+ ].map((p) => p.clone().sub(center));
163
+ for (const sign of [-1, 1]) {
164
+ const clipped = [];
165
+ for (let i = 0; i < polygon.length; i++) {
166
+ const a = polygon[i], b = polygon[(i + 1) % polygon.length];
167
+ if (!a || !b) continue;
168
+ const da = sign * a.dot(axis) - disc.halfThickness;
169
+ const db = sign * b.dot(axis) - disc.halfThickness;
170
+ if (da <= 0) clipped.push(a);
171
+ if (da < 0 && db > 0 || da > 0 && db < 0) clipped.push(a.clone().lerp(b, da / (da - db)));
172
+ }
173
+ polygon = clipped;
174
+ if (polygon.length === 0) return void 0;
175
+ }
176
+ const projected = polygon.map((p) => p.clone().addScaledVector(axis, -p.dot(axis)));
177
+ const zero = new THREE.Vector3();
178
+ let distanceSq = Infinity;
179
+ let nearest = new THREE.Vector3();
180
+ for (let i = 0; i < polygon.length; i++) {
181
+ const a = projected[i], b = projected[(i + 1) % polygon.length];
182
+ const pa = polygon[i], pb = polygon[(i + 1) % polygon.length];
183
+ if (!a || !b || !pa || !pb) continue;
184
+ const edge = b.clone().sub(a);
185
+ const t = THREE.MathUtils.clamp(-a.dot(edge) / (edge.lengthSq() || 1), 0, 1);
186
+ const d = a.clone().addScaledVector(edge, t).lengthSq();
187
+ if (d < distanceSq) {
188
+ distanceSq = d;
189
+ nearest = pa.clone().lerp(pb, t);
190
+ }
191
+ }
192
+ for (let i = 1; i + 1 < polygon.length; i++) {
193
+ const a = projected[0], b = projected[i], c = projected[i + 1];
194
+ const pa = polygon[0], pb = polygon[i], pc = polygon[i + 1];
195
+ if (!a || !b || !c || !pa || !pb || !pc) continue;
196
+ const face = new THREE.Triangle(a, b, c);
197
+ if (face.getArea() < 1e-12 || !face.containsPoint(zero)) continue;
198
+ const weights = face.getBarycoord(zero, new THREE.Vector3());
199
+ if (!weights) continue;
200
+ distanceSq = 0;
201
+ nearest = pa.clone().multiplyScalar(weights.x).addScaledVector(pb, weights.y).addScaledVector(pc, weights.z);
202
+ break;
203
+ }
204
+ if (distanceSq > probe.radius ** 2) return void 0;
205
+ const normal = triangle.getNormal(new THREE.Vector3());
206
+ if (normal.lengthSq() < .5) return void 0;
207
+ let signed = normal.dot(center.clone().sub(triangle.a));
208
+ if (signed < 0) {
209
+ normal.negate();
210
+ signed = -signed;
211
+ }
212
+ const axial = Math.abs(normal.dot(axis));
213
+ const support = disc.halfThickness * axial + probe.radius * Math.sqrt(Math.max(0, 1 - axial ** 2));
214
+ return {
215
+ point: nearest.add(center),
216
+ normal,
217
+ depth: Math.max(0, support - signed)
218
+ };
219
+ }
220
+ /** Sphere against the actual finite cylinder, including its rim and flat end caps. */
221
+ function discSphereContact(probe, center, radius) {
222
+ const disc = probe.disc;
223
+ if (!disc) return void 0;
224
+ const hub = new THREE.Vector3().fromArray(probe.center);
225
+ const axis = new THREE.Vector3().fromArray(disc.normal);
226
+ const offset = center.clone().sub(hub);
227
+ const height = offset.dot(axis);
228
+ const radial = offset.clone().addScaledVector(axis, -height);
229
+ const length = radial.length();
230
+ const point = hub.clone().addScaledVector(axis, THREE.MathUtils.clamp(height, -disc.halfThickness, disc.halfThickness)).addScaledVector(radial, Math.min(1, probe.radius / (length || 1)));
231
+ const normal = point.clone().sub(center);
232
+ const distance = normal.length();
233
+ if (distance > radius) return void 0;
234
+ if (distance > 1e-8) normal.multiplyScalar(1 / distance);
235
+ else normal.copy(axis).multiplyScalar(height >= 0 ? -1 : 1);
236
+ return {
237
+ point,
238
+ normal,
239
+ depth: radius - distance
240
+ };
241
+ }
242
+ //#endregion
243
+ //#region src/aircraft-collision.ts
244
+ /** Contact normals from streamed geometry and nearby parked vehicles, in absolute coordinates. */
245
+ function aircraftObstacleContacts(probes, scene) {
246
+ const contacts = [];
247
+ if (probes.length === 0) return contacts;
248
+ let minX = Infinity, minZ = Infinity, maxX = -Infinity, maxZ = -Infinity;
249
+ for (const probe of probes) {
250
+ const radius = probe.disc ? Math.hypot(probe.radius, probe.disc.halfThickness) : probe.radius;
251
+ minX = Math.min(minX, probe.center[0] - radius);
252
+ maxX = Math.max(maxX, probe.center[0] + radius);
253
+ minZ = Math.min(minZ, probe.center[2] - radius);
254
+ maxZ = Math.max(maxZ, probe.center[2] + radius);
255
+ }
256
+ const near = (point, reach) => (point[0] ?? 0) >= minX - reach && (point[0] ?? 0) <= maxX + reach && (point[2] ?? 0) >= minZ - reach && (point[2] ?? 0) <= maxZ + reach;
257
+ const cars = scene.cars.filter(({ transform, spec }) => near(transform.pos, Math.max(spec.width, spec.length)));
258
+ const aircraft = scene.aircraft.filter((point) => near(point, 1.2));
259
+ for (const probe of probes) {
260
+ const point = probe.center;
261
+ const hit = (normal, depth, at) => {
262
+ contacts.push({
263
+ part: probe.part,
264
+ point: (at ?? new THREE.Vector3().fromArray(point).addScaledVector(normal, -probe.radius)).toArray(),
265
+ normal: normal.toArray(),
266
+ depth
267
+ });
268
+ };
269
+ const sphere = new THREE.Sphere(new THREE.Vector3().fromArray(point).sub(scene.origin), probe.disc ? Math.hypot(probe.radius, probe.disc.halfThickness) : probe.radius);
270
+ if (scene.octree.getSphereTriangles) {
271
+ const triangles = [];
272
+ scene.octree.getSphereTriangles(sphere, triangles);
273
+ if (probe.disc) {
274
+ const localProbe = {
275
+ ...probe,
276
+ center: sphere.center.toArray()
277
+ };
278
+ const contact = triangles.flatMap((triangle) => {
279
+ const contact = discTriangleContact(localProbe, triangle);
280
+ return contact ? [contact] : [];
281
+ }).sort((a, b) => b.depth - a.depth || a.normal.x - b.normal.x || a.normal.y - b.normal.y || a.normal.z - b.normal.z || a.point.x - b.point.x || a.point.y - b.point.y || a.point.z - b.point.z)[0];
282
+ if (contact) hit(contact.normal, contact.depth, contact.point.add(scene.origin));
283
+ } else {
284
+ const faceNormal = new THREE.Vector3(), nearest = new THREE.Vector3();
285
+ const faces = [];
286
+ for (const triangle of triangles) {
287
+ triangle.getNormal(faceNormal);
288
+ if (faceNormal.dot(sphere.center.clone().sub(triangle.a)) < -1e-7) continue;
289
+ triangle.closestPointToPoint(sphere.center, nearest);
290
+ const offset = sphere.center.clone().sub(nearest);
291
+ const distance = offset.length();
292
+ if (distance >= probe.radius) continue;
293
+ const normal = distance > 1e-7 ? offset.multiplyScalar(1 / distance) : faceNormal.clone();
294
+ const depth = probe.radius - distance;
295
+ const same = faces.find((face) => face.normal.dot(normal) > .9999);
296
+ if (same) same.depth = Math.max(same.depth, depth);
297
+ else faces.push({
298
+ normal,
299
+ depth
300
+ });
301
+ }
302
+ faces.sort((a, b) => b.depth - a.depth || a.normal.x - b.normal.x || a.normal.y - b.normal.y || a.normal.z - b.normal.z);
303
+ const nearestFace = faces[0];
304
+ if (nearestFace) hit(nearestFace.normal, nearestFace.depth);
305
+ }
306
+ } else {
307
+ const obstacle = scene.octree.sphereIntersect(sphere);
308
+ if (obstacle) if (probe.disc) {
309
+ const axial = Math.abs(obstacle.normal.dot(new THREE.Vector3().fromArray(probe.disc.normal)));
310
+ const support = axial * probe.disc.halfThickness + Math.sqrt(Math.max(0, 1 - axial ** 2)) * probe.radius;
311
+ const depth = obstacle.depth - sphere.radius + support;
312
+ if (depth >= 0) hit(obstacle.normal, depth, new THREE.Vector3().fromArray(point).addScaledVector(obstacle.normal, -(sphere.radius - obstacle.depth)));
313
+ } else hit(obstacle.normal, obstacle.depth);
314
+ }
315
+ for (const { transform, spec } of cars) {
316
+ if (Math.hypot(transform.pos[0] - point[0], transform.pos[2] - point[2]) > Math.max(spec.width, spec.length) + sphere.radius) continue;
317
+ const orientation = new THREE.Quaternion().fromArray(transform.rot);
318
+ const local = new THREE.Vector3().fromArray(point).sub(new THREE.Vector3().fromArray(transform.pos)).applyQuaternion(orientation.clone().invert());
319
+ const bounds = new THREE.Box3(new THREE.Vector3(-spec.width / 2, 0, -spec.length / 2), new THREE.Vector3(spec.width / 2, spec.height, spec.length / 2));
320
+ if (probe.disc) {
321
+ const localProbe = {
322
+ ...probe,
323
+ center: local.toArray(),
324
+ disc: {
325
+ ...probe.disc,
326
+ normal: new THREE.Vector3().fromArray(probe.disc.normal).applyQuaternion(orientation.clone().invert()).toArray()
327
+ }
328
+ };
329
+ const vertices = Array.from({ length: 8 }, (_, i) => new THREE.Vector3(i & 1 ? bounds.max.x : bounds.min.x, i & 2 ? bounds.max.y : bounds.min.y, i & 4 ? bounds.max.z : bounds.min.z));
330
+ let contact;
331
+ for (const [a, b, c] of [
332
+ [
333
+ 0,
334
+ 2,
335
+ 3
336
+ ],
337
+ [
338
+ 0,
339
+ 3,
340
+ 1
341
+ ],
342
+ [
343
+ 4,
344
+ 5,
345
+ 7
346
+ ],
347
+ [
348
+ 4,
349
+ 7,
350
+ 6
351
+ ],
352
+ [
353
+ 0,
354
+ 4,
355
+ 6
356
+ ],
357
+ [
358
+ 0,
359
+ 6,
360
+ 2
361
+ ],
362
+ [
363
+ 1,
364
+ 3,
365
+ 7
366
+ ],
367
+ [
368
+ 1,
369
+ 7,
370
+ 5
371
+ ],
372
+ [
373
+ 0,
374
+ 1,
375
+ 5
376
+ ],
377
+ [
378
+ 0,
379
+ 5,
380
+ 4
381
+ ],
382
+ [
383
+ 2,
384
+ 6,
385
+ 7
386
+ ],
387
+ [
388
+ 2,
389
+ 7,
390
+ 3
391
+ ]
392
+ ]) {
393
+ const va = vertices[a ?? 0], vb = vertices[b ?? 0], vc = vertices[c ?? 0];
394
+ if (!va || !vb || !vc) continue;
395
+ const candidate = discTriangleContact(localProbe, new THREE.Triangle(va, vb, vc));
396
+ if (candidate && (!contact || candidate.depth > contact.depth)) contact = candidate;
397
+ }
398
+ if (contact) hit(contact.normal.applyQuaternion(orientation), contact.depth, contact.point.applyQuaternion(orientation).add(new THREE.Vector3().fromArray(transform.pos)));
399
+ else if (bounds.containsPoint(local)) hit(new THREE.Vector3(0, 1, 0).applyQuaternion(orientation), bounds.max.y - local.y + probe.disc.halfThickness, new THREE.Vector3().fromArray(point));
400
+ continue;
401
+ }
402
+ const normal = local.clone().sub(bounds.clampPoint(local, new THREE.Vector3()));
403
+ const distance = normal.length();
404
+ if (distance >= probe.radius) continue;
405
+ let depth = probe.radius - distance;
406
+ if (distance > 1e-4) normal.multiplyScalar(1 / distance);
407
+ else {
408
+ const face = [
409
+ "x",
410
+ "y",
411
+ "z"
412
+ ].flatMap((axis) => [{
413
+ axis,
414
+ sign: -1,
415
+ distance: local[axis] - bounds.min[axis]
416
+ }, {
417
+ axis,
418
+ sign: 1,
419
+ distance: bounds.max[axis] - local[axis]
420
+ }]).sort((a, b) => a.distance - b.distance)[0];
421
+ if (!face) continue;
422
+ normal.set(0, 0, 0);
423
+ normal[face.axis] = face.sign;
424
+ depth += face.distance;
425
+ }
426
+ hit(normal.applyQuaternion(orientation), depth);
427
+ }
428
+ for (const other of aircraft) {
429
+ if (probe.disc) {
430
+ const contact = discSphereContact(probe, new THREE.Vector3().fromArray(other), 1.2);
431
+ if (contact) hit(contact.normal, contact.depth, contact.point);
432
+ continue;
433
+ }
434
+ const normal = new THREE.Vector3().fromArray(point).sub(new THREE.Vector3().fromArray(other));
435
+ const distance = normal.length();
436
+ if (distance < 1.2 + probe.radius) hit(distance > 1e-4 ? normal.multiplyScalar(1 / distance) : new THREE.Vector3(0, 1, 0), 1.2 + probe.radius - distance);
437
+ }
438
+ }
439
+ return contacts;
440
+ }
441
+ //#endregion
442
+ //#region src/vehicle-glass.ts
443
+ /**
444
+ * Draw a model's double-sided transparent materials (canopies, windscreens, instrument covers) in
445
+ * one pass. Three otherwise draws each such mesh twice, back faces then front, and flags the
446
+ * material for a new program before each pass: two program lookups and two full uniform uploads
447
+ * per pane, every frame. A P-51 on an apron of parked aircraft switched 52 programs a frame that
448
+ * way. The panes are thin and blended without depth writes (glTF BLEND), so only the order in
449
+ * which a pane's two faces blend can change.
450
+ */
451
+ function drawGlassInOnePass(mesh) {
452
+ for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) if (material.transparent && material.side === THREE.DoubleSide) material.forceSinglePass = true;
453
+ }
454
+ //#endregion
455
+ //#region src/vehicle-interior.ts
456
+ /** Vehicle convenience wrapper around the platform's model-signal binding system. */
457
+ function createVehicleInteriorVisual(model, spec) {
458
+ const visual = createModelSignalVisual(model, spec);
459
+ return {
460
+ ...visual,
461
+ get missingSignals() {
462
+ return visual.missingSignals;
463
+ },
464
+ missingNodes: [...new Set([...spec.nodes.filter((name) => !model.getObjectByName(name)), ...visual.missingNodes])]
465
+ };
466
+ }
467
+ //#endregion
468
+ export { createAircraftDamageVisual as i, drawGlassInOnePass as n, aircraftObstacleContacts as r, createVehicleInteriorVisual as t };
@@ -1,8 +1,26 @@
1
+ import { a as VehicleCameraPose, c as aircraftObstacleContacts, i as VehicleCameraOptions, n as VehicleInteriorVisual, o as vehicleCameraPose, r as createVehicleInteriorVisual, t as VehicleInteriorSignals } from "./vehicle-interior-B8TpzTAx.mjs";
1
2
  import { t as ModelSignalVisual } from "./model-signals-BpeXhsim.mjs";
2
- import { a as VehicleCameraPose, i as VehicleCameraOptions, n as VehicleInteriorVisual, o as vehicleCameraPose, r as createVehicleInteriorVisual, t as VehicleInteriorSignals } from "./vehicle-interior-BgcC750p.mjs";
3
- import { LiveryData, VehicleData, VehiclePlacement } from "@bendyline/molen-schema";
3
+ import { GlassVisual } from "./glass.mjs";
4
+ import { GlassData, GlassStateData, LiveryData, VehicleCollisionPart, VehicleDamageState, VehicleData, VehiclePlacement } from "@bendyline/molen-schema";
4
5
  import * as THREE from "three";
5
6
 
7
+ //#region src/vehicle-proxy.d.ts
8
+ /** The dimensions a vehicle proxy is built from (a `VehicleSpec` satisfies it). */
9
+ interface VehicleProxyDimensions {
10
+ width: number;
11
+ length: number;
12
+ height: number;
13
+ wheelbase: number;
14
+ wheelTrack: number;
15
+ wheelRadius: number;
16
+ }
17
+ /**
18
+ * Shared street-distance silhouette for parked cars and instanced traffic. Painted faces come
19
+ * first so a static batch can tint the body and roof without tinting the glass, tyres or lamps.
20
+ * 148 triangles, one material, no textures or model downloads. Never dispose the cached result.
21
+ */
22
+ declare function vehicleProxyGeometry(spec: VehicleProxyDimensions): THREE.BufferGeometry;
23
+ //#endregion
6
24
  //#region src/vehicles.d.ts
7
25
  interface VehicleVisual {
8
26
  setLivery(data: LiveryData | undefined): void;
@@ -10,7 +28,8 @@ interface VehicleVisual {
10
28
  interior?: VehicleInteriorVisual;
11
29
  /** The visual's exterior `animation` bindings, posed from the same signals as the interior. */
12
30
  animation?: ModelSignalVisual;
13
- update(steer: number, wheelAngle: number, signals?: VehicleInteriorSignals, timeSeconds?: number): void;
31
+ glass?: GlassVisual;
32
+ update(steer: number, wheelAngle: number, signals?: VehicleInteriorSignals, timeSeconds?: number, glassState?: GlassStateData, damageState?: VehicleDamageState): void;
14
33
  dispose(): void;
15
34
  }
16
35
  /**
@@ -26,23 +45,9 @@ declare function createVehicleVisual(model: THREE.Object3D, vehicle: Pick<Vehicl
26
45
  spec?: {
27
46
  length: number;
28
47
  cycle?: unknown;
48
+ collisionParts?: VehicleCollisionPart[];
29
49
  };
30
- }, livery?: LiveryData): VehicleVisual;
31
- /** The dimensions a vehicle proxy is built from (a `VehicleSpec` satisfies it). */
32
- interface VehicleProxyDimensions {
33
- width: number;
34
- length: number;
35
- height: number;
36
- wheelbase: number;
37
- wheelTrack: number;
38
- wheelRadius: number;
39
- }
40
- /**
41
- * The parked-car proxy shape with a white body, for instanced rendering: per-instance paint comes
42
- * from `instanceColor` (three multiplies vertex colours by it, so glass and tyres stay dark).
43
- * Cached by dimensions; never dispose the returned geometry.
44
- */
45
- declare function vehicleProxyGeometry(dimensions: VehicleProxyDimensions): THREE.BufferGeometry;
50
+ }, livery?: LiveryData, glassData?: GlassData): VehicleVisual;
46
51
  /** The shared vertex-coloured material of parked and proxy vehicles. */
47
52
  declare const vehicleProxyMaterial: THREE.MeshStandardMaterial;
48
53
  /**
@@ -60,4 +65,4 @@ declare function isParkedVehicleHidden(batch: THREE.Mesh, index: number): boolea
60
65
  */
61
66
  declare function setParkedVehicleHidden(batch: THREE.Mesh, index: number, hidden: boolean): boolean;
62
67
  //#endregion
63
- export { type VehicleCameraOptions, type VehicleCameraPose, type VehicleInteriorSignals, type VehicleInteriorVisual, VehicleProxyDimensions, VehicleVisual, createParkedVehicleBatch, createVehicleInteriorVisual, createVehicleVisual, isParkedVehicleHidden, setParkedVehicleHidden, vehicleCameraPose, vehicleProxyGeometry, vehicleProxyMaterial };
68
+ export { type VehicleCameraOptions, type VehicleCameraPose, type VehicleInteriorSignals, type VehicleInteriorVisual, type VehicleProxyDimensions, VehicleVisual, createParkedVehicleBatch, createVehicleInteriorVisual, createVehicleVisual, isParkedVehicleHidden, setParkedVehicleHidden, vehicleCameraPose, aircraftObstacleContacts as vehicleObstacleContacts, vehicleProxyGeometry, vehicleProxyMaterial };