@pinkaphant/kolmo 0.2.3 → 0.3.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 (61) hide show
  1. package/bin/kolmo.mjs +1 -1
  2. package/dist/engine/kolmoActor.js +125 -83
  3. package/dist/engine/kolmoLongDrive.js +136 -91
  4. package/dist/engine/kolmoStore.d.ts +6 -5
  5. package/dist/engine/kolmoStore.js +115 -79
  6. package/dist/engine/kolmoVehicle.d.ts +1 -1
  7. package/dist/engine/kolmoVehicle.js +160 -147
  8. package/dist/engine/kolmoVehicleDriver.d.ts +12 -4
  9. package/dist/engine/kolmoVehicleDriver.js +40 -20
  10. package/dist/engine/kolmoWorld.js +55 -35
  11. package/dist/importer/CabinPreviewRig.d.ts +13 -0
  12. package/dist/importer/CabinPreviewRig.js +138 -0
  13. package/dist/importer/CabinStepSection.d.ts +17 -0
  14. package/dist/importer/CabinStepSection.js +222 -0
  15. package/dist/importer/ChopShopPanel.d.ts +31 -1
  16. package/dist/importer/ChopShopPanel.js +474 -380
  17. package/dist/importer/GateHudBar.d.ts +3 -0
  18. package/dist/importer/GateHudBar.js +8 -2
  19. package/dist/importer/GlbImportGate.js +183 -147
  20. package/dist/importer/ImporterPlinthUikitTags.d.ts +2 -1
  21. package/dist/importer/ImporterPlinthUikitTags.js +23 -16
  22. package/dist/importer/Step1CalibrationPlinth.d.ts +10 -0
  23. package/dist/importer/Step1CalibrationPlinth.js +203 -141
  24. package/dist/importer/Step2UniversalPad.d.ts +8 -1
  25. package/dist/importer/Step2UniversalPad.js +112 -90
  26. package/dist/importer/cabinMeshBuilders.d.ts +13 -0
  27. package/dist/importer/cabinMeshBuilders.js +104 -0
  28. package/dist/importer/cabinMixamoRig.d.ts +53 -0
  29. package/dist/importer/cabinMixamoRig.js +150 -0
  30. package/dist/importer/chopShopActions.d.ts +6 -0
  31. package/dist/importer/chopShopActions.js +86 -61
  32. package/dist/importer/chopShopUiComponents.d.ts +22 -0
  33. package/dist/importer/chopShopUiComponents.js +91 -0
  34. package/dist/importer/gateStore.d.ts +5 -2
  35. package/dist/importer/gateStore.js +13 -10
  36. package/dist/importer/glbNormalizer.d.ts +10 -1
  37. package/dist/importer/glbNormalizer.js +114 -49
  38. package/dist/importer/importerWebMcp.js +4 -1
  39. package/dist/importer/index.d.ts +4 -2
  40. package/dist/importer/index.js +24 -21
  41. package/dist/importer/khrCompiler.d.ts +20 -1
  42. package/dist/importer/khrCompiler.js +539 -290
  43. package/dist/importer/launcherBake.js +12 -8
  44. package/dist/importer/meshIslands.d.ts +4 -0
  45. package/dist/importer/meshIslands.js +104 -99
  46. package/dist/importer/surfaceCutter.d.ts +12 -3
  47. package/dist/importer/surfaceCutter.js +220 -127
  48. package/dist/importer/surfaceTopology.d.ts +13 -2
  49. package/dist/importer/surfaceTopology.js +57 -29
  50. package/dist/importer/universalGateBake.d.ts +7 -1
  51. package/dist/importer/universalGateBake.js +63 -60
  52. package/dist/importer/usdToGlb.js +19 -7
  53. package/dist/importer/useChopShopController.d.ts +27 -1
  54. package/dist/importer/useChopShopController.js +369 -255
  55. package/dist/importer/wheelAxlePairing.d.ts +3 -1
  56. package/dist/importer/wheelAxlePairing.js +82 -33
  57. package/dist/index.js +31 -28
  58. package/dist/junk/ShardPieces.js +3 -3
  59. package/dist/physics/index.d.ts +7 -0
  60. package/dist/physics/index.js +66 -40
  61. package/package.json +1 -1
