@adatechnology/game-vehicles-three 0.10.1 → 0.11.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 +17 -0
- package/dist/{chunk-5T52WAQS.js → chunk-GAPMLLDL.js} +224 -5
- package/dist/chunk-GAPMLLDL.js.map +1 -0
- package/dist/chunk-UHLZ23KF.js +565 -0
- package/dist/chunk-UHLZ23KF.js.map +1 -0
- package/dist/index.d.ts +173 -10
- package/dist/index.global.js +1424 -62
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +482 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.js +2 -1
- package/dist/worker-kinds-Dnbh9_c9.d.ts +51 -0
- package/dist/worker-kinds.d.ts +2 -0
- package/dist/worker-kinds.js +9 -0
- package/dist/worker-kinds.js.map +1 -0
- package/package.json +20 -12
- package/dist/chunk-5T52WAQS.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -60,8 +60,476 @@ import {
|
|
|
60
60
|
loadVehiclesTestModule,
|
|
61
61
|
rpmShare,
|
|
62
62
|
slideOfGrip,
|
|
63
|
-
vehicleColliders
|
|
64
|
-
|
|
63
|
+
vehicleColliders,
|
|
64
|
+
vehicleHulls
|
|
65
|
+
} from "./chunk-GAPMLLDL.js";
|
|
66
|
+
import {
|
|
67
|
+
FLAT_PAD,
|
|
68
|
+
MAX_HULL_POINTS,
|
|
69
|
+
convexFaces,
|
|
70
|
+
hullVolume,
|
|
71
|
+
reducePoints
|
|
72
|
+
} from "./chunk-UHLZ23KF.js";
|
|
73
|
+
|
|
74
|
+
// src/crash-parts.ts
|
|
75
|
+
import { CONTACT_READ_STRIDE } from "@adatechnology/game-physics";
|
|
76
|
+
import { crashVehicle } from "@adatechnology/game-vehicles";
|
|
77
|
+
|
|
78
|
+
// src/crash-parts-clamp.ts
|
|
79
|
+
var PASSES = 8;
|
|
80
|
+
var holdWithin = (old, next, slop) => {
|
|
81
|
+
const faces = convexFaces(old);
|
|
82
|
+
if (!faces) return next;
|
|
83
|
+
const middle = [0, 1, 2].map((k) => {
|
|
84
|
+
let sum = 0;
|
|
85
|
+
for (let i = k; i < old.length; i += 3) sum += old[i];
|
|
86
|
+
return sum / (old.length / 3);
|
|
87
|
+
});
|
|
88
|
+
const planes = faces.map(([a, b, c]) => {
|
|
89
|
+
const ux = old[b * 3] - old[a * 3], uy = old[b * 3 + 1] - old[a * 3 + 1], uz = old[b * 3 + 2] - old[a * 3 + 2];
|
|
90
|
+
const wx = old[c * 3] - old[a * 3], wy = old[c * 3 + 1] - old[a * 3 + 1], wz = old[c * 3 + 2] - old[a * 3 + 2];
|
|
91
|
+
const nx = uy * wz - uz * wy, ny = uz * wx - ux * wz, nz = ux * wy - uy * wx;
|
|
92
|
+
const length = Math.hypot(nx, ny, nz) || 1;
|
|
93
|
+
const towardMiddle = nx * (middle[0] - old[a * 3]) + ny * (middle[1] - old[a * 3 + 1]) + nz * (middle[2] - old[a * 3 + 2]);
|
|
94
|
+
const sign = (towardMiddle > 0 ? -1 : 1) / length;
|
|
95
|
+
const normal = [nx * sign, ny * sign, nz * sign];
|
|
96
|
+
return { normal, offset: normal[0] * old[a * 3] + normal[1] * old[a * 3 + 1] + normal[2] * old[a * 3 + 2] + slop };
|
|
97
|
+
});
|
|
98
|
+
let out;
|
|
99
|
+
for (let i = 0; i < next.length; i += 3) {
|
|
100
|
+
const p = [next[i], next[i + 1], next[i + 2]];
|
|
101
|
+
let moved = false;
|
|
102
|
+
for (let pass = 0; pass < PASSES; pass++) {
|
|
103
|
+
let clean = true;
|
|
104
|
+
for (const { normal, offset } of planes) {
|
|
105
|
+
const past = normal[0] * p[0] + normal[1] * p[1] + normal[2] * p[2] - offset;
|
|
106
|
+
if (past <= 0) continue;
|
|
107
|
+
p[0] = p[0] - normal[0] * past;
|
|
108
|
+
p[1] = p[1] - normal[1] * past;
|
|
109
|
+
p[2] = p[2] - normal[2] * past;
|
|
110
|
+
moved = true;
|
|
111
|
+
clean = false;
|
|
112
|
+
}
|
|
113
|
+
if (clean) break;
|
|
114
|
+
}
|
|
115
|
+
if (!moved) continue;
|
|
116
|
+
out ?? (out = Float32Array.from(next));
|
|
117
|
+
out[i] = p[0];
|
|
118
|
+
out[i + 1] = p[1];
|
|
119
|
+
out[i + 2] = p[2];
|
|
120
|
+
}
|
|
121
|
+
return out ?? next;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/crash-parts-chassis.ts
|
|
125
|
+
var HULL_SLOP = 2e-3;
|
|
126
|
+
var convexOf = (points) => ({ kind: "convex", points });
|
|
127
|
+
var createChassisHulls = (colliders, partIndexOf) => {
|
|
128
|
+
let children = [];
|
|
129
|
+
const shape = () => {
|
|
130
|
+
const hulls = colliders.hulls();
|
|
131
|
+
if (hulls.length === 0) throw new Error("crash parts: the car has no hulls yet (its plan is still in the worker: wait for `isHullPending()`)");
|
|
132
|
+
children = hulls.map((hull, handle) => ({ handle, key: hull.key, partId: hull.id, partIndex: partIndexOf.get(hull.id) ?? -1, applied: hull.points, wanted: hull, isHeld: false }));
|
|
133
|
+
return { kind: "compound", mutable: true, children: children.map((child) => ({ shape: convexOf(child.applied), position: [0, 0, 0], tag: child.partIndex })) };
|
|
134
|
+
};
|
|
135
|
+
const release = (world, chassis, partId) => {
|
|
136
|
+
const mine = children.filter((child) => child.partId === partId);
|
|
137
|
+
for (const child of mine) world.setChildShape(chassis, child.handle, null);
|
|
138
|
+
children = children.filter((child) => child.partId !== partId);
|
|
139
|
+
return mine.map((child) => child.applied);
|
|
140
|
+
};
|
|
141
|
+
const settle = (world, chassis, isTouching) => {
|
|
142
|
+
const now = new Map(colliders.hulls().map((hull) => [hull.key, hull]));
|
|
143
|
+
let remade = 0;
|
|
144
|
+
let held = 0;
|
|
145
|
+
const next = [];
|
|
146
|
+
for (const child of children) {
|
|
147
|
+
const hull = now.get(child.key);
|
|
148
|
+
now.delete(child.key);
|
|
149
|
+
if (!hull) {
|
|
150
|
+
world.setChildShape(chassis, child.handle, null);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
next.push(child);
|
|
154
|
+
if (hull === child.wanted && !child.isHeld) continue;
|
|
155
|
+
const points = isTouching(child.applied) ? holdWithin(child.applied, hull.points, HULL_SLOP) : hull.points;
|
|
156
|
+
child.wanted = hull;
|
|
157
|
+
child.isHeld = points !== hull.points;
|
|
158
|
+
if (child.isHeld) held++;
|
|
159
|
+
if (points === child.applied) continue;
|
|
160
|
+
world.setChildShape(chassis, child.handle, convexOf(points));
|
|
161
|
+
child.applied = points;
|
|
162
|
+
remade++;
|
|
163
|
+
}
|
|
164
|
+
children = next;
|
|
165
|
+
return { remade, held, unplaced: now.size };
|
|
166
|
+
};
|
|
167
|
+
return { shape, release, settle, count: () => children.length, hasWork: () => colliders.isHullPending() || children.some((child) => child.isHeld) };
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/crash-parts-math.ts
|
|
171
|
+
var MIN_INERTIA_PER_MASS = 1e-3;
|
|
172
|
+
var rotateBy = (q, v) => {
|
|
173
|
+
const [x, y, z, w] = q;
|
|
174
|
+
const tx = 2 * (y * v[2] - z * v[1]);
|
|
175
|
+
const ty = 2 * (z * v[0] - x * v[2]);
|
|
176
|
+
const tz = 2 * (x * v[1] - y * v[0]);
|
|
177
|
+
return [v[0] + w * tx + y * tz - z * ty, v[1] + w * ty + z * tx - x * tz, v[2] + w * tz + x * ty - y * tx];
|
|
178
|
+
};
|
|
179
|
+
var multiplyQuat = (a, b) => [
|
|
180
|
+
a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],
|
|
181
|
+
a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],
|
|
182
|
+
a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],
|
|
183
|
+
a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2]
|
|
184
|
+
];
|
|
185
|
+
var boxInertia = (mass, size) => [
|
|
186
|
+
mass / 12 * (size[1] * size[1] + size[2] * size[2]),
|
|
187
|
+
mass / 12 * (size[0] * size[0] + size[2] * size[2]),
|
|
188
|
+
mass / 12 * (size[0] * size[0] + size[1] * size[1])
|
|
189
|
+
];
|
|
190
|
+
var lever = (mass, d, k) => mass * (d[0] * d[0] + d[1] * d[1] + d[2] * d[2] - d[k] * d[k]);
|
|
191
|
+
var withoutPart = (total, part) => {
|
|
192
|
+
const mass = total.mass - part.mass;
|
|
193
|
+
if (!(mass > 0)) throw new Error(`crash parts: a part of ${part.mass} kg cannot leave a body of ${total.mass} kg`);
|
|
194
|
+
const centre = [0, 1, 2].map((k) => (total.mass * total.centre[k] - part.mass * part.centre[k]) / mass);
|
|
195
|
+
const partOffset = [part.centre[0] - total.centre[0], part.centre[1] - total.centre[1], part.centre[2] - total.centre[2]];
|
|
196
|
+
const shift = [centre[0] - total.centre[0], centre[1] - total.centre[1], centre[2] - total.centre[2]];
|
|
197
|
+
const floor = mass * MIN_INERTIA_PER_MASS;
|
|
198
|
+
const inertia = [0, 1, 2].map((k) => Math.max(floor, total.inertia[k] - (part.inertia[k] + lever(part.mass, partOffset, k)) - lever(mass, shift, k)));
|
|
199
|
+
return { mass, centre, inertia };
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// src/crash-parts-bodies.ts
|
|
203
|
+
var CLEAR_CHECK_STEPS = 30;
|
|
204
|
+
var PUSH_OUT_PASSES = 3;
|
|
205
|
+
var createPartBodies = (THREE, world, frame) => {
|
|
206
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
207
|
+
const pose = new Float64Array(7);
|
|
208
|
+
const speed = new Float64Array(6);
|
|
209
|
+
const clearOut = [];
|
|
210
|
+
const push = new Float64Array(3);
|
|
211
|
+
const scratch = { box: new THREE.Box3(), corner: new THREE.Vector3(), position: new THREE.Vector3(), quaternion: new THREE.Quaternion(), parent: new THREE.Quaternion() };
|
|
212
|
+
let steps = 0;
|
|
213
|
+
let pushed = 0;
|
|
214
|
+
const extentOf = (holder) => {
|
|
215
|
+
holder.updateWorldMatrix(true, true);
|
|
216
|
+
frame.updateWorldMatrix(true, false);
|
|
217
|
+
const { box, corner } = scratch;
|
|
218
|
+
box.setFromObject(holder);
|
|
219
|
+
const low = [Infinity, Infinity, Infinity];
|
|
220
|
+
const high = [-Infinity, -Infinity, -Infinity];
|
|
221
|
+
for (let k = 0; k < 8; k++) {
|
|
222
|
+
corner.set(k & 1 ? box.max.x : box.min.x, k & 2 ? box.max.y : box.min.y, k & 4 ? box.max.z : box.min.z);
|
|
223
|
+
frame.worldToLocal(corner);
|
|
224
|
+
low[0] = Math.min(low[0], corner.x);
|
|
225
|
+
low[1] = Math.min(low[1], corner.y);
|
|
226
|
+
low[2] = Math.min(low[2], corner.z);
|
|
227
|
+
high[0] = Math.max(high[0], corner.x);
|
|
228
|
+
high[1] = Math.max(high[1], corner.y);
|
|
229
|
+
high[2] = Math.max(high[2], corner.z);
|
|
230
|
+
}
|
|
231
|
+
return { centre: [(low[0] + high[0]) / 2, (low[1] + high[1]) / 2, (low[2] + high[2]) / 2], size: [high[0] - low[0], high[1] - low[1], high[2] - low[2]] };
|
|
232
|
+
};
|
|
233
|
+
const holderTurn = (holder) => {
|
|
234
|
+
holder.getWorldQuaternion(scratch.quaternion);
|
|
235
|
+
frame.getWorldQuaternion(scratch.parent);
|
|
236
|
+
const turn = scratch.parent.clone().invert().multiply(scratch.quaternion);
|
|
237
|
+
return [turn.x, turn.y, turn.z, turn.w];
|
|
238
|
+
};
|
|
239
|
+
const follower = (holder, offset) => ({ holder, offset, turn: holderTurn(holder) });
|
|
240
|
+
const pushOutOfTheFixedWorld = (body) => {
|
|
241
|
+
for (let pass = 0; pass < PUSH_OUT_PASSES; pass++) {
|
|
242
|
+
const depth = world.penetration(body.id, push);
|
|
243
|
+
if (depth <= 0) return;
|
|
244
|
+
world.readPose(body.id, pose, 0);
|
|
245
|
+
world.setPose(body.id, [pose[0] + push[0] * depth, pose[1] + push[1] * depth, pose[2] + push[2] * depth], [pose[3], pose[4], pose[5], pose[6]], true);
|
|
246
|
+
pushed++;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const create = ({ partIndex, mass, hulls, extent, holder, chassis, chassisMass }) => {
|
|
250
|
+
world.readPose(chassis, pose, 0);
|
|
251
|
+
world.readVelocity(chassis, speed, 0);
|
|
252
|
+
const rotation = [pose[3], pose[4], pose[5], pose[6]];
|
|
253
|
+
const lever2 = rotateBy(rotation, [extent.centre[0] - chassisMass.centre[0], extent.centre[1] - chassisMass.centre[1], extent.centre[2] - chassisMass.centre[2]]);
|
|
254
|
+
const around = [speed[3], speed[4], speed[5]];
|
|
255
|
+
const linear = [speed[0] + around[1] * lever2[2] - around[2] * lever2[1], speed[1] + around[2] * lever2[0] - around[0] * lever2[2], speed[2] + around[0] * lever2[1] - around[1] * lever2[0]];
|
|
256
|
+
const origin = rotateBy(rotation, extent.centre);
|
|
257
|
+
const shape = {
|
|
258
|
+
kind: "compound",
|
|
259
|
+
children: hulls.map((points) => ({ shape: { kind: "convex", points: shifted(points, extent.centre) }, position: [0, 0, 0], tag: partIndex }))
|
|
260
|
+
};
|
|
261
|
+
const id = world.createBody({
|
|
262
|
+
shape,
|
|
263
|
+
motion: "dynamic",
|
|
264
|
+
mass,
|
|
265
|
+
inertia: boxInertia(mass, extent.size),
|
|
266
|
+
centreAtOrigin: true,
|
|
267
|
+
continuous: true,
|
|
268
|
+
layer: "debris",
|
|
269
|
+
user: partIndex,
|
|
270
|
+
position: [pose[0] + origin[0], pose[1] + origin[1], pose[2] + origin[2]],
|
|
271
|
+
rotation,
|
|
272
|
+
linearVelocity: linear,
|
|
273
|
+
angularVelocity: around
|
|
274
|
+
});
|
|
275
|
+
const body = { id, partIndex, shape, extent, followers: [follower(holder, [0, 0, 0])], isIgnoring: true };
|
|
276
|
+
world.ignorePair(id, chassis, true);
|
|
277
|
+
pushOutOfTheFixedWorld(body);
|
|
278
|
+
bodies.set(partIndex, body);
|
|
279
|
+
return body;
|
|
280
|
+
};
|
|
281
|
+
const follow = (body, holder, extent) => {
|
|
282
|
+
const base = body.extent.centre;
|
|
283
|
+
body.followers.push(follower(holder, [extent.centre[0] - base[0], extent.centre[1] - base[1], extent.centre[2] - base[2]]));
|
|
284
|
+
};
|
|
285
|
+
const place = (body) => {
|
|
286
|
+
world.readPose(body.id, pose, 0);
|
|
287
|
+
const rotation = [pose[3], pose[4], pose[5], pose[6]];
|
|
288
|
+
for (const { holder, offset, turn } of body.followers) {
|
|
289
|
+
const at = rotateBy(rotation, offset);
|
|
290
|
+
scratch.position.set(pose[0] + at[0], pose[1] + at[1], pose[2] + at[2]);
|
|
291
|
+
const turned = multiplyQuat(rotation, turn);
|
|
292
|
+
const parent = holder.parent;
|
|
293
|
+
if (parent) parent.worldToLocal(scratch.position);
|
|
294
|
+
holder.position.copy(scratch.position);
|
|
295
|
+
scratch.quaternion.set(turned[0], turned[1], turned[2], turned[3]);
|
|
296
|
+
if (parent) {
|
|
297
|
+
parent.getWorldQuaternion(scratch.parent);
|
|
298
|
+
scratch.quaternion.premultiply(scratch.parent.invert());
|
|
299
|
+
}
|
|
300
|
+
holder.quaternion.copy(scratch.quaternion);
|
|
301
|
+
holder.updateMatrix();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const release = (body, chassis) => {
|
|
305
|
+
world.readPose(body.id, pose, 0);
|
|
306
|
+
world.overlapShape({ kind: "box", half: [body.extent.size[0] / 2, body.extent.size[1] / 2, body.extent.size[2] / 2] }, [pose[0], pose[1], pose[2]], [pose[3], pose[4], pose[5], pose[6]], clearOut, { layers: ["vehicle"] });
|
|
307
|
+
if (clearOut.includes(chassis)) return;
|
|
308
|
+
world.ignorePair(body.id, chassis, false);
|
|
309
|
+
body.isIgnoring = false;
|
|
310
|
+
};
|
|
311
|
+
return {
|
|
312
|
+
extentOf,
|
|
313
|
+
create,
|
|
314
|
+
follow,
|
|
315
|
+
bodies,
|
|
316
|
+
pushedOut: () => pushed,
|
|
317
|
+
step: (chassis) => {
|
|
318
|
+
steps++;
|
|
319
|
+
const check = steps % CLEAR_CHECK_STEPS === 0;
|
|
320
|
+
for (const body of bodies.values()) {
|
|
321
|
+
place(body);
|
|
322
|
+
if (check && body.isIgnoring) release(body, chassis);
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
dispose: () => {
|
|
326
|
+
for (const body of bodies.values()) if (world.has(body.id)) world.removeBody(body.id);
|
|
327
|
+
bodies.clear();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
var shifted = (points, by) => {
|
|
332
|
+
const out = new Float32Array(points.length);
|
|
333
|
+
for (let i = 0; i < out.length; i += 3) {
|
|
334
|
+
out[i] = points[i] - by[0];
|
|
335
|
+
out[i + 1] = points[i + 1] - by[1];
|
|
336
|
+
out[i + 2] = points[i + 2] - by[2];
|
|
337
|
+
}
|
|
338
|
+
return out;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/crash-parts.ts
|
|
342
|
+
var CONTACT_POINTS = 64;
|
|
343
|
+
var SETTLE_STEPS = 30;
|
|
344
|
+
var SETTLED_SPEED = 0.05;
|
|
345
|
+
var TOUCH_MARGIN = 0.05;
|
|
346
|
+
var createCrashParts = (options) => {
|
|
347
|
+
const { THREE, world, vehicle, frame, colliders } = options;
|
|
348
|
+
const parts = vehicle.model.parts;
|
|
349
|
+
const partIndexOf = new Map(parts.map((part, index) => [part.id, index]));
|
|
350
|
+
const chassisHulls = createChassisHulls(colliders, partIndexOf);
|
|
351
|
+
const bodies = createPartBodies(THREE, world, frame);
|
|
352
|
+
const pose = new Float64Array(7);
|
|
353
|
+
const speed = new Float64Array(6);
|
|
354
|
+
const touches = new Float32Array(CONTACT_READ_STRIDE * CONTACT_POINTS);
|
|
355
|
+
const strongest = /* @__PURE__ */ new Map();
|
|
356
|
+
let chassis;
|
|
357
|
+
let current = options.mass;
|
|
358
|
+
let calm = 0;
|
|
359
|
+
let cooldown = 0;
|
|
360
|
+
let isDirty = false;
|
|
361
|
+
let released = 0;
|
|
362
|
+
let settles = 0;
|
|
363
|
+
let held = 0;
|
|
364
|
+
let remade = 0;
|
|
365
|
+
let unplaced = 0;
|
|
366
|
+
let blows = 0;
|
|
367
|
+
let events = 0;
|
|
368
|
+
const hitParts = /* @__PURE__ */ new Set();
|
|
369
|
+
const numbers = /* @__PURE__ */ new Map();
|
|
370
|
+
const carried = (partIndex) => bodies.bodies.get(partIndex);
|
|
371
|
+
const takePart = (part, partIndex, holder) => {
|
|
372
|
+
const body = carried(partIndex);
|
|
373
|
+
const extent = bodies.extentOf(holder);
|
|
374
|
+
if (body) return bodies.follow(body, holder, extent);
|
|
375
|
+
const hulls = chassisHulls.release(world, chassis, part.id);
|
|
376
|
+
const solid = hulls.length > 0 ? hulls : [boxPoints(extent.size, extent.centre)];
|
|
377
|
+
bodies.create({ partIndex, mass: part.mass, hulls: solid, extent, holder, chassis, chassisMass: current });
|
|
378
|
+
const own = { mass: part.mass, centre: extent.centre, inertia: boxInertia(part.mass, extent.size) };
|
|
379
|
+
numbers.set(part.id, own);
|
|
380
|
+
current = withoutPart(current, own);
|
|
381
|
+
world.setMassProperties(chassis, { mass: current.mass, inertia: current.inertia, centreOfMass: current.centre });
|
|
382
|
+
released++;
|
|
383
|
+
options.onPartLost?.(part);
|
|
384
|
+
};
|
|
385
|
+
const isTouching = (points) => {
|
|
386
|
+
if (!chassis) return false;
|
|
387
|
+
const count = world.readContacts(chassis, touches);
|
|
388
|
+
if (count === 0) return false;
|
|
389
|
+
world.readPose(chassis, pose, 0);
|
|
390
|
+
let lowX = Infinity, lowY = Infinity, lowZ = Infinity;
|
|
391
|
+
let highX = -Infinity, highY = -Infinity, highZ = -Infinity;
|
|
392
|
+
for (let i = 0; i < points.length; i += 3) {
|
|
393
|
+
const x = points[i], y = points[i + 1], z = points[i + 2];
|
|
394
|
+
if (x < lowX) lowX = x;
|
|
395
|
+
if (x > highX) highX = x;
|
|
396
|
+
if (y < lowY) lowY = y;
|
|
397
|
+
if (y > highY) highY = y;
|
|
398
|
+
if (z < lowZ) lowZ = z;
|
|
399
|
+
if (z > highZ) highZ = z;
|
|
400
|
+
}
|
|
401
|
+
const qx = -pose[3], qy = -pose[4], qz = -pose[5], qw = pose[6];
|
|
402
|
+
for (let c = 0; c < count; c++) {
|
|
403
|
+
const at = c * CONTACT_READ_STRIDE;
|
|
404
|
+
const vx = touches[at] - pose[0], vy = touches[at + 1] - pose[1], vz = touches[at + 2] - pose[2];
|
|
405
|
+
const tx = 2 * (qy * vz - qz * vy);
|
|
406
|
+
const ty = 2 * (qz * vx - qx * vz);
|
|
407
|
+
const tz = 2 * (qx * vy - qy * vx);
|
|
408
|
+
const x = vx + qw * tx + qy * tz - qz * ty;
|
|
409
|
+
const y = vy + qw * ty + qz * tx - qx * tz;
|
|
410
|
+
const z = vz + qw * tz + qx * ty - qy * tx;
|
|
411
|
+
if (x >= lowX - TOUCH_MARGIN && x <= highX + TOUCH_MARGIN && y >= lowY - TOUCH_MARGIN && y <= highY + TOUCH_MARGIN && z >= lowZ - TOUCH_MARGIN && z <= highZ + TOUCH_MARGIN) return true;
|
|
412
|
+
}
|
|
413
|
+
return false;
|
|
414
|
+
};
|
|
415
|
+
const feedDamage = () => {
|
|
416
|
+
const rows = world.contacts;
|
|
417
|
+
strongest.clear();
|
|
418
|
+
for (let i = 0; i < rows.count; i++) {
|
|
419
|
+
const mine = rows.a[i] === chassis ? 0 : rows.b[i] === chassis ? 1 : -1;
|
|
420
|
+
if (mine < 0) continue;
|
|
421
|
+
const tag = mine === 0 ? rows.tagA[i] : rows.tagB[i];
|
|
422
|
+
if (tag < 0 || tag >= parts.length) continue;
|
|
423
|
+
const at = strongest.get(tag);
|
|
424
|
+
if (at === void 0 || rows.approach[i] > rows.approach[at]) strongest.set(tag, i);
|
|
425
|
+
}
|
|
426
|
+
for (const [tag, i] of strongest) {
|
|
427
|
+
const mine = rows.a[i] === chassis;
|
|
428
|
+
const other = mine ? rows.b[i] : rows.a[i];
|
|
429
|
+
const otherMass = world.has(other) ? world.massOf(other) : 0;
|
|
430
|
+
const sign = mine ? 1 : -1;
|
|
431
|
+
const part = parts[tag];
|
|
432
|
+
const result = crashVehicle(vehicle, {
|
|
433
|
+
point: [rows.point[i * 3], rows.point[i * 3 + 1], rows.point[i * 3 + 2]],
|
|
434
|
+
direction: [sign * rows.normal[i * 3], sign * rows.normal[i * 3 + 1], sign * rows.normal[i * 3 + 2]],
|
|
435
|
+
speed: rows.approach[i],
|
|
436
|
+
massKg: current.mass,
|
|
437
|
+
otherMassKg: otherMass > 0 ? otherMass : Infinity,
|
|
438
|
+
contactWidth: Math.max(0.2, part.box.size[2]),
|
|
439
|
+
source: part.id
|
|
440
|
+
});
|
|
441
|
+
blows++;
|
|
442
|
+
events += result.events.length;
|
|
443
|
+
hitParts.add(part.id);
|
|
444
|
+
if (result.events.length > 0) {
|
|
445
|
+
isDirty = true;
|
|
446
|
+
cooldown = 0;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const settle = () => {
|
|
451
|
+
world.readVelocity(chassis, speed, 0);
|
|
452
|
+
const still = Math.hypot(speed[0], speed[1], speed[2]) < SETTLED_SPEED && Math.hypot(speed[3], speed[4], speed[5]) < SETTLED_SPEED;
|
|
453
|
+
calm = still ? calm + 1 : 0;
|
|
454
|
+
if (calm < SETTLE_STEPS || !(isDirty || chassisHulls.hasWork())) return;
|
|
455
|
+
if (cooldown > 0) {
|
|
456
|
+
cooldown--;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const done = chassisHulls.settle(world, chassis, isTouching);
|
|
460
|
+
settles++;
|
|
461
|
+
held += done.held;
|
|
462
|
+
remade += done.remade;
|
|
463
|
+
unplaced += done.unplaced;
|
|
464
|
+
isDirty = done.held > 0 || colliders.isHullPending();
|
|
465
|
+
cooldown = done.held > 0 && !colliders.isHullPending() ? SETTLE_STEPS : 0;
|
|
466
|
+
};
|
|
467
|
+
vehicle.setPartSink((part, holder) => {
|
|
468
|
+
const partIndex = partIndexOf.get(part.id);
|
|
469
|
+
if (chassis === void 0 || partIndex === void 0) return false;
|
|
470
|
+
takePart(part, partIndex, holder);
|
|
471
|
+
return true;
|
|
472
|
+
});
|
|
473
|
+
return {
|
|
474
|
+
shape: () => chassisHulls.shape(),
|
|
475
|
+
bind: (body) => {
|
|
476
|
+
chassis = body;
|
|
477
|
+
world.watchContacts(body, true);
|
|
478
|
+
world.setMassProperties(body, { mass: current.mass, inertia: current.inertia, centreOfMass: current.centre });
|
|
479
|
+
},
|
|
480
|
+
step: () => {
|
|
481
|
+
if (chassis === void 0) return;
|
|
482
|
+
feedDamage();
|
|
483
|
+
bodies.step(chassis);
|
|
484
|
+
settle();
|
|
485
|
+
},
|
|
486
|
+
mass: () => current,
|
|
487
|
+
partNumbers: () => numbers,
|
|
488
|
+
partBodies: () => new Map([...bodies.bodies].map(([index, body]) => [parts[index].id, body.id])),
|
|
489
|
+
stats: () => ({ released, pushedOut: bodies.pushedOut(), settles, remade, held, unplaced, blows, events, hitParts, children: chassisHulls.count() }),
|
|
490
|
+
dispose: () => {
|
|
491
|
+
vehicle.setPartSink(null);
|
|
492
|
+
bodies.dispose();
|
|
493
|
+
if (chassis !== void 0 && world.has(chassis)) world.watchContacts(chassis, false);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
var boxPoints = (size, centre) => {
|
|
498
|
+
const out = new Float32Array(24);
|
|
499
|
+
for (let k = 0; k < 8; k++) {
|
|
500
|
+
out[k * 3] = centre[0] + (k & 1 ? size[0] : -size[0]) / 2;
|
|
501
|
+
out[k * 3 + 1] = centre[1] + (k & 2 ? size[1] : -size[1]) / 2;
|
|
502
|
+
out[k * 3 + 2] = centre[2] + (k & 4 ? size[2] : -size[2]) / 2;
|
|
503
|
+
}
|
|
504
|
+
return out;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
// src/hull-plan-cache.ts
|
|
508
|
+
var createHullPlanCache = () => {
|
|
509
|
+
const shared = /* @__PURE__ */ new Map();
|
|
510
|
+
const flights = /* @__PURE__ */ new Map();
|
|
511
|
+
let planned = 0, reused = 0;
|
|
512
|
+
let isDisposed = false;
|
|
513
|
+
return {
|
|
514
|
+
get: (key) => shared.get(key),
|
|
515
|
+
set: (key, value) => {
|
|
516
|
+
if (!isDisposed && !shared.has(key)) shared.set(key, value);
|
|
517
|
+
},
|
|
518
|
+
flight: (key) => flights.get(key),
|
|
519
|
+
setFlight: (key, flight) => void (isDisposed || flights.set(key, flight)),
|
|
520
|
+
clearFlight: (key) => void flights.delete(key),
|
|
521
|
+
noteReused: () => void reused++,
|
|
522
|
+
noteDivided: () => void planned++,
|
|
523
|
+
stats: () => ({ models: shared.size, planned, reused }),
|
|
524
|
+
dispose: () => {
|
|
525
|
+
isDisposed = true;
|
|
526
|
+
shared.clear();
|
|
527
|
+
flights.clear();
|
|
528
|
+
planned = 0;
|
|
529
|
+
reused = 0;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
};
|
|
65
533
|
export {
|
|
66
534
|
BIKE_ENGINE,
|
|
67
535
|
CAR_ENGINE,
|
|
@@ -73,8 +541,10 @@ export {
|
|
|
73
541
|
DEFAULT_TEST_WRECKS,
|
|
74
542
|
DEFAULT_VEHICLE_SOUND_KEYS,
|
|
75
543
|
ENGINE_PROFILES,
|
|
544
|
+
FLAT_PAD,
|
|
76
545
|
LAMP_RULES,
|
|
77
546
|
LITE_CLASSES,
|
|
547
|
+
MAX_HULL_POINTS,
|
|
78
548
|
MIST_RULES,
|
|
79
549
|
PAGE_ITEM_ALIASES,
|
|
80
550
|
PAGE_SCENARIO_ALIASES,
|
|
@@ -92,11 +562,15 @@ export {
|
|
|
92
562
|
VEHICLE_SCENARIO_IDS,
|
|
93
563
|
VEHICLE_SOUNDS,
|
|
94
564
|
VEHICLE_SOUND_BANK,
|
|
565
|
+
boxInertia,
|
|
95
566
|
classColor,
|
|
96
567
|
classify,
|
|
568
|
+
convexFaces,
|
|
97
569
|
createCabinSmoke,
|
|
570
|
+
createCrashParts,
|
|
98
571
|
createEngineBudget,
|
|
99
572
|
createGearGuess,
|
|
573
|
+
createHullPlanCache,
|
|
100
574
|
createProvingModule,
|
|
101
575
|
createVehicleBody,
|
|
102
576
|
createVehicleColliders,
|
|
@@ -116,14 +590,19 @@ export {
|
|
|
116
590
|
engineProfileOfGroup,
|
|
117
591
|
firingHz,
|
|
118
592
|
fuse,
|
|
593
|
+
holdWithin,
|
|
119
594
|
hornOfGroup,
|
|
595
|
+
hullVolume,
|
|
120
596
|
layerWeight,
|
|
121
597
|
liteMaterials,
|
|
122
598
|
liteMeshes,
|
|
123
599
|
loadProvingModule,
|
|
124
600
|
loadVehiclesTestModule,
|
|
601
|
+
reducePoints,
|
|
125
602
|
rpmShare,
|
|
126
603
|
slideOfGrip,
|
|
127
|
-
vehicleColliders
|
|
604
|
+
vehicleColliders,
|
|
605
|
+
vehicleHulls,
|
|
606
|
+
withoutPart
|
|
128
607
|
};
|
|
129
608
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/crash-parts.ts","../src/crash-parts-clamp.ts","../src/crash-parts-chassis.ts","../src/crash-parts-math.ts","../src/crash-parts-bodies.ts","../src/hull-plan-cache.ts"],"sourcesContent":["import type * as THREE_NS from 'three'\nimport type { BodyId, PhysicsWorld, ShapeDesc, Vec3 } from '@adatechnology/game-physics'\nimport { CONTACT_READ_STRIDE } from '@adatechnology/game-physics'\nimport { crashVehicle } from '@adatechnology/game-vehicles'\nimport type { PartDef, VehicleDestructible } from '@adatechnology/game-vehicles'\n\nimport type { VehicleColliders } from './colliders'\nimport { createChassisHulls } from './crash-parts-chassis'\nimport type { ChassisSettle } from './crash-parts-chassis'\nimport { createPartBodies } from './crash-parts-bodies'\nimport type { PartBody } from './crash-parts-bodies'\nimport { boxInertia, withoutPart } from './crash-parts-math'\nimport type { BodyMass } from './crash-parts-math'\n\ntype Three = typeof THREE_NS\n\n/** Contact points of the car's body read each step. */\nconst CONTACT_POINTS = 64\n/** Steps the car must be still before its hulls are made again (at 120 Hz, a quarter of a second), and how still (m/s, rad/s). */\nconst SETTLE_STEPS = 30\nconst SETTLED_SPEED = 0.05\n/** A contact point this near (m) the box round a hull is the part touching. */\nconst TOUCH_MARGIN = 0.05\n\nexport interface CrashPartsOptions {\n readonly THREE: Three\n readonly world: PhysicsWorld\n readonly vehicle: VehicleDestructible\n /** The frame the hulls and the drawn meshes are in (`createVehicleColliders`' frame); its pose is the body's. */\n readonly frame: THREE_NS.Object3D\n /** Made with `hulls: true`, and its plan back (`isHullPending()` false). */\n readonly colliders: VehicleColliders\n /** The kit's numbers for the whole car, in the frame: its mass, centre of mass and moments. */\n readonly mass: BodyMass\n /** A part left the car (the host remakes what depends on it: a wheel, the vehicle's constraint). */\n readonly onPartLost?: (part: PartDef) => void\n}\n\nexport interface CrashParts {\n /** The chassis compound: make the body from it (dynamic, `mass.mass`, `mass.inertia`, `centreAtOrigin` off) and `bind` it. */\n shape(): ShapeDesc\n bind(chassis: BodyId): void\n /** Once after each step: the contact rows become damage, the parts' drawings follow their bodies, and a car at rest has its hulls made again. */\n step(): void\n /** What the car weighs now. */\n mass(): BodyMass\n partBodies(): ReadonlyMap<string, BodyId>\n /** The kit's numbers each part that came off took with it (its mass, its centre in the frame, its moments). */\n partNumbers(): ReadonlyMap<string, BodyMass>\n stats(): {\n readonly released: number\n readonly pushedOut: number\n /** Times the hulls were looked at again, how many were given to the engine again, held back by the touching rule, and left without a child to go in. */\n readonly settles: number\n readonly remade: number\n readonly held: number\n readonly unplaced: number\n /** Blows the contact rows made (`crashVehicle` calls), the damage events they gave, and the parts whose hull was in those rows. */\n readonly blows: number\n readonly events: number\n readonly hitParts: ReadonlySet<string>\n /** Children left in the chassis compound. */\n readonly children: number\n }\n /** Takes the part bodies out of the world and gives the fling back to the vehicle. The chassis body is the host's. */\n dispose(): void\n}\n\nexport const createCrashParts = (options: CrashPartsOptions): CrashParts => {\n const { THREE, world, vehicle, frame, colliders } = options\n const parts = vehicle.model.parts\n const partIndexOf = new Map(parts.map((part, index) => [part.id, index]))\n const chassisHulls = createChassisHulls(colliders, partIndexOf)\n const bodies = createPartBodies(THREE, world, frame)\n const pose = new Float64Array(7)\n const speed = new Float64Array(6)\n const touches = new Float32Array(CONTACT_READ_STRIDE * CONTACT_POINTS)\n const strongest = new Map<number, number>()\n let chassis: BodyId | undefined\n let current = options.mass\n let calm = 0\n let cooldown = 0\n let isDirty = false\n let released = 0\n let settles = 0\n let held = 0\n let remade = 0\n let unplaced = 0\n let blows = 0\n let events = 0\n const hitParts = new Set<string>()\n\n const numbers = new Map<string, BodyMass>()\n const carried = (partIndex: number): PartBody | undefined => bodies.bodies.get(partIndex)\n\n const takePart = (part: PartDef, partIndex: number, holder: THREE_NS.Object3D): void => {\n const body = carried(partIndex)\n const extent = bodies.extentOf(holder)\n if (body) return bodies.follow(body, holder, extent)\n const hulls = chassisHulls.release(world, chassis!, part.id)\n const solid = hulls.length > 0 ? hulls : [boxPoints(extent.size, extent.centre)]\n bodies.create({ partIndex, mass: part.mass, hulls: solid, extent, holder, chassis: chassis!, chassisMass: current })\n const own: BodyMass = { mass: part.mass, centre: extent.centre, inertia: boxInertia(part.mass, extent.size) }\n numbers.set(part.id, own)\n current = withoutPart(current, own)\n world.setMassProperties(chassis!, { mass: current.mass, inertia: current.inertia, centreOfMass: current.centre })\n released++\n options.onPartLost?.(part)\n }\n\n const isTouching = (points: Float32Array): boolean => {\n if (!chassis) return false\n const count = world.readContacts(chassis, touches)\n if (count === 0) return false\n world.readPose(chassis, pose, 0)\n let lowX = Infinity, lowY = Infinity, lowZ = Infinity\n let highX = -Infinity, highY = -Infinity, highZ = -Infinity\n for (let i = 0; i < points.length; i += 3) {\n const x = points[i]!, y = points[i + 1]!, z = points[i + 2]!\n if (x < lowX) lowX = x\n if (x > highX) highX = x\n if (y < lowY) lowY = y\n if (y > highY) highY = y\n if (z < lowZ) lowZ = z\n if (z > highZ) highZ = z\n }\n // the contact in the chassis frame: the pose's rotation conjugated, applied to the offset\n const qx = -pose[3]!, qy = -pose[4]!, qz = -pose[5]!, qw = pose[6]!\n for (let c = 0; c < count; c++) {\n const at = c * CONTACT_READ_STRIDE\n const vx = touches[at]! - pose[0]!, vy = touches[at + 1]! - pose[1]!, vz = touches[at + 2]! - pose[2]!\n const tx = 2 * (qy * vz - qz * vy)\n const ty = 2 * (qz * vx - qx * vz)\n const tz = 2 * (qx * vy - qy * vx)\n const x = vx + qw * tx + qy * tz - qz * ty\n const y = vy + qw * ty + qz * tx - qx * tz\n const z = vz + qw * tz + qx * ty - qy * tx\n if (x >= lowX - TOUCH_MARGIN && x <= highX + TOUCH_MARGIN && y >= lowY - TOUCH_MARGIN && y <= highY + TOUCH_MARGIN && z >= lowZ - TOUCH_MARGIN && z <= highZ + TOUCH_MARGIN) return true\n }\n return false\n }\n\n const feedDamage = (): void => {\n const rows = world.contacts\n strongest.clear()\n for (let i = 0; i < rows.count; i++) {\n const mine = rows.a[i] === chassis ? 0 : rows.b[i] === chassis ? 1 : -1\n if (mine < 0) continue\n const tag = mine === 0 ? rows.tagA[i]! : rows.tagB[i]!\n if (tag < 0 || tag >= parts.length) continue\n const at = strongest.get(tag)\n if (at === undefined || rows.approach[i]! > rows.approach[at]!) strongest.set(tag, i)\n }\n for (const [tag, i] of strongest) {\n const mine = rows.a[i] === chassis\n const other = mine ? rows.b[i]! : rows.a[i]!\n const otherMass = world.has(other as BodyId) ? world.massOf(other as BodyId) : 0\n const sign = mine ? 1 : -1\n const part = parts[tag]!\n const result = crashVehicle(vehicle, {\n point: [rows.point[i * 3]!, rows.point[i * 3 + 1]!, rows.point[i * 3 + 2]!],\n direction: [sign * rows.normal[i * 3]!, sign * rows.normal[i * 3 + 1]!, sign * rows.normal[i * 3 + 2]!],\n speed: rows.approach[i]!, massKg: current.mass, otherMassKg: otherMass > 0 ? otherMass : Infinity, contactWidth: Math.max(0.2, part.box.size[2]), source: part.id,\n })\n blows++\n events += result.events.length\n hitParts.add(part.id)\n if (result.events.length > 0) {\n isDirty = true\n cooldown = 0\n }\n }\n }\n\n const settle = (): void => {\n world.readVelocity(chassis!, speed, 0)\n const still = Math.hypot(speed[0]!, speed[1]!, speed[2]!) < SETTLED_SPEED && Math.hypot(speed[3]!, speed[4]!, speed[5]!) < SETTLED_SPEED\n calm = still ? calm + 1 : 0\n if (calm < SETTLE_STEPS || !(isDirty || chassisHulls.hasWork())) return\n if (cooldown > 0) {\n cooldown--\n return\n }\n const done: ChassisSettle = chassisHulls.settle(world, chassis!, isTouching)\n settles++\n held += done.held\n remade += done.remade\n unplaced += done.unplaced\n isDirty = done.held > 0 || colliders.isHullPending()\n cooldown = done.held > 0 && !colliders.isHullPending() ? SETTLE_STEPS : 0\n }\n\n vehicle.setPartSink((part, holder) => {\n const partIndex = partIndexOf.get(part.id)\n if (chassis === undefined || partIndex === undefined) return false\n takePart(part, partIndex, holder)\n return true\n })\n\n return {\n shape: () => chassisHulls.shape(),\n bind: (body) => {\n chassis = body\n world.watchContacts(body, true)\n world.setMassProperties(body, { mass: current.mass, inertia: current.inertia, centreOfMass: current.centre })\n },\n step: () => {\n if (chassis === undefined) return\n feedDamage()\n bodies.step(chassis)\n settle()\n },\n mass: () => current,\n partNumbers: () => numbers,\n partBodies: () => new Map([...bodies.bodies].map(([index, body]) => [parts[index]!.id, body.id])),\n stats: () => ({ released, pushedOut: bodies.pushedOut(), settles, remade, held, unplaced, blows, events, hitParts, children: chassisHulls.count() }),\n dispose: () => {\n vehicle.setPartSink(null)\n bodies.dispose()\n if (chassis !== undefined && world.has(chassis)) world.watchContacts(chassis, false)\n },\n }\n}\n\nconst boxPoints = (size: Vec3, centre: Vec3): Float32Array => {\n const out = new Float32Array(24)\n for (let k = 0; k < 8; k++) {\n out[k * 3] = centre[0] + (k & 1 ? size[0] : -size[0]) / 2\n out[k * 3 + 1] = centre[1] + (k & 2 ? size[1] : -size[1]) / 2\n out[k * 3 + 2] = centre[2] + (k & 4 ? size[2] : -size[2]) / 2\n }\n return out\n}\n\nexport type { BodyMass } from './crash-parts-math'\n","import { convexFaces } from './hull-geometry'\n\n/** Passes over the faces of the old hull: each pass brings a point past a face back to it, and the next may undo a little of that at a corner. */\nconst PASSES = 8\n\n/**\n * The points of a rebuilt hull held to the old one while the part is touching something (design 10.5): a point may move in as far as it likes and out at most `slop` past\n * a face of the old hull, so the rebuilt hull does not push what rests on it (energy made). The points past that are brought back along the face they are past; what\n * is left of the move waits for the contact to end. Returns `next` itself when nothing was past the old hull, and the old points when the old hull is not a solid.\n */\nexport const holdWithin = (old: ArrayLike<number>, next: Float32Array, slop: number): Float32Array => {\n const faces = convexFaces(old)\n if (!faces) return next\n const middle = [0, 1, 2].map((k) => {\n let sum = 0\n for (let i = k; i < old.length; i += 3) sum += old[i]!\n return sum / (old.length / 3)\n })\n const planes = faces.map(([a, b, c]) => {\n const ux = old[b * 3]! - old[a * 3]!, uy = old[b * 3 + 1]! - old[a * 3 + 1]!, uz = old[b * 3 + 2]! - old[a * 3 + 2]!\n const wx = old[c * 3]! - old[a * 3]!, wy = old[c * 3 + 1]! - old[a * 3 + 1]!, wz = old[c * 3 + 2]! - old[a * 3 + 2]!\n const nx = uy * wz - uz * wy, ny = uz * wx - ux * wz, nz = ux * wy - uy * wx\n const length = Math.hypot(nx, ny, nz) || 1\n const towardMiddle = nx * (middle[0]! - old[a * 3]!) + ny * (middle[1]! - old[a * 3 + 1]!) + nz * (middle[2]! - old[a * 3 + 2]!)\n const sign = (towardMiddle > 0 ? -1 : 1) / length\n const normal = [nx * sign, ny * sign, nz * sign] as const\n return { normal, offset: normal[0] * old[a * 3]! + normal[1] * old[a * 3 + 1]! + normal[2] * old[a * 3 + 2]! + slop }\n })\n let out: Float32Array | undefined\n for (let i = 0; i < next.length; i += 3) {\n const p = [next[i]!, next[i + 1]!, next[i + 2]!]\n let moved = false\n for (let pass = 0; pass < PASSES; pass++) {\n let clean = true\n for (const { normal, offset } of planes) {\n const past = normal[0] * p[0]! + normal[1] * p[1]! + normal[2] * p[2]! - offset\n if (past <= 0) continue\n p[0] = p[0]! - normal[0] * past\n p[1] = p[1]! - normal[1] * past\n p[2] = p[2]! - normal[2] * past\n moved = true\n clean = false\n }\n if (clean) break\n }\n if (!moved) continue\n out ??= Float32Array.from(next)\n out[i] = p[0]!\n out[i + 1] = p[1]!\n out[i + 2] = p[2]!\n }\n return out ?? next\n}\n","import type { BodyId, PhysicsWorld, ShapeDesc } from '@adatechnology/game-physics'\n\nimport { holdWithin } from './crash-parts-clamp'\nimport type { VehicleColliders, VehicleHull } from './colliders'\n\n/** How far (m) a hull of a part that is touching something may go out past the hull it had (`KIT_WORLD.penetrationSlop`: what a resting body sinks anyway). */\nexport const HULL_SLOP = 0.002\n\n/** One child of the chassis compound: the hull it holds now, and the one the drawing wants when the two are not the same yet (held back while the part touches something). */\ninterface Child {\n readonly handle: number\n readonly key: string\n readonly partId: string\n readonly partIndex: number\n applied: Float32Array\n wanted: VehicleHull\n isHeld: boolean\n}\n\nexport interface ChassisSettle {\n /** Hulls the engine was given again. */\n readonly remade: number\n /** Hulls that were left out or held back this time. */\n readonly held: number\n /** Hulls the drawing has that the compound has no child for (a compound cannot gain a child). */\n readonly unplaced: number\n}\n\nexport interface ChassisHulls {\n /** The compound of the car's hulls, each child tagged with its part's number. */\n shape(): ShapeDesc\n /** Takes the part's children out of the compound; the points they held (frame), for the body the part becomes. */\n release(world: PhysicsWorld, chassis: BodyId, partId: string): Float32Array[]\n /** The hulls the drawing has now, in the compound: those that changed are given to the engine, held to the old ones where `isTouching` says the part touches something. */\n settle(world: PhysicsWorld, chassis: BodyId, isTouching: (points: Float32Array) => boolean): ChassisSettle\n /** Children still in the compound. */\n count(): number\n /** Whether some hull is held back, or the drawing's division is not back yet: the next settle has work. */\n hasWork(): boolean\n}\n\nconst convexOf = (points: Float32Array): ShapeDesc => ({ kind: 'convex', points })\n\nexport const createChassisHulls = (colliders: VehicleColliders, partIndexOf: ReadonlyMap<string, number>): ChassisHulls => {\n let children: Child[] = []\n\n const shape = (): ShapeDesc => {\n const hulls = colliders.hulls()\n if (hulls.length === 0) throw new Error('crash parts: the car has no hulls yet (its plan is still in the worker: wait for `isHullPending()`)')\n children = hulls.map((hull, handle) => ({ handle, key: hull.key, partId: hull.id, partIndex: partIndexOf.get(hull.id) ?? -1, applied: hull.points, wanted: hull, isHeld: false }))\n return { kind: 'compound', mutable: true, children: children.map((child) => ({ shape: convexOf(child.applied), position: [0, 0, 0], tag: child.partIndex })) }\n }\n\n const release: ChassisHulls['release'] = (world, chassis, partId) => {\n const mine = children.filter((child) => child.partId === partId)\n for (const child of mine) world.setChildShape(chassis, child.handle, null)\n children = children.filter((child) => child.partId !== partId)\n return mine.map((child) => child.applied)\n }\n\n const settle: ChassisHulls['settle'] = (world, chassis, isTouching) => {\n const now = new Map(colliders.hulls().map((hull) => [hull.key, hull]))\n let remade = 0\n let held = 0\n const next: Child[] = []\n for (const child of children) {\n const hull = now.get(child.key)\n now.delete(child.key)\n if (!hull) {\n world.setChildShape(chassis, child.handle, null)\n continue\n }\n next.push(child)\n if (hull === child.wanted && !child.isHeld) continue\n const points = isTouching(child.applied) ? holdWithin(child.applied, hull.points, HULL_SLOP) : hull.points\n child.wanted = hull\n child.isHeld = points !== hull.points\n if (child.isHeld) held++\n if (points === child.applied) continue\n world.setChildShape(chassis, child.handle, convexOf(points))\n child.applied = points\n remade++\n }\n children = next\n return { remade, held, unplaced: now.size }\n }\n\n return { shape, release, settle, count: () => children.length, hasWork: () => colliders.isHullPending() || children.some((child) => child.isHeld) }\n}\n","import type { Quat, Vec3 } from '@adatechnology/game-physics'\n\n/** What a body weighs and how it turns: its mass, centre of mass and moments about the principal axes, all in the body's frame. */\nexport interface BodyMass {\n readonly mass: number\n readonly centre: Vec3\n readonly inertia: Vec3\n}\n\n/** The least a moment may fall to when a part's moments are taken off (kg m^2 per kg): a body never reaches zero inertia. */\nconst MIN_INERTIA_PER_MASS = 1e-3\n\nexport const rotateBy = (q: Quat, v: Vec3): Vec3 => {\n const [x, y, z, w] = q\n const tx = 2 * (y * v[2] - z * v[1])\n const ty = 2 * (z * v[0] - x * v[2])\n const tz = 2 * (x * v[1] - y * v[0])\n return [v[0] + w * tx + y * tz - z * ty, v[1] + w * ty + z * tx - x * tz, v[2] + w * tz + x * ty - y * tx]\n}\n\nexport const conjugate = (q: Quat): Quat => [-q[0], -q[1], -q[2], q[3]]\n\nexport const multiplyQuat = (a: Quat, b: Quat): Quat => [\n a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],\n a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],\n a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],\n a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],\n]\n\n/** Moments of a solid box of `mass` and full `size` about its own centre. */\nexport const boxInertia = (mass: number, size: Vec3): Vec3 => [\n (mass / 12) * (size[1] * size[1] + size[2] * size[2]),\n (mass / 12) * (size[0] * size[0] + size[2] * size[2]),\n (mass / 12) * (size[0] * size[0] + size[1] * size[1]),\n]\n\n/** The moment about axis `k` of a point mass `mass` at offset `d` (parallel axis term). */\nconst lever = (mass: number, d: Vec3, k: number): number => mass * (d[0] * d[0] + d[1] * d[1] + d[2] * d[2] - d[k]! * d[k]!)\n\n/**\n * What is left of `total` when `part` (its own mass, centre and moments, in the same frame) leaves: the mass, the centre of mass the rest has, and its moments about that\n * centre (the whole's moments about its centre, less the part's about that centre, moved to the rest's centre by the parallel axis theorem).\n */\nexport const withoutPart = (total: BodyMass, part: BodyMass): BodyMass => {\n const mass = total.mass - part.mass\n if (!(mass > 0)) throw new Error(`crash parts: a part of ${part.mass} kg cannot leave a body of ${total.mass} kg`)\n const centre: Vec3 = [0, 1, 2].map((k) => (total.mass * total.centre[k]! - part.mass * part.centre[k]!) / mass) as unknown as Vec3\n const partOffset: Vec3 = [part.centre[0] - total.centre[0], part.centre[1] - total.centre[1], part.centre[2] - total.centre[2]]\n const shift: Vec3 = [centre[0] - total.centre[0], centre[1] - total.centre[1], centre[2] - total.centre[2]]\n const floor = mass * MIN_INERTIA_PER_MASS\n const inertia = [0, 1, 2].map((k) => Math.max(floor, total.inertia[k]! - (part.inertia[k]! + lever(part.mass, partOffset, k)) - lever(mass, shift, k))) as unknown as Vec3\n return { mass, centre, inertia }\n}\n","import type * as THREE_NS from 'three'\nimport type { BodyId, PhysicsWorld, Quat, ShapeDesc, Vec3 } from '@adatechnology/game-physics'\n\nimport { boxInertia, multiplyQuat, rotateBy } from './crash-parts-math'\nimport type { BodyMass } from './crash-parts-math'\n\ntype Three = typeof THREE_NS\n\n/** Steps between looks at whether a part is clear of the car it came off (it does not meet the car until it is). */\nconst CLEAR_CHECK_STEPS = 30\n/** Times a part found inside the fixed world is moved out along the way the engine gives. */\nconst PUSH_OUT_PASSES = 3\n\n/** A drawn holder that follows the part's body: where it sits against the body's origin and how it is turned against the frame, both fixed when the part came off. */\ninterface Follower {\n readonly holder: THREE_NS.Object3D\n readonly offset: Vec3\n readonly turn: Quat\n}\n\nexport interface PartBody {\n readonly id: BodyId\n readonly partIndex: number\n readonly shape: ShapeDesc\n /** Where the first drawn holder was: the origin the others are placed against. */\n readonly extent: PartExtent\n readonly followers: Follower[]\n /** Still not meeting the car it came off. */\n isIgnoring: boolean\n}\n\n/** Where a part sits in the frame: the centre and size of the box round its drawn meshes (the frame's axes). */\nexport interface PartExtent {\n readonly centre: Vec3\n readonly size: Vec3\n}\n\nexport interface PartBodies {\n /** The part's box in the frame, from what is drawn on `holder`. */\n extentOf(holder: THREE_NS.Object3D): PartExtent\n /** Makes the part's body from `hulls` (frame points) at `extent`, thrown with the point's speed of the chassis; its holder follows from now on. */\n create(options: { readonly partIndex: number; readonly mass: number; readonly hulls: readonly ArrayLike<number>[]; readonly extent: PartExtent; readonly holder: THREE_NS.Object3D; readonly chassis: BodyId; readonly chassisMass: BodyMass }): PartBody\n /** Another drawn holder of a part that already has its body. */\n follow(body: PartBody, holder: THREE_NS.Object3D, extent: PartExtent): void\n /** Holders onto their bodies; releases the parts that are clear of the car. Once a step. */\n step(chassis: BodyId): void\n /** Takes every body out of the world. */\n dispose(): void\n readonly bodies: ReadonlyMap<number, PartBody>\n readonly pushedOut: () => number\n}\n\nexport const createPartBodies = (THREE: Three, world: PhysicsWorld, frame: THREE_NS.Object3D): PartBodies => {\n const bodies = new Map<number, PartBody>()\n const pose = new Float64Array(7)\n const speed = new Float64Array(6)\n const clearOut: BodyId[] = []\n const push = new Float64Array(3)\n const scratch = { box: new THREE.Box3(), corner: new THREE.Vector3(), position: new THREE.Vector3(), quaternion: new THREE.Quaternion(), parent: new THREE.Quaternion() }\n let steps = 0\n let pushed = 0\n\n const extentOf = (holder: THREE_NS.Object3D): PartExtent => {\n holder.updateWorldMatrix(true, true)\n frame.updateWorldMatrix(true, false)\n const { box, corner } = scratch\n box.setFromObject(holder)\n const low = [Infinity, Infinity, Infinity]\n const high = [-Infinity, -Infinity, -Infinity]\n for (let k = 0; k < 8; k++) {\n corner.set(k & 1 ? box.max.x : box.min.x, k & 2 ? box.max.y : box.min.y, k & 4 ? box.max.z : box.min.z)\n frame.worldToLocal(corner)\n low[0] = Math.min(low[0]!, corner.x); low[1] = Math.min(low[1]!, corner.y); low[2] = Math.min(low[2]!, corner.z)\n high[0] = Math.max(high[0]!, corner.x); high[1] = Math.max(high[1]!, corner.y); high[2] = Math.max(high[2]!, corner.z)\n }\n return { centre: [(low[0]! + high[0]!) / 2, (low[1]! + high[1]!) / 2, (low[2]! + high[2]!) / 2], size: [high[0]! - low[0]!, high[1]! - low[1]!, high[2]! - low[2]!] }\n }\n\n const holderTurn = (holder: THREE_NS.Object3D): Quat => {\n holder.getWorldQuaternion(scratch.quaternion)\n frame.getWorldQuaternion(scratch.parent)\n const turn = scratch.parent.clone().invert().multiply(scratch.quaternion)\n return [turn.x, turn.y, turn.z, turn.w]\n }\n\n const follower = (holder: THREE_NS.Object3D, offset: Vec3): Follower => ({ holder, offset, turn: holderTurn(holder) })\n\n const pushOutOfTheFixedWorld = (body: PartBody): void => {\n for (let pass = 0; pass < PUSH_OUT_PASSES; pass++) {\n const depth = world.penetration(body.id, push)\n if (depth <= 0) return\n world.readPose(body.id, pose, 0)\n world.setPose(body.id, [pose[0]! + push[0]! * depth, pose[1]! + push[1]! * depth, pose[2]! + push[2]! * depth], [pose[3]!, pose[4]!, pose[5]!, pose[6]!], true)\n pushed++\n }\n }\n\n const create: PartBodies['create'] = ({ partIndex, mass, hulls, extent, holder, chassis, chassisMass }) => {\n world.readPose(chassis, pose, 0)\n world.readVelocity(chassis, speed, 0)\n const rotation: Quat = [pose[3]!, pose[4]!, pose[5]!, pose[6]!]\n const lever = rotateBy(rotation, [extent.centre[0] - chassisMass.centre[0], extent.centre[1] - chassisMass.centre[1], extent.centre[2] - chassisMass.centre[2]])\n const around: Vec3 = [speed[3]!, speed[4]!, speed[5]!]\n const linear: Vec3 = [speed[0]! + around[1] * lever[2] - around[2] * lever[1], speed[1]! + around[2] * lever[0] - around[0] * lever[2], speed[2]! + around[0] * lever[1] - around[1] * lever[0]]\n const origin = rotateBy(rotation, extent.centre)\n const shape: ShapeDesc = {\n kind: 'compound',\n children: hulls.map((points) => ({ shape: { kind: 'convex', points: shifted(points, extent.centre) } as ShapeDesc, position: [0, 0, 0] as Vec3, tag: partIndex })),\n }\n const id = world.createBody({\n shape, motion: 'dynamic', mass, inertia: boxInertia(mass, extent.size), centreAtOrigin: true, continuous: true, layer: 'debris', user: partIndex,\n position: [pose[0]! + origin[0], pose[1]! + origin[1], pose[2]! + origin[2]], rotation, linearVelocity: linear, angularVelocity: around,\n })\n const body: PartBody = { id, partIndex, shape, extent, followers: [follower(holder, [0, 0, 0])], isIgnoring: true }\n world.ignorePair(id, chassis, true)\n pushOutOfTheFixedWorld(body)\n bodies.set(partIndex, body)\n return body\n }\n\n const follow: PartBodies['follow'] = (body, holder, extent) => {\n const base = body.extent.centre\n body.followers.push(follower(holder, [extent.centre[0] - base[0], extent.centre[1] - base[1], extent.centre[2] - base[2]]))\n }\n\n const place = (body: PartBody): void => {\n world.readPose(body.id, pose, 0)\n const rotation: Quat = [pose[3]!, pose[4]!, pose[5]!, pose[6]!]\n for (const { holder, offset, turn } of body.followers) {\n const at = rotateBy(rotation, offset)\n scratch.position.set(pose[0]! + at[0], pose[1]! + at[1], pose[2]! + at[2])\n const turned = multiplyQuat(rotation, turn)\n const parent = holder.parent\n if (parent) parent.worldToLocal(scratch.position)\n holder.position.copy(scratch.position)\n scratch.quaternion.set(turned[0], turned[1], turned[2], turned[3])\n if (parent) {\n parent.getWorldQuaternion(scratch.parent)\n scratch.quaternion.premultiply(scratch.parent.invert())\n }\n holder.quaternion.copy(scratch.quaternion)\n holder.updateMatrix()\n }\n }\n\n const release = (body: PartBody, chassis: BodyId): void => {\n world.readPose(body.id, pose, 0)\n // the part's box, not its hulls: the engine holds a query shape by its dimensions, and a compound of hulls is a new one for every body\n world.overlapShape({ kind: 'box', half: [body.extent.size[0] / 2, body.extent.size[1] / 2, body.extent.size[2] / 2] }, [pose[0]!, pose[1]!, pose[2]!], [pose[3]!, pose[4]!, pose[5]!, pose[6]!], clearOut, { layers: ['vehicle'] })\n if (clearOut.includes(chassis)) return\n world.ignorePair(body.id, chassis, false)\n body.isIgnoring = false\n }\n\n return {\n extentOf, create, follow, bodies,\n pushedOut: () => pushed,\n step: (chassis) => {\n steps++\n const check = steps % CLEAR_CHECK_STEPS === 0\n for (const body of bodies.values()) {\n place(body)\n if (check && body.isIgnoring) release(body, chassis)\n }\n },\n dispose: () => {\n for (const body of bodies.values()) if (world.has(body.id)) world.removeBody(body.id)\n bodies.clear()\n },\n }\n}\n\nconst shifted = (points: ArrayLike<number>, by: Vec3): Float32Array => {\n const out = new Float32Array(points.length)\n for (let i = 0; i < out.length; i += 3) {\n out[i] = points[i]! - by[0]\n out[i + 1] = points[i + 1]! - by[1]\n out[i + 2] = points[i + 2]! - by[2]\n }\n return out\n}\n","import type { VehicleHull } from './colliders'\nimport type { HullPlan } from './hull-plan'\nimport type { HullPlanResult } from './hull-plan-kind'\n\n/** A hull and the drawn vertices (x y z triples) it was made from. */\nexport interface SharedHull {\n readonly hull: VehicleHull\n readonly drawn: ArrayLike<number>\n}\n\n/** The hulls of an intact model, made once: what every car of it is given instead of making them. */\nexport interface SharedHulls {\n /** The pieces (names and vertex counts) and the hull ceiling it was made for: a car whose pieces differ makes its own. */\n readonly signature: string\n readonly plan: HullPlan\n readonly pieces: ReadonlyMap<string, readonly SharedHull[]>\n /** The solid parts' hulls (one each, whole), filled in by the first car that made them. */\n readonly solids: Map<string, { readonly signature: string; readonly hulls: VehicleHull[] }>\n}\n\n/** A division on its way (in a worker): the cars of the same model wait for it instead of sending another. */\nexport interface HullPlanFlight {\n readonly signature: string\n readonly promise: Promise<HullPlanResult>\n}\n\nexport interface HullPlanCacheStats {\n readonly models: number\n /** Divisions made (here or in a worker). */\n readonly planned: number\n /** Cars given the hulls of a model that was already made. */\n readonly reused: number\n}\n\n/**\n * The hulls of the intact models, by model (the vehicle key, its seed key and its build state, and the ceiling): the division of a car is the same for every car of the model, so it is\n * made once. `dispose` lets everything go (design 10.4: the memory is the engine's shapes and these, nothing is kept after).\n */\nexport interface HullPlanCache {\n get(key: string): SharedHulls | undefined\n set(key: string, shared: SharedHulls): void\n flight(key: string): HullPlanFlight | undefined\n setFlight(key: string, flight: HullPlanFlight): void\n clearFlight(key: string): void\n noteReused(): void\n noteDivided(): void\n stats(): HullPlanCacheStats\n dispose(): void\n}\n\nexport const createHullPlanCache = (): HullPlanCache => {\n const shared = new Map<string, SharedHulls>()\n const flights = new Map<string, HullPlanFlight>()\n let planned = 0, reused = 0\n let isDisposed = false\n return {\n get: (key) => shared.get(key),\n set: (key, value) => {\n if (!isDisposed && !shared.has(key)) shared.set(key, value)\n },\n flight: (key) => flights.get(key),\n setFlight: (key, flight) => void (isDisposed || flights.set(key, flight)),\n clearFlight: (key) => void flights.delete(key),\n noteReused: () => void reused++,\n noteDivided: () => void planned++,\n stats: () => ({ models: shared.size, planned, reused }),\n dispose: () => {\n isDisposed = true\n shared.clear()\n flights.clear()\n planned = 0\n reused = 0\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;;;ACA7B,IAAM,SAAS;AAOR,IAAM,aAAa,CAAC,KAAwB,MAAoB,SAA+B;AACpG,QAAM,QAAQ,YAAY,GAAG;AAC7B,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,SAAS,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM;AAClC,QAAI,MAAM;AACV,aAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,EAAG,QAAO,IAAI,CAAC;AACpD,WAAO,OAAO,IAAI,SAAS;AAAA,EAC7B,CAAC;AACD,QAAM,SAAS,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM;AACtC,UAAM,KAAK,IAAI,IAAI,CAAC,IAAK,IAAI,IAAI,CAAC,GAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAK,IAAI,IAAI,IAAI,CAAC,GAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAK,IAAI,IAAI,IAAI,CAAC;AAClH,UAAM,KAAK,IAAI,IAAI,CAAC,IAAK,IAAI,IAAI,CAAC,GAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAK,IAAI,IAAI,IAAI,CAAC,GAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAK,IAAI,IAAI,IAAI,CAAC;AAClH,UAAM,KAAK,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,KAAK;AAC1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