@pinkaphant/kolmo 0.0.0-stage → 0.1.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 +44 -2
- package/bin/kolmo.mjs +112 -0
- package/dist/engine/index.d.ts +8 -0
- package/dist/engine/index.js +3 -0
- package/dist/engine/kolmoActor.d.ts +6 -0
- package/dist/engine/kolmoIsland.d.ts +17 -0
- package/dist/engine/kolmoLongDrive.d.ts +13 -0
- package/dist/engine/kolmoRigs.d.ts +13 -0
- package/dist/engine/kolmoStore.d.ts +68 -0
- package/dist/engine/kolmoSurface.d.ts +18 -0
- package/dist/engine/kolmoVehicle.d.ts +32 -0
- package/dist/engine/kolmoWorld.d.ts +51 -0
- package/dist/engine/longDriveKit.d.ts +19 -0
- package/dist/engine/mainlandMacroCell.d.ts +19 -0
- package/dist/engine-BiMeAPAi.js +1717 -0
- package/dist/importer/ChopShopPanel.d.ts +44 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +17 -0
- package/dist/importer/GateHudBar.d.ts +29 -0
- package/dist/importer/GlbImportGate.d.ts +7 -0
- package/dist/importer/ImperativeVehicleRig.d.ts +9 -0
- package/dist/importer/Step1CalibrationPlinth.d.ts +38 -0
- package/dist/importer/Step2UniversalPad.d.ts +18 -0
- package/dist/importer/VfxEmitterPool.d.ts +8 -0
- package/dist/importer/chopShopActions.d.ts +44 -0
- package/dist/importer/gateStore.d.ts +73 -0
- package/dist/importer/glbNormalizer.d.ts +22 -0
- package/dist/importer/importerWebMcp.d.ts +37 -0
- package/dist/importer/index.d.ts +17 -0
- package/dist/importer/index.js +3 -0
- package/dist/importer/khrCompiler.d.ts +23 -0
- package/dist/importer/launcherBake.d.ts +15 -0
- package/dist/importer/meshIslands.d.ts +59 -0
- package/dist/importer/surfaceCutter.d.ts +27 -0
- package/dist/importer/surfaceTopology.d.ts +40 -0
- package/dist/importer/universalGateBake.d.ts +41 -0
- package/dist/importer/usdToGlb.d.ts +11 -0
- package/dist/importer/useChopShopController.d.ts +94 -0
- package/dist/importer/vehiclePanelAnim.d.ts +25 -0
- package/dist/importer/wheelAxlePairing.d.ts +19 -0
- package/dist/importer-Cz5w0mnC.js +5005 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +14 -0
- package/dist/junk/DestructibleTarget.d.ts +18 -0
- package/dist/junk/KolmoJunk.d.ts +14 -0
- package/dist/junk/ShardPieces.d.ts +10 -0
- package/dist/junk/TargetDecals.d.ts +18 -0
- package/dist/junk/bvhShatter.d.ts +7 -0
- package/dist/junk/bvhTriCollector.d.ts +20 -0
- package/dist/junk/index.d.ts +12 -0
- package/dist/junk/index.js +1 -0
- package/dist/junk/junkGeometry.d.ts +34 -0
- package/dist/junk/junkImportSanitize.d.ts +6 -0
- package/dist/junk/junkImporter.d.ts +25 -0
- package/dist/junk/junkLabelCanvas.d.ts +7 -0
- package/dist/junk/junkLabels.d.ts +31 -0
- package/dist/junk/junkTypes.d.ts +48 -0
- package/dist/junk/targetHelpers.d.ts +56 -0
- package/dist/junk/targetHitLogic.d.ts +30 -0
- package/dist/junk/useTargetAssets.d.ts +24 -0
- package/dist/junk-B4bC1zAl.js +1049 -0
- package/dist/kolmoSurface-DTnrFXH0.js +558 -0
- package/dist/schema/kolmoSchema.d.ts +69 -0
- package/dist/shaders/celestialBackdrop.d.ts +22 -0
- package/dist/shaders/index.d.ts +6 -0
- package/dist/shaders/index.js +1 -0
- package/dist/shaders/plumeAndSparkle.d.ts +14 -0
- package/dist/shaders/ps2GlslShared.d.ts +20 -0
- package/dist/shaders/ps2MaterialsTSL.d.ts +23 -0
- package/dist/shaders/ps2MaterialsWebGL.d.ts +15 -0
- package/dist/shaders/ps2RoadWebGL.d.ts +7 -0
- package/dist/shaders/ps2TerrainWebGL.d.ts +8 -0
- package/dist/shaders/ps2Textures.d.ts +22 -0
- package/dist/shaders/retroPalettes.d.ts +24 -0
- package/dist/shaders/retroShader.d.ts +69 -0
- package/dist/shaders-GS71Ek1A.js +1383 -0
- package/dist/world/frontage.d.ts +26 -0
- package/dist/world/index.d.ts +9 -0
- package/dist/world/index.js +3 -0
- package/dist/world/infiniteWorld2D.d.ts +24 -0
- package/dist/world/island.d.ts +29 -0
- package/dist/world/macroCellSchema.d.ts +72 -0
- package/dist/world/macroKnightAStar.d.ts +11 -0
- package/dist/world/random.d.ts +23 -0
- package/dist/world/road.d.ts +37 -0
- package/dist/world/roadRibbon.d.ts +44 -0
- package/dist/world/terrain.d.ts +62 -0
- package/dist/world/worldTypes.d.ts +39 -0
- package/dist/world-PRWPYrlx.js +947 -0
- package/dist/worldTypes-Z0KfdCd0.js +226 -0
- package/package.json +100 -4
|
@@ -0,0 +1,5005 @@
|
|
|
1
|
+
import { a as e, d as t, i as n, l as r, o as i, r as a, s as o } from "./kolmoSurface-DTnrFXH0.js";
|
|
2
|
+
import { g as s } from "./shaders-GS71Ek1A.js";
|
|
3
|
+
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
4
|
+
import * as p from "three";
|
|
5
|
+
import { Canvas as m, useFrame as h } from "@react-three/fiber";
|
|
6
|
+
import { Bounds as g, Bvh as _, Grid as v, Line as y, OrbitControls as b } from "@react-three/drei";
|
|
7
|
+
import { KhrAssembly as x, cloneKhrBundle as S, exportKhrGlb as C, loadKhrGlb as w, patchGlbJsonChunk as T } from "@khr3/core";
|
|
8
|
+
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
9
|
+
import { CuboidCollider as k, Physics as A, RigidBody as j, useBeforePhysicsStep as ee, useRevoluteJoint as M } from "@react-three/rapier";
|
|
10
|
+
import { easing as te } from "maath";
|
|
11
|
+
import { KhrVehicle as ne } from "@khr3/core/vehicle";
|
|
12
|
+
import { ENGINE_TORQUE_CURVES as re, STEER_SPEED_CURVES as ie, TIRE_ARCHETYPES as ae, tireGripForSurface as oe } from "@khr3/core/curves";
|
|
13
|
+
import { DOOR_HINGE_SPEC as se } from "@khr3/c12";
|
|
14
|
+
import { GLTFLoader as ce } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
15
|
+
import { BODY_SI as le } from "@khr3/body";
|
|
16
|
+
import { VAULT_CATALOG as N, createAssetVault as ue } from "@khr3/assets";
|
|
17
|
+
import { KOLMOGOROV_CARBINE as P, KOLMOGOROV_PISTOL as de, KOLMOGOROV_SHOTGUN as fe, LAUNCHER_RECIPES as pe, findLauncherRecipe as me, planLauncher as he } from "@khr3/launchers";
|
|
18
|
+
import { create as ge } from "zustand";
|
|
19
|
+
import { ALL_PANELS_ATTACHED_MASK as _e, PaperShellMassMemo as F, buildPaperShellAssembly as ve, exportPaperShellKhrGlb as ye } from "@khr3/vehicles/paper-shell";
|
|
20
|
+
import { EcctrlVehicle as be, ShapeCastWheel as xe } from "@pinkaphant/ecctrl/vehicle";
|
|
21
|
+
import { unzipSync as Se, zipSync as Ce } from "three/examples/jsm/libs/fflate.module.js";
|
|
22
|
+
import { USDLoader as we } from "three/examples/jsm/loaders/USDLoader.js";
|
|
23
|
+
// src/importer/wheelAxlePairing.ts
|
|
24
|
+
function I(e, t) {
|
|
25
|
+
let n = new Map(e.map((e) => [e.id, e])), r = [
|
|
26
|
+
Infinity,
|
|
27
|
+
Infinity,
|
|
28
|
+
Infinity
|
|
29
|
+
], i = [
|
|
30
|
+
-Infinity,
|
|
31
|
+
-Infinity,
|
|
32
|
+
-Infinity
|
|
33
|
+
], a = 0;
|
|
34
|
+
for (let e of t) {
|
|
35
|
+
let t = n.get(e);
|
|
36
|
+
if (t) {
|
|
37
|
+
a++;
|
|
38
|
+
for (let e = 0; e < 3; e++) t.min[e] < r[e] && (r[e] = t.min[e]), t.max[e] > i[e] && (i[e] = t.max[e]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (a === 0) throw Error("measureSelection: empty island selection");
|
|
42
|
+
return {
|
|
43
|
+
center: [
|
|
44
|
+
(r[0] + i[0]) * .5,
|
|
45
|
+
(r[1] + i[1]) * .5,
|
|
46
|
+
(r[2] + i[2]) * .5
|
|
47
|
+
],
|
|
48
|
+
min: r,
|
|
49
|
+
max: i,
|
|
50
|
+
radius: Math.max(i[1] - r[1], i[2] - r[2]) * .5,
|
|
51
|
+
halfWidth: (i[0] - r[0]) * .5
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function L(e) {
|
|
55
|
+
let t = Math.max(e.size[1], e.size[2], 1e-5), n = Math.min(e.size[1], e.size[2]) / t, r = t / Math.max(e.size[0], 1e-5);
|
|
56
|
+
return n >= .56 && r >= 1.25;
|
|
57
|
+
}
|
|
58
|
+
function Te(e, t, n) {
|
|
59
|
+
let r = t, i = Math.max(t.size[1], t.size[2]);
|
|
60
|
+
for (let a of e) {
|
|
61
|
+
if (a.id === t.id || n?.has(a.id) || !L(a)) continue;
|
|
62
|
+
let e = Math.max(a.size[1], a.size[2]);
|
|
63
|
+
if (!(e <= i * 1.32 || e > 1.3) && Math.hypot(a.center[0] - t.center[0], a.center[1] - t.center[1], a.center[2] - t.center[2]) <= e * .45) {
|
|
64
|
+
r = a;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let a = Math.max(r.size[1], r.size[2]) * .5, o = a * .16, s = Math.abs(r.center[0]) > r.size[0] * .5, c = [r.id];
|
|
69
|
+
for (let t of e) {
|
|
70
|
+
if (t.id === r.id || n?.has(t.id) || s && t.min[0] < 0 && t.max[0] > 0) continue;
|
|
71
|
+
let e = Math.max(t.size[1], t.size[2]);
|
|
72
|
+
e > a * 2.1 && e / Math.max(t.size[0], 1e-4) < 1.75 || [
|
|
73
|
+
0,
|
|
74
|
+
1,
|
|
75
|
+
2
|
|
76
|
+
].some((e) => t.min[e] < r.min[e] - o || t.max[e] > r.max[e] + o) || Math.hypot(t.center[1] - r.center[1], t.center[2] - r.center[2]) <= a + o && c.push(t.id);
|
|
77
|
+
}
|
|
78
|
+
return c;
|
|
79
|
+
}
|
|
80
|
+
function Ee(e) {
|
|
81
|
+
if (e.length === 0) return [];
|
|
82
|
+
let t = Infinity, n = Infinity, r = -Infinity;
|
|
83
|
+
for (let i of e) t = Math.min(t, i.min[1]), n = Math.min(n, i.min[2]), r = Math.max(r, i.max[2]);
|
|
84
|
+
let i = Math.max(r - n, 1e-6), a = (e) => Math.max(e.size[1], e.size[2]), o = e.filter((e) => {
|
|
85
|
+
let n = a(e);
|
|
86
|
+
return L(e) && n >= i * .06 && n <= i * .6 && e.min[1] <= t + n * .18 && Math.abs(e.center[0]) > e.size[0] * .45;
|
|
87
|
+
}).sort((e, t) => a(t) - a(e)), s = /* @__PURE__ */ new Set(), c = [];
|
|
88
|
+
for (let t of o) {
|
|
89
|
+
if (s.has(t.id)) continue;
|
|
90
|
+
let n = Math.max(...t.size, 1e-6), r = t.size[0] + t.size[1] + t.size[2] || 1e-6, i = o.filter((e) => e.id !== t.id && !s.has(e.id)).map((e) => ({
|
|
91
|
+
c: e,
|
|
92
|
+
s: Math.hypot(e.center[0] + t.center[0], e.center[1] - t.center[1], e.center[2] - t.center[2]) / n + (Math.abs(e.size[0] - t.size[0]) + Math.abs(e.size[1] - t.size[1]) + Math.abs(e.size[2] - t.size[2])) / r
|
|
93
|
+
})).filter((e) => e.s < .65).sort((e, t) => e.s - t.s)[0]?.c;
|
|
94
|
+
if (!i) continue;
|
|
95
|
+
s.add(t.id), s.add(i.id);
|
|
96
|
+
let a = Te(e, t, s), l = Te(e, i, s);
|
|
97
|
+
a.forEach((e) => s.add(e)), l.forEach((e) => s.add(e)), c.push(t.center[0] >= 0 ? {
|
|
98
|
+
left: a,
|
|
99
|
+
right: l
|
|
100
|
+
} : {
|
|
101
|
+
left: l,
|
|
102
|
+
right: a
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return c.sort((t, n) => I(e, [...n.left, ...n.right]).center[2] - I(e, [...t.left, ...t.right]).center[2]);
|
|
106
|
+
}
|
|
107
|
+
function De(e) {
|
|
108
|
+
if (e.length === 0) return [];
|
|
109
|
+
let t = Infinity, n = Infinity, r = -Infinity;
|
|
110
|
+
for (let i of e) t = Math.min(t, i.min[1]), n = Math.min(n, i.min[2]), r = Math.max(r, i.max[2]);
|
|
111
|
+
let i = Math.max(r - n, 1e-6), a = (e) => Math.max(e.size[1], e.size[2]), o = e.filter((e) => {
|
|
112
|
+
let n = a(e);
|
|
113
|
+
return Math.abs(e.center[0]) < .15 * i && n >= i * .12 && n <= i * .55 && Math.abs(e.size[1] - e.size[2]) <= n * .25 && e.size[0] <= n * .85 && e.min[1] <= t + n * .24;
|
|
114
|
+
}).sort((e, t) => a(t) - a(e)), s = o.find((e) => e.center[2] > 0), c = o.find((e) => e.center[2] < 0 && e.id !== s?.id), l = /* @__PURE__ */ new Set(), u = [];
|
|
115
|
+
if (s) {
|
|
116
|
+
let t = Te(e, s, l);
|
|
117
|
+
t.forEach((e) => l.add(e)), u.push({
|
|
118
|
+
left: t,
|
|
119
|
+
right: [],
|
|
120
|
+
steered: !0,
|
|
121
|
+
driven: !1,
|
|
122
|
+
brake: !0
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (c) {
|
|
126
|
+
let t = Te(e, c, l);
|
|
127
|
+
t.forEach((e) => l.add(e)), u.push({
|
|
128
|
+
left: t,
|
|
129
|
+
right: [],
|
|
130
|
+
steered: !1,
|
|
131
|
+
driven: !0,
|
|
132
|
+
brake: !0
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return u;
|
|
136
|
+
}
|
|
137
|
+
function Oe(e, t, n, r) {
|
|
138
|
+
let i = t.findIndex((e) => e.left.includes(n) || e.right.includes(n));
|
|
139
|
+
if (i >= 0) return t.filter((e, t) => t !== i);
|
|
140
|
+
let a = e.find((e) => e.id === n);
|
|
141
|
+
if (!a) return [...t];
|
|
142
|
+
let o = Te(e, a), s = e.find((e) => e.id === o[0]) ?? a;
|
|
143
|
+
if (r === "motorcycle") return [...t, {
|
|
144
|
+
left: o,
|
|
145
|
+
right: [],
|
|
146
|
+
steered: s.center[2] >= 0,
|
|
147
|
+
driven: s.center[2] < 0,
|
|
148
|
+
brake: !0
|
|
149
|
+
}].sort((t, n) => I(e, n.left).center[2] - I(e, t.left).center[2]);
|
|
150
|
+
let c = e.filter((e) => !o.includes(e.id)).sort((e, t) => Math.hypot(e.center[0] + s.center[0], e.center[1] - s.center[1], e.center[2] - s.center[2]) - Math.hypot(t.center[0] + s.center[0], t.center[1] - s.center[1], t.center[2] - s.center[2]))[0], l = c && Math.hypot(c.center[0] + s.center[0], c.center[1] - s.center[1], c.center[2] - s.center[2]) < Math.max(...s.size) * .45 ? Te(e, c) : [], u = l.length > 0 ? s.center[0] >= 0 ? {
|
|
151
|
+
left: o,
|
|
152
|
+
right: l
|
|
153
|
+
} : {
|
|
154
|
+
left: l,
|
|
155
|
+
right: o
|
|
156
|
+
} : {
|
|
157
|
+
left: o,
|
|
158
|
+
right: []
|
|
159
|
+
};
|
|
160
|
+
return [...t, u].sort((t, n) => I(e, [...n.left, ...n.right]).center[2] - I(e, [...t.left, ...t.right]).center[2]);
|
|
161
|
+
}
|
|
162
|
+
// src/importer/meshIslands.ts
|
|
163
|
+
var ke = class {
|
|
164
|
+
p;
|
|
165
|
+
constructor(e) {
|
|
166
|
+
this.p = new Int32Array(e);
|
|
167
|
+
for (let t = 0; t < e; t++) this.p[t] = t;
|
|
168
|
+
}
|
|
169
|
+
find(e) {
|
|
170
|
+
let t = e;
|
|
171
|
+
for (; this.p[t] !== t;) t = this.p[t];
|
|
172
|
+
for (let n = e; n !== t;) {
|
|
173
|
+
let e = this.p[n];
|
|
174
|
+
this.p[n] = t, n = e;
|
|
175
|
+
}
|
|
176
|
+
return t;
|
|
177
|
+
}
|
|
178
|
+
union(e, t) {
|
|
179
|
+
let n = this.find(e), r = this.find(t);
|
|
180
|
+
n !== r && (this.p[r] = n);
|
|
181
|
+
}
|
|
182
|
+
}, Ae = (e) => (Array.isArray(e.material) ? e.material[0] : e.material) ?? new p.MeshStandardMaterial({ color: "#cbd5e1" });
|
|
183
|
+
function je(e, t) {
|
|
184
|
+
let n = e.clone(), r = t.determinant() < 0;
|
|
185
|
+
if (n.applyMatrix4(t), r) {
|
|
186
|
+
let e = n.getIndex(), t = n.getAttribute("position")?.count ?? 0;
|
|
187
|
+
if (e) {
|
|
188
|
+
let t = e.array;
|
|
189
|
+
for (let e = 0; e + 2 < t.length; e += 3) {
|
|
190
|
+
let n = t[e + 1];
|
|
191
|
+
t[e + 1] = t[e + 2], t[e + 2] = n;
|
|
192
|
+
}
|
|
193
|
+
e.needsUpdate = !0;
|
|
194
|
+
} else {
|
|
195
|
+
let e = new Uint32Array(t);
|
|
196
|
+
for (let n = 0; n + 2 < t; n += 3) e[n] = n, e[n + 1] = n + 2, e[n + 2] = n + 1;
|
|
197
|
+
n.setIndex(new p.BufferAttribute(e, 1));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return n.getAttribute("normal") || n.computeVertexNormals(), n.computeBoundingBox(), n.computeBoundingSphere(), n;
|
|
201
|
+
}
|
|
202
|
+
function Me(e, t) {
|
|
203
|
+
let n = t.turns ?? [
|
|
204
|
+
0,
|
|
205
|
+
0,
|
|
206
|
+
0
|
|
207
|
+
], r = t.axis ?? "lengthZ";
|
|
208
|
+
if (!(t.targetMeters > 0)) throw Error(`normalizeSceneToSi: invalid targetMeters ${t.targetMeters}`);
|
|
209
|
+
let i = e.clone(!0), a = new p.Group();
|
|
210
|
+
a.quaternion.setFromEuler(new p.Euler(n[0] * Math.PI * .5, n[1] * Math.PI * .5, n[2] * Math.PI * .5, "XYZ")), a.add(i), a.updateMatrixWorld(!0);
|
|
211
|
+
let o = new p.Box3().setFromObject(a);
|
|
212
|
+
if (o.isEmpty()) throw Error("normalizeSceneToSi: empty scene bounds");
|
|
213
|
+
let s = o.getSize(new p.Vector3()), c = o.getCenter(new p.Vector3()), l = r === "widthX" ? s.x : r === "heightY" ? s.y : r === "lengthZ" ? s.z : Math.max(s.x, s.y, s.z), u = t.targetMeters / Math.max(l, 1e-5), d = new p.Matrix4().makeTranslation(-c.x * u, -o.min.y * u, -c.z * u).multiply(new p.Matrix4().makeScale(u, u, u)), f = new p.Group();
|
|
214
|
+
f.name = e.name || "KolmoAsset";
|
|
215
|
+
let m = new p.Matrix4(), h = new p.Vector3();
|
|
216
|
+
i.traverse((e) => {
|
|
217
|
+
if (e !== i) {
|
|
218
|
+
if (e instanceof p.Mesh && e.geometry) {
|
|
219
|
+
let t = new p.Mesh(je(e.geometry, m.multiplyMatrices(d, e.matrixWorld)), e.material);
|
|
220
|
+
t.name = e.name, t.userData = { ...e.userData }, f.add(t);
|
|
221
|
+
} else if (e.children.length === 0 && e.name) {
|
|
222
|
+
let t = new p.Object3D();
|
|
223
|
+
t.name = e.name, t.userData = { ...e.userData }, t.position.copy(e.getWorldPosition(h).applyMatrix4(d)), f.add(t);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}), f.updateMatrixWorld(!0);
|
|
227
|
+
let g = new p.Box3().setFromObject(f).getSize(new p.Vector3());
|
|
228
|
+
return {
|
|
229
|
+
scene: f,
|
|
230
|
+
sizeMeters: [
|
|
231
|
+
g.x,
|
|
232
|
+
g.y,
|
|
233
|
+
g.z
|
|
234
|
+
],
|
|
235
|
+
scaleApplied: u
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function R(e, t, n = [
|
|
239
|
+
0,
|
|
240
|
+
0,
|
|
241
|
+
0
|
|
242
|
+
]) {
|
|
243
|
+
let r = e.getIndex(), i = t.length, a = new p.BufferGeometry();
|
|
244
|
+
for (let o of Object.keys(e.attributes)) {
|
|
245
|
+
let s = e.getAttribute(o);
|
|
246
|
+
if (!s) continue;
|
|
247
|
+
let c = s.itemSize, l = new Float32Array(i * 3 * c), u = o === "position";
|
|
248
|
+
for (let e = 0; e < i; e++) {
|
|
249
|
+
let i = t[e];
|
|
250
|
+
for (let t = 0; t < 3; t++) {
|
|
251
|
+
let a = r ? r.getX(i * 3 + t) : i * 3 + t, o = (e * 3 + t) * c;
|
|
252
|
+
if (u) l[o] = s.getX(a) + n[0], l[o + 1] = s.getY(a) + n[1], l[o + 2] = s.getZ(a) + n[2];
|
|
253
|
+
else for (let e = 0; e < c; e++) l[o + e] = s.getComponent(a, e);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
a.setAttribute(o, new p.BufferAttribute(l, c));
|
|
257
|
+
}
|
|
258
|
+
return a.computeBoundingBox(), a.computeBoundingSphere(), a;
|
|
259
|
+
}
|
|
260
|
+
function Ne(e, t = 1e-4) {
|
|
261
|
+
let n = 1 / Math.max(1e-7, t);
|
|
262
|
+
e.updateMatrixWorld(!0);
|
|
263
|
+
let r = new p.Matrix4().copy(e.matrixWorld).invert(), i = new p.Matrix4(), a = [], o = 0;
|
|
264
|
+
return e.traverse((e) => {
|
|
265
|
+
if (!(e instanceof p.Mesh) || !e.geometry) return;
|
|
266
|
+
let t = e.geometry.getAttribute("position");
|
|
267
|
+
if (!t || t.count < 3) return;
|
|
268
|
+
let s = je(e.geometry, i.multiplyMatrices(r, e.matrixWorld)), c = s.getAttribute("position"), l = s.getIndex(), u = Math.floor(l ? l.count / 3 : c.count / 3);
|
|
269
|
+
if (u === 0) return;
|
|
270
|
+
let d = new ke(u), f = /* @__PURE__ */ new Map();
|
|
271
|
+
for (let e = 0; e < u; e++) for (let t = 0; t < 3; t++) {
|
|
272
|
+
let r = l ? l.getX(e * 3 + t) : e * 3 + t, i = `${Math.round(c.getX(r) * n)},${Math.round(c.getY(r) * n)},${Math.round(c.getZ(r) * n)}`, a = f.get(i);
|
|
273
|
+
a === void 0 ? f.set(i, e) : d.union(e, a);
|
|
274
|
+
}
|
|
275
|
+
let m = /* @__PURE__ */ new Map();
|
|
276
|
+
for (let e = 0; e < u; e++) {
|
|
277
|
+
let t = d.find(e), n = m.get(t);
|
|
278
|
+
n || (n = [], m.set(t, n)), n.push(e);
|
|
279
|
+
}
|
|
280
|
+
let h = Ae(e);
|
|
281
|
+
for (let t of m.values()) {
|
|
282
|
+
let n = new Uint32Array(t), r = R(s, n), i = r.boundingBox, c = [
|
|
283
|
+
i.min.x,
|
|
284
|
+
i.min.y,
|
|
285
|
+
i.min.z
|
|
286
|
+
], l = [
|
|
287
|
+
i.max.x,
|
|
288
|
+
i.max.y,
|
|
289
|
+
i.max.z
|
|
290
|
+
];
|
|
291
|
+
a.push({
|
|
292
|
+
id: o++,
|
|
293
|
+
mesh: e,
|
|
294
|
+
geometry: r,
|
|
295
|
+
material: h,
|
|
296
|
+
triangleIndices: n,
|
|
297
|
+
min: c,
|
|
298
|
+
max: l,
|
|
299
|
+
size: [
|
|
300
|
+
l[0] - c[0],
|
|
301
|
+
l[1] - c[1],
|
|
302
|
+
l[2] - c[2]
|
|
303
|
+
],
|
|
304
|
+
center: [
|
|
305
|
+
(c[0] + l[0]) * .5,
|
|
306
|
+
(c[1] + l[1]) * .5,
|
|
307
|
+
(c[2] + l[2]) * .5
|
|
308
|
+
]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}), a;
|
|
312
|
+
}
|
|
313
|
+
function z(e, t, n, r = []) {
|
|
314
|
+
e.updateMatrixWorld(!0);
|
|
315
|
+
let i = new p.Matrix4().copy(e.matrixWorld).invert(), a = new p.Matrix4(), o = new Map(t.map((e) => [e.id, e])), s = /* @__PURE__ */ new Map(), c = (e) => {
|
|
316
|
+
let t = s.get(e);
|
|
317
|
+
return t || (t = je(e.geometry, a.multiplyMatrices(i, e.matrixWorld)), s.set(e, t)), t;
|
|
318
|
+
}, l = /* @__PURE__ */ new Map(), u = [], d = [];
|
|
319
|
+
for (let e of n) {
|
|
320
|
+
let t = e.islandIds.map((e) => o.get(e)).filter((e) => !!e);
|
|
321
|
+
if (t.length === 0) continue;
|
|
322
|
+
let n = [
|
|
323
|
+
Infinity,
|
|
324
|
+
Infinity,
|
|
325
|
+
Infinity
|
|
326
|
+
], r = [
|
|
327
|
+
-Infinity,
|
|
328
|
+
-Infinity,
|
|
329
|
+
-Infinity
|
|
330
|
+
], i = /* @__PURE__ */ new Map();
|
|
331
|
+
for (let e of t) {
|
|
332
|
+
for (let t = 0; t < 3; t++) n[t] = Math.min(n[t], e.min[t]), r[t] = Math.max(r[t], e.max[t]);
|
|
333
|
+
let t = i.get(e.mesh);
|
|
334
|
+
t || (t = [], i.set(e.mesh, t));
|
|
335
|
+
let a = l.get(e.mesh);
|
|
336
|
+
a || (a = /* @__PURE__ */ new Set(), l.set(e.mesh, a));
|
|
337
|
+
for (let n = 0; n < e.triangleIndices.length; n++) {
|
|
338
|
+
let r = e.triangleIndices[n];
|
|
339
|
+
t.push(r), a.add(r);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
let a = [
|
|
343
|
+
(n[0] + r[0]) * .5,
|
|
344
|
+
(n[1] + r[1]) * .5,
|
|
345
|
+
(n[2] + r[2]) * .5
|
|
346
|
+
], s = new p.Group();
|
|
347
|
+
s.name = e.nodeName, s.position.set(a[0], a[1], a[2]);
|
|
348
|
+
let d = 0;
|
|
349
|
+
for (let [t, n] of i) {
|
|
350
|
+
let r = new p.Mesh(R(c(t), n, [
|
|
351
|
+
-a[0],
|
|
352
|
+
-a[1],
|
|
353
|
+
-a[2]
|
|
354
|
+
]), Ae(t));
|
|
355
|
+
r.name = `${e.nodeName}_mesh_${d++}`, s.add(r);
|
|
356
|
+
}
|
|
357
|
+
u.push({
|
|
358
|
+
nodeName: e.nodeName,
|
|
359
|
+
center: a,
|
|
360
|
+
group: s
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
for (let e of r) {
|
|
364
|
+
let t = e.islandIds.map((e) => o.get(e)).filter((e) => !!e);
|
|
365
|
+
if (t.length === 0) continue;
|
|
366
|
+
let n = [
|
|
367
|
+
Infinity,
|
|
368
|
+
Infinity,
|
|
369
|
+
Infinity
|
|
370
|
+
], r = [
|
|
371
|
+
-Infinity,
|
|
372
|
+
-Infinity,
|
|
373
|
+
-Infinity
|
|
374
|
+
], i = /* @__PURE__ */ new Map();
|
|
375
|
+
for (let e of t) {
|
|
376
|
+
for (let t = 0; t < 3; t++) n[t] = Math.min(n[t], e.min[t]), r[t] = Math.max(r[t], e.max[t]);
|
|
377
|
+
let t = i.get(e.mesh);
|
|
378
|
+
t || (t = [], i.set(e.mesh, t));
|
|
379
|
+
let a = l.get(e.mesh);
|
|
380
|
+
a || (a = /* @__PURE__ */ new Set(), l.set(e.mesh, a));
|
|
381
|
+
for (let n = 0; n < e.triangleIndices.length; n++) {
|
|
382
|
+
let r = e.triangleIndices[n];
|
|
383
|
+
t.push(r), a.add(r);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
let a = [
|
|
387
|
+
(n[0] + r[0]) * .5,
|
|
388
|
+
(n[1] + r[1]) * .5,
|
|
389
|
+
(n[2] + r[2]) * .5
|
|
390
|
+
], s = [
|
|
391
|
+
Math.max(.05, r[0] - n[0]),
|
|
392
|
+
Math.max(.05, r[1] - n[1]),
|
|
393
|
+
Math.max(.05, r[2] - n[2])
|
|
394
|
+
], [u, f, m] = e.anchor, h = new p.Group();
|
|
395
|
+
h.name = e.nodeName, h.position.set(u, f, m);
|
|
396
|
+
let g = 0;
|
|
397
|
+
for (let [t, n] of i) {
|
|
398
|
+
let r = new p.Mesh(R(c(t), n, [
|
|
399
|
+
-u,
|
|
400
|
+
-f,
|
|
401
|
+
-m
|
|
402
|
+
]), Ae(t));
|
|
403
|
+
r.name = `${e.nodeName}_skin_${g++}`, h.add(r);
|
|
404
|
+
}
|
|
405
|
+
d.push({
|
|
406
|
+
nodeName: e.nodeName,
|
|
407
|
+
anchor: [
|
|
408
|
+
u,
|
|
409
|
+
f,
|
|
410
|
+
m
|
|
411
|
+
],
|
|
412
|
+
center: a,
|
|
413
|
+
size: s,
|
|
414
|
+
group: h
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
let f = new p.Group();
|
|
418
|
+
f.name = "ChassisVisuals";
|
|
419
|
+
let m = 0;
|
|
420
|
+
e.traverse((e) => {
|
|
421
|
+
if (!(e instanceof p.Mesh) || !e.geometry) return;
|
|
422
|
+
let t = c(e), n = t.getAttribute("position"), r = t.getIndex(), i = Math.floor(r ? r.count / 3 : (n?.count ?? 0) / 3), a = l.get(e);
|
|
423
|
+
if (i === 0 || a && a.size >= i) return;
|
|
424
|
+
let o = [];
|
|
425
|
+
for (let e = 0; e < i; e++) a && a.has(e) || o.push(e);
|
|
426
|
+
if (o.length > 0) {
|
|
427
|
+
let n = new p.Mesh(R(t, o), Ae(e));
|
|
428
|
+
n.name = `Body_mesh_${m++}`, f.add(n);
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
let h = new p.Box3().setFromObject(e), g = h.getSize(new p.Vector3()), _ = h.getCenter(new p.Vector3());
|
|
432
|
+
return {
|
|
433
|
+
wheels: u,
|
|
434
|
+
panels: d,
|
|
435
|
+
chassisGroup: f,
|
|
436
|
+
fullBounds: {
|
|
437
|
+
min: [
|
|
438
|
+
h.min.x,
|
|
439
|
+
h.min.y,
|
|
440
|
+
h.min.z
|
|
441
|
+
],
|
|
442
|
+
max: [
|
|
443
|
+
h.max.x,
|
|
444
|
+
h.max.y,
|
|
445
|
+
h.max.z
|
|
446
|
+
],
|
|
447
|
+
center: [
|
|
448
|
+
_.x,
|
|
449
|
+
_.y,
|
|
450
|
+
_.z
|
|
451
|
+
],
|
|
452
|
+
size: [
|
|
453
|
+
g.x,
|
|
454
|
+
h.max.y - h.min.y,
|
|
455
|
+
g.z
|
|
456
|
+
]
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
// src/importer/surfaceTopology.ts
|
|
461
|
+
var Pe = [
|
|
462
|
+
{
|
|
463
|
+
role: "wheel",
|
|
464
|
+
label: "Wheel / Tire",
|
|
465
|
+
color: "#00E5FF",
|
|
466
|
+
massKg: 22
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
role: "door",
|
|
470
|
+
label: "Door (Hinge)",
|
|
471
|
+
color: "#FFB000",
|
|
472
|
+
massKg: 24
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
role: "hood",
|
|
476
|
+
label: "Hood (Hinge)",
|
|
477
|
+
color: "#10B981",
|
|
478
|
+
massKg: 18
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
role: "trunk",
|
|
482
|
+
label: "Trunk / Gate",
|
|
483
|
+
color: "#A855F7",
|
|
484
|
+
massKg: 16
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
role: "fender",
|
|
488
|
+
label: "Fender Panel",
|
|
489
|
+
color: "#F43F5E",
|
|
490
|
+
massKg: 11
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
role: "bumper",
|
|
494
|
+
label: "Bumper Cover",
|
|
495
|
+
color: "#38BDF8",
|
|
496
|
+
massKg: 12
|
|
497
|
+
}
|
|
498
|
+
], B = 2 ** 26, V = .65, Fe = /* @__PURE__ */ new WeakMap(), Ie = (e, t) => e < t ? e * B + t : t * B + e, Le = (e, t, n) => `${Math.round(e * 1e4)},${Math.round(t * 1e4)},${Math.round(n * 1e4)}`;
|
|
499
|
+
function Re(e) {
|
|
500
|
+
let t = Fe.get(e.geometry);
|
|
501
|
+
if (t) return t;
|
|
502
|
+
let n = ze(e.geometry);
|
|
503
|
+
return Fe.set(e.geometry, n), n;
|
|
504
|
+
}
|
|
505
|
+
function ze(e) {
|
|
506
|
+
let t = e.getAttribute("position"), n = e.getIndex(), r = t ? n ? n.count : t.count : 0, i = Math.floor(r / 3), a = new Uint32Array(i * 3), o = /* @__PURE__ */ new Map(), s = [];
|
|
507
|
+
for (let e = 0; e < i * 3; e++) {
|
|
508
|
+
let r = n ? n.getX(e) : e, i = t.getX(r), c = t.getY(r), l = t.getZ(r), u = Le(i, c, l), d = o.get(u);
|
|
509
|
+
d === void 0 && (d = o.size, o.set(u, d), s.push(i, c, l)), a[e] = d;
|
|
510
|
+
}
|
|
511
|
+
let c = Float32Array.from(s), l = o.size, u = new Float32Array(i * 3), d = new Float32Array(i), f = /* @__PURE__ */ new Map(), m = Array.from({ length: l }, () => /* @__PURE__ */ new Set()), h = new p.Vector3(), g = new p.Vector3(), _ = new p.Vector3(), v = new p.Vector3();
|
|
512
|
+
for (let e = 0; e < i; e++) {
|
|
513
|
+
let t = a[e * 3], n = a[e * 3 + 1], r = a[e * 3 + 2];
|
|
514
|
+
h.fromArray(c, t * 3), g.fromArray(c, n * 3), _.fromArray(c, r * 3), v.crossVectors(g.sub(h), _.sub(h));
|
|
515
|
+
let i = v.length();
|
|
516
|
+
d[e] = i * .5, i > 0 && v.divideScalar(i).toArray(u, e * 3);
|
|
517
|
+
for (let [i, a] of [
|
|
518
|
+
[t, n],
|
|
519
|
+
[n, r],
|
|
520
|
+
[r, t]
|
|
521
|
+
]) {
|
|
522
|
+
if (i === a) continue;
|
|
523
|
+
let t = Ie(i, a), n = f.get(t);
|
|
524
|
+
n ? n.push(e) : f.set(t, [e]), m[i].add(a), m[a].add(i);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
geometry: e,
|
|
529
|
+
triangleCount: i,
|
|
530
|
+
vertexCount: l,
|
|
531
|
+
corners: a,
|
|
532
|
+
points: c,
|
|
533
|
+
normals: u,
|
|
534
|
+
areas: d,
|
|
535
|
+
edgeTriangles: f,
|
|
536
|
+
neighbors: m.map((e) => [...e])
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function Be(e, t, n) {
|
|
540
|
+
if (t < 0 || t >= e.triangleCount) return [];
|
|
541
|
+
let r = new Uint8Array(e.triangleCount), i = [t];
|
|
542
|
+
r[t] = 1;
|
|
543
|
+
for (let t = 0; t < i.length; t++) {
|
|
544
|
+
let a = i[t];
|
|
545
|
+
for (let t = 0; t < 3; t++) {
|
|
546
|
+
let o = e.corners[a * 3 + t], s = e.corners[a * 3 + (t + 1) % 3];
|
|
547
|
+
if (o === s) continue;
|
|
548
|
+
let c = Ie(o, s);
|
|
549
|
+
for (let t of e.edgeTriangles.get(c) ?? []) !r[t] && n(c, a, t) && (r[t] = 1, i.push(t));
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return i.sort((e, t) => e - t);
|
|
553
|
+
}
|
|
554
|
+
function Ve(e, t, n = 32) {
|
|
555
|
+
let r = Math.cos(n * Math.PI / 180), i = e.normals;
|
|
556
|
+
return Be(e, t, (e, t, n) => i[t * 3] * i[n * 3] + i[t * 3 + 1] * i[n * 3 + 1] + i[t * 3 + 2] * i[n * 3 + 2] >= r);
|
|
557
|
+
}
|
|
558
|
+
function He(e, t, n = .03) {
|
|
559
|
+
let r = Math.max(n, 1e-4), i = (e, t, n) => `${Math.floor(e / r)},${Math.floor(t / r)},${Math.floor(n / r)}`, a = /* @__PURE__ */ new Map(), o = new Float32Array(e.triangleCount * 3);
|
|
560
|
+
for (let t = 0; t < e.triangleCount; t++) {
|
|
561
|
+
let n = 0, r = 0, s = 0;
|
|
562
|
+
for (let i = 0; i < 3; i++) {
|
|
563
|
+
let a = e.corners[t * 3 + i] * 3;
|
|
564
|
+
n += e.points[a], r += e.points[a + 1], s += e.points[a + 2];
|
|
565
|
+
}
|
|
566
|
+
n /= 3, r /= 3, s /= 3, o[t * 3] = n, o[t * 3 + 1] = r, o[t * 3 + 2] = s;
|
|
567
|
+
let c = i(n, r, s), l = a.get(c);
|
|
568
|
+
l ? l.push(t) : a.set(c, [t]);
|
|
569
|
+
}
|
|
570
|
+
let s = new Set(t), c = /* @__PURE__ */ new Set();
|
|
571
|
+
for (let e of s) {
|
|
572
|
+
let t = -o[e * 3], l = o[e * 3 + 1], u = o[e * 3 + 2], d = -1, f = n;
|
|
573
|
+
for (let n = -1; n <= 1; n++) for (let c = -1; c <= 1; c++) for (let p = -1; p <= 1; p++) for (let m of a.get(i(t + n * r, l + c * r, u + p * r)) ?? []) {
|
|
574
|
+
if (m === e || s.has(m)) continue;
|
|
575
|
+
let n = Math.hypot(o[m * 3] - t, o[m * 3 + 1] - l, o[m * 3 + 2] - u);
|
|
576
|
+
n <= f && (f = n, d = m);
|
|
577
|
+
}
|
|
578
|
+
d >= 0 && c.add(d);
|
|
579
|
+
}
|
|
580
|
+
return [...c].sort((e, t) => e - t);
|
|
581
|
+
}
|
|
582
|
+
function Ue(e, t, n) {
|
|
583
|
+
let r = e.points;
|
|
584
|
+
return Math.hypot(r[t * 3] - r[n * 3], r[t * 3 + 1] - r[n * 3 + 1], r[t * 3 + 2] - r[n * 3 + 2]);
|
|
585
|
+
}
|
|
586
|
+
function We(e, t, n) {
|
|
587
|
+
let r = e.edgeTriangles.get(Ie(t, n)), i = 1;
|
|
588
|
+
if (r && r.length === 2) {
|
|
589
|
+
let t = e.normals, n = r[0], a = r[1], o = t[n * 3] * t[a * 3] + t[n * 3 + 1] * t[a * 3 + 1] + t[n * 3 + 2] * t[a * 3 + 2];
|
|
590
|
+
i = Math.min(1, Math.acos(Math.max(-1, Math.min(1, o))) / (Math.PI / 2));
|
|
591
|
+
}
|
|
592
|
+
return Ue(e, t, n) * (1 - V * i);
|
|
593
|
+
}
|
|
594
|
+
function Ge(e, t) {
|
|
595
|
+
let n = 0, r = Infinity;
|
|
596
|
+
for (let i = 0; i < e.vertexCount; i++) {
|
|
597
|
+
let a = (e.points[i * 3] - t[0]) ** 2 + (e.points[i * 3 + 1] - t[1]) ** 2 + (e.points[i * 3 + 2] - t[2]) ** 2;
|
|
598
|
+
a < r && (r = a, n = i);
|
|
599
|
+
}
|
|
600
|
+
return n;
|
|
601
|
+
}
|
|
602
|
+
function Ke(e, t, n, r, i = We) {
|
|
603
|
+
if (t === n) return [t];
|
|
604
|
+
let a = new Float64Array(e.vertexCount).fill(Infinity), o = new Int32Array(e.vertexCount).fill(-1), s = [[0, t]];
|
|
605
|
+
a[t] = 0;
|
|
606
|
+
let c = (e) => {
|
|
607
|
+
s.push(e);
|
|
608
|
+
for (let e = s.length - 1; e > 0;) {
|
|
609
|
+
let t = e - 1 >> 1;
|
|
610
|
+
if (s[t][0] <= s[e][0]) break;
|
|
611
|
+
[s[t], s[e]] = [s[e], s[t]], e = t;
|
|
612
|
+
}
|
|
613
|
+
}, l = () => {
|
|
614
|
+
let e = s[0], t = s.pop();
|
|
615
|
+
if (s.length > 0) {
|
|
616
|
+
s[0] = t;
|
|
617
|
+
for (let e = 0;;) {
|
|
618
|
+
let t = e * 2 + 1, n = t + 1, r = e;
|
|
619
|
+
if (t < s.length && s[t][0] < s[r][0] && (r = t), n < s.length && s[n][0] < s[r][0] && (r = n), r === e) break;
|
|
620
|
+
[s[r], s[e]] = [s[e], s[r]], e = r;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return e;
|
|
624
|
+
};
|
|
625
|
+
for (; s.length > 0;) {
|
|
626
|
+
let [t, s] = l();
|
|
627
|
+
if (!(t > a[s])) {
|
|
628
|
+
if (s === n) break;
|
|
629
|
+
for (let l of e.neighbors[s]) {
|
|
630
|
+
if (l !== n && r?.has(l)) continue;
|
|
631
|
+
let u = t + i(e, s, l);
|
|
632
|
+
u < a[l] && (a[l] = u, o[l] = s, c([u, l]));
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!Number.isFinite(a[n])) return null;
|
|
637
|
+
let u = [n];
|
|
638
|
+
for (let e = n; e !== t;) e = o[e], u.push(e);
|
|
639
|
+
return u.reverse();
|
|
640
|
+
}
|
|
641
|
+
// src/importer/surfaceCutter.ts
|
|
642
|
+
function qe(e, t) {
|
|
643
|
+
let n = 0, r = 0;
|
|
644
|
+
for (let i of t) {
|
|
645
|
+
let t = e.areas[i];
|
|
646
|
+
for (let r = 0; r < 3; r++) n += e.points[e.corners[i * 3 + r] * 3] * t / 3;
|
|
647
|
+
r += t;
|
|
648
|
+
}
|
|
649
|
+
return r > 0 ? n / r : 0;
|
|
650
|
+
}
|
|
651
|
+
function Je(e, t, n) {
|
|
652
|
+
let r = Re(e), i = [...new Set(t)].sort((e, t) => e - t), a = n && Math.abs(qe(r, i)) > .08 ? He(r, i) : [];
|
|
653
|
+
return {
|
|
654
|
+
islandId: e.id,
|
|
655
|
+
triangles: i,
|
|
656
|
+
mirrored: a
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function Ye(e, t, n, r) {
|
|
660
|
+
let i = Re(e), a = n === "crease" ? Ve(i, t, r.creaseDeg) : [t], o = r.current?.islandId === e.id ? new Set(r.current.triangles) : /* @__PURE__ */ new Set();
|
|
661
|
+
for (let e of a) r.remove ? o.delete(e) : o.add(e);
|
|
662
|
+
return Je(e, [...o], r.mirrorX);
|
|
663
|
+
}
|
|
664
|
+
function Xe(e, t) {
|
|
665
|
+
if (t.length < 2) return t.map((e) => [
|
|
666
|
+
e[0],
|
|
667
|
+
e[1],
|
|
668
|
+
e[2]
|
|
669
|
+
]);
|
|
670
|
+
let n = Re(e), r = t.map((e) => Ge(n, e)), i = [], a = t.length >= 3 ? r.length : r.length - 1;
|
|
671
|
+
for (let e = 0; e < a; e++) {
|
|
672
|
+
let o = Ke(n, r[e], r[(e + 1) % r.length]) ?? [r[e], r[(e + 1) % r.length]];
|
|
673
|
+
for (let r of o.slice(0, e === a - 1 && t.length < 3 ? void 0 : -1)) i.push([
|
|
674
|
+
n.points[r * 3],
|
|
675
|
+
n.points[r * 3 + 1],
|
|
676
|
+
n.points[r * 3 + 2]
|
|
677
|
+
]);
|
|
678
|
+
}
|
|
679
|
+
return t.length >= 3 && i.length > 0 && i.push([...i[0]]), i;
|
|
680
|
+
}
|
|
681
|
+
function Ze(e, t, n) {
|
|
682
|
+
if (t.length < 3) throw Error("Place at least 3 seam dots around the panel first.");
|
|
683
|
+
let r = Re(e), i = t.map((e) => Ge(r, e));
|
|
684
|
+
if (new Set(i).size !== i.length) throw Error("Two dots snapped to the same vertex — spread dots apart or enable Split Coarse Edges.");
|
|
685
|
+
let a = [], o = /* @__PURE__ */ new Set();
|
|
686
|
+
for (let e = 0; e < i.length; e++) {
|
|
687
|
+
let t = Ke(r, i[e], i[(e + 1) % i.length], o, n.exact ? Ue : We);
|
|
688
|
+
if (!t) throw Error(`No mesh edge path connects dot ${e + 1} to dot ${(e + 1) % i.length + 1}.`);
|
|
689
|
+
for (let e of t.slice(0, -1)) a.push(e), o.add(e);
|
|
690
|
+
}
|
|
691
|
+
let s = /* @__PURE__ */ new Set();
|
|
692
|
+
for (let e = 0; e < a.length; e++) s.add(Ie(a[e], a[(e + 1) % a.length]));
|
|
693
|
+
let c = [...s].map((e) => r.edgeTriangles.get(e) ?? []).find((e) => e.length === 2);
|
|
694
|
+
if (!c) throw Error("Loop runs only along open mesh border — nothing enclosed to peel.");
|
|
695
|
+
let l = Be(r, c[0], (e) => !s.has(e));
|
|
696
|
+
if (new Set(l).has(c[1])) throw Error("Loop didn't enclose an isolated patch — add another dot along the shutline.");
|
|
697
|
+
let u = Be(r, c[1], (e) => !s.has(e)), d = (e) => e.reduce((e, t) => e + r.areas[t], 0);
|
|
698
|
+
return Je(e, d(l) <= d(u) ? l : u, n.mirrorX);
|
|
699
|
+
}
|
|
700
|
+
function Qe(e, t, n = .28) {
|
|
701
|
+
let r = e.index ? e.toNonIndexed() : e.clone(), i = Object.keys(r.attributes), a = i.map((e) => r.getAttribute(e).itemSize), o = i.slice(0, i.indexOf("position")).reduce((e, t, n) => e + a[n], 0), s = r.getAttribute("position").count, c = (e) => {
|
|
702
|
+
let t = [];
|
|
703
|
+
return i.forEach((n, i) => {
|
|
704
|
+
let o = r.getAttribute(n);
|
|
705
|
+
for (let n = 0; n < a[i]; n++) t.push(o.getComponent(e, n));
|
|
706
|
+
}), t;
|
|
707
|
+
}, l = [];
|
|
708
|
+
for (let e = 0; e * 3 + 2 < s; e++) l.push([
|
|
709
|
+
c(e * 3),
|
|
710
|
+
c(e * 3 + 1),
|
|
711
|
+
c(e * 3 + 2)
|
|
712
|
+
]);
|
|
713
|
+
let u = l.length, d = (e) => new p.Vector3(e[o], e[o + 1], e[o + 2]), f = (e, t, n) => e.map((e, r) => e + (t[r] - e) * n), m = ze(r);
|
|
714
|
+
for (let e = 0; e < t.length; e++) {
|
|
715
|
+
let r = new p.Vector3(...t[e]), i = new p.Vector3(...t[(e + 1) % t.length]), a = i.clone().sub(r), o = a.length();
|
|
716
|
+
if (o < 1e-7) continue;
|
|
717
|
+
a.divideScalar(o);
|
|
718
|
+
let s = r.clone().add(i).multiplyScalar(.5), c = new p.Vector3(), u = new p.Vector3();
|
|
719
|
+
for (let e = 0; e < m.triangleCount; e++) {
|
|
720
|
+
u.set(0, 0, 0);
|
|
721
|
+
for (let t = 0; t < 3; t++) u.add(new p.Vector3().fromArray(m.points, m.corners[e * 3 + t] * 3));
|
|
722
|
+
u.multiplyScalar(1 / 3).distanceTo(s) <= Math.max(o, .25) && c.addScaledVector(new p.Vector3().fromArray(m.normals, e * 3), m.areas[e]);
|
|
723
|
+
}
|
|
724
|
+
let h = c.lengthSq() > 0 ? c.normalize() : new p.Vector3(0, 1, 0), g = new p.Vector3().crossVectors(a, h);
|
|
725
|
+
if (g.lengthSq() < 1e-12) continue;
|
|
726
|
+
g.normalize();
|
|
727
|
+
let _ = (e) => g.dot(e) - g.dot(r), v = 1e-6, y = /* @__PURE__ */ new Map(), b = (e) => {
|
|
728
|
+
let t = d(e), n = Le(t.x, t.y, t.z), r = y.get(n);
|
|
729
|
+
return r === void 0 && (r = y.size, y.set(n, r)), r;
|
|
730
|
+
}, x = l.map((e) => {
|
|
731
|
+
let t = e.map((e) => _(d(e))), n = t.filter((e) => e > v).length, r = t.filter((e) => e < -1e-6).length;
|
|
732
|
+
if (n === 0 || r === 0) return null;
|
|
733
|
+
let i = n === 1 ? t.findIndex((e) => e > v) : t.findIndex((e) => e < -1e-6), [a, o, s] = [
|
|
734
|
+
0,
|
|
735
|
+
1,
|
|
736
|
+
2
|
|
737
|
+
].map((t) => e[(i + t) % 3]), [c, l, u] = [
|
|
738
|
+
0,
|
|
739
|
+
1,
|
|
740
|
+
2
|
|
741
|
+
].map((e) => t[(i + e) % 3]), p = Math.abs(l) <= v ? null : f(a, o, c / (c - l)), m = Math.abs(u) <= v ? null : f(a, s, c / (c - u));
|
|
742
|
+
return {
|
|
743
|
+
c0: a,
|
|
744
|
+
c1: o,
|
|
745
|
+
c2: s,
|
|
746
|
+
p01: p,
|
|
747
|
+
p02: m,
|
|
748
|
+
k01: p ? Ie(b(a), b(o)) : -1,
|
|
749
|
+
k02: m ? Ie(b(a), b(s)) : -1,
|
|
750
|
+
chord: [p ?? o, m ?? s]
|
|
751
|
+
};
|
|
752
|
+
}), S = /* @__PURE__ */ new Set();
|
|
753
|
+
for (let e of x) {
|
|
754
|
+
if (!e) continue;
|
|
755
|
+
let t = Infinity, i = -Infinity, s = Infinity;
|
|
756
|
+
for (let n of e.chord) {
|
|
757
|
+
let e = d(n).sub(r), o = e.dot(a);
|
|
758
|
+
t = Math.min(t, o), i = Math.max(i, o), s = Math.min(s, Math.abs(e.dot(h)));
|
|
759
|
+
}
|
|
760
|
+
i >= -1e-6 && t <= o + v && s <= n && (e.p01 && S.add(e.k01), e.p02 && S.add(e.k02));
|
|
761
|
+
}
|
|
762
|
+
let C = [];
|
|
763
|
+
l.forEach((e, t) => {
|
|
764
|
+
let n = x[t], r = n?.p01 && S.has(n.k01) ? n.p01 : null, i = n?.p02 && S.has(n.k02) ? n.p02 : null;
|
|
765
|
+
if (!n || !r && !i) {
|
|
766
|
+
C.push(e);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
let { c0: a, c1: o, c2: s } = n;
|
|
770
|
+
r && i ? C.push([
|
|
771
|
+
a,
|
|
772
|
+
r,
|
|
773
|
+
i
|
|
774
|
+
], [
|
|
775
|
+
r,
|
|
776
|
+
o,
|
|
777
|
+
s
|
|
778
|
+
], [
|
|
779
|
+
r,
|
|
780
|
+
s,
|
|
781
|
+
i
|
|
782
|
+
]) : r ? C.push([
|
|
783
|
+
a,
|
|
784
|
+
r,
|
|
785
|
+
s
|
|
786
|
+
], [
|
|
787
|
+
r,
|
|
788
|
+
o,
|
|
789
|
+
s
|
|
790
|
+
]) : C.push([
|
|
791
|
+
a,
|
|
792
|
+
o,
|
|
793
|
+
i
|
|
794
|
+
], [
|
|
795
|
+
i,
|
|
796
|
+
o,
|
|
797
|
+
s
|
|
798
|
+
]);
|
|
799
|
+
}), l = C;
|
|
800
|
+
}
|
|
801
|
+
let h = new p.BufferGeometry(), g = 0;
|
|
802
|
+
return i.forEach((e, t) => {
|
|
803
|
+
let n = a[t], i = new Float32Array(l.length * 3 * n);
|
|
804
|
+
l.forEach((e, t) => {
|
|
805
|
+
for (let r = 0; r < 3; r++) for (let a = 0; a < n; a++) i[(t * 3 + r) * n + a] = e[r][g + a];
|
|
806
|
+
}), h.setAttribute(e, new p.BufferAttribute(i, n, r.getAttribute(e).normalized)), g += n;
|
|
807
|
+
}), h.getAttribute("normal") || h.computeVertexNormals(), h.computeBoundingBox(), h.computeBoundingSphere(), {
|
|
808
|
+
geometry: h,
|
|
809
|
+
added: l.length - u
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
function $e(e, t, n) {
|
|
813
|
+
let r = e.mesh, i = r.parent;
|
|
814
|
+
if (!i) throw Error("Selected island mesh has no parent scene.");
|
|
815
|
+
let a = r.geometry, o = a.getAttribute("position"), s = a.getIndex(), c = o ? Math.floor((s ? s.count : o.count) / 3) : 0, l = (t) => t.map((t) => e.triangleIndices[t]), u = l(t.triangles), d = l(t.mirrored), f = /* @__PURE__ */ new Set([...u, ...d]), m = [], h = (e, t) => {
|
|
816
|
+
if (e.length === 0) return;
|
|
817
|
+
let n = new p.Mesh(R(a, e), r.material);
|
|
818
|
+
n.name = t, n.position.copy(r.position), n.quaternion.copy(r.quaternion), n.scale.copy(r.scale), i.add(n), m.push(n);
|
|
819
|
+
};
|
|
820
|
+
h(u, n), h(d, `${n}_mirror`);
|
|
821
|
+
let g = [];
|
|
822
|
+
for (let e = 0; e < c; e++) f.has(e) || g.push(e);
|
|
823
|
+
return r.geometry = g.length > 0 ? R(a, g) : new p.BufferGeometry(), {
|
|
824
|
+
mintedMeshes: m,
|
|
825
|
+
undo: () => {
|
|
826
|
+
r.geometry = a;
|
|
827
|
+
for (let e of m) e.removeFromParent(), e.geometry.dispose();
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
function et(e, t) {
|
|
832
|
+
let n = (e) => `${e.mesh.uuid}|${e.triangleIndices.length}|${e.center.map((e) => e.toFixed(4)).join(",")}`, r = /* @__PURE__ */ new Map();
|
|
833
|
+
for (let e of t) {
|
|
834
|
+
let t = n(e), i = r.get(t);
|
|
835
|
+
i ? i.push(e.id) : r.set(t, [e.id]);
|
|
836
|
+
}
|
|
837
|
+
let i = /* @__PURE__ */ new Map();
|
|
838
|
+
for (let t of e) i.set(t.id, r.get(n(t))?.shift() ?? null);
|
|
839
|
+
return i;
|
|
840
|
+
}
|
|
841
|
+
function tt(e, t, n) {
|
|
842
|
+
let r = e.find((e) => e.id === t);
|
|
843
|
+
if (!r || Math.abs(r.center[0]) <= .08) return null;
|
|
844
|
+
let i = Math.max(...r.size, .15), a = null, o = .55;
|
|
845
|
+
for (let s of e) {
|
|
846
|
+
if (s.id === t || n?.has(s.id)) continue;
|
|
847
|
+
let e = Math.hypot(s.center[0] + r.center[0], s.center[1] - r.center[1], s.center[2] - r.center[2]) / i, c = (Math.abs(s.size[0] - r.size[0]) + Math.abs(s.size[1] - r.size[1]) + Math.abs(s.size[2] - r.size[2])) / (r.size[0] + r.size[1] + r.size[2] + 1e-5);
|
|
848
|
+
e + c < o && (o = e + c, a = s.id);
|
|
849
|
+
}
|
|
850
|
+
return a;
|
|
851
|
+
}
|
|
852
|
+
function nt(e, t, n = .004) {
|
|
853
|
+
let r = R(e, t), i = r.getAttribute("position"), a = r.getAttribute("normal");
|
|
854
|
+
if (i && a) {
|
|
855
|
+
for (let e = 0; e < i.count; e++) i.setXYZ(e, i.getX(e) + a.getX(e) * n, i.getY(e) + a.getY(e) * n, i.getZ(e) + a.getZ(e) * n);
|
|
856
|
+
i.needsUpdate = !0;
|
|
857
|
+
}
|
|
858
|
+
return r;
|
|
859
|
+
}
|
|
860
|
+
function rt(e, t, n = "Wheel_12gon") {
|
|
861
|
+
let r = new p.Group();
|
|
862
|
+
r.name = n;
|
|
863
|
+
let i = new p.CylinderGeometry(e, e, t, 12, 1);
|
|
864
|
+
i.rotateZ(Math.PI * .5);
|
|
865
|
+
let a = new p.CylinderGeometry(e * .62, e * .62, t * 1.04, 12, 1);
|
|
866
|
+
a.rotateZ(Math.PI * .5);
|
|
867
|
+
let o = new p.CylinderGeometry(e * .22, e * .22, t * 1.1, 6, 1);
|
|
868
|
+
o.rotateZ(Math.PI * .5);
|
|
869
|
+
let s = new p.Mesh(i, new p.MeshStandardMaterial({
|
|
870
|
+
color: "#1b2028",
|
|
871
|
+
roughness: .92,
|
|
872
|
+
metalness: .05,
|
|
873
|
+
flatShading: !0
|
|
874
|
+
}));
|
|
875
|
+
s.name = `${n}_tire`;
|
|
876
|
+
let c = new p.Mesh(a, new p.MeshStandardMaterial({
|
|
877
|
+
color: "#cbd5e1",
|
|
878
|
+
roughness: .36,
|
|
879
|
+
metalness: .72,
|
|
880
|
+
flatShading: !0
|
|
881
|
+
}));
|
|
882
|
+
c.name = `${n}_rim`;
|
|
883
|
+
let l = new p.Mesh(o, new p.MeshStandardMaterial({
|
|
884
|
+
color: "#f59e0b",
|
|
885
|
+
roughness: .45,
|
|
886
|
+
metalness: .6,
|
|
887
|
+
flatShading: !0
|
|
888
|
+
}));
|
|
889
|
+
return l.name = `${n}_hub`, r.add(s, c, l), r;
|
|
890
|
+
}
|
|
891
|
+
// src/importer/khrCompiler.ts
|
|
892
|
+
var it = [
|
|
893
|
+
"map",
|
|
894
|
+
"normalMap",
|
|
895
|
+
"roughnessMap",
|
|
896
|
+
"metalnessMap",
|
|
897
|
+
"aoMap",
|
|
898
|
+
"emissiveMap"
|
|
899
|
+
], H = (e) => Number(e.toFixed(4)), at = (e, t, n, r) => [
|
|
900
|
+
H(e / 12 * (n * n + r * r)),
|
|
901
|
+
H(e / 12 * (t * t + r * r)),
|
|
902
|
+
H(e / 12 * (t * t + n * n))
|
|
903
|
+
];
|
|
904
|
+
function ot(t, n, r) {
|
|
905
|
+
if (!n) return [];
|
|
906
|
+
let i = new Map(t.map((e) => [e.id, e])), a = (e) => Object.entries(n).filter(([t, n]) => n === e && !r.has(Number(t)) && i.has(Number(t))).map(([e]) => Number(e)), o = [], s = (e) => Pe.find((t) => t.role === e)?.massKg ?? 16;
|
|
907
|
+
for (let n of [1, -1]) {
|
|
908
|
+
let r = a("door").filter((e) => (i.get(e).center[0] >= 0 ? 1 : -1) === n);
|
|
909
|
+
if (r.length === 0) continue;
|
|
910
|
+
let c = r.map((e) => i.get(e).center[2]), l = Math.max(...c) - Math.min(...c), u = (Math.min(...c) + Math.max(...c)) * .5;
|
|
911
|
+
(l > .85 ? [r.filter((e) => i.get(e).center[2] >= u), r.filter((e) => i.get(e).center[2] < u)] : [r]).filter((e) => e.length > 0).forEach((r, i) => {
|
|
912
|
+
let a = `${i === 0 ? "F" : "R"}${n > 0 ? "L" : "R"}`;
|
|
913
|
+
o.push({
|
|
914
|
+
nodeName: `Door_${a}`,
|
|
915
|
+
role: `door_${a.toLowerCase()}`,
|
|
916
|
+
islandIds: r,
|
|
917
|
+
massKg: s("door"),
|
|
918
|
+
hinge: e(I(t, r), "door")
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
for (let n of ["hood", "trunk"]) {
|
|
923
|
+
let r = a(n);
|
|
924
|
+
r.length > 0 && o.push({
|
|
925
|
+
nodeName: n === "hood" ? "Hood" : "Trunk",
|
|
926
|
+
role: n,
|
|
927
|
+
islandIds: r,
|
|
928
|
+
massKg: s(n),
|
|
929
|
+
hinge: e(I(t, r), n)
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
for (let n of ["fender", "bumper"]) a(n).forEach((r, i) => {
|
|
933
|
+
o.push({
|
|
934
|
+
nodeName: `${n === "fender" ? "Fender" : "Bumper"}_${i + 1}`,
|
|
935
|
+
role: n,
|
|
936
|
+
islandIds: [r],
|
|
937
|
+
massKg: s(n),
|
|
938
|
+
hinge: e(I(t, [r]), n)
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
return o;
|
|
942
|
+
}
|
|
943
|
+
function st(e, t, n, r, i) {
|
|
944
|
+
let a = t.filter((e) => e.left.length > 0);
|
|
945
|
+
if (a.length > 0) {
|
|
946
|
+
let t = a.map((t) => ({
|
|
947
|
+
a: t,
|
|
948
|
+
z: I(e, [...t.left, ...t.right]).center[2]
|
|
949
|
+
})).sort((e, t) => t.z - e.z), i = t.length, o = [];
|
|
950
|
+
return t.forEach(({ a: t }, a) => {
|
|
951
|
+
let s = I(e, t.left), c = t.right.length > 0 ? I(e, t.right) : s, l = Math.max(.12, s.radius, c.radius), u = Math.max(.09, Math.max(s.halfWidth, c.halfWidth) * 2), d = n === "motorcycle" ? a > 0 : r === "AWD" || i === 1 ? !0 : r === "FWD" ? a === 0 : a > 0, f = t.steered ?? a === 0, p = t.driven ?? d, m = t.brake ?? !0, h = i === 2 ? a === 0 ? "F" : "R" : `A${a}`;
|
|
952
|
+
t.right.length === 0 ? o.push({
|
|
953
|
+
nodeName: `Wheel_${h}C`,
|
|
954
|
+
islandIds: [...t.left],
|
|
955
|
+
radius: l,
|
|
956
|
+
width: u,
|
|
957
|
+
steered: f,
|
|
958
|
+
driven: p,
|
|
959
|
+
brake: m
|
|
960
|
+
}) : (o.push({
|
|
961
|
+
nodeName: `Wheel_${h}L`,
|
|
962
|
+
islandIds: [...t.left],
|
|
963
|
+
radius: l,
|
|
964
|
+
width: u,
|
|
965
|
+
steered: f,
|
|
966
|
+
driven: p,
|
|
967
|
+
brake: m
|
|
968
|
+
}), o.push({
|
|
969
|
+
nodeName: `Wheel_${h}R`,
|
|
970
|
+
islandIds: [...t.right],
|
|
971
|
+
radius: l,
|
|
972
|
+
width: u,
|
|
973
|
+
steered: f,
|
|
974
|
+
driven: p,
|
|
975
|
+
brake: m
|
|
976
|
+
}));
|
|
977
|
+
}), o;
|
|
978
|
+
}
|
|
979
|
+
let [o, s, c] = i;
|
|
980
|
+
if (n === "motorcycle") {
|
|
981
|
+
let e = Math.max(.24, Math.min(.36, s * .28)), t = Math.max(.12, o * .22), n = c * .34;
|
|
982
|
+
return [{
|
|
983
|
+
nodeName: "Wheel_FC",
|
|
984
|
+
islandIds: [],
|
|
985
|
+
fallbackPos: [
|
|
986
|
+
0,
|
|
987
|
+
e,
|
|
988
|
+
n
|
|
989
|
+
],
|
|
990
|
+
radius: e,
|
|
991
|
+
width: t,
|
|
992
|
+
steered: !0,
|
|
993
|
+
driven: !1,
|
|
994
|
+
brake: !0
|
|
995
|
+
}, {
|
|
996
|
+
nodeName: "Wheel_RC",
|
|
997
|
+
islandIds: [],
|
|
998
|
+
fallbackPos: [
|
|
999
|
+
0,
|
|
1000
|
+
e,
|
|
1001
|
+
-n
|
|
1002
|
+
],
|
|
1003
|
+
radius: e,
|
|
1004
|
+
width: t,
|
|
1005
|
+
steered: !1,
|
|
1006
|
+
driven: !0,
|
|
1007
|
+
brake: !0
|
|
1008
|
+
}];
|
|
1009
|
+
}
|
|
1010
|
+
let l = Math.max(.26, Math.min(.42, s * .24)), u = Math.max(.18, o * .14), d = o * .41, f = c * .32, p = r === "AWD" || r === "FWD", m = r === "AWD" || r === "RWD";
|
|
1011
|
+
return [
|
|
1012
|
+
{
|
|
1013
|
+
nodeName: "Wheel_FL",
|
|
1014
|
+
islandIds: [],
|
|
1015
|
+
fallbackPos: [
|
|
1016
|
+
d,
|
|
1017
|
+
l,
|
|
1018
|
+
f
|
|
1019
|
+
],
|
|
1020
|
+
radius: l,
|
|
1021
|
+
width: u,
|
|
1022
|
+
steered: !0,
|
|
1023
|
+
driven: p,
|
|
1024
|
+
brake: !0
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
nodeName: "Wheel_FR",
|
|
1028
|
+
islandIds: [],
|
|
1029
|
+
fallbackPos: [
|
|
1030
|
+
-d,
|
|
1031
|
+
l,
|
|
1032
|
+
f
|
|
1033
|
+
],
|
|
1034
|
+
radius: l,
|
|
1035
|
+
width: u,
|
|
1036
|
+
steered: !0,
|
|
1037
|
+
driven: p,
|
|
1038
|
+
brake: !0
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
nodeName: "Wheel_RL",
|
|
1042
|
+
islandIds: [],
|
|
1043
|
+
fallbackPos: [
|
|
1044
|
+
d,
|
|
1045
|
+
l,
|
|
1046
|
+
-f
|
|
1047
|
+
],
|
|
1048
|
+
radius: l,
|
|
1049
|
+
width: u,
|
|
1050
|
+
steered: !1,
|
|
1051
|
+
driven: m,
|
|
1052
|
+
brake: !0
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
nodeName: "Wheel_RR",
|
|
1056
|
+
islandIds: [],
|
|
1057
|
+
fallbackPos: [
|
|
1058
|
+
-d,
|
|
1059
|
+
l,
|
|
1060
|
+
-f
|
|
1061
|
+
],
|
|
1062
|
+
radius: l,
|
|
1063
|
+
width: u,
|
|
1064
|
+
steered: !1,
|
|
1065
|
+
driven: m,
|
|
1066
|
+
brake: !0
|
|
1067
|
+
}
|
|
1068
|
+
];
|
|
1069
|
+
}
|
|
1070
|
+
async function ct(e, n) {
|
|
1071
|
+
e.updateMatrixWorld(!0);
|
|
1072
|
+
let r = new p.Box3().setFromObject(e), i = r.getSize(new p.Vector3()), a = r.getCenter(new p.Vector3()), o = Math.max(.25, i.x), s = Math.max(.25, i.y), c = Math.max(.25, i.z), l = Math.max(5, n.massKg || 1e3), u = new p.Group();
|
|
1073
|
+
u.name = n.name || e.name || `Kolmo_${n.archetype}`;
|
|
1074
|
+
let d = [], f;
|
|
1075
|
+
if (n.archetype === "car" || n.archetype === "motorcycle") {
|
|
1076
|
+
let t = n.islands ?? Ne(e), i = n.axles ?? (n.archetype === "motorcycle" ? De(t) : Ee(t)), m = n.driveType ?? (n.archetype === "motorcycle" ? "RWD" : "AWD"), h = st(t, i, n.archetype, m, [
|
|
1077
|
+
o,
|
|
1078
|
+
s,
|
|
1079
|
+
c
|
|
1080
|
+
]), g = ot(t, n.partPicks, new Set(h.flatMap((e) => e.islandIds))), _ = z(e, t, h.filter((e) => e.islandIds.length > 0), g.map((e) => ({
|
|
1081
|
+
nodeName: e.nodeName,
|
|
1082
|
+
islandIds: e.islandIds,
|
|
1083
|
+
anchor: e.hinge.anchor
|
|
1084
|
+
}))), v = new p.Group();
|
|
1085
|
+
v.name = "Chassis", v.add(_.chassisGroup), u.add(v);
|
|
1086
|
+
for (let e of h) {
|
|
1087
|
+
let t = _.wheels.find((t) => t.nodeName === e.nodeName), r = t?.center ?? e.fallbackPos ?? [
|
|
1088
|
+
0,
|
|
1089
|
+
e.radius,
|
|
1090
|
+
0
|
|
1091
|
+
];
|
|
1092
|
+
if (n.wheelSource === "fleet12" || !t) {
|
|
1093
|
+
let t = rt(e.radius, e.width, e.nodeName);
|
|
1094
|
+
t.position.set(r[0], r[1], r[2]), u.add(t);
|
|
1095
|
+
} else u.add(t.group);
|
|
1096
|
+
}
|
|
1097
|
+
let y = Math.max(...h.map((e) => e.radius)), b = Math.max(.08, Math.min(.3, y * .68)), x = b * .4, S = Math.min(r.max.y - .2, Math.max(y * 1.15, b - x + .16)), C = Math.max(S + .26, r.max.y * .92), w = [
|
|
1098
|
+
H(Math.max(n.archetype === "motorcycle" ? .26 : .45, o * (n.archetype === "motorcycle" ? .55 : .92))),
|
|
1099
|
+
H(Math.max(.26, C - S)),
|
|
1100
|
+
H(Math.max(.55, c * .92))
|
|
1101
|
+
], T = new p.Object3D();
|
|
1102
|
+
T.name = "Chassis_Hull", T.position.set(H(a.x), H((S + C) * .5), H(a.z)), v.add(T);
|
|
1103
|
+
let E = n.archetype === "motorcycle" ? Math.max(y * .95, s * .32) : Math.min(C, Math.max(y + .14, s * .36)), D = h.map((e) => _.wheels.find((t) => t.nodeName === e.nodeName)?.center[2] ?? e.fallbackPos?.[2] ?? 0), O = D.reduce((e, t) => e + t, 0) / Math.max(1, D.length), k = Math.max(80, l - g.reduce((e, t) => e + t.massKg, 0)), A = ae.streetDrift90s, j = oe(A.muPeakLng, .82);
|
|
1104
|
+
d = [{
|
|
1105
|
+
nodeName: "Chassis",
|
|
1106
|
+
motion: {
|
|
1107
|
+
isKinematic: !1,
|
|
1108
|
+
mass: k,
|
|
1109
|
+
centerOfMass: [
|
|
1110
|
+
0,
|
|
1111
|
+
H(E),
|
|
1112
|
+
H(O)
|
|
1113
|
+
],
|
|
1114
|
+
inertiaDiagonal: at(k, o, Math.max(.45, s - y * .5), c)
|
|
1115
|
+
},
|
|
1116
|
+
extras: { role: "chassis" }
|
|
1117
|
+
}, {
|
|
1118
|
+
nodeName: "Chassis_Hull",
|
|
1119
|
+
collider: {
|
|
1120
|
+
shape: {
|
|
1121
|
+
type: "box",
|
|
1122
|
+
size: w
|
|
1123
|
+
},
|
|
1124
|
+
friction: .38,
|
|
1125
|
+
restitution: .05
|
|
1126
|
+
}
|
|
1127
|
+
}];
|
|
1128
|
+
for (let e of g) {
|
|
1129
|
+
let t = _.panels.find((t) => t.nodeName === e.nodeName);
|
|
1130
|
+
if (!t) continue;
|
|
1131
|
+
v.add(t.group);
|
|
1132
|
+
let n = [
|
|
1133
|
+
H(t.center[0] - t.anchor[0]),
|
|
1134
|
+
H(t.center[1] - t.anchor[1]),
|
|
1135
|
+
H(t.center[2] - t.anchor[2])
|
|
1136
|
+
], r = new p.Object3D();
|
|
1137
|
+
r.name = `${e.nodeName}_Panel`, r.position.set(n[0], n[1], n[2]), t.group.add(r), d.push({
|
|
1138
|
+
nodeName: r.name,
|
|
1139
|
+
collider: {
|
|
1140
|
+
shape: {
|
|
1141
|
+
type: "box",
|
|
1142
|
+
size: [
|
|
1143
|
+
H(t.size[0]),
|
|
1144
|
+
H(t.size[1]),
|
|
1145
|
+
H(t.size[2])
|
|
1146
|
+
]
|
|
1147
|
+
},
|
|
1148
|
+
friction: .45
|
|
1149
|
+
}
|
|
1150
|
+
}), d.push({
|
|
1151
|
+
nodeName: e.nodeName,
|
|
1152
|
+
motion: {
|
|
1153
|
+
isKinematic: !1,
|
|
1154
|
+
mass: e.massKg,
|
|
1155
|
+
centerOfMass: n,
|
|
1156
|
+
inertiaDiagonal: at(e.massKg, t.size[0], t.size[1], t.size[2])
|
|
1157
|
+
},
|
|
1158
|
+
joint: {
|
|
1159
|
+
connectedNodeName: "Chassis",
|
|
1160
|
+
kind: "revolute",
|
|
1161
|
+
axis: e.hinge.axis,
|
|
1162
|
+
limits: e.hinge.limits,
|
|
1163
|
+
drive: {
|
|
1164
|
+
mode: "acceleration",
|
|
1165
|
+
stiffness: 60,
|
|
1166
|
+
damping: 12,
|
|
1167
|
+
positionTarget: 0
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
extras: { role: e.role }
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
for (let e of h) {
|
|
1174
|
+
let t = H(Math.max(.08, Math.min(.3, e.radius * .68))), n = H(t * .4);
|
|
1175
|
+
d.push({
|
|
1176
|
+
nodeName: e.nodeName,
|
|
1177
|
+
extras: { ecctrlWheel: {
|
|
1178
|
+
radius: H(e.radius),
|
|
1179
|
+
width: H(e.width),
|
|
1180
|
+
travel: t,
|
|
1181
|
+
sag: n,
|
|
1182
|
+
steer: e.steered,
|
|
1183
|
+
drive: e.driven,
|
|
1184
|
+
brake: e.brake,
|
|
1185
|
+
tireGripFactor: j,
|
|
1186
|
+
latFrictionEllipseScale: A.latFrictionEllipseScale,
|
|
1187
|
+
relaxLngRate: A.relaxLngRate,
|
|
1188
|
+
relaxLatRate: A.relaxLatRate,
|
|
1189
|
+
lngSlipRatioCurveData: A.lng,
|
|
1190
|
+
latSlipRatioCurveData: A.lat
|
|
1191
|
+
} }
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
let ee = Math.max(25, n.powerOrThrust || (n.archetype === "motorcycle" ? 165 : 280));
|
|
1195
|
+
f = { tune: n.archetype === "motorcycle" ? {
|
|
1196
|
+
engineHorsepower: ee,
|
|
1197
|
+
engineMaxRPM: 13500,
|
|
1198
|
+
gearRatios: [
|
|
1199
|
+
2.6,
|
|
1200
|
+
1.95,
|
|
1201
|
+
1.55,
|
|
1202
|
+
1.3,
|
|
1203
|
+
1.12,
|
|
1204
|
+
1
|
|
1205
|
+
],
|
|
1206
|
+
finalDriveRatio: 2.8,
|
|
1207
|
+
transmissionMode: "auto",
|
|
1208
|
+
shiftUpRPM: 12200,
|
|
1209
|
+
shiftDownRPM: 6200,
|
|
1210
|
+
maxSteerAngle: .42,
|
|
1211
|
+
twoWheelBalance: !0,
|
|
1212
|
+
maxLeanAngle: .78,
|
|
1213
|
+
leanOmega: 10,
|
|
1214
|
+
leanDampingRatio: .85,
|
|
1215
|
+
engineTorqueCurveData: re.naScreamer
|
|
1216
|
+
} : {
|
|
1217
|
+
engineHorsepower: ee,
|
|
1218
|
+
engineMaxRPM: 7e3,
|
|
1219
|
+
gearRatios: [
|
|
1220
|
+
3.1,
|
|
1221
|
+
2.05,
|
|
1222
|
+
1.42,
|
|
1223
|
+
1,
|
|
1224
|
+
.82
|
|
1225
|
+
],
|
|
1226
|
+
finalDriveRatio: 3.58,
|
|
1227
|
+
transmissionMode: "auto",
|
|
1228
|
+
maxSteerAngle: .55,
|
|
1229
|
+
rollCenterHeight: .12,
|
|
1230
|
+
antiRollStiffness: 14e3,
|
|
1231
|
+
engineTorqueCurveData: re.naScreamer,
|
|
1232
|
+
steerAngleCurveData: ie.driftCountersteer
|
|
1233
|
+
} };
|
|
1234
|
+
} else if (n.archetype === "starcraft") {
|
|
1235
|
+
for (let t of e.clone(!0).children) u.add(t);
|
|
1236
|
+
let t = new p.Object3D();
|
|
1237
|
+
t.name = "HullBody", t.position.set(a.x, a.y, a.z), u.add(t);
|
|
1238
|
+
let r = Math.max(400, n.powerOrThrust || 4500, Math.ceil(l * 9.81 * .72));
|
|
1239
|
+
d = [{
|
|
1240
|
+
nodeName: "HullBody",
|
|
1241
|
+
motion: {
|
|
1242
|
+
isKinematic: !1,
|
|
1243
|
+
mass: l,
|
|
1244
|
+
centerOfMass: [
|
|
1245
|
+
0,
|
|
1246
|
+
H(-s * .06),
|
|
1247
|
+
0
|
|
1248
|
+
],
|
|
1249
|
+
inertiaDiagonal: at(l, o, s, c)
|
|
1250
|
+
},
|
|
1251
|
+
collider: {
|
|
1252
|
+
shape: {
|
|
1253
|
+
type: "box",
|
|
1254
|
+
size: [
|
|
1255
|
+
H(o * .86),
|
|
1256
|
+
H(s * .78),
|
|
1257
|
+
H(c * .9)
|
|
1258
|
+
]
|
|
1259
|
+
},
|
|
1260
|
+
friction: .35,
|
|
1261
|
+
restitution: .08
|
|
1262
|
+
}
|
|
1263
|
+
}];
|
|
1264
|
+
for (let [e, t, n, i] of [
|
|
1265
|
+
[
|
|
1266
|
+
"Thruster_FL",
|
|
1267
|
+
o * .36,
|
|
1268
|
+
c * .32,
|
|
1269
|
+
!1
|
|
1270
|
+
],
|
|
1271
|
+
[
|
|
1272
|
+
"Thruster_FR",
|
|
1273
|
+
-o * .36,
|
|
1274
|
+
c * .32,
|
|
1275
|
+
!0
|
|
1276
|
+
],
|
|
1277
|
+
[
|
|
1278
|
+
"Thruster_RL",
|
|
1279
|
+
o * .36,
|
|
1280
|
+
-c * .32,
|
|
1281
|
+
!0
|
|
1282
|
+
],
|
|
1283
|
+
[
|
|
1284
|
+
"Thruster_RR",
|
|
1285
|
+
-o * .36,
|
|
1286
|
+
-c * .32,
|
|
1287
|
+
!1
|
|
1288
|
+
]
|
|
1289
|
+
]) {
|
|
1290
|
+
let o = new p.Object3D();
|
|
1291
|
+
o.name = e, o.position.set(a.x + t, a.y, a.z + n), u.add(o), d.push({
|
|
1292
|
+
nodeName: e,
|
|
1293
|
+
extras: { ecctrlPropeller: {
|
|
1294
|
+
maxThrust: r,
|
|
1295
|
+
torqueRatio: .6,
|
|
1296
|
+
invertTorque: i
|
|
1297
|
+
} }
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
f = { droneTune: {
|
|
1301
|
+
controlMode: "VELOCITY",
|
|
1302
|
+
maxYawRate: 2.4,
|
|
1303
|
+
maxHorizSpeed: 44,
|
|
1304
|
+
maxVertSpeed: 22,
|
|
1305
|
+
maxTiltAngle: .52,
|
|
1306
|
+
airDragFactor: .18
|
|
1307
|
+
} };
|
|
1308
|
+
} else {
|
|
1309
|
+
let t = new p.Group();
|
|
1310
|
+
t.name = "PropBody";
|
|
1311
|
+
let r = !1;
|
|
1312
|
+
for (let n of e.clone(!0).children) t.add(n), n.traverse((e) => {
|
|
1313
|
+
e instanceof p.Mesh && (e.geometry?.getAttribute("position")?.count ?? 0) >= 3 && (r = !0);
|
|
1314
|
+
});
|
|
1315
|
+
u.add(t), d = [{
|
|
1316
|
+
nodeName: "PropBody",
|
|
1317
|
+
motion: n.staticProp ? { isKinematic: !0 } : {
|
|
1318
|
+
isKinematic: !1,
|
|
1319
|
+
mass: l,
|
|
1320
|
+
centerOfMass: [
|
|
1321
|
+
H(a.x),
|
|
1322
|
+
H(a.y),
|
|
1323
|
+
H(a.z)
|
|
1324
|
+
],
|
|
1325
|
+
inertiaDiagonal: at(l, o, s, c)
|
|
1326
|
+
},
|
|
1327
|
+
collider: r ? {
|
|
1328
|
+
meshNodeName: "PropBody",
|
|
1329
|
+
convexHull: !0,
|
|
1330
|
+
friction: .6,
|
|
1331
|
+
restitution: .1
|
|
1332
|
+
} : {
|
|
1333
|
+
shape: {
|
|
1334
|
+
type: "box",
|
|
1335
|
+
size: [
|
|
1336
|
+
H(o),
|
|
1337
|
+
H(s),
|
|
1338
|
+
H(c)
|
|
1339
|
+
]
|
|
1340
|
+
},
|
|
1341
|
+
friction: .6,
|
|
1342
|
+
restitution: .1
|
|
1343
|
+
}
|
|
1344
|
+
}];
|
|
1345
|
+
}
|
|
1346
|
+
let m = [];
|
|
1347
|
+
u.traverse((e) => {
|
|
1348
|
+
if (!(e instanceof p.Mesh) || !e.material) return;
|
|
1349
|
+
let t = e.material;
|
|
1350
|
+
for (let e of it) {
|
|
1351
|
+
let n = t[e];
|
|
1352
|
+
n && !n.image && (m.push({
|
|
1353
|
+
rec: t,
|
|
1354
|
+
slot: e,
|
|
1355
|
+
tex: n
|
|
1356
|
+
}), t[e] = null);
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
let h;
|
|
1360
|
+
try {
|
|
1361
|
+
h = new Uint8Array(await C(u, d, f));
|
|
1362
|
+
} finally {
|
|
1363
|
+
for (let e of m) e.rec[e.slot] = e.tex;
|
|
1364
|
+
}
|
|
1365
|
+
let g = t(h, n.patches ?? []);
|
|
1366
|
+
return g instanceof Uint8Array ? g : new Uint8Array(g);
|
|
1367
|
+
}
|
|
1368
|
+
// src/importer/ChopShopPanel.tsx
|
|
1369
|
+
var lt = [
|
|
1370
|
+
{
|
|
1371
|
+
mode: "island",
|
|
1372
|
+
label: "1 · Bucket",
|
|
1373
|
+
hint: "1-click any separate mesh piece (auto-mirrors X=0)."
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
mode: "crease",
|
|
1377
|
+
label: "2 · Crease Flood",
|
|
1378
|
+
hint: "Click a fused panel/tire face to flood up to shutlines."
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
mode: "loop",
|
|
1382
|
+
label: "3 · Tape Lasso",
|
|
1383
|
+
hint: "Click 3+ seam dots around a fused door/hood/wheel, Close Loop, then Peel."
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
mode: "triangle",
|
|
1387
|
+
label: "4 · Brush",
|
|
1388
|
+
hint: "Click or drag to paint faces. Alt / Right-click erases."
|
|
1389
|
+
}
|
|
1390
|
+
], ut = {
|
|
1391
|
+
position: "absolute",
|
|
1392
|
+
top: 52,
|
|
1393
|
+
right: 10,
|
|
1394
|
+
bottom: 48,
|
|
1395
|
+
width: 306,
|
|
1396
|
+
display: "flex",
|
|
1397
|
+
flexDirection: "column",
|
|
1398
|
+
gap: 8,
|
|
1399
|
+
padding: "10px 11px",
|
|
1400
|
+
background: "rgba(10, 13, 18, 0.93)",
|
|
1401
|
+
border: "1px solid #1C2632",
|
|
1402
|
+
borderRadius: 6,
|
|
1403
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1404
|
+
color: "#E6EDF3",
|
|
1405
|
+
overflowY: "auto",
|
|
1406
|
+
zIndex: 18,
|
|
1407
|
+
backdropFilter: "blur(6px)"
|
|
1408
|
+
}, dt = {
|
|
1409
|
+
border: "1px solid #1E293B",
|
|
1410
|
+
borderRadius: 4,
|
|
1411
|
+
padding: "7px 8px",
|
|
1412
|
+
display: "grid",
|
|
1413
|
+
gap: 6
|
|
1414
|
+
};
|
|
1415
|
+
function U({ label: e, active: t = !1, disabled: n = !1, color: r = "#FFB000", onClick: i }) {
|
|
1416
|
+
return /* @__PURE__ */ D("button", {
|
|
1417
|
+
type: "button",
|
|
1418
|
+
disabled: n,
|
|
1419
|
+
onClick: i,
|
|
1420
|
+
style: {
|
|
1421
|
+
padding: "5px 7px",
|
|
1422
|
+
borderRadius: 3,
|
|
1423
|
+
fontSize: 10.5,
|
|
1424
|
+
fontWeight: t ? 700 : 600,
|
|
1425
|
+
fontFamily: "inherit",
|
|
1426
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
1427
|
+
border: `1px solid ${n ? "#1E293B" : t ? r : "#2B3A4E"}`,
|
|
1428
|
+
background: t ? r : "#0F151E",
|
|
1429
|
+
color: n ? "#475569" : t ? "#080B10" : "#E2E8F0",
|
|
1430
|
+
textAlign: "left"
|
|
1431
|
+
},
|
|
1432
|
+
children: e
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
function ft(e) {
|
|
1436
|
+
let t = Pe.find((t) => t.role === e.activeRole) ?? Pe[0], n = (t) => t === "wheel" ? e.wheelCount : Object.values(e.partPicks).filter((e) => e === t).length, r = Object.keys(e.partPicks).length;
|
|
1437
|
+
return /* @__PURE__ */ O("aside", {
|
|
1438
|
+
style: ut,
|
|
1439
|
+
"aria-label": "Car Chop-Shop",
|
|
1440
|
+
children: [
|
|
1441
|
+
/* @__PURE__ */ O("div", {
|
|
1442
|
+
style: {
|
|
1443
|
+
display: "flex",
|
|
1444
|
+
justifyContent: "space-between",
|
|
1445
|
+
alignItems: "center"
|
|
1446
|
+
},
|
|
1447
|
+
children: [/* @__PURE__ */ D("span", {
|
|
1448
|
+
style: {
|
|
1449
|
+
fontSize: 11.5,
|
|
1450
|
+
fontWeight: 800,
|
|
1451
|
+
color: "#FFB000",
|
|
1452
|
+
letterSpacing: "0.05em"
|
|
1453
|
+
},
|
|
1454
|
+
children: "CHOP-SHOP · CUT & HINGE"
|
|
1455
|
+
}), /* @__PURE__ */ D("span", {
|
|
1456
|
+
style: {
|
|
1457
|
+
fontSize: 10,
|
|
1458
|
+
color: "#38BDF8"
|
|
1459
|
+
},
|
|
1460
|
+
children: `${e.wheelCount}W · ${r}P`
|
|
1461
|
+
})]
|
|
1462
|
+
}),
|
|
1463
|
+
/* @__PURE__ */ O("div", {
|
|
1464
|
+
style: dt,
|
|
1465
|
+
children: [/* @__PURE__ */ O("div", {
|
|
1466
|
+
style: {
|
|
1467
|
+
display: "flex",
|
|
1468
|
+
justifyContent: "space-between",
|
|
1469
|
+
fontSize: 10.5,
|
|
1470
|
+
color: "#94A3B8"
|
|
1471
|
+
},
|
|
1472
|
+
children: [/* @__PURE__ */ D("span", { children: "LENGTH (+Z SI)" }), /* @__PURE__ */ D("span", {
|
|
1473
|
+
style: {
|
|
1474
|
+
color: "#00E5FF",
|
|
1475
|
+
fontWeight: 700
|
|
1476
|
+
},
|
|
1477
|
+
children: `${e.targetMeters.toFixed(2)} m`
|
|
1478
|
+
})]
|
|
1479
|
+
}), /* @__PURE__ */ D("input", {
|
|
1480
|
+
type: "range",
|
|
1481
|
+
min: 1.6,
|
|
1482
|
+
max: 7.5,
|
|
1483
|
+
step: .05,
|
|
1484
|
+
value: e.targetMeters,
|
|
1485
|
+
onChange: (t) => e.onChangeTargetMeters(Number(t.target.value)),
|
|
1486
|
+
style: {
|
|
1487
|
+
width: "100%",
|
|
1488
|
+
accentColor: "#00E5FF"
|
|
1489
|
+
}
|
|
1490
|
+
})]
|
|
1491
|
+
}),
|
|
1492
|
+
/* @__PURE__ */ O("div", {
|
|
1493
|
+
style: dt,
|
|
1494
|
+
children: [/* @__PURE__ */ D("span", {
|
|
1495
|
+
style: {
|
|
1496
|
+
fontSize: 10,
|
|
1497
|
+
color: "#94A3B8",
|
|
1498
|
+
letterSpacing: "0.06em"
|
|
1499
|
+
},
|
|
1500
|
+
children: "1. PICK PART ROLE TO TAG OR CUT"
|
|
1501
|
+
}), /* @__PURE__ */ D("div", {
|
|
1502
|
+
style: {
|
|
1503
|
+
display: "grid",
|
|
1504
|
+
gridTemplateColumns: "1fr 1fr",
|
|
1505
|
+
gap: 5
|
|
1506
|
+
},
|
|
1507
|
+
children: Pe.map((t) => {
|
|
1508
|
+
let r = n(t.role);
|
|
1509
|
+
return /* @__PURE__ */ D(U, {
|
|
1510
|
+
active: e.activeRole === t.role,
|
|
1511
|
+
color: t.color,
|
|
1512
|
+
label: `${t.label}${r > 0 ? ` (${r})` : ""}`,
|
|
1513
|
+
onClick: () => e.onSelectRole(t.role)
|
|
1514
|
+
}, t.role);
|
|
1515
|
+
})
|
|
1516
|
+
})]
|
|
1517
|
+
}),
|
|
1518
|
+
/* @__PURE__ */ O("div", {
|
|
1519
|
+
style: dt,
|
|
1520
|
+
children: [
|
|
1521
|
+
/* @__PURE__ */ D("span", {
|
|
1522
|
+
style: {
|
|
1523
|
+
fontSize: 10,
|
|
1524
|
+
color: "#94A3B8",
|
|
1525
|
+
letterSpacing: "0.06em"
|
|
1526
|
+
},
|
|
1527
|
+
children: "2. SURFACE CUTTER (FUSED MESHES)"
|
|
1528
|
+
}),
|
|
1529
|
+
/* @__PURE__ */ D("div", {
|
|
1530
|
+
style: {
|
|
1531
|
+
display: "grid",
|
|
1532
|
+
gridTemplateColumns: "1fr 1fr",
|
|
1533
|
+
gap: 5
|
|
1534
|
+
},
|
|
1535
|
+
children: lt.map((t) => /* @__PURE__ */ D(U, {
|
|
1536
|
+
label: t.label,
|
|
1537
|
+
active: e.surfaceMode === t.mode,
|
|
1538
|
+
color: "#00E5FF",
|
|
1539
|
+
onClick: () => e.onChangeSurfaceMode(t.mode)
|
|
1540
|
+
}, t.mode))
|
|
1541
|
+
}),
|
|
1542
|
+
/* @__PURE__ */ D("div", {
|
|
1543
|
+
style: {
|
|
1544
|
+
fontSize: 10,
|
|
1545
|
+
color: "#94A3B8",
|
|
1546
|
+
lineHeight: 1.35
|
|
1547
|
+
},
|
|
1548
|
+
children: lt.find((t) => t.mode === e.surfaceMode)?.hint
|
|
1549
|
+
}),
|
|
1550
|
+
e.surfaceMode === "crease" && /* @__PURE__ */ O("label", {
|
|
1551
|
+
style: {
|
|
1552
|
+
display: "grid",
|
|
1553
|
+
gridTemplateColumns: "72px 1fr 36px",
|
|
1554
|
+
alignItems: "center",
|
|
1555
|
+
gap: 6,
|
|
1556
|
+
fontSize: 10.5
|
|
1557
|
+
},
|
|
1558
|
+
children: [
|
|
1559
|
+
/* @__PURE__ */ D("span", { children: "Crease" }),
|
|
1560
|
+
/* @__PURE__ */ D("input", {
|
|
1561
|
+
type: "range",
|
|
1562
|
+
min: 12,
|
|
1563
|
+
max: 62,
|
|
1564
|
+
step: 1,
|
|
1565
|
+
value: e.creaseDeg,
|
|
1566
|
+
onChange: (t) => e.onChangeCreaseDeg(Number(t.target.value)),
|
|
1567
|
+
style: { accentColor: "#FFB000" }
|
|
1568
|
+
}),
|
|
1569
|
+
/* @__PURE__ */ D("span", {
|
|
1570
|
+
style: {
|
|
1571
|
+
textAlign: "right",
|
|
1572
|
+
color: "#FFB000"
|
|
1573
|
+
},
|
|
1574
|
+
children: `${e.creaseDeg}°`
|
|
1575
|
+
})
|
|
1576
|
+
]
|
|
1577
|
+
}),
|
|
1578
|
+
/* @__PURE__ */ O("label", {
|
|
1579
|
+
style: {
|
|
1580
|
+
display: "flex",
|
|
1581
|
+
alignItems: "center",
|
|
1582
|
+
gap: 6,
|
|
1583
|
+
fontSize: 10.5,
|
|
1584
|
+
cursor: "pointer"
|
|
1585
|
+
},
|
|
1586
|
+
children: [/* @__PURE__ */ D("input", {
|
|
1587
|
+
type: "checkbox",
|
|
1588
|
+
checked: e.mirrorX,
|
|
1589
|
+
onChange: (t) => e.onToggleMirrorX(t.target.checked),
|
|
1590
|
+
style: { accentColor: "#00E5FF" }
|
|
1591
|
+
}), /* @__PURE__ */ D("span", { children: "Mirror cut/tag across X = 0 (L + R)" })]
|
|
1592
|
+
}),
|
|
1593
|
+
e.surfaceMode === "loop" && /* @__PURE__ */ O("label", {
|
|
1594
|
+
style: {
|
|
1595
|
+
display: "flex",
|
|
1596
|
+
alignItems: "center",
|
|
1597
|
+
gap: 6,
|
|
1598
|
+
fontSize: 10.5,
|
|
1599
|
+
cursor: "pointer"
|
|
1600
|
+
},
|
|
1601
|
+
children: [/* @__PURE__ */ D("input", {
|
|
1602
|
+
type: "checkbox",
|
|
1603
|
+
checked: e.splitCoarse,
|
|
1604
|
+
onChange: (t) => e.onToggleSplitCoarse(t.target.checked),
|
|
1605
|
+
style: { accentColor: "#FFB000" }
|
|
1606
|
+
}), /* @__PURE__ */ D("span", { children: "Split coarse triangles under cut line" })]
|
|
1607
|
+
}),
|
|
1608
|
+
e.surfaceMode !== "island" && /* @__PURE__ */ O("div", {
|
|
1609
|
+
style: {
|
|
1610
|
+
display: "flex",
|
|
1611
|
+
flexWrap: "wrap",
|
|
1612
|
+
gap: 5
|
|
1613
|
+
},
|
|
1614
|
+
children: [
|
|
1615
|
+
e.surfaceMode === "loop" && /* @__PURE__ */ D(U, {
|
|
1616
|
+
label: `[ CLOSE LOOP (${e.loopDotCount}) ]`,
|
|
1617
|
+
disabled: e.loopDotCount < 3,
|
|
1618
|
+
color: "#00E5FF",
|
|
1619
|
+
onClick: e.onCloseLoop
|
|
1620
|
+
}),
|
|
1621
|
+
/* @__PURE__ */ D(U, {
|
|
1622
|
+
label: `[ PEEL ${e.selectedFaces}${e.mirroredFaces > 0 ? `+${e.mirroredFaces}` : ""} FACES → ${e.activeRole.toUpperCase()} ]`,
|
|
1623
|
+
active: e.selectedFaces > 0,
|
|
1624
|
+
disabled: e.selectedFaces === 0,
|
|
1625
|
+
color: t.color,
|
|
1626
|
+
onClick: e.onPeel
|
|
1627
|
+
}),
|
|
1628
|
+
(e.selectedFaces > 0 || e.loopDotCount > 0) && /* @__PURE__ */ D(U, {
|
|
1629
|
+
label: "[ CLEAR ]",
|
|
1630
|
+
onClick: e.onClearSelection
|
|
1631
|
+
})
|
|
1632
|
+
]
|
|
1633
|
+
}),
|
|
1634
|
+
(e.undoCount > 0 || r > 0) && /* @__PURE__ */ O("div", {
|
|
1635
|
+
style: {
|
|
1636
|
+
display: "flex",
|
|
1637
|
+
gap: 5
|
|
1638
|
+
},
|
|
1639
|
+
children: [e.undoCount > 0 && /* @__PURE__ */ D(U, {
|
|
1640
|
+
label: `[ UNDO CUT (${e.undoCount}) ]`,
|
|
1641
|
+
color: "#F43F5E",
|
|
1642
|
+
onClick: e.onUndoCut
|
|
1643
|
+
}), r > 0 && /* @__PURE__ */ D(U, {
|
|
1644
|
+
label: "[ CLEAR TAGS ]",
|
|
1645
|
+
onClick: e.onClearTags
|
|
1646
|
+
})]
|
|
1647
|
+
})
|
|
1648
|
+
]
|
|
1649
|
+
}),
|
|
1650
|
+
/* @__PURE__ */ O("div", {
|
|
1651
|
+
style: dt,
|
|
1652
|
+
children: [
|
|
1653
|
+
/* @__PURE__ */ D("span", {
|
|
1654
|
+
style: {
|
|
1655
|
+
fontSize: 10,
|
|
1656
|
+
color: "#94A3B8",
|
|
1657
|
+
letterSpacing: "0.06em"
|
|
1658
|
+
},
|
|
1659
|
+
children: "3. HINGE & EXPLODE PREVIEW"
|
|
1660
|
+
}),
|
|
1661
|
+
/* @__PURE__ */ O("label", {
|
|
1662
|
+
style: {
|
|
1663
|
+
display: "grid",
|
|
1664
|
+
gridTemplateColumns: "62px 1fr 42px",
|
|
1665
|
+
alignItems: "center",
|
|
1666
|
+
gap: 6,
|
|
1667
|
+
fontSize: 10.5
|
|
1668
|
+
},
|
|
1669
|
+
children: [
|
|
1670
|
+
/* @__PURE__ */ D("span", { children: "Hinges" }),
|
|
1671
|
+
/* @__PURE__ */ D("input", {
|
|
1672
|
+
type: "range",
|
|
1673
|
+
min: 0,
|
|
1674
|
+
max: 1,
|
|
1675
|
+
step: .02,
|
|
1676
|
+
value: e.hingeScrub,
|
|
1677
|
+
onChange: (t) => e.onChangeHingeScrub(Number(t.target.value)),
|
|
1678
|
+
style: { accentColor: "#10B981" }
|
|
1679
|
+
}),
|
|
1680
|
+
/* @__PURE__ */ D("span", {
|
|
1681
|
+
style: {
|
|
1682
|
+
textAlign: "right",
|
|
1683
|
+
color: "#10B981"
|
|
1684
|
+
},
|
|
1685
|
+
children: `${Math.round(e.hingeScrub * 100)}%`
|
|
1686
|
+
})
|
|
1687
|
+
]
|
|
1688
|
+
}),
|
|
1689
|
+
/* @__PURE__ */ O("label", {
|
|
1690
|
+
style: {
|
|
1691
|
+
display: "grid",
|
|
1692
|
+
gridTemplateColumns: "62px 1fr 42px",
|
|
1693
|
+
alignItems: "center",
|
|
1694
|
+
gap: 6,
|
|
1695
|
+
fontSize: 10.5
|
|
1696
|
+
},
|
|
1697
|
+
children: [
|
|
1698
|
+
/* @__PURE__ */ D("span", { children: "Explode" }),
|
|
1699
|
+
/* @__PURE__ */ D("input", {
|
|
1700
|
+
type: "range",
|
|
1701
|
+
min: 0,
|
|
1702
|
+
max: 1.2,
|
|
1703
|
+
step: .02,
|
|
1704
|
+
value: e.explodeAmount,
|
|
1705
|
+
onChange: (t) => e.onChangeExplodeAmount(Number(t.target.value)),
|
|
1706
|
+
style: { accentColor: "#FFB000" }
|
|
1707
|
+
}),
|
|
1708
|
+
/* @__PURE__ */ D("span", {
|
|
1709
|
+
style: {
|
|
1710
|
+
textAlign: "right",
|
|
1711
|
+
color: "#FFB000"
|
|
1712
|
+
},
|
|
1713
|
+
children: `${e.explodeAmount.toFixed(2)}m`
|
|
1714
|
+
})
|
|
1715
|
+
]
|
|
1716
|
+
})
|
|
1717
|
+
]
|
|
1718
|
+
}),
|
|
1719
|
+
/* @__PURE__ */ O("div", {
|
|
1720
|
+
style: dt,
|
|
1721
|
+
children: [
|
|
1722
|
+
/* @__PURE__ */ D("span", {
|
|
1723
|
+
style: {
|
|
1724
|
+
fontSize: 10,
|
|
1725
|
+
color: "#94A3B8",
|
|
1726
|
+
letterSpacing: "0.06em"
|
|
1727
|
+
},
|
|
1728
|
+
children: "4. WHEELS & POWERTRAIN"
|
|
1729
|
+
}),
|
|
1730
|
+
/* @__PURE__ */ O("div", {
|
|
1731
|
+
style: {
|
|
1732
|
+
display: "grid",
|
|
1733
|
+
gridTemplateColumns: "1fr 1fr",
|
|
1734
|
+
gap: 5
|
|
1735
|
+
},
|
|
1736
|
+
children: [/* @__PURE__ */ D(U, {
|
|
1737
|
+
label: "Imported Tires",
|
|
1738
|
+
active: e.wheelSource === "imported",
|
|
1739
|
+
color: "#00E5FF",
|
|
1740
|
+
onClick: () => e.onChangeWheelSource("imported")
|
|
1741
|
+
}), /* @__PURE__ */ D(U, {
|
|
1742
|
+
label: "12-Gon Fleet",
|
|
1743
|
+
active: e.wheelSource === "fleet12",
|
|
1744
|
+
color: "#10B981",
|
|
1745
|
+
onClick: () => e.onChangeWheelSource("fleet12")
|
|
1746
|
+
})]
|
|
1747
|
+
}),
|
|
1748
|
+
/* @__PURE__ */ D("div", {
|
|
1749
|
+
style: {
|
|
1750
|
+
display: "grid",
|
|
1751
|
+
gridTemplateColumns: "repeat(3, 1fr)",
|
|
1752
|
+
gap: 5
|
|
1753
|
+
},
|
|
1754
|
+
children: [
|
|
1755
|
+
"AWD",
|
|
1756
|
+
"RWD",
|
|
1757
|
+
"FWD"
|
|
1758
|
+
].map((t) => /* @__PURE__ */ D(U, {
|
|
1759
|
+
label: t,
|
|
1760
|
+
active: e.driveType === t,
|
|
1761
|
+
color: "#FFB000",
|
|
1762
|
+
onClick: () => e.onChangeDriveType(t)
|
|
1763
|
+
}, t))
|
|
1764
|
+
}),
|
|
1765
|
+
/* @__PURE__ */ O("label", {
|
|
1766
|
+
style: {
|
|
1767
|
+
display: "grid",
|
|
1768
|
+
gridTemplateColumns: "62px 1fr 46px",
|
|
1769
|
+
alignItems: "center",
|
|
1770
|
+
gap: 6,
|
|
1771
|
+
fontSize: 10.5
|
|
1772
|
+
},
|
|
1773
|
+
children: [
|
|
1774
|
+
/* @__PURE__ */ D("span", { children: "Power" }),
|
|
1775
|
+
/* @__PURE__ */ D("input", {
|
|
1776
|
+
type: "range",
|
|
1777
|
+
min: 90,
|
|
1778
|
+
max: 720,
|
|
1779
|
+
step: 10,
|
|
1780
|
+
value: e.horsepower,
|
|
1781
|
+
onChange: (t) => e.onChangeHorsepower(Number(t.target.value)),
|
|
1782
|
+
style: { accentColor: "#FFB000" }
|
|
1783
|
+
}),
|
|
1784
|
+
/* @__PURE__ */ D("span", {
|
|
1785
|
+
style: {
|
|
1786
|
+
textAlign: "right",
|
|
1787
|
+
color: "#FFB000"
|
|
1788
|
+
},
|
|
1789
|
+
children: `${e.horsepower}HP`
|
|
1790
|
+
})
|
|
1791
|
+
]
|
|
1792
|
+
})
|
|
1793
|
+
]
|
|
1794
|
+
}),
|
|
1795
|
+
e.statusNote && /* @__PURE__ */ D("div", {
|
|
1796
|
+
style: {
|
|
1797
|
+
fontSize: 10.5,
|
|
1798
|
+
color: "#34D399",
|
|
1799
|
+
padding: "4px 6px",
|
|
1800
|
+
background: "rgba(16,185,129,0.1)",
|
|
1801
|
+
border: "1px solid rgba(16,185,129,0.35)",
|
|
1802
|
+
borderRadius: 4
|
|
1803
|
+
},
|
|
1804
|
+
children: e.statusNote
|
|
1805
|
+
}),
|
|
1806
|
+
/* @__PURE__ */ O("div", {
|
|
1807
|
+
style: {
|
|
1808
|
+
display: "grid",
|
|
1809
|
+
gap: 6,
|
|
1810
|
+
marginTop: "auto"
|
|
1811
|
+
},
|
|
1812
|
+
children: [/* @__PURE__ */ D(U, {
|
|
1813
|
+
label: "[ -> STEP 2: COMPILE & TEST TRACK (WASD) ]",
|
|
1814
|
+
active: e.unlocked,
|
|
1815
|
+
disabled: !e.unlocked || e.busy,
|
|
1816
|
+
color: "#FFB000",
|
|
1817
|
+
onClick: e.onGoTestDrive
|
|
1818
|
+
}), e.onSpawnWorld && /* @__PURE__ */ D(U, {
|
|
1819
|
+
label: e.busy ? "[ COMPILING KHR3… ]" : "[ -> SPAWN & DRIVE ON LONG DRIVE ]",
|
|
1820
|
+
active: e.unlocked,
|
|
1821
|
+
disabled: !e.unlocked || e.busy,
|
|
1822
|
+
color: "#10B981",
|
|
1823
|
+
onClick: e.onSpawnWorld
|
|
1824
|
+
})]
|
|
1825
|
+
})
|
|
1826
|
+
]
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
// src/importer/launcherBake.ts
|
|
1830
|
+
var pt = {
|
|
1831
|
+
receiver: "#334155",
|
|
1832
|
+
barrel: "#1e293b",
|
|
1833
|
+
bolt: "#94a3b8",
|
|
1834
|
+
pump: "#b45309",
|
|
1835
|
+
trigger: "#cbd5e1",
|
|
1836
|
+
magazine: "#0f172a",
|
|
1837
|
+
stock: "#475569",
|
|
1838
|
+
screen_rect: "#38bdf8"
|
|
1839
|
+
};
|
|
1840
|
+
function mt(e, t) {
|
|
1841
|
+
let n = new p.Group();
|
|
1842
|
+
n.name = e.recipeId;
|
|
1843
|
+
let r = /* @__PURE__ */ new Map([["root", n]]);
|
|
1844
|
+
for (let i of e.nodes) {
|
|
1845
|
+
let a = r.get(i.parent) ?? n, o;
|
|
1846
|
+
if (i.size[0] > 0 && i.size[1] > 0 && i.size[2] > 0) {
|
|
1847
|
+
let n = e.parts.find((e) => e.name === i.name || `${e.name}_Collider` === i.name), r = pt[n?.role ?? "receiver"] ?? "#475569", a = new p.MeshStandardMaterial({
|
|
1848
|
+
color: r,
|
|
1849
|
+
roughness: .72,
|
|
1850
|
+
metalness: .28,
|
|
1851
|
+
flatShading: !0
|
|
1852
|
+
}), s = new p.Mesh(new p.BoxGeometry(i.size[0], i.size[1], i.size[2]), a);
|
|
1853
|
+
t && n && !n.joint && (s.visible = !1), o = s;
|
|
1854
|
+
} else o = new p.Group();
|
|
1855
|
+
o.name = i.name, o.position.set(i.position[0], i.position[1], i.position[2]), a.add(o), r.set(i.name, o);
|
|
1856
|
+
}
|
|
1857
|
+
if (t) {
|
|
1858
|
+
let e = r.get("Receiver_Root") ?? n, i = t.clone(!0);
|
|
1859
|
+
i.name = "Launcher_VisualMesh", e.add(i);
|
|
1860
|
+
}
|
|
1861
|
+
return n;
|
|
1862
|
+
}
|
|
1863
|
+
async function ht(e = P, n, r = []) {
|
|
1864
|
+
let i = typeof e == "string" ? pe.find((t) => t.id === e) ?? me("kolmogorov_carbine") : e, a = he(i), o = mt(a, n), s = new Uint8Array(await C(o, a.specs, {
|
|
1865
|
+
gateDomain: "launcher",
|
|
1866
|
+
launcher: a.spec,
|
|
1867
|
+
ikSockets: a.sockets
|
|
1868
|
+
})), c = t(s, r), l = c instanceof Uint8Array ? c : new Uint8Array(c), u = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
|
|
1869
|
+
return {
|
|
1870
|
+
glbBytes: l,
|
|
1871
|
+
bundle: await w(u),
|
|
1872
|
+
plan: a
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
// src/importer/DomainWorkshopPanel.tsx
|
|
1876
|
+
var gt = {
|
|
1877
|
+
position: "absolute",
|
|
1878
|
+
top: 52,
|
|
1879
|
+
left: 12,
|
|
1880
|
+
width: 292,
|
|
1881
|
+
maxHeight: "calc(100% - 110px)",
|
|
1882
|
+
overflowY: "auto",
|
|
1883
|
+
padding: 12,
|
|
1884
|
+
background: "rgba(10,12,14,0.94)",
|
|
1885
|
+
border: "1px solid #1C2229",
|
|
1886
|
+
borderRadius: 4,
|
|
1887
|
+
color: "#E6EDF3",
|
|
1888
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1889
|
+
fontSize: 11,
|
|
1890
|
+
zIndex: 22,
|
|
1891
|
+
display: "flex",
|
|
1892
|
+
flexDirection: "column",
|
|
1893
|
+
gap: 8
|
|
1894
|
+
}, W = {
|
|
1895
|
+
padding: "5px 8px",
|
|
1896
|
+
background: "#11161C",
|
|
1897
|
+
border: "1px solid #00E5FF",
|
|
1898
|
+
color: "#E6EDF3",
|
|
1899
|
+
borderRadius: 2,
|
|
1900
|
+
fontSize: 10.5,
|
|
1901
|
+
fontFamily: "inherit",
|
|
1902
|
+
cursor: "pointer",
|
|
1903
|
+
textAlign: "left"
|
|
1904
|
+
};
|
|
1905
|
+
function _t(e) {
|
|
1906
|
+
if (!e) return 0;
|
|
1907
|
+
let t = 0;
|
|
1908
|
+
return e.traverse((e) => {
|
|
1909
|
+
let n = e;
|
|
1910
|
+
if (n.isMesh && n.material) for (let e of Array.isArray(n.material) ? n.material : [n.material]) {
|
|
1911
|
+
let n = e;
|
|
1912
|
+
n.flatShading = !0, n.normalMap = null, n.bumpMap = null, n.map && (n.map.magFilter = p.NearestFilter, n.map.anisotropy = 1, n.map.needsUpdate = !0), n.needsUpdate = !0, t++;
|
|
1913
|
+
}
|
|
1914
|
+
}), t;
|
|
1915
|
+
}
|
|
1916
|
+
function vt({ domain: e, targetMeters: t, onChangeTargetMeters: n, onSnapC12: r, onLoadVaultUrl: i, onForgeLauncherRecipe: a, onAddSocketPatch: o, onEnforceCrispyPerson: s, onUploadToVault: c }) {
|
|
1917
|
+
let [l, u] = f(!1), [d, p] = f("cars"), [m, h] = f(""), [g, _] = f(null);
|
|
1918
|
+
if (e === "vehicle" && !l) return null;
|
|
1919
|
+
let v = Object.entries(N[d]);
|
|
1920
|
+
return /* @__PURE__ */ O("aside", {
|
|
1921
|
+
style: gt,
|
|
1922
|
+
"aria-label": `${e.toUpperCase()} Workshop`,
|
|
1923
|
+
children: [
|
|
1924
|
+
/* @__PURE__ */ O("div", {
|
|
1925
|
+
style: {
|
|
1926
|
+
display: "flex",
|
|
1927
|
+
justifyContent: "space-between",
|
|
1928
|
+
alignItems: "center",
|
|
1929
|
+
color: "#FFB000",
|
|
1930
|
+
fontWeight: 700
|
|
1931
|
+
},
|
|
1932
|
+
children: [/* @__PURE__ */ D("span", { children: `WORKSHOP :: ${e.toUpperCase()}` }), /* @__PURE__ */ D("button", {
|
|
1933
|
+
type: "button",
|
|
1934
|
+
style: {
|
|
1935
|
+
...W,
|
|
1936
|
+
padding: "2px 6px",
|
|
1937
|
+
borderColor: "#10B981"
|
|
1938
|
+
},
|
|
1939
|
+
onClick: () => u((e) => !e),
|
|
1940
|
+
children: l ? "HIDE VAULT" : "R2 VAULT"
|
|
1941
|
+
})]
|
|
1942
|
+
}),
|
|
1943
|
+
e === "c12" && /* @__PURE__ */ O(E, { children: [
|
|
1944
|
+
/* @__PURE__ */ D("div", {
|
|
1945
|
+
style: { color: "#94A3B8" },
|
|
1946
|
+
children: "Exact 3.0m / 0.25m C12 Cyclotomic Lattice & Openings"
|
|
1947
|
+
}),
|
|
1948
|
+
/* @__PURE__ */ D("button", {
|
|
1949
|
+
type: "button",
|
|
1950
|
+
style: W,
|
|
1951
|
+
onClick: () => {
|
|
1952
|
+
n(3), r(), _("Snapped to 3.00 m C12 module (12 steps).");
|
|
1953
|
+
},
|
|
1954
|
+
children: "[ SNAP TO 3.00M C12 MODULE ]"
|
|
1955
|
+
}),
|
|
1956
|
+
/* @__PURE__ */ D("button", {
|
|
1957
|
+
type: "button",
|
|
1958
|
+
style: W,
|
|
1959
|
+
onClick: () => {
|
|
1960
|
+
o("Aperture_Doorway_900x2100", [
|
|
1961
|
+
0,
|
|
1962
|
+
se.openingHeightM * .5,
|
|
1963
|
+
0
|
|
1964
|
+
]), o("Socket_DoorHinge", [...se.hingeOffsetLocal]), _("Stamped 900x2100 doorway + KHR revolute hinge socket.");
|
|
1965
|
+
},
|
|
1966
|
+
children: "[ STAMP 0.9x2.1M HINGED DOORWAY ]"
|
|
1967
|
+
}),
|
|
1968
|
+
/* @__PURE__ */ D("button", {
|
|
1969
|
+
type: "button",
|
|
1970
|
+
style: W,
|
|
1971
|
+
onClick: () => {
|
|
1972
|
+
o("Aperture_Window", [
|
|
1973
|
+
0,
|
|
1974
|
+
1.45,
|
|
1975
|
+
0
|
|
1976
|
+
]), _("Stamped window opening anchor.");
|
|
1977
|
+
},
|
|
1978
|
+
children: "[ STAMP WINDOW APERTURE ]"
|
|
1979
|
+
}),
|
|
1980
|
+
/* @__PURE__ */ D("button", {
|
|
1981
|
+
type: "button",
|
|
1982
|
+
style: W,
|
|
1983
|
+
onClick: () => i(N.city.door_hinged_single, "door_hinged_900x2100"),
|
|
1984
|
+
children: "[ LOAD VAULT: HINGED DOOR .GLB ]"
|
|
1985
|
+
})
|
|
1986
|
+
] }),
|
|
1987
|
+
e === "launcher" && /* @__PURE__ */ O(E, { children: [
|
|
1988
|
+
/* @__PURE__ */ D("div", {
|
|
1989
|
+
style: { color: "#94A3B8" },
|
|
1990
|
+
children: "Articulated `@khr3/launchers` Forger (`Receiver_Root` + `Bolt`/`Pump`/`Trigger` KHR drives)"
|
|
1991
|
+
}),
|
|
1992
|
+
/* @__PURE__ */ D("div", {
|
|
1993
|
+
style: {
|
|
1994
|
+
display: "flex",
|
|
1995
|
+
flexWrap: "wrap",
|
|
1996
|
+
gap: 4
|
|
1997
|
+
},
|
|
1998
|
+
children: pe.map((e) => /* @__PURE__ */ D("button", {
|
|
1999
|
+
type: "button",
|
|
2000
|
+
style: {
|
|
2001
|
+
...W,
|
|
2002
|
+
borderColor: "#FFB000",
|
|
2003
|
+
fontSize: 10
|
|
2004
|
+
},
|
|
2005
|
+
onClick: () => {
|
|
2006
|
+
let t = he(e), n = Number((e.dims.receiverLength + e.dims.barrelLength + (e.dims.hasStock ? .22 : 0)).toFixed(2));
|
|
2007
|
+
a?.(e.id, mt(t), n), _(`Forged ${e.label} (${t.parts.length} parts, ${e.spec.magazineCapacity} rd, ${e.spec.fireRateHz} Hz)`);
|
|
2008
|
+
},
|
|
2009
|
+
children: `FORGE ${e.id.replace("kolmogorov_", "").toUpperCase()}`
|
|
2010
|
+
}, e.id))
|
|
2011
|
+
}),
|
|
2012
|
+
/* @__PURE__ */ O("label", {
|
|
2013
|
+
style: {
|
|
2014
|
+
display: "flex",
|
|
2015
|
+
justifyContent: "space-between",
|
|
2016
|
+
alignItems: "center"
|
|
2017
|
+
},
|
|
2018
|
+
children: [/* @__PURE__ */ D("span", { children: "Length (m):" }), /* @__PURE__ */ D("input", {
|
|
2019
|
+
type: "number",
|
|
2020
|
+
step: .05,
|
|
2021
|
+
min: .12,
|
|
2022
|
+
max: 2.2,
|
|
2023
|
+
value: t,
|
|
2024
|
+
onChange: (e) => n(Number(e.target.value) || .72),
|
|
2025
|
+
style: {
|
|
2026
|
+
width: 72,
|
|
2027
|
+
background: "#0A0C0E",
|
|
2028
|
+
color: "#00E5FF",
|
|
2029
|
+
border: "1px solid #1C2229",
|
|
2030
|
+
padding: "2px 4px"
|
|
2031
|
+
}
|
|
2032
|
+
})]
|
|
2033
|
+
}),
|
|
2034
|
+
[
|
|
2035
|
+
["IK_Palm_Primary", [
|
|
2036
|
+
0,
|
|
2037
|
+
-.06,
|
|
2038
|
+
-.08
|
|
2039
|
+
]],
|
|
2040
|
+
["IK_Index_Trigger", [
|
|
2041
|
+
0,
|
|
2042
|
+
-.02,
|
|
2043
|
+
-.02
|
|
2044
|
+
]],
|
|
2045
|
+
["IK_Palm_Forend", [
|
|
2046
|
+
0,
|
|
2047
|
+
-.03,
|
|
2048
|
+
.22
|
|
2049
|
+
]],
|
|
2050
|
+
["Socket_Muzzle", [
|
|
2051
|
+
0,
|
|
2052
|
+
.04,
|
|
2053
|
+
t * .5
|
|
2054
|
+
]],
|
|
2055
|
+
["Socket_Eject", [
|
|
2056
|
+
.03,
|
|
2057
|
+
.04,
|
|
2058
|
+
.02
|
|
2059
|
+
]],
|
|
2060
|
+
["screen_rect", [
|
|
2061
|
+
0,
|
|
2062
|
+
.07,
|
|
2063
|
+
-.12
|
|
2064
|
+
]]
|
|
2065
|
+
].map(([e, t]) => /* @__PURE__ */ D("button", {
|
|
2066
|
+
type: "button",
|
|
2067
|
+
style: W,
|
|
2068
|
+
onClick: () => {
|
|
2069
|
+
o(e, [
|
|
2070
|
+
t[0],
|
|
2071
|
+
t[1],
|
|
2072
|
+
t[2]
|
|
2073
|
+
]), _(`Stamped ${e}`);
|
|
2074
|
+
},
|
|
2075
|
+
children: `+ STAMP ${e}`
|
|
2076
|
+
}, e)),
|
|
2077
|
+
/* @__PURE__ */ D("div", {
|
|
2078
|
+
style: {
|
|
2079
|
+
display: "flex",
|
|
2080
|
+
flexWrap: "wrap",
|
|
2081
|
+
gap: 4
|
|
2082
|
+
},
|
|
2083
|
+
children: Object.entries(N.weapons).map(([e, t]) => /* @__PURE__ */ D("button", {
|
|
2084
|
+
type: "button",
|
|
2085
|
+
style: {
|
|
2086
|
+
...W,
|
|
2087
|
+
borderColor: "#10B981",
|
|
2088
|
+
fontSize: 9.5
|
|
2089
|
+
},
|
|
2090
|
+
onClick: () => i(t, e),
|
|
2091
|
+
children: e.replace("kolmogorov_", "").toUpperCase()
|
|
2092
|
+
}, e))
|
|
2093
|
+
})
|
|
2094
|
+
] }),
|
|
2095
|
+
e === "person" && /* @__PURE__ */ O(E, { children: [
|
|
2096
|
+
/* @__PURE__ */ D("div", {
|
|
2097
|
+
style: { color: "#94A3B8" },
|
|
2098
|
+
children: "SI 1.75m Capsule (`BODY_SI`) & Faceted Mixamo Rig"
|
|
2099
|
+
}),
|
|
2100
|
+
/* @__PURE__ */ D("button", {
|
|
2101
|
+
type: "button",
|
|
2102
|
+
style: W,
|
|
2103
|
+
onClick: () => {
|
|
2104
|
+
n(le.capsuleHalfHeight * 2 + le.capsuleRadius * 2 + le.floatHeight), _("Scaled character to exact 1.75 m SI standing height.");
|
|
2105
|
+
},
|
|
2106
|
+
children: "[ LOCK 1.75M SI STANDING HEIGHT ]"
|
|
2107
|
+
}),
|
|
2108
|
+
/* @__PURE__ */ D("button", {
|
|
2109
|
+
type: "button",
|
|
2110
|
+
style: W,
|
|
2111
|
+
onClick: () => {
|
|
2112
|
+
s(), _("Stripped normalMap/bumpMap + forced flatShading & NearestFilter.");
|
|
2113
|
+
},
|
|
2114
|
+
children: "[ ENFORCE FACETED RETRO SHADING ]"
|
|
2115
|
+
}),
|
|
2116
|
+
/* @__PURE__ */ D("button", {
|
|
2117
|
+
type: "button",
|
|
2118
|
+
style: W,
|
|
2119
|
+
onClick: () => {
|
|
2120
|
+
o("Socket_Hand_R", [
|
|
2121
|
+
.22,
|
|
2122
|
+
1.12,
|
|
2123
|
+
.28
|
|
2124
|
+
]), o("Socket_Hand_L", [
|
|
2125
|
+
-.22,
|
|
2126
|
+
1.12,
|
|
2127
|
+
.28
|
|
2128
|
+
]), o("Socket_Back", [
|
|
2129
|
+
0,
|
|
2130
|
+
1.25,
|
|
2131
|
+
-.18
|
|
2132
|
+
]), _("Stamped Socket_Hand_R, Socket_Hand_L & Socket_Back.");
|
|
2133
|
+
},
|
|
2134
|
+
children: "[ STAMP HAND & BACK SOCKETS ]"
|
|
2135
|
+
})
|
|
2136
|
+
] }),
|
|
2137
|
+
(e === "prop" || e === "junk") && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
2138
|
+
style: { color: "#94A3B8" },
|
|
2139
|
+
children: e === "junk" ? "BVH Shatter & Local Decal Target" : "KHR Convex/Box Prop"
|
|
2140
|
+
}), /* @__PURE__ */ D("button", {
|
|
2141
|
+
type: "button",
|
|
2142
|
+
style: W,
|
|
2143
|
+
onClick: () => i(N.city.prop_arcade_cabinet, "prop_arcade_cabinet"),
|
|
2144
|
+
children: "[ LOAD VAULT: ARCADE CABINET ]"
|
|
2145
|
+
})] }),
|
|
2146
|
+
l && /* @__PURE__ */ O("div", {
|
|
2147
|
+
style: {
|
|
2148
|
+
borderTop: "1px solid #1C2229",
|
|
2149
|
+
paddingTop: 8,
|
|
2150
|
+
display: "flex",
|
|
2151
|
+
flexDirection: "column",
|
|
2152
|
+
gap: 6
|
|
2153
|
+
},
|
|
2154
|
+
children: [
|
|
2155
|
+
/* @__PURE__ */ D("div", {
|
|
2156
|
+
style: {
|
|
2157
|
+
display: "flex",
|
|
2158
|
+
gap: 4
|
|
2159
|
+
},
|
|
2160
|
+
children: [
|
|
2161
|
+
"cars",
|
|
2162
|
+
"weapons",
|
|
2163
|
+
"city"
|
|
2164
|
+
].map((e) => /* @__PURE__ */ D("button", {
|
|
2165
|
+
type: "button",
|
|
2166
|
+
style: {
|
|
2167
|
+
...W,
|
|
2168
|
+
borderColor: d === e ? "#FFB000" : "#1C2229"
|
|
2169
|
+
},
|
|
2170
|
+
onClick: () => p(e),
|
|
2171
|
+
children: e.toUpperCase()
|
|
2172
|
+
}, e))
|
|
2173
|
+
}),
|
|
2174
|
+
/* @__PURE__ */ D("div", {
|
|
2175
|
+
style: {
|
|
2176
|
+
maxHeight: 120,
|
|
2177
|
+
overflowY: "auto",
|
|
2178
|
+
display: "flex",
|
|
2179
|
+
flexDirection: "column",
|
|
2180
|
+
gap: 3
|
|
2181
|
+
},
|
|
2182
|
+
children: v.map(([e, t]) => /* @__PURE__ */ D("button", {
|
|
2183
|
+
type: "button",
|
|
2184
|
+
style: {
|
|
2185
|
+
...W,
|
|
2186
|
+
fontSize: 10
|
|
2187
|
+
},
|
|
2188
|
+
onClick: () => i(t, e),
|
|
2189
|
+
children: `-> ${e}`
|
|
2190
|
+
}, e))
|
|
2191
|
+
}),
|
|
2192
|
+
c && /* @__PURE__ */ O("div", {
|
|
2193
|
+
style: {
|
|
2194
|
+
display: "flex",
|
|
2195
|
+
gap: 4
|
|
2196
|
+
},
|
|
2197
|
+
children: [/* @__PURE__ */ D("input", {
|
|
2198
|
+
type: "password",
|
|
2199
|
+
placeholder: "VAULT_WRITE_TOKEN",
|
|
2200
|
+
value: m,
|
|
2201
|
+
onChange: (e) => h(e.target.value),
|
|
2202
|
+
style: {
|
|
2203
|
+
flex: 1,
|
|
2204
|
+
background: "#0A0C0E",
|
|
2205
|
+
color: "#E6EDF3",
|
|
2206
|
+
border: "1px solid #1C2229",
|
|
2207
|
+
padding: "3px 5px",
|
|
2208
|
+
fontSize: 10
|
|
2209
|
+
}
|
|
2210
|
+
}), /* @__PURE__ */ D("button", {
|
|
2211
|
+
type: "button",
|
|
2212
|
+
style: {
|
|
2213
|
+
...W,
|
|
2214
|
+
borderColor: "#10B981"
|
|
2215
|
+
},
|
|
2216
|
+
onClick: () => {
|
|
2217
|
+
c(d, m), _(`Uploading to ${ue().baseUrl}/assets/${d}…`);
|
|
2218
|
+
},
|
|
2219
|
+
children: "PUT R2"
|
|
2220
|
+
})]
|
|
2221
|
+
})
|
|
2222
|
+
]
|
|
2223
|
+
}),
|
|
2224
|
+
g && /* @__PURE__ */ D("div", {
|
|
2225
|
+
style: {
|
|
2226
|
+
color: "#10B981",
|
|
2227
|
+
fontSize: 10
|
|
2228
|
+
},
|
|
2229
|
+
children: g
|
|
2230
|
+
})
|
|
2231
|
+
]
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
// src/importer/gateStore.ts
|
|
2235
|
+
var yt = Object.freeze({
|
|
2236
|
+
TRUCK: 1.4,
|
|
2237
|
+
STREET: 1.9,
|
|
2238
|
+
SPORT: 2.8
|
|
2239
|
+
}), bt = Object.freeze({
|
|
2240
|
+
PLUSH: .65,
|
|
2241
|
+
BALANCED: .75,
|
|
2242
|
+
STIFF: .85
|
|
2243
|
+
}), G = {
|
|
2244
|
+
massKg: 780,
|
|
2245
|
+
com: [
|
|
2246
|
+
0,
|
|
2247
|
+
.42,
|
|
2248
|
+
.08
|
|
2249
|
+
],
|
|
2250
|
+
frontSplit: .53,
|
|
2251
|
+
cornerK: [28500, 26200],
|
|
2252
|
+
speedKmh: 0,
|
|
2253
|
+
rpm: 850,
|
|
2254
|
+
sparkBurst: null,
|
|
2255
|
+
massDirty: !0
|
|
2256
|
+
};
|
|
2257
|
+
function xt(e, t, n, r) {
|
|
2258
|
+
let [i, a, o] = e.aabbSize, s = i >= .04 && a >= .04 && o >= .04 && Math.max(i, a, o) <= 120, c = Math.abs(e.minY) <= .005;
|
|
2259
|
+
if (!s || !c) return !1;
|
|
2260
|
+
if (t === "c12") return e.c12Aligned;
|
|
2261
|
+
if (t === "vehicle" && (r || n === "car")) {
|
|
2262
|
+
let t = e.wheelbase >= 1.2 && e.wheelbase <= 5.6, n = e.wheelRadii.every((e) => e >= .16 && e <= .65);
|
|
2263
|
+
return t && n;
|
|
2264
|
+
}
|
|
2265
|
+
return !0;
|
|
2266
|
+
}
|
|
2267
|
+
var K = ge((e) => ({
|
|
2268
|
+
step: 1,
|
|
2269
|
+
domain: "vehicle",
|
|
2270
|
+
vehicleArchetype: "car",
|
|
2271
|
+
usePaperShellProxy: !1,
|
|
2272
|
+
presetId: "coupe_86",
|
|
2273
|
+
shadingMode: "psx-flat",
|
|
2274
|
+
eraMode: "dreamcast-60",
|
|
2275
|
+
freqBucket: "STREET",
|
|
2276
|
+
dampBucket: "BALANCED",
|
|
2277
|
+
wrenchMode: "UNLATCH_200",
|
|
2278
|
+
driveType: "AWD",
|
|
2279
|
+
staticProp: !1,
|
|
2280
|
+
massKg: 1380,
|
|
2281
|
+
powerOrThrust: 240,
|
|
2282
|
+
attachedMask: _e,
|
|
2283
|
+
unlatchedMask: 0,
|
|
2284
|
+
fuelLiters: 42,
|
|
2285
|
+
dropTrigger: 0,
|
|
2286
|
+
chaseCam: !0,
|
|
2287
|
+
detachedDebris: [],
|
|
2288
|
+
calibration: {
|
|
2289
|
+
wheelbase: 2.4,
|
|
2290
|
+
trackWidth: 1.36,
|
|
2291
|
+
wheelRadii: [
|
|
2292
|
+
.31,
|
|
2293
|
+
.31,
|
|
2294
|
+
.31,
|
|
2295
|
+
.31
|
|
2296
|
+
],
|
|
2297
|
+
minY: 0,
|
|
2298
|
+
aabbSize: [
|
|
2299
|
+
1.62,
|
|
2300
|
+
1.28,
|
|
2301
|
+
4.18
|
|
2302
|
+
],
|
|
2303
|
+
c12Ticks: [
|
|
2304
|
+
19,
|
|
2305
|
+
15,
|
|
2306
|
+
50
|
|
2307
|
+
],
|
|
2308
|
+
c12Aligned: !1,
|
|
2309
|
+
detectedAnchors: [],
|
|
2310
|
+
isSingleMeshProxy: !1
|
|
2311
|
+
},
|
|
2312
|
+
setField: (t, n) => e({ [t]: n }),
|
|
2313
|
+
setCalibration: (t) => e({ calibration: t }),
|
|
2314
|
+
triggerDrop: () => e((e) => ({ dropTrigger: e.dropTrigger + 1 })),
|
|
2315
|
+
resetAllPanels: () => {
|
|
2316
|
+
G.massDirty = !0, e({
|
|
2317
|
+
attachedMask: _e,
|
|
2318
|
+
unlatchedMask: 0,
|
|
2319
|
+
detachedDebris: []
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
})), St = "#0A0C0E", Ct = "#1C2229", wt = "#FFB000", q = "#00E5FF", Tt = "#FF3B30", Et = "#10B981", Dt = "#E6EDF3";
|
|
2323
|
+
function J({ label: e, active: t = !1, disabled: n = !1, accent: r = wt, onClick: i }) {
|
|
2324
|
+
return /* @__PURE__ */ D("button", {
|
|
2325
|
+
type: "button",
|
|
2326
|
+
disabled: n,
|
|
2327
|
+
onClick: i,
|
|
2328
|
+
style: {
|
|
2329
|
+
padding: "4px 8px",
|
|
2330
|
+
borderRadius: 2,
|
|
2331
|
+
border: `1px solid ${n ? Ct : t ? r : q}`,
|
|
2332
|
+
background: t ? r : St,
|
|
2333
|
+
color: n ? "#55606E" : t ? St : Dt,
|
|
2334
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2335
|
+
fontSize: 10.5,
|
|
2336
|
+
fontWeight: t ? 700 : 500,
|
|
2337
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
2338
|
+
whiteSpace: "nowrap"
|
|
2339
|
+
},
|
|
2340
|
+
children: e
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
var Ot = {
|
|
2344
|
+
display: "flex",
|
|
2345
|
+
flexWrap: "wrap",
|
|
2346
|
+
justifyContent: "space-between",
|
|
2347
|
+
alignItems: "center",
|
|
2348
|
+
gap: 8,
|
|
2349
|
+
padding: "8px 12px",
|
|
2350
|
+
background: St,
|
|
2351
|
+
borderBottom: `1px solid ${Ct}`,
|
|
2352
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2353
|
+
zIndex: 20
|
|
2354
|
+
};
|
|
2355
|
+
function kt(e) {
|
|
2356
|
+
let t = K(), n = xt(t.calibration, t.domain, t.vehicleArchetype, t.usePaperShellProxy), r = d(null);
|
|
2357
|
+
l(() => {
|
|
2358
|
+
let n = 0, i = "", a = () => {
|
|
2359
|
+
let o = G.massKg.toFixed(0), s = G.com.map((e) => e.toFixed(2)).join(","), c = G.speedKmh.toFixed(0), l = G.rpm.toFixed(0), u = t.domain === "vehicle" ? `MASS=${o}KG COM=[${s}] HINGED=${e.choppedCount} ${l} RPM ${c} KM/H` : `MASS=${o}KG COM=[${s}] PATCHES=${e.patchCount} ${c} KM/H`;
|
|
2360
|
+
u !== i && r.current && (r.current.textContent = u, i = u), n = requestAnimationFrame(a);
|
|
2361
|
+
};
|
|
2362
|
+
return n = requestAnimationFrame(a), () => cancelAnimationFrame(n);
|
|
2363
|
+
}, [
|
|
2364
|
+
t.domain,
|
|
2365
|
+
e.patchCount,
|
|
2366
|
+
e.choppedCount
|
|
2367
|
+
]);
|
|
2368
|
+
let i = t.calibration, a = t.domain === "c12" ? `C12=[${i.c12Ticks.join("x")}]TICKS (${i.c12Aligned ? "ALIGNED" : "OFF-GRID"}) MIN_Y=${i.minY.toFixed(4)}M AABB=[${i.aabbSize.join("x")}]M` : t.domain === "launcher" ? `ANCHORS=${i.detectedAnchors.length || 1} MIN_Y=${i.minY.toFixed(4)}M AABB=[${i.aabbSize.join("x")}]M` : `WB=${i.wheelbase.toFixed(2)}M MIN_Y=${i.minY.toFixed(4)}M AABB=[${i.aabbSize.join("x")}]M`;
|
|
2369
|
+
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ O("div", {
|
|
2370
|
+
style: Ot,
|
|
2371
|
+
children: [/* @__PURE__ */ O("div", {
|
|
2372
|
+
style: {
|
|
2373
|
+
display: "flex",
|
|
2374
|
+
flexWrap: "wrap",
|
|
2375
|
+
gap: 6,
|
|
2376
|
+
alignItems: "center"
|
|
2377
|
+
},
|
|
2378
|
+
children: [
|
|
2379
|
+
/* @__PURE__ */ D("span", {
|
|
2380
|
+
style: {
|
|
2381
|
+
fontSize: 11,
|
|
2382
|
+
color: wt,
|
|
2383
|
+
fontWeight: 700
|
|
2384
|
+
},
|
|
2385
|
+
children: `KOLMO :: CAR CHOP-SHOP & GLB GATE · ${e.assetName.toUpperCase()}`
|
|
2386
|
+
}),
|
|
2387
|
+
[
|
|
2388
|
+
"vehicle",
|
|
2389
|
+
"c12",
|
|
2390
|
+
"launcher",
|
|
2391
|
+
"person",
|
|
2392
|
+
"prop",
|
|
2393
|
+
"junk"
|
|
2394
|
+
].map((n) => /* @__PURE__ */ D(J, {
|
|
2395
|
+
label: `[ ${n.toUpperCase()} ]`,
|
|
2396
|
+
active: t.domain === n,
|
|
2397
|
+
onClick: () => e.onSelectDomain(n)
|
|
2398
|
+
}, n)),
|
|
2399
|
+
/* @__PURE__ */ D(J, {
|
|
2400
|
+
label: e.hasCustomFile ? "[ REPLACE .GLB · .USD… ]" : "[ DROP / OPEN .GLB · .USD ]",
|
|
2401
|
+
accent: q,
|
|
2402
|
+
onClick: e.onChooseFile
|
|
2403
|
+
}),
|
|
2404
|
+
!e.hasCustomFile && t.domain === "vehicle" && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(J, {
|
|
2405
|
+
label: "BLANK: SOLID PICKUP",
|
|
2406
|
+
active: e.assetName === "pickup_truck",
|
|
2407
|
+
accent: Et,
|
|
2408
|
+
onClick: () => e.onLoadStarterCar("/models/pickup-truck.glb", "pickup_truck")
|
|
2409
|
+
}), /* @__PURE__ */ D(J, {
|
|
2410
|
+
label: "BLANK: HATCHBACK",
|
|
2411
|
+
active: e.assetName === "hatchback_86",
|
|
2412
|
+
accent: Et,
|
|
2413
|
+
onClick: () => e.onLoadStarterCar("/models/Hatchback-segmented.glb", "hatchback_86")
|
|
2414
|
+
})] }),
|
|
2415
|
+
e.usdInfo && /* @__PURE__ */ D("span", {
|
|
2416
|
+
style: {
|
|
2417
|
+
fontSize: 10,
|
|
2418
|
+
color: Et
|
|
2419
|
+
},
|
|
2420
|
+
children: e.usdInfo
|
|
2421
|
+
})
|
|
2422
|
+
]
|
|
2423
|
+
}), /* @__PURE__ */ O("div", {
|
|
2424
|
+
style: {
|
|
2425
|
+
display: "flex",
|
|
2426
|
+
flexWrap: "wrap",
|
|
2427
|
+
gap: 6,
|
|
2428
|
+
alignItems: "center"
|
|
2429
|
+
},
|
|
2430
|
+
children: [
|
|
2431
|
+
/* @__PURE__ */ D(J, {
|
|
2432
|
+
label: t.eraMode === "dreamcast-60" ? "[ ERA: DREAMCAST 60FPS ]" : "[ ERA: PSX 1/3 ]",
|
|
2433
|
+
active: t.eraMode === "psx-1-3",
|
|
2434
|
+
accent: q,
|
|
2435
|
+
onClick: () => t.setField("eraMode", t.eraMode === "dreamcast-60" ? "psx-1-3" : "dreamcast-60")
|
|
2436
|
+
}),
|
|
2437
|
+
/* @__PURE__ */ D(J, {
|
|
2438
|
+
label: "[ STEP 1: CHOP & CALIBRATE ]",
|
|
2439
|
+
active: t.step === 1,
|
|
2440
|
+
onClick: () => t.setField("step", 1)
|
|
2441
|
+
}),
|
|
2442
|
+
/* @__PURE__ */ D(J, {
|
|
2443
|
+
label: "[ -> STEP 2: LIVE DRIVE TRACK (WASD) ]",
|
|
2444
|
+
active: t.step === 2,
|
|
2445
|
+
disabled: !n,
|
|
2446
|
+
accent: n ? wt : Tt,
|
|
2447
|
+
onClick: () => t.setField("step", 2)
|
|
2448
|
+
})
|
|
2449
|
+
]
|
|
2450
|
+
})]
|
|
2451
|
+
}), /* @__PURE__ */ O("div", {
|
|
2452
|
+
style: {
|
|
2453
|
+
...Ot,
|
|
2454
|
+
position: "absolute",
|
|
2455
|
+
left: 0,
|
|
2456
|
+
right: 0,
|
|
2457
|
+
bottom: 0,
|
|
2458
|
+
borderBottom: "none",
|
|
2459
|
+
borderTop: `1px solid ${Ct}`
|
|
2460
|
+
},
|
|
2461
|
+
children: [t.step === 1 ? /* @__PURE__ */ O("div", {
|
|
2462
|
+
style: {
|
|
2463
|
+
display: "flex",
|
|
2464
|
+
flexWrap: "wrap",
|
|
2465
|
+
gap: 6,
|
|
2466
|
+
alignItems: "center"
|
|
2467
|
+
},
|
|
2468
|
+
children: [
|
|
2469
|
+
/* @__PURE__ */ D(J, {
|
|
2470
|
+
label: "[ ROT X +90° ]",
|
|
2471
|
+
onClick: () => e.onBumpTurn(0)
|
|
2472
|
+
}),
|
|
2473
|
+
/* @__PURE__ */ D(J, {
|
|
2474
|
+
label: "[ ROT Y +90° ]",
|
|
2475
|
+
onClick: () => e.onBumpTurn(1)
|
|
2476
|
+
}),
|
|
2477
|
+
/* @__PURE__ */ D(J, {
|
|
2478
|
+
label: "[ ROT Z +90° ]",
|
|
2479
|
+
onClick: () => e.onBumpTurn(2)
|
|
2480
|
+
}),
|
|
2481
|
+
/* @__PURE__ */ D(J, {
|
|
2482
|
+
label: "[ AUTO-SCALE SI ]",
|
|
2483
|
+
onClick: e.onAutoScaleSi
|
|
2484
|
+
}),
|
|
2485
|
+
/* @__PURE__ */ D(J, {
|
|
2486
|
+
label: "[ SNAP TIRES Y=0 ]",
|
|
2487
|
+
onClick: e.onSnapYZero
|
|
2488
|
+
}),
|
|
2489
|
+
t.domain === "c12" && /* @__PURE__ */ D(J, {
|
|
2490
|
+
label: "[ SNAP 1/12M C12 ]",
|
|
2491
|
+
accent: Et,
|
|
2492
|
+
onClick: e.onSnapC12
|
|
2493
|
+
}),
|
|
2494
|
+
t.domain === "vehicle" && /* @__PURE__ */ O(E, { children: [
|
|
2495
|
+
[
|
|
2496
|
+
"car",
|
|
2497
|
+
"motorcycle",
|
|
2498
|
+
"starcraft"
|
|
2499
|
+
].map((n) => /* @__PURE__ */ D(J, {
|
|
2500
|
+
label: n.toUpperCase(),
|
|
2501
|
+
active: !t.usePaperShellProxy && t.vehicleArchetype === n,
|
|
2502
|
+
onClick: () => e.onSelectVehicleSub(n)
|
|
2503
|
+
}, n)),
|
|
2504
|
+
!t.usePaperShellProxy && t.vehicleArchetype !== "starcraft" && /* @__PURE__ */ D(J, {
|
|
2505
|
+
label: `[ AUTO-POP TIRES (${e.wheelCount}W) ]`,
|
|
2506
|
+
onClick: e.onAutoPopWheels
|
|
2507
|
+
}),
|
|
2508
|
+
/* @__PURE__ */ D(J, {
|
|
2509
|
+
label: "[ C0 CRASH PROXY ]",
|
|
2510
|
+
active: t.usePaperShellProxy,
|
|
2511
|
+
onClick: e.onWrapProxy
|
|
2512
|
+
})
|
|
2513
|
+
] }),
|
|
2514
|
+
t.domain === "prop" && /* @__PURE__ */ D(J, {
|
|
2515
|
+
label: t.staticProp ? "[ STATIC HULL ]" : "[ DYNAMIC HULL ]",
|
|
2516
|
+
active: t.staticProp,
|
|
2517
|
+
onClick: () => t.setField("staticProp", !t.staticProp)
|
|
2518
|
+
}),
|
|
2519
|
+
/* @__PURE__ */ D("span", {
|
|
2520
|
+
style: {
|
|
2521
|
+
fontSize: 10.5,
|
|
2522
|
+
color: n ? q : Tt
|
|
2523
|
+
},
|
|
2524
|
+
children: a
|
|
2525
|
+
})
|
|
2526
|
+
]
|
|
2527
|
+
}) : /* @__PURE__ */ O("div", {
|
|
2528
|
+
style: {
|
|
2529
|
+
display: "flex",
|
|
2530
|
+
flexWrap: "wrap",
|
|
2531
|
+
gap: 6,
|
|
2532
|
+
alignItems: "center"
|
|
2533
|
+
},
|
|
2534
|
+
children: [
|
|
2535
|
+
/* @__PURE__ */ D(J, {
|
|
2536
|
+
label: "[ RESET / DROP ]",
|
|
2537
|
+
accent: wt,
|
|
2538
|
+
onClick: () => t.triggerDrop()
|
|
2539
|
+
}),
|
|
2540
|
+
t.domain === "vehicle" && /* @__PURE__ */ D(J, {
|
|
2541
|
+
label: t.chaseCam ? "[ CAM: CHASE (WASD) ]" : "[ CAM: ORBIT ]",
|
|
2542
|
+
active: t.chaseCam,
|
|
2543
|
+
accent: Et,
|
|
2544
|
+
onClick: () => t.setField("chaseCam", !t.chaseCam)
|
|
2545
|
+
}),
|
|
2546
|
+
t.domain === "vehicle" && t.usePaperShellProxy ? /* @__PURE__ */ O(E, { children: [
|
|
2547
|
+
/* @__PURE__ */ D(J, {
|
|
2548
|
+
label: t.wrenchMode === "UNLATCH_200" ? "[ WRENCH: 200 N·S UNLATCH ]" : "[ WRENCH: 1800 N·S RIP OFF ]",
|
|
2549
|
+
active: t.wrenchMode === "RIP_1800",
|
|
2550
|
+
accent: Tt,
|
|
2551
|
+
onClick: () => t.setField("wrenchMode", t.wrenchMode === "UNLATCH_200" ? "RIP_1800" : "UNLATCH_200")
|
|
2552
|
+
}),
|
|
2553
|
+
[
|
|
2554
|
+
"TRUCK",
|
|
2555
|
+
"STREET",
|
|
2556
|
+
"SPORT"
|
|
2557
|
+
].map((e) => /* @__PURE__ */ D(J, {
|
|
2558
|
+
label: e,
|
|
2559
|
+
active: t.freqBucket === e,
|
|
2560
|
+
onClick: () => t.setField("freqBucket", e)
|
|
2561
|
+
}, e)),
|
|
2562
|
+
[
|
|
2563
|
+
"PLUSH",
|
|
2564
|
+
"BALANCED",
|
|
2565
|
+
"STIFF"
|
|
2566
|
+
].map((e) => /* @__PURE__ */ D(J, {
|
|
2567
|
+
label: e,
|
|
2568
|
+
active: t.dampBucket === e,
|
|
2569
|
+
accent: q,
|
|
2570
|
+
onClick: () => t.setField("dampBucket", e)
|
|
2571
|
+
}, e)),
|
|
2572
|
+
/* @__PURE__ */ D(J, {
|
|
2573
|
+
label: "[ RESET PANELS ]",
|
|
2574
|
+
onClick: () => t.resetAllPanels()
|
|
2575
|
+
})
|
|
2576
|
+
] }) : /* @__PURE__ */ O(E, { children: [
|
|
2577
|
+
t.domain === "vehicle" && e.choppedCount > 0 && /* @__PURE__ */ O(E, { children: [
|
|
2578
|
+
/* @__PURE__ */ D(J, {
|
|
2579
|
+
label: "[ SWING DOORS ]",
|
|
2580
|
+
accent: wt,
|
|
2581
|
+
onClick: () => e.onSwingPanelRole("door")
|
|
2582
|
+
}),
|
|
2583
|
+
/* @__PURE__ */ D(J, {
|
|
2584
|
+
label: "[ POP HOOD ]",
|
|
2585
|
+
accent: Et,
|
|
2586
|
+
onClick: () => e.onSwingPanelRole("hood")
|
|
2587
|
+
}),
|
|
2588
|
+
/* @__PURE__ */ D(J, {
|
|
2589
|
+
label: "[ POP TRUNK ]",
|
|
2590
|
+
accent: q,
|
|
2591
|
+
onClick: () => e.onSwingPanelRole("trunk")
|
|
2592
|
+
})
|
|
2593
|
+
] }),
|
|
2594
|
+
[
|
|
2595
|
+
"none",
|
|
2596
|
+
"plume",
|
|
2597
|
+
"sparkle",
|
|
2598
|
+
"brake_flare",
|
|
2599
|
+
"headlight",
|
|
2600
|
+
"seat"
|
|
2601
|
+
].map((t) => /* @__PURE__ */ D(J, {
|
|
2602
|
+
label: `STAMP:${t.toUpperCase()}`,
|
|
2603
|
+
active: e.stampTool === t,
|
|
2604
|
+
onClick: () => e.onSelectStampTool(t)
|
|
2605
|
+
}, t)),
|
|
2606
|
+
e.patchCount > 0 && /* @__PURE__ */ D(J, {
|
|
2607
|
+
label: `[ UNDO (${e.patchCount}) ]`,
|
|
2608
|
+
onClick: e.onUndoPatch
|
|
2609
|
+
})
|
|
2610
|
+
] }),
|
|
2611
|
+
/* @__PURE__ */ D(J, {
|
|
2612
|
+
label: "[ DOWNLOAD KHR3 .GLB ]",
|
|
2613
|
+
disabled: e.busy,
|
|
2614
|
+
accent: q,
|
|
2615
|
+
onClick: e.onDownloadGlb
|
|
2616
|
+
}),
|
|
2617
|
+
e.onSpawnWorld && /* @__PURE__ */ D(J, {
|
|
2618
|
+
label: e.busy ? "[ SEALING… ]" : "[ DRIVE ON LONG DRIVE -> ]",
|
|
2619
|
+
disabled: e.busy,
|
|
2620
|
+
accent: Et,
|
|
2621
|
+
onClick: e.onSpawnWorld
|
|
2622
|
+
})
|
|
2623
|
+
]
|
|
2624
|
+
}), /* @__PURE__ */ D("span", {
|
|
2625
|
+
ref: r,
|
|
2626
|
+
style: {
|
|
2627
|
+
fontSize: 10.5,
|
|
2628
|
+
color: q
|
|
2629
|
+
}
|
|
2630
|
+
})]
|
|
2631
|
+
})] });
|
|
2632
|
+
}
|
|
2633
|
+
// src/importer/importerWebMcp.ts
|
|
2634
|
+
function At() {
|
|
2635
|
+
if (typeof navigator > "u") return null;
|
|
2636
|
+
let e = navigator.modelContext;
|
|
2637
|
+
return e && typeof e.registerTool == "function" ? e : null;
|
|
2638
|
+
}
|
|
2639
|
+
function jt(e) {
|
|
2640
|
+
let t = ue();
|
|
2641
|
+
return [
|
|
2642
|
+
{
|
|
2643
|
+
name: "importer_state",
|
|
2644
|
+
description: "Read current calibration bounds, SI scale, domain, step, wheel axles, and unlock status.",
|
|
2645
|
+
inputSchema: {
|
|
2646
|
+
type: "object",
|
|
2647
|
+
properties: {}
|
|
2648
|
+
},
|
|
2649
|
+
annotations: { readOnlyHint: !0 },
|
|
2650
|
+
execute: () => {
|
|
2651
|
+
let t = K.getState();
|
|
2652
|
+
return {
|
|
2653
|
+
assetName: e.assetName,
|
|
2654
|
+
domain: t.domain,
|
|
2655
|
+
step: t.step,
|
|
2656
|
+
vehicleArchetype: t.vehicleArchetype,
|
|
2657
|
+
targetMeters: e.targetMeters,
|
|
2658
|
+
wheelCount: e.wheelCount,
|
|
2659
|
+
choppedCount: e.choppedCount,
|
|
2660
|
+
unlocked: e.unlocked,
|
|
2661
|
+
calibration: t.calibration
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
},
|
|
2665
|
+
{
|
|
2666
|
+
name: "importer_capture_view",
|
|
2667
|
+
description: "Capture current 3D calibration viewport PNG data URL.",
|
|
2668
|
+
inputSchema: {
|
|
2669
|
+
type: "object",
|
|
2670
|
+
properties: {}
|
|
2671
|
+
},
|
|
2672
|
+
annotations: { readOnlyHint: !0 },
|
|
2673
|
+
execute: () => ({ dataUrl: e.captureDataUrl?.() ?? null })
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
name: "importer_list_models",
|
|
2677
|
+
description: "List available starter and R2 vault .glb models across cars, weapons, and city categories.",
|
|
2678
|
+
inputSchema: {
|
|
2679
|
+
type: "object",
|
|
2680
|
+
properties: { prefix: { type: "string" } }
|
|
2681
|
+
},
|
|
2682
|
+
annotations: { readOnlyHint: !0 },
|
|
2683
|
+
execute: async (e) => {
|
|
2684
|
+
let n = typeof e.prefix == "string" ? e.prefix : "";
|
|
2685
|
+
try {
|
|
2686
|
+
let e = await t.listPrefix(n);
|
|
2687
|
+
return {
|
|
2688
|
+
catalog: N,
|
|
2689
|
+
liveVault: e
|
|
2690
|
+
};
|
|
2691
|
+
} catch {
|
|
2692
|
+
return {
|
|
2693
|
+
catalog: N,
|
|
2694
|
+
liveVault: null
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
},
|
|
2699
|
+
{
|
|
2700
|
+
name: "importer_set_stage",
|
|
2701
|
+
description: "Switch importer stage (1 = Chop & Calibrate, 2 = Live Drive / Seal Pad).",
|
|
2702
|
+
inputSchema: {
|
|
2703
|
+
type: "object",
|
|
2704
|
+
properties: { step: {
|
|
2705
|
+
type: "number",
|
|
2706
|
+
enum: [1, 2]
|
|
2707
|
+
} },
|
|
2708
|
+
required: ["step"]
|
|
2709
|
+
},
|
|
2710
|
+
execute: (e) => {
|
|
2711
|
+
let t = e.step === 2 ? 2 : 1;
|
|
2712
|
+
return K.getState().setField("step", t), {
|
|
2713
|
+
ok: !0,
|
|
2714
|
+
step: t
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
},
|
|
2718
|
+
{
|
|
2719
|
+
name: "importer_load",
|
|
2720
|
+
description: "Load a .glb model by URL or vault key into the calibration bay.",
|
|
2721
|
+
inputSchema: {
|
|
2722
|
+
type: "object",
|
|
2723
|
+
properties: {
|
|
2724
|
+
url: { type: "string" },
|
|
2725
|
+
name: { type: "string" }
|
|
2726
|
+
},
|
|
2727
|
+
required: ["url"]
|
|
2728
|
+
},
|
|
2729
|
+
execute: (n) => {
|
|
2730
|
+
let r = String(n.url ?? ""), i = r.startsWith("http") || r.startsWith("/") ? r : t.url(r), a = typeof n.name == "string" ? n.name : r.split("/").pop()?.replace(/\.glb$/i, "") ?? "asset";
|
|
2731
|
+
return e.loadStarterCar(i, a), {
|
|
2732
|
+
ok: !0,
|
|
2733
|
+
url: i,
|
|
2734
|
+
label: a
|
|
2735
|
+
};
|
|
2736
|
+
}
|
|
2737
|
+
},
|
|
2738
|
+
{
|
|
2739
|
+
name: "importer_orient",
|
|
2740
|
+
description: "Rotate asset in exact 90-degree quarter-turns around X (0), Y (1), or Z (2).",
|
|
2741
|
+
inputSchema: {
|
|
2742
|
+
type: "object",
|
|
2743
|
+
properties: { axis: {
|
|
2744
|
+
type: "number",
|
|
2745
|
+
enum: [
|
|
2746
|
+
0,
|
|
2747
|
+
1,
|
|
2748
|
+
2
|
|
2749
|
+
]
|
|
2750
|
+
} },
|
|
2751
|
+
required: ["axis"]
|
|
2752
|
+
},
|
|
2753
|
+
execute: (t) => {
|
|
2754
|
+
let n = t.axis === 1 ? 1 : t.axis === 2 ? 2 : 0;
|
|
2755
|
+
return e.bumpTurn(n), {
|
|
2756
|
+
ok: !0,
|
|
2757
|
+
axis: n
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
name: "importer_scale",
|
|
2763
|
+
description: "Scale asset cleanly to exact SI target meters with [1,1,1] node scale and Y=0 contact.",
|
|
2764
|
+
inputSchema: {
|
|
2765
|
+
type: "object",
|
|
2766
|
+
properties: { meters: { type: "number" } },
|
|
2767
|
+
required: ["meters"]
|
|
2768
|
+
},
|
|
2769
|
+
execute: (t) => {
|
|
2770
|
+
let n = Math.max(.05, Number(t.meters) || 1);
|
|
2771
|
+
return e.setTargetMeters(n), {
|
|
2772
|
+
ok: !0,
|
|
2773
|
+
targetMeters: n
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
},
|
|
2777
|
+
{
|
|
2778
|
+
name: "importer_set_kind",
|
|
2779
|
+
description: "Set asset domain (vehicle, c12, launcher, person, prop, junk) and optional vehicle archetype.",
|
|
2780
|
+
inputSchema: {
|
|
2781
|
+
type: "object",
|
|
2782
|
+
properties: {
|
|
2783
|
+
domain: {
|
|
2784
|
+
type: "string",
|
|
2785
|
+
enum: [
|
|
2786
|
+
"vehicle",
|
|
2787
|
+
"c12",
|
|
2788
|
+
"launcher",
|
|
2789
|
+
"person",
|
|
2790
|
+
"prop",
|
|
2791
|
+
"junk"
|
|
2792
|
+
]
|
|
2793
|
+
},
|
|
2794
|
+
archetype: {
|
|
2795
|
+
type: "string",
|
|
2796
|
+
enum: [
|
|
2797
|
+
"car",
|
|
2798
|
+
"motorcycle",
|
|
2799
|
+
"starcraft"
|
|
2800
|
+
]
|
|
2801
|
+
}
|
|
2802
|
+
},
|
|
2803
|
+
required: ["domain"]
|
|
2804
|
+
},
|
|
2805
|
+
execute: (t) => {
|
|
2806
|
+
let n = t.domain || "vehicle", r = t.archetype || "car";
|
|
2807
|
+
return e.applyDomainDefaults(n, r, !1), {
|
|
2808
|
+
ok: !0,
|
|
2809
|
+
domain: n,
|
|
2810
|
+
archetype: r
|
|
2811
|
+
};
|
|
2812
|
+
}
|
|
2813
|
+
},
|
|
2814
|
+
{
|
|
2815
|
+
name: "importer_pop_wheels",
|
|
2816
|
+
description: "Auto-detect and pair symmetric wheel islands into Ecctrl ShapeCastWheel axles.",
|
|
2817
|
+
inputSchema: {
|
|
2818
|
+
type: "object",
|
|
2819
|
+
properties: {}
|
|
2820
|
+
},
|
|
2821
|
+
execute: () => (e.autoPopWheels(), { ok: !0 })
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
name: "importer_set_points",
|
|
2825
|
+
description: "Stamp an explicit IK / muzzle / grip / doorway socket point in local SI meters.",
|
|
2826
|
+
inputSchema: {
|
|
2827
|
+
type: "object",
|
|
2828
|
+
properties: {
|
|
2829
|
+
name: { type: "string" },
|
|
2830
|
+
position: {
|
|
2831
|
+
type: "array",
|
|
2832
|
+
items: { type: "number" },
|
|
2833
|
+
minItems: 3,
|
|
2834
|
+
maxItems: 3
|
|
2835
|
+
}
|
|
2836
|
+
},
|
|
2837
|
+
required: ["name", "position"]
|
|
2838
|
+
},
|
|
2839
|
+
execute: (t) => {
|
|
2840
|
+
let n = t.position, r = [
|
|
2841
|
+
Number(n[0]) || 0,
|
|
2842
|
+
Number(n[1]) || 0,
|
|
2843
|
+
Number(n[2]) || 0
|
|
2844
|
+
];
|
|
2845
|
+
return e.addAnchorPoint(String(t.name), r), {
|
|
2846
|
+
ok: !0,
|
|
2847
|
+
name: t.name,
|
|
2848
|
+
position: r
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2851
|
+
},
|
|
2852
|
+
{
|
|
2853
|
+
name: "importer_export",
|
|
2854
|
+
description: "Bake and export the KHR_physics_rigid_bodies .glb (or spawn straight into the active world).",
|
|
2855
|
+
inputSchema: {
|
|
2856
|
+
type: "object",
|
|
2857
|
+
properties: { spawnInWorld: { type: "boolean" } }
|
|
2858
|
+
},
|
|
2859
|
+
execute: async (t) => (await e.sealAndExport(!!t.spawnInWorld), { ok: !0 })
|
|
2860
|
+
}
|
|
2861
|
+
];
|
|
2862
|
+
}
|
|
2863
|
+
function Mt(e, t = !0) {
|
|
2864
|
+
let n = At();
|
|
2865
|
+
return l(() => {
|
|
2866
|
+
if (!t || !n) return;
|
|
2867
|
+
let r = new AbortController(), i = jt(e);
|
|
2868
|
+
for (let e of i) n.registerTool(e, { signal: r.signal });
|
|
2869
|
+
return () => {
|
|
2870
|
+
r.abort();
|
|
2871
|
+
for (let e of i) n.unregisterTool?.(e.name);
|
|
2872
|
+
};
|
|
2873
|
+
}, [
|
|
2874
|
+
t,
|
|
2875
|
+
n,
|
|
2876
|
+
e
|
|
2877
|
+
]), !!(t && n);
|
|
2878
|
+
}
|
|
2879
|
+
// src/importer/Step1CalibrationPlinth.tsx
|
|
2880
|
+
function Nt(e, t) {
|
|
2881
|
+
let n = new p.BufferGeometry();
|
|
2882
|
+
return n.setAttribute("position", new p.BufferAttribute(e, 3)), n.setAttribute("normal", new p.BufferAttribute(t, 3)), n;
|
|
2883
|
+
}
|
|
2884
|
+
function Pt(e) {
|
|
2885
|
+
let t = new p.Group();
|
|
2886
|
+
t.name = `Starter_${e}`;
|
|
2887
|
+
let n = e === "c12" ? new p.BoxGeometry(3, 3, 3) : e === "person" ? new p.CapsuleGeometry(.3, 1, 6, 12) : e === "launcher" ? new p.BoxGeometry(.14, .24, .92) : e === "junk" ? new p.CylinderGeometry(.32, .34, .85, 12) : new p.BoxGeometry(1.72, 1.25, 4.25), r = new p.Mesh(n, new p.MeshStandardMaterial({
|
|
2888
|
+
color: "#38bdf8",
|
|
2889
|
+
roughness: .55,
|
|
2890
|
+
flatShading: !0
|
|
2891
|
+
}));
|
|
2892
|
+
return r.position.y = e === "c12" ? 1.5 : e === "person" ? .88 : .65, t.add(r), t;
|
|
2893
|
+
}
|
|
2894
|
+
var Ft = Object.fromEntries(Pe.filter((e) => e.role !== "wheel").map((e) => [e.role, e.color]));
|
|
2895
|
+
function It(t) {
|
|
2896
|
+
let n = K((e) => e.calibration), r = d(!1), i = u(() => t.assembly.panels.map((e) => Nt(e.localPositions, e.localNormals)), [t.assembly]), a = u(() => Nt(t.assembly.wheels[0].positions, t.assembly.wheels[0].normals), [t.assembly]);
|
|
2897
|
+
l(() => {
|
|
2898
|
+
let e = () => {
|
|
2899
|
+
r.current = !1;
|
|
2900
|
+
};
|
|
2901
|
+
return window.addEventListener("pointerup", e), () => window.removeEventListener("pointerup", e);
|
|
2902
|
+
}, []);
|
|
2903
|
+
let o = u(() => t.faceSelection ? t.islands.find((e) => e.id === t.faceSelection.islandId) ?? null : null, [t.faceSelection, t.islands]), s = u(() => o && t.faceSelection && t.faceSelection.triangles.length > 0 ? nt(o.geometry, t.faceSelection.triangles, .0045) : null, [o, t.faceSelection]), c = u(() => o && t.faceSelection && t.faceSelection.mirrored.length > 0 ? nt(o.geometry, t.faceSelection.mirrored, .0045) : null, [o, t.faceSelection]);
|
|
2904
|
+
l(() => () => {
|
|
2905
|
+
s?.dispose();
|
|
2906
|
+
}, [s]), l(() => () => {
|
|
2907
|
+
c?.dispose();
|
|
2908
|
+
}, [c]);
|
|
2909
|
+
let f = u(() => {
|
|
2910
|
+
if (!t.loopDots || t.loopDots.points.length < 2) return null;
|
|
2911
|
+
let e = t.islands.find((e) => e.id === t.loopDots.islandId);
|
|
2912
|
+
return e ? Xe(e, t.loopDots.points) : null;
|
|
2913
|
+
}, [t.loopDots, t.islands]), m = u(() => {
|
|
2914
|
+
if (t.wheelSource !== "fleet12" || t.islands.length === 0) return [];
|
|
2915
|
+
let e = [];
|
|
2916
|
+
return t.axles.forEach((n, r) => {
|
|
2917
|
+
for (let [i, a] of [["L", n.left], ["R", n.right]]) {
|
|
2918
|
+
if (a.length === 0) continue;
|
|
2919
|
+
let n = I(t.islands, a), o = Math.max(.14, n.radius), s = Math.max(.1, n.halfWidth * 2);
|
|
2920
|
+
e.push({
|
|
2921
|
+
key: `f12_${r}_${i}`,
|
|
2922
|
+
pos: n.center,
|
|
2923
|
+
group: rt(o, s)
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
}), e;
|
|
2927
|
+
}, [
|
|
2928
|
+
t.wheelSource,
|
|
2929
|
+
t.axles,
|
|
2930
|
+
t.islands
|
|
2931
|
+
]), h = (e, n, r) => {
|
|
2932
|
+
e.faceIndex != null && (e.stopPropagation(), t.onPickFace({
|
|
2933
|
+
islandId: n,
|
|
2934
|
+
faceIndex: e.faceIndex,
|
|
2935
|
+
point: [
|
|
2936
|
+
e.point.x,
|
|
2937
|
+
e.point.y,
|
|
2938
|
+
e.point.z
|
|
2939
|
+
],
|
|
2940
|
+
erase: !!(e.altKey || e.button === 2),
|
|
2941
|
+
isDrag: r
|
|
2942
|
+
}));
|
|
2943
|
+
};
|
|
2944
|
+
return /* @__PURE__ */ D(g, {
|
|
2945
|
+
fit: !0,
|
|
2946
|
+
clip: !0,
|
|
2947
|
+
margin: 1.38,
|
|
2948
|
+
children: /* @__PURE__ */ O(_, {
|
|
2949
|
+
firstHitOnly: !0,
|
|
2950
|
+
children: [/* @__PURE__ */ O("group", {
|
|
2951
|
+
ref: t.rootObjRef,
|
|
2952
|
+
children: [t.useProxy ? /* @__PURE__ */ O(E, { children: [
|
|
2953
|
+
t.previewScene && /* @__PURE__ */ D("primitive", { object: t.previewScene }),
|
|
2954
|
+
t.assembly.panels.map((e, n) => /* @__PURE__ */ D("mesh", {
|
|
2955
|
+
position: e.anchorChassis,
|
|
2956
|
+
geometry: i[n],
|
|
2957
|
+
children: /* @__PURE__ */ D("meshStandardMaterial", {
|
|
2958
|
+
color: e.colorHex,
|
|
2959
|
+
roughness: e.isGlass ? .15 : .88,
|
|
2960
|
+
transparent: e.isGlass || !!t.previewScene,
|
|
2961
|
+
opacity: t.previewScene ? .28 : e.isGlass ? .32 : 1,
|
|
2962
|
+
wireframe: !!t.previewScene,
|
|
2963
|
+
flatShading: t.assembly.shadingMode === "psx-flat"
|
|
2964
|
+
})
|
|
2965
|
+
}, e.partId)),
|
|
2966
|
+
t.assembly.wheels.map((e) => /* @__PURE__ */ D("group", {
|
|
2967
|
+
position: e.position,
|
|
2968
|
+
children: /* @__PURE__ */ D("mesh", {
|
|
2969
|
+
geometry: a,
|
|
2970
|
+
children: /* @__PURE__ */ D("meshStandardMaterial", {
|
|
2971
|
+
color: 1843753,
|
|
2972
|
+
roughness: .9,
|
|
2973
|
+
flatShading: !0
|
|
2974
|
+
})
|
|
2975
|
+
})
|
|
2976
|
+
}, e.slotId))
|
|
2977
|
+
] }) : t.islands.length > 0 ? /* @__PURE__ */ O(E, { children: [
|
|
2978
|
+
t.islands.map((n) => {
|
|
2979
|
+
let i = t.wheelColors.get(n.id), a = i ? void 0 : t.partPicks[n.id], o = i ?? (a ? Ft[a] : void 0);
|
|
2980
|
+
if (i && t.wheelSource === "fleet12") return null;
|
|
2981
|
+
let s = [
|
|
2982
|
+
0,
|
|
2983
|
+
0,
|
|
2984
|
+
0
|
|
2985
|
+
], c = [
|
|
2986
|
+
0,
|
|
2987
|
+
0,
|
|
2988
|
+
0
|
|
2989
|
+
], l = new p.Quaternion();
|
|
2990
|
+
if (a && (t.hingeScrub > 0 || t.explodeAmount > 0)) {
|
|
2991
|
+
let r = e(n, a);
|
|
2992
|
+
c = r.anchor, t.hingeScrub > 0 && l.setFromAxisAngle(new p.Vector3(...r.axis).normalize(), r.openAngle * t.hingeScrub), t.explodeAmount > 0 && (s = [
|
|
2993
|
+
r.explodeDir[0] * t.explodeAmount,
|
|
2994
|
+
r.explodeDir[1] * t.explodeAmount,
|
|
2995
|
+
r.explodeDir[2] * t.explodeAmount
|
|
2996
|
+
]);
|
|
2997
|
+
} else i && t.explodeAmount > 0 && (s = [
|
|
2998
|
+
Math.sign(n.center[0] || 1) * t.explodeAmount * .65,
|
|
2999
|
+
0,
|
|
3000
|
+
0
|
|
3001
|
+
]);
|
|
3002
|
+
return /* @__PURE__ */ D("group", {
|
|
3003
|
+
position: [
|
|
3004
|
+
c[0] + s[0],
|
|
3005
|
+
c[1] + s[1],
|
|
3006
|
+
c[2] + s[2]
|
|
3007
|
+
],
|
|
3008
|
+
quaternion: l,
|
|
3009
|
+
children: /* @__PURE__ */ O("group", {
|
|
3010
|
+
position: [
|
|
3011
|
+
-c[0],
|
|
3012
|
+
-c[1],
|
|
3013
|
+
-c[2]
|
|
3014
|
+
],
|
|
3015
|
+
children: [/* @__PURE__ */ D("mesh", {
|
|
3016
|
+
geometry: n.geometry,
|
|
3017
|
+
material: n.material,
|
|
3018
|
+
onClick: (e) => {
|
|
3019
|
+
e.delta > 5 || (t.surfaceMode === "island" ? (e.stopPropagation(), t.onClickIsland(n.id)) : t.surfaceMode !== "triangle" && h(e, n.id, !1));
|
|
3020
|
+
},
|
|
3021
|
+
onContextMenu: (e) => {
|
|
3022
|
+
t.surfaceMode !== "island" && h(e, n.id, !1);
|
|
3023
|
+
},
|
|
3024
|
+
onPointerDown: (e) => {
|
|
3025
|
+
t.surfaceMode === "triangle" && (e.button === 0 || e.button === 2) && (r.current = !0, h(e, n.id, !1));
|
|
3026
|
+
},
|
|
3027
|
+
onPointerMove: (e) => {
|
|
3028
|
+
t.surfaceMode === "triangle" && r.current && h(e, n.id, !0);
|
|
3029
|
+
}
|
|
3030
|
+
}), o && /* @__PURE__ */ D("mesh", {
|
|
3031
|
+
geometry: n.geometry,
|
|
3032
|
+
raycast: () => null,
|
|
3033
|
+
children: /* @__PURE__ */ D("meshBasicMaterial", {
|
|
3034
|
+
color: o,
|
|
3035
|
+
transparent: !0,
|
|
3036
|
+
opacity: .38,
|
|
3037
|
+
depthWrite: !1
|
|
3038
|
+
})
|
|
3039
|
+
})]
|
|
3040
|
+
})
|
|
3041
|
+
}, n.id);
|
|
3042
|
+
}),
|
|
3043
|
+
m.map((e) => /* @__PURE__ */ D("primitive", {
|
|
3044
|
+
object: e.group,
|
|
3045
|
+
position: [
|
|
3046
|
+
e.pos[0] + Math.sign(e.pos[0] || 1) * t.explodeAmount * .65,
|
|
3047
|
+
e.pos[1],
|
|
3048
|
+
e.pos[2]
|
|
3049
|
+
]
|
|
3050
|
+
}, e.key)),
|
|
3051
|
+
s && /* @__PURE__ */ D("mesh", {
|
|
3052
|
+
geometry: s,
|
|
3053
|
+
raycast: () => null,
|
|
3054
|
+
children: /* @__PURE__ */ D("meshBasicMaterial", {
|
|
3055
|
+
color: t.activeRoleColor,
|
|
3056
|
+
transparent: !0,
|
|
3057
|
+
opacity: .62,
|
|
3058
|
+
side: p.DoubleSide,
|
|
3059
|
+
depthWrite: !1
|
|
3060
|
+
})
|
|
3061
|
+
}),
|
|
3062
|
+
c && /* @__PURE__ */ D("mesh", {
|
|
3063
|
+
geometry: c,
|
|
3064
|
+
raycast: () => null,
|
|
3065
|
+
children: /* @__PURE__ */ D("meshBasicMaterial", {
|
|
3066
|
+
color: "#00E5FF",
|
|
3067
|
+
transparent: !0,
|
|
3068
|
+
opacity: .48,
|
|
3069
|
+
side: p.DoubleSide,
|
|
3070
|
+
depthWrite: !1
|
|
3071
|
+
})
|
|
3072
|
+
}),
|
|
3073
|
+
t.loopDots?.points.map((e, t) => /* @__PURE__ */ O("mesh", {
|
|
3074
|
+
position: [
|
|
3075
|
+
e[0],
|
|
3076
|
+
e[1],
|
|
3077
|
+
e[2]
|
|
3078
|
+
],
|
|
3079
|
+
raycast: () => null,
|
|
3080
|
+
children: [/* @__PURE__ */ D("sphereGeometry", { args: [
|
|
3081
|
+
.032,
|
|
3082
|
+
10,
|
|
3083
|
+
10
|
|
3084
|
+
] }), /* @__PURE__ */ D("meshBasicMaterial", {
|
|
3085
|
+
color: t === 0 ? "#10B981" : "#FFB000",
|
|
3086
|
+
depthTest: !1
|
|
3087
|
+
})]
|
|
3088
|
+
}, `dot_${t}`)),
|
|
3089
|
+
f && f.length >= 2 && /* @__PURE__ */ D(y, {
|
|
3090
|
+
points: f,
|
|
3091
|
+
color: "#FFB000",
|
|
3092
|
+
lineWidth: 2.5
|
|
3093
|
+
})
|
|
3094
|
+
] }) : t.previewScene && /* @__PURE__ */ D("primitive", { object: t.previewScene }), /* @__PURE__ */ O("mesh", {
|
|
3095
|
+
position: [
|
|
3096
|
+
0,
|
|
3097
|
+
n.aabbSize[1] * .5 + n.minY,
|
|
3098
|
+
0
|
|
3099
|
+
],
|
|
3100
|
+
raycast: () => null,
|
|
3101
|
+
children: [/* @__PURE__ */ D("boxGeometry", { args: [
|
|
3102
|
+
n.aabbSize[0],
|
|
3103
|
+
n.aabbSize[1],
|
|
3104
|
+
n.aabbSize[2]
|
|
3105
|
+
] }), /* @__PURE__ */ D("meshBasicMaterial", {
|
|
3106
|
+
color: 58879,
|
|
3107
|
+
wireframe: !0,
|
|
3108
|
+
transparent: !0,
|
|
3109
|
+
opacity: .28
|
|
3110
|
+
})]
|
|
3111
|
+
})]
|
|
3112
|
+
}), /* @__PURE__ */ O("mesh", {
|
|
3113
|
+
position: [
|
|
3114
|
+
0,
|
|
3115
|
+
.01,
|
|
3116
|
+
Math.max(2.6, n.aabbSize[2] * .6)
|
|
3117
|
+
],
|
|
3118
|
+
rotation: [
|
|
3119
|
+
-Math.PI * .5,
|
|
3120
|
+
0,
|
|
3121
|
+
0
|
|
3122
|
+
],
|
|
3123
|
+
raycast: () => null,
|
|
3124
|
+
children: [/* @__PURE__ */ D("coneGeometry", { args: [
|
|
3125
|
+
.25,
|
|
3126
|
+
.6,
|
|
3127
|
+
3
|
|
3128
|
+
] }), /* @__PURE__ */ D("meshBasicMaterial", {
|
|
3129
|
+
color: 58879,
|
|
3130
|
+
wireframe: !0
|
|
3131
|
+
})]
|
|
3132
|
+
})]
|
|
3133
|
+
})
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3136
|
+
// src/importer/glbNormalizer.ts
|
|
3137
|
+
var Lt = 1 / 12, Rt = Object.freeze([
|
|
3138
|
+
"IK_Palm_Primary",
|
|
3139
|
+
"IK_Index_Trigger",
|
|
3140
|
+
"IK_Thumb_Safety",
|
|
3141
|
+
"IK_Palm_Forend",
|
|
3142
|
+
"Socket_Muzzle",
|
|
3143
|
+
"Socket_Eject",
|
|
3144
|
+
"Socket_HitStart",
|
|
3145
|
+
"Socket_HitEnd",
|
|
3146
|
+
"Socket_Tip",
|
|
3147
|
+
"Socket_Holster",
|
|
3148
|
+
"Socket_Seat",
|
|
3149
|
+
"Socket_Optic"
|
|
3150
|
+
]), Y = new p.Box3(), X = new p.Vector3();
|
|
3151
|
+
function zt(e) {
|
|
3152
|
+
return [
|
|
3153
|
+
e[0] * .5,
|
|
3154
|
+
e[1] * .5,
|
|
3155
|
+
e[2] * .5
|
|
3156
|
+
];
|
|
3157
|
+
}
|
|
3158
|
+
function Bt(e) {
|
|
3159
|
+
return Number((Math.max(1, Math.round(e * 12)) / 12).toFixed(6));
|
|
3160
|
+
}
|
|
3161
|
+
function Vt(e) {
|
|
3162
|
+
let t = [
|
|
3163
|
+
Math.round(e[0] * 12),
|
|
3164
|
+
Math.round(e[1] * 12),
|
|
3165
|
+
Math.round(e[2] * 12)
|
|
3166
|
+
];
|
|
3167
|
+
return {
|
|
3168
|
+
c12Ticks: t,
|
|
3169
|
+
c12Aligned: t.every((e) => e >= 1) && Math.abs(e[0] * 12 - t[0]) <= .06 && Math.abs(e[1] * 12 - t[1]) <= .06 && Math.abs(e[2] * 12 - t[2]) <= .06
|
|
3170
|
+
};
|
|
3171
|
+
}
|
|
3172
|
+
function Ht(e) {
|
|
3173
|
+
if (!e) return [];
|
|
3174
|
+
let t = /* @__PURE__ */ new Set();
|
|
3175
|
+
return e.traverse((e) => {
|
|
3176
|
+
e.name && (Rt.includes(e.name) || e.name.startsWith("IK_") || e.name.startsWith("Socket_") || e.name.startsWith("Kolmo_")) && t.add(e.name);
|
|
3177
|
+
}), [...t];
|
|
3178
|
+
}
|
|
3179
|
+
function Ut(e, t) {
|
|
3180
|
+
return e === "c12" ? {
|
|
3181
|
+
len: 3,
|
|
3182
|
+
massKg: 0,
|
|
3183
|
+
power: 0
|
|
3184
|
+
} : e === "person" ? {
|
|
3185
|
+
len: 1.75,
|
|
3186
|
+
massKg: 72,
|
|
3187
|
+
power: 0
|
|
3188
|
+
} : e === "launcher" ? {
|
|
3189
|
+
len: .92,
|
|
3190
|
+
massKg: 4.2,
|
|
3191
|
+
power: 120
|
|
3192
|
+
} : e === "junk" ? {
|
|
3193
|
+
len: .85,
|
|
3194
|
+
massKg: 18,
|
|
3195
|
+
power: 0
|
|
3196
|
+
} : e === "prop" ? {
|
|
3197
|
+
len: 1.5,
|
|
3198
|
+
massKg: 85,
|
|
3199
|
+
power: 0
|
|
3200
|
+
} : t === "motorcycle" ? {
|
|
3201
|
+
len: 2.08,
|
|
3202
|
+
massKg: 198,
|
|
3203
|
+
power: 165
|
|
3204
|
+
} : t === "starcraft" ? {
|
|
3205
|
+
len: 7.2,
|
|
3206
|
+
massKg: 680,
|
|
3207
|
+
power: 4500
|
|
3208
|
+
} : {
|
|
3209
|
+
len: 4.35,
|
|
3210
|
+
massKg: 1380,
|
|
3211
|
+
power: 260
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
function Wt(e, t = 1, n = 0, r = !1, i = null) {
|
|
3215
|
+
let a = e.lattice.preset, o = a.wheelbase * t, s = a.trackWidth * t, c = Number((a.wheelRadius * t).toFixed(3)), l = (e.lattice.rings[e.lattice.rings.length - 1].z - e.lattice.rings[0].z) * t, u = [
|
|
3216
|
+
Number((a.halfWidth * 2 * t).toFixed(3)),
|
|
3217
|
+
Number((a.roofY * t).toFixed(3)),
|
|
3218
|
+
Number(l.toFixed(3))
|
|
3219
|
+
], { c12Ticks: d, c12Aligned: f } = Vt(u), p = {
|
|
3220
|
+
wheelbase: Number(o.toFixed(3)),
|
|
3221
|
+
trackWidth: Number(s.toFixed(3)),
|
|
3222
|
+
wheelRadii: [
|
|
3223
|
+
c,
|
|
3224
|
+
c,
|
|
3225
|
+
c,
|
|
3226
|
+
c
|
|
3227
|
+
],
|
|
3228
|
+
minY: Number(n.toFixed(4)),
|
|
3229
|
+
aabbSize: u,
|
|
3230
|
+
c12Ticks: d,
|
|
3231
|
+
c12Aligned: f,
|
|
3232
|
+
detectedAnchors: Ht(i),
|
|
3233
|
+
isSingleMeshProxy: r
|
|
3234
|
+
};
|
|
3235
|
+
return K.getState().setCalibration(p), p;
|
|
3236
|
+
}
|
|
3237
|
+
function Gt(e, t = 0) {
|
|
3238
|
+
e.updateMatrixWorld(!0), Y.setFromObject(e), Y.isEmpty() ? X.set(1, 1, 1) : Y.getSize(X);
|
|
3239
|
+
let n = [
|
|
3240
|
+
Number(X.x.toFixed(3)),
|
|
3241
|
+
Number(X.y.toFixed(3)),
|
|
3242
|
+
Number(X.z.toFixed(3))
|
|
3243
|
+
], r = Number(Math.max(1.25, X.z * .62).toFixed(3)), i = Number(Math.max(.4, X.x * .82).toFixed(3)), a = Number(Math.max(.2, Math.min(.45, X.y * .24)).toFixed(3)), { c12Ticks: o, c12Aligned: s } = Vt(n), c = {
|
|
3244
|
+
wheelbase: r,
|
|
3245
|
+
trackWidth: i,
|
|
3246
|
+
wheelRadii: [
|
|
3247
|
+
a,
|
|
3248
|
+
a,
|
|
3249
|
+
a,
|
|
3250
|
+
a
|
|
3251
|
+
],
|
|
3252
|
+
minY: Number(((Y.isEmpty() ? 0 : Y.min.y) + t).toFixed(4)),
|
|
3253
|
+
aabbSize: n,
|
|
3254
|
+
c12Ticks: o,
|
|
3255
|
+
c12Aligned: s,
|
|
3256
|
+
detectedAnchors: Ht(e),
|
|
3257
|
+
isSingleMeshProxy: !1
|
|
3258
|
+
};
|
|
3259
|
+
return K.getState().setCalibration(c), c;
|
|
3260
|
+
}
|
|
3261
|
+
function Kt(e, t = "coupe_86", n = "psx-flat") {
|
|
3262
|
+
let r = ve(t, n);
|
|
3263
|
+
if (!e) return Wt(r, 1, 0, !0, null), r;
|
|
3264
|
+
if (Y.setFromObject(e), Y.isEmpty()) return Wt(r, 1, 0, !0, e), r;
|
|
3265
|
+
Y.getSize(X);
|
|
3266
|
+
let i = r.lattice.rings[r.lattice.rings.length - 1].z - r.lattice.rings[0].z;
|
|
3267
|
+
return Wt(r, X.z > .2 ? Math.max(.5, Math.min(2, X.z / i)) : 1, 0, !0, e), r;
|
|
3268
|
+
}
|
|
3269
|
+
// src/importer/ImperativeVehicleRig.tsx
|
|
3270
|
+
var qt = new p.Vector3(), Jt = new p.Vector3(), Yt = new p.Vector3(), Xt = new p.Quaternion();
|
|
3271
|
+
function Zt(e, t) {
|
|
3272
|
+
let n = new p.BufferGeometry();
|
|
3273
|
+
return n.setAttribute("position", new p.BufferAttribute(e, 3)), n.setAttribute("normal", new p.BufferAttribute(t, 3)), n;
|
|
3274
|
+
}
|
|
3275
|
+
function Qt({ chassisBodyRef: e, panel: t, massKg: n, geometry: r, onWrenchHit: i }) {
|
|
3276
|
+
let a = d(null), o = t.breakaway.hingeAxisLocal ?? [
|
|
3277
|
+
1,
|
|
3278
|
+
0,
|
|
3279
|
+
0
|
|
3280
|
+
], s = t.breakaway.swingMinMaxRad ?? [-1.1, 1.1];
|
|
3281
|
+
return M(e, a, [
|
|
3282
|
+
t.anchorChassis,
|
|
3283
|
+
[
|
|
3284
|
+
0,
|
|
3285
|
+
0,
|
|
3286
|
+
0
|
|
3287
|
+
],
|
|
3288
|
+
o,
|
|
3289
|
+
s
|
|
3290
|
+
]), /* @__PURE__ */ O(j, {
|
|
3291
|
+
ref: a,
|
|
3292
|
+
position: t.anchorChassis,
|
|
3293
|
+
mass: n,
|
|
3294
|
+
colliders: !1,
|
|
3295
|
+
canSleep: !1,
|
|
3296
|
+
children: [/* @__PURE__ */ D(k, { args: zt(t.aabbSize) }), /* @__PURE__ */ D("mesh", {
|
|
3297
|
+
geometry: r,
|
|
3298
|
+
onClick: (e) => {
|
|
3299
|
+
e.stopPropagation(), i(t);
|
|
3300
|
+
},
|
|
3301
|
+
children: /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3302
|
+
color: t.colorHex,
|
|
3303
|
+
roughness: .85,
|
|
3304
|
+
flatShading: !0
|
|
3305
|
+
})
|
|
3306
|
+
})]
|
|
3307
|
+
});
|
|
3308
|
+
}
|
|
3309
|
+
function $t({ assembly: e, importedRoot: t, chassisGroupRef: n }) {
|
|
3310
|
+
let r = d(null), i = d(null), a = d(K.getState().dropTrigger), o = d({
|
|
3311
|
+
w: !1,
|
|
3312
|
+
s: !1,
|
|
3313
|
+
a: !1,
|
|
3314
|
+
d: !1,
|
|
3315
|
+
space: !1
|
|
3316
|
+
}), s = K((e) => e.attachedMask), c = K((e) => e.unlatchedMask), f = K((e) => e.fuelLiters), p = K((e) => e.freqBucket), m = K((e) => e.dampBucket), g = K((e) => e.detachedDebris), _ = u(() => new F(e), [e]), v = u(() => _.getPanelIntrinsics(), [_]), y = u(() => e.panels.map((e) => Zt(e.localPositions, e.localNormals)), [e]), b = u(() => Zt(e.skateboardPositions, e.skateboardNormals), [e]), x = u(() => Zt(e.wheels[0].positions, e.wheels[0].normals), [e]), S = u(() => t ? t.clone(!0) : null, [t]);
|
|
3317
|
+
l(() => {
|
|
3318
|
+
G.massDirty = !0;
|
|
3319
|
+
let e = (e) => (t) => {
|
|
3320
|
+
(t.code === "KeyW" || t.code === "ArrowUp") && (o.current.w = e), (t.code === "KeyS" || t.code === "ArrowDown") && (o.current.s = e), (t.code === "KeyA" || t.code === "ArrowLeft") && (o.current.a = e), (t.code === "KeyD" || t.code === "ArrowRight") && (o.current.d = e), t.code === "Space" && (o.current.space = e);
|
|
3321
|
+
}, t = e(!0), n = e(!1);
|
|
3322
|
+
return window.addEventListener("keydown", t), window.addEventListener("keyup", n), () => {
|
|
3323
|
+
window.removeEventListener("keydown", t), window.removeEventListener("keyup", n);
|
|
3324
|
+
};
|
|
3325
|
+
}, [
|
|
3326
|
+
e,
|
|
3327
|
+
p,
|
|
3328
|
+
m
|
|
3329
|
+
]);
|
|
3330
|
+
let C = _.evaluate(s, f), w = 2 * Math.PI * yt[p], T = bt[m], A = C.totalMassKg * .5 * C.frontAxleRatio, M = C.totalMassKg * .5 - A, te = A * w * w, ne = M * w * w, re = 2 * T * Math.sqrt(te * A), ie = 2 * T * Math.sqrt(ne * M);
|
|
3331
|
+
ee(() => {
|
|
3332
|
+
let e = r.current?.body ?? null;
|
|
3333
|
+
if (i.current = e, !e) return;
|
|
3334
|
+
let t = K.getState().dropTrigger;
|
|
3335
|
+
if (t !== a.current && (a.current = t, e.setTranslation({
|
|
3336
|
+
x: 0,
|
|
3337
|
+
y: 1.2,
|
|
3338
|
+
z: 0
|
|
3339
|
+
}, !0), e.setLinvel({
|
|
3340
|
+
x: 0,
|
|
3341
|
+
y: 0,
|
|
3342
|
+
z: 0
|
|
3343
|
+
}, !0), e.setAngvel({
|
|
3344
|
+
x: 0,
|
|
3345
|
+
y: 0,
|
|
3346
|
+
z: 0
|
|
3347
|
+
}, !0)), G.massDirty) {
|
|
3348
|
+
G.massDirty = !1;
|
|
3349
|
+
let t = K.getState(), n = _.evaluate(t.attachedMask, t.fuelLiters);
|
|
3350
|
+
e.setAdditionalMassProperties(n.totalMassKg, {
|
|
3351
|
+
x: n.centerOfMass[0],
|
|
3352
|
+
y: n.centerOfMass[1],
|
|
3353
|
+
z: n.centerOfMass[2]
|
|
3354
|
+
}, {
|
|
3355
|
+
x: n.inertiaDiagonal[0],
|
|
3356
|
+
y: n.inertiaDiagonal[1],
|
|
3357
|
+
z: n.inertiaDiagonal[2]
|
|
3358
|
+
}, {
|
|
3359
|
+
x: n.inertiaOrientation[0],
|
|
3360
|
+
y: n.inertiaOrientation[1],
|
|
3361
|
+
z: n.inertiaOrientation[2],
|
|
3362
|
+
w: n.inertiaOrientation[3]
|
|
3363
|
+
}, !0), G.massKg = n.totalMassKg, G.com = [...n.centerOfMass], G.frontSplit = n.frontAxleRatio, G.cornerK = [te, ne];
|
|
3364
|
+
}
|
|
3365
|
+
}), h(() => {
|
|
3366
|
+
let e = r.current;
|
|
3367
|
+
if (!e) return;
|
|
3368
|
+
let t = o.current;
|
|
3369
|
+
e.setMovement({
|
|
3370
|
+
forward: t.w,
|
|
3371
|
+
backward: t.s,
|
|
3372
|
+
steerLeft: t.a,
|
|
3373
|
+
steerRight: t.d,
|
|
3374
|
+
brake: t.space
|
|
3375
|
+
}), G.speedKmh = e.currLinVel.length() * 3.6, G.rpm = Math.max(850, e.engineRPM);
|
|
3376
|
+
});
|
|
3377
|
+
let ae = (e) => {
|
|
3378
|
+
let t = K.getState(), n = 1 << e.bitIndex, i = t.wrenchMode === "UNLATCH_200" ? 200 : 1800, a = r.current?.body, o = v[e.bitIndex];
|
|
3379
|
+
if (a) {
|
|
3380
|
+
let t = a.translation();
|
|
3381
|
+
G.sparkBurst = [
|
|
3382
|
+
t.x + e.anchorChassis[0],
|
|
3383
|
+
t.y + e.anchorChassis[1],
|
|
3384
|
+
t.z + e.anchorChassis[2]
|
|
3385
|
+
];
|
|
3386
|
+
}
|
|
3387
|
+
if (i <= e.breakaway.breakImpulseNs && e.breakaway.hingeAxisLocal && (t.unlatchedMask & n) === 0) {
|
|
3388
|
+
t.setField("unlatchedMask", t.unlatchedMask | n);
|
|
3389
|
+
return;
|
|
3390
|
+
}
|
|
3391
|
+
if (t.setField("attachedMask", t.attachedMask & ~n), t.setField("unlatchedMask", t.unlatchedMask & ~n), G.massDirty = !0, !a) return;
|
|
3392
|
+
let s = a.translation(), c = a.rotation(), l = a.linvel(), u = a.angvel(), d = a.worldCom();
|
|
3393
|
+
Xt.set(c.x, c.y, c.z, c.w), qt.set(e.anchorChassis[0], e.anchorChassis[1], e.anchorChassis[2]).applyQuaternion(Xt).add(s), Jt.set(qt.x - d.x, qt.y - d.y, qt.z - d.z), Yt.set(u.x, u.y, u.z).cross(Jt);
|
|
3394
|
+
let f = Math.min(8, i / Math.max(15, o.massKg * 18));
|
|
3395
|
+
t.setField("detachedDebris", [...t.detachedDebris, {
|
|
3396
|
+
id: `${e.partId}_${Date.now()}`,
|
|
3397
|
+
partId: e.partId,
|
|
3398
|
+
massKg: o.massKg,
|
|
3399
|
+
position: [
|
|
3400
|
+
qt.x,
|
|
3401
|
+
qt.y,
|
|
3402
|
+
qt.z
|
|
3403
|
+
],
|
|
3404
|
+
quaternion: [
|
|
3405
|
+
c.x,
|
|
3406
|
+
c.y,
|
|
3407
|
+
c.z,
|
|
3408
|
+
c.w
|
|
3409
|
+
],
|
|
3410
|
+
linvel: [
|
|
3411
|
+
l.x + Yt.x + (e.anchorChassis[0] >= 0 ? 1 : -1) * f,
|
|
3412
|
+
l.y + Yt.y + .65 * f,
|
|
3413
|
+
l.z + Yt.z + (e.anchorChassis[2] >= 0 ? .5 : -.5) * f
|
|
3414
|
+
],
|
|
3415
|
+
angvel: [
|
|
3416
|
+
u.x,
|
|
3417
|
+
u.y,
|
|
3418
|
+
u.z
|
|
3419
|
+
],
|
|
3420
|
+
aabbSize: e.aabbSize,
|
|
3421
|
+
colorHex: e.colorHex
|
|
3422
|
+
}]);
|
|
3423
|
+
}, oe = u(() => ({
|
|
3424
|
+
engineHorsepower: 190,
|
|
3425
|
+
gearRatios: [
|
|
3426
|
+
3.5,
|
|
3427
|
+
2.1,
|
|
3428
|
+
1.4,
|
|
3429
|
+
1
|
|
3430
|
+
],
|
|
3431
|
+
finalDriveRatio: 3.9,
|
|
3432
|
+
rollCenterHeight: .24,
|
|
3433
|
+
antiRollStiffness: 2400
|
|
3434
|
+
}), []);
|
|
3435
|
+
return /* @__PURE__ */ O(E, { children: [
|
|
3436
|
+
/* @__PURE__ */ O(be, {
|
|
3437
|
+
ref: r,
|
|
3438
|
+
position: [
|
|
3439
|
+
0,
|
|
3440
|
+
.35,
|
|
3441
|
+
0
|
|
3442
|
+
],
|
|
3443
|
+
colliders: !1,
|
|
3444
|
+
carConfig: oe,
|
|
3445
|
+
canSleep: !1,
|
|
3446
|
+
children: [
|
|
3447
|
+
/* @__PURE__ */ D(k, {
|
|
3448
|
+
args: zt(e.skateboardBoxSize),
|
|
3449
|
+
position: e.skateboardBoxCenter
|
|
3450
|
+
}),
|
|
3451
|
+
/* @__PURE__ */ O("group", {
|
|
3452
|
+
ref: n,
|
|
3453
|
+
children: [
|
|
3454
|
+
S && /* @__PURE__ */ D("primitive", { object: S }),
|
|
3455
|
+
/* @__PURE__ */ D("mesh", {
|
|
3456
|
+
geometry: b,
|
|
3457
|
+
children: /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3458
|
+
color: 2304045,
|
|
3459
|
+
roughness: .9,
|
|
3460
|
+
flatShading: !0
|
|
3461
|
+
})
|
|
3462
|
+
}),
|
|
3463
|
+
e.panels.map((t, n) => {
|
|
3464
|
+
let r = 1 << t.bitIndex;
|
|
3465
|
+
return (s & r) === 0 || (c & r) !== 0 ? null : /* @__PURE__ */ D("mesh", {
|
|
3466
|
+
position: t.anchorChassis,
|
|
3467
|
+
geometry: y[n],
|
|
3468
|
+
onClick: (e) => {
|
|
3469
|
+
e.stopPropagation(), ae(t);
|
|
3470
|
+
},
|
|
3471
|
+
children: /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3472
|
+
color: t.colorHex,
|
|
3473
|
+
roughness: t.isGlass ? .15 : .88,
|
|
3474
|
+
transparent: t.isGlass || !!S,
|
|
3475
|
+
opacity: S ? .28 : t.isGlass ? .32 : 1,
|
|
3476
|
+
wireframe: !!S,
|
|
3477
|
+
flatShading: e.shadingMode === "psx-flat"
|
|
3478
|
+
})
|
|
3479
|
+
}, t.partId);
|
|
3480
|
+
})
|
|
3481
|
+
]
|
|
3482
|
+
}),
|
|
3483
|
+
e.wheels.map((e) => {
|
|
3484
|
+
let t = e.slotId.includes("_f"), n = e.omi.suspensionTravel ?? .2;
|
|
3485
|
+
return /* @__PURE__ */ D(xe, {
|
|
3486
|
+
name: e.slotId,
|
|
3487
|
+
position: [
|
|
3488
|
+
e.position[0],
|
|
3489
|
+
e.position[1] + (n - .07),
|
|
3490
|
+
e.position[2]
|
|
3491
|
+
],
|
|
3492
|
+
rayShapeR: e.omi.radius,
|
|
3493
|
+
rayShapeH: e.omi.width * .5,
|
|
3494
|
+
rayLength: n,
|
|
3495
|
+
wheelModelRadius: e.omi.radius,
|
|
3496
|
+
springK: t ? te : ne,
|
|
3497
|
+
dampingC: t ? re : ie,
|
|
3498
|
+
steerWheel: e.omi.steering,
|
|
3499
|
+
driveWheel: e.omi.propulsion,
|
|
3500
|
+
brakeWheel: !0,
|
|
3501
|
+
maxBrakeTorque: 1600,
|
|
3502
|
+
children: /* @__PURE__ */ D("mesh", {
|
|
3503
|
+
geometry: x,
|
|
3504
|
+
children: /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3505
|
+
color: 1843753,
|
|
3506
|
+
roughness: .9,
|
|
3507
|
+
flatShading: !0
|
|
3508
|
+
})
|
|
3509
|
+
})
|
|
3510
|
+
}, e.slotId);
|
|
3511
|
+
})
|
|
3512
|
+
]
|
|
3513
|
+
}),
|
|
3514
|
+
e.panels.map((e, t) => {
|
|
3515
|
+
let n = 1 << e.bitIndex;
|
|
3516
|
+
return (s & n) === 0 || (c & n) === 0 ? null : /* @__PURE__ */ D(Qt, {
|
|
3517
|
+
chassisBodyRef: i,
|
|
3518
|
+
panel: e,
|
|
3519
|
+
massKg: v[t].massKg,
|
|
3520
|
+
geometry: y[t],
|
|
3521
|
+
onWrenchHit: ae
|
|
3522
|
+
}, `unlatched_${e.partId}`);
|
|
3523
|
+
}),
|
|
3524
|
+
g.map((e) => /* @__PURE__ */ O(j, {
|
|
3525
|
+
position: e.position,
|
|
3526
|
+
mass: e.massKg,
|
|
3527
|
+
linearVelocity: e.linvel,
|
|
3528
|
+
angularVelocity: e.angvel,
|
|
3529
|
+
colliders: !1,
|
|
3530
|
+
children: [/* @__PURE__ */ D(k, { args: zt(e.aabbSize) }), /* @__PURE__ */ O("mesh", { children: [/* @__PURE__ */ D("boxGeometry", { args: e.aabbSize }), /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3531
|
+
color: e.colorHex,
|
|
3532
|
+
roughness: .88,
|
|
3533
|
+
flatShading: !0
|
|
3534
|
+
})] })]
|
|
3535
|
+
}, e.id))
|
|
3536
|
+
] });
|
|
3537
|
+
}
|
|
3538
|
+
// src/importer/Step2UniversalPad.tsx
|
|
3539
|
+
var en = new p.Vector3(), tn = new p.Vector3(0, 1, 0), nn = new p.Vector3(), rn = new p.Vector3(), an = new p.Vector3();
|
|
3540
|
+
function on({ bundle: e, subArchetype: t, patches: a, stampActive: o, panelAnimRef: c, onStampSurface: f }) {
|
|
3541
|
+
let m = d(null), g = K((e) => e.chaseCam), _ = d(K.getState().dropTrigger), v = d({
|
|
3542
|
+
w: !1,
|
|
3543
|
+
s: !1,
|
|
3544
|
+
a: !1,
|
|
3545
|
+
d: !1,
|
|
3546
|
+
space: !1,
|
|
3547
|
+
shift: !1
|
|
3548
|
+
}), y = d(new p.Vector3(0, 1, 4)), b = d({
|
|
3549
|
+
...r(),
|
|
3550
|
+
throttle: 0,
|
|
3551
|
+
boost: 0,
|
|
3552
|
+
brake: 0,
|
|
3553
|
+
headlight: 1,
|
|
3554
|
+
always: 1
|
|
3555
|
+
}), x = u(() => S(e), [e]), C = u(() => n(a), [a]), w = u(() => i(x), [x]);
|
|
3556
|
+
return l(() => (c.current = w, () => {
|
|
3557
|
+
c.current === w && (c.current = null);
|
|
3558
|
+
}), [w, c]), l(() => {
|
|
3559
|
+
G.massKg = x.totalDynamicMass, G.com = [...x.centerOfMass];
|
|
3560
|
+
let e = (e) => (t) => {
|
|
3561
|
+
(t.code === "KeyW" || t.code === "ArrowUp") && (v.current.w = e), (t.code === "KeyS" || t.code === "ArrowDown") && (v.current.s = e), (t.code === "KeyA" || t.code === "ArrowLeft") && (v.current.a = e), (t.code === "KeyD" || t.code === "ArrowRight") && (v.current.d = e), t.code === "Space" && (v.current.space = e), (t.code === "ShiftLeft" || t.code === "ShiftRight") && (v.current.shift = e);
|
|
3562
|
+
}, t = e(!0), n = e(!1);
|
|
3563
|
+
return window.addEventListener("keydown", t), window.addEventListener("keyup", n), () => {
|
|
3564
|
+
window.removeEventListener("keydown", t), window.removeEventListener("keyup", n);
|
|
3565
|
+
};
|
|
3566
|
+
}, [x]), h((e, n) => {
|
|
3567
|
+
let r = Math.min(Math.max(n, 1e-4), .05);
|
|
3568
|
+
w.step(r);
|
|
3569
|
+
let i = m.current;
|
|
3570
|
+
if (!i?.body) return;
|
|
3571
|
+
let a = K.getState().dropTrigger;
|
|
3572
|
+
a !== _.current && (_.current = a, i.body.setTranslation({
|
|
3573
|
+
x: 0,
|
|
3574
|
+
y: 1.35,
|
|
3575
|
+
z: 0
|
|
3576
|
+
}, !0), i.body.setRotation({
|
|
3577
|
+
x: 0,
|
|
3578
|
+
y: 0,
|
|
3579
|
+
z: 0,
|
|
3580
|
+
w: 1
|
|
3581
|
+
}, !0), i.body.setLinvel({
|
|
3582
|
+
x: 0,
|
|
3583
|
+
y: 0,
|
|
3584
|
+
z: 0
|
|
3585
|
+
}, !0), i.body.setAngvel({
|
|
3586
|
+
x: 0,
|
|
3587
|
+
y: 0,
|
|
3588
|
+
z: 0
|
|
3589
|
+
}, !0));
|
|
3590
|
+
let s = v.current;
|
|
3591
|
+
t === "starcraft" ? i.setMovement({
|
|
3592
|
+
pitchForward: s.w,
|
|
3593
|
+
pitchBackward: s.s,
|
|
3594
|
+
yawLeft: s.a,
|
|
3595
|
+
yawRight: s.d,
|
|
3596
|
+
throttleUp: s.space
|
|
3597
|
+
}) : (i.setMovement({
|
|
3598
|
+
forward: s.w,
|
|
3599
|
+
backward: s.s,
|
|
3600
|
+
steerLeft: s.a,
|
|
3601
|
+
steerRight: s.d,
|
|
3602
|
+
brake: s.space
|
|
3603
|
+
}), s.shift && s.w && i.body.applyImpulse(an.copy(i.bodyZAxis).multiplyScalar(i.body.mass() * 6.2 * r), !0));
|
|
3604
|
+
let c = b.current;
|
|
3605
|
+
c.throttle = +!!s.w, c.boost = s.w && s.shift ? 1 : 0, c.brake = s.space || s.s ? 1 : 0, G.speedKmh = i.currLinVel.length() * 3.6, G.rpm = Math.max(850, i.engineRPM), g && !o && (en.copy(i.bodyZAxis).projectOnPlane(tn), en.lengthSq() < 1e-6 ? en.set(0, 0, 1) : en.normalize(), nn.copy(i.currPos).addScaledVector(en, -6.8).addScaledVector(tn, 2.25), rn.copy(i.currPos).addScaledVector(en, 3.5).addScaledVector(tn, .65), te.damp3(e.camera.position, nn, .14, r), te.damp3(y.current, rn, .08, r), e.camera.lookAt(y.current));
|
|
3606
|
+
}), /* @__PURE__ */ D("group", {
|
|
3607
|
+
onClick: (e) => {
|
|
3608
|
+
o ? f(e) : e.delta <= 5 && w.toggleHitObject(e.object) && e.stopPropagation();
|
|
3609
|
+
},
|
|
3610
|
+
children: /* @__PURE__ */ D(ne, {
|
|
3611
|
+
ref: m,
|
|
3612
|
+
bundle: x,
|
|
3613
|
+
position: [
|
|
3614
|
+
0,
|
|
3615
|
+
t === "starcraft" ? 1.4 : .35,
|
|
3616
|
+
0
|
|
3617
|
+
],
|
|
3618
|
+
carConfig: t === "motorcycle" ? {
|
|
3619
|
+
twoWheelBalance: !0,
|
|
3620
|
+
maxLeanAngle: .78
|
|
3621
|
+
} : void 0,
|
|
3622
|
+
children: /* @__PURE__ */ D(s, {
|
|
3623
|
+
emitters: C,
|
|
3624
|
+
signalsRef: b
|
|
3625
|
+
})
|
|
3626
|
+
})
|
|
3627
|
+
});
|
|
3628
|
+
}
|
|
3629
|
+
function sn({ bundle: e, domain: t, staticProp: i, patches: o, onStampSurface: c }) {
|
|
3630
|
+
let f = d(null), p = d(!1), m = K((e) => e.dropTrigger), h = d({
|
|
3631
|
+
...r(),
|
|
3632
|
+
throttle: .9,
|
|
3633
|
+
boost: 1,
|
|
3634
|
+
brake: 1,
|
|
3635
|
+
headlight: 1,
|
|
3636
|
+
fire: 1,
|
|
3637
|
+
always: 1
|
|
3638
|
+
}), g = u(() => S(e), [e, m]), _ = u(() => n(o), [o]), v = t === "c12" || t === "prop" && i;
|
|
3639
|
+
return l(() => {
|
|
3640
|
+
G.massKg = g.totalDynamicMass, G.com = [...g.centerOfMass], G.speedKmh = 0;
|
|
3641
|
+
}, [g]), /* @__PURE__ */ O("group", {
|
|
3642
|
+
onClick: (e) => {
|
|
3643
|
+
c(e), p.current = a(f.current, g, p.current);
|
|
3644
|
+
},
|
|
3645
|
+
children: [/* @__PURE__ */ D(x, {
|
|
3646
|
+
ref: f,
|
|
3647
|
+
bundle: g,
|
|
3648
|
+
position: [
|
|
3649
|
+
0,
|
|
3650
|
+
v ? 0 : 1.2,
|
|
3651
|
+
0
|
|
3652
|
+
],
|
|
3653
|
+
fixedRoot: v
|
|
3654
|
+
}, `asm_${m}`), /* @__PURE__ */ D(s, {
|
|
3655
|
+
emitters: _,
|
|
3656
|
+
signalsRef: h
|
|
3657
|
+
})]
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
function cn({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: r, patches: i, stampActive: a, panelAnimRef: o, onStampSurface: s }) {
|
|
3661
|
+
let c = K((e) => e.domain), l = K((e) => e.vehicleArchetype), u = K((e) => e.usePaperShellProxy), d = K((e) => e.staticProp);
|
|
3662
|
+
return /* @__PURE__ */ O(A, {
|
|
3663
|
+
interpolate: !0,
|
|
3664
|
+
timeStep: 1 / 60,
|
|
3665
|
+
children: [
|
|
3666
|
+
/* @__PURE__ */ D(j, {
|
|
3667
|
+
type: "fixed",
|
|
3668
|
+
position: [
|
|
3669
|
+
0,
|
|
3670
|
+
-.25,
|
|
3671
|
+
0
|
|
3672
|
+
],
|
|
3673
|
+
colliders: !1,
|
|
3674
|
+
children: /* @__PURE__ */ D(k, {
|
|
3675
|
+
args: [
|
|
3676
|
+
180,
|
|
3677
|
+
.25,
|
|
3678
|
+
180
|
|
3679
|
+
],
|
|
3680
|
+
friction: .92
|
|
3681
|
+
})
|
|
3682
|
+
}),
|
|
3683
|
+
/* @__PURE__ */ O("mesh", {
|
|
3684
|
+
rotation: [
|
|
3685
|
+
-Math.PI * .5,
|
|
3686
|
+
0,
|
|
3687
|
+
0
|
|
3688
|
+
],
|
|
3689
|
+
position: [
|
|
3690
|
+
0,
|
|
3691
|
+
-.004,
|
|
3692
|
+
0
|
|
3693
|
+
],
|
|
3694
|
+
receiveShadow: !0,
|
|
3695
|
+
children: [/* @__PURE__ */ D("planeGeometry", { args: [360, 360] }), /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3696
|
+
color: "#11161d",
|
|
3697
|
+
roughness: .95
|
|
3698
|
+
})]
|
|
3699
|
+
}),
|
|
3700
|
+
/* @__PURE__ */ D(j, {
|
|
3701
|
+
type: "fixed",
|
|
3702
|
+
position: [
|
|
3703
|
+
0,
|
|
3704
|
+
.36,
|
|
3705
|
+
18
|
|
3706
|
+
],
|
|
3707
|
+
rotation: [
|
|
3708
|
+
-.19,
|
|
3709
|
+
0,
|
|
3710
|
+
0
|
|
3711
|
+
],
|
|
3712
|
+
colliders: "cuboid",
|
|
3713
|
+
children: /* @__PURE__ */ O("mesh", { children: [/* @__PURE__ */ D("boxGeometry", { args: [
|
|
3714
|
+
4.4,
|
|
3715
|
+
.22,
|
|
3716
|
+
6.2
|
|
3717
|
+
] }), /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3718
|
+
color: "#f59e0b",
|
|
3719
|
+
roughness: .75,
|
|
3720
|
+
flatShading: !0
|
|
3721
|
+
})] })
|
|
3722
|
+
}),
|
|
3723
|
+
[-12, 12].flatMap((e) => [
|
|
3724
|
+
-24,
|
|
3725
|
+
-12,
|
|
3726
|
+
0,
|
|
3727
|
+
12,
|
|
3728
|
+
24,
|
|
3729
|
+
36,
|
|
3730
|
+
48
|
|
3731
|
+
].map((t) => /* @__PURE__ */ O("mesh", {
|
|
3732
|
+
position: [
|
|
3733
|
+
e,
|
|
3734
|
+
.35,
|
|
3735
|
+
t
|
|
3736
|
+
],
|
|
3737
|
+
children: [/* @__PURE__ */ D("coneGeometry", { args: [
|
|
3738
|
+
.28,
|
|
3739
|
+
.7,
|
|
3740
|
+
8
|
|
3741
|
+
] }), /* @__PURE__ */ D("meshStandardMaterial", {
|
|
3742
|
+
color: "#ff5a1f",
|
|
3743
|
+
roughness: .6,
|
|
3744
|
+
flatShading: !0
|
|
3745
|
+
})]
|
|
3746
|
+
}, `cone_${e}_${t}`))),
|
|
3747
|
+
c === "vehicle" && u ? /* @__PURE__ */ D($t, {
|
|
3748
|
+
assembly: e,
|
|
3749
|
+
importedRoot: t,
|
|
3750
|
+
chassisGroupRef: n
|
|
3751
|
+
}) : r ? c === "vehicle" ? /* @__PURE__ */ D(on, {
|
|
3752
|
+
bundle: r,
|
|
3753
|
+
subArchetype: l,
|
|
3754
|
+
patches: i,
|
|
3755
|
+
stampActive: a,
|
|
3756
|
+
panelAnimRef: o,
|
|
3757
|
+
onStampSurface: s
|
|
3758
|
+
}) : /* @__PURE__ */ D(sn, {
|
|
3759
|
+
bundle: r,
|
|
3760
|
+
domain: c,
|
|
3761
|
+
staticProp: d,
|
|
3762
|
+
patches: i,
|
|
3763
|
+
onStampSurface: s
|
|
3764
|
+
}) : null
|
|
3765
|
+
]
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
// src/importer/VfxEmitterPool.tsx
|
|
3769
|
+
var Z = 256, ln = new p.Vector3(), un = new p.Vector3(), Q = new p.Vector3(), dn = new p.Quaternion(), fn = new p.Matrix4(), pn = new p.Color();
|
|
3770
|
+
function mn({ chassisObjRef: e, emitters: t }) {
|
|
3771
|
+
let n = d(null), r = d(0), i = d(0), a = u(() => {
|
|
3772
|
+
let e = new Float32Array(Z * 3), t = new Float32Array(Z * 3), n = new Float32Array(Z), r = new Float32Array(Z), i = new Float32Array(Z * 2), a = new Float32Array(Z * 3), o = new Float32Array(Z * 3);
|
|
3773
|
+
return n.fill(999), r.fill(1), {
|
|
3774
|
+
pos: e,
|
|
3775
|
+
vel: t,
|
|
3776
|
+
age: n,
|
|
3777
|
+
life: r,
|
|
3778
|
+
sizeStartEnd: i,
|
|
3779
|
+
colorStart: a,
|
|
3780
|
+
colorEnd: o
|
|
3781
|
+
};
|
|
3782
|
+
}, []), o = u(() => new p.PlaneGeometry(1, 1), []), s = u(() => new p.MeshBasicMaterial({
|
|
3783
|
+
color: 16777215,
|
|
3784
|
+
side: p.DoubleSide,
|
|
3785
|
+
transparent: !0,
|
|
3786
|
+
opacity: .85,
|
|
3787
|
+
depthWrite: !1
|
|
3788
|
+
}), []);
|
|
3789
|
+
l(() => {
|
|
3790
|
+
let e = n.current;
|
|
3791
|
+
if (e) {
|
|
3792
|
+
fn.makeScale(0, 0, 0), pn.setRGB(1, 1, 1);
|
|
3793
|
+
for (let t = 0; t < Z; t++) e.setMatrixAt(t, fn), e.setColorAt(t, pn);
|
|
3794
|
+
e.instanceMatrix.needsUpdate = !0, e.instanceColor && (e.instanceColor.needsUpdate = !0);
|
|
3795
|
+
}
|
|
3796
|
+
}, []);
|
|
3797
|
+
let c = (e, t, n, i, o, s, c, l, u, d, f, p, m, h) => {
|
|
3798
|
+
let g = r.current;
|
|
3799
|
+
r.current = g + 1 & 255;
|
|
3800
|
+
let _ = g * 3, v = g * 2;
|
|
3801
|
+
a.pos[_] = e, a.pos[_ + 1] = t, a.pos[_ + 2] = n;
|
|
3802
|
+
let y = c + Math.random() * (l - c);
|
|
3803
|
+
a.vel[_] = (i + (Math.random() - .5) * u) * y, a.vel[_ + 1] = (o + (Math.random() - .5) * u) * y + .35, a.vel[_ + 2] = (s + (Math.random() - .5) * u) * y, a.age[g] = 0, a.life[g] = Math.max(.05, p), a.sizeStartEnd[v] = d, a.sizeStartEnd[v + 1] = f, a.colorStart[_] = m[0], a.colorStart[_ + 1] = m[1], a.colorStart[_ + 2] = m[2], a.colorEnd[_] = h[0], a.colorEnd[_ + 1] = h[1], a.colorEnd[_ + 2] = h[2];
|
|
3804
|
+
};
|
|
3805
|
+
return h((r, o) => {
|
|
3806
|
+
let s = n.current;
|
|
3807
|
+
if (!s) return;
|
|
3808
|
+
let l = Math.min(.05, o), u = e.current;
|
|
3809
|
+
u ? (u.getWorldPosition(ln), u.getWorldQuaternion(dn)) : (ln.set(0, 0, 0), dn.identity());
|
|
3810
|
+
let d = t[0];
|
|
3811
|
+
if (d) {
|
|
3812
|
+
let e = Math.max(.15, Math.min(1, G.rpm / 6500));
|
|
3813
|
+
for (i.current += d.desc.rateHz * e * l; i.current >= 1;) {
|
|
3814
|
+
--i.current, un.set(d.position[0], d.position[1], d.position[2]).applyQuaternion(dn).add(ln), Q.set(0, 0, -1).applyQuaternion(dn);
|
|
3815
|
+
let e = d.desc;
|
|
3816
|
+
c(un.x, un.y, un.z, Q.x, Q.y, Q.z, e.speedMinMax[0], e.speedMinMax[1], e.coneOuterAngle, e.sizeStartEnd[0], e.sizeStartEnd[1], e.lifetimeSec, e.colorStart, e.colorEnd);
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
let f = G.sparkBurst;
|
|
3820
|
+
if (f && t[1]) {
|
|
3821
|
+
G.sparkBurst = null;
|
|
3822
|
+
let e = t[1].desc;
|
|
3823
|
+
Q.set(0, 0, -1).applyQuaternion(dn);
|
|
3824
|
+
for (let t = 0; t < 18; t++) c(f[0], f[1], f[2], Q.x, Q.y + .4, Q.z, e.speedMinMax[0], e.speedMinMax[1], e.coneOuterAngle, e.sizeStartEnd[0], e.sizeStartEnd[1], e.lifetimeSec, e.colorStart, e.colorEnd);
|
|
3825
|
+
}
|
|
3826
|
+
let p = r.camera.quaternion;
|
|
3827
|
+
for (let e = 0; e < Z; e++) {
|
|
3828
|
+
let t = a.age[e], n = a.life[e];
|
|
3829
|
+
if (t >= n) {
|
|
3830
|
+
fn.makeScale(0, 0, 0), s.setMatrixAt(e, fn);
|
|
3831
|
+
continue;
|
|
3832
|
+
}
|
|
3833
|
+
let r = t + l;
|
|
3834
|
+
a.age[e] = r;
|
|
3835
|
+
let i = Math.min(1, r / n), o = e * 3, c = e * 2;
|
|
3836
|
+
a.pos[o] += a.vel[o] * l, a.pos[o + 1] += a.vel[o + 1] * l, a.pos[o + 2] += a.vel[o + 2] * l;
|
|
3837
|
+
let u = a.sizeStartEnd[c] + (a.sizeStartEnd[c + 1] - a.sizeStartEnd[c]) * i;
|
|
3838
|
+
un.set(a.pos[o], a.pos[o + 1], a.pos[o + 2]), Q.set(u, u, u), fn.compose(un, p, Q), s.setMatrixAt(e, fn), pn.setRGB(a.colorStart[o] + (a.colorEnd[o] - a.colorStart[o]) * i, a.colorStart[o + 1] + (a.colorEnd[o + 1] - a.colorStart[o + 1]) * i, a.colorStart[o + 2] + (a.colorEnd[o + 2] - a.colorStart[o + 2]) * i), s.setColorAt(e, pn);
|
|
3839
|
+
}
|
|
3840
|
+
s.instanceMatrix.needsUpdate = !0, s.instanceColor && (s.instanceColor.needsUpdate = !0);
|
|
3841
|
+
}), /* @__PURE__ */ D("instancedMesh", {
|
|
3842
|
+
ref: n,
|
|
3843
|
+
args: [
|
|
3844
|
+
o,
|
|
3845
|
+
s,
|
|
3846
|
+
Z
|
|
3847
|
+
],
|
|
3848
|
+
frustumCulled: !1
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
// src/importer/usdToGlb.ts
|
|
3852
|
+
var hn = [
|
|
3853
|
+
80,
|
|
3854
|
+
88,
|
|
3855
|
+
82,
|
|
3856
|
+
45,
|
|
3857
|
+
85,
|
|
3858
|
+
83,
|
|
3859
|
+
68,
|
|
3860
|
+
67
|
|
3861
|
+
], gn = [
|
|
3862
|
+
"map",
|
|
3863
|
+
"normalMap",
|
|
3864
|
+
"roughnessMap",
|
|
3865
|
+
"metalnessMap",
|
|
3866
|
+
"aoMap",
|
|
3867
|
+
"emissiveMap"
|
|
3868
|
+
], _n = (e) => e.byteLength >= 8 && hn.every((t, n) => e[n] === t), vn = (e) => /\.(usd|usda|usdc|usdz)$/i.test(e.trim());
|
|
3869
|
+
function yn(e) {
|
|
3870
|
+
let t = /* @__PURE__ */ new Map(), n = (e, r, i, a) => {
|
|
3871
|
+
let o = r * e.scale.x, s = i * e.scale.y, c = a * e.scale.z;
|
|
3872
|
+
if (e.name && t.set(e.name, [
|
|
3873
|
+
Math.abs(o),
|
|
3874
|
+
Math.abs(s),
|
|
3875
|
+
Math.abs(c)
|
|
3876
|
+
]), e.position.set(e.position.x * r, e.position.y * i, e.position.z * a), e.scale.set(1, 1, 1), e instanceof p.Mesh && e.geometry && (Math.abs(o - 1) > 1e-5 || Math.abs(s - 1) > 1e-5 || Math.abs(c - 1) > 1e-5)) {
|
|
3877
|
+
let t = e.geometry.clone();
|
|
3878
|
+
t.applyMatrix4(new p.Matrix4().makeScale(o, s, c));
|
|
3879
|
+
let n = o * s * c < 0 ? t.getIndex() : null;
|
|
3880
|
+
if (n) {
|
|
3881
|
+
let e = n.array;
|
|
3882
|
+
for (let t = 0; t + 2 < e.length; t += 3) {
|
|
3883
|
+
let n = e[t + 1];
|
|
3884
|
+
e[t + 1] = e[t + 2], e[t + 2] = n;
|
|
3885
|
+
}
|
|
3886
|
+
n.needsUpdate = !0;
|
|
3887
|
+
}
|
|
3888
|
+
t.computeVertexNormals(), t.computeBoundingBox(), e.geometry = t;
|
|
3889
|
+
}
|
|
3890
|
+
for (let t of e.children) n(t, o, s, c);
|
|
3891
|
+
};
|
|
3892
|
+
return n(e, 1, 1, 1), e.updateMatrixWorld(!0), t;
|
|
3893
|
+
}
|
|
3894
|
+
function bn(e) {
|
|
3895
|
+
if (typeof e == "string") return [e];
|
|
3896
|
+
let t = e instanceof Uint8Array ? e : new Uint8Array(e), n = new TextDecoder();
|
|
3897
|
+
return _n(t) ? [] : t.byteLength >= 2 && t[0] === 80 && t[1] === 75 ? Object.entries(Se(t)).filter(([e, t]) => /\.(usd|usda)$/i.test(e) && !_n(t)).map(([, e]) => n.decode(e)) : [n.decode(t)];
|
|
3898
|
+
}
|
|
3899
|
+
function xn(e, t) {
|
|
3900
|
+
for (let n of e.split(/\r?\n/)) {
|
|
3901
|
+
let e = n.indexOf("=");
|
|
3902
|
+
if (e >= 0) {
|
|
3903
|
+
let r = n.slice(0, e).trim().split(/\s+/).pop();
|
|
3904
|
+
r && (t[r] = n.slice(e + 1).trim());
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
function Sn(e) {
|
|
3909
|
+
let t = e.replace(/#[^\n]*/g, ""), n = [], r = [], i = /\b(?:def|over|class)\s+(?:([A-Za-z0-9_]+)\s+)?"([^"]+)"\s*(?:\(([\s\S]*?)\))?\s*\{/g, a = 0;
|
|
3910
|
+
for (; a < t.length;) {
|
|
3911
|
+
let e = t.indexOf("{", a), o = t.indexOf("}", a);
|
|
3912
|
+
if (o !== -1 && (e === -1 || o < e)) {
|
|
3913
|
+
let e = r.pop();
|
|
3914
|
+
e && xn(t.slice(a, o), e.attrs), a = o + 1;
|
|
3915
|
+
continue;
|
|
3916
|
+
}
|
|
3917
|
+
if (e === -1) break;
|
|
3918
|
+
let s = t.slice(a, e + 1);
|
|
3919
|
+
i.lastIndex = 0;
|
|
3920
|
+
let c = i.exec(s);
|
|
3921
|
+
if (c) {
|
|
3922
|
+
let e = r[r.length - 1];
|
|
3923
|
+
e && xn(s.slice(0, c.index), e.attrs);
|
|
3924
|
+
let t = [...r].reverse().find((e) => e !== null)?.path ?? "", i = (c[3] ?? "").match(/apiSchemas\s*=\s*\[([^\]]*)\]/), a = i ? Array.from(i[1].matchAll(/"([^"]+)"/g), (e) => e[1]) : [], o = {
|
|
3925
|
+
path: `${t}/${c[2]}`,
|
|
3926
|
+
name: c[2],
|
|
3927
|
+
typeName: c[1] ?? "Xform",
|
|
3928
|
+
apiSchemas: a,
|
|
3929
|
+
attrs: {}
|
|
3930
|
+
};
|
|
3931
|
+
n.push(o), r.push(o);
|
|
3932
|
+
} else r.push(null);
|
|
3933
|
+
a = e + 1;
|
|
3934
|
+
}
|
|
3935
|
+
return n;
|
|
3936
|
+
}
|
|
3937
|
+
var Cn = (e) => e === void 0 ? void 0 : /^(true|1)$/i.test(e.trim()) ? !0 : !/^(false|0)$/i.test(e.trim()) && void 0, $ = (e) => {
|
|
3938
|
+
let t = e === void 0 ? NaN : Number(e.replace(/[()"]/g, "").trim());
|
|
3939
|
+
return Number.isFinite(t) ? t : void 0;
|
|
3940
|
+
}, wn = (e) => {
|
|
3941
|
+
let t = e?.match(/\(\s*([^\s,)]+)\s*,\s*([^\s,)]+)\s*,\s*([^\s,)]+)\s*\)/), n = t ? [
|
|
3942
|
+
Number(t[1]),
|
|
3943
|
+
Number(t[2]),
|
|
3944
|
+
Number(t[3])
|
|
3945
|
+
] : null;
|
|
3946
|
+
return n?.every(Number.isFinite) ? n : void 0;
|
|
3947
|
+
}, Tn = (e) => e?.match(/<([^>]+)>/)?.[1]?.split("/").filter(Boolean).pop();
|
|
3948
|
+
function En(e, t) {
|
|
3949
|
+
if (e.typeName === "Cube") {
|
|
3950
|
+
let n = Math.max(.001, $(e.attrs.size) ?? 2);
|
|
3951
|
+
return {
|
|
3952
|
+
type: "box",
|
|
3953
|
+
size: [
|
|
3954
|
+
n * t[0],
|
|
3955
|
+
n * t[1],
|
|
3956
|
+
n * t[2]
|
|
3957
|
+
]
|
|
3958
|
+
};
|
|
3959
|
+
}
|
|
3960
|
+
if (e.typeName === "Sphere") return {
|
|
3961
|
+
type: "sphere",
|
|
3962
|
+
radius: Math.max(.001, ($(e.attrs.radius) ?? 1) * Math.max(t[0], t[1], t[2]))
|
|
3963
|
+
};
|
|
3964
|
+
if (e.typeName === "Cylinder" || e.typeName === "Capsule") {
|
|
3965
|
+
let n = e.typeName === "Capsule", r = Math.max(.001, ($(e.attrs.radius) ?? (n ? .5 : 1)) * Math.max(t[0], t[2])), i = Math.max(.001, ($(e.attrs.height) ?? (n ? 1 : 2)) * t[1]);
|
|
3966
|
+
return {
|
|
3967
|
+
type: n ? "capsule" : "cylinder",
|
|
3968
|
+
height: i,
|
|
3969
|
+
radiusTop: r,
|
|
3970
|
+
radiusBottom: r
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
return null;
|
|
3974
|
+
}
|
|
3975
|
+
function Dn(e, t, n, r) {
|
|
3976
|
+
let i = /* @__PURE__ */ new Set();
|
|
3977
|
+
for (let t of Object.keys(e)) {
|
|
3978
|
+
let e = t.match(/^drive:([^:]+):physics:/);
|
|
3979
|
+
e && i.add(e[1]);
|
|
3980
|
+
}
|
|
3981
|
+
let a = n[1] ? 1 : n[2] ? 2 : 0;
|
|
3982
|
+
return [...i].map((n) => {
|
|
3983
|
+
let i = $(e[`drive:${n}:physics:stiffness`]), o = $(e[`drive:${n}:physics:damping`]), s = $(e[`drive:${n}:physics:maxForce`]), c = $(e[`drive:${n}:physics:targetPosition`]), l = $(e[`drive:${n}:physics:targetVelocity`]), u = (e[`drive:${n}:physics:type`] ?? "").includes("acceleration") ? "acceleration" : "force";
|
|
3984
|
+
return {
|
|
3985
|
+
type: t === "revolute" ? "angular" : "linear",
|
|
3986
|
+
mode: u,
|
|
3987
|
+
axis: a,
|
|
3988
|
+
...c === void 0 ? l === void 0 ? { positionTarget: 0 } : {} : { positionTarget: c * r },
|
|
3989
|
+
...l === void 0 ? {} : { velocityTarget: l * r },
|
|
3990
|
+
...i !== void 0 && i >= 0 ? { stiffness: i } : {},
|
|
3991
|
+
...o !== void 0 && o >= 0 ? { damping: o } : {},
|
|
3992
|
+
...s !== void 0 && s >= 0 ? { maxForce: s } : {}
|
|
3993
|
+
};
|
|
3994
|
+
});
|
|
3995
|
+
}
|
|
3996
|
+
function On(e, t, n) {
|
|
3997
|
+
let r = e.flatMap(Sn);
|
|
3998
|
+
if (r.length === 0) return [];
|
|
3999
|
+
let i = /* @__PURE__ */ new Map();
|
|
4000
|
+
t.traverse((e) => {
|
|
4001
|
+
e !== t && e.name && !i.has(e.name) && i.set(e.name, e);
|
|
4002
|
+
});
|
|
4003
|
+
let a = /* @__PURE__ */ new Map();
|
|
4004
|
+
for (let e of r) {
|
|
4005
|
+
let t = $(e.attrs["physics:dynamicFriction"]) ?? $(e.attrs["physics:staticFriction"]), n = $(e.attrs["physics:restitution"]);
|
|
4006
|
+
(e.typeName === "PhysicsMaterial" || e.apiSchemas.includes("PhysicsMaterialAPI") || t !== void 0 || n !== void 0) && a.set(e.path, {
|
|
4007
|
+
...t !== void 0 && t >= 0 ? { friction: t } : {},
|
|
4008
|
+
...n !== void 0 && n >= 0 ? { restitution: n } : {}
|
|
4009
|
+
});
|
|
4010
|
+
}
|
|
4011
|
+
let o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
4012
|
+
let t = o.get(e);
|
|
4013
|
+
return t || (t = { nodeName: e }, o.set(e, t)), t;
|
|
4014
|
+
};
|
|
4015
|
+
for (let e of r) {
|
|
4016
|
+
let t = i.get(e.name);
|
|
4017
|
+
if (!t) continue;
|
|
4018
|
+
let r = (e.apiSchemas.includes("PhysicsRigidBodyAPI") || Cn(e.attrs["physics:rigidBodyEnabled"]) === !0) && Cn(e.attrs["physics:rigidBodyEnabled"]) !== !1, o = (e.apiSchemas.includes("PhysicsCollisionAPI") || e.apiSchemas.includes("PhysicsMeshCollisionAPI") || Cn(e.attrs["physics:collisionEnabled"]) === !0) && Cn(e.attrs["physics:collisionEnabled"]) !== !1;
|
|
4019
|
+
if (r) {
|
|
4020
|
+
let n = Cn(e.attrs["physics:kinematicEnabled"]) === !0, r = $(e.attrs["physics:mass"]), i = n ? r !== void 0 && r >= 0 ? r : void 0 : r !== void 0 && r > 0 ? r : 1, a = wn(e.attrs["physics:centerOfMass"]), o = wn(e.attrs["physics:diagonalInertia"]);
|
|
4021
|
+
s(t.name).motion = {
|
|
4022
|
+
isKinematic: n,
|
|
4023
|
+
...i === void 0 ? {} : { mass: i },
|
|
4024
|
+
...a ? { centerOfMass: a } : {},
|
|
4025
|
+
...o?.every((e) => e > 0) ? { inertiaDiagonal: o } : {}
|
|
4026
|
+
};
|
|
4027
|
+
}
|
|
4028
|
+
if (o) {
|
|
4029
|
+
let r = e.attrs["material:binding:physics"]?.match(/<([^>]+)>/)?.[1], i = (r ? a.get(r) : void 0) ?? a.get(e.path) ?? {}, o = En(e, n?.get(t.name) ?? [
|
|
4030
|
+
1,
|
|
4031
|
+
1,
|
|
4032
|
+
1
|
|
4033
|
+
]);
|
|
4034
|
+
if (o) s(t.name).collider = {
|
|
4035
|
+
shape: o,
|
|
4036
|
+
...i
|
|
4037
|
+
};
|
|
4038
|
+
else {
|
|
4039
|
+
let n = t instanceof p.Mesh ? t : void 0;
|
|
4040
|
+
if (n || t.traverse((e) => {
|
|
4041
|
+
!n && e instanceof p.Mesh && (n = e);
|
|
4042
|
+
}), n) {
|
|
4043
|
+
n.name || (n.name = `${t.name}_Mesh`);
|
|
4044
|
+
let r = (e.attrs["physics:approximation"] ?? "").replace(/"/g, "").trim();
|
|
4045
|
+
s(t.name).collider = {
|
|
4046
|
+
meshNodeName: n.name,
|
|
4047
|
+
convexHull: r !== "none",
|
|
4048
|
+
...i
|
|
4049
|
+
};
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
for (let e of r) {
|
|
4055
|
+
let n = e.typeName === "PhysicsRevoluteJoint" ? "revolute" : e.typeName === "PhysicsPrismaticJoint" ? "prismatic" : e.typeName === "PhysicsFixedJoint" ? "fixed" : null, r = n ? Tn(e.attrs["physics:body1"]) : void 0, a = r ? i.get(r) : void 0;
|
|
4056
|
+
if (!n || !a) continue;
|
|
4057
|
+
let o = Tn(e.attrs["physics:body0"]);
|
|
4058
|
+
if (!o || !i.has(o)) {
|
|
4059
|
+
if (o = `${e.name}_WorldAnchor`, !i.has(o)) {
|
|
4060
|
+
let n = new p.Object3D();
|
|
4061
|
+
n.name = o;
|
|
4062
|
+
let r = i.get(e.name);
|
|
4063
|
+
r && n.position.copy(r.getWorldPosition(new p.Vector3())), t.add(n), i.set(o, n);
|
|
4064
|
+
}
|
|
4065
|
+
s(o).motion = { isKinematic: !0 };
|
|
4066
|
+
}
|
|
4067
|
+
let c = s(a.name);
|
|
4068
|
+
c.motion ||= {
|
|
4069
|
+
isKinematic: !1,
|
|
4070
|
+
mass: 1
|
|
4071
|
+
};
|
|
4072
|
+
let l = (e.attrs["physics:axis"] ?? "X").replace(/"/g, "").trim().toUpperCase(), u = l === "Y" ? [
|
|
4073
|
+
0,
|
|
4074
|
+
1,
|
|
4075
|
+
0
|
|
4076
|
+
] : l === "Z" ? [
|
|
4077
|
+
0,
|
|
4078
|
+
0,
|
|
4079
|
+
1
|
|
4080
|
+
] : [
|
|
4081
|
+
1,
|
|
4082
|
+
0,
|
|
4083
|
+
0
|
|
4084
|
+
], d = n === "revolute" ? Math.PI / 180 : 1, f = $(e.attrs["physics:lowerLimit"]), m = $(e.attrs["physics:upperLimit"]), h = n === "fixed" ? [] : Dn(e.attrs, n, u, d);
|
|
4085
|
+
c.joint = {
|
|
4086
|
+
connectedNodeName: o,
|
|
4087
|
+
kind: n,
|
|
4088
|
+
...n === "fixed" ? {} : { axis: u },
|
|
4089
|
+
...f !== void 0 && m !== void 0 && f <= m ? { limits: [f * d, m * d] } : {},
|
|
4090
|
+
enableCollision: Cn(e.attrs["physics:collisionEnabled"]) === !0,
|
|
4091
|
+
...h.length > 0 ? { drives: h } : {}
|
|
4092
|
+
};
|
|
4093
|
+
}
|
|
4094
|
+
return [...o.values()];
|
|
4095
|
+
}
|
|
4096
|
+
function kn(e) {
|
|
4097
|
+
let t = "", n = !1, r = !1, i = 0, a = 0, o = !1;
|
|
4098
|
+
for (let s = 0; s < e.length; s++) {
|
|
4099
|
+
let c = e[s];
|
|
4100
|
+
r ? (t += c, c === "\n" && (r = !1, o = !1)) : !n && c === "#" ? (r = !0, t += c) : c === "\"" && e[s - 1] !== "\\" ? (n = !n, t += c) : n ? t += c : (c === "[" ? i++ : c === "]" && (i = Math.max(0, i - 1)), c === "\n" ? (o = !1, t += c) : (c === "=" && (o = !0), i === 0 && (c === "{" || c === "}") ? (o = !1, t += `\n${c}\n`) : i === 0 && c === "(" && (!o || a > 0) ? (a++, t += a === 1 ? " (\n" : "(", o = !1) : i === 0 && c === ")" && a > 0 ? (a--, t += a === 0 ? "\n)\n" : ")", o = !1) : t += c));
|
|
4101
|
+
}
|
|
4102
|
+
return t;
|
|
4103
|
+
}
|
|
4104
|
+
async function An(e, t) {
|
|
4105
|
+
let n = new we(), r = new TextEncoder(), i = new TextDecoder(), a;
|
|
4106
|
+
if (typeof e == "string") a = n.parse(kn(e));
|
|
4107
|
+
else {
|
|
4108
|
+
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
4109
|
+
if (_n(t)) a = n.parse(t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength));
|
|
4110
|
+
else if (t.byteLength >= 2 && t[0] === 80 && t[1] === 75) {
|
|
4111
|
+
let e = Se(t);
|
|
4112
|
+
for (let [t, n] of Object.entries(e)) /\.(usd|usda)$/i.test(t) && !_n(n) && (e[t] = r.encode(kn(i.decode(n))));
|
|
4113
|
+
let o = Ce(e, { level: 0 });
|
|
4114
|
+
a = n.parse(o.buffer.slice(o.byteOffset, o.byteOffset + o.byteLength));
|
|
4115
|
+
} else a = n.parse(kn(i.decode(t)));
|
|
4116
|
+
}
|
|
4117
|
+
let o = On(bn(e), a, yn(a)), s = [];
|
|
4118
|
+
a.traverse((e) => {
|
|
4119
|
+
if (!(e instanceof p.Mesh) || !e.material) return;
|
|
4120
|
+
let t = e.material;
|
|
4121
|
+
for (let e of gn) {
|
|
4122
|
+
let n = t[e];
|
|
4123
|
+
n && !n.image && (s.push({
|
|
4124
|
+
rec: t,
|
|
4125
|
+
slot: e,
|
|
4126
|
+
tex: n
|
|
4127
|
+
}), t[e] = null);
|
|
4128
|
+
}
|
|
4129
|
+
});
|
|
4130
|
+
try {
|
|
4131
|
+
return {
|
|
4132
|
+
glb: new Uint8Array(await C(a, o, t)),
|
|
4133
|
+
scene: a,
|
|
4134
|
+
specs: o
|
|
4135
|
+
};
|
|
4136
|
+
} finally {
|
|
4137
|
+
for (let e of s) e.rec[e.slot] = e.tex;
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
// src/importer/chopShopActions.ts
|
|
4141
|
+
function jn(e) {
|
|
4142
|
+
let t = e.islands.find((t) => t.id === e.loopDots.islandId);
|
|
4143
|
+
if (!t) throw Error("Loop island no longer exists.");
|
|
4144
|
+
let n, r;
|
|
4145
|
+
if (e.splitCoarse) {
|
|
4146
|
+
let i = t.mesh, a = i.geometry;
|
|
4147
|
+
i.geometry = Qe(a, e.loopDots.points).geometry;
|
|
4148
|
+
let o = Ne(e.workingScene), s = et(e.islands, o);
|
|
4149
|
+
n = () => {
|
|
4150
|
+
i.geometry = a;
|
|
4151
|
+
}, r = e.axles.map((e) => ({
|
|
4152
|
+
left: e.left.flatMap((e) => s.get(e) ?? []),
|
|
4153
|
+
right: e.right.flatMap((e) => s.get(e) ?? []),
|
|
4154
|
+
steered: e.steered,
|
|
4155
|
+
driven: e.driven,
|
|
4156
|
+
brake: e.brake
|
|
4157
|
+
}));
|
|
4158
|
+
let c = e.loopDots.points[0];
|
|
4159
|
+
if (t = o.find((e) => e.mesh === i && c.every((t, n) => t >= e.min[n] - .01 && t <= e.max[n] + .01)) ?? o[0], !t) throw Error("Refined surface lost seam anchor.");
|
|
4160
|
+
}
|
|
4161
|
+
return {
|
|
4162
|
+
selection: Ze(t, e.loopDots.points, {
|
|
4163
|
+
mirrorX: e.mirrorX,
|
|
4164
|
+
exact: e.splitCoarse
|
|
4165
|
+
}),
|
|
4166
|
+
refinedUndo: n,
|
|
4167
|
+
nextAxles: r
|
|
4168
|
+
};
|
|
4169
|
+
}
|
|
4170
|
+
function Mn(e) {
|
|
4171
|
+
let t = e.islands.find((t) => t.id === e.faceSelection.islandId);
|
|
4172
|
+
if (!t) throw Error("Selected surface island no longer exists.");
|
|
4173
|
+
let { mintedMeshes: n, undo: r } = $e(t, e.faceSelection, e.cutName), i = Ne(e.workingScene), a = et(e.islands, i), o = (e) => e.flatMap((e) => a.get(e) ?? []), s = e.prevAxles.map((e) => ({
|
|
4174
|
+
...e,
|
|
4175
|
+
left: o(e.left),
|
|
4176
|
+
right: o(e.right)
|
|
4177
|
+
})).filter((e) => e.left.length > 0 || e.right.length > 0), c = {};
|
|
4178
|
+
for (let [t, n] of Object.entries(e.prevPicks)) {
|
|
4179
|
+
let e = a.get(Number(t));
|
|
4180
|
+
e != null && (c[e] = n);
|
|
4181
|
+
}
|
|
4182
|
+
let l = new Set(n), u = i.filter((e) => l.has(e.mesh)).map((e) => e.id), d, f = !1;
|
|
4183
|
+
if (e.activeRole === "wheel") {
|
|
4184
|
+
for (let t of u) s.some((e) => e.left.includes(t) || e.right.includes(t)) || (s = Oe(i, s, t, e.mode));
|
|
4185
|
+
d = `Peeled ${u.length} wheel mesh(es) and paired axle!`;
|
|
4186
|
+
} else {
|
|
4187
|
+
for (let t of u) c[t] = e.activeRole;
|
|
4188
|
+
f = !0, d = `Peeled ${e.faceSelection.triangles.length + e.faceSelection.mirrored.length} faces → hinged ${e.activeRole.toUpperCase()}!`;
|
|
4189
|
+
}
|
|
4190
|
+
for (let e of i) e.geometry.dispose();
|
|
4191
|
+
return {
|
|
4192
|
+
nextAxles: s,
|
|
4193
|
+
nextPicks: c,
|
|
4194
|
+
undo: r,
|
|
4195
|
+
status: d,
|
|
4196
|
+
bumpHinge: f
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
function Nn(e, t, n) {
|
|
4200
|
+
if (t === "none" || e.delta > 5) return null;
|
|
4201
|
+
e.stopPropagation();
|
|
4202
|
+
let r = e.face ? e.face.normal.clone().transformDirection(e.object.matrixWorld).normalize() : new p.Vector3(0, 1, 0), i = e.point.clone().addScaledVector(r, .015), a = [
|
|
4203
|
+
Number(i.x.toFixed(4)),
|
|
4204
|
+
Number(i.y.toFixed(4)),
|
|
4205
|
+
Number(i.z.toFixed(4))
|
|
4206
|
+
], s = o(r), c = `${t}_${n}`;
|
|
4207
|
+
return t === "plume" ? {
|
|
4208
|
+
nodeName: `Kolmo_${c}`,
|
|
4209
|
+
translation: a,
|
|
4210
|
+
rotation: s,
|
|
4211
|
+
extension: {
|
|
4212
|
+
kind: "plume",
|
|
4213
|
+
drive: "boost",
|
|
4214
|
+
size: 1
|
|
4215
|
+
}
|
|
4216
|
+
} : t === "sparkle" ? {
|
|
4217
|
+
nodeName: `Kolmo_${c}`,
|
|
4218
|
+
translation: a,
|
|
4219
|
+
rotation: s,
|
|
4220
|
+
extension: {
|
|
4221
|
+
kind: "sparkle",
|
|
4222
|
+
drive: "throttle",
|
|
4223
|
+
size: 1
|
|
4224
|
+
}
|
|
4225
|
+
} : t === "brake_flare" ? {
|
|
4226
|
+
nodeName: `Kolmo_${c}`,
|
|
4227
|
+
translation: a,
|
|
4228
|
+
rotation: s,
|
|
4229
|
+
extension: {
|
|
4230
|
+
kind: "flare",
|
|
4231
|
+
drive: "brake",
|
|
4232
|
+
color: [
|
|
4233
|
+
1,
|
|
4234
|
+
.14,
|
|
4235
|
+
.08
|
|
4236
|
+
],
|
|
4237
|
+
size: .85
|
|
4238
|
+
}
|
|
4239
|
+
} : t === "headlight" ? {
|
|
4240
|
+
nodeName: `Kolmo_${c}`,
|
|
4241
|
+
translation: a,
|
|
4242
|
+
rotation: s,
|
|
4243
|
+
extension: {
|
|
4244
|
+
kind: "flare",
|
|
4245
|
+
drive: "headlight",
|
|
4246
|
+
color: [
|
|
4247
|
+
1,
|
|
4248
|
+
.96,
|
|
4249
|
+
.84
|
|
4250
|
+
],
|
|
4251
|
+
size: .75
|
|
4252
|
+
},
|
|
4253
|
+
spotLight: {
|
|
4254
|
+
color: [
|
|
4255
|
+
1,
|
|
4256
|
+
.96,
|
|
4257
|
+
.88
|
|
4258
|
+
],
|
|
4259
|
+
intensity: 18,
|
|
4260
|
+
range: 42
|
|
4261
|
+
}
|
|
4262
|
+
} : {
|
|
4263
|
+
nodeName: `Socket_${c}`,
|
|
4264
|
+
translation: a,
|
|
4265
|
+
rotation: s,
|
|
4266
|
+
extension: { socket: t }
|
|
4267
|
+
};
|
|
4268
|
+
}
|
|
4269
|
+
async function Pn(e) {
|
|
4270
|
+
let t = await e.arrayBuffer(), n = e.name.replace(/\.[^.]+$/, "") || "ImportedCar";
|
|
4271
|
+
if (vn(e.name)) {
|
|
4272
|
+
let e = await An(t);
|
|
4273
|
+
return {
|
|
4274
|
+
baseName: n,
|
|
4275
|
+
scene: e.scene,
|
|
4276
|
+
usdInfo: `USD · ${e.specs.length} node(s)`
|
|
4277
|
+
};
|
|
4278
|
+
}
|
|
4279
|
+
return {
|
|
4280
|
+
baseName: n,
|
|
4281
|
+
scene: await new Promise((e, n) => new ce().parse(t, "", (t) => e(t.scene), n)),
|
|
4282
|
+
usdInfo: null
|
|
4283
|
+
};
|
|
4284
|
+
}
|
|
4285
|
+
// src/importer/universalGateBake.ts
|
|
4286
|
+
var Fn = [
|
|
4287
|
+
"map",
|
|
4288
|
+
"normalMap",
|
|
4289
|
+
"roughnessMap",
|
|
4290
|
+
"metalnessMap",
|
|
4291
|
+
"aoMap",
|
|
4292
|
+
"emissiveMap"
|
|
4293
|
+
];
|
|
4294
|
+
function In(e, t, n, r) {
|
|
4295
|
+
return [
|
|
4296
|
+
Number((e / 12 * (n * n + r * r)).toFixed(4)),
|
|
4297
|
+
Number((e / 12 * (t * t + r * r)).toFixed(4)),
|
|
4298
|
+
Number((e / 12 * (t * t + n * n)).toFixed(4))
|
|
4299
|
+
];
|
|
4300
|
+
}
|
|
4301
|
+
async function Ln(e, n, r, i) {
|
|
4302
|
+
let a = [];
|
|
4303
|
+
e.traverse((e) => {
|
|
4304
|
+
if (!(e instanceof p.Mesh) || !e.material) return;
|
|
4305
|
+
let t = e.material;
|
|
4306
|
+
for (let e of Fn) {
|
|
4307
|
+
let n = t[e];
|
|
4308
|
+
n && !n.image && (a.push({
|
|
4309
|
+
rec: t,
|
|
4310
|
+
slot: e,
|
|
4311
|
+
tex: n
|
|
4312
|
+
}), t[e] = null);
|
|
4313
|
+
}
|
|
4314
|
+
});
|
|
4315
|
+
let o;
|
|
4316
|
+
try {
|
|
4317
|
+
o = new Uint8Array(await C(e, n, r));
|
|
4318
|
+
} finally {
|
|
4319
|
+
for (let e of a) e.rec[e.slot] = e.tex;
|
|
4320
|
+
}
|
|
4321
|
+
let s = t(o, i);
|
|
4322
|
+
return s instanceof Uint8Array ? s : new Uint8Array(s);
|
|
4323
|
+
}
|
|
4324
|
+
async function Rn(e) {
|
|
4325
|
+
if (e.domain === "vehicle" && e.usePaperShellProxy) {
|
|
4326
|
+
let { glb: n } = await ye(e.assembly, e.attachedMask, e.fuelLiters), r = new Uint8Array(T(n, (e) => {
|
|
4327
|
+
let t = e.scenes?.[0];
|
|
4328
|
+
t && (t.extras = {
|
|
4329
|
+
...t.extras ?? {},
|
|
4330
|
+
tune: {
|
|
4331
|
+
engineHorsepower: 190,
|
|
4332
|
+
gearRatios: [
|
|
4333
|
+
3.5,
|
|
4334
|
+
2.1,
|
|
4335
|
+
1.4,
|
|
4336
|
+
1
|
|
4337
|
+
],
|
|
4338
|
+
finalDriveRatio: 3.9,
|
|
4339
|
+
rollCenterHeight: .24,
|
|
4340
|
+
antiRollStiffness: 2400
|
|
4341
|
+
}
|
|
4342
|
+
});
|
|
4343
|
+
})), i = new Uint8Array(t(r, [{
|
|
4344
|
+
nodeName: "Socket_seat_gate",
|
|
4345
|
+
translation: [
|
|
4346
|
+
.34,
|
|
4347
|
+
.62,
|
|
4348
|
+
-.08
|
|
4349
|
+
],
|
|
4350
|
+
extension: { socket: "seat" }
|
|
4351
|
+
}, ...e.patches])), a = i.buffer.slice(i.byteOffset, i.byteOffset + i.byteLength);
|
|
4352
|
+
return {
|
|
4353
|
+
glbBytes: i,
|
|
4354
|
+
bundle: await w(a),
|
|
4355
|
+
worldKind: "car"
|
|
4356
|
+
};
|
|
4357
|
+
}
|
|
4358
|
+
let n = e.normalizedScene ?? new p.Group();
|
|
4359
|
+
if (e.domain === "vehicle") {
|
|
4360
|
+
let t = await ct(n, {
|
|
4361
|
+
archetype: e.vehicleArchetype,
|
|
4362
|
+
massKg: e.massKg,
|
|
4363
|
+
powerOrThrust: e.powerOrThrust,
|
|
4364
|
+
driveType: e.driveType,
|
|
4365
|
+
wheelSource: e.wheelSource,
|
|
4366
|
+
axles: e.axles,
|
|
4367
|
+
islands: e.islands,
|
|
4368
|
+
partPicks: e.partPicks,
|
|
4369
|
+
patches: e.patches,
|
|
4370
|
+
name: e.name
|
|
4371
|
+
}), r = t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
4372
|
+
return {
|
|
4373
|
+
glbBytes: t,
|
|
4374
|
+
bundle: await w(r),
|
|
4375
|
+
worldKind: e.vehicleArchetype
|
|
4376
|
+
};
|
|
4377
|
+
}
|
|
4378
|
+
if (e.domain === "launcher") {
|
|
4379
|
+
let t = e.name.toLowerCase(), { glbBytes: r, bundle: i } = await ht(t.includes("pistol") ? de : t.includes("shotgun") ? fe : P, e.normalizedScene && !e.normalizedScene.name.startsWith("Starter_") ? n : null, e.patches);
|
|
4380
|
+
return {
|
|
4381
|
+
glbBytes: r,
|
|
4382
|
+
bundle: i,
|
|
4383
|
+
worldKind: "prop"
|
|
4384
|
+
};
|
|
4385
|
+
}
|
|
4386
|
+
n.updateMatrixWorld(!0);
|
|
4387
|
+
let r = new p.Box3().setFromObject(n), i = r.isEmpty() ? new p.Vector3(1, 1, 1) : r.getSize(new p.Vector3()), a = r.isEmpty() ? new p.Vector3(0, .5, 0) : r.getCenter(new p.Vector3()), o = Math.max(.08, i.x), s = Math.max(.08, i.y), c = Math.max(.08, i.z), l = new p.Group();
|
|
4388
|
+
l.name = e.name;
|
|
4389
|
+
let u = new p.Group();
|
|
4390
|
+
u.name = e.domain === "c12" ? "C12Shell" : e.domain === "person" ? "PersonRig" : e.domain === "junk" ? "JunkTarget" : "PropBody";
|
|
4391
|
+
let d = !1;
|
|
4392
|
+
for (let e of n.clone(!0).children) u.add(e), e.traverse((e) => {
|
|
4393
|
+
e instanceof p.Mesh && (e.geometry?.getAttribute("position")?.count ?? 0) >= 3 && (d = !0);
|
|
4394
|
+
});
|
|
4395
|
+
l.add(u);
|
|
4396
|
+
let f = e.domain === "c12" || e.domain === "prop" && e.staticProp, m = Math.max(.5, e.massKg || (e.domain === "person" ? 72 : e.domain === "junk" ? 18 : 65)), h = [
|
|
4397
|
+
Number(a.x.toFixed(4)),
|
|
4398
|
+
Number(a.y.toFixed(4)),
|
|
4399
|
+
Number(a.z.toFixed(4))
|
|
4400
|
+
], g = await Ln(l, [{
|
|
4401
|
+
nodeName: u.name,
|
|
4402
|
+
motion: f ? { isKinematic: !0 } : {
|
|
4403
|
+
isKinematic: !1,
|
|
4404
|
+
mass: m,
|
|
4405
|
+
centerOfMass: h,
|
|
4406
|
+
inertiaDiagonal: In(m, o, s, c)
|
|
4407
|
+
},
|
|
4408
|
+
collider: d && !f ? {
|
|
4409
|
+
meshNodeName: u.name,
|
|
4410
|
+
convexHull: !0,
|
|
4411
|
+
friction: .62,
|
|
4412
|
+
restitution: .12
|
|
4413
|
+
} : {
|
|
4414
|
+
shape: {
|
|
4415
|
+
type: "box",
|
|
4416
|
+
size: [
|
|
4417
|
+
Number(o.toFixed(4)),
|
|
4418
|
+
Number(s.toFixed(4)),
|
|
4419
|
+
Number(c.toFixed(4))
|
|
4420
|
+
]
|
|
4421
|
+
},
|
|
4422
|
+
friction: .72,
|
|
4423
|
+
restitution: .08
|
|
4424
|
+
},
|
|
4425
|
+
extras: {
|
|
4426
|
+
role: e.domain,
|
|
4427
|
+
...e.domain === "junk" ? { destructible: {
|
|
4428
|
+
fractureShards: 8,
|
|
4429
|
+
decalBudget: 16,
|
|
4430
|
+
breakImpulseNs: 65
|
|
4431
|
+
} } : {}
|
|
4432
|
+
}
|
|
4433
|
+
}], { gateDomain: e.domain }, e.patches), _ = g.buffer.slice(g.byteOffset, g.byteOffset + g.byteLength);
|
|
4434
|
+
return {
|
|
4435
|
+
glbBytes: g,
|
|
4436
|
+
bundle: await w(_),
|
|
4437
|
+
worldKind: "prop"
|
|
4438
|
+
};
|
|
4439
|
+
}
|
|
4440
|
+
// src/importer/useChopShopController.ts
|
|
4441
|
+
function zn(e) {
|
|
4442
|
+
let t = K(), [n, r] = f("pickup_truck"), [i, a] = f(!1), [o, s] = f(null), [p, m] = f(null), [h, g] = f([
|
|
4443
|
+
0,
|
|
4444
|
+
0,
|
|
4445
|
+
0
|
|
4446
|
+
]), [_, v] = f(4.65), [y, b] = f(0), [x, S] = f(null), [C, w] = f(0), [T, E] = f([]), [D, O] = f({}), [k, A] = f("imported"), [j, ee] = f("door"), [M, te] = f("crease"), [ne, re] = f(32), [ie, ae] = f(!0), [oe, se] = f(!1), [le, N] = f(null), [ue, P] = f(null), [de, fe] = f(0), [pe, me] = f(0), [he, ge] = f([]), [_e, F] = f("Click a door/hood face with Crease Flood or Tape Lasso, then Peel!"), [ye, be] = f("none"), [xe, Se] = f([]), [Ce, we] = f(null), [I, L] = f(!1), Te = d(null), ke = d(null), Ae = d(null), je = d(0), R = c((e, t) => {
|
|
4447
|
+
L(!0), new ce().load(e, (e) => {
|
|
4448
|
+
r(t), m(e.scene), g([
|
|
4449
|
+
0,
|
|
4450
|
+
0,
|
|
4451
|
+
0
|
|
4452
|
+
]), v(t.includes("pickup") ? 4.65 : 4.2), O({}), N(null), P(null), ge([]), fe(0), F(`Loaded ${t} — chop doors/hood/trunk or pop tires!`), L(!1);
|
|
4453
|
+
}, void 0, () => L(!1));
|
|
4454
|
+
}, []);
|
|
4455
|
+
l(() => {
|
|
4456
|
+
R("/models/pickup-truck.glb", "pickup_truck");
|
|
4457
|
+
}, [R]);
|
|
4458
|
+
let z = u(() => {
|
|
4459
|
+
let e = p ?? (t.domain === "vehicle" && t.usePaperShellProxy ? null : Pt(t.domain));
|
|
4460
|
+
if (!e) return null;
|
|
4461
|
+
try {
|
|
4462
|
+
return Me(e, {
|
|
4463
|
+
turns: h,
|
|
4464
|
+
targetMeters: Math.max(.05, _),
|
|
4465
|
+
axis: "lengthZ"
|
|
4466
|
+
}).scene;
|
|
4467
|
+
} catch {
|
|
4468
|
+
return null;
|
|
4469
|
+
}
|
|
4470
|
+
}, [
|
|
4471
|
+
p,
|
|
4472
|
+
t.domain,
|
|
4473
|
+
t.usePaperShellProxy,
|
|
4474
|
+
h,
|
|
4475
|
+
_
|
|
4476
|
+
]), B = u(() => x ?? ve(t.presetId, t.shadingMode), [
|
|
4477
|
+
x,
|
|
4478
|
+
t.presetId,
|
|
4479
|
+
t.shadingMode
|
|
4480
|
+
]);
|
|
4481
|
+
l(() => {
|
|
4482
|
+
t.domain === "vehicle" && t.usePaperShellProxy ? Wt(B, 1, y, !!p, z) : z && Gt(z, y);
|
|
4483
|
+
}, [
|
|
4484
|
+
t.domain,
|
|
4485
|
+
t.usePaperShellProxy,
|
|
4486
|
+
B,
|
|
4487
|
+
z,
|
|
4488
|
+
y,
|
|
4489
|
+
p,
|
|
4490
|
+
C
|
|
4491
|
+
]);
|
|
4492
|
+
let V = u(() => z && t.domain === "vehicle" && !t.usePaperShellProxy && t.vehicleArchetype !== "starcraft" ? Ne(z) : [], [
|
|
4493
|
+
z,
|
|
4494
|
+
t.domain,
|
|
4495
|
+
t.usePaperShellProxy,
|
|
4496
|
+
t.vehicleArchetype,
|
|
4497
|
+
C
|
|
4498
|
+
]);
|
|
4499
|
+
l(() => () => {
|
|
4500
|
+
for (let e of V) e.geometry.dispose();
|
|
4501
|
+
}, [V]), l(() => {
|
|
4502
|
+
if (!z) return;
|
|
4503
|
+
let e = Ne(z);
|
|
4504
|
+
E(t.vehicleArchetype === "car" ? Ee(e) : t.vehicleArchetype === "motorcycle" ? De(e) : []);
|
|
4505
|
+
for (let t of e) t.geometry.dispose();
|
|
4506
|
+
O({}), N(null), P(null), ge([]);
|
|
4507
|
+
}, [z, t.vehicleArchetype]);
|
|
4508
|
+
let Fe = u(() => new Set(T.flatMap((e) => [...e.left, ...e.right])), [T]), Ie = u(() => {
|
|
4509
|
+
let e = /* @__PURE__ */ new Map();
|
|
4510
|
+
return T.forEach((t, n) => {
|
|
4511
|
+
for (let r of [...t.left, ...t.right]) e.set(r, n === 0 ? "#00E5FF" : "#10B981");
|
|
4512
|
+
}), e;
|
|
4513
|
+
}, [T]);
|
|
4514
|
+
return l(() => {
|
|
4515
|
+
if (t.step !== 2 || t.domain === "vehicle" && t.usePaperShellProxy) return;
|
|
4516
|
+
let e = !0;
|
|
4517
|
+
return Rn({
|
|
4518
|
+
name: n,
|
|
4519
|
+
domain: t.domain,
|
|
4520
|
+
vehicleArchetype: t.vehicleArchetype,
|
|
4521
|
+
usePaperShellProxy: !1,
|
|
4522
|
+
assembly: B,
|
|
4523
|
+
attachedMask: t.attachedMask,
|
|
4524
|
+
fuelLiters: t.fuelLiters,
|
|
4525
|
+
normalizedScene: z,
|
|
4526
|
+
massKg: t.massKg,
|
|
4527
|
+
powerOrThrust: t.powerOrThrust,
|
|
4528
|
+
driveType: t.driveType,
|
|
4529
|
+
staticProp: t.staticProp,
|
|
4530
|
+
axles: T,
|
|
4531
|
+
islands: V,
|
|
4532
|
+
partPicks: D,
|
|
4533
|
+
wheelSource: k,
|
|
4534
|
+
patches: xe
|
|
4535
|
+
}).then((t) => {
|
|
4536
|
+
e && we(t.bundle);
|
|
4537
|
+
}).catch(() => {
|
|
4538
|
+
e && we(null);
|
|
4539
|
+
}), () => {
|
|
4540
|
+
e = !1;
|
|
4541
|
+
};
|
|
4542
|
+
}, [
|
|
4543
|
+
t.step,
|
|
4544
|
+
t.domain,
|
|
4545
|
+
t.vehicleArchetype,
|
|
4546
|
+
t.usePaperShellProxy,
|
|
4547
|
+
t.massKg,
|
|
4548
|
+
t.powerOrThrust,
|
|
4549
|
+
t.driveType,
|
|
4550
|
+
t.staticProp,
|
|
4551
|
+
n,
|
|
4552
|
+
B,
|
|
4553
|
+
z,
|
|
4554
|
+
T,
|
|
4555
|
+
V,
|
|
4556
|
+
D,
|
|
4557
|
+
k,
|
|
4558
|
+
xe
|
|
4559
|
+
]), {
|
|
4560
|
+
st: t,
|
|
4561
|
+
assetName: n,
|
|
4562
|
+
hasCustomFile: i,
|
|
4563
|
+
usdInfo: o,
|
|
4564
|
+
targetMeters: _,
|
|
4565
|
+
setTargetMeters: v,
|
|
4566
|
+
setYOffset: b,
|
|
4567
|
+
setTurns: g,
|
|
4568
|
+
axles: T,
|
|
4569
|
+
setAxles: E,
|
|
4570
|
+
partPicks: D,
|
|
4571
|
+
setPartPicks: O,
|
|
4572
|
+
wheelSource: k,
|
|
4573
|
+
setWheelSource: A,
|
|
4574
|
+
activeRole: j,
|
|
4575
|
+
setActiveRole: ee,
|
|
4576
|
+
surfaceMode: M,
|
|
4577
|
+
setSurfaceMode: te,
|
|
4578
|
+
creaseDeg: ne,
|
|
4579
|
+
setCreaseDeg: re,
|
|
4580
|
+
mirrorX: ie,
|
|
4581
|
+
setMirrorX: ae,
|
|
4582
|
+
splitCoarse: oe,
|
|
4583
|
+
setSplitCoarse: se,
|
|
4584
|
+
faceSelection: le,
|
|
4585
|
+
setFaceSelection: N,
|
|
4586
|
+
loopDots: ue,
|
|
4587
|
+
setLoopDots: P,
|
|
4588
|
+
hingeScrub: de,
|
|
4589
|
+
setHingeScrub: fe,
|
|
4590
|
+
explodeAmount: pe,
|
|
4591
|
+
setExplodeAmount: me,
|
|
4592
|
+
undoStack: he,
|
|
4593
|
+
statusNote: _e,
|
|
4594
|
+
stampTool: ye,
|
|
4595
|
+
setStampTool: be,
|
|
4596
|
+
patches: xe,
|
|
4597
|
+
setPatches: Se,
|
|
4598
|
+
liveBundle: Ce,
|
|
4599
|
+
busy: I,
|
|
4600
|
+
fileRef: Te,
|
|
4601
|
+
rootObjRef: ke,
|
|
4602
|
+
panelAnimRef: Ae,
|
|
4603
|
+
workingScene: z,
|
|
4604
|
+
assembly: B,
|
|
4605
|
+
setProxyAssembly: S,
|
|
4606
|
+
islands: V,
|
|
4607
|
+
wheelColors: Ie,
|
|
4608
|
+
loadStarterCar: R,
|
|
4609
|
+
ingestFile: async (e) => {
|
|
4610
|
+
L(!0);
|
|
4611
|
+
try {
|
|
4612
|
+
let { baseName: n, scene: i, usdInfo: o } = await Pn(e);
|
|
4613
|
+
r(n), a(!0), g([
|
|
4614
|
+
0,
|
|
4615
|
+
0,
|
|
4616
|
+
0
|
|
4617
|
+
]), b(0), Se([]), t.setField("step", 1), m(i), s(o), o ? t.setField("usePaperShellProxy", !1) : t.domain === "vehicle" && t.usePaperShellProxy && S(Kt(i, t.presetId, t.shadingMode)), F(`Imported "${n}" — orient/scale, pop wheels, and chop doors/hood!`);
|
|
4618
|
+
} finally {
|
|
4619
|
+
L(!1);
|
|
4620
|
+
}
|
|
4621
|
+
},
|
|
4622
|
+
applyDomainDefaults: (e, n, r) => {
|
|
4623
|
+
let i = Ut(e, n);
|
|
4624
|
+
t.setField("domain", e), t.setField("vehicleArchetype", n), t.setField("usePaperShellProxy", r), t.setField("massKg", i.massKg), t.setField("powerOrThrust", i.power), t.setField("step", 1), v(e === "c12" ? Bt(i.len) : i.len);
|
|
4625
|
+
},
|
|
4626
|
+
handleBucketIsland: (e) => {
|
|
4627
|
+
if (t.vehicleArchetype === "starcraft") return;
|
|
4628
|
+
if (j === "wheel") {
|
|
4629
|
+
E((n) => Oe(V, n, e, t.vehicleArchetype === "motorcycle" ? "motorcycle" : "car"));
|
|
4630
|
+
return;
|
|
4631
|
+
}
|
|
4632
|
+
if (Fe.has(e)) {
|
|
4633
|
+
F("That island is already paired as a wheel.");
|
|
4634
|
+
return;
|
|
4635
|
+
}
|
|
4636
|
+
let n = V.reduce((e, t) => t.triangleIndices.length > e.triangleIndices.length ? t : e, V[0]);
|
|
4637
|
+
if (V.length > 1 && e === n.id) {
|
|
4638
|
+
F("Main body shell — switch to Crease Flood or Tape Lasso to cut a panel!");
|
|
4639
|
+
return;
|
|
4640
|
+
}
|
|
4641
|
+
let r = ie && (j === "door" || j === "fender") ? tt(V, e, Fe) : null, i = r === null ? [e] : [e, r];
|
|
4642
|
+
O((t) => {
|
|
4643
|
+
let n = { ...t }, r = t[e] === j;
|
|
4644
|
+
for (let e of i) r ? delete n[e] : n[e] = j;
|
|
4645
|
+
return F(r ? `Cleared ${j} tag.` : `Tagged ${i.length} piece(s) as ${j} — drag Hinges to test!`), n;
|
|
4646
|
+
});
|
|
4647
|
+
},
|
|
4648
|
+
handlePickFace: (e) => {
|
|
4649
|
+
let t = V.find((t) => t.id === e.islandId);
|
|
4650
|
+
t && (M === "loop" ? (N(null), P((n) => e.erase ? n && n.points.length > 1 ? {
|
|
4651
|
+
...n,
|
|
4652
|
+
points: n.points.slice(0, -1)
|
|
4653
|
+
} : null : n?.islandId === t.id ? {
|
|
4654
|
+
islandId: t.id,
|
|
4655
|
+
points: [...n.points, e.point]
|
|
4656
|
+
} : {
|
|
4657
|
+
islandId: t.id,
|
|
4658
|
+
points: [e.point]
|
|
4659
|
+
})) : (M === "crease" && !e.isDrag || M === "triangle") && N((n) => Ye(t, e.faceIndex, M, {
|
|
4660
|
+
creaseDeg: ne,
|
|
4661
|
+
mirrorX: ie,
|
|
4662
|
+
current: n,
|
|
4663
|
+
remove: e.erase
|
|
4664
|
+
})));
|
|
4665
|
+
},
|
|
4666
|
+
forgeScene: (e, t, n) => {
|
|
4667
|
+
r(e), m(t), g([
|
|
4668
|
+
0,
|
|
4669
|
+
0,
|
|
4670
|
+
0
|
|
4671
|
+
]), v(n), a(!0);
|
|
4672
|
+
},
|
|
4673
|
+
handleCloseLoop: () => {
|
|
4674
|
+
if (z && ue) try {
|
|
4675
|
+
let e = jn({
|
|
4676
|
+
workingScene: z,
|
|
4677
|
+
islands: V,
|
|
4678
|
+
loopDots: ue,
|
|
4679
|
+
splitCoarse: oe,
|
|
4680
|
+
mirrorX: ie,
|
|
4681
|
+
axles: T
|
|
4682
|
+
});
|
|
4683
|
+
e.refinedUndo && e.nextAxles && (ge((t) => [...t, {
|
|
4684
|
+
undo: e.refinedUndo,
|
|
4685
|
+
axles: T,
|
|
4686
|
+
picks: D
|
|
4687
|
+
}]), E(e.nextAxles), w((e) => e + 1)), N(e.selection), P(null), F("Loop closed — click PEEL to slice those faces into a real part!");
|
|
4688
|
+
} catch (e) {
|
|
4689
|
+
F(e instanceof Error ? e.message : "Could not close loop.");
|
|
4690
|
+
}
|
|
4691
|
+
},
|
|
4692
|
+
handlePeelSelection: () => {
|
|
4693
|
+
if (z && le && le.triangles.length !== 0) try {
|
|
4694
|
+
let e = Mn({
|
|
4695
|
+
workingScene: z,
|
|
4696
|
+
islands: V,
|
|
4697
|
+
faceSelection: le,
|
|
4698
|
+
activeRole: j,
|
|
4699
|
+
cutName: `${j}_chop_${++je.current}`,
|
|
4700
|
+
prevAxles: T,
|
|
4701
|
+
prevPicks: D,
|
|
4702
|
+
mode: t.vehicleArchetype === "motorcycle" ? "motorcycle" : "car"
|
|
4703
|
+
});
|
|
4704
|
+
e.bumpHinge && de === 0 && fe(.48), ge((t) => [...t, {
|
|
4705
|
+
undo: e.undo,
|
|
4706
|
+
axles: T,
|
|
4707
|
+
picks: D
|
|
4708
|
+
}]), E(e.nextAxles), O(e.nextPicks), N(null), P(null), w((e) => e + 1), F(e.status);
|
|
4709
|
+
} catch (e) {
|
|
4710
|
+
F(e instanceof Error ? e.message : "Peel failed.");
|
|
4711
|
+
}
|
|
4712
|
+
},
|
|
4713
|
+
handleUndoCut: () => {
|
|
4714
|
+
let e = he[he.length - 1];
|
|
4715
|
+
e && (e.undo(), ge((e) => e.slice(0, -1)), E(e.axles), O(e.picks), N(null), P(null), w((e) => e + 1), F("Undid last cut."));
|
|
4716
|
+
},
|
|
4717
|
+
handleStampSurface: (e) => {
|
|
4718
|
+
let t = Nn(e, ye, xe.length + 1);
|
|
4719
|
+
t && Se((e) => [...e, t]);
|
|
4720
|
+
},
|
|
4721
|
+
sealAndExport: async (r) => {
|
|
4722
|
+
L(!0);
|
|
4723
|
+
try {
|
|
4724
|
+
let i = await Rn({
|
|
4725
|
+
name: n,
|
|
4726
|
+
domain: t.domain,
|
|
4727
|
+
vehicleArchetype: t.vehicleArchetype,
|
|
4728
|
+
usePaperShellProxy: t.usePaperShellProxy,
|
|
4729
|
+
assembly: B,
|
|
4730
|
+
attachedMask: t.attachedMask,
|
|
4731
|
+
fuelLiters: t.fuelLiters,
|
|
4732
|
+
normalizedScene: z,
|
|
4733
|
+
massKg: t.massKg,
|
|
4734
|
+
powerOrThrust: t.powerOrThrust,
|
|
4735
|
+
driveType: t.driveType,
|
|
4736
|
+
staticProp: t.staticProp,
|
|
4737
|
+
axles: T,
|
|
4738
|
+
islands: V,
|
|
4739
|
+
partPicks: D,
|
|
4740
|
+
wheelSource: k,
|
|
4741
|
+
patches: xe
|
|
4742
|
+
});
|
|
4743
|
+
if (r && e) e({
|
|
4744
|
+
id: `${n.toLowerCase().replace(/[^a-z0-9]+/g, "_")}_${Date.now().toString(36)}`,
|
|
4745
|
+
label: n,
|
|
4746
|
+
kind: i.worldKind,
|
|
4747
|
+
domain: t.domain,
|
|
4748
|
+
glbBytes: i.glbBytes,
|
|
4749
|
+
bundle: i.bundle
|
|
4750
|
+
});
|
|
4751
|
+
else {
|
|
4752
|
+
let e = URL.createObjectURL(new Blob([i.glbBytes], { type: "model/gltf-binary" })), t = document.createElement("a");
|
|
4753
|
+
t.href = e, t.download = `${n}_khr3.glb`, t.click(), URL.revokeObjectURL(e);
|
|
4754
|
+
}
|
|
4755
|
+
} finally {
|
|
4756
|
+
L(!1);
|
|
4757
|
+
}
|
|
4758
|
+
},
|
|
4759
|
+
wheelCount: T.reduce((e, t) => e + +(t.left.length > 0) + +(t.right.length > 0), 0),
|
|
4760
|
+
choppedCount: Object.keys(D).length,
|
|
4761
|
+
unlocked: xt(t.calibration, t.domain, t.vehicleArchetype, t.usePaperShellProxy),
|
|
4762
|
+
activeRoleColor: Pe.find((e) => e.role === j)?.color ?? "#FFB000",
|
|
4763
|
+
bumpTurn: (e) => g((t) => {
|
|
4764
|
+
let n = [...t];
|
|
4765
|
+
return n[e] = (n[e] + 1) % 4, n;
|
|
4766
|
+
}),
|
|
4767
|
+
wrapProxy: () => {
|
|
4768
|
+
let e = !t.usePaperShellProxy;
|
|
4769
|
+
t.setField("usePaperShellProxy", e), e && S(Kt(z, t.presetId, t.shadingMode));
|
|
4770
|
+
},
|
|
4771
|
+
autoPopWheels: () => E(t.vehicleArchetype === "car" ? Ee(V) : De(V)),
|
|
4772
|
+
autoScaleSi: () => v(Ut(t.domain, t.vehicleArchetype).len),
|
|
4773
|
+
snapC12: () => v((e) => Bt(e))
|
|
4774
|
+
};
|
|
4775
|
+
}
|
|
4776
|
+
// src/importer/GlbImportGate.tsx
|
|
4777
|
+
function Bn({ onSpawnInWorld: e, enableWebMcp: t = !0 }) {
|
|
4778
|
+
let n = zn(e), { st: r } = n, i = r.step === 1 && r.domain === "vehicle" && !r.usePaperShellProxy && r.vehicleArchetype !== "starcraft", a = !(r.step === 2 && r.domain === "vehicle" && !r.usePaperShellProxy && r.chaseCam && n.stampTool === "none");
|
|
4779
|
+
return Mt(u(() => ({
|
|
4780
|
+
assetName: n.assetName,
|
|
4781
|
+
wheelCount: n.wheelCount,
|
|
4782
|
+
choppedCount: n.choppedCount,
|
|
4783
|
+
unlocked: n.unlocked,
|
|
4784
|
+
targetMeters: n.targetMeters,
|
|
4785
|
+
setTargetMeters: n.setTargetMeters,
|
|
4786
|
+
bumpTurn: n.bumpTurn,
|
|
4787
|
+
autoPopWheels: n.autoPopWheels,
|
|
4788
|
+
applyDomainDefaults: n.applyDomainDefaults,
|
|
4789
|
+
loadStarterCar: n.loadStarterCar,
|
|
4790
|
+
addAnchorPoint: (e, t) => {
|
|
4791
|
+
n.setPatches((n) => [...n, {
|
|
4792
|
+
nodeName: e,
|
|
4793
|
+
translation: t,
|
|
4794
|
+
extension: { socket: "optic" }
|
|
4795
|
+
}]);
|
|
4796
|
+
},
|
|
4797
|
+
sealAndExport: n.sealAndExport
|
|
4798
|
+
}), [n]), t), /* @__PURE__ */ O("div", {
|
|
4799
|
+
onDragOver: (e) => e.preventDefault(),
|
|
4800
|
+
onDrop: (e) => {
|
|
4801
|
+
e.preventDefault();
|
|
4802
|
+
let t = e.dataTransfer.files?.[0];
|
|
4803
|
+
t && n.ingestFile(t);
|
|
4804
|
+
},
|
|
4805
|
+
style: {
|
|
4806
|
+
position: "relative",
|
|
4807
|
+
display: "flex",
|
|
4808
|
+
flexDirection: "column",
|
|
4809
|
+
width: "100%",
|
|
4810
|
+
height: "100%",
|
|
4811
|
+
overflow: "hidden",
|
|
4812
|
+
background: "#0A0C0E",
|
|
4813
|
+
imageRendering: r.eraMode === "psx-1-3" ? "pixelated" : "auto"
|
|
4814
|
+
},
|
|
4815
|
+
children: [
|
|
4816
|
+
/* @__PURE__ */ D("input", {
|
|
4817
|
+
ref: n.fileRef,
|
|
4818
|
+
type: "file",
|
|
4819
|
+
accept: ".glb,.usd,.usda,.usdc,.usdz",
|
|
4820
|
+
hidden: !0,
|
|
4821
|
+
onChange: (e) => {
|
|
4822
|
+
let t = e.target.files?.[0];
|
|
4823
|
+
t && n.ingestFile(t);
|
|
4824
|
+
}
|
|
4825
|
+
}),
|
|
4826
|
+
/* @__PURE__ */ D(kt, {
|
|
4827
|
+
hasCustomFile: n.hasCustomFile,
|
|
4828
|
+
assetName: n.assetName,
|
|
4829
|
+
usdInfo: n.usdInfo,
|
|
4830
|
+
busy: n.busy,
|
|
4831
|
+
wheelCount: n.wheelCount,
|
|
4832
|
+
choppedCount: n.choppedCount,
|
|
4833
|
+
stampTool: n.stampTool,
|
|
4834
|
+
patchCount: n.patches.length,
|
|
4835
|
+
onChooseFile: () => n.fileRef.current?.click(),
|
|
4836
|
+
onLoadStarterCar: n.loadStarterCar,
|
|
4837
|
+
onSelectDomain: (e) => n.applyDomainDefaults(e, r.vehicleArchetype, !1),
|
|
4838
|
+
onSelectVehicleSub: (e) => n.applyDomainDefaults("vehicle", e, !1),
|
|
4839
|
+
onBumpTurn: n.bumpTurn,
|
|
4840
|
+
onAutoScaleSi: n.autoScaleSi,
|
|
4841
|
+
onSnapYZero: () => n.setYOffset(0),
|
|
4842
|
+
onSnapC12: n.snapC12,
|
|
4843
|
+
onWrapProxy: n.wrapProxy,
|
|
4844
|
+
onAutoPopWheels: n.autoPopWheels,
|
|
4845
|
+
onSelectStampTool: n.setStampTool,
|
|
4846
|
+
onUndoPatch: () => n.setPatches((e) => e.slice(0, -1)),
|
|
4847
|
+
onSwingPanelRole: (e) => n.panelAnimRef.current?.toggleRolePrefix(e),
|
|
4848
|
+
onDownloadGlb: () => void n.sealAndExport(!1),
|
|
4849
|
+
onSpawnWorld: e ? () => void n.sealAndExport(!0) : void 0
|
|
4850
|
+
}),
|
|
4851
|
+
r.step === 1 && r.domain !== "vehicle" && /* @__PURE__ */ D(vt, {
|
|
4852
|
+
domain: r.domain,
|
|
4853
|
+
targetMeters: n.targetMeters,
|
|
4854
|
+
onChangeTargetMeters: n.setTargetMeters,
|
|
4855
|
+
onSnapC12: n.snapC12,
|
|
4856
|
+
onLoadVaultUrl: n.loadStarterCar,
|
|
4857
|
+
onForgeLauncherRecipe: n.forgeScene,
|
|
4858
|
+
onAddSocketPatch: (e, t) => n.setPatches((n) => [...n, {
|
|
4859
|
+
nodeName: e,
|
|
4860
|
+
translation: t,
|
|
4861
|
+
extension: { socket: "optic" }
|
|
4862
|
+
}]),
|
|
4863
|
+
workingScene: n.workingScene,
|
|
4864
|
+
onEnforceCrispyPerson: () => _t(n.workingScene)
|
|
4865
|
+
}),
|
|
4866
|
+
i && /* @__PURE__ */ D(ft, {
|
|
4867
|
+
targetMeters: n.targetMeters,
|
|
4868
|
+
onChangeTargetMeters: n.setTargetMeters,
|
|
4869
|
+
activeRole: n.activeRole,
|
|
4870
|
+
onSelectRole: n.setActiveRole,
|
|
4871
|
+
surfaceMode: n.surfaceMode,
|
|
4872
|
+
onChangeSurfaceMode: (e) => {
|
|
4873
|
+
n.setSurfaceMode(e), n.setFaceSelection(null), n.setLoopDots(null);
|
|
4874
|
+
},
|
|
4875
|
+
creaseDeg: n.creaseDeg,
|
|
4876
|
+
onChangeCreaseDeg: n.setCreaseDeg,
|
|
4877
|
+
mirrorX: n.mirrorX,
|
|
4878
|
+
onToggleMirrorX: n.setMirrorX,
|
|
4879
|
+
splitCoarse: n.splitCoarse,
|
|
4880
|
+
onToggleSplitCoarse: n.setSplitCoarse,
|
|
4881
|
+
selectedFaces: n.faceSelection?.triangles.length ?? 0,
|
|
4882
|
+
mirroredFaces: n.faceSelection?.mirrored.length ?? 0,
|
|
4883
|
+
loopDotCount: n.loopDots?.points.length ?? 0,
|
|
4884
|
+
undoCount: n.undoStack.length,
|
|
4885
|
+
partPicks: n.partPicks,
|
|
4886
|
+
wheelCount: n.wheelCount,
|
|
4887
|
+
wheelSource: n.wheelSource,
|
|
4888
|
+
onChangeWheelSource: n.setWheelSource,
|
|
4889
|
+
driveType: r.driveType,
|
|
4890
|
+
onChangeDriveType: (e) => r.setField("driveType", e),
|
|
4891
|
+
horsepower: r.powerOrThrust,
|
|
4892
|
+
onChangeHorsepower: (e) => r.setField("powerOrThrust", e),
|
|
4893
|
+
hingeScrub: n.hingeScrub,
|
|
4894
|
+
onChangeHingeScrub: n.setHingeScrub,
|
|
4895
|
+
explodeAmount: n.explodeAmount,
|
|
4896
|
+
onChangeExplodeAmount: n.setExplodeAmount,
|
|
4897
|
+
statusNote: n.statusNote,
|
|
4898
|
+
unlocked: n.unlocked,
|
|
4899
|
+
busy: n.busy,
|
|
4900
|
+
onCloseLoop: n.handleCloseLoop,
|
|
4901
|
+
onPeel: n.handlePeelSelection,
|
|
4902
|
+
onClearSelection: () => {
|
|
4903
|
+
n.setFaceSelection(null), n.setLoopDots(null);
|
|
4904
|
+
},
|
|
4905
|
+
onUndoCut: n.handleUndoCut,
|
|
4906
|
+
onClearTags: () => {
|
|
4907
|
+
n.setPartPicks({}), n.setHingeScrub(0);
|
|
4908
|
+
},
|
|
4909
|
+
onGoTestDrive: () => r.setField("step", 2),
|
|
4910
|
+
onSpawnWorld: e ? () => void n.sealAndExport(!0) : void 0
|
|
4911
|
+
}),
|
|
4912
|
+
/* @__PURE__ */ D("div", {
|
|
4913
|
+
style: {
|
|
4914
|
+
flex: 1,
|
|
4915
|
+
minHeight: 0
|
|
4916
|
+
},
|
|
4917
|
+
children: /* @__PURE__ */ O(m, {
|
|
4918
|
+
dpr: r.eraMode === "psx-1-3" ? .333 : [1, 1.5],
|
|
4919
|
+
gl: {
|
|
4920
|
+
localClippingEnabled: !0,
|
|
4921
|
+
antialias: !1
|
|
4922
|
+
},
|
|
4923
|
+
camera: {
|
|
4924
|
+
position: [
|
|
4925
|
+
4.2,
|
|
4926
|
+
2.4,
|
|
4927
|
+
5.2
|
|
4928
|
+
],
|
|
4929
|
+
fov: 45
|
|
4930
|
+
},
|
|
4931
|
+
children: [
|
|
4932
|
+
/* @__PURE__ */ D("color", {
|
|
4933
|
+
attach: "background",
|
|
4934
|
+
args: ["#0A0C0E"]
|
|
4935
|
+
}),
|
|
4936
|
+
/* @__PURE__ */ D("ambientLight", { intensity: .72 }),
|
|
4937
|
+
/* @__PURE__ */ D("directionalLight", {
|
|
4938
|
+
position: [
|
|
4939
|
+
6,
|
|
4940
|
+
10,
|
|
4941
|
+
8
|
|
4942
|
+
],
|
|
4943
|
+
intensity: 1.35
|
|
4944
|
+
}),
|
|
4945
|
+
/* @__PURE__ */ D("directionalLight", {
|
|
4946
|
+
position: [
|
|
4947
|
+
-6,
|
|
4948
|
+
4,
|
|
4949
|
+
-6
|
|
4950
|
+
],
|
|
4951
|
+
intensity: .45,
|
|
4952
|
+
color: "#00E5FF"
|
|
4953
|
+
}),
|
|
4954
|
+
/* @__PURE__ */ D(v, {
|
|
4955
|
+
infiniteGrid: !0,
|
|
4956
|
+
cellSize: r.domain === "c12" ? 1 / 12 : .5,
|
|
4957
|
+
sectionSize: 3,
|
|
4958
|
+
sectionColor: "#1C2229",
|
|
4959
|
+
cellColor: "#12161B",
|
|
4960
|
+
fadeDistance: 90
|
|
4961
|
+
}),
|
|
4962
|
+
/* @__PURE__ */ D(b, {
|
|
4963
|
+
makeDefault: !0,
|
|
4964
|
+
enabled: a,
|
|
4965
|
+
enableDamping: !0
|
|
4966
|
+
}),
|
|
4967
|
+
r.step === 1 ? /* @__PURE__ */ D(It, {
|
|
4968
|
+
assembly: n.assembly,
|
|
4969
|
+
useProxy: r.domain === "vehicle" && r.usePaperShellProxy,
|
|
4970
|
+
previewScene: n.workingScene,
|
|
4971
|
+
islands: n.islands,
|
|
4972
|
+
axles: n.axles,
|
|
4973
|
+
wheelColors: n.wheelColors,
|
|
4974
|
+
partPicks: n.partPicks,
|
|
4975
|
+
wheelSource: n.wheelSource,
|
|
4976
|
+
surfaceMode: n.surfaceMode,
|
|
4977
|
+
activeRoleColor: n.activeRoleColor,
|
|
4978
|
+
faceSelection: n.faceSelection,
|
|
4979
|
+
loopDots: n.loopDots,
|
|
4980
|
+
hingeScrub: n.hingeScrub,
|
|
4981
|
+
explodeAmount: n.explodeAmount,
|
|
4982
|
+
rootObjRef: n.rootObjRef,
|
|
4983
|
+
onClickIsland: n.handleBucketIsland,
|
|
4984
|
+
onPickFace: n.handlePickFace
|
|
4985
|
+
}) : /* @__PURE__ */ D(cn, {
|
|
4986
|
+
assembly: n.assembly,
|
|
4987
|
+
importedRoot: n.workingScene,
|
|
4988
|
+
rootObjRef: n.rootObjRef,
|
|
4989
|
+
liveBundle: n.liveBundle,
|
|
4990
|
+
patches: n.patches,
|
|
4991
|
+
stampActive: n.stampTool !== "none",
|
|
4992
|
+
panelAnimRef: n.panelAnimRef,
|
|
4993
|
+
onStampSurface: n.handleStampSurface
|
|
4994
|
+
}),
|
|
4995
|
+
r.domain === "vehicle" && r.usePaperShellProxy && /* @__PURE__ */ D(mn, {
|
|
4996
|
+
chassisObjRef: n.rootObjRef,
|
|
4997
|
+
emitters: n.assembly.emitters
|
|
4998
|
+
})
|
|
4999
|
+
]
|
|
5000
|
+
})
|
|
5001
|
+
})
|
|
5002
|
+
]
|
|
5003
|
+
});
|
|
5004
|
+
}
|
|
5005
|
+
export { I as $, _t as A, Qe as B, kt as C, xt as D, G as E, nt as F, ze as G, Ye as H, rt as I, He as J, Ve as K, tt as L, mt as M, ft as N, K as O, ct as P, R as Q, $e as R, Mt as S, yt as T, Ze as U, et as V, Pe as W, Me as X, Ne as Y, z as Z, Kt as _, mn as a, jt as b, Lt as c, Ut as d, Ee as et, Ht as f, Bt as g, Gt as h, vn as i, ht as j, vt as k, Rt as l, Wt as m, Rn as n, Oe as nt, cn as o, zt as p, Re as q, An as r, $t as s, Bn as t, De as tt, Vt as u, It as v, bt as w, At as x, Pt as y, Xe as z };
|