@@ -36,16 +36,20 @@ function d(e, n) {
36
36
  }
37
37
  return r;
38
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, {
39
+ async function f(a = i, o, u = []) {
40
+ let f = typeof a == "string" ? s.find((e) => e.id === a) ?? c("kolmogorov_carbine") : a, p = l(f), m = d(p, o), h = new Uint8Array(await n(m, p.specs, {
41
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);
42
+ launcher: p.spec,
43
+ ikSockets: p.sockets
44
+ }));
45
+ m.traverse((e) => {
46
+ e instanceof t.Mesh && (e.geometry?.dispose(), Array.isArray(e.material) ? e.material.forEach((e) => e.dispose()) : e.material?.dispose());
47
+ });
48
+ let g = e(h, u), _ = g instanceof Uint8Array ? g : new Uint8Array(g), v = _.buffer.slice(_.byteOffset, _.byteOffset + _.byteLength);
45
49
  return {
46
- glbBytes: g,
47
- bundle: await r(_),
48
- plan: f
50
+ glbBytes: _,
51
+ bundle: await r(v),
52
+ plan: p
49
53
  };
50
54
  }
51
55
  export { i as KOLMOGOROV_CARBINE, a as KOLMOGOROV_PISTOL, o as KOLMOGOROV_SHOTGUN, s as LAUNCHER_RECIPES, f as bakeArticulatedLauncherGlb, d as buildLauncherSceneFromPlan };
@@ -32,6 +32,7 @@ export interface SeparatedPanelMesh {
32
32
  }
33
33
  export interface SeparatedVehicleMeshes {
34
34
  wheels: SeparatedWheelMesh[];
35
+ propellers: SeparatedWheelMesh[];
35
36
  panels: SeparatedPanelMesh[];
36
37
  chassisGroup: THREE.Group;
37
38
  fullBounds: {
@@ -56,4 +57,7 @@ export declare function separateVehicleMeshes(normalizedScene: THREE.Object3D, i
56
57
  nodeName: string;
57
58
  islandIds: readonly number[];
58
59
  anchor: [number, number, number];
60
+ }>, propellerGroups?: ReadonlyArray<{
61
+ nodeName: string;
62
+ islandIds: readonly number[];
59
63
  }>): SeparatedVehicleMeshes;
@@ -52,26 +52,28 @@ function s(e, t) {
52
52
  let c = new r.Box3().setFromObject(s);
53
53
  if (c.isEmpty()) throw Error("normalizeSceneToSi: empty scene bounds");
54
54
  let l = c.getSize(new r.Vector3()), u = c.getCenter(new r.Vector3()), d = i === "widthX" ? l.x : i === "heightY" ? l.y : i === "lengthZ" ? l.z : Math.max(l.x, l.y, l.z), f = t.targetMeters / Math.max(d, 1e-5), p = new r.Matrix4().makeTranslation(-u.x * f, -c.min.y * f, -u.z * f).multiply(new r.Matrix4().makeScale(f, f, f)), m = new r.Group();
55
- m.name = e.name || "KolmoAsset";
56
- let h = new r.Matrix4(), g = new r.Vector3();
57
- a.traverse((e) => {
58
- if (e !== a) {
59
- if (e instanceof r.Mesh && e.geometry) {
60
- let t = new r.Mesh(o(e.geometry, h.multiplyMatrices(p, e.matrixWorld)), e.material);
61
- t.name = e.name, t.userData = { ...e.userData }, m.add(t);
62
- } else if (e.children.length === 0 && e.name) {
63
- let t = new r.Object3D();
64
- t.name = e.name, t.userData = { ...e.userData }, t.position.copy(e.getWorldPosition(g).applyMatrix4(p)), m.add(t);
65
- }
55
+ m.name = e.name || "KolmoAsset", m.userData = { ...e.userData };
56
+ let h = new r.Matrix4(), g = new r.Matrix4(), _ = new r.Vector3(), v = new r.Quaternion(), y = new r.Quaternion(), b = new r.Vector3(), x = (e, t) => {
57
+ t.updateMatrixWorld(!0), g.copy(t.matrixWorld).invert(), t.getWorldQuaternion(y).invert();
58
+ for (let n of e.children) if (n instanceof r.Mesh && n.geometry) {
59
+ h.multiplyMatrices(p, n.matrixWorld);
60
+ let e = new r.Mesh(o(n.geometry, g.clone().multiply(h)), n.material);
61
+ e.name = n.name, e.userData = { ...n.userData }, t.add(e), n.children.length > 0 && x(n, e);
62
+ } else {
63
+ let e = !!(n.name || Object.keys(n.userData).length > 0);
64
+ if (n.children.length === 0 && !e) continue;
65
+ let i = n.children.length > 0 ? new r.Group() : new r.Object3D();
66
+ i.name = n.name, i.userData = { ...n.userData }, n.matrixWorld.decompose(_, v, b), _.applyMatrix4(p).applyMatrix4(g), i.position.copy(_), i.quaternion.copy(y).multiply(v.normalize()).normalize(), i.scale.set(1, 1, 1), t.add(i), n.children.length > 0 && x(n, i);
66
67
  }
67
- }), m.updateMatrixWorld(!0);
68
- let _ = new r.Box3().setFromObject(m).getSize(new r.Vector3());
68
+ };
69
+ x(a, m), m.updateMatrixWorld(!0);
70
+ let S = new r.Box3().setFromObject(m).getSize(new r.Vector3());
69
71
  return {
70
72
  scene: m,
71
73
  sizeMeters: [
72
- _.x,
73
- _.y,
74
- _.z
74
+ S.x,
75
+ S.y,
76
+ S.z
75
77
  ],
76
78
  scaleApplied: f
77
79
  };
@@ -151,58 +153,60 @@ function l(e, t = 1e-4) {
151
153
  }
152
154
  }), u;
153
155
  }
