@pinkaphant/kolmo 0.1.2 → 0.1.3

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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -14
  3. package/bin/kolmo.mjs +19 -53
  4. package/dist/body/HeldItem.js +171 -0
  5. package/dist/body/KhrBody.js +179 -0
  6. package/dist/body/bodySi.d.ts +2 -2
  7. package/dist/body/bodySi.js +61 -0
  8. package/dist/body/index.js +4 -1
  9. package/dist/engine/index.d.ts +4 -4
  10. package/dist/engine/index.js +12 -3
  11. package/dist/engine/kolmoActor.d.ts +11 -4
  12. package/dist/engine/kolmoActor.js +197 -0
  13. package/dist/engine/kolmoInput.d.ts +12 -0
  14. package/dist/engine/kolmoInput.js +80 -0
  15. package/dist/engine/kolmoIsland.d.ts +3 -1
  16. package/dist/engine/kolmoIsland.js +311 -0
  17. package/dist/engine/kolmoLongDrive.js +223 -0
  18. package/dist/engine/kolmoRigs.js +59 -0
  19. package/dist/engine/kolmoStore.d.ts +53 -27
  20. package/dist/engine/kolmoStore.js +211 -0
  21. package/dist/engine/kolmoSurface.d.ts +1 -1
  22. package/dist/engine/kolmoSurface.js +182 -0
  23. package/dist/engine/kolmoVehicle.d.ts +2 -1
  24. package/dist/engine/kolmoVehicle.js +244 -0
  25. package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
  26. package/dist/engine/kolmoVehicleDriver.js +38 -0
  27. package/dist/engine/kolmoWorld.d.ts +7 -15
  28. package/dist/engine/kolmoWorld.js +136 -0
  29. package/dist/engine/longDriveKit.d.ts +4 -2
  30. package/dist/engine/longDriveKit.js +254 -0
  31. package/dist/engine/mainlandMacroCell.d.ts +3 -7
  32. package/dist/engine/mainlandMacroCell.js +247 -0
  33. package/dist/engine/shiftedFixedBody.d.ts +13 -0
  34. package/dist/engine/shiftedFixedBody.js +64 -0
  35. package/dist/importer/ChopShopPanel.js +465 -0
  36. package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
  37. package/dist/importer/DomainWorkshopPanel.js +385 -0
  38. package/dist/importer/GateHudBar.js +312 -0
  39. package/dist/importer/GlbImportGate.js +250 -0
  40. package/dist/importer/ImperativeVehicleRig.js +336 -0
  41. package/dist/importer/ImporterPlinthUikitTags.js +112 -0
  42. package/dist/importer/Step1CalibrationPlinth.js +275 -0
  43. package/dist/importer/Step2UniversalPad.js +244 -0
  44. package/dist/importer/VfxEmitterPool.js +91 -0
  45. package/dist/importer/chopShopActions.d.ts +22 -2
  46. package/dist/importer/chopShopActions.js +232 -0
  47. package/dist/importer/gateStore.d.ts +1 -1
  48. package/dist/importer/gateStore.js +92 -0
  49. package/dist/importer/glbNormalizer.js +133 -0
  50. package/dist/importer/importerWebMcp.d.ts +17 -6
  51. package/dist/importer/importerWebMcp.js +343 -0
  52. package/dist/importer/index.js +22 -3
  53. package/dist/importer/khrCompiler.d.ts +1 -1
  54. package/dist/importer/khrCompiler.js +434 -0
  55. package/dist/importer/launcherBake.js +51 -0
  56. package/dist/importer/meshIslands.d.ts +1 -1
  57. package/dist/importer/meshIslands.js +301 -0
  58. package/dist/importer/surfaceCutter.js +254 -0
  59. package/dist/importer/surfaceTopology.js +183 -0
  60. package/dist/importer/universalGateBake.js +162 -0
  61. package/dist/importer/usdToGlb.js +294 -0
  62. package/dist/importer/useChopShopController.d.ts +11 -2
  63. package/dist/importer/useChopShopController.js +364 -0
  64. package/dist/importer/vehiclePanelAnim.js +214 -0
  65. package/dist/importer/wheelAxlePairing.d.ts +1 -2
  66. package/dist/importer/wheelAxlePairing.js +102 -0
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +69 -13
  69. package/dist/junk/DestructibleTarget.js +154 -0
  70. package/dist/junk/KolmoJunk.js +65 -0
  71. package/dist/junk/ShardPieces.d.ts +6 -4
  72. package/dist/junk/ShardPieces.js +74 -0
  73. package/dist/junk/TargetDecals.js +51 -0
  74. package/dist/junk/bvhShatter.js +55 -0
  75. package/dist/junk/bvhTriCollector.js +78 -0
  76. package/dist/junk/index.js +11 -1
  77. package/dist/junk/junkGeometry.js +69 -0
  78. package/dist/junk/junkImportSanitize.js +54 -0
  79. package/dist/junk/junkImporter.js +95 -0
  80. package/dist/junk/junkLabelCanvas.js +67 -0
  81. package/dist/junk/junkLabels.js +35 -0
  82. package/dist/junk/targetHelpers.js +103 -0
  83. package/dist/junk/targetHitLogic.js +128 -0
  84. package/dist/junk/useTargetAssets.js +102 -0
  85. package/dist/physics/index.d.ts +26 -0
  86. package/dist/physics/index.js +84 -0
  87. package/dist/schema/kolmoSchema.d.ts +2 -1
  88. package/dist/schema/kolmoSchema.js +184 -0
  89. package/dist/shaders/celestialBackdrop.d.ts +1 -1
  90. package/dist/shaders/celestialBackdrop.js +344 -0
  91. package/dist/shaders/index.d.ts +0 -1
  92. package/dist/shaders/index.js +9 -1
  93. package/dist/shaders/plumeAndSparkle.js +271 -0
  94. package/dist/shaders/ps2GlslShared.d.ts +1 -1
  95. package/dist/shaders/ps2GlslShared.js +3 -0
  96. package/dist/shaders/ps2MaterialsTSL.js +65 -0
  97. package/dist/shaders/ps2MaterialsWebGL.js +40 -0
  98. package/dist/shaders/ps2RoadWebGL.js +101 -0
  99. package/dist/shaders/ps2TerrainWebGL.js +54 -0
  100. package/dist/shaders/ps2Textures.js +224 -0
  101. package/dist/shaders/retroPalettes.js +188 -0
  102. package/dist/shaders/retroShader.d.ts +31 -3
  103. package/dist/shaders/retroShader.js +249 -0
  104. package/dist/shaders/tsl.d.ts +1 -0
  105. package/dist/shaders/tsl.js +1 -0
  106. package/dist/vite/index.d.ts +15 -0
  107. package/dist/vite/index.js +90 -0
  108. package/dist/world/frontage.js +32 -0
  109. package/dist/world/index.d.ts +1 -1
  110. package/dist/world/index.js +11 -3
  111. package/dist/world/infiniteWorld2D.js +244 -0
  112. package/dist/world/island.js +201 -0
  113. package/dist/world/macroCellSchema.js +27 -0
  114. package/dist/world/macroKnightAStar.js +171 -0
  115. package/dist/world/random.js +33 -0
  116. package/dist/world/road.js +136 -0
  117. package/dist/world/roadRibbon.d.ts +6 -6
  118. package/dist/world/roadRibbon.js +161 -0
  119. package/dist/world/terrain.js +87 -0
  120. package/dist/world/worldTypes.js +111 -0
  121. package/package.json +32 -18
  122. package/dist/body-B7FTf67o.js +0 -362
  123. package/dist/engine-BeKvBM8d.js +0 -1745
  124. package/dist/importer-B2-S-N_e.js +0 -5113
  125. package/dist/junk-B4bC1zAl.js +0 -1049
  126. package/dist/kolmoSurface-DTnrFXH0.js +0 -558
  127. package/dist/shaders-GS71Ek1A.js +0 -1383
  128. package/dist/world-PRWPYrlx.js +0 -947
  129. package/dist/worldTypes-Z0KfdCd0.js +0 -226
