@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.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -14
  3. package/bin/kolmo.mjs +22 -54
  4. package/dist/body/HeldItem.js +171 -0
  5. package/dist/body/KhrBody.js +171 -0
  6. package/dist/body/bodySi.d.ts +0 -11
  7. package/dist/body/bodySi.js +52 -0
  8. package/dist/body/index.d.ts +1 -1
  9. package/dist/body/index.js +4 -1
  10. package/dist/engine/index.d.ts +4 -4
  11. package/dist/engine/index.js +12 -3
  12. package/dist/engine/kolmoActor.d.ts +11 -4
  13. package/dist/engine/kolmoActor.js +197 -0
  14. package/dist/engine/kolmoInput.d.ts +17 -0
  15. package/dist/engine/kolmoInput.js +78 -0
  16. package/dist/engine/kolmoIsland.d.ts +3 -1
  17. package/dist/engine/kolmoIsland.js +311 -0
  18. package/dist/engine/kolmoLongDrive.js +223 -0
  19. package/dist/engine/kolmoRigs.js +59 -0
  20. package/dist/engine/kolmoStore.d.ts +53 -27
  21. package/dist/engine/kolmoStore.js +211 -0
  22. package/dist/engine/kolmoSurface.d.ts +1 -1
  23. package/dist/engine/kolmoSurface.js +182 -0
  24. package/dist/engine/kolmoVehicle.d.ts +3 -1
  25. package/dist/engine/kolmoVehicle.js +250 -0
  26. package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
  27. package/dist/engine/kolmoVehicleDriver.js +29 -0
  28. package/dist/engine/kolmoWorld.d.ts +7 -15
  29. package/dist/engine/kolmoWorld.js +139 -0
  30. package/dist/engine/longDriveKit.d.ts +4 -2
  31. package/dist/engine/longDriveKit.js +254 -0
  32. package/dist/engine/mainlandMacroCell.d.ts +3 -7
  33. package/dist/engine/mainlandMacroCell.js +247 -0
  34. package/dist/engine/shiftedFixedBody.d.ts +13 -0
  35. package/dist/engine/shiftedFixedBody.js +64 -0
  36. package/dist/importer/ChopShopPanel.js +465 -0
  37. package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
  38. package/dist/importer/DomainWorkshopPanel.js +385 -0
  39. package/dist/importer/GateHudBar.js +312 -0
  40. package/dist/importer/GlbImportGate.js +250 -0
  41. package/dist/importer/ImperativeVehicleRig.js +336 -0
  42. package/dist/importer/ImporterPlinthUikitTags.js +112 -0
  43. package/dist/importer/Step1CalibrationPlinth.js +275 -0
  44. package/dist/importer/Step2UniversalPad.js +244 -0
  45. package/dist/importer/VfxEmitterPool.js +91 -0
  46. package/dist/importer/chopShopActions.d.ts +22 -2
  47. package/dist/importer/chopShopActions.js +232 -0
  48. package/dist/importer/gateStore.d.ts +1 -1
  49. package/dist/importer/gateStore.js +92 -0
  50. package/dist/importer/glbNormalizer.js +133 -0
  51. package/dist/importer/importerWebMcp.d.ts +17 -6
  52. package/dist/importer/importerWebMcp.js +343 -0
  53. package/dist/importer/index.js +22 -3
  54. package/dist/importer/khrCompiler.d.ts +1 -1
  55. package/dist/importer/khrCompiler.js +434 -0
  56. package/dist/importer/launcherBake.js +51 -0
  57. package/dist/importer/meshIslands.d.ts +1 -1
  58. package/dist/importer/meshIslands.js +301 -0
  59. package/dist/importer/surfaceCutter.js +254 -0
  60. package/dist/importer/surfaceTopology.js +183 -0
  61. package/dist/importer/universalGateBake.js +162 -0
  62. package/dist/importer/usdToGlb.js +294 -0
  63. package/dist/importer/useChopShopController.d.ts +11 -2
  64. package/dist/importer/useChopShopController.js +364 -0
  65. package/dist/importer/vehiclePanelAnim.js +214 -0
  66. package/dist/importer/wheelAxlePairing.d.ts +1 -2
  67. package/dist/importer/wheelAxlePairing.js +102 -0
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +69 -13
  70. package/dist/junk/DestructibleTarget.js +154 -0
  71. package/dist/junk/KolmoJunk.js +65 -0
  72. package/dist/junk/ShardPieces.d.ts +6 -4
  73. package/dist/junk/ShardPieces.js +74 -0
  74. package/dist/junk/TargetDecals.js +51 -0
  75. package/dist/junk/bvhShatter.js +55 -0
  76. package/dist/junk/bvhTriCollector.js +78 -0
  77. package/dist/junk/index.js +11 -1
  78. package/dist/junk/junkGeometry.js +69 -0
  79. package/dist/junk/junkImportSanitize.js +54 -0
  80. package/dist/junk/junkImporter.js +95 -0
  81. package/dist/junk/junkLabelCanvas.js +67 -0
  82. package/dist/junk/junkLabels.js +35 -0
  83. package/dist/junk/targetHelpers.js +103 -0
  84. package/dist/junk/targetHitLogic.js +128 -0
  85. package/dist/junk/useTargetAssets.js +102 -0
  86. package/dist/physics/index.d.ts +26 -0
  87. package/dist/physics/index.js +84 -0
  88. package/dist/schema/kolmoSchema.d.ts +2 -1
  89. package/dist/schema/kolmoSchema.js +184 -0
  90. package/dist/shaders/celestialBackdrop.d.ts +1 -1
  91. package/dist/shaders/celestialBackdrop.js +344 -0
  92. package/dist/shaders/index.d.ts +0 -1
  93. package/dist/shaders/index.js +9 -1
  94. package/dist/shaders/plumeAndSparkle.js +271 -0
  95. package/dist/shaders/ps2GlslShared.d.ts +1 -1
  96. package/dist/shaders/ps2GlslShared.js +3 -0
  97. package/dist/shaders/ps2MaterialsTSL.js +65 -0
  98. package/dist/shaders/ps2MaterialsWebGL.js +40 -0
  99. package/dist/shaders/ps2RoadWebGL.js +101 -0
  100. package/dist/shaders/ps2TerrainWebGL.js +54 -0
  101. package/dist/shaders/ps2Textures.js +224 -0
  102. package/dist/shaders/retroPalettes.js +188 -0
  103. package/dist/shaders/retroShader.d.ts +31 -3
  104. package/dist/shaders/retroShader.js +249 -0
  105. package/dist/shaders/tsl.d.ts +1 -0
  106. package/dist/shaders/tsl.js +1 -0
  107. package/dist/vite/index.d.ts +15 -0
  108. package/dist/vite/index.js +90 -0
  109. package/dist/world/frontage.js +32 -0
  110. package/dist/world/index.d.ts +1 -1
  111. package/dist/world/index.js +11 -3
  112. package/dist/world/infiniteWorld2D.js +244 -0
  113. package/dist/world/island.js +201 -0
  114. package/dist/world/macroCellSchema.js +27 -0
  115. package/dist/world/macroKnightAStar.js +171 -0
  116. package/dist/world/random.js +33 -0
  117. package/dist/world/road.js +136 -0
  118. package/dist/world/roadRibbon.d.ts +6 -6
  119. package/dist/world/roadRibbon.js +161 -0
  120. package/dist/world/terrain.js +87 -0
  121. package/dist/world/worldTypes.js +111 -0
  122. package/package.json +32 -18
  123. package/dist/body-B7FTf67o.js +0 -362
  124. package/dist/engine-BeKvBM8d.js +0 -1745
  125. package/dist/importer-B2-S-N_e.js +0 -5113
  126. package/dist/junk-B4bC1zAl.js +0 -1049
  127. package/dist/kolmoSurface-DTnrFXH0.js +0 -558
  128. package/dist/shaders-GS71Ek1A.js +0 -1383
  129. package/dist/world-PRWPYrlx.js +0 -947
  130. package/dist/worldTypes-Z0KfdCd0.js +0 -226