154
- function u(e, t, n, i = []) {
156
+ function u(e, t, n, i = [], s = []) {
155
157
  e.updateMatrixWorld(!0);
156
- let s = new r.Matrix4().copy(e.matrixWorld).invert(), l = new r.Matrix4(), u = new Map(t.map((e) => [e.id, e])), d = /* @__PURE__ */ new Map(), f = (e) => {
157
- let t = d.get(e);
158
- return t || (t = o(e.geometry, l.multiplyMatrices(s, e.matrixWorld)), d.set(e, t)), t;
159
- }, p = /* @__PURE__ */ new Map(), m = [], h = [];
160
- for (let e of n) {
161
- let t = e.islandIds.map((e) => u.get(e)).filter((e) => !!e);
162
- if (t.length === 0) continue;
163
- let n = [
164
- Infinity,
165
- Infinity,
166
- Infinity
167
- ], i = [
168
- -Infinity,
169
- -Infinity,
170
- -Infinity
171
- ], o = /* @__PURE__ */ new Map();
172
- for (let e of t) {
173
- for (let t = 0; t < 3; t++) n[t] = Math.min(n[t], e.min[t]), i[t] = Math.max(i[t], e.max[t]);
174
- let t = o.get(e.mesh);
175
- t || (t = [], o.set(e.mesh, t));
176
- let r = p.get(e.mesh);
177
- r || (r = /* @__PURE__ */ new Set(), p.set(e.mesh, r));
178
- for (let n = 0; n < e.triangleIndices.length; n++) {
179
- let i = e.triangleIndices[n];
180
- t.push(i), r.add(i);
158
+ let l = new r.Matrix4().copy(e.matrixWorld).invert(), u = new r.Matrix4(), d = new Map(t.map((e) => [e.id, e])), f = /* @__PURE__ */ new Map(), p = (e) => {
159
+ let t = f.get(e);
160
+ return t || (t = o(e.geometry, u.multiplyMatrices(l, e.matrixWorld)), f.set(e, t)), t;
161
+ }, m = /* @__PURE__ */ new Map(), h = [], g = [], _ = [], v = (e, t) => {
162
+ for (let n of e) {
163
+ let e = n.islandIds.map((e) => d.get(e)).filter((e) => !!e);
164
+ if (e.length === 0) continue;
165
+ let i = [
166
+ Infinity,
167
+ Infinity,
168
+ Infinity
169
+ ], o = [
170
+ -Infinity,
171
+ -Infinity,
172
+ -Infinity
173
+ ], s = /* @__PURE__ */ new Map();
174
+ for (let t of e) {
175
+ for (let e = 0; e < 3; e++) i[e] = Math.min(i[e], t.min[e]), o[e] = Math.max(o[e], t.max[e]);
176
+ let e = s.get(t.mesh);
177
+ e || (e = [], s.set(t.mesh, e));
178
+ let n = m.get(t.mesh);
179
+ n || (n = /* @__PURE__ */ new Set(), m.set(t.mesh, n));
180
+ for (let r = 0; r < t.triangleIndices.length; r++) {
181
+ let i = t.triangleIndices[r];
182
+ e.push(i), n.add(i);
183
+ }
181
184
  }
185
+ let l = [
186
+ (i[0] + o[0]) * .5,
187
+ (i[1] + o[1]) * .5,
188
+ (i[2] + o[2]) * .5
189
+ ], u = new r.Group();
190
+ u.name = n.nodeName, u.position.set(l[0], l[1], l[2]);
191
+ let f = 0;
192
+ for (let [e, t] of s) {
193
+ let i = new r.Mesh(c(p(e), t, [
194
+ -l[0],
195
+ -l[1],
196
+ -l[2]
197
+ ]), a(e));
198
+ i.name = `${n.nodeName}_mesh_${f++}`, u.add(i);
199
+ }
200
+ t.push({
201
+ nodeName: n.nodeName,
202
+ center: l,
203
+ group: u
204
+ });
182
205
  }
183
- let s = [
184
- (n[0] + i[0]) * .5,
185
- (n[1] + i[1]) * .5,
186
- (n[2] + i[2]) * .5
187
- ], l = new r.Group();
188
- l.name = e.nodeName, l.position.set(s[0], s[1], s[2]);
189
- let d = 0;
190
- for (let [t, n] of o) {
191
- let i = new r.Mesh(c(f(t), n, [
192
- -s[0],
193
- -s[1],
194
- -s[2]
195
- ]), a(t));
196
- i.name = `${e.nodeName}_mesh_${d++}`, l.add(i);
197
- }
198
- m.push({
199
- nodeName: e.nodeName,
200
- center: s,
201
- group: l
202
- });
203
- }
206
+ };
207
+ v(n, h), v(s, g);
204
208
  for (let e of i) {
205
- let t = e.islandIds.map((e) => u.get(e)).filter((e) => !!e);
209
+ let t = e.islandIds.map((e) => d.get(e)).filter((e) => !!e);
206
210
  if (t.length === 0) continue;
207
211
  let n = [
208
212
  Infinity,
@@ -217,8 +221,8 @@ function u(e, t, n, i = []) {
217
221
  for (let t = 0; t < 3; t++) n[t] = Math.min(n[t], e.min[t]), i[t] = Math.max(i[t], e.max[t]);
218
222
  let t = o.get(e.mesh);
219
223
  t || (t = [], o.set(e.mesh, t));
220
- let r = p.get(e.mesh);
221
- r || (r = /* @__PURE__ */ new Set(), p.set(e.mesh, r));
224
+ let r = m.get(e.mesh);
225
+ r || (r = /* @__PURE__ */ new Set(), m.set(e.mesh, r));
222
226
  for (let n = 0; n < e.triangleIndices.length; n++) {
223
227
  let i = e.triangleIndices[n];
224
228
  t.push(i), r.add(i);
@@ -232,68 +236,69 @@ function u(e, t, n, i = []) {
232
236
  Math.max(.05, i[0] - n[0]),
233
237
  Math.max(.05, i[1] - n[1]),
234
238
  Math.max(.05, i[2] - n[2])
235
- ], [d, m, g] = e.anchor, _ = new r.Group();
236
- _.name = e.nodeName, _.position.set(d, m, g);
239
+ ], [u, f, h] = e.anchor, g = new r.Group();
240
+ g.name = e.nodeName, g.position.set(u, f, h);
237
241
  let v = 0;
238
242
  for (let [t, n] of o) {
239
- let i = new r.Mesh(c(f(t), n, [
240
- -d,
241
- -m,
242
- -g
243
+ let i = new r.Mesh(c(p(t), n, [
244
+ -u,
245
+ -f,
246
+ -h
243
247
  ]), a(t));
244
- i.name = `${e.nodeName}_skin_${v++}`, _.add(i);
248
+ i.name = `${e.nodeName}_skin_${v++}`, g.add(i);
245
249
  }
246
- h.push({
250
+ _.push({
247
251
  nodeName: e.nodeName,
248
252
  anchor: [
249
- d,
250
- m,
251
- g
253
+ u,
254
+ f,
255
+ h
252
256
  ],
253
257
  center: s,
254
258
  size: l,
255
- group: _
259
+ group: g
256
260
  });
257
261
  }
258
- let g = new r.Group();
259
- g.name = "ChassisVisuals";
260
- let _ = 0;
262
+ let y = new r.Group();
263
+ y.name = "ChassisVisuals";
264
+ let b = 0;
261
265
  e.traverse((e) => {
262
266
  if (!(e instanceof r.Mesh) || !e.geometry) return;
263
- let t = f(e), n = t.getAttribute("position"), i = t.getIndex(), o = Math.floor(i ? i.count / 3 : (n?.count ?? 0) / 3), s = p.get(e);
267
+ let t = p(e), n = t.getAttribute("position"), i = t.getIndex(), o = Math.floor(i ? i.count / 3 : (n?.count ?? 0) / 3), s = m.get(e);
264
268
  if (o === 0 || s && s.size >= o) return;
265
269
  let l = [];
266
270
  for (let e = 0; e < o; e++) s && s.has(e) || l.push(e);
267
271
  if (l.length > 0) {
268
272
  let n = new r.Mesh(c(t, l), a(e));
269
- n.name = `Body_mesh_${_++}`, g.add(n);
273
+ n.name = `Body_mesh_${b++}`, y.add(n);
270
274
  }
271
275
  });
272
- let v = new r.Box3().setFromObject(e), y = v.getSize(new r.Vector3()), b = v.getCenter(new r.Vector3());
276
+ let x = new r.Box3().setFromObject(e), S = x.getSize(new r.Vector3()), C = x.getCenter(new r.Vector3());
273
277
  return {
274
- wheels: m,
275
- panels: h,
276
- chassisGroup: g,
278
+ wheels: h,
279
+ propellers: g,
280
+ panels: _,
281
+ chassisGroup: y,
277
282
  fullBounds: {
278
283
  min: [
279
- v.min.x,
280
- v.min.y,
281
- v.min.z
284
+ x.min.x,
285
+ x.min.y,
286
+ x.min.z
282
287
  ],
283
288
  max: [
284
- v.max.x,
285
- v.max.y,
286
- v.max.z
289
+ x.max.x,
290
+ x.max.y,
291
+ x.max.z
287
292
  ],
288
293
  center: [
289
- b.x,
290
- b.y,
291
- b.z
294
+ C.x,
295
+ C.y,
296
+ C.z
292
297
  ],
293
298
  size: [
294
- y.x,
295
- v.max.y - v.min.y,
296
- y.z
299
+ S.x,
300
+ x.max.y - x.min.y,
301
+ S.z
297
302
  ]
298
303
  }
299
304
  };
@@ -1,22 +1,31 @@
1
1
  import * as THREE from "three";
2
2
  import { type MeshIsland } from "./meshIslands.js";
3
- import { CHOP_ROLES, buildSurfaceTopology, floodFillByCrease, getIslandTopology, mirrorTriangles, type ActiveChopRole, type ChopPartRole, type CutVec3, type FaceSelection, type SurfaceSelectMode, type SurfaceTopology } from "./surfaceTopology.js";
4
- export { CHOP_ROLES, buildSurfaceTopology, floodFillByCrease, getIslandTopology, mirrorTriangles, type ActiveChopRole, type ChopPartRole, type CutVec3, type FaceSelection, type SurfaceSelectMode, type SurfaceTopology };
3
+ import { CHOP_ROLES, buildSurfaceTopology, countSelectionFaces, floodFillByCrease, getIslandTopology, mirrorTriangles, selectionEntries, type ActiveChopRole, type ChopPartRole, type CutVec3, type FaceSelection, type IslandFaceSlice, type SurfaceSelectMode, type SurfaceTopology } from "./surfaceTopology.js";
4
+ export { createFleet12GonWheelGroup } from "./wheelAxlePairing.js";
5
+ export { CHOP_ROLES, buildSurfaceTopology, countSelectionFaces, floodFillByCrease, getIslandTopology, mirrorTriangles, selectionEntries, type ActiveChopRole, type ChopPartRole, type CutVec3, type FaceSelection, type IslandFaceSlice, type SurfaceSelectMode, type SurfaceTopology, };
5
6
  export declare function selectFacesByClick(island: MeshIsland, faceIndex: number, mode: Exclude<SurfaceSelectMode, "island" | "loop">, opts: {
6
7
  creaseDeg: number;
7
8
  mirrorX: boolean;
8
9
  current: FaceSelection | null;
9
10
  remove?: boolean;
11
+ allIslands?: readonly MeshIsland[];
12
+ excludeMirrorIds?: ReadonlySet<number>;
10
13
  }): FaceSelection;
11
14
  export declare function previewLoopPolyline(island: MeshIsland, dots: readonly CutVec3[]): [number, number, number][];
12
15
  export declare function selectFacesByLoop(island: MeshIsland, dots: readonly CutVec3[], opts: {
13
16
  mirrorX: boolean;
14
17
  exact?: boolean;
18
+ allIslands?: readonly MeshIsland[];
19
+ excludeMirrorIds?: ReadonlySet<number>;
15
20
  }): FaceSelection;
16
21
  export declare function refineMeshAlongLoop(geometry: THREE.BufferGeometry, dots: readonly CutVec3[], depthM?: number): {
17
22
  geometry: THREE.BufferGeometry;
18
23
  added: number;
19
24
  };
25
+ export declare function peelFaceSelection(islands: readonly MeshIsland[], selection: FaceSelection, baseName: string, targetRoot?: THREE.Object3D): {
26
+ mintedMeshes: THREE.Mesh[];
27
+ undo: () => void;
28
+ };
20
29
  export declare function peelIslandSelection(island: MeshIsland, selection: FaceSelection, baseName: string): {
21
30
  mintedMeshes: THREE.Mesh[];
22
31
  undo: () => void;
@@ -24,4 +33,4 @@ export declare function peelIslandSelection(island: MeshIsland, selection: FaceS
24
33
  export declare function remapIslandIds(before: readonly MeshIsland[], after: readonly MeshIsland[]): Map<number, number | null>;
25
34
  export declare function findMirrorIslandId(islands: readonly MeshIsland[], seedId: number, excludeIds?: ReadonlySet<number>): number | null;
26
35
  export declare function buildSelectionOverlayGeometry(src: THREE.BufferGeometry, tris: readonly number[], liftM?: number): THREE.BufferGeometry;
27
- export declare function createFleet12GonWheelGroup(radius: number, width: number, nodeName?: string): THREE.Group;
36
+ export declare function buildMultiSelectionOverlay(islands: readonly MeshIsland[], selection: FaceSelection | null, which: "triangles" | "mirrored", liftM?: number): THREE.BufferGeometry | null;