@pinkaphant/kolmo 0.1.2 → 0.2.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/LICENSE +21 -0
- package/README.md +16 -14
- package/bin/kolmo.mjs +22 -54
- package/dist/body/HeldItem.js +171 -0
- package/dist/body/KhrBody.js +171 -0
- package/dist/body/bodySi.d.ts +0 -11
- package/dist/body/bodySi.js +52 -0
- package/dist/body/index.d.ts +1 -1
- package/dist/body/index.js +4 -1
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +12 -3
- package/dist/engine/kolmoActor.d.ts +11 -4
- package/dist/engine/kolmoActor.js +197 -0
- package/dist/engine/kolmoInput.d.ts +17 -0
- package/dist/engine/kolmoInput.js +78 -0
- package/dist/engine/kolmoIsland.d.ts +3 -1
- package/dist/engine/kolmoIsland.js +311 -0
- package/dist/engine/kolmoLongDrive.js +223 -0
- package/dist/engine/kolmoRigs.js +59 -0
- package/dist/engine/kolmoStore.d.ts +53 -27
- package/dist/engine/kolmoStore.js +211 -0
- package/dist/engine/kolmoSurface.d.ts +1 -1
- package/dist/engine/kolmoSurface.js +182 -0
- package/dist/engine/kolmoVehicle.d.ts +3 -1
- package/dist/engine/kolmoVehicle.js +250 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
- package/dist/engine/kolmoVehicleDriver.js +29 -0
- package/dist/engine/kolmoWorld.d.ts +7 -15
- package/dist/engine/kolmoWorld.js +139 -0
- package/dist/engine/longDriveKit.d.ts +4 -2
- package/dist/engine/longDriveKit.js +254 -0
- package/dist/engine/mainlandMacroCell.d.ts +3 -7
- package/dist/engine/mainlandMacroCell.js +247 -0
- package/dist/engine/shiftedFixedBody.d.ts +13 -0
- package/dist/engine/shiftedFixedBody.js +64 -0
- package/dist/importer/ChopShopPanel.js +465 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
- package/dist/importer/DomainWorkshopPanel.js +385 -0
- package/dist/importer/GateHudBar.js +312 -0
- package/dist/importer/GlbImportGate.js +250 -0
- package/dist/importer/ImperativeVehicleRig.js +336 -0
- package/dist/importer/ImporterPlinthUikitTags.js +112 -0
- package/dist/importer/Step1CalibrationPlinth.js +275 -0
- package/dist/importer/Step2UniversalPad.js +244 -0
- package/dist/importer/VfxEmitterPool.js +91 -0
- package/dist/importer/chopShopActions.d.ts +22 -2
- package/dist/importer/chopShopActions.js +232 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +92 -0
- package/dist/importer/glbNormalizer.js +133 -0
- package/dist/importer/importerWebMcp.d.ts +17 -6
- package/dist/importer/importerWebMcp.js +343 -0
- package/dist/importer/index.js +22 -3
- package/dist/importer/khrCompiler.d.ts +1 -1
- package/dist/importer/khrCompiler.js +434 -0
- package/dist/importer/launcherBake.js +51 -0
- package/dist/importer/meshIslands.d.ts +1 -1
- package/dist/importer/meshIslands.js +301 -0
- package/dist/importer/surfaceCutter.js +254 -0
- package/dist/importer/surfaceTopology.js +183 -0
- package/dist/importer/universalGateBake.js +162 -0
- package/dist/importer/usdToGlb.js +294 -0
- package/dist/importer/useChopShopController.d.ts +11 -2
- package/dist/importer/useChopShopController.js +364 -0
- package/dist/importer/vehiclePanelAnim.js +214 -0
- package/dist/importer/wheelAxlePairing.d.ts +1 -2
- package/dist/importer/wheelAxlePairing.js +102 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -13
- package/dist/junk/DestructibleTarget.js +154 -0
- package/dist/junk/KolmoJunk.js +65 -0
- package/dist/junk/ShardPieces.d.ts +6 -4
- package/dist/junk/ShardPieces.js +74 -0
- package/dist/junk/TargetDecals.js +51 -0
- package/dist/junk/bvhShatter.js +55 -0
- package/dist/junk/bvhTriCollector.js +78 -0
- package/dist/junk/index.js +11 -1
- package/dist/junk/junkGeometry.js +69 -0
- package/dist/junk/junkImportSanitize.js +54 -0
- package/dist/junk/junkImporter.js +95 -0
- package/dist/junk/junkLabelCanvas.js +67 -0
- package/dist/junk/junkLabels.js +35 -0
- package/dist/junk/targetHelpers.js +103 -0
- package/dist/junk/targetHitLogic.js +128 -0
- package/dist/junk/useTargetAssets.js +102 -0
- package/dist/physics/index.d.ts +26 -0
- package/dist/physics/index.js +84 -0
- package/dist/schema/kolmoSchema.d.ts +2 -1
- package/dist/schema/kolmoSchema.js +184 -0
- package/dist/shaders/celestialBackdrop.d.ts +1 -1
- package/dist/shaders/celestialBackdrop.js +344 -0
- package/dist/shaders/index.d.ts +0 -1
- package/dist/shaders/index.js +9 -1
- package/dist/shaders/plumeAndSparkle.js +271 -0
- package/dist/shaders/ps2GlslShared.d.ts +1 -1
- package/dist/shaders/ps2GlslShared.js +3 -0
- package/dist/shaders/ps2MaterialsTSL.js +65 -0
- package/dist/shaders/ps2MaterialsWebGL.js +40 -0
- package/dist/shaders/ps2RoadWebGL.js +101 -0
- package/dist/shaders/ps2TerrainWebGL.js +54 -0
- package/dist/shaders/ps2Textures.js +224 -0
- package/dist/shaders/retroPalettes.js +188 -0
- package/dist/shaders/retroShader.d.ts +31 -3
- package/dist/shaders/retroShader.js +249 -0
- package/dist/shaders/tsl.d.ts +1 -0
- package/dist/shaders/tsl.js +1 -0
- package/dist/vite/index.d.ts +15 -0
- package/dist/vite/index.js +90 -0
- package/dist/world/frontage.js +32 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +11 -3
- package/dist/world/infiniteWorld2D.js +244 -0
- package/dist/world/island.js +201 -0
- package/dist/world/macroCellSchema.js +27 -0
- package/dist/world/macroKnightAStar.js +171 -0
- package/dist/world/random.js +33 -0
- package/dist/world/road.js +136 -0
- package/dist/world/roadRibbon.d.ts +6 -6
- package/dist/world/roadRibbon.js +161 -0
- package/dist/world/terrain.js +87 -0
- package/dist/world/worldTypes.js +111 -0
- package/package.json +32 -18
- package/dist/body-B7FTf67o.js +0 -362
- package/dist/engine-BeKvBM8d.js +0 -1745
- package/dist/importer-B2-S-N_e.js +0 -5113
- package/dist/junk-B4bC1zAl.js +0 -1049
- package/dist/kolmoSurface-DTnrFXH0.js +0 -558
- package/dist/shaders-GS71Ek1A.js +0 -1383
- package/dist/world-PRWPYrlx.js +0 -947
- package/dist/worldTypes-Z0KfdCd0.js +0 -226
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { inferKolmoSocketRole as e } from "../schema/kolmoSchema.js";
|
|
2
|
+
import { normalToMinusZQuaternion as t } from "./vehiclePanelAnim.js";
|
|
3
|
+
import { toggleIslandSelection as n } from "./wheelAxlePairing.js";
|
|
4
|
+
import { convertUsdToGlb as r, isUsdFileName as i } from "./usdToGlb.js";
|
|
5
|
+
import { extractMeshIslands as a } from "./meshIslands.js";
|
|
6
|
+
import { peelIslandSelection as o, refineMeshAlongLoop as s, remapIslandIds as c, selectFacesByClick as l, selectFacesByLoop as u } from "./surfaceCutter.js";
|
|
7
|
+
import * as d from "three";
|
|
8
|
+
import { GLTFLoader as f } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
9
|
+
import { createAssetVault as p, normalizeVaultKey as m } from "@khr3/assets";
|
|
10
|
+
// src/importer/chopShopActions.ts
|
|
11
|
+
function h(e) {
|
|
12
|
+
let t = e.islands.find((t) => t.id === e.loopDots.islandId);
|
|
13
|
+
if (!t) throw Error("Loop island no longer exists.");
|
|
14
|
+
let n, r;
|
|
15
|
+
if (e.splitCoarse) {
|
|
16
|
+
let i = t.mesh, o = i.geometry;
|
|
17
|
+
i.geometry = s(o, e.loopDots.points).geometry;
|
|
18
|
+
let l = a(e.workingScene), u = c(e.islands, l);
|
|
19
|
+
n = () => {
|
|
20
|
+
i.geometry = o;
|
|
21
|
+
}, r = e.axles.map((e) => ({
|
|
22
|
+
left: e.left.flatMap((e) => u.get(e) ?? []),
|
|
23
|
+
right: e.right.flatMap((e) => u.get(e) ?? []),
|
|
24
|
+
steered: e.steered,
|
|
25
|
+
driven: e.driven,
|
|
26
|
+
brake: e.brake
|
|
27
|
+
}));
|
|
28
|
+
let d = e.loopDots.points[0];
|
|
29
|
+
t = l.find((e) => e.mesh === i && d.every((t, n) => t >= e.min[n] - .01 && t <= e.max[n] + .01)) ?? l[0];
|
|
30
|
+
for (let e of l) e !== t && e.geometry.dispose();
|
|
31
|
+
if (!t) throw Error("Refined surface lost seam anchor.");
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
selection: u(t, e.loopDots.points, {
|
|
35
|
+
mirrorX: e.mirrorX,
|
|
36
|
+
exact: e.splitCoarse
|
|
37
|
+
}),
|
|
38
|
+
refinedUndo: n,
|
|
39
|
+
nextAxles: r
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function g(e) {
|
|
43
|
+
let t = e.islands.find((t) => t.id === e.faceSelection.islandId);
|
|
44
|
+
if (!t) throw Error("Selected surface island no longer exists.");
|
|
45
|
+
let { mintedMeshes: r, undo: i } = o(t, e.faceSelection, e.cutName), s = a(e.workingScene), l = c(e.islands, s), u = (e) => e.flatMap((e) => l.get(e) ?? []), d = e.prevAxles.map((e) => ({
|
|
46
|
+
...e,
|
|
47
|
+
left: u(e.left),
|
|
48
|
+
right: u(e.right)
|
|
49
|
+
})).filter((e) => e.left.length > 0 || e.right.length > 0), f = {};
|
|
50
|
+
for (let [t, n] of Object.entries(e.prevPicks)) {
|
|
51
|
+
let e = l.get(Number(t));
|
|
52
|
+
e != null && (f[e] = n);
|
|
53
|
+
}
|
|
54
|
+
let p = new Set(r), m = s.filter((e) => p.has(e.mesh)).map((e) => e.id), h, g = !1;
|
|
55
|
+
if (e.activeRole === "wheel") {
|
|
56
|
+
for (let t of m) d.some((e) => e.left.includes(t) || e.right.includes(t)) || (d = n(s, d, t, e.mode));
|
|
57
|
+
h = `Peeled ${m.length} wheel mesh(es) and paired axle!`;
|
|
58
|
+
} else {
|
|
59
|
+
for (let t of m) f[t] = e.activeRole;
|
|
60
|
+
g = !0, h = `Peeled ${e.faceSelection.triangles.length + e.faceSelection.mirrored.length} faces → hinged ${e.activeRole.toUpperCase()}!`;
|
|
61
|
+
}
|
|
62
|
+
for (let e of s) e.geometry.dispose();
|
|
63
|
+
return {
|
|
64
|
+
nextAxles: d,
|
|
65
|
+
nextPicks: f,
|
|
66
|
+
undo: i,
|
|
67
|
+
status: h,
|
|
68
|
+
bumpHinge: g
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function _(n, r, i) {
|
|
72
|
+
if (r === "none" || n.delta > 5) return null;
|
|
73
|
+
n.stopPropagation();
|
|
74
|
+
let a = n.face ? n.face.normal.clone().transformDirection(n.object.matrixWorld).normalize() : new d.Vector3(0, 1, 0), o = n.point.clone().addScaledVector(a, .015), s = [
|
|
75
|
+
Number(o.x.toFixed(4)),
|
|
76
|
+
Number(o.y.toFixed(4)),
|
|
77
|
+
Number(o.z.toFixed(4))
|
|
78
|
+
], c = t(a), l = `${r}_${i}`;
|
|
79
|
+
if (r === "plume") return {
|
|
80
|
+
nodeName: `Kolmo_${l}`,
|
|
81
|
+
translation: s,
|
|
82
|
+
rotation: c,
|
|
83
|
+
extension: {
|
|
84
|
+
kind: "plume",
|
|
85
|
+
drive: "boost",
|
|
86
|
+
size: 1
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
if (r === "sparkle") return {
|
|
90
|
+
nodeName: `Kolmo_${l}`,
|
|
91
|
+
translation: s,
|
|
92
|
+
rotation: c,
|
|
93
|
+
extension: {
|
|
94
|
+
kind: "sparkle",
|
|
95
|
+
drive: "throttle",
|
|
96
|
+
size: 1
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
if (r === "brake_flare") return {
|
|
100
|
+
nodeName: `Kolmo_${l}`,
|
|
101
|
+
translation: s,
|
|
102
|
+
rotation: c,
|
|
103
|
+
extension: {
|
|
104
|
+
kind: "flare",
|
|
105
|
+
drive: "brake",
|
|
106
|
+
color: [
|
|
107
|
+
1,
|
|
108
|
+
.14,
|
|
109
|
+
.08
|
|
110
|
+
],
|
|
111
|
+
size: .85
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
if (r === "headlight") return {
|
|
115
|
+
nodeName: `Kolmo_${l}`,
|
|
116
|
+
translation: s,
|
|
117
|
+
rotation: c,
|
|
118
|
+
extension: {
|
|
119
|
+
kind: "flare",
|
|
120
|
+
drive: "headlight",
|
|
121
|
+
color: [
|
|
122
|
+
1,
|
|
123
|
+
.96,
|
|
124
|
+
.84
|
|
125
|
+
],
|
|
126
|
+
size: .75
|
|
127
|
+
},
|
|
128
|
+
spotLight: {
|
|
129
|
+
color: [
|
|
130
|
+
1,
|
|
131
|
+
.96,
|
|
132
|
+
.88
|
|
133
|
+
],
|
|
134
|
+
intensity: 18,
|
|
135
|
+
range: 42
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
let u = `Socket_${l}`;
|
|
139
|
+
return {
|
|
140
|
+
nodeName: u,
|
|
141
|
+
translation: s,
|
|
142
|
+
rotation: c,
|
|
143
|
+
extension: { socket: e(u, r) }
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async function v(e) {
|
|
147
|
+
let t = await e.arrayBuffer(), n = e.name.replace(/\.[^.]+$/, "") || "ImportedCar";
|
|
148
|
+
if (i(e.name)) {
|
|
149
|
+
let e = await r(t);
|
|
150
|
+
return {
|
|
151
|
+
baseName: n,
|
|
152
|
+
scene: e.scene,
|
|
153
|
+
usdInfo: `USD · ${e.specs.length} node(s)`
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
baseName: n,
|
|
158
|
+
scene: await new Promise((e, n) => new f().parse(t, "", (t) => e(t.scene), n)),
|
|
159
|
+
usdInfo: null
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
async function y(e, t, n, r, i) {
|
|
163
|
+
let a = p(i), o = t.toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "asset", s = m(`${e.replace(/^\/+|\/+$/g, "")}/${o}.glb`), c = r.trim(), l = { "Content-Type": "model/gltf-binary" };
|
|
164
|
+
c && (l.Authorization = `Bearer ${c}`);
|
|
165
|
+
let u = await fetch(`${a.baseUrl}/admin/assets/${s}`, {
|
|
166
|
+
method: "PUT",
|
|
167
|
+
headers: l,
|
|
168
|
+
credentials: "include",
|
|
169
|
+
body: n
|
|
170
|
+
});
|
|
171
|
+
if (u.status === 404 && (u = await a.upload(s, n, c || void 0)), !u.ok) throw Error(`Vault upload rejected (${u.status} ${u.statusText || "Unauthorized"})`);
|
|
172
|
+
return {
|
|
173
|
+
key: s,
|
|
174
|
+
url: a.url(s)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function b(e) {
|
|
178
|
+
let { req: t, workingScene: n, islands: r, creaseDeg: i, mirrorX: a, onPeel: o, onBucket: s } = e;
|
|
179
|
+
if (!n || r.length === 0) return {
|
|
180
|
+
ok: !1,
|
|
181
|
+
status: "No mesh islands available to cut."
|
|
182
|
+
};
|
|
183
|
+
let c = r.reduce((e, t) => t.triangleIndices.length > e.triangleIndices.length ? t : e, r[0]), d = t.islandId === void 0 ? c : r.find((e) => e.id === t.islandId);
|
|
184
|
+
if (!d) return {
|
|
185
|
+
ok: !1,
|
|
186
|
+
status: `Island ${t.islandId} not found.`
|
|
187
|
+
};
|
|
188
|
+
try {
|
|
189
|
+
if (t.loopPoints && t.loopPoints.length >= 3) {
|
|
190
|
+
let e = o(u(d, t.loopPoints, {
|
|
191
|
+
mirrorX: t.mirrorX ?? a,
|
|
192
|
+
exact: !1
|
|
193
|
+
}), t.role);
|
|
194
|
+
return e ? {
|
|
195
|
+
ok: !0,
|
|
196
|
+
status: e.status
|
|
197
|
+
} : {
|
|
198
|
+
ok: !1,
|
|
199
|
+
status: "Loop enclosed zero faces."
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if (t.faceIndex !== void 0) {
|
|
203
|
+
let e = o(l(d, t.faceIndex, "crease", {
|
|
204
|
+
creaseDeg: t.creaseDeg ?? i,
|
|
205
|
+
mirrorX: t.mirrorX ?? a,
|
|
206
|
+
current: null,
|
|
207
|
+
remove: !1
|
|
208
|
+
}), t.role);
|
|
209
|
+
return e ? {
|
|
210
|
+
ok: !0,
|
|
211
|
+
status: e.status
|
|
212
|
+
} : {
|
|
213
|
+
ok: !1,
|
|
214
|
+
status: "Face selection empty."
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return s(d.id, t.role), {
|
|
218
|
+
ok: !0,
|
|
219
|
+
status: `Tagged island ${d.id} as ${t.role}.`
|
|
220
|
+
};
|
|
221
|
+
} catch (e) {
|
|
222
|
+
return {
|
|
223
|
+
ok: !1,
|
|
224
|
+
status: e instanceof Error ? e.message : "Cut failed."
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function x(e, t) {
|
|
229
|
+
let n = URL.createObjectURL(new Blob([t], { type: "model/gltf-binary" })), r = document.createElement("a");
|
|
230
|
+
r.href = n, r.download = `${e}_khr3.glb`, r.click(), URL.revokeObjectURL(n);
|
|
231
|
+
}
|
|
232
|
+
export { _ as buildSurfaceStampPatch, x as downloadBlobGlb, h as executeCloseLoop, b as executeCutPartMcp, g as executePeelTransaction, v as parseIngestedAssetFile, y as putAuthenticatedVaultGlb };
|
|
@@ -2,7 +2,7 @@ import { type PaperShellPresetId, type ShadingMode, type ShellPartId } from "@kh
|
|
|
2
2
|
import type { CarDriveMode } from "./khrCompiler.js";
|
|
3
3
|
export type GateStep = 1 | 2;
|
|
4
4
|
export type GateDomain = "vehicle" | "c12" | "launcher" | "person" | "prop" | "junk";
|
|
5
|
-
export type VehicleSubArchetype = "car" | "
|
|
5
|
+
export type VehicleSubArchetype = "car" | "starcraft";
|
|
6
6
|
export type EraMode = "dreamcast-60" | "psx-1-3";
|
|
7
7
|
export type FreqBucket = "TRUCK" | "STREET" | "SPORT";
|
|
8
8
|
export type DampBucket = "PLUSH" | "BALANCED" | "STIFF";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { create as e } from "zustand";
|
|
2
|
+
import { ALL_PANELS_ATTACHED_MASK as t } from "@khr3/vehicles/paper-shell";
|
|
3
|
+
// src/importer/gateStore.ts
|
|
4
|
+
var n = Object.freeze({
|
|
5
|
+
TRUCK: 1.4,
|
|
6
|
+
STREET: 1.9,
|
|
7
|
+
SPORT: 2.8
|
|
8
|
+
}), r = Object.freeze({
|
|
9
|
+
PLUSH: .65,
|
|
10
|
+
BALANCED: .75,
|
|
11
|
+
STIFF: .85
|
|
12
|
+
}), i = {
|
|
13
|
+
massKg: 780,
|
|
14
|
+
com: [
|
|
15
|
+
0,
|
|
16
|
+
.42,
|
|
17
|
+
.08
|
|
18
|
+
],
|
|
19
|
+
frontSplit: .53,
|
|
20
|
+
cornerK: [28500, 26200],
|
|
21
|
+
speedKmh: 0,
|
|
22
|
+
rpm: 850,
|
|
23
|
+
sparkBurst: null,
|
|
24
|
+
massDirty: !0
|
|
25
|
+
};
|
|
26
|
+
function a(e, t, n, r) {
|
|
27
|
+
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;
|
|
28
|
+
if (!s || !c) return !1;
|
|
29
|
+
if (t === "c12") return e.c12Aligned;
|
|
30
|
+
if (t === "vehicle" && (r || n === "car")) {
|
|
31
|
+
let t = e.wheelbase >= 1.2 && e.wheelbase <= 5.6, n = e.wheelRadii.every((e) => e >= .16 && e <= .65);
|
|
32
|
+
return t && n;
|
|
33
|
+
}
|
|
34
|
+
return !0;
|
|
35
|
+
}
|
|
36
|
+
var o = e((e) => ({
|
|
37
|
+
step: 1,
|
|
38
|
+
domain: "vehicle",
|
|
39
|
+
vehicleArchetype: "car",
|
|
40
|
+
usePaperShellProxy: !1,
|
|
41
|
+
presetId: "coupe_86",
|
|
42
|
+
shadingMode: "psx-flat",
|
|
43
|
+
eraMode: "dreamcast-60",
|
|
44
|
+
freqBucket: "STREET",
|
|
45
|
+
dampBucket: "BALANCED",
|
|
46
|
+
wrenchMode: "UNLATCH_200",
|
|
47
|
+
driveType: "AWD",
|
|
48
|
+
staticProp: !1,
|
|
49
|
+
massKg: 1380,
|
|
50
|
+
powerOrThrust: 240,
|
|
51
|
+
attachedMask: t,
|
|
52
|
+
unlatchedMask: 0,
|
|
53
|
+
fuelLiters: 42,
|
|
54
|
+
dropTrigger: 0,
|
|
55
|
+
chaseCam: !0,
|
|
56
|
+
detachedDebris: [],
|
|
57
|
+
calibration: {
|
|
58
|
+
wheelbase: 2.4,
|
|
59
|
+
trackWidth: 1.36,
|
|
60
|
+
wheelRadii: [
|
|
61
|
+
.31,
|
|
62
|
+
.31,
|
|
63
|
+
.31,
|
|
64
|
+
.31
|
|
65
|
+
],
|
|
66
|
+
minY: 0,
|
|
67
|
+
aabbSize: [
|
|
68
|
+
1.62,
|
|
69
|
+
1.28,
|
|
70
|
+
4.18
|
|
71
|
+
],
|
|
72
|
+
c12Ticks: [
|
|
73
|
+
19,
|
|
74
|
+
15,
|
|
75
|
+
50
|
|
76
|
+
],
|
|
77
|
+
c12Aligned: !1,
|
|
78
|
+
detectedAnchors: [],
|
|
79
|
+
isSingleMeshProxy: !1
|
|
80
|
+
},
|
|
81
|
+
setField: (t, n) => e({ [t]: n }),
|
|
82
|
+
setCalibration: (t) => e({ calibration: t }),
|
|
83
|
+
triggerDrop: () => e((e) => ({ dropTrigger: e.dropTrigger + 1 })),
|
|
84
|
+
resetAllPanels: () => {
|
|
85
|
+
i.massDirty = !0, e({
|
|
86
|
+
attachedMask: t,
|
|
87
|
+
unlatchedMask: 0,
|
|
88
|
+
detachedDebris: []
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
export { r as DAMP_ZETA, n as FREQ_HZ, i as gateTelemetry, a as isGateStep1Unlocked, o as useGateStore };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useGateStore as e } from "./gateStore.js";
|
|
2
|
+
import * as t from "three";
|
|
3
|
+
import { buildPaperShellAssembly as n } from "@khr3/vehicles/paper-shell";
|
|
4
|
+
// src/importer/glbNormalizer.ts
|
|
5
|
+
var r = 1 / 12, i = Object.freeze([
|
|
6
|
+
"IK_Palm_Primary",
|
|
7
|
+
"IK_Index_Trigger",
|
|
8
|
+
"IK_Thumb_Safety",
|
|
9
|
+
"IK_Palm_Forend",
|
|
10
|
+
"Socket_Muzzle",
|
|
11
|
+
"Socket_Eject",
|
|
12
|
+
"Socket_HitStart",
|
|
13
|
+
"Socket_HitEnd",
|
|
14
|
+
"Socket_Tip",
|
|
15
|
+
"Socket_Holster",
|
|
16
|
+
"Socket_Seat",
|
|
17
|
+
"Socket_Optic"
|
|
18
|
+
]), a = new t.Box3(), o = new t.Vector3();
|
|
19
|
+
function s(e) {
|
|
20
|
+
return [
|
|
21
|
+
e[0] * .5,
|
|
22
|
+
e[1] * .5,
|
|
23
|
+
e[2] * .5
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
function c(e) {
|
|
27
|
+
return Number((Math.max(1, Math.round(e * 12)) / 12).toFixed(6));
|
|
28
|
+
}
|
|
29
|
+
function l(e) {
|
|
30
|
+
let t = [
|
|
31
|
+
Math.round(e[0] * 12),
|
|
32
|
+
Math.round(e[1] * 12),
|
|
33
|
+
Math.round(e[2] * 12)
|
|
34
|
+
];
|
|
35
|
+
return {
|
|
36
|
+
c12Ticks: t,
|
|
37
|
+
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
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function u(e) {
|
|
41
|
+
if (!e) return [];
|
|
42
|
+
let t = /* @__PURE__ */ new Set();
|
|
43
|
+
return e.traverse((e) => {
|
|
44
|
+
e.name && (i.includes(e.name) || e.name.startsWith("IK_") || e.name.startsWith("Socket_") || e.name.startsWith("Kolmo_")) && t.add(e.name);
|
|
45
|
+
}), [...t];
|
|
46
|
+
}
|
|
47
|
+
function d(e, t) {
|
|
48
|
+
return e === "c12" ? {
|
|
49
|
+
len: 3,
|
|
50
|
+
massKg: 0,
|
|
51
|
+
power: 0
|
|
52
|
+
} : e === "person" ? {
|
|
53
|
+
len: 1.75,
|
|
54
|
+
massKg: 72,
|
|
55
|
+
power: 0
|
|
56
|
+
} : e === "launcher" ? {
|
|
57
|
+
len: .92,
|
|
58
|
+
massKg: 4.2,
|
|
59
|
+
power: 120
|
|
60
|
+
} : e === "junk" ? {
|
|
61
|
+
len: .85,
|
|
62
|
+
massKg: 18,
|
|
63
|
+
power: 0
|
|
64
|
+
} : e === "prop" ? {
|
|
65
|
+
len: 1.5,
|
|
66
|
+
massKg: 85,
|
|
67
|
+
power: 0
|
|
68
|
+
} : t === "starcraft" ? {
|
|
69
|
+
len: 7.2,
|
|
70
|
+
massKg: 680,
|
|
71
|
+
power: 4500
|
|
72
|
+
} : {
|
|
73
|
+
len: 4.35,
|
|
74
|
+
massKg: 1380,
|
|
75
|
+
power: 260
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function f(t, n = 1, r = 0, i = !1, a = null) {
|
|
79
|
+
let o = t.lattice.preset, s = o.wheelbase * n, c = o.trackWidth * n, d = Number((o.wheelRadius * n).toFixed(3)), f = (t.lattice.rings[t.lattice.rings.length - 1].z - t.lattice.rings[0].z) * n, p = [
|
|
80
|
+
Number((o.halfWidth * 2 * n).toFixed(3)),
|
|
81
|
+
Number((o.roofY * n).toFixed(3)),
|
|
82
|
+
Number(f.toFixed(3))
|
|
83
|
+
], { c12Ticks: m, c12Aligned: h } = l(p), g = {
|
|
84
|
+
wheelbase: Number(s.toFixed(3)),
|
|
85
|
+
trackWidth: Number(c.toFixed(3)),
|
|
86
|
+
wheelRadii: [
|
|
87
|
+
d,
|
|
88
|
+
d,
|
|
89
|
+
d,
|
|
90
|
+
d
|
|
91
|
+
],
|
|
92
|
+
minY: Number(r.toFixed(4)),
|
|
93
|
+
aabbSize: p,
|
|
94
|
+
c12Ticks: m,
|
|
95
|
+
c12Aligned: h,
|
|
96
|
+
detectedAnchors: u(a),
|
|
97
|
+
isSingleMeshProxy: i
|
|
98
|
+
};
|
|
99
|
+
return e.getState().setCalibration(g), g;
|
|
100
|
+
}
|
|
101
|
+
function p(t, n = 0) {
|
|
102
|
+
t.updateMatrixWorld(!0), a.setFromObject(t), a.isEmpty() ? o.set(1, 1, 1) : a.getSize(o);
|
|
103
|
+
let r = [
|
|
104
|
+
Number(o.x.toFixed(3)),
|
|
105
|
+
Number(o.y.toFixed(3)),
|
|
106
|
+
Number(o.z.toFixed(3))
|
|
107
|
+
], i = Number(Math.max(1.25, o.z * .62).toFixed(3)), s = Number(Math.max(.4, o.x * .82).toFixed(3)), c = Number(Math.max(.2, Math.min(.45, o.y * .24)).toFixed(3)), { c12Ticks: d, c12Aligned: f } = l(r), p = {
|
|
108
|
+
wheelbase: i,
|
|
109
|
+
trackWidth: s,
|
|
110
|
+
wheelRadii: [
|
|
111
|
+
c,
|
|
112
|
+
c,
|
|
113
|
+
c,
|
|
114
|
+
c
|
|
115
|
+
],
|
|
116
|
+
minY: Number(((a.isEmpty() ? 0 : a.min.y) + n).toFixed(4)),
|
|
117
|
+
aabbSize: r,
|
|
118
|
+
c12Ticks: d,
|
|
119
|
+
c12Aligned: f,
|
|
120
|
+
detectedAnchors: u(t),
|
|
121
|
+
isSingleMeshProxy: !1
|
|
122
|
+
};
|
|
123
|
+
return e.getState().setCalibration(p), p;
|
|
124
|
+
}
|
|
125
|
+
function m(e, t = "coupe_86", r = "psx-flat") {
|
|
126
|
+
let i = n(t, r);
|
|
127
|
+
if (!e) return f(i, 1, 0, !0, null), i;
|
|
128
|
+
if (a.setFromObject(e), a.isEmpty()) return f(i, 1, 0, !0, e), i;
|
|
129
|
+
a.getSize(o);
|
|
130
|
+
let s = i.lattice.rings[i.lattice.rings.length - 1].z - i.lattice.rings[0].z;
|
|
131
|
+
return f(i, o.z > .2 ? Math.max(.5, Math.min(2, o.z / s)) : 1, 0, !0, e), i;
|
|
132
|
+
}
|
|
133
|
+
export { r as C12_TICK_M, i as UNIFIED_ANCHOR_NAMES, l as computeC12Metrics, d as defaultTargetMeters, u as detectSceneAnchors, s as khrBoxToRapierHalfExtents, f as measureAssemblyCalibration, p as measureNormalizedSceneCalibration, c as snapMetersToC12, m as wrapSingleMeshWithPaperShellProxy };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type KolmoSocketRole } from "../schema/kolmoSchema.js";
|
|
1
2
|
import { type GateDomain } from "./gateStore.js";
|
|
3
|
+
import type { ActiveChopRole, CutVec3 } from "./surfaceCutter.js";
|
|
2
4
|
export interface WebMcpTool {
|
|
3
5
|
readonly name: string;
|
|
4
6
|
readonly description: string;
|
|
@@ -14,6 +16,14 @@ export interface ModelContext {
|
|
|
14
16
|
}): unknown;
|
|
15
17
|
unregisterTool?(name: string): void;
|
|
16
18
|
}
|
|
19
|
+
export interface CutPartMcpRequest {
|
|
20
|
+
readonly role: ActiveChopRole;
|
|
21
|
+
readonly islandId?: number;
|
|
22
|
+
readonly faceIndex?: number;
|
|
23
|
+
readonly creaseDeg?: number;
|
|
24
|
+
readonly loopPoints?: readonly CutVec3[];
|
|
25
|
+
readonly mirrorX?: boolean;
|
|
26
|
+
}
|
|
17
27
|
export interface ImporterWebMcpHost {
|
|
18
28
|
readonly assetName: string;
|
|
19
29
|
readonly wheelCount: number;
|
|
@@ -23,15 +33,16 @@ export interface ImporterWebMcpHost {
|
|
|
23
33
|
readonly setTargetMeters: (m: number) => void;
|
|
24
34
|
readonly bumpTurn: (axis: 0 | 1 | 2) => void;
|
|
25
35
|
readonly autoPopWheels: () => void;
|
|
26
|
-
readonly applyDomainDefaults: (d: GateDomain, sub: "car" | "
|
|
27
|
-
readonly loadStarterCar: (url: string, label: string) => void
|
|
28
|
-
readonly addAnchorPoint: (name: string, pos: [number, number, number]) => void;
|
|
36
|
+
readonly applyDomainDefaults: (d: GateDomain, sub: "car" | "starcraft", proxy: boolean) => void;
|
|
37
|
+
readonly loadStarterCar: (url: string, label: string) => void | Promise<void>;
|
|
38
|
+
readonly addAnchorPoint: (name: string, pos: [number, number, number], role?: KolmoSocketRole) => void;
|
|
39
|
+
readonly cutPart?: (req: CutPartMcpRequest) => {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
status: string;
|
|
42
|
+
};
|
|
29
43
|
readonly sealAndExport: (spawnInWorld: boolean) => Promise<void>;
|
|
30
44
|
readonly captureDataUrl?: () => string | null;
|
|
31
45
|
}
|
|
32
46
|
export declare function getNavigatorModelContext(): ModelContext | null;
|
|
33
|
-
/**
|
|
34
|
-
* Registers W3C WebMCP tools onto `navigator.modelContext` using clean unprefixed `importer_*` names.
|
|
35
|
-
*/
|
|
36
47
|
export declare function buildImporterWebMcpTools(host: ImporterWebMcpHost): readonly WebMcpTool[];
|
|
37
48
|
export declare function useImporterWebMcp(host: ImporterWebMcpHost, enabled?: boolean): boolean;
|