@@ -0,0 +1,434 @@
1
+ import { stampKolmoNodesIntoGlb as e } from "../schema/kolmoSchema.js";
2
+ import { createFleet12GonWheelGroup as t } from "./surfaceCutter.js";
3
+ import { measureSelection as n, suggestCarAxles as r } from "./wheelAxlePairing.js";
4
+ import { extractMeshIslands as i, separateVehicleMeshes as a } from "./meshIslands.js";
5
+ import { CHOP_ROLES as o } from "./surfaceTopology.js";
6
+ import { buildPatchPreviewEmitters as s, computeChopPartHinge as c, createVehiclePanelAnimator as l, normalToMinusZQuaternion as u } from "./vehiclePanelAnim.js";
7
+ import * as d from "three";
8
+ import { exportKhrGlb as f } from "@khr3/core";
9
+ import { ENGINE_TORQUE_CURVES as p, STEER_SPEED_CURVES as m, TIRE_ARCHETYPES as h, tireGripForSurface as g } from "@khr3/core/curves";
10
+ // src/importer/khrCompiler.ts
11
+ var _ = [
12
+ "map",
13
+ "normalMap",
14
+ "roughnessMap",
15
+ "metalnessMap",
16
+ "aoMap",
17
+ "emissiveMap"
18
+ ], v = (e) => Number(e.toFixed(4)), y = (e, t, n, r) => [
19
+ v(e / 12 * (n * n + r * r)),
20
+ v(e / 12 * (t * t + r * r)),
21
+ v(e / 12 * (t * t + n * n))
22
+ ];
23
+ function b(e, t, r) {
24
+ if (!t) return [];
25
+ let i = new Map(e.map((e) => [e.id, e])), a = (e) => Object.entries(t).filter(([t, n]) => n === e && !r.has(Number(t)) && i.has(Number(t))).map(([e]) => Number(e)), s = [], l = (e) => o.find((t) => t.role === e)?.massKg ?? 16;
26
+ for (let t of [1, -1]) {
27
+ let r = a("door").filter((e) => (i.get(e).center[0] >= 0 ? 1 : -1) === t);
28
+ if (r.length === 0) continue;
29
+ let o = r.map((e) => i.get(e).center[2]), u = Math.max(...o) - Math.min(...o), d = (Math.min(...o) + Math.max(...o)) * .5;
30
+ (u > .85 ? [r.filter((e) => i.get(e).center[2] >= d), r.filter((e) => i.get(e).center[2] < d)] : [r]).filter((e) => e.length > 0).forEach((r, i) => {
31
+ let a = `${i === 0 ? "F" : "R"}${t > 0 ? "L" : "R"}`;
32
+ s.push({
33
+ nodeName: `Door_${a}`,
34
+ role: `door_${a.toLowerCase()}`,
35
+ islandIds: r,
36
+ massKg: l("door"),
37
+ hinge: c(n(e, r), "door")
38
+ });
39
+ });
40
+ }
41
+ for (let t of ["hood", "trunk"]) {
42
+ let r = a(t);
43
+ r.length > 0 && s.push({
44
+ nodeName: t === "hood" ? "Hood" : "Trunk",
45
+ role: t,
46
+ islandIds: r,
47
+ massKg: l(t),
48
+ hinge: c(n(e, r), t)
49
+ });
50
+ }
51
+ for (let t of ["fender", "bumper"]) a(t).forEach((r, i) => {
52
+ s.push({
53
+ nodeName: `${t === "fender" ? "Fender" : "Bumper"}_${i + 1}`,
54
+ role: t,
55
+ islandIds: [r],
56
+ massKg: l(t),
57
+ hinge: c(n(e, [r]), t)
58
+ });
59
+ });
60
+ return s;
61
+ }
62
+ function x(e, t, r, i) {
63
+ let a = t.filter((e) => e.left.length > 0);
64
+ if (a.length > 0) {
65
+ let t = a.map((t) => ({
66
+ a: t,
67
+ z: n(e, [...t.left, ...t.right]).center[2]
68
+ })).sort((e, t) => t.z - e.z), i = t.length, o = [];
69
+ return t.forEach(({ a: t }, a) => {
70
+ let s = n(e, t.left), c = t.right.length > 0 ? n(e, t.right) : s, l = Math.max(.12, s.radius, c.radius), u = Math.max(.09, Math.max(s.halfWidth, c.halfWidth) * 2), d = r === "AWD" || i === 1 ? !0 : r === "FWD" ? a === 0 : a > 0, f = t.steered ?? a === 0, p = t.driven ?? d, m = t.brake ?? !0, h = i === 2 ? a === 0 ? "F" : "R" : `A${a}`;
71
+ t.right.length === 0 ? o.push({
72
+ nodeName: `Wheel_${h}C`,
73
+ islandIds: [...t.left],
74
+ radius: l,
75
+ width: u,
76
+ steered: f,
77
+ driven: p,
78
+ brake: m
79
+ }) : (o.push({
80
+ nodeName: `Wheel_${h}L`,
81
+ islandIds: [...t.left],
82
+ radius: l,
83
+ width: u,
84
+ steered: f,
85
+ driven: p,
86
+ brake: m
87
+ }), o.push({
88
+ nodeName: `Wheel_${h}R`,
89
+ islandIds: [...t.right],
90
+ radius: l,
91
+ width: u,
92
+ steered: f,
93
+ driven: p,
94
+ brake: m
95
+ }));
96
+ }), o;
97
+ }
98
+ let [o, s, c] = i, l = Math.max(.26, Math.min(.42, s * .24)), u = Math.max(.18, o * .14), d = o * .41, f = c * .32, p = r === "AWD" || r === "FWD", m = r === "AWD" || r === "RWD";
99
+ return [
100
+ {
101
+ nodeName: "Wheel_FL",
102
+ islandIds: [],
103
+ fallbackPos: [
104
+ d,
105
+ l,
106
+ f
107
+ ],
108
+ radius: l,
109
+ width: u,
110
+ steered: !0,
111
+ driven: p,
112
+ brake: !0
113
+ },
114
+ {
115
+ nodeName: "Wheel_FR",
116
+ islandIds: [],
117
+ fallbackPos: [
118
+ -d,
119
+ l,
120
+ f
121
+ ],
122
+ radius: l,
123
+ width: u,
124
+ steered: !0,
125
+ driven: p,
126
+ brake: !0
127
+ },
128
+ {
129
+ nodeName: "Wheel_RL",
130
+ islandIds: [],
131
+ fallbackPos: [
132
+ d,
133
+ l,
134
+ -f
135
+ ],
136
+ radius: l,
137
+ width: u,
138
+ steered: !1,
139
+ driven: m,
140
+ brake: !0
141
+ },
142
+ {
143
+ nodeName: "Wheel_RR",
144
+ islandIds: [],
145
+ fallbackPos: [
146
+ -d,
147
+ l,
148
+ -f
149
+ ],
150
+ radius: l,
151
+ width: u,
152
+ steered: !1,
153
+ driven: m,
154
+ brake: !0
155
+ }
156
+ ];
157
+ }
158
+ async function S(n, o) {
159
+ n.updateMatrixWorld(!0);
160
+ let s = new d.Box3().setFromObject(n), c = s.getSize(new d.Vector3()), l = s.getCenter(new d.Vector3()), u = Math.max(.25, c.x), S = Math.max(.25, c.y), C = Math.max(.25, c.z), w = Math.max(5, o.massKg || 1e3), T = new d.Group();
161
+ T.name = o.name || n.name || `Kolmo_${o.archetype}`;
162
+ let E = [], D;
163
+ if (o.archetype === "car") {
164
+ let e = o.islands ?? i(n), c = x(e, o.axles ?? r(e), o.driveType ?? "AWD", [
165
+ u,
166
+ S,
167
+ C
168
+ ]), f = b(e, o.partPicks, new Set(c.flatMap((e) => e.islandIds))), _ = a(n, e, c.filter((e) => e.islandIds.length > 0), f.map((e) => ({
169
+ nodeName: e.nodeName,
170
+ islandIds: e.islandIds,
171
+ anchor: e.hinge.anchor
172
+ }))), O = new d.Group();
173
+ O.name = "Chassis", O.add(_.chassisGroup), T.add(O);
174
+ for (let e of c) {
175
+ let n = _.wheels.find((t) => t.nodeName === e.nodeName), r = n?.center ?? e.fallbackPos ?? [
176
+ 0,
177
+ e.radius,
178
+ 0
179
+ ];
180
+ if (o.wheelSource === "fleet12" || !n) {
181
+ let n = t(e.radius, e.width, e.nodeName);
182
+ n.position.set(r[0], r[1], r[2]), T.add(n);
183
+ } else T.add(n.group);
184
+ }
185
+ let k = Math.max(...c.map((e) => e.radius)), A = Math.max(.08, Math.min(.3, k * .68)), j = A * .4, M = Math.min(s.max.y - .2, Math.max(k * 1.15, A - j + .16)), N = Math.max(M + .26, s.max.y * .92), P = [
186
+ v(Math.max(.45, u * .92)),
187
+ v(Math.max(.26, N - M)),
188
+ v(Math.max(.55, C * .92))
189
+ ], F = new d.Object3D();
190
+ F.name = "Chassis_Hull", F.position.set(v(l.x), v((M + N) * .5), v(l.z)), O.add(F);
191
+ let I = Math.min(N, Math.max(k + .14, S * .36)), L = c.map((e) => _.wheels.find((t) => t.nodeName === e.nodeName)?.center[2] ?? e.fallbackPos?.[2] ?? 0), R = L.reduce((e, t) => e + t, 0) / Math.max(1, L.length), z = Math.max(80, w - f.reduce((e, t) => e + t.massKg, 0)), B = h.streetDrift90s, V = g(B.muPeakLng, .82);
192
+ E = [{
193
+ nodeName: "Chassis",
194
+ motion: {
195
+ isKinematic: !1,
196
+ mass: z,
197
+ centerOfMass: [
198
+ 0,
199
+ v(I),
200
+ v(R)
201
+ ],
202
+ inertiaDiagonal: y(z, u, Math.max(.45, S - k * .5), C)
203
+ },
204
+ extras: { role: "chassis" }
205
+ }, {
206
+ nodeName: "Chassis_Hull",
207
+ collider: {
208
+ shape: {
209
+ type: "box",
210
+ size: P
211
+ },
212
+ friction: .38,
213
+ restitution: .05
214
+ }
215
+ }];
216
+ for (let e of f) {
217
+ let t = _.panels.find((t) => t.nodeName === e.nodeName);
218
+ if (!t) continue;
219
+ O.add(t.group);
220
+ let n = [
221
+ v(t.center[0] - t.anchor[0]),
222
+ v(t.center[1] - t.anchor[1]),
223
+ v(t.center[2] - t.anchor[2])
224
+ ], r = new d.Object3D();
225
+ r.name = `${e.nodeName}_Panel`, r.position.set(n[0], n[1], n[2]), t.group.add(r), E.push({
226
+ nodeName: r.name,
227
+ collider: {
228
+ shape: {
229
+ type: "box",
230
+ size: [
231
+ v(t.size[0]),
232
+ v(t.size[1]),
233
+ v(t.size[2])
234
+ ]
235
+ },
236
+ friction: .45
237
+ }
238
+ }), E.push({
239
+ nodeName: e.nodeName,
240
+ motion: {
241
+ isKinematic: !1,
242
+ mass: e.massKg,
243
+ centerOfMass: n,
244
+ inertiaDiagonal: y(e.massKg, t.size[0], t.size[1], t.size[2])
245
+ },
246
+ joint: {
247
+ connectedNodeName: "Chassis",
248
+ kind: "revolute",
249
+ axis: e.hinge.axis,
250
+ limits: e.hinge.limits,
251
+ drive: {
252
+ mode: "acceleration",
253
+ stiffness: 60,
254
+ damping: 12,
255
+ positionTarget: 0
256
+ }
257
+ },
258
+ extras: { role: e.role }
259
+ });
260
+ }
261
+ for (let e of c) {
262
+ let t = v(Math.max(.08, Math.min(.3, e.radius * .68))), n = v(t * .4);
263
+ E.push({
264
+ nodeName: e.nodeName,
265
+ extras: { ecctrlWheel: {
266
+ radius: v(e.radius),
267
+ width: v(e.width),
268
+ travel: t,
269
+ sag: n,
270
+ steer: e.steered,
271
+ drive: e.driven,
272
+ brake: e.brake,
273
+ tireGripFactor: V,
274
+ latFrictionEllipseScale: B.latFrictionEllipseScale,
275
+ relaxLngRate: B.relaxLngRate,
276
+ relaxLatRate: B.relaxLatRate,
277
+ lngSlipRatioCurveData: B.lng,
278
+ latSlipRatioCurveData: B.lat
279
+ } }
280
+ });
281
+ }
282
+ D = { tune: {
283
+ engineHorsepower: Math.max(25, o.powerOrThrust || 280),
284
+ engineMaxRPM: 7e3,
285
+ gearRatios: [
286
+ 3.1,
287
+ 2.05,
288
+ 1.42,
289
+ 1,
290
+ .82
291
+ ],
292
+ finalDriveRatio: 3.58,
293
+ transmissionMode: "auto",
294
+ maxSteerAngle: .55,
295
+ rollCenterHeight: .12,
296
+ antiRollStiffness: 14e3,
297
+ engineTorqueCurveData: p.naScreamer,
298
+ steerAngleCurveData: m.driftCountersteer
299
+ } };
300
+ } else if (o.archetype === "starcraft") {
301
+ for (let e of n.clone(!0).children) T.add(e);
302
+ let e = new d.Object3D();
303
+ e.name = "HullBody", e.position.set(l.x, l.y, l.z), T.add(e);
304
+ let t = Math.max(400, o.powerOrThrust || 4500, Math.ceil(w * 9.81 * .72));
305
+ E = [{
306
+ nodeName: "HullBody",
307
+ motion: {
308
+ isKinematic: !1,
309
+ mass: w,
310
+ centerOfMass: [
311
+ 0,
312
+ v(-S * .06),
313
+ 0
314
+ ],
315
+ inertiaDiagonal: y(w, u, S, C)
316
+ },
317
+ collider: {
318
+ shape: {
319
+ type: "box",
320
+ size: [
321
+ v(u * .86),
322
+ v(S * .78),
323
+ v(C * .9)
324
+ ]
325
+ },
326
+ friction: .35,
327
+ restitution: .08
328
+ }
329
+ }];
330
+ for (let [e, n, r, i] of [
331
+ [
332
+ "Thruster_FL",
333
+ u * .36,
334
+ C * .32,
335
+ !1
336
+ ],
337
+ [
338
+ "Thruster_FR",
339
+ -u * .36,
340
+ C * .32,
341
+ !0
342
+ ],
343
+ [
344
+ "Thruster_RL",
345
+ u * .36,
346
+ -C * .32,
347
+ !0
348
+ ],
349
+ [
350
+ "Thruster_RR",
351
+ -u * .36,
352
+ -C * .32,
353
+ !1
354
+ ]
355
+ ]) {
356
+ let a = new d.Object3D();
357
+ a.name = e, a.position.set(l.x + n, l.y, l.z + r), T.add(a), E.push({
358
+ nodeName: e,
359
+ extras: { ecctrlPropeller: {
360
+ maxThrust: t,
361
+ torqueRatio: .6,
362
+ invertTorque: i
363
+ } }
364
+ });
365
+ }
366
+ D = { droneTune: {
367
+ controlMode: "VELOCITY",
368
+ maxYawRate: 2.4,
369
+ maxHorizSpeed: 44,
370
+ maxVertSpeed: 22,
371
+ maxTiltAngle: .52,
372
+ airDragFactor: .18
373
+ } };
374
+ } else {
375
+ let e = new d.Group();
376
+ e.name = "PropBody";
377
+ let t = !1;
378
+ for (let r of n.clone(!0).children) e.add(r), r.traverse((e) => {
379
+ e instanceof d.Mesh && (e.geometry?.getAttribute("position")?.count ?? 0) >= 3 && (t = !0);
380
+ });
381
+ T.add(e), E = [{
382
+ nodeName: "PropBody",
383
+ motion: o.staticProp ? { isKinematic: !0 } : {
384
+ isKinematic: !1,
385
+ mass: w,
386
+ centerOfMass: [
387
+ v(l.x),
388
+ v(l.y),
389
+ v(l.z)
390
+ ],
391
+ inertiaDiagonal: y(w, u, S, C)
392
+ },
393
+ collider: t ? {
394
+ meshNodeName: "PropBody",
395
+ convexHull: !0,
396
+ friction: .6,
397
+ restitution: .1
398
+ } : {
399
+ shape: {
400
+ type: "box",
401
+ size: [
402
+ v(u),
403
+ v(S),
404
+ v(C)
405
+ ]
406
+ },
407
+ friction: .6,
408
+ restitution: .1
409
+ }
410
+ }];
411
+ }
412
+ let O = [];
413
+ T.traverse((e) => {
414
+ if (!(e instanceof d.Mesh) || !e.material) return;
415
+ let t = e.material;
416
+ for (let e of _) {
417
+ let n = t[e];
418
+ n && !n.image && (O.push({
419
+ rec: t,
420
+ slot: e,
421
+ tex: n
422
+ }), t[e] = null);
423
+ }
424
+ });
425
+ let k;
426
+ try {
427
+ k = new Uint8Array(await f(T, E, D));
428
+ } finally {
429
+ for (let e of O) e.rec[e.slot] = e.tex;
430
+ }
431
+ let A = e(k, o.patches ?? []);
432
+ return A instanceof Uint8Array ? A : new Uint8Array(A);
433
+ }
434
+ export { s as buildPatchPreviewEmitters, S as compileKhrAssetGlb, c as computeChopPartHinge, l as createVehiclePanelAnimator, u as normalToMinusZQuaternion };
@@ -0,0 +1,51 @@
1
+ import { stampKolmoNodesIntoGlb as e } from "../schema/kolmoSchema.js";
2
+ import * as t from "three";
3
+ import { exportKhrGlb as n, loadKhrGlb as r } from "@khr3/core";
4
+ import { KOLMOGOROV_CARBINE as i, KOLMOGOROV_PISTOL as a, KOLMOGOROV_SHOTGUN as o, LAUNCHER_RECIPES as s, findLauncherRecipe as c, planLauncher as l } from "@khr3/launchers";
5
+ // src/importer/launcherBake.ts
6
+ var u = {
7
+ receiver: "#334155",
8
+ barrel: "#1e293b",
9
+ bolt: "#94a3b8",
10
+ pump: "#b45309",
11
+ trigger: "#cbd5e1",
12
+ magazine: "#0f172a",
13
+ stock: "#475569",
14
+ screen_rect: "#38bdf8"
15
+ };
16
+ function d(e, n) {
17
+ let r = new t.Group();
18
+ r.name = e.recipeId;
19
+ let i = /* @__PURE__ */ new Map([["root", r]]);
20
+ for (let a of e.nodes) {
21
+ let o = i.get(a.parent) ?? r, s;
22
+ if (a.size[0] > 0 && a.size[1] > 0 && a.size[2] > 0) {
23
+ let r = e.parts.find((e) => e.name === a.name || `${e.name}_Collider` === a.name), i = u[r?.role ?? "receiver"] ?? "#475569", o = new t.MeshStandardMaterial({
24
+ color: i,
25
+ roughness: .72,
26
+ metalness: .28,
27
+ flatShading: !0
28
+ }), c = new t.Mesh(new t.BoxGeometry(a.size[0], a.size[1], a.size[2]), o);
29
+ n && r && !r.joint && (c.visible = !1), s = c;
30
+ } else s = new t.Group();
31
+ s.name = a.name, s.position.set(a.position[0], a.position[1], a.position[2]), o.add(s), i.set(a.name, s);
32
+ }
33
+ if (n) {
34
+ let e = i.get("Receiver_Root") ?? r, t = n.clone(!0);
35
+ t.name = "Launcher_VisualMesh", e.add(t);
36
+ }
37
+ return r;
38
+ }
39
+ async function f(t = i, a, o = []) {
40
+ let u = typeof t == "string" ? s.find((e) => e.id === t) ?? c("kolmogorov_carbine") : t, f = l(u), p = d(f, a), m = new Uint8Array(await n(p, f.specs, {
41
+ gateDomain: "launcher",
42
+ launcher: f.spec,
43
+ ikSockets: f.sockets
44
+ })), h = e(m, o), g = h instanceof Uint8Array ? h : new Uint8Array(h), _ = g.buffer.slice(g.byteOffset, g.byteOffset + g.byteLength);
45
+ return {
46
+ glbBytes: g,
47
+ bundle: await r(_),
48
+ plan: f
49
+ };
50
+ }
51
+ export { i as KOLMOGOROV_CARBINE, a as KOLMOGOROV_PISTOL, o as KOLMOGOROV_SHOTGUN, s as LAUNCHER_RECIPES, f as bakeArticulatedLauncherGlb, d as buildLauncherSceneFromPlan };
@@ -41,7 +41,7 @@ export interface SeparatedVehicleMeshes {
41
41
  size: [number, number, number];
42
42
  };
43
43
  }
44
- export { measureSelection, suggestCarAxles, suggestMotorcycleWheels, toggleIslandSelection, type SelectionBounds, type WheelAxle } from "./wheelAxlePairing.js";
44
+ export { measureSelection, suggestCarAxles, toggleIslandSelection, type SelectionBounds, type WheelAxle } from "./wheelAxlePairing.js";
45
45
  export declare function normalizeSceneToSi(sourceScene: THREE.Object3D, options: {
46
46
  turns?: OrientTurns;
47
47
  targetMeters: number;