@khr3/core 0.2.10 → 0.2.12

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.
Files changed (55) hide show
  1. package/README.md +8 -0
  2. package/dist/KhrAssembly.d.ts +44 -8
  3. package/dist/KhrCollider.d.ts +25 -7
  4. package/dist/clone.d.ts +45 -0
  5. package/dist/decoders.d.ts +30 -0
  6. package/dist/{khrExporter.d.ts → exporter.d.ts} +2 -2
  7. package/dist/{khrGlb.d.ts → glb.d.ts} +4 -3
  8. package/dist/index.d.ts +10 -9
  9. package/dist/index.js +1087 -926
  10. package/dist/index.js.map +1 -1
  11. package/dist/inertia.d.ts +41 -0
  12. package/dist/joints-5IgWDD2w.js +865 -0
  13. package/dist/joints-5IgWDD2w.js.map +1 -0
  14. package/dist/{jointDynamics.d.ts → joints.d.ts} +10 -7
  15. package/dist/loader.d.ts +9 -0
  16. package/dist/types.d.ts +284 -0
  17. package/dist/useKhrGlb.d.ts +6 -1
  18. package/dist/vehicle.d.ts +22 -2
  19. package/dist/vehicle.js +617 -665
  20. package/dist/vehicle.js.map +1 -1
  21. package/dist/vehicleJoints.d.ts +50 -0
  22. package/dist/wheelLoads.d.ts +5 -4
  23. package/package.json +4 -16
  24. package/dist/AssemblyRootBody.d.ts +0 -16
  25. package/dist/BundleSceneHost.d.ts +0 -23
  26. package/dist/KhrVehicle.d.ts +0 -20
  27. package/dist/assemblyPlan.d.ts +0 -61
  28. package/dist/curves.d.ts +0 -378
  29. package/dist/curves.js +0 -542
  30. package/dist/curves.js.map +0 -1
  31. package/dist/khrBundleFinalize.d.ts +0 -15
  32. package/dist/khrClone.d.ts +0 -14
  33. package/dist/khrConfigTypes.d.ts +0 -62
  34. package/dist/khrExportEncoders.d.ts +0 -8
  35. package/dist/khrExtras.d.ts +0 -22
  36. package/dist/khrInertia.d.ts +0 -18
  37. package/dist/khrJointParser.d.ts +0 -3
  38. package/dist/khrLoader.d.ts +0 -7
  39. package/dist/khrMassProps.d.ts +0 -16
  40. package/dist/khrParsers.d.ts +0 -10
  41. package/dist/khrPlugin.d.ts +0 -8
  42. package/dist/khrPluginHelpers.d.ts +0 -26
  43. package/dist/khrRotorDecoders.d.ts +0 -4
  44. package/dist/khrShapeParser.d.ts +0 -8
  45. package/dist/khrTypes.d.ts +0 -141
  46. package/dist/khrVehicleChassis.d.ts +0 -20
  47. package/dist/khrVehicleJointHelpers.d.ts +0 -37
  48. package/dist/khrVehicleJoints.d.ts +0 -30
  49. package/dist/khrVehicleRotors.d.ts +0 -22
  50. package/dist/khrVehicleSlots.d.ts +0 -41
  51. package/dist/khrVehicleTypes.d.ts +0 -52
  52. package/dist/pacejka.d.ts +0 -22
  53. package/dist/physicsEcs-Bi0ikONC.js +0 -1156
  54. package/dist/physicsEcs-Bi0ikONC.js.map +0 -1
  55. package/dist/physicsEcs.d.ts +0 -25
