@pinkaphant/kolmo 0.4.5 → 0.4.7
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/AGENTS.md +29 -0
- package/CLAUDE.md +8 -0
- package/README.md +11 -13
- package/bin/kolmo.mjs +7 -6
- package/dist/engine/index.d.ts +5 -1
- package/dist/engine/index.js +11 -6
- package/dist/engine/kolmoActor.d.ts +9 -1
- package/dist/engine/kolmoActor.js +12 -2
- package/dist/engine/kolmoActor.js.map +1 -1
- package/dist/engine/kolmoBotControl.d.ts +44 -0
- package/dist/engine/kolmoBotControl.js +194 -0
- package/dist/engine/kolmoBotControl.js.map +1 -0
- package/dist/engine/kolmoBotJournal.d.ts +23 -0
- package/dist/engine/kolmoBotJournal.js +138 -0
- package/dist/engine/kolmoBotJournal.js.map +1 -0
- package/dist/engine/kolmoFloatingOrigin.js +1 -8
- package/dist/engine/kolmoFloatingOrigin.js.map +1 -1
- package/dist/engine/kolmoGltfLoader.d.ts +16 -0
- package/dist/engine/kolmoGltfLoader.js +46 -0
- package/dist/engine/kolmoGltfLoader.js.map +1 -0
- package/dist/engine/kolmoHud.js +85 -80
- package/dist/engine/kolmoHud.js.map +1 -1
- package/dist/engine/kolmoInput.js +9 -7
- package/dist/engine/kolmoInput.js.map +1 -1
- package/dist/engine/kolmoLongDrive.js +32 -14
- package/dist/engine/kolmoLongDrive.js.map +1 -1
- package/dist/engine/kolmoPilotMesh.d.ts +4 -0
- package/dist/engine/kolmoPilotMesh.js +174 -2
- package/dist/engine/kolmoPilotMesh.js.map +1 -1
- package/dist/engine/kolmoVehicleAutoCompile.d.ts +1 -0
- package/dist/engine/kolmoVehicleAutoCompile.js +21 -5
- package/dist/engine/kolmoVehicleAutoCompile.js.map +1 -1
- package/dist/engine/kolmoVehicleDriver.d.ts +1 -0
- package/dist/engine/kolmoVehicleDriver.js +20 -12
- package/dist/engine/kolmoVehicleDriver.js.map +1 -1
- package/dist/engine/kolmoVehicleInner.js +25 -9
- package/dist/engine/kolmoVehicleInner.js.map +1 -1
- package/dist/engine/kolmoWardrobeRig.d.ts +22 -0
- package/dist/engine/kolmoWardrobeRig.js +146 -0
- package/dist/engine/kolmoWardrobeRig.js.map +1 -0
- package/dist/engine/kolmoWorld.d.ts +2 -2
- package/dist/engine/kolmoWorld.js +4 -1
- package/dist/engine/kolmoWorld.js.map +1 -1
- package/dist/importer/DomainWorkshopPanel.d.ts +3 -1
- package/dist/importer/DomainWorkshopPanel.js +15 -48
- package/dist/importer/DomainWorkshopPanel.js.map +1 -1
- package/dist/importer/GateHudBar.js.map +1 -1
- package/dist/importer/GlbImportGate.js +219 -210
- package/dist/importer/GlbImportGate.js.map +1 -1
- package/dist/importer/ImperativeVehicleRig.js +7 -6
- package/dist/importer/ImperativeVehicleRig.js.map +1 -1
- package/dist/importer/LiveDrivePads.js +41 -17
- package/dist/importer/LiveDrivePads.js.map +1 -1
- package/dist/importer/WardrobeWorkshopPanel.d.ts +15 -0
- package/dist/importer/WardrobeWorkshopPanel.js +529 -0
- package/dist/importer/WardrobeWorkshopPanel.js.map +1 -0
- package/dist/importer/importerWebMcp.d.ts +2 -0
- package/dist/importer/importerWebMcp.js +5 -3
- package/dist/importer/importerWebMcp.js.map +1 -1
- package/dist/importer/importerWebMcpTools.js +36 -9
- package/dist/importer/importerWebMcpTools.js.map +1 -1
- package/dist/importer/index.d.ts +6 -0
- package/dist/importer/index.js +10 -4
- package/dist/importer/khrCarGeometryMass.js +14 -8
- package/dist/importer/khrCarGeometryMass.js.map +1 -1
- package/dist/importer/khrCarPlanner.js +50 -44
- package/dist/importer/khrCarPlanner.js.map +1 -1
- package/dist/importer/useChopShopController.d.ts +2 -0
- package/dist/importer/useChopShopController.js +18 -0
- package/dist/importer/useChopShopController.js.map +1 -1
- package/dist/importer/wardrobeAutoFit.d.ts +16 -0
- package/dist/importer/wardrobeAutoFit.js +410 -0
- package/dist/importer/wardrobeAutoFit.js.map +1 -0
- package/dist/importer/wardrobeCatalog.d.ts +16 -0
- package/dist/importer/wardrobeCatalog.js +409 -0
- package/dist/importer/wardrobeCatalog.js.map +1 -0
- package/dist/importer/wardrobeController.d.ts +49 -0
- package/dist/importer/wardrobeController.js +181 -0
- package/dist/importer/wardrobeController.js.map +1 -0
- package/dist/importer/wardrobeFitter.d.ts +27 -0
- package/dist/importer/wardrobeFitter.js +269 -0
- package/dist/importer/wardrobeFitter.js.map +1 -0
- package/dist/importer/wardrobeWebMcpTools.d.ts +2 -0
- package/dist/importer/wardrobeWebMcpTools.js +198 -0
- package/dist/importer/wardrobeWebMcpTools.js.map +1 -0
- package/dist/index.js +15 -3
- package/dist/junk/DestructibleTarget.js +2 -2
- package/dist/junk/DestructibleTarget.js.map +1 -1
- package/dist/junk/ShardPieces.js +2 -2
- package/dist/junk/ShardPieces.js.map +1 -1
- package/dist/junk/index.d.ts +1 -0
- package/dist/junk/index.js +2 -1
- package/dist/junk/junkImporter.js +2 -2
- package/dist/junk/junkImporter.js.map +1 -1
- package/dist/junk/junkSheetSplitter.d.ts +38 -0
- package/dist/junk/junkSheetSplitter.js +104 -0
- package/dist/junk/junkSheetSplitter.js.map +1 -0
- package/dist/physics/index.d.ts +4 -1
- package/dist/physics/index.js +34 -8
- package/dist/physics/index.js.map +1 -1
- package/dist/physics/nBodyGravity.d.ts +42 -0
- package/dist/physics/nBodyGravity.js +70 -0
- package/dist/physics/nBodyGravity.js.map +1 -0
- package/dist/vite/index.d.ts +2 -12
- package/dist/vite/index.js +8 -77
- package/dist/vite/index.js.map +1 -1
- package/docs/api-reference.md +671 -91
- package/package.json +14 -11
- package/skills/kolmo-engine/SKILL.md +109 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { inferKolmoSocketRole } from "../schema/kolmoTypes.js";
|
|
1
|
+
import { VALID_SOCKETS, inferKolmoSocketRole } from "../schema/kolmoTypes.js";
|
|
2
2
|
import { useGateStore } from "./gateStore.js";
|
|
3
|
+
import { createWardrobeWebMcpTools } from "./wardrobeWebMcpTools.js";
|
|
3
4
|
import { VAULT_CATALOG, createAssetVault } from "@khr3/assets";
|
|
4
5
|
// src/importer/importerWebMcpTools.ts
|
|
5
6
|
function resolveModelUrl(raw, resolveKey) {
|
|
@@ -15,6 +16,17 @@ var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
|
15
16
|
"bumper",
|
|
16
17
|
"wheel"
|
|
17
18
|
]);
|
|
19
|
+
var VALID_DOMAINS = /* @__PURE__ */ new Set([
|
|
20
|
+
"vehicle",
|
|
21
|
+
"c12",
|
|
22
|
+
"launcher",
|
|
23
|
+
"person",
|
|
24
|
+
"prop",
|
|
25
|
+
"junk",
|
|
26
|
+
"suika",
|
|
27
|
+
"sand3d"
|
|
28
|
+
]);
|
|
29
|
+
var VALID_ARCHETYPES = /* @__PURE__ */ new Set(["car", "craft"]);
|
|
18
30
|
function createImporterWebMcpTools(getHost) {
|
|
19
31
|
const vault = createAssetVault();
|
|
20
32
|
return [
|
|
@@ -93,7 +105,8 @@ function createImporterWebMcpTools(getHost) {
|
|
|
93
105
|
required: ["step"]
|
|
94
106
|
},
|
|
95
107
|
execute: (input) => {
|
|
96
|
-
|
|
108
|
+
if (input.step !== 1 && input.step !== 2) throw new Error(`Invalid importer_set_stage step "${String(input.step)}". Expected 1 or 2.`);
|
|
109
|
+
const step = input.step;
|
|
97
110
|
if (step === 2 && !getHost().unlocked) return {
|
|
98
111
|
ok: false,
|
|
99
112
|
error: "Step 1 calibration requirements are not yet unlocked.",
|
|
@@ -145,7 +158,8 @@ function createImporterWebMcpTools(getHost) {
|
|
|
145
158
|
required: ["axis"]
|
|
146
159
|
},
|
|
147
160
|
execute: (input) => {
|
|
148
|
-
|
|
161
|
+
if (input.axis !== 0 && input.axis !== 1 && input.axis !== 2) throw new Error(`Invalid importer_orient axis "${String(input.axis)}". Expected 0 (X), 1 (Y), or 2 (Z).`);
|
|
162
|
+
const axis = input.axis;
|
|
149
163
|
getHost().bumpTurn(axis);
|
|
150
164
|
return {
|
|
151
165
|
ok: true,
|
|
@@ -162,7 +176,9 @@ function createImporterWebMcpTools(getHost) {
|
|
|
162
176
|
required: ["meters"]
|
|
163
177
|
},
|
|
164
178
|
execute: (input) => {
|
|
165
|
-
const
|
|
179
|
+
const rawMeters = Number(input.meters);
|
|
180
|
+
if (!Number.isFinite(rawMeters) || rawMeters <= 0) throw new Error(`Invalid importer_scale meters "${String(input.meters)}". Expected a positive finite number.`);
|
|
181
|
+
const targetMeters = Math.max(.05, rawMeters);
|
|
166
182
|
getHost().setTargetMeters(targetMeters);
|
|
167
183
|
return {
|
|
168
184
|
ok: true,
|
|
@@ -172,7 +188,7 @@ function createImporterWebMcpTools(getHost) {
|
|
|
172
188
|
},
|
|
173
189
|
{
|
|
174
190
|
name: "importer_set_kind",
|
|
175
|
-
description: "Set asset domain (vehicle, c12, launcher, person, prop, junk, suika) and optional vehicle archetype.",
|
|
191
|
+
description: "Set asset domain (vehicle, c12, launcher, person, prop, junk, suika, sand3d) and optional vehicle archetype.",
|
|
176
192
|
inputSchema: {
|
|
177
193
|
type: "object",
|
|
178
194
|
properties: {
|
|
@@ -185,7 +201,8 @@ function createImporterWebMcpTools(getHost) {
|
|
|
185
201
|
"person",
|
|
186
202
|
"prop",
|
|
187
203
|
"junk",
|
|
188
|
-
"suika"
|
|
204
|
+
"suika",
|
|
205
|
+
"sand3d"
|
|
189
206
|
]
|
|
190
207
|
},
|
|
191
208
|
archetype: {
|
|
@@ -196,7 +213,10 @@ function createImporterWebMcpTools(getHost) {
|
|
|
196
213
|
required: ["domain"]
|
|
197
214
|
},
|
|
198
215
|
execute: (input) => {
|
|
199
|
-
const
|
|
216
|
+
const rawDomain = String(input.domain ?? "");
|
|
217
|
+
if (!VALID_DOMAINS.has(rawDomain)) throw new Error(`Unknown domain "${rawDomain}". Valid domains: vehicle | c12 | launcher | person | prop | junk | suika | sand3d.`);
|
|
218
|
+
if (input.archetype !== void 0 && !VALID_ARCHETYPES.has(String(input.archetype))) throw new Error(`Unknown vehicle archetype "${String(input.archetype)}". Valid archetypes: car | craft.`);
|
|
219
|
+
const domain = rawDomain;
|
|
200
220
|
const archetype = input.archetype === "craft" ? "craft" : "car";
|
|
201
221
|
getHost().applyDomainDefaults(domain, archetype, false);
|
|
202
222
|
return {
|
|
@@ -257,7 +277,9 @@ function createImporterWebMcpTools(getHost) {
|
|
|
257
277
|
ok: false,
|
|
258
278
|
error: "Cut tool unavailable on current host."
|
|
259
279
|
};
|
|
260
|
-
const
|
|
280
|
+
const rawRole = String(input.role ?? "");
|
|
281
|
+
if (!VALID_ROLES.has(rawRole)) throw new Error(`Unknown chop role "${rawRole}". Valid roles: door | hood | trunk | fender | bumper | wheel.`);
|
|
282
|
+
const role = rawRole;
|
|
261
283
|
const loopPoints = Array.isArray(input.loopPoints) ? input.loopPoints.filter((pt) => Array.isArray(pt) && pt.length >= 3).map((pt) => [
|
|
262
284
|
Number(pt[0]) || 0,
|
|
263
285
|
Number(pt[1]) || 0,
|
|
@@ -307,6 +329,10 @@ function createImporterWebMcpTools(getHost) {
|
|
|
307
329
|
execute: (input) => {
|
|
308
330
|
const name = String(input.name ?? "").trim(), posArr = input.position;
|
|
309
331
|
if (!name || !Array.isArray(posArr) || posArr.length !== 3 || !posArr.every((v) => typeof v === "number" && Number.isFinite(v))) throw new Error("importer_set_points requires a non-empty name and a 3-element finite numeric position array.");
|
|
332
|
+
if (input.role !== void 0) {
|
|
333
|
+
const explicitRole = String(input.role);
|
|
334
|
+
if (!VALID_SOCKETS.has(explicitRole)) throw new Error(`Unknown socket role "${explicitRole}". Valid roles: seat | exit | grip_primary | grip_secondary | optic | muzzle | eject | hinge | mount | contact.`);
|
|
335
|
+
}
|
|
310
336
|
const pos = [
|
|
311
337
|
posArr[0],
|
|
312
338
|
posArr[1],
|
|
@@ -333,7 +359,8 @@ function createImporterWebMcpTools(getHost) {
|
|
|
333
359
|
await getHost().sealAndExport(!!input.spawnInWorld);
|
|
334
360
|
return { ok: true };
|
|
335
361
|
}
|
|
336
|
-
}
|
|
362
|
+
},
|
|
363
|
+
...createWardrobeWebMcpTools(getHost)
|
|
337
364
|
];
|
|
338
365
|
}
|
|
339
366
|
export { createImporterWebMcpTools };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importerWebMcpTools.js","names":[],"sources":["../../src/importer/importerWebMcpTools.ts"],"sourcesContent":["import { VAULT_CATALOG, createAssetVault } from \"@khr3/assets\";\nimport { inferKolmoSocketRole, type KolmoSocketRole } from \"../schema/kolmoSchema.js\";\nimport { useGateStore, type GateDomain } from \"./gateStore.js\";\nimport type { ImporterWebMcpHost, WebMcpTool } from \"./importerWebMcp.js\";\nimport type { ActiveChopRole } from \"./surfaceCutter.js\";\n\nfunction resolveModelUrl(raw: string, resolveKey: (key: string) => string): string {\n const trimmed = raw.trim();\n if (!trimmed || /^(javascript|data|vbscript|file):/i.test(trimmed))\n throw new Error(`Invalid importer model URL: \"${raw}\"`);\n return /^https?:\\/\\//i.test(trimmed) || trimmed.startsWith(\"/\") ? trimmed : resolveKey(trimmed);\n}\n\nconst VALID_ROLES = new Set<string>([\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"]);\n\nexport function createImporterWebMcpTools(getHost: () => ImporterWebMcpHost): readonly WebMcpTool[] {\n const vault = createAssetVault();\n return [\n {\n name: \"importer_state\",\n description: \"Read current calibration bounds, SI scale, domain, step, wheel axles, and unlock status.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const h = getHost(), st = useGateStore.getState();\n return {\n assetName: h.assetName, domain: st.domain, step: st.step, vehicleArchetype: st.vehicleArchetype,\n targetMeters: h.targetMeters, wheelCount: h.wheelCount, choppedCount: h.choppedCount,\n unlocked: h.unlocked, calibration: st.calibration,\n };\n },\n },\n {\n name: \"importer_capture_view\",\n description: \"Capture current 3D calibration viewport PNG data URL.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const dataUrl = getHost().captureDataUrl?.() ?? null;\n return { ok: !!dataUrl, mimeType: \"image/png\", dataUrl };\n },\n },\n {\n name: \"importer_list_models\",\n description: \"List available starter and R2 vault .glb models across cars, weapons, and city categories.\",\n inputSchema: { type: \"object\", properties: { prefix: { type: \"string\" } } },\n annotations: { readOnlyHint: true },\n execute: async (input) => {\n const prefix = typeof input.prefix === \"string\" ? input.prefix : \"\";\n try { return { catalog: VAULT_CATALOG, liveVault: await vault.listPrefix(prefix) }; }\n catch { return { catalog: VAULT_CATALOG, liveVault: null }; }\n },\n },\n {\n name: \"importer_set_stage\",\n description: \"Switch importer stage (1 = Chop & Calibrate, 2 = Live Drive / Seal Pad; requires Step 1 unlocked).\",\n inputSchema: { type: \"object\", properties: { step: { type: \"number\", enum: [1, 2] } }, required: [\"step\"] },\n execute: (input) => {\n const step = input.step === 2 ? 2 : 1;\n if (step === 2 && !getHost().unlocked)\n return { ok: false, error: \"Step 1 calibration requirements are not yet unlocked.\", step: 1 };\n useGateStore.getState().setField(\"step\", step);\n return { ok: true, step };\n },\n },\n {\n name: \"importer_load\",\n description: \"Load a .glb model by URL or vault key into the calibration bay.\",\n inputSchema: { type: \"object\", properties: { url: { type: \"string\" }, name: { type: \"string\" } }, required: [\"url\"] },\n execute: async (input) => {\n const rawUrl = String(input.url ?? \"\");\n const url = resolveModelUrl(rawUrl, (k) => vault.url(k));\n const label = typeof input.name === \"string\" && input.name.trim()\n ? input.name.trim()\n : rawUrl.split(\"/\").pop()?.replace(/\\.glb$/i, \"\") || \"asset\";\n await getHost().loadStarterCar(url, label);\n return { ok: true, url, label };\n },\n },\n {\n name: \"importer_orient\",\n description: \"Rotate asset in exact 90-degree quarter-turns around X (0), Y (1), or Z (2).\",\n inputSchema: { type: \"object\", properties: { axis: { type: \"number\", enum: [0, 1, 2] } }, required: [\"axis\"] },\n execute: (input) => {\n const axis: 0 | 1 | 2 = input.axis === 1 ? 1 : input.axis === 2 ? 2 : 0;\n getHost().bumpTurn(axis);\n return { ok: true, axis };\n },\n },\n {\n name: \"importer_scale\",\n description: \"Scale asset cleanly to exact SI target meters with [1,1,1] node scale and Y=0 contact.\",\n inputSchema: { type: \"object\", properties: { meters: { type: \"number\" } }, required: [\"meters\"] },\n execute: (input) => {\n const targetMeters = Math.max(0.05, Number(input.meters) || 1);\n getHost().setTargetMeters(targetMeters);\n return { ok: true, targetMeters };\n },\n },\n {\n name: \"importer_set_kind\",\n description: \"Set asset domain (vehicle, c12, launcher, person, prop, junk, suika) and optional vehicle archetype.\",\n inputSchema: {\n type: \"object\",\n properties: {\n domain: { type: \"string\", enum: [\"vehicle\", \"c12\", \"launcher\", \"person\", \"prop\", \"junk\", \"suika\"] },\n archetype: { type: \"string\", enum: [\"car\", \"craft\"] },\n },\n required: [\"domain\"],\n },\n execute: (input) => {\n const domain = (input.domain as GateDomain) || \"vehicle\";\n const archetype = input.archetype === \"craft\" ? \"craft\" : \"car\";\n getHost().applyDomainDefaults(domain, archetype, false);\n return { ok: true, domain, archetype };\n },\n },\n {\n name: \"importer_pop_wheels\",\n description: \"Auto-detect and pair symmetric wheel islands into Ecctrl ShapeCastWheel axles.\",\n inputSchema: { type: \"object\", properties: {} },\n execute: () => { getHost().autoPopWheels(); return { ok: true }; },\n },\n {\n name: \"importer_cut_part\",\n description: \"Cut or tag an openable/hinged KHR vehicle part by islandId, crease faceIndex, or loopPoints.\",\n inputSchema: {\n type: \"object\",\n properties: {\n role: { type: \"string\", enum: [\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"] },\n islandId: { type: \"number\" }, faceIndex: { type: \"number\" }, creaseDeg: { type: \"number\" }, mirrorX: { type: \"boolean\" },\n loopPoints: { type: \"array\", items: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 } },\n },\n required: [\"role\"],\n },\n execute: (input) => {\n const h = getHost();\n if (!h.cutPart) return { ok: false, error: \"Cut tool unavailable on current host.\" };\n const role: ActiveChopRole = VALID_ROLES.has(String(input.role)) ? (input.role as ActiveChopRole) : \"door\";\n const loopPoints = Array.isArray(input.loopPoints)\n ? input.loopPoints.filter((pt): pt is number[] => Array.isArray(pt) && pt.length >= 3)\n .map((pt) => [Number(pt[0]) || 0, Number(pt[1]) || 0, Number(pt[2]) || 0] as const)\n : undefined;\n return h.cutPart({\n role,\n ...(typeof input.islandId === \"number\" ? { islandId: input.islandId } : {}),\n ...(typeof input.faceIndex === \"number\" ? { faceIndex: input.faceIndex } : {}),\n ...(typeof input.creaseDeg === \"number\" ? { creaseDeg: input.creaseDeg } : {}),\n ...(typeof input.mirrorX === \"boolean\" ? { mirrorX: input.mirrorX } : {}),\n ...(loopPoints && loopPoints.length >= 3 ? { loopPoints } : {}),\n });\n },\n },\n {\n name: \"importer_set_points\",\n description: \"Stamp an explicit IK / muzzle / grip / seat / contact / hinge socket point in local SI meters.\",\n inputSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n role: { type: \"string\", enum: [\"seat\", \"exit\", \"grip_primary\", \"grip_secondary\", \"optic\", \"muzzle\", \"eject\", \"hinge\", \"mount\", \"contact\"] },\n position: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 },\n },\n required: [\"name\", \"position\"],\n },\n execute: (input) => {\n const name = String(input.name ?? \"\").trim(), posArr = input.position;\n if (!name || !Array.isArray(posArr) || posArr.length !== 3 || !posArr.every((v) => typeof v === \"number\" && Number.isFinite(v)))\n throw new Error(\"importer_set_points requires a non-empty name and a 3-element finite numeric position array.\");\n const pos: [number, number, number] = [posArr[0], posArr[1], posArr[2]];\n const role = inferKolmoSocketRole(name, typeof input.role === \"string\" ? (input.role as KolmoSocketRole) : undefined);\n getHost().addAnchorPoint(name, pos, role);\n return { ok: true, name, role, position: pos };\n },\n },\n {\n name: \"importer_export\",\n description: \"Bake and export the KHR_physics_rigid_bodies .glb (or spawn straight into the active world).\",\n inputSchema: { type: \"object\", properties: { spawnInWorld: { type: \"boolean\" } } },\n execute: async (input) => { await getHost().sealAndExport(!!input.spawnInWorld);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AAa;IACT,MAAM;IACN,YAAY;KACR,MAAM,EAAE,MAAM,SAAS;KACvB,MAAM;MAAE,MAAM;MAAU,MAAM;OAAC;OAAQ;OAAQ;OAAgB;OAAkB;OAAS;OAAU;OAAS;OAAS;OAAS;MAAS;KAAE;KAC1I,UAAU;MAAE,MAAM;MAAS,OAAO,EAAE,MAAM,SAAS;MAAG,UAAU;MAAG,UAAU;KAAE;IACnF;IACA,UAAU,CAAC,QAAQ,UAAU;GACjC;GACA,UAAU,UAAU;IAChB,MAAM,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,SAAS,MAAM;IAC7D,IAAI,CAAC,QAAQ,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW,KAAK,CAAC,OAAO,OAAO,MAAM,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,CAAC,GAC1H,MAAM,IAAI,MAAM,8FAA8F;IAClH,MAAM,MAAgC;KAAC,OAAO;KAAI,OAAO;KAAI,OAAO;IAAE;IACtE,MAAM,OAAO,qBAAqB,MAAM,OAAO,MAAM,SAAS,WAAY,MAAM,OAA2B,KAAA,CAAS;IACpH,QAAQ,CAAC,CAAC,eAAe,MAAM,KAAK,IAAI;IACxC,OAAO;KAAE,IAAI;KAAM;KAAM;KAAM,UAAU;IAAI;GACjD;EACJ;EACA;GACI,MAAM;GACN,aAAa;GACb,aAAa;IAAE,MAAM;IAAU,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,EAAE;GAAE;GACjF,SAAS,OAAO,UAAU;IAAE,MAAM,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,YAAY;IAAG,OAAO,EAAE,IAAI,KAAK;GAAG;EAC1G;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"importerWebMcpTools.js","names":[],"sources":["../../src/importer/importerWebMcpTools.ts"],"sourcesContent":["import { VAULT_CATALOG, createAssetVault } from \"@khr3/assets\";\nimport { inferKolmoSocketRole, type KolmoSocketRole } from \"../schema/kolmoSchema.js\";\nimport { VALID_SOCKETS } from \"../schema/kolmoTypes.js\";\nimport { useGateStore, type GateDomain } from \"./gateStore.js\";\nimport type { ImporterWebMcpHost, WebMcpTool } from \"./importerWebMcp.js\";\nimport type { ActiveChopRole } from \"./surfaceCutter.js\";\nimport { createWardrobeWebMcpTools } from \"./wardrobeWebMcpTools.js\";\n\nfunction resolveModelUrl(raw: string, resolveKey: (key: string) => string): string {\n const trimmed = raw.trim();\n if (!trimmed || /^(javascript|data|vbscript|file):/i.test(trimmed))\n throw new Error(`Invalid importer model URL: \"${raw}\"`);\n return /^https?:\\/\\//i.test(trimmed) || trimmed.startsWith(\"/\") ? trimmed : resolveKey(trimmed);\n}\n\nconst VALID_ROLES = new Set<string>([\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"]);\nconst VALID_DOMAINS = new Set<string>([\"vehicle\", \"c12\", \"launcher\", \"person\", \"prop\", \"junk\", \"suika\", \"sand3d\"]);\nconst VALID_ARCHETYPES = new Set<string>([\"car\", \"craft\"]);\n\nexport function createImporterWebMcpTools(getHost: () => ImporterWebMcpHost): readonly WebMcpTool[] {\n const vault = createAssetVault();\n return [\n {\n name: \"importer_state\",\n description: \"Read current calibration bounds, SI scale, domain, step, wheel axles, and unlock status.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const h = getHost(), st = useGateStore.getState();\n return {\n assetName: h.assetName, domain: st.domain, step: st.step, vehicleArchetype: st.vehicleArchetype,\n targetMeters: h.targetMeters, wheelCount: h.wheelCount, choppedCount: h.choppedCount,\n unlocked: h.unlocked, calibration: st.calibration,\n };\n },\n },\n {\n name: \"importer_capture_view\",\n description: \"Capture current 3D calibration viewport PNG data URL.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const dataUrl = getHost().captureDataUrl?.() ?? null;\n return { ok: !!dataUrl, mimeType: \"image/png\", dataUrl };\n },\n },\n {\n name: \"importer_list_models\",\n description: \"List available starter and R2 vault .glb models across cars, weapons, and city categories.\",\n inputSchema: { type: \"object\", properties: { prefix: { type: \"string\" } } },\n annotations: { readOnlyHint: true },\n execute: async (input) => {\n const prefix = typeof input.prefix === \"string\" ? input.prefix : \"\";\n try { return { catalog: VAULT_CATALOG, liveVault: await vault.listPrefix(prefix) }; }\n catch { return { catalog: VAULT_CATALOG, liveVault: null }; }\n },\n },\n {\n name: \"importer_set_stage\",\n description: \"Switch importer stage (1 = Chop & Calibrate, 2 = Live Drive / Seal Pad; requires Step 1 unlocked).\",\n inputSchema: { type: \"object\", properties: { step: { type: \"number\", enum: [1, 2] } }, required: [\"step\"] },\n execute: (input) => {\n if (input.step !== 1 && input.step !== 2) {\n throw new Error(`Invalid importer_set_stage step \"${String(input.step)}\". Expected 1 or 2.`);\n }\n const step = input.step;\n if (step === 2 && !getHost().unlocked)\n return { ok: false, error: \"Step 1 calibration requirements are not yet unlocked.\", step: 1 };\n useGateStore.getState().setField(\"step\", step);\n return { ok: true, step };\n },\n },\n {\n name: \"importer_load\",\n description: \"Load a .glb model by URL or vault key into the calibration bay.\",\n inputSchema: { type: \"object\", properties: { url: { type: \"string\" }, name: { type: \"string\" } }, required: [\"url\"] },\n execute: async (input) => {\n const rawUrl = String(input.url ?? \"\");\n const url = resolveModelUrl(rawUrl, (k) => vault.url(k));\n const label = typeof input.name === \"string\" && input.name.trim()\n ? input.name.trim()\n : rawUrl.split(\"/\").pop()?.replace(/\\.glb$/i, \"\") || \"asset\";\n await getHost().loadStarterCar(url, label);\n return { ok: true, url, label };\n },\n },\n {\n name: \"importer_orient\",\n description: \"Rotate asset in exact 90-degree quarter-turns around X (0), Y (1), or Z (2).\",\n inputSchema: { type: \"object\", properties: { axis: { type: \"number\", enum: [0, 1, 2] } }, required: [\"axis\"] },\n execute: (input) => {\n if (input.axis !== 0 && input.axis !== 1 && input.axis !== 2) {\n throw new Error(`Invalid importer_orient axis \"${String(input.axis)}\". Expected 0 (X), 1 (Y), or 2 (Z).`);\n }\n const axis: 0 | 1 | 2 = input.axis;\n getHost().bumpTurn(axis);\n return { ok: true, axis };\n },\n },\n {\n name: \"importer_scale\",\n description: \"Scale asset cleanly to exact SI target meters with [1,1,1] node scale and Y=0 contact.\",\n inputSchema: { type: \"object\", properties: { meters: { type: \"number\" } }, required: [\"meters\"] },\n execute: (input) => {\n const rawMeters = Number(input.meters);\n if (!Number.isFinite(rawMeters) || rawMeters <= 0) {\n throw new Error(`Invalid importer_scale meters \"${String(input.meters)}\". Expected a positive finite number.`);\n }\n const targetMeters = Math.max(0.05, rawMeters);\n getHost().setTargetMeters(targetMeters);\n return { ok: true, targetMeters };\n },\n },\n {\n name: \"importer_set_kind\",\n description: \"Set asset domain (vehicle, c12, launcher, person, prop, junk, suika, sand3d) and optional vehicle archetype.\",\n inputSchema: {\n type: \"object\",\n properties: {\n domain: { type: \"string\", enum: [\"vehicle\", \"c12\", \"launcher\", \"person\", \"prop\", \"junk\", \"suika\", \"sand3d\"] },\n archetype: { type: \"string\", enum: [\"car\", \"craft\"] },\n },\n required: [\"domain\"],\n },\n execute: (input) => {\n const rawDomain = String(input.domain ?? \"\");\n if (!VALID_DOMAINS.has(rawDomain)) {\n throw new Error(`Unknown domain \"${rawDomain}\". Valid domains: vehicle | c12 | launcher | person | prop | junk | suika | sand3d.`);\n }\n if (input.archetype !== undefined && !VALID_ARCHETYPES.has(String(input.archetype))) {\n throw new Error(`Unknown vehicle archetype \"${String(input.archetype)}\". Valid archetypes: car | craft.`);\n }\n const domain = rawDomain as GateDomain;\n const archetype = input.archetype === \"craft\" ? \"craft\" : \"car\";\n getHost().applyDomainDefaults(domain, archetype, false);\n return { ok: true, domain, archetype };\n },\n },\n {\n name: \"importer_pop_wheels\",\n description: \"Auto-detect and pair symmetric wheel islands into Ecctrl ShapeCastWheel axles.\",\n inputSchema: { type: \"object\", properties: {} },\n execute: () => { getHost().autoPopWheels(); return { ok: true }; },\n },\n {\n name: \"importer_cut_part\",\n description: \"Cut or tag an openable/hinged KHR vehicle part by islandId, crease faceIndex, or loopPoints.\",\n inputSchema: {\n type: \"object\",\n properties: {\n role: { type: \"string\", enum: [\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"] },\n islandId: { type: \"number\" }, faceIndex: { type: \"number\" }, creaseDeg: { type: \"number\" }, mirrorX: { type: \"boolean\" },\n loopPoints: { type: \"array\", items: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 } },\n },\n required: [\"role\"],\n },\n execute: (input) => {\n const h = getHost();\n if (!h.cutPart) return { ok: false, error: \"Cut tool unavailable on current host.\" };\n const rawRole = String(input.role ?? \"\");\n if (!VALID_ROLES.has(rawRole)) {\n throw new Error(`Unknown chop role \"${rawRole}\". Valid roles: door | hood | trunk | fender | bumper | wheel.`);\n }\n const role = rawRole as ActiveChopRole;\n const loopPoints = Array.isArray(input.loopPoints)\n ? input.loopPoints.filter((pt): pt is number[] => Array.isArray(pt) && pt.length >= 3)\n .map((pt) => [Number(pt[0]) || 0, Number(pt[1]) || 0, Number(pt[2]) || 0] as const)\n : undefined;\n return h.cutPart({\n role,\n ...(typeof input.islandId === \"number\" ? { islandId: input.islandId } : {}),\n ...(typeof input.faceIndex === \"number\" ? { faceIndex: input.faceIndex } : {}),\n ...(typeof input.creaseDeg === \"number\" ? { creaseDeg: input.creaseDeg } : {}),\n ...(typeof input.mirrorX === \"boolean\" ? { mirrorX: input.mirrorX } : {}),\n ...(loopPoints && loopPoints.length >= 3 ? { loopPoints } : {}),\n });\n },\n },\n {\n name: \"importer_set_points\",\n description: \"Stamp an explicit IK / muzzle / grip / seat / contact / hinge socket point in local SI meters.\",\n inputSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n role: { type: \"string\", enum: [\"seat\", \"exit\", \"grip_primary\", \"grip_secondary\", \"optic\", \"muzzle\", \"eject\", \"hinge\", \"mount\", \"contact\"] },\n position: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 },\n },\n required: [\"name\", \"position\"],\n },\n execute: (input) => {\n const name = String(input.name ?? \"\").trim(), posArr = input.position;\n if (!name || !Array.isArray(posArr) || posArr.length !== 3 || !posArr.every((v) => typeof v === \"number\" && Number.isFinite(v)))\n throw new Error(\"importer_set_points requires a non-empty name and a 3-element finite numeric position array.\");\n if (input.role !== undefined) {\n const explicitRole = String(input.role);\n if (!VALID_SOCKETS.has(explicitRole)) {\n throw new Error(\n `Unknown socket role \"${explicitRole}\". Valid roles: seat | exit | grip_primary | grip_secondary | optic | muzzle | eject | hinge | mount | contact.`,\n );\n }\n }\n const pos: [number, number, number] = [posArr[0], posArr[1], posArr[2]];\n const role = inferKolmoSocketRole(name, typeof input.role === \"string\" ? (input.role as KolmoSocketRole) : undefined);\n getHost().addAnchorPoint(name, pos, role);\n return { ok: true, name, role, position: pos };\n },\n },\n {\n name: \"importer_export\",\n description: \"Bake and export the KHR_physics_rigid_bodies .glb (or spawn straight into the active world).\",\n inputSchema: { type: \"object\", properties: { spawnInWorld: { type: \"boolean\" } } },\n execute: async (input) => { await getHost().sealAndExport(!!input.spawnInWorld); return { ok: true }; },\n },\n ...createWardrobeWebMcpTools(getHost),\n ];\n}\n"],"mappings":";;;;;AAQA,SAAS,gBAAgB,KAAa,YAA6C;CAC/E,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,CAAC,WAAW,qCAAqC,KAAK,OAAO,GAC7D,MAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;CAC1D,OAAO,gBAAgB,KAAK,OAAO,KAAK,QAAQ,WAAW,GAAG,IAAI,UAAU,WAAW,OAAO;AAClG;AAEA,IAAM,8BAAc,IAAI,IAAY;CAAC;CAAQ;CAAQ;CAAS;CAAU;CAAU;AAAO,CAAC;AAC1F,IAAM,gCAAgB,IAAI,IAAY;CAAC;CAAW;CAAO;CAAY;CAAU;CAAQ;CAAQ;CAAS;AAAQ,CAAC;AACjH,IAAM,mCAAmB,IAAI,IAAY,CAAC,OAAO,OAAO,CA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AAM;KAAM,UAAU;IAAI;GACjD;EACJ;EACA;GACI,MAAM;GACN,aAAa;GACb,aAAa;IAAE,MAAM;IAAU,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,EAAE;GAAE;GACjF,SAAS,OAAO,UAAU;IAAE,MAAM,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,YAAY;IAAG,OAAO,EAAE,IAAI,KAAK;GAAG;EAC1G;EACA,GAAG,0BAA0B,OAAO;CACxC;AACJ"}
|
package/dist/importer/index.d.ts
CHANGED
|
@@ -21,3 +21,9 @@ export * from "./meshIslands.js";
|
|
|
21
21
|
export * from "./khrCompiler.js";
|
|
22
22
|
export * from "./fusedWheelDetect.js";
|
|
23
23
|
export * from "./cylinderBooleanSlice.js";
|
|
24
|
+
export * from "./wardrobeCatalog.js";
|
|
25
|
+
export * from "./wardrobeFitter.js";
|
|
26
|
+
export * from "./wardrobeAutoFit.js";
|
|
27
|
+
export * from "./wardrobeController.js";
|
|
28
|
+
export * from "./wardrobeWebMcpTools.js";
|
|
29
|
+
export { WardrobeWorkshopSection, type WardrobeWorkshopSectionProps } from "./WardrobeWorkshopPanel.js";
|
package/dist/importer/index.js
CHANGED
|
@@ -16,14 +16,14 @@ import { ImperativeVehicleRig } from "./ImperativeVehicleRig.js";
|
|
|
16
16
|
import { Step2UniversalPad } from "./Step2UniversalPad.js";
|
|
17
17
|
import { VfxEmitterPool } from "./VfxEmitterPool.js";
|
|
18
18
|
import { DAMP_ZETA, FREQ_HZ, gateTelemetry, isGateStep1Unlocked, useGateStore } from "./gateStore.js";
|
|
19
|
-
import { JUNK_PROCEDURAL_RECIPES, buildProceduralJunkScene } from "../junk/junkProceduralScenes.js";
|
|
20
|
-
import { C12_PROCEDURAL_RECIPES, buildProceduralC12Scene } from "./proceduralC12AndCraft.js";
|
|
21
|
-
import { PERSON_PROCEDURAL_RECIPES, PROP_PROCEDURAL_RECIPES, buildProceduralPersonScene, buildProceduralPropScene } from "./proceduralPersonAndProp.js";
|
|
22
19
|
import { C12_TICK_M, UNIFIED_ANCHOR_NAMES, computeC12Metrics, defaultTargetMeters, detectSceneAnchors, khrBoxToRapierHalfExtents, measureAssemblyCalibration, measureNormalizedSceneCalibration, snapMetersToC12, wrapSingleMeshWithPaperShellProxy } from "./glbNormalizer.js";
|
|
23
20
|
import { bakeUniversalGateGlb } from "./universalGateBake.js";
|
|
24
21
|
import { bakeArticulatedLauncherGlb, buildLauncherSceneFromPlan } from "./launcherBake.js";
|
|
25
22
|
import { convertUsdToGlb, isUsdFileName } from "./usdToGlb.js";
|
|
26
23
|
import { ChopShopPanel } from "./ChopShopPanel.js";
|
|
24
|
+
import { JUNK_PROCEDURAL_RECIPES, buildProceduralJunkScene } from "../junk/junkProceduralScenes.js";
|
|
25
|
+
import { C12_PROCEDURAL_RECIPES, buildProceduralC12Scene } from "./proceduralC12AndCraft.js";
|
|
26
|
+
import { PERSON_PROCEDURAL_RECIPES, PROP_PROCEDURAL_RECIPES, buildProceduralPersonScene, buildProceduralPropScene } from "./proceduralPersonAndProp.js";
|
|
27
27
|
import { useChopShopController } from "./useChopShopController.js";
|
|
28
28
|
import { DomainWorkshopPanel, enforceRetroPersonMaterials } from "./DomainWorkshopPanel.js";
|
|
29
29
|
import { buildImporterWebMcpTools, getNavigatorModelContext, useImporterWebMcp } from "./importerWebMcp.js";
|
|
@@ -33,4 +33,10 @@ import { extractMeshIslands } from "./meshIslands.js";
|
|
|
33
33
|
import { compileKhrAssetGlb } from "./khrCompiler.js";
|
|
34
34
|
import { detectFusedCarWheels } from "./fusedWheelDetect.js";
|
|
35
35
|
import { sliceCarWheelCylinders } from "./cylinderBooleanSlice.js";
|
|
36
|
-
|
|
36
|
+
import { TRIPO_CHARACTER_BASES, TRIPO_WARDROBE_BASE_PATH, TRIPO_WARDROBE_GARMENTS, inferWardrobeSlotFromName, tripoWardrobeUrl } from "./wardrobeCatalog.js";
|
|
37
|
+
import { applyWardrobePiecePatch, listWardrobePieces, resetWardrobePiece } from "./wardrobeFitter.js";
|
|
38
|
+
import { autoFitWardrobeShoes, bindWardrobeToHumanoidSkeleton, layerGarmentOntoCharacterScene, tuckInnerBodyUnderClothing } from "./wardrobeAutoFit.js";
|
|
39
|
+
import { detectCharacterDefaultTurns, executeWardrobeFitOnHost, layerWardrobeGarmentIntoHost, loadGlbSceneFromUrl, loadWardrobeBaseIntoHost, removeWardrobePieceFromHost, resolveWardrobeCatalogUrl } from "./wardrobeController.js";
|
|
40
|
+
import { createWardrobeWebMcpTools } from "./wardrobeWebMcpTools.js";
|
|
41
|
+
import { WardrobeWorkshopSection } from "./WardrobeWorkshopPanel.js";
|
|
42
|
+
export { C12_PROCEDURAL_RECIPES, C12_TICK_M, CHOP_ROLES, CRAFT_PROCEDURAL_RECIPES, ChopShopPanel, DAMP_ZETA, DomainWorkshopPanel, FREQ_HZ, GateHudBar, GlbImportGate, ImperativeVehicleRig, GlbImportGate as ImporterWorkbench, JUNK_PROCEDURAL_RECIPES, PERSON_PROCEDURAL_RECIPES, PROP_PROCEDURAL_RECIPES, Step1CalibrationPlinth, Step2UniversalPad, TRIPO_CHARACTER_BASES, TRIPO_WARDROBE_BASE_PATH, TRIPO_WARDROBE_GARMENTS, UNIFIED_ANCHOR_NAMES, VfxEmitterPool, WardrobeWorkshopSection, WheelRingHandles3D, applyWardrobePiecePatch, autoFitWardrobeShoes, bakeArticulatedLauncherGlb, bakeUniversalGateGlb, bindWardrobeToHumanoidSkeleton, buildImporterWebMcpTools, buildLauncherSceneFromPlan, buildPatchPreviewEmitters, buildProceduralC12Scene, buildProceduralCraftScene, buildProceduralDomainScene, buildProceduralJunkScene, buildProceduralPersonScene, buildProceduralPropScene, buildSelectionOverlayGeometry, buildSurfaceTopology, compileKhrAssetGlb, computeC12Metrics, computeChopPartHinge, convertUsdToGlb, createFleet12GonWheelGroup, createWardrobeWebMcpTools, defaultTargetMeters, detectCharacterDefaultTurns, detectFusedCarWheels, detectSceneAnchors, enforceMirrorCutterSymmetry, enforceRetroPersonMaterials, executeWardrobeFitOnHost, extractMeshIslands, findMirrorIslandId, floodFillByCrease, gateTelemetry, getIslandTopology, getNavigatorModelContext, inferMirrorOriginX, inferWardrobeSlotFromName, isGateStep1Unlocked, isUsdFileName, khrBoxToRapierHalfExtents, layerGarmentOntoCharacterScene, layerWardrobeGarmentIntoHost, listWardrobePieces, loadGlbSceneFromUrl, loadWardrobeBaseIntoHost, makeStarterDomainScene, measureAssemblyCalibration, measureNormalizedSceneCalibration, measureSelection, mirrorCutterId, mirrorTriangles, normalToMinusZQuaternion, normalizeSceneToSi, peelIslandSelection, previewLoopPolyline, refineMeshAlongLoop, registerSand3dStarterFactory, remapIslandIds, removeWardrobePieceFromHost, resetWardrobePiece, resolveVaultCarSelection, resolveWardrobeCatalogUrl, selectFacesByClick, selectFacesByLoop, separateVehicleMeshes, sliceCarWheelCylinders, sliceMeshTriangles, snapCuttersAxles, snapMetersToC12, suggestCarAxles, toggleIslandSelection, tripoWardrobeUrl, tuckInnerBodyUnderClothing, updateWheelCutter, useChopShopController, useGateStore, useImporterWebMcp, wrapSingleMeshWithPaperShellProxy };
|
|
@@ -41,12 +41,15 @@ function deriveChassisGeometryPlan(params) {
|
|
|
41
41
|
const fallbackCenter = new THREE.Vector3(center.x, groundClearance + fallbackSize.y * .5, center.z);
|
|
42
42
|
const measuredSize = hullBox.isEmpty() ? fallbackSize : hullBox.getSize(new THREE.Vector3());
|
|
43
43
|
const measuredCenter = hullBox.isEmpty() ? fallbackCenter : hullBox.getCenter(new THREE.Vector3());
|
|
44
|
+
const rawMinY = hullBox.isEmpty() ? groundClearance : hullBox.min.y;
|
|
45
|
+
const rawMaxY = hullBox.isEmpty() ? groundClearance + fallbackSize.y : hullBox.max.y;
|
|
46
|
+
const safeHullMinY = Math.min(Math.max(rawMinY, maxWheelRadius * 1.15), Math.max(rawMinY, rawMaxY - .28));
|
|
44
47
|
const hx = Math.max(.35, measuredSize.x);
|
|
45
|
-
const hy = Math.max(.24,
|
|
48
|
+
const hy = Math.max(.24, rawMaxY - safeHullMinY);
|
|
46
49
|
const hz = Math.max(.7, measuredSize.z);
|
|
47
50
|
const hullCenter = [
|
|
48
51
|
r4(measuredCenter.x),
|
|
49
|
-
r4(
|
|
52
|
+
r4(safeHullMinY + hy * .5),
|
|
50
53
|
r4(measuredCenter.z)
|
|
51
54
|
];
|
|
52
55
|
const hullSize = [
|
|
@@ -54,9 +57,12 @@ function deriveChassisGeometryPlan(params) {
|
|
|
54
57
|
r4(hy),
|
|
55
58
|
r4(hz)
|
|
56
59
|
];
|
|
60
|
+
const minY = rawMinY;
|
|
61
|
+
const maxSafeComY = Math.max(.22, maxWheelRadius * 1.05);
|
|
57
62
|
let comX = measuredCenter.x;
|
|
58
|
-
let comY =
|
|
63
|
+
let comY = Math.min(minY + measuredSize.y * .34, maxSafeComY);
|
|
59
64
|
let comZ = measuredCenter.z;
|
|
65
|
+
const fullBoxInertia = boxInertia(chassisMass, hx, Math.max(.24, measuredSize.y), hz);
|
|
60
66
|
let inertiaDiagonal;
|
|
61
67
|
if (partBoxes.length >= 2) {
|
|
62
68
|
const totalVol = partBoxes.reduce((s, p) => s + p.vol, 0);
|
|
@@ -68,7 +74,7 @@ function deriveChassisGeometryPlan(params) {
|
|
|
68
74
|
wz += p.center.z * w;
|
|
69
75
|
}
|
|
70
76
|
comX = wx;
|
|
71
|
-
comY = Math.min(wy,
|
|
77
|
+
comY = Math.min(wy, maxSafeComY);
|
|
72
78
|
comZ = wz;
|
|
73
79
|
let ix = 0, iy = 0, iz = 0;
|
|
74
80
|
for (const p of partBoxes) {
|
|
@@ -79,11 +85,11 @@ function deriveChassisGeometryPlan(params) {
|
|
|
79
85
|
iz += m / 12 * (p.size.x * p.size.x + p.size.y * p.size.y) + m * (dx * dx + dy * dy);
|
|
80
86
|
}
|
|
81
87
|
inertiaDiagonal = [
|
|
82
|
-
r4(Math.max(20, ix)),
|
|
83
|
-
r4(Math.max(20, iy)),
|
|
84
|
-
r4(Math.max(15, iz))
|
|
88
|
+
r4(Math.max(20, ix, fullBoxInertia[0] * .85)),
|
|
89
|
+
r4(Math.max(20, iy, fullBoxInertia[1] * .85)),
|
|
90
|
+
r4(Math.max(15, iz, fullBoxInertia[2] * .85))
|
|
85
91
|
];
|
|
86
|
-
} else inertiaDiagonal =
|
|
92
|
+
} else inertiaDiagonal = fullBoxInertia;
|
|
87
93
|
const hullObj = new THREE.Object3D();
|
|
88
94
|
hullObj.name = "Chassis_Hull";
|
|
89
95
|
hullObj.position.set(hullCenter[0], hullCenter[1], hullCenter[2]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"khrCarGeometryMass.js","names":[],"sources":["../../src/importer/khrCarGeometryMass.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { KhrExportNodeSpec } from \"@khr3/core\";\nimport { boxInertia, r4 } from \"./khrCraftPropCompiler.js\";\nimport { isMeshObject } from \"./sceneSiNormalize.js\";\n\nexport interface DerivedChassisPlan {\n readonly chassisMass: number;\n readonly centerOfMass: [number, number, number];\n readonly inertiaDiagonal: [number, number, number];\n readonly inertiaOrientation: [number, number, number, number];\n readonly hullNodeName: \"Chassis_Hull\";\n readonly hullCenter: [number, number, number];\n readonly hullSize: [number, number, number];\n readonly colliderSpec: KhrExportNodeSpec;\n}\n\nexport function deriveChassisGeometryPlan(params: {\n readonly chassis: THREE.Group;\n readonly totalMass: number;\n readonly panelsMassKg: number;\n readonly size: readonly [number, number, number];\n readonly center: THREE.Vector3;\n readonly maxWheelRadius: number;\n}): DerivedChassisPlan {\n const { chassis, totalMass, panelsMassKg, size, center, maxWheelRadius } = params;\n const chassisMass = Math.max(80, totalMass - panelsMassKg);\n\n chassis.updateMatrixWorld(true);\n const invChassis = new THREE.Matrix4().copy(chassis.matrixWorld).invert();\n const relMat = new THREE.Matrix4();\n const v = new THREE.Vector3();\n\n const hullBox = new THREE.Box3();\n const partBoxes: Array<{ box: THREE.Box3; size: THREE.Vector3; center: THREE.Vector3; vol: number }> = [];\n\n chassis.traverse((obj) => {\n if (!isMeshObject(obj) || obj.name.startsWith(\"ArchLiner\")) return;\n const pos = obj.geometry.getAttribute(\"position\");\n if (!pos || pos.count === 0) return;\n relMat.multiplyMatrices(invChassis, obj.matrixWorld);\n const mb = new THREE.Box3();\n for (let i = 0; i < pos.count; i++) {\n v.fromBufferAttribute(pos, i).applyMatrix4(relMat);\n if (Number.isFinite(v.x) && Number.isFinite(v.y) && Number.isFinite(v.z)) {\n mb.expandByPoint(v);\n hullBox.expandByPoint(v);\n }\n }\n if (!mb.isEmpty()) {\n const pSize = mb.getSize(new THREE.Vector3());\n const pCenter = mb.getCenter(new THREE.Vector3());\n const vol = Math.max(1e-4, Math.max(0.02, pSize.x) * Math.max(0.02, pSize.y) * Math.max(0.02, pSize.z));\n partBoxes.push({ box: mb, size: pSize, center: pCenter, vol });\n }\n });\n\n const groundClearance = Math.max(0.08, Math.min(maxWheelRadius * 0.65, size[1] * 0.25));\n const fallbackSize = new THREE.Vector3(\n Math.max(0.4, size[0] * 0.85),\n Math.max(0.32, size[1] - groundClearance),\n Math.max(0.8, size[2] * 0.92),\n );\n const fallbackCenter = new THREE.Vector3(center.x, groundClearance + fallbackSize.y * 0.5, center.z);\n\n const measuredSize = hullBox.isEmpty() ? fallbackSize : hullBox.getSize(new THREE.Vector3());\n const measuredCenter = hullBox.isEmpty() ? fallbackCenter : hullBox.getCenter(new THREE.Vector3());\n const hx = Math.max(0.35, measuredSize.x);\n const hy = Math.max(0.24,
|
|
1
|
+
{"version":3,"file":"khrCarGeometryMass.js","names":[],"sources":["../../src/importer/khrCarGeometryMass.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { KhrExportNodeSpec } from \"@khr3/core\";\nimport { boxInertia, r4 } from \"./khrCraftPropCompiler.js\";\nimport { isMeshObject } from \"./sceneSiNormalize.js\";\n\nexport interface DerivedChassisPlan {\n readonly chassisMass: number;\n readonly centerOfMass: [number, number, number];\n readonly inertiaDiagonal: [number, number, number];\n readonly inertiaOrientation: [number, number, number, number];\n readonly hullNodeName: \"Chassis_Hull\";\n readonly hullCenter: [number, number, number];\n readonly hullSize: [number, number, number];\n readonly colliderSpec: KhrExportNodeSpec;\n}\n\nexport function deriveChassisGeometryPlan(params: {\n readonly chassis: THREE.Group;\n readonly totalMass: number;\n readonly panelsMassKg: number;\n readonly size: readonly [number, number, number];\n readonly center: THREE.Vector3;\n readonly maxWheelRadius: number;\n}): DerivedChassisPlan {\n const { chassis, totalMass, panelsMassKg, size, center, maxWheelRadius } = params;\n const chassisMass = Math.max(80, totalMass - panelsMassKg);\n\n chassis.updateMatrixWorld(true);\n const invChassis = new THREE.Matrix4().copy(chassis.matrixWorld).invert();\n const relMat = new THREE.Matrix4();\n const v = new THREE.Vector3();\n\n const hullBox = new THREE.Box3();\n const partBoxes: Array<{ box: THREE.Box3; size: THREE.Vector3; center: THREE.Vector3; vol: number }> = [];\n\n chassis.traverse((obj) => {\n if (!isMeshObject(obj) || obj.name.startsWith(\"ArchLiner\")) return;\n const pos = obj.geometry.getAttribute(\"position\");\n if (!pos || pos.count === 0) return;\n relMat.multiplyMatrices(invChassis, obj.matrixWorld);\n const mb = new THREE.Box3();\n for (let i = 0; i < pos.count; i++) {\n v.fromBufferAttribute(pos, i).applyMatrix4(relMat);\n if (Number.isFinite(v.x) && Number.isFinite(v.y) && Number.isFinite(v.z)) {\n mb.expandByPoint(v);\n hullBox.expandByPoint(v);\n }\n }\n if (!mb.isEmpty()) {\n const pSize = mb.getSize(new THREE.Vector3());\n const pCenter = mb.getCenter(new THREE.Vector3());\n const vol = Math.max(1e-4, Math.max(0.02, pSize.x) * Math.max(0.02, pSize.y) * Math.max(0.02, pSize.z));\n partBoxes.push({ box: mb, size: pSize, center: pCenter, vol });\n }\n });\n\n const groundClearance = Math.max(0.08, Math.min(maxWheelRadius * 0.65, size[1] * 0.25));\n const fallbackSize = new THREE.Vector3(\n Math.max(0.4, size[0] * 0.85),\n Math.max(0.32, size[1] - groundClearance),\n Math.max(0.8, size[2] * 0.92),\n );\n const fallbackCenter = new THREE.Vector3(center.x, groundClearance + fallbackSize.y * 0.5, center.z);\n\n const measuredSize = hullBox.isEmpty() ? fallbackSize : hullBox.getSize(new THREE.Vector3());\n const measuredCenter = hullBox.isEmpty() ? fallbackCenter : hullBox.getCenter(new THREE.Vector3());\n const rawMinY = hullBox.isEmpty() ? groundClearance : hullBox.min.y;\n const rawMaxY = hullBox.isEmpty() ? groundClearance + fallbackSize.y : hullBox.max.y;\n const safeHullMinY = Math.min(Math.max(rawMinY, maxWheelRadius * 1.15), Math.max(rawMinY, rawMaxY - 0.28));\n const hx = Math.max(0.35, measuredSize.x);\n const hy = Math.max(0.24, rawMaxY - safeHullMinY);\n const hz = Math.max(0.7, measuredSize.z);\n const hullCenter: [number, number, number] = [r4(measuredCenter.x), r4(safeHullMinY + hy * 0.5), r4(measuredCenter.z)];\n const hullSize: [number, number, number] = [r4(hx), r4(hy), r4(hz)];\n\n const minY = rawMinY;\n const maxSafeComY = Math.max(0.22, maxWheelRadius * 1.05);\n let comX = measuredCenter.x;\n let comY = Math.min(minY + measuredSize.y * 0.34, maxSafeComY);\n let comZ = measuredCenter.z;\n const fullBoxInertia = boxInertia(chassisMass, hx, Math.max(0.24, measuredSize.y), hz);\n let inertiaDiagonal: [number, number, number];\n\n if (partBoxes.length >= 2) {\n const totalVol = partBoxes.reduce((s, p) => s + p.vol, 0);\n let wx = 0, wy = 0, wz = 0;\n for (const p of partBoxes) {\n const w = p.vol / totalVol;\n wx += p.center.x * w;\n wy += p.center.y * w;\n wz += p.center.z * w;\n }\n comX = wx;\n comY = Math.min(wy, maxSafeComY);\n comZ = wz;\n let ix = 0, iy = 0, iz = 0;\n for (const p of partBoxes) {\n const m = chassisMass * (p.vol / totalVol);\n const dx = p.center.x - comX, dy = p.center.y - comY, dz = p.center.z - comZ;\n ix += (m / 12) * (p.size.y * p.size.y + p.size.z * p.size.z) + m * (dy * dy + dz * dz);\n iy += (m / 12) * (p.size.x * p.size.x + p.size.z * p.size.z) + m * (dx * dx + dz * dz);\n iz += (m / 12) * (p.size.x * p.size.x + p.size.y * p.size.y) + m * (dx * dx + dy * dy);\n }\n inertiaDiagonal = [\n r4(Math.max(20, ix, fullBoxInertia[0] * 0.85)),\n r4(Math.max(20, iy, fullBoxInertia[1] * 0.85)),\n r4(Math.max(15, iz, fullBoxInertia[2] * 0.85)),\n ];\n } else {\n inertiaDiagonal = fullBoxInertia;\n }\n\n const hullObj = new THREE.Object3D();\n hullObj.name = \"Chassis_Hull\";\n hullObj.position.set(hullCenter[0], hullCenter[1], hullCenter[2]);\n chassis.add(hullObj);\n\n const colliderSpec: KhrExportNodeSpec = {\n nodeName: \"Chassis_Hull\",\n collider: {\n shape: { type: \"box\", size: hullSize },\n friction: 0.38,\n restitution: 0.05,\n },\n extras: { role: \"chassis_hull\" },\n };\n\n return {\n chassisMass,\n centerOfMass: [r4(comX), r4(comY), r4(comZ)],\n inertiaDiagonal,\n inertiaOrientation: [0, 0, 0, 1],\n hullNodeName: \"Chassis_Hull\",\n hullCenter,\n hullSize,\n colliderSpec,\n };\n}\n"],"mappings":";;;;AAgBA,SAAgB,0BAA0B,QAOnB;CACnB,MAAM,EAAE,SAAS,WAAW,cAAc,MAAM,QAAQ,mBAAmB;CAC3E,MAAM,cAAc,KAAK,IAAI,IAAI,YAAY,YAAY;CAEzD,QAAQ,kBAAkB,IAAI;CAC9B,MAAM,aAAa,IAAI,MAAM,QAAQ,CAAC,CAAC,KAAK,QAAQ,WAAW,CAAC,CAAC,OAAO;CACxE,MAAM,SAAS,IAAI,MAAM,QAAQ;CACjC,MAAM,IAAI,IAAI,MAAM,QAAQ;CAE5B,MAAM,UAAU,IAAI,MAAM,KAAK;CAC/B,MAAM,YAAiG,CAAC;CAExG,QAAQ,UAAU,QAAQ;EACtB,IAAI,CAAC,aAAa,GAAG,KAAK,IAAI,KAAK,WAAW,WAAW,GAAG;EAC5D,MAAM,MAAM,IAAI,SAAS,aAAa,UAAU;EAChD,IA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AC;EAC/B,cAAc;EACd;EACA;EACA;CACJ;AACJ"}
|
|
@@ -10,7 +10,7 @@ import { isMeshObject } from "./sceneSiNormalize.js";
|
|
|
10
10
|
import { createFleet12GonWheelGroup } from "./surfacePeel.js";
|
|
11
11
|
import { suggestCarAxles } from "./wheelAxlePairing.js";
|
|
12
12
|
import * as THREE from "three";
|
|
13
|
-
import { ENGINE_TORQUE_CURVES,
|
|
13
|
+
import { ENGINE_TORQUE_CURVES, TIRE_ARCHETYPES, tireGripForSurface } from "@khr3/core/curves";
|
|
14
14
|
// src/importer/khrCarPlanner.ts
|
|
15
15
|
function buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center, totalMass) {
|
|
16
16
|
const [sx, sy, sz] = size;
|
|
@@ -142,8 +142,8 @@ function buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center
|
|
|
142
142
|
},
|
|
143
143
|
extras: { role: "chassis" }
|
|
144
144
|
}, derived.colliderSpec];
|
|
145
|
-
const tire = TIRE_ARCHETYPES.
|
|
146
|
-
const tireGripFactor = tireGripForSurface(tire.muPeakLng, .
|
|
145
|
+
const tire = TIRE_ARCHETYPES.hypercarDry;
|
|
146
|
+
const tireGripFactor = tireGripForSurface(tire.muPeakLng, .85);
|
|
147
147
|
for (const p of panels) {
|
|
148
148
|
const sp = splitPanels.find((s) => s.nodeName === p.nodeName);
|
|
149
149
|
if (!sp) continue;
|
|
@@ -194,34 +194,10 @@ function buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
const cornerMass = totalMass / Math.max(1, wheels.length);
|
|
197
|
-
const [ixx, , izz] = derived.inertiaDiagonal;
|
|
198
|
-
const [comX, , comZ] = derived.centerOfMass;
|
|
199
|
-
const wheelCenters = wheels.map((w) => {
|
|
200
|
-
const obj = exportRoot.getObjectByName(w.nodeName);
|
|
201
|
-
return obj ? [
|
|
202
|
-
obj.position.x,
|
|
203
|
-
obj.position.y,
|
|
204
|
-
obj.position.z
|
|
205
|
-
] : w.fallbackPos ?? [
|
|
206
|
-
0,
|
|
207
|
-
w.radius,
|
|
208
|
-
0
|
|
209
|
-
];
|
|
210
|
-
});
|
|
211
|
-
const sumAbsRx = wheelCenters.reduce((s, c) => s + Math.abs(c[0] - comX), 0);
|
|
212
|
-
const sumAbsRz = wheelCenters.reduce((s, c) => s + Math.abs(c[2] - comZ), 0);
|
|
213
197
|
for (let wi = 0; wi < wheels.length; wi++) {
|
|
214
198
|
const w = wheels[wi];
|
|
215
|
-
const wc = wheelCenters[wi];
|
|
216
|
-
const rx = Math.abs(wc[0] - comX);
|
|
217
|
-
const rz = Math.abs(wc[2] - comZ);
|
|
218
|
-
const mPitch = rz > .001 && sumAbsRz > .001 ? Math.max(ixx, 1) / (rz * sumAbsRz) : Infinity;
|
|
219
|
-
const mRoll = rx > .001 && sumAbsRx > .001 ? Math.max(izz, 1) / (rx * sumAbsRx) : Infinity;
|
|
220
|
-
const effDampMass = Math.sqrt(cornerMass * Math.max(Math.min(cornerMass, 10), Math.min(cornerMass, mPitch, mRoll)));
|
|
221
199
|
const wTravel = r4(Math.max(.18, Math.min(.32, w.radius * .85)));
|
|
222
200
|
const wSag = r4(Math.max(wTravel * .42, Math.min(wTravel * .52, .08)));
|
|
223
|
-
const springK = r4(Math.max(8e3, cornerMass * 9.81 / Math.max(wSag, 1e-4)));
|
|
224
|
-
const dampingC = r4(Math.max(700, 1.3 * Math.sqrt(springK * effDampMass)));
|
|
225
201
|
const maxForce = r4(Math.max(1800, cornerMass * 9.81 * 2.2));
|
|
226
202
|
specs.push({
|
|
227
203
|
nodeName: w.nodeName,
|
|
@@ -230,20 +206,15 @@ function buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center
|
|
|
230
206
|
width: r4(w.width),
|
|
231
207
|
steering: w.steered,
|
|
232
208
|
propulsion: w.driven,
|
|
233
|
-
maxSteeringAngle: w.steered ? .
|
|
209
|
+
maxSteeringAngle: w.steered ? .58 : 0,
|
|
234
210
|
maxForce,
|
|
235
|
-
suspensionTravel: wTravel
|
|
236
|
-
suspensionStiffness: springK,
|
|
237
|
-
suspensionDampingCompression: dampingC,
|
|
238
|
-
suspensionDampingRebound: dampingC
|
|
211
|
+
suspensionTravel: wTravel
|
|
239
212
|
},
|
|
240
213
|
extras: { ecctrlWheel: {
|
|
241
214
|
radius: r4(w.radius),
|
|
242
215
|
width: r4(w.width),
|
|
243
216
|
travel: wTravel,
|
|
244
217
|
sag: wSag,
|
|
245
|
-
springK,
|
|
246
|
-
dampingC,
|
|
247
218
|
steer: w.steered,
|
|
248
219
|
drive: w.driven,
|
|
249
220
|
brake: w.brake,
|
|
@@ -262,19 +233,54 @@ function buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center
|
|
|
262
233
|
coveredSourceNodes,
|
|
263
234
|
sceneExtras: { tune: {
|
|
264
235
|
engineHorsepower: Math.max(25, opts.powerOrThrust || 280),
|
|
265
|
-
engineMaxRPM:
|
|
236
|
+
engineMaxRPM: 6500,
|
|
266
237
|
gearRatios: [
|
|
267
|
-
3.
|
|
268
|
-
2.
|
|
269
|
-
1.
|
|
270
|
-
1,
|
|
271
|
-
.
|
|
238
|
+
3.2,
|
|
239
|
+
2.1,
|
|
240
|
+
1.45,
|
|
241
|
+
1.05,
|
|
242
|
+
.84
|
|
272
243
|
],
|
|
273
|
-
finalDriveRatio: 3.
|
|
244
|
+
finalDriveRatio: 3.55,
|
|
274
245
|
transmissionMode: "auto",
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
246
|
+
steerRate: Math.PI * 2,
|
|
247
|
+
maxSteerAngle: .58,
|
|
248
|
+
reverseTorqueScale: 1,
|
|
249
|
+
reverseRPMScale: .5,
|
|
250
|
+
engineTorqueCurveData: ENGINE_TORQUE_CURVES.w16QuadTurbo,
|
|
251
|
+
steerAngleCurveData: {
|
|
252
|
+
samples: 60,
|
|
253
|
+
points: [
|
|
254
|
+
{
|
|
255
|
+
x: 0,
|
|
256
|
+
y: 1,
|
|
257
|
+
r_out: 0,
|
|
258
|
+
w_out: 1
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
x: .45,
|
|
262
|
+
y: .94,
|
|
263
|
+
r_in: -.1,
|
|
264
|
+
r_out: -.18,
|
|
265
|
+
w_in: 1,
|
|
266
|
+
w_out: 1
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
x: .75,
|
|
270
|
+
y: .82,
|
|
271
|
+
r_in: -.32,
|
|
272
|
+
r_out: -.28,
|
|
273
|
+
w_in: 1,
|
|
274
|
+
w_out: 1
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
x: 1,
|
|
278
|
+
y: .72,
|
|
279
|
+
r_in: -.25,
|
|
280
|
+
w_in: 1
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
}
|
|
278
284
|
} }
|
|
279
285
|
};
|
|
280
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"khrCarPlanner.js","names":[],"sources":["../../src/importer/khrCarPlanner.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { KhrExportNodeSpec } from \"@khr3/core\";\nimport { ENGINE_TORQUE_CURVES, STEER_SPEED_CURVES, TIRE_ARCHETYPES, tireGripForSurface } from \"@khr3/core/curves\";\nimport { deriveChassisGeometryPlan } from \"./khrCarGeometryMass.js\";\nimport { sliceCarWheelCylinders } from \"./cylinderBooleanSlice.js\";\nimport { detectFusedCarWheels } from \"./fusedWheelDetect.js\";\nimport {\n attachPreservedArchLiner,\n buildPanelSpecs,\n collectArchLinerNodes,\n collectCarChassisExcludeSet,\n resolveCarWheels,\n tryExtractPreCoredCar,\n type ResolvedPanelPlan,\n type ResolvedWheelPlan,\n type SubtreeDisambiguateTarget,\n} from \"./khrCarPlanHelpers.js\";\nimport { boxInertia, r4, type KolmoCompileOptions } from \"./khrCraftPropCompiler.js\";\nimport { disambiguateExportSubtrees } from \"./khrNodeNameGuard.js\";\nimport { extractMeshIslands, separateVehicleMeshes, type SeparatedPanelMesh } from \"./meshIslands.js\";\nimport { isMeshObject } from \"./sceneSiNormalize.js\";\nimport { createFleet12GonWheelGroup } from \"./surfaceCutter.js\";\nimport { suggestCarAxles } from \"./wheelAxlePairing.js\";\n\nexport function buildCarExportPlan(\n normalizedScene: THREE.Group,\n exportRoot: THREE.Group,\n opts: KolmoCompileOptions,\n box: THREE.Box3,\n size: readonly [number, number, number],\n center: THREE.Vector3,\n totalMass: number,\n): { specs: KhrExportNodeSpec[]; sceneExtras: Record<string, unknown>; coveredSourceNodes: Set<THREE.Object3D> } {\n const [sx, sy, sz] = size;\n const driveType = opts.driveType ?? \"AWD\";\n let wheels: ResolvedWheelPlan[];\n let wheelZs: number[];\n let panels: ResolvedPanelPlan[] = [];\n let splitPanels: SeparatedPanelMesh[] = [];\n let userSubtrees: SubtreeDisambiguateTarget[] = [];\n const coveredSourceNodes = new Set<THREE.Object3D>();\n const chassis = new THREE.Group();\n chassis.name = \"Chassis\";\n\n const preCored = tryExtractPreCoredCar(normalizedScene, chassis, exportRoot, opts, driveType);\n if (preCored) {\n wheels = preCored.wheels;\n wheelZs = preCored.wheelZs;\n panels = preCored.panels;\n splitPanels = preCored.splitPanels;\n userSubtrees = preCored.userSubtrees;\n for (const n of preCored.coveredSourceNodes) coveredSourceNodes.add(n);\n } else {\n const hasOptsIslands = !!opts.islands && opts.islands.length > 0;\n const islands = hasOptsIslands ? opts.islands! : extractMeshIslands(normalizedScene);\n const linerNodes = collectArchLinerNodes(normalizedScene);\n const linerMeshes = new Set<THREE.Object3D>();\n for (const ln of linerNodes) ln.traverse((o) => { if (isMeshObject(o)) linerMeshes.add(o); });\n const axles = opts.axles ?? suggestCarAxles(linerMeshes.size > 0 ? islands.filter((i) => !linerMeshes.has(i.mesh)) : islands);\n const hasAxleWheels = axles.some((a) => a.left.length > 0 || a.right.length > 0);\n const explicitCutters = opts.wheelCutters && opts.wheelCutters.length > 0 ? opts.wheelCutters : null;\n const useCoring = opts.wheelSource !== \"fleet12\" && (!!explicitCutters || !hasAxleWheels);\n const detectedCutters = useCoring ? (explicitCutters ?? detectFusedCarWheels(normalizedScene, { mirrorX: opts.mirrorX ?? true })) : [];\n\n if (detectedCutters.length >= 2) {\n panels = buildPanelSpecs(islands, opts.partPicks, new Set(axles.flatMap((a) => [...a.left, ...a.right])));\n let sliceSource: THREE.Object3D = normalizedScene;\n if (panels.length > 0) {\n const split = separateVehicleMeshes(\n normalizedScene,\n islands,\n [],\n panels.map((p) => ({ nodeName: p.nodeName, islandIds: p.islandIds, anchor: p.hinge.anchor })),\n );\n splitPanels = split.panels;\n sliceSource = split.chassisGroup;\n }\n const sliced = sliceCarWheelCylinders(sliceSource, detectedCutters, {\n sealArchLiner: opts.sealArchLiner ?? true,\n mirrorX: opts.mirrorX ?? true,\n });\n chassis.add(sliced.chassis);\n if (sliced.liner) chassis.add(sliced.liner);\n exportRoot.add(chassis);\n const fwd = driveType === \"AWD\" || driveType === \"FWD\";\n const rwd = driveType === \"AWD\" || driveType === \"RWD\";\n wheels = sliced.cutters.map((c, i) => {\n const grp = sliced.wheels[i];\n if (grp && grp.children.length > 0) exportRoot.add(grp);\n else {\n const wg = createFleet12GonWheelGroup(c.radius, c.width, `Wheel_${c.id.toUpperCase()}`);\n wg.position.set(c.center[0], c.center[1], c.center[2]);\n exportRoot.add(wg);\n }\n const isFront = c.axle === \"front\";\n return { nodeName: `Wheel_${c.id.toUpperCase()}`, islandIds: [], fallbackPos: c.center, radius: c.radius, width: c.width, steered: isFront, driven: isFront ? fwd : rwd, brake: true };\n });\n wheelZs = sliced.cutters.map((c) => c.center[2]);\n } else {\n wheels = resolveCarWheels(islands, axles, driveType, size);\n panels = buildPanelSpecs(islands, opts.partPicks, new Set(wheels.flatMap((w) => w.islandIds)));\n const split = separateVehicleMeshes(\n normalizedScene,\n islands,\n wheels.filter((w) => w.islandIds.length > 0),\n panels.map((p) => ({ nodeName: p.nodeName, islandIds: p.islandIds, anchor: p.hinge.anchor })),\n normalizedScene,\n collectCarChassisExcludeSet(normalizedScene, linerNodes),\n );\n chassis.add(split.chassisGroup);\n const preservedLiner = attachPreservedArchLiner(linerNodes, chassis, opts.sealArchLiner);\n if (preservedLiner) {\n userSubtrees.push({ obj: preservedLiner, includeRoot: false });\n for (const ln of linerNodes) coveredSourceNodes.add(ln);\n }\n exportRoot.add(chassis);\n splitPanels = split.panels;\n for (const w of wheels) {\n const sep = split.wheels.find((sw) => sw.nodeName === w.nodeName);\n const pos = sep?.center ?? w.fallbackPos ?? [0, w.radius, 0];\n if (opts.wheelSource === \"fleet12\" || !sep) {\n const wg = createFleet12GonWheelGroup(w.radius, w.width, w.nodeName);\n wg.position.set(pos[0], pos[1], pos[2]);\n exportRoot.add(wg);\n } else exportRoot.add(sep.group);\n }\n wheelZs = wheels.map((w) => split.wheels.find((sw) => sw.nodeName === w.nodeName)?.center[2] ?? w.fallbackPos?.[2] ?? 0);\n }\n if (!hasOptsIslands) for (const isl of islands) isl.geometry.dispose();\n }\n\n const maxR = Math.max(...wheels.map((w) => w.radius));\n const panelsMassKg = panels.reduce((sum, p) => sum + p.massKg, 0);\n const derived = deriveChassisGeometryPlan({\n chassis, totalMass, panelsMassKg, size, center, maxWheelRadius: maxR,\n });\n const chassisMass = derived.chassisMass;\n\n const specs: KhrExportNodeSpec[] = [\n {\n nodeName: \"Chassis\",\n motion: {\n isKinematic: false,\n mass: r4(chassisMass),\n centerOfMass: derived.centerOfMass,\n inertiaDiagonal: derived.inertiaDiagonal,\n inertiaOrientation: derived.inertiaOrientation,\n },\n extras: { role: \"chassis\" },\n },\n derived.colliderSpec,\n ];\n\n const tire = TIRE_ARCHETYPES.streetDrift90s;\n const tireGripFactor = tireGripForSurface(tire.muPeakLng, 0.82);\n for (const p of panels) {\n const sp = splitPanels.find((s) => s.nodeName === p.nodeName);\n if (!sp) continue;\n chassis.add(sp.group);\n const relCom: [number, number, number] = [r4(sp.center[0] - sp.anchor[0]), r4(sp.center[1] - sp.anchor[1]), r4(sp.center[2] - sp.anchor[2])];\n const colNode = new THREE.Object3D();\n colNode.name = `${p.nodeName}_Panel`;\n colNode.position.set(relCom[0], relCom[1], relCom[2]);\n sp.group.add(colNode);\n specs.push(\n { nodeName: colNode.name, collider: { shape: { type: \"box\", size: [r4(sp.size[0]), r4(sp.size[1]), r4(sp.size[2])] }, friction: 0.45 } },\n { nodeName: p.nodeName, motion: { isKinematic: false, mass: p.massKg, centerOfMass: relCom, inertiaDiagonal: boxInertia(p.massKg, sp.size[0], sp.size[1], sp.size[2]) }, joint: { connectedNodeName: \"Chassis\", kind: \"revolute\", axis: p.hinge.axis, limits: p.hinge.limits, drive: { mode: \"acceleration\", stiffness: 60, damping: 12, positionTarget: 0 } }, extras: { role: p.role } },\n );\n }\n const nWheels = Math.max(1, wheels.length);\n const cornerMass = totalMass / nWheels;\n const [ixx, , izz] = derived.inertiaDiagonal;\n const [comX, , comZ] = derived.centerOfMass;\n const wheelCenters = wheels.map((w) => {\n const obj = exportRoot.getObjectByName(w.nodeName);\n return obj ? ([obj.position.x, obj.position.y, obj.position.z] as const) : (w.fallbackPos ?? ([0, w.radius, 0] as const));\n });\n const sumAbsRx = wheelCenters.reduce((s, c) => s + Math.abs(c[0] - comX), 0);\n const sumAbsRz = wheelCenters.reduce((s, c) => s + Math.abs(c[2] - comZ), 0);\n for (let wi = 0; wi < wheels.length; wi++) {\n const w = wheels[wi];\n const wc = wheelCenters[wi];\n const rx = Math.abs(wc[0] - comX);\n const rz = Math.abs(wc[2] - comZ);\n const mPitch = rz > 1e-3 && sumAbsRz > 1e-3 ? Math.max(ixx, 1) / (rz * sumAbsRz) : Infinity;\n const mRoll = rx > 1e-3 && sumAbsRx > 1e-3 ? Math.max(izz, 1) / (rx * sumAbsRx) : Infinity;\n const modalMass = Math.max(Math.min(cornerMass, 10), Math.min(cornerMass, mPitch, mRoll));\n const effDampMass = Math.sqrt(cornerMass * modalMass);\n const wTravel = r4(Math.max(0.18, Math.min(0.32, w.radius * 0.85)));\n const wSag = r4(Math.max(wTravel * 0.42, Math.min(wTravel * 0.52, 0.08)));\n const springK = r4(Math.max(8000, (cornerMass * 9.81) / Math.max(wSag, 1e-4)));\n const dampingC = r4(Math.max(700, 2 * 0.65 * Math.sqrt(springK * effDampMass)));\n const maxForce = r4(Math.max(1800, cornerMass * 9.81 * 2.2));\n specs.push({\n nodeName: w.nodeName,\n wheel: {\n radius: r4(w.radius), width: r4(w.width), steering: w.steered, propulsion: w.driven,\n maxSteeringAngle: w.steered ? 0.55 : 0, maxForce, suspensionTravel: wTravel,\n suspensionStiffness: springK, suspensionDampingCompression: dampingC, suspensionDampingRebound: dampingC,\n },\n extras: {\n ecctrlWheel: {\n radius: r4(w.radius), width: r4(w.width), travel: wTravel, sag: wSag,\n springK, dampingC,\n steer: w.steered, drive: w.driven, brake: w.brake, tireGripFactor,\n latFrictionEllipseScale: tire.latFrictionEllipseScale, relaxLngRate: tire.relaxLngRate,\n relaxLatRate: tire.relaxLatRate, lngSlipRatioCurveData: tire.lng, latSlipRatioCurveData: tire.lat,\n },\n },\n });\n }\n disambiguateExportSubtrees(exportRoot, specs, userSubtrees);\n return {\n specs,\n coveredSourceNodes,\n sceneExtras: {\n tune: {\n engineHorsepower: Math.max(25, opts.powerOrThrust || 280), engineMaxRPM: 7000,\n gearRatios: [3.1, 2.05, 1.42, 1, 0.82], finalDriveRatio: 3.58, transmissionMode: \"auto\",\n maxSteerAngle: 0.55, engineTorqueCurveData: ENGINE_TORQUE_CURVES.naScreamer, steerAngleCurveData: STEER_SPEED_CURVES.driftCountersteer,\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,mBACZ,iBACA,YACA,MACA,KACA,MACA,QACA,WAC6G;CAC7G,MAAM,CAAC,IAAI,IAAI,MAAM;CACrB,MAAM,YAAY,KAAK,aAAa;CACpC,IAAI;CAEJ,IAAI,SAA8B,CAAC;CACnC,IAAI,cAAoC,CAAC;CACzC,IAAI,eAA4C,CAAC;CACjD,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AI;GAAG,iBAAiB;GAAM,kBAAkB;GACjF,eAAe;GAAM,uBAAuB,qBAAqB;GAAY,qBAAqB,mBAAmB;EACzH,EACJ;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"khrCarPlanner.js","names":[],"sources":["../../src/importer/khrCarPlanner.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { KhrExportNodeSpec } from \"@khr3/core\";\nimport { ENGINE_TORQUE_CURVES, TIRE_ARCHETYPES, tireGripForSurface } from \"@khr3/core/curves\";\nimport { deriveChassisGeometryPlan } from \"./khrCarGeometryMass.js\";\nimport { sliceCarWheelCylinders } from \"./cylinderBooleanSlice.js\";\nimport { detectFusedCarWheels } from \"./fusedWheelDetect.js\";\nimport {\n attachPreservedArchLiner,\n buildPanelSpecs,\n collectArchLinerNodes,\n collectCarChassisExcludeSet,\n resolveCarWheels,\n tryExtractPreCoredCar,\n type ResolvedPanelPlan,\n type ResolvedWheelPlan,\n type SubtreeDisambiguateTarget,\n} from \"./khrCarPlanHelpers.js\";\nimport { boxInertia, r4, type KolmoCompileOptions } from \"./khrCraftPropCompiler.js\";\nimport { disambiguateExportSubtrees } from \"./khrNodeNameGuard.js\";\nimport { extractMeshIslands, separateVehicleMeshes, type SeparatedPanelMesh } from \"./meshIslands.js\";\nimport { isMeshObject } from \"./sceneSiNormalize.js\";\nimport { createFleet12GonWheelGroup } from \"./surfaceCutter.js\";\nimport { suggestCarAxles } from \"./wheelAxlePairing.js\";\n\nexport function buildCarExportPlan(\n normalizedScene: THREE.Group,\n exportRoot: THREE.Group,\n opts: KolmoCompileOptions,\n box: THREE.Box3,\n size: readonly [number, number, number],\n center: THREE.Vector3,\n totalMass: number,\n): { specs: KhrExportNodeSpec[]; sceneExtras: Record<string, unknown>; coveredSourceNodes: Set<THREE.Object3D> } {\n const [sx, sy, sz] = size;\n const driveType = opts.driveType ?? \"AWD\";\n let wheels: ResolvedWheelPlan[];\n let wheelZs: number[];\n let panels: ResolvedPanelPlan[] = [];\n let splitPanels: SeparatedPanelMesh[] = [];\n let userSubtrees: SubtreeDisambiguateTarget[] = [];\n const coveredSourceNodes = new Set<THREE.Object3D>();\n const chassis = new THREE.Group();\n chassis.name = \"Chassis\";\n\n const preCored = tryExtractPreCoredCar(normalizedScene, chassis, exportRoot, opts, driveType);\n if (preCored) {\n wheels = preCored.wheels;\n wheelZs = preCored.wheelZs;\n panels = preCored.panels;\n splitPanels = preCored.splitPanels;\n userSubtrees = preCored.userSubtrees;\n for (const n of preCored.coveredSourceNodes) coveredSourceNodes.add(n);\n } else {\n const hasOptsIslands = !!opts.islands && opts.islands.length > 0;\n const islands = hasOptsIslands ? opts.islands! : extractMeshIslands(normalizedScene);\n const linerNodes = collectArchLinerNodes(normalizedScene);\n const linerMeshes = new Set<THREE.Object3D>();\n for (const ln of linerNodes) ln.traverse((o) => { if (isMeshObject(o)) linerMeshes.add(o); });\n const axles = opts.axles ?? suggestCarAxles(linerMeshes.size > 0 ? islands.filter((i) => !linerMeshes.has(i.mesh)) : islands);\n const hasAxleWheels = axles.some((a) => a.left.length > 0 || a.right.length > 0);\n const explicitCutters = opts.wheelCutters && opts.wheelCutters.length > 0 ? opts.wheelCutters : null;\n const useCoring = opts.wheelSource !== \"fleet12\" && (!!explicitCutters || !hasAxleWheels);\n const detectedCutters = useCoring ? (explicitCutters ?? detectFusedCarWheels(normalizedScene, { mirrorX: opts.mirrorX ?? true })) : [];\n\n if (detectedCutters.length >= 2) {\n panels = buildPanelSpecs(islands, opts.partPicks, new Set(axles.flatMap((a) => [...a.left, ...a.right])));\n let sliceSource: THREE.Object3D = normalizedScene;\n if (panels.length > 0) {\n const split = separateVehicleMeshes(\n normalizedScene,\n islands,\n [],\n panels.map((p) => ({ nodeName: p.nodeName, islandIds: p.islandIds, anchor: p.hinge.anchor })),\n );\n splitPanels = split.panels;\n sliceSource = split.chassisGroup;\n }\n const sliced = sliceCarWheelCylinders(sliceSource, detectedCutters, {\n sealArchLiner: opts.sealArchLiner ?? true,\n mirrorX: opts.mirrorX ?? true,\n });\n chassis.add(sliced.chassis);\n if (sliced.liner) chassis.add(sliced.liner);\n exportRoot.add(chassis);\n const fwd = driveType === \"AWD\" || driveType === \"FWD\";\n const rwd = driveType === \"AWD\" || driveType === \"RWD\";\n wheels = sliced.cutters.map((c, i) => {\n const grp = sliced.wheels[i];\n if (grp && grp.children.length > 0) exportRoot.add(grp);\n else {\n const wg = createFleet12GonWheelGroup(c.radius, c.width, `Wheel_${c.id.toUpperCase()}`);\n wg.position.set(c.center[0], c.center[1], c.center[2]);\n exportRoot.add(wg);\n }\n const isFront = c.axle === \"front\";\n return { nodeName: `Wheel_${c.id.toUpperCase()}`, islandIds: [], fallbackPos: c.center, radius: c.radius, width: c.width, steered: isFront, driven: isFront ? fwd : rwd, brake: true };\n });\n wheelZs = sliced.cutters.map((c) => c.center[2]);\n } else {\n wheels = resolveCarWheels(islands, axles, driveType, size);\n panels = buildPanelSpecs(islands, opts.partPicks, new Set(wheels.flatMap((w) => w.islandIds)));\n const split = separateVehicleMeshes(\n normalizedScene,\n islands,\n wheels.filter((w) => w.islandIds.length > 0),\n panels.map((p) => ({ nodeName: p.nodeName, islandIds: p.islandIds, anchor: p.hinge.anchor })),\n normalizedScene,\n collectCarChassisExcludeSet(normalizedScene, linerNodes),\n );\n chassis.add(split.chassisGroup);\n const preservedLiner = attachPreservedArchLiner(linerNodes, chassis, opts.sealArchLiner);\n if (preservedLiner) {\n userSubtrees.push({ obj: preservedLiner, includeRoot: false });\n for (const ln of linerNodes) coveredSourceNodes.add(ln);\n }\n exportRoot.add(chassis);\n splitPanels = split.panels;\n for (const w of wheels) {\n const sep = split.wheels.find((sw) => sw.nodeName === w.nodeName);\n const pos = sep?.center ?? w.fallbackPos ?? [0, w.radius, 0];\n if (opts.wheelSource === \"fleet12\" || !sep) {\n const wg = createFleet12GonWheelGroup(w.radius, w.width, w.nodeName);\n wg.position.set(pos[0], pos[1], pos[2]);\n exportRoot.add(wg);\n } else exportRoot.add(sep.group);\n }\n wheelZs = wheels.map((w) => split.wheels.find((sw) => sw.nodeName === w.nodeName)?.center[2] ?? w.fallbackPos?.[2] ?? 0);\n }\n if (!hasOptsIslands) for (const isl of islands) isl.geometry.dispose();\n }\n\n const maxR = Math.max(...wheels.map((w) => w.radius));\n const panelsMassKg = panels.reduce((sum, p) => sum + p.massKg, 0);\n const derived = deriveChassisGeometryPlan({\n chassis, totalMass, panelsMassKg, size, center, maxWheelRadius: maxR,\n });\n const chassisMass = derived.chassisMass;\n\n const specs: KhrExportNodeSpec[] = [\n {\n nodeName: \"Chassis\",\n motion: {\n isKinematic: false,\n mass: r4(chassisMass),\n centerOfMass: derived.centerOfMass,\n inertiaDiagonal: derived.inertiaDiagonal,\n inertiaOrientation: derived.inertiaOrientation,\n },\n extras: { role: \"chassis\" },\n },\n derived.colliderSpec,\n ];\n\n const tire = TIRE_ARCHETYPES.hypercarDry;\n const tireGripFactor = tireGripForSurface(tire.muPeakLng, 0.85);\n for (const p of panels) {\n const sp = splitPanels.find((s) => s.nodeName === p.nodeName);\n if (!sp) continue;\n chassis.add(sp.group);\n const relCom: [number, number, number] = [r4(sp.center[0] - sp.anchor[0]), r4(sp.center[1] - sp.anchor[1]), r4(sp.center[2] - sp.anchor[2])];\n const colNode = new THREE.Object3D();\n colNode.name = `${p.nodeName}_Panel`;\n colNode.position.set(relCom[0], relCom[1], relCom[2]);\n sp.group.add(colNode);\n specs.push(\n { nodeName: colNode.name, collider: { shape: { type: \"box\", size: [r4(sp.size[0]), r4(sp.size[1]), r4(sp.size[2])] }, friction: 0.45 } },\n { nodeName: p.nodeName, motion: { isKinematic: false, mass: p.massKg, centerOfMass: relCom, inertiaDiagonal: boxInertia(p.massKg, sp.size[0], sp.size[1], sp.size[2]) }, joint: { connectedNodeName: \"Chassis\", kind: \"revolute\", axis: p.hinge.axis, limits: p.hinge.limits, drive: { mode: \"acceleration\", stiffness: 60, damping: 12, positionTarget: 0 } }, extras: { role: p.role } },\n );\n }\n const nWheels = Math.max(1, wheels.length);\n const cornerMass = totalMass / nWheels;\n for (let wi = 0; wi < wheels.length; wi++) {\n const w = wheels[wi];\n const wTravel = r4(Math.max(0.18, Math.min(0.32, w.radius * 0.85)));\n const wSag = r4(Math.max(wTravel * 0.42, Math.min(wTravel * 0.52, 0.08)));\n const maxForce = r4(Math.max(1800, cornerMass * 9.81 * 2.2));\n specs.push({\n nodeName: w.nodeName,\n wheel: {\n radius: r4(w.radius), width: r4(w.width), steering: w.steered, propulsion: w.driven,\n maxSteeringAngle: w.steered ? 0.58 : 0, maxForce, suspensionTravel: wTravel,\n },\n extras: {\n ecctrlWheel: {\n radius: r4(w.radius), width: r4(w.width), travel: wTravel, sag: wSag,\n steer: w.steered, drive: w.driven, brake: w.brake, tireGripFactor,\n latFrictionEllipseScale: tire.latFrictionEllipseScale, relaxLngRate: tire.relaxLngRate,\n relaxLatRate: tire.relaxLatRate, lngSlipRatioCurveData: tire.lng, latSlipRatioCurveData: tire.lat,\n },\n },\n });\n }\n disambiguateExportSubtrees(exportRoot, specs, userSubtrees);\n return {\n specs,\n coveredSourceNodes,\n sceneExtras: {\n tune: {\n engineHorsepower: Math.max(25, opts.powerOrThrust || 280), engineMaxRPM: 6500,\n gearRatios: [3.2, 2.1, 1.45, 1.05, 0.84], finalDriveRatio: 3.55, transmissionMode: \"auto\",\n steerRate: Math.PI * 2, maxSteerAngle: 0.58, reverseTorqueScale: 1, reverseRPMScale: 0.5,\n engineTorqueCurveData: ENGINE_TORQUE_CURVES.w16QuadTurbo,\n steerAngleCurveData: {\n samples: 60,\n points: [\n { x: 0, y: 1, r_out: 0, w_out: 1 },\n { x: 0.45, y: 0.94, r_in: -0.1, r_out: -0.18, w_in: 1, w_out: 1 },\n { x: 0.75, y: 0.82, r_in: -0.32, r_out: -0.28, w_in: 1, w_out: 1 },\n { x: 1, y: 0.72, r_in: -0.25, w_in: 1 },\n ],\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,mBAC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yB,KAAK;IAAyB,cAAc,KAAK;IAC1E,cAAc,KAAK;IAAc,uBAAuB,KAAK;IAAK,uBAAuB,KAAK;GAClG,EACJ;EACJ,CAAC;CACL;CACA,2BAA2B,YAAY,OAAO,YAAY;CAC1D,OAAO;EACH;EACA;EACA,aAAa,EACT,MAAM;GACF,kBAAkB,KAAK,IAAI,IAAI,KAAK,iBAAiB,GAAG;GAAG,cAAc;GACzE,YAAY;IAAC;IAAK;IAAK;IAAM;IAAM;GAAI;GAAG,iBAAiB;GAAM,kBAAkB;GACnF,WAAW,KAAK,KAAK;GAAG,eAAe;GAAM,oBAAoB;GAAG,iBAAiB;GACrF,uBAAuB,qBAAqB;GAC5C,qBAAqB;IACjB,SAAS;IACT,QAAQ;KACJ;MAAE,GAAG;MAAG,GAAG;MAAG,OAAO;MAAG,OAAO;KAAE;KACjC;MAAE,GAAG;MAAM,GAAG;MAAM,MAAM;MAAM,OAAO;MAAO,MAAM;MAAG,OAAO;KAAE;KAChE;MAAE,GAAG;MAAM,GAAG;MAAM,MAAM;MAAO,OAAO;MAAO,MAAM;MAAG,OAAO;KAAE;KACjE;MAAE,GAAG;MAAG,GAAG;MAAM,MAAM;MAAO,MAAM;KAAE;IAC1C;GACJ;EACJ,EACJ;CACJ;AACJ"}
|
|
@@ -3,6 +3,7 @@ import type { PaperShellPresetId } from "@khr3/vehicles/paper-shell";
|
|
|
3
3
|
import { buildSurfaceStampPatch } from "./chopShopActions.js";
|
|
4
4
|
import type { CutPartMcpRequest } from "./importerWebMcp.js";
|
|
5
5
|
import type { GateWorldPayload } from "./universalGateBake.js";
|
|
6
|
+
import type { WardrobeActionHost } from "./wardrobeController.js";
|
|
6
7
|
export declare function useChopShopController(onSpawnInWorld?: (asset: GateWorldPayload) => void): {
|
|
7
8
|
st: import("./gateStore.js").GateState;
|
|
8
9
|
assetName: string;
|
|
@@ -65,6 +66,7 @@ export declare function useChopShopController(onSpawnInWorld?: (asset: GateWorld
|
|
|
65
66
|
rootObjRef: import("react").RefObject<THREE.Group<THREE.Object3DEventMap> | null>;
|
|
66
67
|
panelJointsRef: import("react").RefObject<import("@khr3/core/vehicle").KhrVehicleJointsHandle | null>;
|
|
67
68
|
workingScene: THREE.Group<THREE.Object3DEventMap> | null;
|
|
69
|
+
wardrobeHost: WardrobeActionHost;
|
|
68
70
|
assembly: import("@khr3/vehicles/paper-shell").PaperShellAssembly;
|
|
69
71
|
setProxyAssembly: import("react").Dispatch<import("react").SetStateAction<import("@khr3/vehicles/paper-shell").PaperShellAssembly | null>>;
|
|
70
72
|
islands: import("./meshIslands.js").MeshIsland[];
|