@@ -0,0 +1,250 @@
1
+ import { inferKolmoSocketRole as e } from "../schema/kolmoSchema.js";
2
+ import { ChopShopPanel as t } from "./ChopShopPanel.js";
3
+ import { DomainWorkshopPanel as n, enforceRetroPersonMaterials as r } from "./DomainWorkshopPanel.js";
4
+ import { GateHudBar as i } from "./GateHudBar.js";
5
+ import { useImporterWebMcp as a } from "./importerWebMcp.js";
6
+ import { Step1CalibrationPlinth as o } from "./Step1CalibrationPlinth.js";
7
+ import { Step2UniversalPad as s } from "./Step2UniversalPad.js";
8
+ import { VfxEmitterPool as c } from "./VfxEmitterPool.js";
9
+ import { useChopShopController as l } from "./useChopShopController.js";
10
+ import { useMemo as u, useRef as d } from "react";
11
+ import { Canvas as f } from "@react-three/fiber";
12
+ import { Grid as p, OrbitControls as m } from "@react-three/drei";
13
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
14
+ // src/importer/GlbImportGate.tsx
15
+ function _({ onSpawnInWorld: _, enableWebMcp: v = !0 }) {
16
+ let y = l(_), { st: b } = y, x = d(null), S = b.step === 1 && b.domain === "vehicle" && !b.usePaperShellProxy && b.vehicleArchetype !== "starcraft", C = !(b.step === 2 && b.domain === "vehicle" && !b.usePaperShellProxy && b.chaseCam && y.stampTool === "none"), w = (t, n, r) => {
17
+ let i = e(t, r);
18
+ y.setPatches((e) => [...e, {
19
+ nodeName: t,
20
+ translation: n,
21
+ extension: { socket: i }
22
+ }]);
23
+ }, T = u(() => ({
24
+ assetName: y.assetName,
25
+ wheelCount: y.wheelCount,
26
+ choppedCount: y.choppedCount,
27
+ unlocked: y.unlocked,
28
+ targetMeters: y.targetMeters,
29
+ setTargetMeters: y.setTargetMeters,
30
+ bumpTurn: y.bumpTurn,
31
+ autoPopWheels: y.autoPopWheels,
32
+ applyDomainDefaults: y.applyDomainDefaults,
33
+ loadStarterCar: y.loadStarterCar,
34
+ addAnchorPoint: w,
35
+ cutPart: y.cutPart,
36
+ sealAndExport: y.sealAndExport,
37
+ captureDataUrl: () => x.current?.() ?? null
38
+ }), [y]);
39
+ return a(T, v), /* @__PURE__ */ g("div", {
40
+ onDragOver: (e) => e.preventDefault(),
41
+ onDrop: (e) => {
42
+ e.preventDefault();
43
+ let t = e.dataTransfer.files?.[0];
44
+ t && y.ingestFile(t);
45
+ },
46
+ style: {
47
+ position: "relative",
48
+ display: "flex",
49
+ flexDirection: "column",
50
+ width: "100%",
51
+ height: "100%",
52
+ overflow: "hidden",
53
+ background: "#0A0C0E",
54
+ imageRendering: b.eraMode === "psx-1-3" ? "pixelated" : "auto"
55
+ },
56
+ children: [
57
+ /* @__PURE__ */ h("input", {
58
+ ref: y.fileRef,
59
+ type: "file",
60
+ accept: ".glb,.usd,.usda,.usdc,.usdz",
61
+ hidden: !0,
62
+ onChange: (e) => {
63
+ let t = e.target.files?.[0];
64
+ t && y.ingestFile(t);
65
+ }
66
+ }),
67
+ /* @__PURE__ */ h(i, {
68
+ hasCustomFile: y.hasCustomFile,
69
+ assetName: y.assetName,
70
+ usdInfo: y.usdInfo,
71
+ busy: y.busy,
72
+ wheelCount: y.wheelCount,
73
+ choppedCount: y.choppedCount,
74
+ stampTool: y.stampTool,
75
+ patchCount: y.patches.length,
76
+ onChooseFile: () => y.fileRef.current?.click(),
77
+ onLoadStarterCar: (e, t) => {
78
+ y.loadStarterCar(e, t).catch(() => {});
79
+ },
80
+ onSelectDomain: (e) => y.applyDomainDefaults(e, b.vehicleArchetype, !1),
81
+ onSelectVehicleSub: (e) => y.applyDomainDefaults("vehicle", e, !1),
82
+ onBumpTurn: y.bumpTurn,
83
+ onAutoScaleSi: y.autoScaleSi,
84
+ onSnapYZero: () => y.setYOffset(0),
85
+ onSnapC12: y.snapC12,
86
+ onWrapProxy: y.wrapProxy,
87
+ onAutoPopWheels: y.autoPopWheels,
88
+ onSelectStampTool: y.setStampTool,
89
+ onUndoPatch: () => y.setPatches((e) => e.slice(0, -1)),
90
+ onSwingPanelRole: (e) => y.panelAnimRef.current?.toggleRolePrefix(e),
91
+ onDownloadGlb: () => void y.sealAndExport(!1),
92
+ onSpawnWorld: _ ? () => void y.sealAndExport(!0) : void 0
93
+ }),
94
+ b.step === 1 && b.domain !== "vehicle" && /* @__PURE__ */ h(n, {
95
+ domain: b.domain,
96
+ hasCustomFile: y.hasCustomFile,
97
+ targetMeters: y.targetMeters,
98
+ onChangeTargetMeters: y.setTargetMeters,
99
+ onSnapC12: y.snapC12,
100
+ onLoadVaultUrl: y.loadStarterCar,
101
+ onForgeLauncherRecipe: y.forgeScene,
102
+ onAddSocketPatch: w,
103
+ workingScene: y.workingScene,
104
+ onEnforceCrispyPerson: () => r(y.workingScene),
105
+ onUploadToVault: y.uploadToVault
106
+ }),
107
+ S && /* @__PURE__ */ h(t, {
108
+ targetMeters: y.targetMeters,
109
+ onChangeTargetMeters: y.setTargetMeters,
110
+ activeRole: y.activeRole,
111
+ onSelectRole: y.setActiveRole,
112
+ surfaceMode: y.surfaceMode,
113
+ onChangeSurfaceMode: (e) => {
114
+ y.setSurfaceMode(e), y.setFaceSelection(null), y.setLoopDots(null);
115
+ },
116
+ creaseDeg: y.creaseDeg,
117
+ onChangeCreaseDeg: y.setCreaseDeg,
118
+ mirrorX: y.mirrorX,
119
+ onToggleMirrorX: y.setMirrorX,
120
+ splitCoarse: y.splitCoarse,
121
+ onToggleSplitCoarse: y.setSplitCoarse,
122
+ selectedFaces: y.faceSelection?.triangles.length ?? 0,
123
+ mirroredFaces: y.faceSelection?.mirrored.length ?? 0,
124
+ loopDotCount: y.loopDots?.points.length ?? 0,
125
+ undoCount: y.undoStack.length,
126
+ partPicks: y.partPicks,
127
+ wheelCount: y.wheelCount,
128
+ wheelSource: y.wheelSource,
129
+ onChangeWheelSource: y.setWheelSource,
130
+ driveType: b.driveType,
131
+ onChangeDriveType: (e) => b.setField("driveType", e),
132
+ horsepower: b.powerOrThrust,
133
+ onChangeHorsepower: (e) => b.setField("powerOrThrust", e),
134
+ hingeScrub: y.hingeScrub,
135
+ onChangeHingeScrub: y.setHingeScrub,
136
+ explodeAmount: y.explodeAmount,
137
+ onChangeExplodeAmount: y.setExplodeAmount,
138
+ statusNote: y.statusNote,
139
+ unlocked: y.unlocked,
140
+ busy: y.busy,
141
+ onCloseLoop: y.handleCloseLoop,
142
+ onPeel: y.handlePeelSelection,
143
+ onClearSelection: () => {
144
+ y.setFaceSelection(null), y.setLoopDots(null);
145
+ },
146
+ onUndoCut: y.handleUndoCut,
147
+ onClearTags: () => {
148
+ y.setPartPicks({}), y.setHingeScrub(0);
149
+ },
150
+ onGoTestDrive: () => b.setField("step", 2),
151
+ onSpawnWorld: _ ? () => void y.sealAndExport(!0) : void 0
152
+ }),
153
+ /* @__PURE__ */ h("div", {
154
+ style: {
155
+ flex: 1,
156
+ minHeight: 0
157
+ },
158
+ children: /* @__PURE__ */ g(f, {
159
+ dpr: b.eraMode === "psx-1-3" ? .333 : [1, 1.5],
160
+ gl: {
161
+ localClippingEnabled: !0,
162
+ antialias: !1,
163
+ preserveDrawingBuffer: !0
164
+ },
165
+ camera: {
166
+ position: [
167
+ 4.2,
168
+ 2.4,
169
+ 5.2
170
+ ],
171
+ fov: 45
172
+ },
173
+ onCreated: ({ gl: e, scene: t, camera: n }) => {
174
+ x.current = () => (e.render(t, n), typeof e.domElement?.toDataURL == "function" ? e.domElement.toDataURL("image/png") : null);
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ h("color", {
178
+ attach: "background",
179
+ args: ["#0A0C0E"]
180
+ }),
181
+ /* @__PURE__ */ h("ambientLight", { intensity: .72 }),
182
+ /* @__PURE__ */ h("directionalLight", {
183
+ position: [
184
+ 6,
185
+ 10,
186
+ 8
187
+ ],
188
+ intensity: 1.35
189
+ }),
190
+ /* @__PURE__ */ h("directionalLight", {
191
+ position: [
192
+ -6,
193
+ 4,
194
+ -6
195
+ ],
196
+ intensity: .45,
197
+ color: "#00E5FF"
198
+ }),
199
+ /* @__PURE__ */ h(p, {
200
+ infiniteGrid: !0,
201
+ cellSize: b.domain === "c12" ? 1 / 12 : .5,
202
+ sectionSize: 3,
203
+ sectionColor: "#1C2229",
204
+ cellColor: "#12161B",
205
+ fadeDistance: 90
206
+ }),
207
+ /* @__PURE__ */ h(m, {
208
+ makeDefault: !0,
209
+ enabled: C,
210
+ enableDamping: !0
211
+ }),
212
+ b.step === 1 ? /* @__PURE__ */ h(o, {
213
+ assembly: y.assembly,
214
+ useProxy: b.domain === "vehicle" && b.usePaperShellProxy,
215
+ previewScene: y.workingScene,
216
+ islands: y.islands,
217
+ axles: y.axles,
218
+ wheelColors: y.wheelColors,
219
+ partPicks: y.partPicks,
220
+ wheelSource: y.wheelSource,
221
+ surfaceMode: y.surfaceMode,
222
+ activeRoleColor: y.activeRoleColor,
223
+ faceSelection: y.faceSelection,
224
+ loopDots: y.loopDots,
225
+ hingeScrub: y.hingeScrub,
226
+ explodeAmount: y.explodeAmount,
227
+ rootObjRef: y.rootObjRef,
228
+ onClickIsland: y.handleBucketIsland,
229
+ onPickFace: y.handlePickFace
230
+ }) : /* @__PURE__ */ h(s, {
231
+ assembly: y.assembly,
232
+ importedRoot: y.workingScene,
233
+ rootObjRef: y.rootObjRef,
234
+ liveBundle: y.liveBundle,
235
+ patches: y.patches,
236
+ stampActive: y.stampTool !== "none",
237
+ panelAnimRef: y.panelAnimRef,
238
+ onStampSurface: y.handleStampSurface
239
+ }),
240
+ b.domain === "vehicle" && b.usePaperShellProxy && /* @__PURE__ */ h(c, {
241
+ chassisObjRef: y.rootObjRef,
242
+ emitters: y.assembly.emitters
243
+ })
244
+ ]
245
+ })
246
+ })
247
+ ]
248
+ });
249
+ }
250
+ export { _ as GlbImportGate };
@@ -0,0 +1,336 @@
1
+ import { DAMP_ZETA as e, FREQ_HZ as t, gateTelemetry as n, useGateStore as r } from "./gateStore.js";
2
+ import { khrBoxToRapierHalfExtents as i } from "./glbNormalizer.js";
3
+ import { useEffect as a, useMemo as o, useRef as s } from "react";
4
+ import * as c from "three";
5
+ import { useFrame as l } from "@react-three/fiber";
6
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
7
+ import { CuboidCollider as p, RigidBody as m, useRevoluteJoint as h } from "@react-three/rapier";
8
+ import { PaperShellMassMemo as g } from "@khr3/vehicles/paper-shell";
9
+ import { EcctrlVehicle as _, ShapeCastWheel as v } from "@pinkaphant/ecctrl/vehicle";
10
+ // src/importer/ImperativeVehicleRig.tsx
11
+ var y = new c.Vector3(), b = new c.Vector3(), x = new c.Vector3(), S = new c.Quaternion();
12
+ function C(e, t) {
13
+ let n = e ? e.translation() : {
14
+ x: 0,
15
+ y: .35,
16
+ z: 0
17
+ }, r = e ? e.rotation() : {
18
+ x: 0,
19
+ y: 0,
20
+ z: 0,
21
+ w: 1
22
+ }, i = e ? e.linvel() : {
23
+ x: 0,
24
+ y: 0,
25
+ z: 0
26
+ }, a = e ? e.angvel() : {
27
+ x: 0,
28
+ y: 0,
29
+ z: 0
30
+ }, o = e ? e.worldCom() : n;
31
+ return S.set(r.x, r.y, r.z, r.w), y.set(t[0], t[1], t[2]).applyQuaternion(S).add(n), b.set(y.x - o.x, y.y - o.y, y.z - o.z), x.set(a.x, a.y, a.z).cross(b), {
32
+ pos: [
33
+ y.x,
34
+ y.y,
35
+ y.z
36
+ ],
37
+ quat: [
38
+ r.x,
39
+ r.y,
40
+ r.z,
41
+ r.w
42
+ ],
43
+ linvel: [
44
+ i.x + x.x,
45
+ i.y + x.y,
46
+ i.z + x.z
47
+ ],
48
+ angvel: [
49
+ a.x,
50
+ a.y,
51
+ a.z
52
+ ]
53
+ };
54
+ }
55
+ function w(e, t) {
56
+ let n = new c.BufferGeometry();
57
+ return n.setAttribute("position", new c.BufferAttribute(e, 3)), n.setAttribute("normal", new c.BufferAttribute(t, 3)), n.computeBoundingBox(), n;
58
+ }
59
+ function T({ chassisBodyRef: e, panel: t, massKg: n, geometry: r, spawnPose: a, onWrenchHit: c }) {
60
+ let l = s(null), u = s(a), g = t.breakaway.hingeAxisLocal ?? [
61
+ 1,
62
+ 0,
63
+ 0
64
+ ], _ = t.breakaway.swingMinMaxRad ?? [-1.1, 1.1], v = o(() => {
65
+ let e = r.boundingBox;
66
+ return e ? [
67
+ (e.min.x + e.max.x) * .5,
68
+ (e.min.y + e.max.y) * .5,
69
+ (e.min.z + e.max.z) * .5
70
+ ] : [
71
+ 0,
72
+ 0,
73
+ 0
74
+ ];
75
+ }, [r]);
76
+ return h(e, l, [
77
+ t.anchorChassis,
78
+ [
79
+ 0,
80
+ 0,
81
+ 0
82
+ ],
83
+ g,
84
+ _
85
+ ]), /* @__PURE__ */ f(m, {
86
+ ref: l,
87
+ position: u.current.pos,
88
+ quaternion: u.current.quat,
89
+ linearVelocity: u.current.linvel,
90
+ angularVelocity: u.current.angvel,
91
+ mass: n,
92
+ colliders: !1,
93
+ canSleep: !1,
94
+ children: [/* @__PURE__ */ d(p, {
95
+ args: i(t.aabbSize),
96
+ position: v
97
+ }), /* @__PURE__ */ d("mesh", {
98
+ geometry: r,
99
+ onClick: (e) => {
100
+ e.stopPropagation(), c(t);
101
+ },
102
+ children: /* @__PURE__ */ d("meshStandardMaterial", {
103
+ color: t.colorHex,
104
+ roughness: .85,
105
+ flatShading: !0
106
+ })
107
+ })]
108
+ });
109
+ }
110
+ function E({ assembly: c, importedRoot: h, chassisGroupRef: y }) {
111
+ let b = s(null), x = s(null), S = s(""), E = s(r.getState().dropTrigger), D = s({
112
+ w: !1,
113
+ s: !1,
114
+ a: !1,
115
+ d: !1,
116
+ space: !1
117
+ }), O = s(/* @__PURE__ */ new Map()), k = r((e) => e.attachedMask), A = r((e) => e.unlatchedMask), j = r((e) => e.fuelLiters), M = r((e) => e.freqBucket), N = r((e) => e.dampBucket), P = r((e) => e.detachedDebris), F = o(() => new g(c), [c]), I = o(() => F.getPanelIntrinsics(), [F]), L = o(() => c.panels.map((e) => w(e.localPositions, e.localNormals)), [c]), R = o(() => w(c.skateboardPositions, c.skateboardNormals), [c]), z = o(() => w(c.wheels[0].positions, c.wheels[0].normals), [c]), B = o(() => h ? h.clone(!0) : null, [h]);
118
+ a(() => () => {
119
+ for (let e of L) e.dispose();
120
+ R.dispose(), z.dispose();
121
+ }, [
122
+ L,
123
+ R,
124
+ z
125
+ ]), a(() => {
126
+ n.massDirty = !0;
127
+ }, [
128
+ c,
129
+ k,
130
+ A,
131
+ j,
132
+ M,
133
+ N
134
+ ]), a(() => {
135
+ if (typeof window > "u") return;
136
+ let e = (e) => (t) => {
137
+ (t.code === "KeyW" || t.code === "ArrowUp") && (D.current.w = e), (t.code === "KeyS" || t.code === "ArrowDown") && (D.current.s = e), (t.code === "KeyA" || t.code === "ArrowLeft") && (D.current.a = e), (t.code === "KeyD" || t.code === "ArrowRight") && (D.current.d = e), t.code === "Space" && (D.current.space = e);
138
+ }, t = e(!0), n = e(!1);
139
+ return window.addEventListener("keydown", t), window.addEventListener("keyup", n), () => {
140
+ window.removeEventListener("keydown", t), window.removeEventListener("keyup", n);
141
+ };
142
+ }, []);
143
+ let V = F.evaluate(k & ~A, j), H = 2 * Math.PI * t[M], U = e[N], W = V.totalMassKg * .5 * V.frontAxleRatio, G = V.totalMassKg * .5 - W, K = W * H * H, q = G * H * H, J = 2 * U * Math.sqrt(K * W), Y = 2 * U * Math.sqrt(q * G);
144
+ l(() => {
145
+ let e = b.current, t = e?.body ?? null;
146
+ if (x.current = t, !e || !t) return;
147
+ let i = r.getState().dropTrigger;
148
+ i !== E.current && (E.current = i, t.setTranslation({
149
+ x: 0,
150
+ y: 1.2,
151
+ z: 0
152
+ }, !0), t.setRotation({
153
+ x: 0,
154
+ y: 0,
155
+ z: 0,
156
+ w: 1
157
+ }, !0), t.setLinvel({
158
+ x: 0,
159
+ y: 0,
160
+ z: 0
161
+ }, !0), t.setAngvel({
162
+ x: 0,
163
+ y: 0,
164
+ z: 0
165
+ }, !0));
166
+ let a = r.getState(), o = a.attachedMask & ~a.unlatchedMask, s = `${t.handle}:${o}:${a.fuelLiters}`;
167
+ if (n.massDirty || S.current !== s) {
168
+ n.massDirty = !1, S.current = s;
169
+ let e = F.evaluate(o, a.fuelLiters);
170
+ t.setAdditionalMassProperties(e.totalMassKg, {
171
+ x: e.centerOfMass[0],
172
+ y: e.centerOfMass[1],
173
+ z: e.centerOfMass[2]
174
+ }, {
175
+ x: e.inertiaDiagonal[0],
176
+ y: e.inertiaDiagonal[1],
177
+ z: e.inertiaDiagonal[2]
178
+ }, {
179
+ x: e.inertiaOrientation[0],
180
+ y: e.inertiaOrientation[1],
181
+ z: e.inertiaOrientation[2],
182
+ w: e.inertiaOrientation[3]
183
+ }, !0), t.recomputeMassPropertiesFromColliders(), n.massKg = e.totalMassKg, n.com = [...e.centerOfMass], n.frontSplit = e.frontAxleRatio, n.cornerK = [K, q];
184
+ }
185
+ let c = D.current;
186
+ e.setMovement({
187
+ forward: c.w,
188
+ backward: c.s,
189
+ steerLeft: c.a,
190
+ steerRight: c.d,
191
+ brake: c.space
192
+ }), n.speedKmh = e.currLinVel.length() * 3.6, n.rpm = Math.max(850, e.engineRPM);
193
+ });
194
+ let X = (e) => {
195
+ let t = r.getState(), i = 1 << e.bitIndex, a = t.wrenchMode === "UNLATCH_200" ? 200 : 1800, o = b.current?.body ?? null, s = I[e.bitIndex], c = C(o, e.anchorChassis);
196
+ if (n.sparkBurst = [...c.pos], a <= e.breakaway.breakImpulseNs && e.breakaway.hingeAxisLocal && (t.unlatchedMask & i) === 0) {
197
+ O.current.set(e.bitIndex, c), t.setField("unlatchedMask", t.unlatchedMask | i), n.massDirty = !0;
198
+ return;
199
+ }
200
+ if (O.current.delete(e.bitIndex), t.setField("attachedMask", t.attachedMask & ~i), t.setField("unlatchedMask", t.unlatchedMask & ~i), n.massDirty = !0, !o) return;
201
+ let l = Math.min(8, a / Math.max(15, s.massKg * 18));
202
+ t.setField("detachedDebris", [...t.detachedDebris, {
203
+ id: `${e.partId}_${Date.now()}`,
204
+ partId: e.partId,
205
+ massKg: s.massKg,
206
+ position: [...c.pos],
207
+ quaternion: [...c.quat],
208
+ linvel: [
209
+ c.linvel[0] + (e.anchorChassis[0] >= 0 ? 1 : -1) * l,
210
+ c.linvel[1] + .65 * l,
211
+ c.linvel[2] + (e.anchorChassis[2] >= 0 ? .5 : -.5) * l
212
+ ],
213
+ angvel: [...c.angvel],
214
+ aabbSize: e.aabbSize,
215
+ colorHex: e.colorHex
216
+ }]);
217
+ }, Z = o(() => ({
218
+ engineHorsepower: 190,
219
+ gearRatios: [
220
+ 3.5,
221
+ 2.1,
222
+ 1.4,
223
+ 1
224
+ ],
225
+ finalDriveRatio: 3.9,
226
+ rollCenterHeight: .24,
227
+ antiRollStiffness: 2400
228
+ }), []);
229
+ return /* @__PURE__ */ f(u, { children: [
230
+ /* @__PURE__ */ f(_, {
231
+ ref: b,
232
+ position: [
233
+ 0,
234
+ .35,
235
+ 0
236
+ ],
237
+ colliders: !1,
238
+ carConfig: Z,
239
+ canSleep: !1,
240
+ children: [
241
+ /* @__PURE__ */ d(p, {
242
+ args: i(c.skateboardBoxSize),
243
+ position: c.skateboardBoxCenter
244
+ }),
245
+ /* @__PURE__ */ f("group", {
246
+ ref: y,
247
+ children: [
248
+ B && /* @__PURE__ */ d("primitive", { object: B }),
249
+ /* @__PURE__ */ d("mesh", {
250
+ geometry: R,
251
+ children: /* @__PURE__ */ d("meshStandardMaterial", {
252
+ color: 2304045,
253
+ roughness: .9,
254
+ flatShading: !0
255
+ })
256
+ }),
257
+ c.panels.map((e, t) => {
258
+ let n = 1 << e.bitIndex;
259
+ return (k & n) === 0 || (A & n) !== 0 ? null : /* @__PURE__ */ d("mesh", {
260
+ position: e.anchorChassis,
261
+ geometry: L[t],
262
+ onClick: (t) => {
263
+ t.stopPropagation(), X(e);
264
+ },
265
+ children: /* @__PURE__ */ d("meshStandardMaterial", {
266
+ color: e.colorHex,
267
+ roughness: e.isGlass ? .15 : .88,
268
+ transparent: e.isGlass || !!B,
269
+ opacity: B ? .28 : e.isGlass ? .32 : 1,
270
+ wireframe: !!B,
271
+ flatShading: c.shadingMode === "psx-flat"
272
+ })
273
+ }, e.partId);
274
+ })
275
+ ]
276
+ }),
277
+ c.wheels.map((e) => {
278
+ let t = e.slotId.includes("_f"), n = e.omi.suspensionTravel ?? .2;
279
+ return /* @__PURE__ */ d(v, {
280
+ name: e.slotId,
281
+ position: [
282
+ e.position[0],
283
+ e.position[1] + (n - .07),
284
+ e.position[2]
285
+ ],
286
+ rayShapeR: e.omi.radius,
287
+ rayShapeH: e.omi.width * .5,
288
+ rayLength: n,
289
+ wheelModelRadius: e.omi.radius,
290
+ springK: t ? K : q,
291
+ dampingC: t ? J : Y,
292
+ steerWheel: e.omi.steering,
293
+ driveWheel: e.omi.propulsion,
294
+ brakeWheel: !0,
295
+ maxBrakeTorque: 1600,
296
+ children: /* @__PURE__ */ d("mesh", {
297
+ geometry: z,
298
+ children: /* @__PURE__ */ d("meshStandardMaterial", {
299
+ color: 1843753,
300
+ roughness: .9,
301
+ flatShading: !0
302
+ })
303
+ })
304
+ }, e.slotId);
305
+ })
306
+ ]
307
+ }),
308
+ c.panels.map((e, t) => {
309
+ let n = 1 << e.bitIndex;
310
+ if ((k & n) === 0 || (A & n) === 0) return null;
311
+ let r = O.current.get(e.bitIndex) ?? C(x.current, e.anchorChassis);
312
+ return /* @__PURE__ */ d(T, {
313
+ chassisBodyRef: x,
314
+ panel: e,
315
+ massKg: I[t].massKg,
316
+ geometry: L[t],
317
+ spawnPose: r,
318
+ onWrenchHit: X
319
+ }, `unlatched_${e.partId}`);
320
+ }),
321
+ P.map((e) => /* @__PURE__ */ f(m, {
322
+ position: e.position,
323
+ quaternion: e.quaternion,
324
+ mass: e.massKg,
325
+ linearVelocity: e.linvel,
326
+ angularVelocity: e.angvel,
327
+ colliders: !1,
328
+ children: [/* @__PURE__ */ d(p, { args: i(e.aabbSize) }), /* @__PURE__ */ f("mesh", { children: [/* @__PURE__ */ d("boxGeometry", { args: e.aabbSize }), /* @__PURE__ */ d("meshStandardMaterial", {
329
+ color: e.colorHex,
330
+ roughness: .88,
331
+ flatShading: !0
332
+ })] })]
333
+ }, e.id))
334
+ ] });
335
+ }
336
+ export { E as ImperativeVehicleRig };
@@ -0,0 +1,112 @@
1
+ import { useMemo as e, useRef as t } from "react";
2
+ import * as n from "three";
3
+ import { useFrame as r, useThree as i } from "@react-three/fiber";
4
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
+ import { Container as s, Root as c, Text as l } from "@react-three/uikit";
6
+ // src/importer/ImporterPlinthUikitTags.tsx
7
+ function u(e) {
8
+ let t = new n.Group();
9
+ t.name = `Starter_${e}`;
10
+ let r = e === "c12" ? new n.BoxGeometry(3, 3, 3) : e === "person" ? new n.CapsuleGeometry(.3, 1, 6, 12) : e === "launcher" ? new n.BoxGeometry(.14, .24, .92) : e === "junk" ? new n.CylinderGeometry(.32, .34, .85, 12) : new n.BoxGeometry(1.72, 1.25, 4.25), i = new n.Mesh(r, new n.MeshStandardMaterial({
11
+ color: "#38bdf8",
12
+ roughness: .55,
13
+ flatShading: !0
14
+ }));
15
+ return i.position.y = e === "c12" ? 1.5 : e === "person" ? .88 : .65, t.add(i), t;
16
+ }
17
+ new n.Vector3();
18
+ function d({ position: e, label: n, sub: u, accent: d, onClick: f }) {
19
+ let p = t(null), { camera: m } = i();
20
+ return r(() => {
21
+ p.current && p.current.quaternion.copy(m.quaternion);
22
+ }), /* @__PURE__ */ a("group", {
23
+ ref: p,
24
+ position: [
25
+ e[0],
26
+ e[1],
27
+ e[2]
28
+ ],
29
+ children: /* @__PURE__ */ a(c, {
30
+ pixelSize: .0022,
31
+ children: /* @__PURE__ */ o(s, {
32
+ paddingX: 10,
33
+ paddingY: 4,
34
+ borderRadius: 999,
35
+ backgroundColor: "rgba(9, 13, 24, 0.88)",
36
+ borderWidth: 1.5,
37
+ borderColor: d,
38
+ flexDirection: "row",
39
+ alignItems: "center",
40
+ gap: 6,
41
+ hover: { backgroundColor: "#1e293b" },
42
+ onClick: f ? (e) => {
43
+ e.stopPropagation(), f();
44
+ } : void 0,
45
+ children: [/* @__PURE__ */ a(l, {
46
+ fontSize: 12,
47
+ fontWeight: "bold",
48
+ color: d,
49
+ children: n
50
+ }), /* @__PURE__ */ a(l, {
51
+ fontSize: 11,
52
+ color: "#cbd5e1",
53
+ children: u
54
+ })]
55
+ })
56
+ })
57
+ });
58
+ }
59
+ function f({ cal: t, islands: n, wheelColors: r, partPicks: i, explodeAmount: s, onClickIsland: c }) {
60
+ let l = e(() => `${t.aabbSize[0].toFixed(2)}m W × ${t.aabbSize[1].toFixed(2)}m H × ${t.aabbSize[2].toFixed(2)}m L`, [t.aabbSize]), u = e(() => `Ymin ${t.minY >= 0 ? "+" : ""}${t.minY.toFixed(3)}m`, [t.minY]), f = e(() => {
61
+ let e = [];
62
+ for (let t of n) {
63
+ let n = r.get(t.id), a = i[t.id];
64
+ if (!n && !a) continue;
65
+ let o = Math.sign(t.center[0] || 1) * s * .65, c = [
66
+ t.center[0] + o,
67
+ t.center[1] + t.size[1] * .5 + .16,
68
+ t.center[2]
69
+ ];
70
+ if (n) {
71
+ let r = t.center[0] >= 0 ? "L" : "R", i = t.center[2] >= 0 ? "F" : "R";
72
+ e.push({
73
+ id: t.id,
74
+ pos: c,
75
+ label: `WHEEL ${i}${r}`,
76
+ sub: `R ${(t.size[1] * .5).toFixed(2)}m`,
77
+ accent: n
78
+ });
79
+ } else a && e.push({
80
+ id: t.id,
81
+ pos: c,
82
+ label: a.toUpperCase(),
83
+ sub: `${t.triangleIndices.length} tris`,
84
+ accent: "#38bdf8"
85
+ });
86
+ if (e.length >= 12) break;
87
+ }
88
+ return e;
89
+ }, [
90
+ n,
91
+ r,
92
+ i,
93
+ s
94
+ ]);
95
+ return /* @__PURE__ */ o("group", { children: [/* @__PURE__ */ a(d, {
96
+ position: [
97
+ 0,
98
+ t.aabbSize[1] + t.minY + .34,
99
+ 0
100
+ ],
101
+ label: "SI BOUNDS",
102
+ sub: `${l} · ${u}`,
103
+ accent: "#00e5ff"
104
+ }), f.map((e) => /* @__PURE__ */ a(d, {
105
+ position: e.pos,
106
+ label: e.label,
107
+ sub: e.sub,
108
+ accent: e.accent,
109
+ onClick: () => c(e.id)
110
+ }, `pill_${e.id}`))] });
111
+ }
112
+ export { f as ImporterPlinthUikitTags, u as makeStarterDomainScene };