@@ -0,0 +1,865 @@
1
+ import React, { createContext, useCallback, useEffect, useLayoutEffect, useRef } from "react";
2
+ import { BallCollider, CapsuleCollider, CoefficientCombineRule, ConvexHullCollider, CuboidCollider, CylinderCollider, TrimeshCollider } from "@react-three/rapier";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import * as THREE from "three";
5
+ // src/types.ts
6
+ var KhrValidationError = class extends Error {
7
+ constructor(message) {
8
+ super(message);
9
+ this.name = "KhrValidationError";
10
+ }
11
+ };
12
+ var JointRegistryContext = createContext(null);
13
+ var COMBINE_MODES = /* @__PURE__ */ new Set([
14
+ "average",
15
+ "minimum",
16
+ "maximum",
17
+ "multiply"
18
+ ]);
19
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
20
+ var isFiniteNum = (v) => typeof v === "number" && Number.isFinite(v);
21
+ var isPosNum = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
22
+ var isNonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
23
+ function optFiniteNum(v, label, nonNeg = false) {
24
+ if (v === void 0) return void 0;
25
+ if (!isFiniteNum(v) || nonNeg && v < 0) throw new KhrValidationError(`Invalid ${label}: expected finite number${nonNeg ? " >= 0" : ""}`);
26
+ return v;
27
+ }
28
+ function assignRef(ref, value) {
29
+ if (typeof ref === "function") ref(value);
30
+ else if (ref && typeof ref === "object") ref.current = value;
31
+ }
32
+ // src/inertia.ts
33
+ var SCALE_EPS = 1e-4;
34
+ var _wsScratch = new THREE.Vector3();
35
+ var _one = new THREE.Vector3(1, 1, 1);
36
+ var _tmpPos = new THREE.Vector3();
37
+ var _tmpQuat = new THREE.Quaternion();
38
+ var _tmpQuatB = new THREE.Quaternion();
39
+ function isUnitScalar(v) {
40
+ return typeof v === "number" && Number.isFinite(v) && Math.abs(v - 1) <= 1e-9;
41
+ }
42
+ function assertUnitScale(scale, owner) {
43
+ if (scale === void 0) return;
44
+ let ok = false;
45
+ if (typeof scale === "number") ok = isUnitScalar(scale);
46
+ else if (Array.isArray(scale)) ok = scale.length === 3 && scale.every(isUnitScalar);
47
+ else if (typeof scale === "object" && scale && "x" in scale && "y" in scale && "z" in scale) {
48
+ const v = scale;
49
+ ok = isUnitScalar(v.x) && isUnitScalar(v.y) && isUnitScalar(v.z);
50
+ }
51
+ if (!ok) throw new KhrValidationError(`${owner}: scale must be 1 (got ${typeof scale === "number" && !Number.isFinite(scale) ? String(scale) : JSON.stringify(scale)}); bake scale into the .glb at import`);
52
+ }
53
+ function readFiniteVec3(val, fieldLabel) {
54
+ if (!Array.isArray(val) || val.length !== 3 || !val.every((n) => typeof n === "number" && Number.isFinite(n))) throw new KhrValidationError(`Invalid ${fieldLabel}: expected finite 3-tuple`);
55
+ return [
56
+ val[0],
57
+ val[1],
58
+ val[2]
59
+ ];
60
+ }
61
+ function readUnitQuat(val, fieldLabel) {
62
+ if (!Array.isArray(val) || val.length !== 4 || !val.every((n) => typeof n === "number" && Number.isFinite(n))) throw new KhrValidationError(`Invalid ${fieldLabel}: expected finite 4-tuple`);
63
+ const norm = Math.hypot(val[0], val[1], val[2], val[3]);
64
+ if (!(norm > 1e-6)) throw new KhrValidationError(`Invalid ${fieldLabel}: zero-norm quaternion`);
65
+ return [
66
+ val[0] / norm,
67
+ val[1] / norm,
68
+ val[2] / norm,
69
+ val[3] / norm
70
+ ];
71
+ }
72
+ function assertIdentityWorldScale(obj, nodeName) {
73
+ obj.getWorldScale(_wsScratch);
74
+ if (!Number.isFinite(_wsScratch.x) || !Number.isFinite(_wsScratch.y) || !Number.isFinite(_wsScratch.z) || Math.abs(_wsScratch.x - 1) > SCALE_EPS || Math.abs(_wsScratch.y - 1) > SCALE_EPS || Math.abs(_wsScratch.z - 1) > SCALE_EPS) throw new KhrValidationError(`Non-identity world scale [${_wsScratch.x.toFixed(4)}, ${_wsScratch.y.toFixed(4)}, ${_wsScratch.z.toFixed(4)}] on "${nodeName}"; bake scale=[1,1,1]`);
75
+ const ls = obj.scale;
76
+ if (!Number.isFinite(ls.x) || !Number.isFinite(ls.y) || !Number.isFinite(ls.z) || Math.abs(ls.x - 1) > SCALE_EPS || Math.abs(ls.y - 1) > SCALE_EPS || Math.abs(ls.z - 1) > SCALE_EPS) throw new KhrValidationError(`Non-identity local scale [${ls.x.toFixed(4)}, ${ls.y.toFixed(4)}, ${ls.z.toFixed(4)}] on "${nodeName}"; bake scale=[1,1,1]`);
77
+ }
78
+ function assertSceneIdentityWorldScale(root) {
79
+ root.updateMatrixWorld(true);
80
+ root.traverse((child) => {
81
+ assertIdentityWorldScale(child, child.name || (child === root ? "gltf.scene" : "unnamed_node"));
82
+ });
83
+ }
84
+ function computeRelativePose(ownerObj, childObj) {
85
+ const ownerPos = ownerObj.getWorldPosition(new THREE.Vector3());
86
+ const ownerInvQuat = ownerObj.getWorldQuaternion(new THREE.Quaternion()).invert();
87
+ const pos = childObj.getWorldPosition(new THREE.Vector3()).sub(ownerPos).applyQuaternion(ownerInvQuat);
88
+ const quat = ownerInvQuat.multiply(childObj.getWorldQuaternion(new THREE.Quaternion()));
89
+ return {
90
+ localPosition: [
91
+ pos.x,
92
+ pos.y,
93
+ pos.z
94
+ ],
95
+ localQuaternion: [
96
+ quat.x,
97
+ quat.y,
98
+ quat.z,
99
+ quat.w
100
+ ]
101
+ };
102
+ }
103
+ function extractMeshColliderShape(targetObj, meshNodeName, convexHull) {
104
+ assertIdentityWorldScale(targetObj, meshNodeName);
105
+ const invOwner = targetObj.matrixWorld.clone().invert();
106
+ const rel = new THREE.Matrix4();
107
+ const v = new THREE.Vector3();
108
+ const verts = [];
109
+ const indices = [];
110
+ targetObj.traverse((child) => {
111
+ const mesh = child;
112
+ if (!mesh.isMesh || !mesh.geometry) return;
113
+ assertIdentityWorldScale(mesh, mesh.name || meshNodeName);
114
+ const posAttr = mesh.geometry.getAttribute("position");
115
+ if (!posAttr || posAttr.count === 0) return;
116
+ rel.multiplyMatrices(invOwner, mesh.matrixWorld);
117
+ const base = verts.length / 3;
118
+ for (let i = 0; i < posAttr.count; i++) {
119
+ v.fromBufferAttribute(posAttr, i).applyMatrix4(rel);
120
+ if (!Number.isFinite(v.x) || !Number.isFinite(v.y) || !Number.isFinite(v.z)) throw new KhrValidationError(`Non-finite vertex in collider mesh "${meshNodeName}"`);
121
+ verts.push(v.x, v.y, v.z);
122
+ }
123
+ const idx = mesh.geometry.getIndex();
124
+ if (idx) for (let i = 0; i < idx.count; i++) indices.push(base + idx.getX(i));
125
+ else for (let i = 0; i < posAttr.count; i++) indices.push(base + i);
126
+ });
127
+ if (verts.length < 9) throw new KhrValidationError(`Collider node "${meshNodeName}" has fewer than 3 vertices`);
128
+ if (convexHull) return {
129
+ type: "convexHull",
130
+ vertices: new Float32Array(verts),
131
+ meshNodeName
132
+ };
133
+ if (indices.length < 3) throw new KhrValidationError(`Trimesh node "${meshNodeName}" has fewer than 3 indices`);
134
+ return {
135
+ type: "trimesh",
136
+ vertices: new Float32Array(verts),
137
+ indices: new Uint32Array(indices),
138
+ meshNodeName
139
+ };
140
+ }
141
+ function bodyPoseMatrix(body, target = new THREE.Matrix4()) {
142
+ return target.compose(_tmpPos.fromArray(body.localPosition), _tmpQuat.fromArray(body.localQuaternion), _one);
143
+ }
144
+ function computeAssemblyMassAndCom(bodies) {
145
+ let totalDynamicMass = 0, mx = 0, my = 0, mz = 0;
146
+ for (const b of bodies) {
147
+ if (b.isKinematic) continue;
148
+ totalDynamicMass += b.mass;
149
+ _tmpPos.fromArray(b.centerOfMass).applyQuaternion(_tmpQuat.fromArray(b.localQuaternion));
150
+ mx += (b.localPosition[0] + _tmpPos.x) * b.mass;
151
+ my += (b.localPosition[1] + _tmpPos.y) * b.mass;
152
+ mz += (b.localPosition[2] + _tmpPos.z) * b.mass;
153
+ }
154
+ return {
155
+ totalDynamicMass,
156
+ centerOfMass: totalDynamicMass > 0 ? [
157
+ mx / totalDynamicMass,
158
+ my / totalDynamicMass,
159
+ mz / totalDynamicMass
160
+ ] : [
161
+ 0,
162
+ 0,
163
+ 0
164
+ ]
165
+ };
166
+ }
167
+ /**
168
+ * Builds a `RigidBody`-local mass specification from a `KhrBodySpec`.
169
+ * When `hasExplicitInertia` is false, Rapier WASM (`parry3d`) computes exact volume, CoM,
170
+ * parallel-axis tensor, and principal inertia directly from the attached colliders.
171
+ */
172
+ function buildBodyMassTarget(body, bodyRotInRigidBody = [
173
+ 0,
174
+ 0,
175
+ 0,
176
+ 1
177
+ ], bodyOffsetInRigidBody = [
178
+ 0,
179
+ 0,
180
+ 0
181
+ ]) {
182
+ if (body.isKinematic || !(body.mass > 0)) return null;
183
+ _tmpQuat.set(bodyRotInRigidBody[0], bodyRotInRigidBody[1], bodyRotInRigidBody[2], bodyRotInRigidBody[3]).normalize();
184
+ _tmpPos.fromArray(body.centerOfMass).applyQuaternion(_tmpQuat);
185
+ const com = [
186
+ bodyOffsetInRigidBody[0] + _tmpPos.x,
187
+ bodyOffsetInRigidBody[1] + _tmpPos.y,
188
+ bodyOffsetInRigidBody[2] + _tmpPos.z
189
+ ];
190
+ _tmpQuatB.copy(_tmpQuat).multiply(new THREE.Quaternion().fromArray(body.inertiaOrientation)).normalize();
191
+ return {
192
+ mass: body.mass,
193
+ com,
194
+ hasExplicitCom: Boolean(body.hasExplicitCom) || Math.abs(com[0]) > 1e-9 || Math.abs(com[1]) > 1e-9 || Math.abs(com[2]) > 1e-9,
195
+ inertiaDiagonal: [
196
+ body.inertiaDiagonal[0],
197
+ body.inertiaDiagonal[1],
198
+ body.inertiaDiagonal[2]
199
+ ],
200
+ inertiaFrame: [
201
+ _tmpQuatB.x,
202
+ _tmpQuatB.y,
203
+ _tmpQuatB.z,
204
+ _tmpQuatB.w
205
+ ],
206
+ hasExplicitInertia: Boolean(body.hasExplicitInertia)
207
+ };
208
+ }
209
+ /**
210
+ * Applies `KHR_physics_rigid_bodies` mass properties to a live Rapier WASM `RigidBody`:
211
+ * - Explicit `motion.inertiaDiagonal`: passes authored `{ mass, com, inertiaDiagonal, inertiaFrame }` directly to Rapier.
212
+ * - Omitted `motion.inertiaDiagonal`: delegates volume, CoM, parallel-axis lumping, and Jacobi principal-axis inertia
213
+ * to Rapier's Rust `parry3d` engine across all attached colliders, preserving explicit `motion.centerOfMass` if authored.
214
+ */
215
+ function applyRapierBodyMass(rb, target) {
216
+ if (!target || !(target.mass > 0)) return;
217
+ const n = rb.numColliders();
218
+ if (target.hasExplicitInertia) {
219
+ for (let i = 0; i < n; i++) rb.collider(i).setDensity(0);
220
+ rb.setAdditionalMassProperties(target.mass, {
221
+ x: target.com[0],
222
+ y: target.com[1],
223
+ z: target.com[2]
224
+ }, {
225
+ x: target.inertiaDiagonal[0],
226
+ y: target.inertiaDiagonal[1],
227
+ z: target.inertiaDiagonal[2]
228
+ }, {
229
+ x: target.inertiaFrame[0],
230
+ y: target.inertiaFrame[1],
231
+ z: target.inertiaFrame[2],
232
+ w: target.inertiaFrame[3]
233
+ }, true);
234
+ rb.recomputeMassPropertiesFromColliders();
235
+ return;
236
+ }
237
+ rb.setAdditionalMassProperties(0, {
238
+ x: 0,
239
+ y: 0,
240
+ z: 0
241
+ }, {
242
+ x: 0,
243
+ y: 0,
244
+ z: 0
245
+ }, {
246
+ x: 0,
247
+ y: 0,
248
+ z: 0,
249
+ w: 1
250
+ }, false);
251
+ for (let i = 0; i < n; i++) rb.collider(i).setDensity(1);
252
+ rb.recomputeMassPropertiesFromColliders();
253
+ const unitMass = rb.mass();
254
+ if (n > 0 && unitMass > 1e-9) {
255
+ const rho = target.mass / unitMass;
256
+ for (let i = 0; i < n; i++) rb.collider(i).setDensity(rho);
257
+ rb.recomputeMassPropertiesFromColliders();
258
+ if (target.hasExplicitCom) {
259
+ const pi = rb.principalInertia();
260
+ const pf = rb.principalInertiaLocalFrame();
261
+ for (let i = 0; i < n; i++) rb.collider(i).setDensity(0);
262
+ rb.setAdditionalMassProperties(target.mass, {
263
+ x: target.com[0],
264
+ y: target.com[1],
265
+ z: target.com[2]
266
+ }, {
267
+ x: pi.x,
268
+ y: pi.y,
269
+ z: pi.z
270
+ }, {
271
+ x: pf.x,
272
+ y: pf.y,
273
+ z: pf.z,
274
+ w: pf.w
275
+ }, true);
276
+ rb.recomputeMassPropertiesFromColliders();
277
+ }
278
+ return;
279
+ }
280
+ for (let i = 0; i < n; i++) rb.collider(i).setDensity(0);
281
+ const diag = .04 * target.mass;
282
+ rb.setAdditionalMassProperties(target.mass, {
283
+ x: target.com[0],
284
+ y: target.com[1],
285
+ z: target.com[2]
286
+ }, {
287
+ x: diag,
288
+ y: diag,
289
+ z: diag
290
+ }, {
291
+ x: 0,
292
+ y: 0,
293
+ z: 0,
294
+ w: 1
295
+ }, true);
296
+ rb.recomputeMassPropertiesFromColliders();
297
+ }
298
+ // src/clone.ts
299
+ var mountedScenes = /* @__PURE__ */ new WeakSet();
300
+ var clonedScenes = /* @__PURE__ */ new WeakSet();
301
+ var disposedScenes = /* @__PURE__ */ new WeakSet();
302
+ var templateByClone = /* @__PURE__ */ new WeakMap();
303
+ var subtreeRestorersByScene = /* @__PURE__ */ new WeakMap();
304
+ function findSceneRoot(obj) {
305
+ let cur = obj;
306
+ while (cur.parent) cur = cur.parent;
307
+ return cur;
308
+ }
309
+ function registerMountedSubtree(ownerScene, restoreForClone) {
310
+ let set = subtreeRestorersByScene.get(ownerScene);
311
+ if (!set) {
312
+ set = /* @__PURE__ */ new Set();
313
+ subtreeRestorersByScene.set(ownerScene, set);
314
+ }
315
+ set.add(restoreForClone);
316
+ return () => {
317
+ set?.delete(restoreForClone);
318
+ };
319
+ }
320
+ function claimBundleMount(bundle, ownerComponent) {
321
+ if (disposedScenes.has(bundle.scene)) throw new KhrValidationError(`${ownerComponent}: KhrAssetBundle "${bundle.scene.name || bundle.scene.uuid}" has already been disposed`);
322
+ if (mountedScenes.has(bundle.scene)) throw new KhrValidationError(`${ownerComponent}: KhrAssetBundle "${bundle.scene.name || bundle.scene.uuid}" is already mounted; call cloneKhrBundle(template) per concurrent instance`);
323
+ mountedScenes.add(bundle.scene);
324
+ }
325
+ function releaseBundleMount(bundle) {
326
+ mountedScenes.delete(bundle.scene);
327
+ }
328
+ function remapNode(srcRoot, node, dstRoot) {
329
+ if (node === srcRoot) return dstRoot;
330
+ const path = [];
331
+ let cur = node;
332
+ while (cur && cur !== srcRoot) {
333
+ const parent = cur.parent;
334
+ if (!parent) throw new KhrValidationError(`cloneKhrBundle: body node "${node.name}" is detached from bundle.scene`);
335
+ const idx = parent.children.indexOf(cur);
336
+ if (idx < 0) throw new KhrValidationError(`cloneKhrBundle: child index missing for "${node.name}"`);
337
+ path.push(idx);
338
+ cur = parent;
339
+ }
340
+ let out = dstRoot;
341
+ for (let i = path.length - 1; i >= 0; i--) out = out.children[path[i]];
342
+ return out;
343
+ }
344
+ function cloneCurve(curve) {
345
+ if (!curve) return void 0;
346
+ return {
347
+ ...curve,
348
+ points: curve.points.map((pt) => ({ ...pt }))
349
+ };
350
+ }
351
+ function cloneCarTune(tune) {
352
+ if (!tune) return void 0;
353
+ return {
354
+ ...tune,
355
+ ...tune.gearRatios ? { gearRatios: [...tune.gearRatios] } : {},
356
+ ...tune.engineTorqueCurveData ? { engineTorqueCurveData: cloneCurve(tune.engineTorqueCurveData) } : {},
357
+ ...tune.steerAngleCurveData ? { steerAngleCurveData: cloneCurve(tune.steerAngleCurveData) } : {}
358
+ };
359
+ }
360
+ /**
361
+ * Returns a structural `Object3D` clone with any mounted `RotorVisualSlot` / `MountSubtreeSlot`
362
+ * subtrees restored synchronously when `root` is currently mounted, or `root` itself otherwise.
363
+ */
364
+ function snapshotSceneWithMountedSubtrees(root) {
365
+ const scopedSet = subtreeRestorersByScene.get(root);
366
+ if (!scopedSet || scopedSet.size === 0) return root;
367
+ const restorers = [...scopedSet];
368
+ const reattach = [];
369
+ for (let i = restorers.length - 1; i >= 0; i--) reattach.push(restorers[i]());
370
+ try {
371
+ return root.clone(true);
372
+ } finally {
373
+ for (let i = reattach.length - 1; i >= 0; i--) reattach[i]();
374
+ }
375
+ }
376
+ /**
377
+ * Clones a parsed `KhrAssetBundle` in O(nodes) while sharing GPU `BufferGeometry` / `Material` buffers
378
+ * and Rapier `Float32Array` collider vertices. Only restores subtrees belonging to `bundle.scene`.
379
+ */
380
+ function cloneKhrBundle(bundle) {
381
+ if (disposedScenes.has(bundle.scene)) throw new KhrValidationError(`cloneKhrBundle: cannot clone disposed KhrAssetBundle "${bundle.scene.name || bundle.scene.uuid}"`);
382
+ const scopedSet = subtreeRestorersByScene.get(bundle.scene);
383
+ const restorers = scopedSet ? [...scopedSet] : [];
384
+ const reattach = [];
385
+ for (let i = restorers.length - 1; i >= 0; i--) reattach.push(restorers[i]());
386
+ try {
387
+ const scene = bundle.scene.clone(true);
388
+ clonedScenes.add(scene);
389
+ templateByClone.set(scene, templateByClone.get(bundle.scene) ?? bundle.scene);
390
+ const sockets = Object.create(null);
391
+ for (const [k, v] of Object.entries(bundle.sockets)) sockets[k] = [
392
+ v[0],
393
+ v[1],
394
+ v[2]
395
+ ];
396
+ return {
397
+ scene,
398
+ bodies: bundle.bodies.map((b) => {
399
+ const drives = b.joint ? b.joint.drives.map((d) => ({ ...d })) : [];
400
+ return {
401
+ ...b,
402
+ centerOfMass: [...b.centerOfMass],
403
+ inertiaDiagonal: [...b.inertiaDiagonal],
404
+ inertiaOrientation: [...b.inertiaOrientation],
405
+ ...b.linearVelocity ? { linearVelocity: [...b.linearVelocity] } : {},
406
+ ...b.angularVelocity ? { angularVelocity: [...b.angularVelocity] } : {},
407
+ localPosition: [...b.localPosition],
408
+ localQuaternion: [...b.localQuaternion],
409
+ colliders: b.colliders.map((c) => ({
410
+ ...c,
411
+ shape: c.shape.type === "box" ? {
412
+ ...c.shape,
413
+ size: [...c.shape.size]
414
+ } : { ...c.shape },
415
+ localPosition: [...c.localPosition],
416
+ localQuaternion: [...c.localQuaternion]
417
+ })),
418
+ joint: b.joint ? {
419
+ ...b.joint,
420
+ axis: [...b.joint.axis],
421
+ limits: b.joint.limits ? [...b.joint.limits] : null,
422
+ drive: drives[0] ?? (b.joint.drive ? { ...b.joint.drive } : null),
423
+ drives,
424
+ anchor1: [...b.joint.anchor1],
425
+ anchor2: [...b.joint.anchor2]
426
+ } : null,
427
+ ...b.breakaway ? { breakaway: { ...b.breakaway } } : {},
428
+ object: remapNode(bundle.scene, b.object, scene)
429
+ };
430
+ }),
431
+ wheels: bundle.wheels.map((w) => ({
432
+ ...w,
433
+ object: remapNode(bundle.scene, w.object, scene),
434
+ position: [...w.position],
435
+ ...w.quaternion ? { quaternion: [...w.quaternion] } : {},
436
+ ...w.lngSlipRatioCurveData ? { lngSlipRatioCurveData: cloneCurve(w.lngSlipRatioCurveData) } : {},
437
+ ...w.latSlipRatioCurveData ? { latSlipRatioCurveData: cloneCurve(w.latSlipRatioCurveData) } : {}
438
+ })),
439
+ propellers: bundle.propellers.map((p) => ({
440
+ ...p,
441
+ object: remapNode(bundle.scene, p.object, scene),
442
+ position: [...p.position],
443
+ ...p.quaternion ? { quaternion: [...p.quaternion] } : {}
444
+ })),
445
+ sockets,
446
+ totalDynamicMass: bundle.totalDynamicMass,
447
+ centerOfMass: [...bundle.centerOfMass],
448
+ ...bundle.tune ? { tune: cloneCarTune(bundle.tune) } : {},
449
+ ...bundle.droneTune ? { droneTune: { ...bundle.droneTune } } : {}
450
+ };
451
+ } finally {
452
+ for (let i = reattach.length - 1; i >= 0; i--) reattach[i]();
453
+ }
454
+ }
455
+ function disposeSceneGpuResources(roots) {
456
+ const geos = /* @__PURE__ */ new Set();
457
+ const mats = /* @__PURE__ */ new Set();
458
+ const texs = /* @__PURE__ */ new Set();
459
+ for (const root of roots) root.traverse((child) => {
460
+ const mesh = child;
461
+ if (mesh.geometry && !geos.has(mesh.geometry)) {
462
+ geos.add(mesh.geometry);
463
+ mesh.geometry.dispose();
464
+ }
465
+ const matList = Array.isArray(mesh.material) ? mesh.material : mesh.material ? [mesh.material] : [];
466
+ for (const mat of matList) if (!mats.has(mat)) {
467
+ mats.add(mat);
468
+ for (const val of Object.values(mat)) if (val && typeof val === "object" && "isTexture" in val && val.isTexture) {
469
+ const tex = val;
470
+ if (!texs.has(tex)) {
471
+ texs.add(tex);
472
+ tex.dispose();
473
+ }
474
+ }
475
+ mat.dispose();
476
+ }
477
+ });
478
+ }
479
+ /**
480
+ * Releases mount ownership. On root templates (or when `{ disposeTemplate: true }` is passed on a clone),
481
+ * disposes unique GPU geometries, materials, and textures once.
482
+ */
483
+ function disposeKhrBundle(bundle, options) {
484
+ mountedScenes.delete(bundle.scene);
485
+ if (disposedScenes.has(bundle.scene)) return;
486
+ disposedScenes.add(bundle.scene);
487
+ const isClone = clonedScenes.has(bundle.scene);
488
+ if (isClone && !options?.disposeTemplate) return;
489
+ const targetRoot = isClone ? templateByClone.get(bundle.scene) ?? bundle.scene : bundle.scene;
490
+ disposedScenes.add(targetRoot);
491
+ disposeSceneGpuResources([
492
+ targetRoot,
493
+ ...bundle.wheels.map((w) => w.object),
494
+ ...bundle.propellers.map((p) => p.object)
495
+ ]);
496
+ }
497
+ function captureSubtreeOrigins(objects, explicitScene) {
498
+ const parentOrders = /* @__PURE__ */ new Map();
499
+ const origins = /* @__PURE__ */ new Map();
500
+ for (const obj of objects) {
501
+ const ownerScene = explicitScene ?? findSceneRoot(obj);
502
+ const origParent = obj.parent;
503
+ let origOrder = null;
504
+ let origIndex = -1;
505
+ if (origParent) {
506
+ let order = parentOrders.get(origParent);
507
+ if (!order) {
508
+ order = /* @__PURE__ */ new Map();
509
+ origParent.children.forEach((child, idx) => order.set(child, idx));
510
+ parentOrders.set(origParent, order);
511
+ }
512
+ origOrder = order;
513
+ origIndex = order.get(obj) ?? origParent.children.indexOf(obj);
514
+ }
515
+ origins.set(obj, {
516
+ ownerScene,
517
+ origParent,
518
+ origIndex,
519
+ origOrder,
520
+ origPos: obj.position.clone(),
521
+ origQuat: obj.quaternion.clone(),
522
+ origScale: obj.scale.clone()
523
+ });
524
+ }
525
+ return origins;
526
+ }
527
+ function restoreSubtreeOrigin(object, snap) {
528
+ object.position.copy(snap.origPos);
529
+ object.quaternion.copy(snap.origQuat);
530
+ object.scale.copy(snap.origScale);
531
+ const { origParent, origIndex, origOrder } = snap;
532
+ if (!origParent) return;
533
+ if (object.parent && object.parent !== origParent) object.parent.remove(object);
534
+ const existingIdx = origParent.children.indexOf(object);
535
+ if (existingIdx >= 0) origParent.children.splice(existingIdx, 1);
536
+ let insertAt = origParent.children.length;
537
+ if (origOrder && origOrder.size > 0) {
538
+ for (let i = 0; i < origParent.children.length; i++) if ((origOrder.get(origParent.children[i]) ?? 1e400) > origIndex) {
539
+ insertAt = i;
540
+ break;
541
+ }
542
+ } else if (origIndex >= 0) insertAt = Math.min(origIndex, origParent.children.length);
543
+ object.parent = origParent;
544
+ origParent.children.splice(insertAt, 0, object);
545
+ }
546
+ function BundleSceneHost({ bundle, owner }) {
547
+ const hostRef = useRef(null);
548
+ useLayoutEffect(() => {
549
+ const host = hostRef.current;
550
+ if (!host) return;
551
+ claimBundleMount(bundle, owner);
552
+ host.add(bundle.scene);
553
+ return () => {
554
+ if (bundle.scene.parent === host) host.remove(bundle.scene);
555
+ releaseBundleMount(bundle);
556
+ };
557
+ }, [bundle, owner]);
558
+ return React.createElement("group", { ref: hostRef });
559
+ }
560
+ function MountSubtreeSlot({ object, position, quaternion, origin }) {
561
+ const slotRef = useRef(null);
562
+ useLayoutEffect(() => {
563
+ const slot = slotRef.current;
564
+ if (!slot) return;
565
+ const snap = origin ?? captureSubtreeOrigins([object]).get(object);
566
+ if (snap.origParent) snap.origParent.remove(object);
567
+ object.position.set(0, 0, 0);
568
+ object.quaternion.set(0, 0, 0, 1);
569
+ object.scale.set(1, 1, 1);
570
+ slot.add(object);
571
+ const untrack = registerMountedSubtree(snap.ownerScene, () => {
572
+ const p = object.position.clone(), q = object.quaternion.clone(), s = object.scale.clone();
573
+ if (object.parent === slot) slot.remove(object);
574
+ restoreSubtreeOrigin(object, snap);
575
+ return () => {
576
+ if (snap.origParent) snap.origParent.remove(object);
577
+ object.position.copy(p);
578
+ object.quaternion.copy(q);
579
+ object.scale.copy(s);
580
+ slot.add(object);
581
+ };
582
+ });
583
+ return () => {
584
+ untrack();
585
+ if (object.parent === slot) slot.remove(object);
586
+ restoreSubtreeOrigin(object, snap);
587
+ };
588
+ }, [object, origin]);
589
+ return React.createElement("group", {
590
+ ref: slotRef,
591
+ position,
592
+ quaternion
593
+ });
594
+ }
595
+ // src/KhrCollider.tsx
596
+ var COMBINE_RULES = {
597
+ average: CoefficientCombineRule.Average,
598
+ minimum: CoefficientCombineRule.Min,
599
+ maximum: CoefficientCombineRule.Max,
600
+ multiply: CoefficientCombineRule.Multiply
601
+ };
602
+ /** `RAPIER.TriMeshFlags.FIX_INTERNAL_EDGES` (144) — merges duplicate vertices and suppresses internal seam ghost normals. */
603
+ var KHR_TRIMESH_FLAGS = 144;
604
+ function KhrCollider({ c, position, quaternion, density, mass, massProperties, collisionGroups, solverGroups, ref }) {
605
+ const innerRef = useRef(null);
606
+ const setRef = useCallback((node) => {
607
+ innerRef.current = node;
608
+ assignRef(ref, node);
609
+ }, [ref]);
610
+ useEffect(() => {
611
+ innerRef.current?.parent()?.recomputeMassPropertiesFromColliders();
612
+ }, [
613
+ c,
614
+ density,
615
+ mass,
616
+ massProperties
617
+ ]);
618
+ const effCollisionGroups = c.collisionGroups ?? collisionGroups;
619
+ const effSolverGroups = solverGroups ?? effCollisionGroups;
620
+ const massOption = massProperties ? { massProperties } : mass !== void 0 ? { mass } : { density: density ?? 0 };
621
+ const common = {
622
+ ref: setRef,
623
+ position: position ?? c.localPosition,
624
+ quaternion: quaternion ?? c.localQuaternion,
625
+ ...massOption,
626
+ ...c.friction === void 0 ? {} : { friction: c.friction },
627
+ ...c.restitution === void 0 ? {} : { restitution: c.restitution },
628
+ ...c.frictionCombine === void 0 ? {} : { frictionCombineRule: COMBINE_RULES[c.frictionCombine] },
629
+ ...c.restitutionCombine === void 0 ? {} : { restitutionCombineRule: COMBINE_RULES[c.restitutionCombine] },
630
+ ...effCollisionGroups === void 0 ? {} : { collisionGroups: effCollisionGroups },
631
+ ...effSolverGroups === void 0 ? {} : { solverGroups: effSolverGroups }
632
+ };
633
+ const { shape } = c;
634
+ if (shape.type === "box") {
635
+ const [sx, sy, sz] = shape.size;
636
+ return /* @__PURE__ */ jsx(CuboidCollider, {
637
+ args: [
638
+ sx * .5,
639
+ sy * .5,
640
+ sz * .5
641
+ ],
642
+ ...common
643
+ });
644
+ }
645
+ if (shape.type === "sphere") return /* @__PURE__ */ jsx(BallCollider, {
646
+ args: [shape.radius],
647
+ ...common
648
+ });
649
+ if (shape.type === "cylinder") return /* @__PURE__ */ jsx(CylinderCollider, {
650
+ args: [shape.height * .5, shape.radiusTop],
651
+ ...common
652
+ });
653
+ if (shape.type === "capsule") return /* @__PURE__ */ jsx(CapsuleCollider, {
654
+ args: [shape.height * .5, shape.radiusTop],
655
+ ...common
656
+ });
657
+ if (shape.type === "convexHull") return /* @__PURE__ */ jsx(ConvexHullCollider, {
658
+ args: [shape.vertices],
659
+ ...common
660
+ });
661
+ return /* @__PURE__ */ jsx(TrimeshCollider, {
662
+ args: [
663
+ shape.vertices,
664
+ shape.indices,
665
+ 144
666
+ ],
667
+ ...common
668
+ });
669
+ }
670
+ // src/joints.ts
671
+ /**
672
+ * Rapier interaction group bitmask for attached vehicle articulated panels:
673
+ * member of group 1 (`0x0002`), collides with all groups except group 1 (`0xfffd`),
674
+ * preventing sibling hinged panels (e.g. `door_fl` <-> `door_rl` / `hood`) from
675
+ * fighting across joints while colliding normally with world geometry and projectiles.
676
+ */
677
+ var ATTACHED_PANEL_INTERACTION_GROUPS = 196605;
678
+ var DETACHED_PANEL_INTERACTION_GROUPS = 0xffffffff;
679
+ var _q1 = new THREE.Quaternion();
680
+ var _q2 = new THREE.Quaternion();
681
+ var _qRel = new THREE.Quaternion();
682
+ var _deltaPos = new THREE.Vector3();
683
+ var _axWorld = new THREE.Vector3();
684
+ function createRapierImpulseJoint(rapier, world, parentBody, childBody, joint, anchorParent, anchorChild, axisParent, axisChild, restFrameRelQuat) {
685
+ const a1 = {
686
+ x: anchorParent[0],
687
+ y: anchorParent[1],
688
+ z: anchorParent[2]
689
+ };
690
+ const a2 = {
691
+ x: anchorChild[0],
692
+ y: anchorChild[1],
693
+ z: anchorChild[2]
694
+ };
695
+ const qRel = _qRel.set(restFrameRelQuat[0], restFrameRelQuat[1], restFrameRelQuat[2], restFrameRelQuat[3]).normalize();
696
+ const axFromChild = _axWorld.set(axisChild[0], axisChild[1], axisChild[2]).applyQuaternion(qRel);
697
+ const ax = (axFromChild.lengthSq() > 1e-12 ? axFromChild : _axWorld.set(axisParent[0], axisParent[1], axisParent[2])).normalize();
698
+ let data;
699
+ if (joint.kind === "fixed") {
700
+ const pr = parentBody.rotation();
701
+ const cr = childBody.rotation();
702
+ const bodyRel = _q1.set(pr.x, pr.y, pr.z, pr.w).invert().multiply(_q2.set(cr.x, cr.y, cr.z, cr.w)).normalize();
703
+ data = rapier.JointData.fixed(a1, {
704
+ x: bodyRel.x,
705
+ y: bodyRel.y,
706
+ z: bodyRel.z,
707
+ w: bodyRel.w
708
+ }, a2, {
709
+ x: 0,
710
+ y: 0,
711
+ z: 0,
712
+ w: 1
713
+ });
714
+ } else if (joint.kind === "revolute") {
715
+ data = rapier.JointData.revolute(a1, a2, {
716
+ x: ax.x,
717
+ y: ax.y,
718
+ z: ax.z
719
+ });
720
+ if (joint.limits) {
721
+ data.limitsEnabled = true;
722
+ data.limits = [joint.limits[0], joint.limits[1]];
723
+ }
724
+ } else {
725
+ data = rapier.JointData.prismatic(a1, a2, {
726
+ x: ax.x,
727
+ y: ax.y,
728
+ z: ax.z
729
+ });
730
+ if (joint.limits) {
731
+ data.limitsEnabled = true;
732
+ data.limits = [joint.limits[0], joint.limits[1]];
733
+ }
734
+ }
735
+ const imp = world.createImpulseJoint(data, parentBody, childBody, true);
736
+ imp.setContactsEnabled(Boolean(joint.enableCollision));
737
+ const activeDrive = selectMatchingDrive(joint);
738
+ configureJointDrive(rapier, imp, joint.kind, activeDrive, activeDrive?.positionTarget ?? null);
739
+ return imp;
740
+ }
741
+ function selectMatchingDrive(joint) {
742
+ if (joint.kind === "fixed") return null;
743
+ const expectedType = joint.kind === "revolute" ? "angular" : "linear";
744
+ for (const d of joint.drives) if (d.type === void 0 || d.type === expectedType) return d;
745
+ return joint.drive;
746
+ }
747
+ function configureJointDrive(rapier, imp, kind, drive, targetPos) {
748
+ if (kind === "fixed" || !drive) return;
749
+ const unit = imp;
750
+ unit.configureMotorModel(drive.mode === "force" ? rapier.MotorModel.ForceBased : rapier.MotorModel.AccelerationBased);
751
+ const effTargetPos = targetPos ?? drive.positionTarget ?? (drive.stiffness !== void 0 && drive.stiffness > 0 ? 0 : null);
752
+ if (effTargetPos !== null && drive.stiffness !== void 0) {
753
+ if (drive.velocityTarget !== void 0) unit.configureMotor(effTargetPos, drive.velocityTarget, drive.stiffness, drive.damping ?? 0);
754
+ else unit.configureMotorPosition(effTargetPos, drive.stiffness, drive.damping ?? 0);
755
+ } else if (drive.velocityTarget !== void 0) unit.configureMotorVelocity(drive.velocityTarget, drive.damping ?? 0);
756
+ if (drive.maxForce !== void 0) unit.setMotorMaxForce?.(drive.maxForce);
757
+ }
758
+ function measureJointCoordinate(parentBody, childBody, kind, axisParent, anchorParent) {
759
+ if (!parentBody || !childBody || kind === "fixed") return 0;
760
+ const pr = parentBody.rotation();
761
+ const cr = childBody.rotation();
762
+ _q1.set(pr.x, pr.y, pr.z, pr.w);
763
+ _q2.set(cr.x, cr.y, cr.z, cr.w);
764
+ if (kind === "prismatic") {
765
+ const pt = parentBody.translation();
766
+ const ct = childBody.translation();
767
+ _deltaPos.set(anchorParent[0], anchorParent[1], anchorParent[2]).applyQuaternion(_q1);
768
+ _deltaPos.set(ct.x - (pt.x + _deltaPos.x), ct.y - (pt.y + _deltaPos.y), ct.z - (pt.z + _deltaPos.z));
769
+ _axWorld.set(axisParent[0], axisParent[1], axisParent[2]).applyQuaternion(_q1).normalize();
770
+ return _deltaPos.dot(_axWorld);
771
+ }
772
+ _qRel.copy(_q1).invert().multiply(_q2).normalize();
773
+ if (_qRel.w < 0) _qRel.set(-_qRel.x, -_qRel.y, -_qRel.z, -_qRel.w);
774
+ const sinHalf = _qRel.x * axisParent[0] + _qRel.y * axisParent[1] + _qRel.z * axisParent[2];
775
+ return 2 * Math.atan2(sinHalf, _qRel.w);
776
+ }
777
+ function buildJointRuntime(params) {
778
+ const { rapier, world, nodeName, role, kind, object, axisParent, anchorParent, limits, drive, breakaway, rapierJoint, parentBody, childBody } = params;
779
+ const rt = {
780
+ nodeName,
781
+ role,
782
+ kind,
783
+ object,
784
+ axis: new THREE.Vector3(axisParent[0], axisParent[1], axisParent[2]).normalize(),
785
+ limits,
786
+ drive,
787
+ positionTarget: drive?.positionTarget ?? null,
788
+ velocityTarget: drive?.velocityTarget ?? 0,
789
+ rapierJoint,
790
+ parentBody,
791
+ childBody,
792
+ unlatched: false,
793
+ detached: false,
794
+ getCoordinate: () => measureJointCoordinate(rt.parentBody, rt.childBody, kind, axisParent, anchorParent),
795
+ applyTarget: (target) => {
796
+ if (rt.detached || !rt.rapierJoint) return;
797
+ if (!drive || drive.stiffness === void 0) throw new KhrValidationError(`Joint "${nodeName}" has no authored drive stiffness; cannot set a position target`);
798
+ rt.unlatched = false;
799
+ rt.positionTarget = target;
800
+ configureJointDrive(rapier, rt.rapierJoint, kind, drive, target);
801
+ if (parentBody.isDynamic()) parentBody.wakeUp();
802
+ if (childBody.isDynamic()) childBody.wakeUp();
803
+ },
804
+ applyImpactImpulse: (impulseNs) => {
805
+ if (rt.detached || !breakaway || !(impulseNs > 0)) return rt.detached ? "detached" : rt.unlatched ? "unlatched" : "intact";
806
+ if (impulseNs >= breakaway.breakImpulseNs) {
807
+ if (world && rt.rapierJoint && world.getImpulseJoint(rt.rapierJoint.handle)) world.removeImpulseJoint(rt.rapierJoint, true);
808
+ rt.rapierJoint = null;
809
+ rt.detached = true;
810
+ rt.unlatched = true;
811
+ rt.positionTarget = null;
812
+ const ud = childBody.userData;
813
+ if (ud?.ecctrl) childBody.userData = {
814
+ ...ud,
815
+ ecctrl: {
816
+ ...ud.ecctrl,
817
+ excludeVehicleRay: false
818
+ }
819
+ };
820
+ for (let i = 0; i < childBody.numColliders(); i++) {
821
+ const col = childBody.collider(i);
822
+ if (col.collisionGroups() === 196605) {
823
+ col.setCollisionGroups(DETACHED_PANEL_INTERACTION_GROUPS);
824
+ col.setSolverGroups(DETACHED_PANEL_INTERACTION_GROUPS);
825
+ }
826
+ }
827
+ if (childBody.isDynamic()) childBody.wakeUp();
828
+ return "detached";
829
+ }
830
+ if (breakaway.latchImpulseNs !== void 0 && impulseNs >= breakaway.latchImpulseNs && !rt.unlatched) {
831
+ rt.unlatched = true;
832
+ rt.positionTarget = null;
833
+ if (kind !== "fixed" && rt.rapierJoint) rt.rapierJoint.configureMotorPosition(0, 0, Math.min(drive?.damping ?? 1, 1.5));
834
+ if (childBody.isDynamic()) childBody.wakeUp();
835
+ return "unlatched";
836
+ }
837
+ return rt.unlatched ? "unlatched" : "intact";
838
+ }
839
+ };
840
+ return rt;
841
+ }
842
+ function openTargetForLimits(limits) {
843
+ return Math.abs(limits[0]) > Math.abs(limits[1]) ? limits[0] : limits[1];
844
+ }
845
+ function closedTargetForLimits(limits) {
846
+ return Math.min(limits[1], Math.max(limits[0], 0));
847
+ }
848
+ function isJointOpen(rt) {
849
+ if (!rt.limits) return false;
850
+ const openTgt = openTargetForLimits(rt.limits);
851
+ const closedTgt = closedTargetForLimits(rt.limits);
852
+ if (Math.abs(openTgt - closedTgt) <= 1e-6) return false;
853
+ const cur = rt.positionTarget ?? rt.getCoordinate();
854
+ return Math.abs(cur - openTgt) < Math.abs(cur - closedTgt);
855
+ }
856
+ function toggleDrivenJoint(rt) {
857
+ if (rt.detached || rt.drive?.stiffness === void 0) return false;
858
+ const limits = rt.limits ?? [0, Math.PI / 2];
859
+ const nextTarget = isJointOpen(rt) ? closedTargetForLimits(limits) : openTargetForLimits(limits);
860
+ rt.applyTarget(nextTarget);
861
+ return true;
862
+ }
863
+ export { computeRelativePose as A, isObj as B, applyRapierBodyMass as C, bodyPoseMatrix as D, assertUnitScale as E, JointRegistryContext as F, optFiniteNum as H, KhrValidationError as I, assignRef as L, readFiniteVec3 as M, readUnitQuat as N, buildBodyMassTarget as O, COMBINE_MODES as P, isFiniteNum as R, snapshotSceneWithMountedSubtrees as S, assertSceneIdentityWorldScale as T, isPosNum as V, cloneKhrBundle as _, configureJointDrive as a, releaseBundleMount as b, measureJointCoordinate as c, KHR_TRIMESH_FLAGS as d, KhrCollider as f, claimBundleMount as g, captureSubtreeOrigins as h, closedTargetForLimits as i, extractMeshColliderShape as j, computeAssemblyMassAndCom as k, openTargetForLimits as l, MountSubtreeSlot as m, DETACHED_PANEL_INTERACTION_GROUPS as n, createRapierImpulseJoint as o, BundleSceneHost as p, buildJointRuntime as r, isJointOpen as s, ATTACHED_PANEL_INTERACTION_GROUPS as t, toggleDrivenJoint as u, disposeKhrBundle as v, assertIdentityWorldScale as w, restoreSubtreeOrigin as x, registerMountedSubtree as y, isNonNegNum as z };
864
+
865
+ //# sourceMappingURL=joints-5IgWDD2w.js.map