@pinkaphant/kolmo 0.1.1 → 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 (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -14
  3. package/bin/kolmo.mjs +19 -54
  4. package/dist/body/HeldItem.d.ts +22 -0
  5. package/dist/body/HeldItem.js +171 -0
  6. package/dist/body/KhrBody.d.ts +26 -0
  7. package/dist/body/KhrBody.js +179 -0
  8. package/dist/body/bodySi.d.ts +59 -0
  9. package/dist/body/bodySi.js +61 -0
  10. package/dist/body/index.d.ts +3 -0
  11. package/dist/body/index.js +4 -0
  12. package/dist/engine/index.d.ts +4 -4
  13. package/dist/engine/index.js +12 -3
  14. package/dist/engine/kolmoActor.d.ts +11 -4
  15. package/dist/engine/kolmoActor.js +197 -0
  16. package/dist/engine/kolmoInput.d.ts +12 -0
  17. package/dist/engine/kolmoInput.js +80 -0
  18. package/dist/engine/kolmoIsland.d.ts +3 -1
  19. package/dist/engine/kolmoIsland.js +311 -0
  20. package/dist/engine/kolmoLongDrive.js +223 -0
  21. package/dist/engine/kolmoRigs.js +59 -0
  22. package/dist/engine/kolmoStore.d.ts +53 -27
  23. package/dist/engine/kolmoStore.js +211 -0
  24. package/dist/engine/kolmoSurface.d.ts +1 -1
  25. package/dist/engine/kolmoSurface.js +182 -0
  26. package/dist/engine/kolmoVehicle.d.ts +2 -1
  27. package/dist/engine/kolmoVehicle.js +244 -0
  28. package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
  29. package/dist/engine/kolmoVehicleDriver.js +38 -0
  30. package/dist/engine/kolmoWorld.d.ts +7 -15
  31. package/dist/engine/kolmoWorld.js +136 -0
  32. package/dist/engine/longDriveKit.d.ts +4 -2
  33. package/dist/engine/longDriveKit.js +254 -0
  34. package/dist/engine/mainlandMacroCell.d.ts +3 -7
  35. package/dist/engine/mainlandMacroCell.js +247 -0
  36. package/dist/engine/shiftedFixedBody.d.ts +13 -0
  37. package/dist/engine/shiftedFixedBody.js +64 -0
  38. package/dist/importer/ChopShopPanel.js +465 -0
  39. package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
  40. package/dist/importer/DomainWorkshopPanel.js +385 -0
  41. package/dist/importer/GateHudBar.js +312 -0
  42. package/dist/importer/GlbImportGate.js +250 -0
  43. package/dist/importer/ImperativeVehicleRig.js +336 -0
  44. package/dist/importer/ImporterPlinthUikitTags.js +112 -0
  45. package/dist/importer/Step1CalibrationPlinth.js +275 -0
  46. package/dist/importer/Step2UniversalPad.js +244 -0
  47. package/dist/importer/VfxEmitterPool.js +91 -0
  48. package/dist/importer/chopShopActions.d.ts +22 -2
  49. package/dist/importer/chopShopActions.js +232 -0
  50. package/dist/importer/gateStore.d.ts +1 -1
  51. package/dist/importer/gateStore.js +92 -0
  52. package/dist/importer/glbNormalizer.js +133 -0
  53. package/dist/importer/importerWebMcp.d.ts +17 -6
  54. package/dist/importer/importerWebMcp.js +343 -0
  55. package/dist/importer/index.js +22 -3
  56. package/dist/importer/khrCompiler.d.ts +1 -1
  57. package/dist/importer/khrCompiler.js +434 -0
  58. package/dist/importer/launcherBake.js +51 -0
  59. package/dist/importer/meshIslands.d.ts +1 -1
  60. package/dist/importer/meshIslands.js +301 -0
  61. package/dist/importer/surfaceCutter.js +254 -0
  62. package/dist/importer/surfaceTopology.js +183 -0
  63. package/dist/importer/universalGateBake.js +162 -0
  64. package/dist/importer/usdToGlb.js +294 -0
  65. package/dist/importer/useChopShopController.d.ts +11 -2
  66. package/dist/importer/useChopShopController.js +364 -0
  67. package/dist/importer/vehiclePanelAnim.js +214 -0
  68. package/dist/importer/wheelAxlePairing.d.ts +1 -2
  69. package/dist/importer/wheelAxlePairing.js +102 -0
  70. package/dist/index.d.ts +2 -3
  71. package/dist/index.js +69 -14
  72. package/dist/junk/DestructibleTarget.js +154 -0
  73. package/dist/junk/KolmoJunk.js +65 -0
  74. package/dist/junk/ShardPieces.d.ts +6 -4
  75. package/dist/junk/ShardPieces.js +74 -0
  76. package/dist/junk/TargetDecals.js +51 -0
  77. package/dist/junk/bvhShatter.js +55 -0
  78. package/dist/junk/bvhTriCollector.js +78 -0
  79. package/dist/junk/index.js +11 -1
  80. package/dist/junk/junkGeometry.js +69 -0
  81. package/dist/junk/junkImportSanitize.js +54 -0
  82. package/dist/junk/junkImporter.js +95 -0
  83. package/dist/junk/junkLabelCanvas.js +67 -0
  84. package/dist/junk/junkLabels.js +35 -0
  85. package/dist/junk/targetHelpers.js +103 -0
  86. package/dist/junk/targetHitLogic.js +128 -0
  87. package/dist/junk/useTargetAssets.js +102 -0
  88. package/dist/physics/index.d.ts +26 -0
  89. package/dist/physics/index.js +84 -0
  90. package/dist/schema/kolmoSchema.d.ts +2 -1
  91. package/dist/schema/kolmoSchema.js +184 -0
  92. package/dist/shaders/celestialBackdrop.d.ts +1 -1
  93. package/dist/shaders/celestialBackdrop.js +344 -0
  94. package/dist/shaders/index.d.ts +0 -1
  95. package/dist/shaders/index.js +9 -1
  96. package/dist/shaders/plumeAndSparkle.js +271 -0
  97. package/dist/shaders/ps2GlslShared.d.ts +1 -1
  98. package/dist/shaders/ps2GlslShared.js +3 -0
  99. package/dist/shaders/ps2MaterialsTSL.js +65 -0
  100. package/dist/shaders/ps2MaterialsWebGL.js +40 -0
  101. package/dist/shaders/ps2RoadWebGL.js +101 -0
  102. package/dist/shaders/ps2TerrainWebGL.js +54 -0
  103. package/dist/shaders/ps2Textures.js +224 -0
  104. package/dist/shaders/retroPalettes.js +188 -0
  105. package/dist/shaders/retroShader.d.ts +31 -3
  106. package/dist/shaders/retroShader.js +249 -0
  107. package/dist/shaders/tsl.d.ts +1 -0
  108. package/dist/shaders/tsl.js +1 -0
  109. package/dist/vite/index.d.ts +15 -0
  110. package/dist/vite/index.js +90 -0
  111. package/dist/world/frontage.js +32 -0
  112. package/dist/world/index.d.ts +1 -1
  113. package/dist/world/index.js +11 -3
  114. package/dist/world/infiniteWorld2D.js +244 -0
  115. package/dist/world/island.js +201 -0
  116. package/dist/world/macroCellSchema.js +27 -0
  117. package/dist/world/macroKnightAStar.js +171 -0
  118. package/dist/world/random.js +33 -0
  119. package/dist/world/road.js +136 -0
  120. package/dist/world/roadRibbon.d.ts +6 -6
  121. package/dist/world/roadRibbon.js +161 -0
  122. package/dist/world/terrain.js +87 -0
  123. package/dist/world/worldTypes.js +111 -0
  124. package/package.json +36 -19
  125. package/dist/engine-BeKvBM8d.js +0 -1745
  126. package/dist/importer-D9bdcGTh.js +0 -5113
  127. package/dist/junk-B4bC1zAl.js +0 -1049
  128. package/dist/kolmoSurface-DTnrFXH0.js +0 -558
  129. package/dist/shaders-GS71Ek1A.js +0 -1383
  130. package/dist/world-PRWPYrlx.js +0 -947
  131. package/dist/worldTypes-Z0KfdCd0.js +0 -226
@@ -0,0 +1,69 @@
1
+ import * as e from "three";
2
+ // src/junk/junkGeometry.ts
3
+ var t = .085, n = .25, r = .32, i = 14;
4
+ function a(e, t) {
5
+ return t === "3-gon" || t === "12-gon" ? t : e > 14 ? "3-gon" : "12-gon";
6
+ }
7
+ function o(e) {
8
+ if (e.index) return Math.floor(e.index.count / 3);
9
+ let t = e.attributes.position;
10
+ return t ? Math.floor(t.count / 3) : 0;
11
+ }
12
+ function s(r) {
13
+ if (r === "3-gon") {
14
+ let r = new e.CylinderGeometry(t, t, n, 3, 1, !1, Math.PI, Math.PI * 2), i = r.toNonIndexed();
15
+ return r.dispose(), i.computeVertexNormals(), i.computeBoundingBox(), i.computeBoundingSphere(), i;
16
+ }
17
+ let i = new e.CylinderGeometry(t, t, n, 12, 2, !1, Math.PI, Math.PI * 2);
18
+ return i.computeBoundingBox(), i.computeBoundingSphere(), i;
19
+ }
20
+ function c() {
21
+ let t = r * .5, n = [
22
+ new e.Vector2(1e-4, -.16),
23
+ new e.Vector2(.048, -.16),
24
+ new e.Vector2(.055, -.16 + .015),
25
+ new e.Vector2(.055, .01),
26
+ new e.Vector2(.046, .045),
27
+ new e.Vector2(.022, .085),
28
+ new e.Vector2(.02, .135),
29
+ new e.Vector2(.025, .148),
30
+ new e.Vector2(.024, t),
31
+ new e.Vector2(1e-4, t)
32
+ ], i = new e.LatheGeometry(n, 12, Math.PI, Math.PI * 2), a = i.attributes.position, o = i.attributes.uv, s = r;
33
+ for (let n = 0; n < a.count; n++) {
34
+ let r = e.MathUtils.clamp((a.getY(n) + t) / s, 0, 1);
35
+ o.setY(n, r);
36
+ }
37
+ return o.needsUpdate = !0, i.attributes.normal || i.computeVertexNormals(), i.computeBoundingBox(), i.computeBoundingSphere(), i;
38
+ }
39
+ function l() {
40
+ return new e.MeshStandardMaterial({
41
+ color: "#a7f3d0",
42
+ transparent: !0,
43
+ opacity: .42,
44
+ roughness: .12,
45
+ metalness: .1,
46
+ depthWrite: !1
47
+ });
48
+ }
49
+ function u(t) {
50
+ return [
51
+ new e.MeshStandardMaterial({
52
+ color: t ? "#ffffff" : "#e2e8f0",
53
+ map: t ?? null,
54
+ roughness: .48,
55
+ metalness: .15
56
+ }),
57
+ new e.MeshStandardMaterial({
58
+ color: "#cbd5e1",
59
+ roughness: .34,
60
+ metalness: .78
61
+ }),
62
+ new e.MeshStandardMaterial({
63
+ color: "#94a3b8",
64
+ roughness: .38,
65
+ metalness: .78
66
+ })
67
+ ];
68
+ }
69
+ export { r as BOTTLE_HEIGHT, i as CAN_LOD_THRESHOLD_M, n as TIN_CAN_HEIGHT, t as TIN_CAN_RADIUS, c as buildGlassBottleGeometry, s as buildTinCanGeometry, o as countGeometryTriangles, l as createGlassBottleMaterial, u as createTinCanMaterials, a as selectCanLod };
@@ -0,0 +1,54 @@
1
+ import * as e from "three";
2
+ // src/junk/junkImportSanitize.ts
3
+ var t = [
4
+ "map",
5
+ "normalMap",
6
+ "roughnessMap",
7
+ "metalnessMap",
8
+ "emissiveMap",
9
+ "aoMap",
10
+ "alphaMap"
11
+ ];
12
+ function n(t, n) {
13
+ let r = t.geometry, i = r?.attributes?.position;
14
+ if (i) {
15
+ for (let e = 0; e < i.count; e++) if (!Number.isFinite(i.getX(e)) || !Number.isFinite(i.getY(e)) || !Number.isFinite(i.getZ(e))) throw Error(`GLB "${n}" contains non-finite vertex coordinates.`);
16
+ if (r.index) {
17
+ let e = r.index;
18
+ for (let t = 0; t < e.count; t++) {
19
+ let r = e.getX(t);
20
+ if (!Number.isInteger(r) || r < 0 || r >= i.count) throw Error(`GLB "${n}" contains out-of-bounds triangle indices.`);
21
+ }
22
+ }
23
+ if (r.attributes.normal) {
24
+ let e = r.attributes.normal, t = !1;
25
+ for (let n = 0; n < e.count; n++) Number.isFinite(e.getX(n)) && Number.isFinite(e.getY(n)) && Number.isFinite(e.getZ(n)) || (e.setXYZ(n, 0, 1, 0), t = !0);
26
+ t && (e.needsUpdate = !0);
27
+ }
28
+ if (r.computeBoundingBox(), r.attributes.normal || r.computeVertexNormals(), r.attributes.uv) {
29
+ let e = r.attributes.uv, t = !1;
30
+ for (let n = 0; n < e.count; n++) Number.isFinite(e.getX(n)) && Number.isFinite(e.getY(n)) || (e.setXY(n, 0, 0), t = !0);
31
+ t && (e.needsUpdate = !0);
32
+ } else r.setAttribute("uv", new e.Float32BufferAttribute(new Float32Array(i.count * 2), 2));
33
+ t.castShadow = !0, t.receiveShadow = !0;
34
+ }
35
+ }
36
+ function r(n) {
37
+ let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
38
+ n.traverse((n) => {
39
+ if (!(n instanceof e.Mesh)) return;
40
+ n.geometry?.dispose();
41
+ let a = Array.isArray(n.material) ? n.material : [n.material];
42
+ for (let n of a) {
43
+ if (!n || r.has(n)) continue;
44
+ r.add(n);
45
+ let a = n;
46
+ for (let n of t) {
47
+ let t = a[n];
48
+ t instanceof e.Texture && !i.has(t) && (i.add(t), t.dispose());
49
+ }
50
+ n.dispose();
51
+ }
52
+ });
53
+ }
54
+ export { r as disposeImportedRoot, n as ensureMeshAttributes };
@@ -0,0 +1,95 @@
1
+ import { disposeImportedRoot as e, ensureMeshAttributes as t } from "./junkImportSanitize.js";
2
+ import * as n from "three";
3
+ import { GLTFLoader as r } from "three/examples/jsm/loaders/GLTFLoader.js";
4
+ // src/junk/junkImporter.ts
5
+ var i = /(base|stand|pedestal|mount|anchor|frame)/i;
6
+ function a(e) {
7
+ return Math.round(e * 1e4) / 1e4;
8
+ }
9
+ function o(e) {
10
+ if (e.index) return Math.floor(e.index.count / 3);
11
+ let t = e.attributes.position;
12
+ return t ? Math.floor(t.count / 3) : 0;
13
+ }
14
+ function s(e, t) {
15
+ let r = new Map(t.map((e) => [e.segmentId, e]));
16
+ e.traverse((e) => {
17
+ if (!(e instanceof n.Mesh)) return;
18
+ let t = e.userData.segmentId;
19
+ if (!t) return;
20
+ let i = r.get(t);
21
+ i && (e.userData.destructible = i.destructible, e.userData.customName = i.customName);
22
+ });
23
+ }
24
+ async function c(s, c = "imported.glb") {
25
+ if (!s || s.byteLength === 0) throw Error(`Cannot import "${c}": file is empty (0 bytes).`);
26
+ let l = new r(), u;
27
+ try {
28
+ u = await l.parseAsync(s.slice(0), "");
29
+ } catch (e) {
30
+ let t = e instanceof Error ? e.message : String(e);
31
+ throw Error(`Failed to parse GLB "${c}": ${t}`);
32
+ }
33
+ let d = u.scene, f = [];
34
+ try {
35
+ d.traverse((e) => {
36
+ e instanceof n.Mesh && e.geometry?.attributes?.position && (t(e, c), f.push(e));
37
+ });
38
+ } catch (t) {
39
+ throw e(d), t;
40
+ }
41
+ if (f.length === 0) throw e(d), Error(`GLB "${c}" contains no valid renderable meshes.`);
42
+ d.updateMatrixWorld(!0);
43
+ let p = new n.Box3().setFromObject(d), m = new n.Vector3();
44
+ p.getSize(m);
45
+ let h = Math.max(m.x, m.y, m.z);
46
+ if (!Number.isFinite(h) || h <= 1e-6) throw e(d), Error(`GLB "${c}" has invalid or zero-size bounds.`);
47
+ let g = h > 1.2 || h < .25 ? .55 / h : 1, _ = h * g;
48
+ _ < .1 && (g = .1 / h), _ > 2.5 && (g = 2.5 / h), d.scale.multiplyScalar(g), d.updateMatrixWorld(!0);
49
+ let v = new n.Box3().setFromObject(d), y = new n.Vector3(), b = new n.Vector3();
50
+ v.getCenter(y), v.getSize(b), d.position.sub(y);
51
+ let x = new n.Group();
52
+ x.name = c, x.add(d), x.updateMatrixWorld(!0);
53
+ let S = f.some((e) => {
54
+ let t = e.name || e.parent?.name || "";
55
+ return !i.test(t);
56
+ }), C = new n.Box3(), w = new n.Vector3(), T = f.map((e, t) => {
57
+ let n = `seg_${t}`, r = e.name?.trim() || e.parent?.name?.trim() || `Segment ${t + 1}`, s = !S || !i.test(r);
58
+ return C.setFromObject(e), C.getSize(w), e.userData.segmentId = n, e.userData.destructible = s, e.userData.customName = r, {
59
+ segmentId: n,
60
+ originalName: r,
61
+ customName: r,
62
+ destructible: s,
63
+ triCount: o(e.geometry),
64
+ bboxSizeM: [
65
+ a(Math.max(.002, w.x)),
66
+ a(Math.max(.002, w.y)),
67
+ a(Math.max(.002, w.z))
68
+ ]
69
+ };
70
+ }), E = [
71
+ a(Math.max(.02, b.x)),
72
+ a(Math.max(.02, b.y)),
73
+ a(Math.max(.02, b.z))
74
+ ];
75
+ return {
76
+ root: x,
77
+ fileName: c,
78
+ segments: T,
79
+ bboxSizeM: E,
80
+ normalizedExtent: a(Math.max(...E)),
81
+ halfExtents: [
82
+ Math.max(.015, E[0] * .5),
83
+ Math.max(.015, E[1] * .5),
84
+ Math.max(.015, E[2] * .5)
85
+ ],
86
+ dispose: () => e(x)
87
+ };
88
+ }
89
+ async function l(e, t = "imported.glb") {
90
+ if (!e) throw Error("No GLB URL provided.");
91
+ let n = await fetch(e);
92
+ if (!n.ok) throw Error(`Failed to fetch GLB "${t}" (${n.status}).`);
93
+ return c(await n.arrayBuffer(), t);
94
+ }
95
+ export { s as applySegmentsToImportedRoot, l as loadImportedGlbUrl, c as parseImportedGlbBuffer };
@@ -0,0 +1,67 @@
1
+ function e(e, t, n) {
2
+ e.fillStyle = "#f8fafc", e.fillRect(0, 0, t, n), e.fillStyle = "#0f172a", e.fillRect(0, 0, t * .14, n), e.fillRect(t * .86, 0, t * .14, n);
3
+ let r = t * .5, i = n * .5;
4
+ for (let [t, n] of [
5
+ [108, "#0f172a"],
6
+ [86, "#f8fafc"],
7
+ [64, "#dc2626"],
8
+ [42, "#f8fafc"],
9
+ [22, "#ef4444"],
10
+ [9, "#facc15"]
11
+ ]) e.beginPath(), e.arc(r, i, t, 0, Math.PI * 2), e.fillStyle = n, e.fill();
12
+ e.strokeStyle = "#0f172a", e.lineWidth = 3, e.beginPath(), e.moveTo(r - 118, i), e.lineTo(r - 90, i), e.moveTo(r + 90, i), e.lineTo(r + 118, i), e.moveTo(r, i - 118), e.lineTo(r, i - 90), e.moveTo(r, i + 90), e.lineTo(r, i + 118), e.stroke();
13
+ }
14
+ function t(e, t, n) {
15
+ e.fillStyle = "#facc15", e.fillRect(0, 0, t, n), e.fillStyle = "#eab308";
16
+ for (let r = 24; r < t; r += 48) for (let t = 24; t < n; t += 48) e.beginPath(), e.arc(r, t, 8, 0, Math.PI * 2), e.fill();
17
+ let r = t * .5, i = n * .5;
18
+ e.beginPath(), e.arc(r, i, 96, 0, Math.PI * 2), e.fillStyle = "#fde047", e.fill(), e.lineWidth = 7, e.strokeStyle = "#18181b", e.stroke(), e.fillStyle = "#ffffff", e.beginPath(), e.arc(r - 34, i - 22, 24, 0, Math.PI * 2), e.arc(r + 34, i - 26, 17, 0, Math.PI * 2), e.fill(), e.stroke(), e.fillStyle = "#18181b", e.beginPath(), e.arc(r - 26, i - 18, 9, 0, Math.PI * 2), e.arc(r + 38, i - 30, 8, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r, i + 12, 52, .1 * Math.PI, .9 * Math.PI), e.fillStyle = "#7f1d1d", e.fill(), e.stroke(), e.fillStyle = "#fb7185", e.beginPath(), e.ellipse(r + 12, i + 56, 20, 24, .12, 0, Math.PI * 2), e.fill(), e.stroke(), e.fillStyle = "#ffffff", e.fillRect(r - 22, i + 16, 16, 14), e.fillRect(r + 4, i + 16, 16, 14);
19
+ }
20
+ function n(e, t, n) {
21
+ let r = e.createLinearGradient(0, 0, t, n);
22
+ r.addColorStop(0, "#0284c7"), r.addColorStop(.5, "#06b6d4"), r.addColorStop(1, "#2563eb"), e.fillStyle = r, e.fillRect(0, 0, t, n), e.fillStyle = "#ec4899", e.beginPath(), e.moveTo(0, n * .72), e.lineTo(t, n * .25), e.lineTo(t, n * .42), e.lineTo(0, n * .89), e.closePath(), e.fill(), e.fillStyle = "#fde047", e.fillRect(0, 14, t, 14), e.fillRect(0, n - 28, t, 14), e.fillStyle = "rgba(255,255,255,0.45)";
23
+ for (let [t, n, r] of [
24
+ [
25
+ 130,
26
+ 70,
27
+ 10
28
+ ],
29
+ [
30
+ 165,
31
+ 190,
32
+ 14
33
+ ],
34
+ [
35
+ 350,
36
+ 62,
37
+ 12
38
+ ],
39
+ [
40
+ 380,
41
+ 185,
42
+ 9
43
+ ]
44
+ ]) e.beginPath(), e.arc(t, n, r, 0, Math.PI * 2), e.fill();
45
+ let i = t * .5, a = n * .5;
46
+ e.fillStyle = "#0f172a", e.fillRect(i - 122, a - 48, 244, 96), e.strokeStyle = "#fde047", e.lineWidth = 5, e.strokeRect(i - 122, a - 48, 244, 96), e.textAlign = "center", e.textBaseline = "middle", e.fillStyle = "#fde047", e.font = "bold 34px sans-serif", e.fillText("TRIS' SODA", i, a - 12), e.fillStyle = "#67e8f9", e.font = "bold 18px monospace", e.fillText("DREAMCAST FIZZ", i, a + 24);
47
+ }
48
+ function r(e, t, n) {
49
+ e.fillStyle = "#fef3c7", e.fillRect(0, 0, t, n), e.fillStyle = "#b91c1c", e.fillRect(0, 0, t, n * .46), e.fillStyle = "#1e3a8a", e.fillRect(0, n * .8, t, n * .2), e.fillStyle = "#f59e0b", e.fillRect(0, n * .45, t, 10);
50
+ let r = t * .5;
51
+ e.beginPath(), e.ellipse(r, n * .62, 62, 34, 0, 0, Math.PI * 2), e.fillStyle = "#78350f", e.fill(), e.lineWidth = 4, e.strokeStyle = "#f59e0b", e.stroke(), e.textAlign = "center", e.textBaseline = "middle", e.fillStyle = "#fef3c7", e.font = "bold 36px serif", e.fillText("GARY'S", r, 46), e.fillStyle = "#fde047", e.font = "bold 28px sans-serif", e.fillText("BEANS", r, 88), e.fillStyle = "#fef3c7", e.font = "bold 18px sans-serif", e.fillText("BAKED IN SAUCE", r, n * .62);
52
+ }
53
+ function i(i, a, o = 512, s = 256) {
54
+ switch (a) {
55
+ case "target":
56
+ e(i, o, s);
57
+ break;
58
+ case "goofy-emoji":
59
+ t(i, o, s);
60
+ break;
61
+ case "tris-soda":
62
+ n(i, o, s);
63
+ break;
64
+ case "garys-beans": r(i, o, s);
65
+ }
66
+ }
67
+ export { i as renderProceduralLabelCanvas };
@@ -0,0 +1,35 @@
1
+ import { renderProceduralLabelCanvas as e } from "./junkLabelCanvas.js";
2
+ import * as t from "three";
3
+ // src/junk/junkLabels.ts
4
+ var n = /* @__PURE__ */ new Map();
5
+ function r(e) {
6
+ return e.colorSpace = t.SRGBColorSpace, e.wrapS = t.RepeatWrapping, e.wrapT = t.ClampToEdgeWrapping, e.flipY = !0, e.anisotropy = 1, e.needsUpdate = !0, e;
7
+ }
8
+ function i(i, a) {
9
+ if (typeof document > "u") return null;
10
+ let o = i === "custom" ? "target" : i, s = a?.cache !== !1;
11
+ if (s) {
12
+ let e = n.get(o);
13
+ if (e) return e;
14
+ }
15
+ let c = document.createElement("canvas");
16
+ c.width = 512, c.height = 256;
17
+ let l = c.getContext("2d");
18
+ if (!l) return null;
19
+ e(l, o, c.width, c.height);
20
+ let u = r(new t.CanvasTexture(c));
21
+ return s && n.set(o, u), u;
22
+ }
23
+ function a(e) {
24
+ return new Promise((n, i) => {
25
+ !e || typeof e != "string" ? i(/* @__PURE__ */ Error("Invalid custom label URL.")) : new t.TextureLoader().load(e, (e) => {
26
+ r(e), n({
27
+ texture: e,
28
+ dispose: () => e.dispose()
29
+ });
30
+ }, void 0, () => {
31
+ i(/* @__PURE__ */ Error("Failed to decode custom label image from URL."));
32
+ });
33
+ });
34
+ }
35
+ export { i as getProceduralLabelTexture, a as loadCustomLabelTexture };
@@ -0,0 +1,103 @@
1
+ import { splitObjectIntoShards as e } from "./bvhShatter.js";
2
+ import { createGlassBottleMaterial as t } from "./junkGeometry.js";
3
+ import * as n from "three";
4
+ // src/junk/targetHelpers.ts
5
+ var r = .65;
6
+ function i(e) {
7
+ return e === "glass-bottle" ? 1200 : e === "imported-glb" ? 800 : 220;
8
+ }
9
+ var a = new n.Vector3(), o = new n.Vector3(), s = new n.Vector3(0, 0, 1), c = new n.Quaternion(), l = new n.Euler(), u = new n.Matrix4(), d = new n.Matrix3(), f = new n.Box3();
10
+ function p(e, t, n) {
11
+ return e.updateMatrixWorld(!0), a.set(t[0], t[1], t[2]), e.worldToLocal(a), u.copy(e.matrixWorld).invert(), d.getNormalMatrix(u), o.set(n[0], n[1], n[2]).applyMatrix3(d), o.lengthSq() > 1e-8 ? o.normalize() : o.set(0, 0, 1), c.setFromUnitVectors(s, o), l.setFromQuaternion(c, "XYZ"), {
12
+ position: [
13
+ a.x,
14
+ a.y,
15
+ a.z
16
+ ],
17
+ rotation: [
18
+ l.x,
19
+ l.y,
20
+ l.z
21
+ ]
22
+ };
23
+ }
24
+ function m(e, t) {
25
+ a.set(t[0], t[1], t[2]);
26
+ let r = null, i = Infinity;
27
+ return e.traverse((e) => {
28
+ if (!(e instanceof n.Mesh) || e.userData.isDecal || e.userData.isGizmo) return;
29
+ f.setFromObject(e);
30
+ let t = f.distanceToPoint(a);
31
+ t < i && (i = t, r = e);
32
+ }), r;
33
+ }
34
+ function h(t, a, o, s, c, l = "tin-can") {
35
+ let u = e(t, a), d = i(l), f = new n.Vector3(...c.impulse), p = Math.min(1.5, Math.max(.75, .75 + f.length() * .12)), m = f.lengthSq() > 1e-6 ? f.clone().normalize() : new n.Vector3(0, .25, -1).normalize();
36
+ return {
37
+ states: u.map((e, t) => {
38
+ let i = new n.Vector3(...e.centroid).clone().applyQuaternion(s), a = i.lengthSq() > 1e-6 ? i.clone().normalize() : new n.Vector3(t % 3 - 1, .5, (t + 1) % 3 - 1).normalize(), c = o.clone().add(i).addScaledVector(a, .008), l = Math.max(.01, e.halfExtents[0] * r), u = Math.max(.01, e.halfExtents[1] * r), f = Math.max(.01, e.halfExtents[2] * r), h = Math.max(.008, 8 * l * u * f * d), g = a.clone().multiplyScalar(1.25 * p).addScaledVector(m, .85 * p);
39
+ g.y += .8 * p;
40
+ let _ = g.clone().multiplyScalar(h), v = t % 2 == 0 ? 1 : -1, y = new n.Vector3(v * (.6 + a.z * .4), v * (.7 + a.x * .4), -v * (.5 + a.y * .4)).multiplyScalar(7.5), b = Math.max(1e-5, h * (l * l + u * u + f * f) * .35), x = y.clone().multiplyScalar(b);
41
+ return {
42
+ spec: e,
43
+ worldPos: [
44
+ c.x,
45
+ c.y,
46
+ c.z
47
+ ],
48
+ worldQuat: [
49
+ s.x,
50
+ s.y,
51
+ s.z,
52
+ s.w
53
+ ],
54
+ impulse: [
55
+ _.x,
56
+ _.y,
57
+ _.z
58
+ ],
59
+ torque: [
60
+ x.x,
61
+ x.y,
62
+ x.z
63
+ ],
64
+ linvel: [
65
+ g.x,
66
+ g.y,
67
+ g.z
68
+ ],
69
+ angvel: [
70
+ y.x,
71
+ y.y,
72
+ y.z
73
+ ],
74
+ density: d
75
+ };
76
+ }),
77
+ specs: u
78
+ };
79
+ }
80
+ function g(e, r, i) {
81
+ if (e === "glass-bottle") return t();
82
+ if (e === "tin-can") return new n.MeshStandardMaterial({
83
+ color: r ? "#e2e8f0" : "#94a3b8",
84
+ map: r ?? null,
85
+ roughness: .45,
86
+ metalness: .35,
87
+ side: n.DoubleSide
88
+ });
89
+ let a = null;
90
+ if (i?.traverse((e) => {
91
+ !a && e instanceof n.Mesh && (e.userData.isDecal || e.userData.isGizmo || (a = Array.isArray(e.material) ? e.material[0] ?? null : e.material ?? null));
92
+ }), a) {
93
+ let e = a.clone();
94
+ return e.side = n.DoubleSide, e;
95
+ }
96
+ return new n.MeshStandardMaterial({
97
+ color: "#cbd5e1",
98
+ roughness: .6,
99
+ metalness: .2,
100
+ side: n.DoubleSide
101
+ });
102
+ }
103
+ export { r as SHARD_COLLIDER_INSET, h as buildShardStates, p as computeLocalDecalTransform, g as createShardMaterial, m as findClosestMeshInGroup, i as getTargetDensity };
@@ -0,0 +1,128 @@
1
+ import { buildShardStates as e, computeLocalDecalTransform as t, createShardMaterial as n, findClosestMeshInGroup as r } from "./targetHelpers.js";
2
+ import * as i from "three";
3
+ // src/junk/targetHitLogic.ts
4
+ var a = new i.Vector3();
5
+ function o(o, s, c, l, u, d, f, p) {
6
+ let m;
7
+ if (c) {
8
+ c.recomputeMassPropertiesFromColliders?.();
9
+ let e = Math.max(.001, c.mass()) * 3.5, t = Math.hypot(p.impulse[0], p.impulse[1], p.impulse[2]), n = t > e && t > 1e-6 ? e / t : 1;
10
+ c.applyImpulseAtPoint({
11
+ x: p.impulse[0] * n,
12
+ y: p.impulse[1] * n,
13
+ z: p.impulse[2] * n
14
+ }, {
15
+ x: p.point[0],
16
+ y: p.point[1],
17
+ z: p.point[2]
18
+ }, !0);
19
+ let r = c.translation();
20
+ m = [
21
+ r.x,
22
+ r.y,
23
+ r.z
24
+ ];
25
+ }
26
+ let h = Math.hypot(p.impulse[0], p.impulse[1], p.impulse[2]), g = Math.max(1, Math.round(o.maxHp * Math.min(1, Math.max(.28, h / 8)))), _ = Math.max(0, d - g);
27
+ if ((o.fragile || _ <= 0) && l) {
28
+ let t = new i.Vector3(...o.position), r = new i.Quaternion();
29
+ if (c) {
30
+ let e = c.translation(), n = c.rotation();
31
+ t.set(e.x, e.y, e.z), r.set(n.x, n.y, n.z, n.w);
32
+ } else l.getWorldPosition(t), l.getWorldQuaternion(r);
33
+ let { states: a, specs: u } = e(l, o.shatterPieceCount, t, r, p, o.kind), d = n(o.kind, s.activeLabelTex, s.importedRoot);
34
+ return {
35
+ shattered: !0,
36
+ nextHp: 0,
37
+ shatterPos: [
38
+ t.x,
39
+ t.y,
40
+ t.z
41
+ ],
42
+ shardStates: a,
43
+ shardSpecs: u,
44
+ shardMaterial: d
45
+ };
46
+ }
47
+ let v = u ?? (l ? r(l, p.point) : null);
48
+ if (!v) return {
49
+ shattered: !1,
50
+ nextHp: _,
51
+ bodyPos: m
52
+ };
53
+ let y = t(v, p.point, p.normal);
54
+ v.getWorldScale(a);
55
+ let b = Math.max(1e-4, (Math.abs(a.x) + Math.abs(a.y) + Math.abs(a.z)) / 3);
56
+ return {
57
+ shattered: !1,
58
+ nextHp: _,
59
+ bodyPos: m,
60
+ newDecal: {
61
+ id: f,
62
+ position: y.position,
63
+ rotation: y.rotation,
64
+ scale: .045 / b
65
+ },
66
+ newDecalMesh: u ? void 0 : v
67
+ };
68
+ }
69
+ function s(e, t, n, r, i, a, o, s) {
70
+ let c = null, l = null;
71
+ if (i && n) try {
72
+ c = n.translation(), l = n.linvel();
73
+ } catch {
74
+ c = null, l = null;
75
+ }
76
+ let u = s ?? e.position;
77
+ return {
78
+ id: e.id,
79
+ kind: e.kind,
80
+ lodMode: e.canLodMode,
81
+ activeLod: t.effectiveLod,
82
+ triCount: t.triCount,
83
+ labelId: e.labelId,
84
+ customLabelLoaded: t.customLabelLoaded,
85
+ materialTransparent: e.kind === "glass-bottle",
86
+ opacity: e.kind === "glass-bottle" ? .42 : 1,
87
+ hp: r,
88
+ maxHp: e.maxHp,
89
+ alive: i,
90
+ decalCount: i ? a : 0,
91
+ activeShardCount: i ? 0 : o,
92
+ position: c ? [
93
+ c.x,
94
+ c.y,
95
+ c.z
96
+ ] : [...u],
97
+ linearVelocity: l ? [
98
+ l.x,
99
+ l.y,
100
+ l.z
101
+ ] : [
102
+ 0,
103
+ 0,
104
+ 0
105
+ ]
106
+ };
107
+ }
108
+ function c(e, t, n) {
109
+ n && e.set(t, { current: n });
110
+ }
111
+ function l(e, t, n, r, i = 16) {
112
+ let a = [...e, t], o = Math.max(0, a.length - i);
113
+ for (let e = 0; e < o; e++) n.delete(a[e].id);
114
+ return c(n, t.id, r), o > 0 ? a.slice(o) : a;
115
+ }
116
+ function u(e, t, n) {
117
+ e?.traverse((e) => {
118
+ e instanceof i.Mesh && !e.userData.isDecal && (e.userData.targetId = t, e.userData.destructibleTarget = !0, e.userData.isDestructibleTarget = !0, e.userData.applyHit = n);
119
+ });
120
+ }
121
+ function d(e, t, n) {
122
+ if (e) try {
123
+ let t = e.translation();
124
+ return n.set(t.x, t.y, t.z), !0;
125
+ } catch {}
126
+ return t ? (t.getWorldPosition(n), !0) : !1;
127
+ }
128
+ export { l as appendDecalBounded, c as attachDecalMeshRef, s as buildTargetSnapshot, o as executeTargetHit, d as readTargetWorldPos, u as tagImportedMeshes };
@@ -0,0 +1,102 @@
1
+ import { buildGlassBottleGeometry as e, buildTinCanGeometry as t, countGeometryTriangles as n, createGlassBottleMaterial as r, createTinCanMaterials as i, selectCanLod as a } from "./junkGeometry.js";
2
+ import { applySegmentsToImportedRoot as o, loadImportedGlbUrl as s } from "./junkImporter.js";
3
+ import { getProceduralLabelTexture as c, loadCustomLabelTexture as l } from "./junkLabels.js";
4
+ import { useEffect as u, useMemo as d, useState as f } from "react";
5
+ // src/junk/useTargetAssets.ts
6
+ function p(p, m) {
7
+ let [h, g] = f(() => a(10, p.canLodMode)), [_, v] = f(null), [y, b] = f(null), x = p.canLodMode === "auto" ? h : p.canLodMode;
8
+ u(() => {
9
+ p.canLodMode !== "auto" && g(p.canLodMode);
10
+ }, [p.canLodMode]), u(() => {
11
+ if (p.labelId !== "custom" || !p.customAlbedoUrl) {
12
+ v(null);
13
+ return;
14
+ }
15
+ let e = !1, t = null;
16
+ return l(p.customAlbedoUrl).then((n) => {
17
+ e ? n.dispose() : (t = n.dispose, v(n.texture));
18
+ }).catch(() => {
19
+ e || v(null);
20
+ }), () => {
21
+ e = !0, t?.();
22
+ };
23
+ }, [p.labelId, p.customAlbedoUrl]), u(() => {
24
+ if (p.kind !== "imported-glb" || m || !p.importedUrl) {
25
+ b(null);
26
+ return;
27
+ }
28
+ let e = !1, t = null;
29
+ return s(p.importedUrl, p.id).then((n) => {
30
+ e ? n.dispose() : (t = n, b(n));
31
+ }).catch(() => {
32
+ e || b(null);
33
+ }), () => {
34
+ e = !0, t?.dispose();
35
+ };
36
+ }, [
37
+ p.kind,
38
+ p.importedUrl,
39
+ p.id,
40
+ m
41
+ ]);
42
+ let S = m ?? y, C = d(() => S ? m ? S.root.clone(!0) : S.root : null, [S, m]);
43
+ u(() => {
44
+ C && p.segments && o(C, p.segments);
45
+ }, [C, p.segments]);
46
+ let w = d(() => p.kind === "tin-can" ? t("3-gon") : null, [p.kind]), T = d(() => p.kind === "tin-can" ? t("12-gon") : null, [p.kind]), E = d(() => p.kind === "glass-bottle" ? e() : null, [p.kind]), D = d(() => p.kind === "glass-bottle" ? r() : null, [p.kind]);
47
+ u(() => () => {
48
+ w?.dispose(), T?.dispose(), E?.dispose(), D?.dispose();
49
+ }, [
50
+ w,
51
+ T,
52
+ E,
53
+ D
54
+ ]);
55
+ let O = d(() => p.labelId === "custom" && _ ? _ : c(p.labelId), [p.labelId, _]), k = d(() => p.kind === "tin-can" ? i(O) : null, [p.kind, O]);
56
+ u(() => () => {
57
+ k?.forEach((e) => e.dispose());
58
+ }, [k]);
59
+ let A = d(() => {
60
+ if (p.kind === "tin-can") {
61
+ let e = x === "3-gon" ? w : T;
62
+ return e ? n(e) : 0;
63
+ }
64
+ return p.kind === "glass-bottle" ? E ? n(E) : 0 : S ? S.segments.reduce((e, t) => e + t.triCount, 0) : 0;
65
+ }, [
66
+ p.kind,
67
+ x,
68
+ w,
69
+ T,
70
+ E,
71
+ S
72
+ ]), j = !!(p.labelId === "custom" && p.customAlbedoUrl && _), M = S?.halfExtents ?? null, N = S?.fileName ?? "glb";
73
+ return d(() => ({
74
+ effectiveLod: x,
75
+ setActiveLod: g,
76
+ can3Geo: w,
77
+ can12Geo: T,
78
+ canMats: k,
79
+ bottleGeo: E,
80
+ bottleMat: D,
81
+ activeLabelTex: O,
82
+ customLabelLoaded: j,
83
+ importedRoot: C,
84
+ importedHalfExtents: M,
85
+ importedKey: N,
86
+ triCount: A
87
+ }), [
88
+ x,
89
+ w,
90
+ T,
91
+ k,
92
+ E,
93
+ D,
94
+ O,
95
+ j,
96
+ C,
97
+ M,
98
+ N,
99
+ A
100
+ ]);
101
+ }
102
+ export { p as useTargetAssets };
@@ -0,0 +1,26 @@
1
+ import React, { type ReactNode, type RefObject } from "react";
2
+ import * as THREE from "three";
3
+ import { type PhysicsWorldProps } from "@khr3/core";
4
+ import type { World } from "koota";
5
+ export type KolmoTimeControlValue = number | RefObject<number>;
6
+ export type KolmoPointGravity = {
7
+ readonly kind: "point";
8
+ readonly center: readonly [number, number, number];
9
+ readonly surfaceG: number;
10
+ readonly radius: number;
11
+ };
12
+ export type KolmoGravityCallback = (pos: THREE.Vector3, out: THREE.Vector3) => THREE.Vector3;
13
+ export type KolmoGravitySpec = "planar" | "zero" | "custom" | readonly [number, number, number] | KolmoPointGravity | KolmoGravityCallback;
14
+ export declare const KolmoGravityContext: React.Context<boolean>;
15
+ export declare function useOptionalKootaWorld(): World | null;
16
+ export interface KolmoPhysicsProps extends Omit<PhysicsWorldProps, "gravity" | "debug" | "timeScale" | "maxDelta" | "children"> {
17
+ readonly gravity?: KolmoGravitySpec;
18
+ readonly paused?: boolean;
19
+ readonly timeScale?: KolmoTimeControlValue;
20
+ readonly maxDelta?: KolmoTimeControlValue;
21
+ readonly physicsDebug?: boolean;
22
+ readonly world?: World | null;
23
+ readonly children: ReactNode;
24
+ }
25
+ export declare function KolmoPhysics({ gravity, paused, timeScale, maxDelta, physicsDebug, world, children, ...physicsProps }: KolmoPhysicsProps): React.JSX.Element;
26
+ export declare function useIsKolmoCustomGravity(): boolean;