@pinkaphant/kolmo 0.4.4 → 0.4.5

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 (164) hide show
  1. package/README.md +60 -6
  2. package/bin/kolmo.mjs +455 -15
  3. package/dist/engine/index.d.ts +2 -0
  4. package/dist/engine/index.js +7 -5
  5. package/dist/engine/kolmoActions.js +24 -9
  6. package/dist/engine/kolmoActions.js.map +1 -1
  7. package/dist/engine/kolmoActor.js +19 -31
  8. package/dist/engine/kolmoActor.js.map +1 -1
  9. package/dist/engine/kolmoActorHelpers.d.ts +24 -0
  10. package/dist/engine/kolmoActorHelpers.js +64 -0
  11. package/dist/engine/kolmoActorHelpers.js.map +1 -0
  12. package/dist/engine/kolmoGame.js +4 -1
  13. package/dist/engine/kolmoGame.js.map +1 -1
  14. package/dist/engine/kolmoHud.js +34 -15
  15. package/dist/engine/kolmoHud.js.map +1 -1
  16. package/dist/engine/kolmoInput.d.ts +2 -0
  17. package/dist/engine/kolmoInput.js +12 -12
  18. package/dist/engine/kolmoInput.js.map +1 -1
  19. package/dist/engine/kolmoLongDrive.d.ts +1 -1
  20. package/dist/engine/kolmoLongDrive.js +10 -8
  21. package/dist/engine/kolmoLongDrive.js.map +1 -1
  22. package/dist/engine/kolmoPilotMesh.js +189 -48
  23. package/dist/engine/kolmoPilotMesh.js.map +1 -1
  24. package/dist/engine/kolmoTouchOverlay.d.ts +21 -0
  25. package/dist/engine/kolmoTouchOverlay.js +326 -0
  26. package/dist/engine/kolmoTouchOverlay.js.map +1 -0
  27. package/dist/engine/kolmoTouchState.d.ts +50 -0
  28. package/dist/engine/kolmoTouchState.js +210 -0
  29. package/dist/engine/kolmoTouchState.js.map +1 -0
  30. package/dist/engine/kolmoVehicleConfig.d.ts +2 -0
  31. package/dist/engine/kolmoVehicleConfig.js +8 -4
  32. package/dist/engine/kolmoVehicleConfig.js.map +1 -1
  33. package/dist/engine/kolmoVehicleDriver.d.ts +1 -0
  34. package/dist/engine/kolmoVehicleDriver.js +26 -50
  35. package/dist/engine/kolmoVehicleDriver.js.map +1 -1
  36. package/dist/engine/kolmoVehicleInner.js +31 -19
  37. package/dist/engine/kolmoVehicleInner.js.map +1 -1
  38. package/dist/engine/kolmoWorld.js +6 -2
  39. package/dist/engine/kolmoWorld.js.map +1 -1
  40. package/dist/engine/longDriveKit.d.ts +6 -1
  41. package/dist/engine/longDriveKit.js +8 -5
  42. package/dist/engine/longDriveKit.js.map +1 -1
  43. package/dist/engine/macroCellBuilder.d.ts +10 -0
  44. package/dist/engine/macroCellBuilder.js +101 -18
  45. package/dist/engine/macroCellBuilder.js.map +1 -1
  46. package/dist/engine/mainlandMacroCell.js +18 -9
  47. package/dist/engine/mainlandMacroCell.js.map +1 -1
  48. package/dist/importer/DomainWorkshopPanel.d.ts +3 -3
  49. package/dist/importer/DomainWorkshopPanel.js +148 -44
  50. package/dist/importer/DomainWorkshopPanel.js.map +1 -1
  51. package/dist/importer/GateHudBar.d.ts +2 -0
  52. package/dist/importer/GateHudBar.js +113 -35
  53. package/dist/importer/GateHudBar.js.map +1 -1
  54. package/dist/importer/GlbImportGate.js +16 -3
  55. package/dist/importer/GlbImportGate.js.map +1 -1
  56. package/dist/importer/LiveDrivePads.js +5 -3
  57. package/dist/importer/LiveDrivePads.js.map +1 -1
  58. package/dist/importer/Step1CalibrationPlinth.js +2 -2
  59. package/dist/importer/WheelRingHandles3D.js +2 -1
  60. package/dist/importer/WheelRingHandles3D.js.map +1 -1
  61. package/dist/importer/chopShopActions.js +20 -16
  62. package/dist/importer/chopShopActions.js.map +1 -1
  63. package/dist/importer/chopShopHandlers.js +16 -9
  64. package/dist/importer/chopShopHandlers.js.map +1 -1
  65. package/dist/importer/chopShopIoActions.d.ts +2 -0
  66. package/dist/importer/chopShopIoActions.js +33 -2
  67. package/dist/importer/chopShopIoActions.js.map +1 -1
  68. package/dist/importer/cylinderBooleanSlice.js.map +1 -1
  69. package/dist/importer/fusedWheelDetect.d.ts +2 -2
  70. package/dist/importer/fusedWheelDetect.js +227 -106
  71. package/dist/importer/fusedWheelDetect.js.map +1 -1
  72. package/dist/importer/fusedWheelFit.d.ts +6 -0
  73. package/dist/importer/fusedWheelFit.js +82 -1
  74. package/dist/importer/fusedWheelFit.js.map +1 -1
  75. package/dist/importer/gateStore.d.ts +2 -2
  76. package/dist/importer/gateStore.js +4 -3
  77. package/dist/importer/gateStore.js.map +1 -1
  78. package/dist/importer/glbNormalizer.js +5 -0
  79. package/dist/importer/glbNormalizer.js.map +1 -1
  80. package/dist/importer/importerWebMcpTools.js +3 -2
  81. package/dist/importer/importerWebMcpTools.js.map +1 -1
  82. package/dist/importer/index.d.ts +4 -2
  83. package/dist/importer/index.js +7 -3
  84. package/dist/importer/khrCarGeometryMass.d.ts +20 -0
  85. package/dist/importer/khrCarGeometryMass.js +125 -0
  86. package/dist/importer/khrCarGeometryMass.js.map +1 -0
  87. package/dist/importer/khrCarPlanHelpers.js +12 -22
  88. package/dist/importer/khrCarPlanHelpers.js.map +1 -1
  89. package/dist/importer/khrCarPlanner.js +52 -85
  90. package/dist/importer/khrCarPlanner.js.map +1 -1
  91. package/dist/importer/proceduralC12AndCraft.d.ts +18 -0
  92. package/dist/importer/proceduralC12AndCraft.js +302 -0
  93. package/dist/importer/proceduralC12AndCraft.js.map +1 -0
  94. package/dist/importer/proceduralDomainBuilders.d.ts +10 -0
  95. package/dist/importer/proceduralDomainBuilders.js +346 -0
  96. package/dist/importer/proceduralDomainBuilders.js.map +1 -0
  97. package/dist/importer/proceduralPersonAndProp.d.ts +8 -0
  98. package/dist/importer/proceduralPersonAndProp.js +303 -0
  99. package/dist/importer/proceduralPersonAndProp.js.map +1 -0
  100. package/dist/importer/starterScene.d.ts +3 -1
  101. package/dist/importer/starterScene.js +69 -13
  102. package/dist/importer/starterScene.js.map +1 -1
  103. package/dist/importer/universalGateBake.js +43 -11
  104. package/dist/importer/universalGateBake.js.map +1 -1
  105. package/dist/importer/useChopShopController.d.ts +3 -1
  106. package/dist/importer/useChopShopController.js +33 -18
  107. package/dist/importer/useChopShopController.js.map +1 -1
  108. package/dist/importer/useChopShopState.d.ts +1 -1
  109. package/dist/importer/useChopShopState.js +35 -9
  110. package/dist/importer/useChopShopState.js.map +1 -1
  111. package/dist/importer/wheelCutterHelpers.d.ts +7 -4
  112. package/dist/importer/wheelCutterHelpers.js +58 -28
  113. package/dist/importer/wheelCutterHelpers.js.map +1 -1
  114. package/dist/index.d.ts +4 -0
  115. package/dist/index.js +20 -7
  116. package/dist/junk/DestructibleTarget.js +9 -3
  117. package/dist/junk/DestructibleTarget.js.map +1 -1
  118. package/dist/junk/ShardPieces.js +10 -2
  119. package/dist/junk/ShardPieces.js.map +1 -1
  120. package/dist/junk/index.d.ts +1 -0
  121. package/dist/junk/index.js +2 -1
  122. package/dist/junk/junkProceduralScenes.d.ts +12 -0
  123. package/dist/junk/junkProceduralScenes.js +220 -0
  124. package/dist/junk/junkProceduralScenes.js.map +1 -0
  125. package/dist/sand3d/KolmoSand3D.d.ts +19 -0
  126. package/dist/sand3d/KolmoSand3D.js +92 -0
  127. package/dist/sand3d/KolmoSand3D.js.map +1 -0
  128. package/dist/sand3d/Sand3dWorkshopSection.d.ts +8 -0
  129. package/dist/sand3d/Sand3dWorkshopSection.js +117 -0
  130. package/dist/sand3d/Sand3dWorkshopSection.js.map +1 -0
  131. package/dist/sand3d/gateBakeHelpers.d.ts +21 -0
  132. package/dist/sand3d/gateBakeHelpers.js +225 -0
  133. package/dist/sand3d/gateBakeHelpers.js.map +1 -0
  134. package/dist/sand3d/gateDoorwayBake.d.ts +12 -0
  135. package/dist/sand3d/gateDoorwayBake.js +203 -0
  136. package/dist/sand3d/gateDoorwayBake.js.map +1 -0
  137. package/dist/sand3d/index.d.ts +3 -0
  138. package/dist/sand3d/index.js +4 -0
  139. package/dist/sand3d/index.js.map +1 -0
  140. package/dist/sand3d/sand3dAssetLoader.d.ts +28 -0
  141. package/dist/sand3d/sand3dAssetLoader.js +177 -0
  142. package/dist/sand3d/sand3dAssetLoader.js.map +1 -0
  143. package/dist/suika/KolmoSuikaOrb.d.ts +33 -0
  144. package/dist/suika/KolmoSuikaOrb.js +375 -0
  145. package/dist/suika/KolmoSuikaOrb.js.map +1 -0
  146. package/dist/suika/index.d.ts +4 -0
  147. package/dist/suika/index.js +5 -0
  148. package/dist/suika/index.js.map +1 -0
  149. package/dist/suika/suikaArbiter.d.ts +60 -0
  150. package/dist/suika/suikaArbiter.js +265 -0
  151. package/dist/suika/suikaArbiter.js.map +1 -0
  152. package/dist/suika/suikaGeometry.d.ts +10 -0
  153. package/dist/suika/suikaGeometry.js +251 -0
  154. package/dist/suika/suikaGeometry.js.map +1 -0
  155. package/dist/suika/suikaTypes.d.ts +74 -0
  156. package/dist/suika/suikaTypes.js +196 -0
  157. package/dist/suika/suikaTypes.js.map +1 -0
  158. package/dist/world/index.d.ts +1 -1
  159. package/dist/world/index.js +2 -2
  160. package/dist/world/worldTypes.d.ts +4 -0
  161. package/dist/world/worldTypes.js +21 -1
  162. package/dist/world/worldTypes.js.map +1 -1
  163. package/docs/api-reference.md +82 -125
  164. package/package.json +14 -6
@@ -0,0 +1,251 @@
1
+ import { disposeImportedRoot, ensureMeshAttributes, isMeshNode } from "../junk/junkImportSanitize.js";
2
+ import { getSuikaTier } from "./suikaTypes.js";
3
+ import * as THREE from "three";
4
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
5
+ // src/suika/suikaGeometry.ts
6
+ function extractUniqueVertices(geometry) {
7
+ const pos = geometry.getAttribute("position");
8
+ const seen = /* @__PURE__ */ new Set();
9
+ const verts = [];
10
+ for (let i = 0; i < pos.count; i++) {
11
+ const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);
12
+ const key = `${x.toFixed(4)},${y.toFixed(4)},${z.toFixed(4)}`;
13
+ if (!seen.has(key)) {
14
+ seen.add(key);
15
+ verts.push(x, y, z);
16
+ }
17
+ }
18
+ geometry.dispose();
19
+ return verts;
20
+ }
21
+ var UNIT_DODECAHEDRON_VERTS = extractUniqueVertices(new THREE.DodecahedronGeometry(1, 0));
22
+ var UNIT_ICOSAHEDRON_VERTS = extractUniqueVertices(new THREE.IcosahedronGeometry(1, 0));
23
+ var UNIT_GEODESIC1_VERTS = extractUniqueVertices(new THREE.IcosahedronGeometry(1, 1));
24
+ var UNIT_GEODESIC2_VERTS = extractUniqueVertices(new THREE.IcosahedronGeometry(1, 2));
25
+ function getConvexHullVertices(shape, radius) {
26
+ switch (shape) {
27
+ case "pyramid": return new Float32Array([
28
+ 0,
29
+ radius,
30
+ 0,
31
+ 0,
32
+ -radius,
33
+ radius,
34
+ radius,
35
+ -radius,
36
+ 0,
37
+ 0,
38
+ -radius,
39
+ -radius,
40
+ -radius,
41
+ -radius,
42
+ 0
43
+ ]);
44
+ case "octahedron": return new Float32Array([
45
+ radius,
46
+ 0,
47
+ 0,
48
+ -radius,
49
+ 0,
50
+ 0,
51
+ 0,
52
+ radius,
53
+ 0,
54
+ 0,
55
+ -radius,
56
+ 0,
57
+ 0,
58
+ 0,
59
+ radius,
60
+ 0,
61
+ 0,
62
+ -radius
63
+ ]);
64
+ case "dodecahedron": return Float32Array.from(UNIT_DODECAHEDRON_VERTS, (v) => v * radius);
65
+ case "icosahedron": return Float32Array.from(UNIT_ICOSAHEDRON_VERTS, (v) => v * radius);
66
+ case "geodesic1": return Float32Array.from(UNIT_GEODESIC1_VERTS, (v) => v * radius);
67
+ case "geodesic2": return Float32Array.from(UNIT_GEODESIC2_VERTS, (v) => v * radius);
68
+ case "cube":
69
+ case "sphere": return /* @__PURE__ */ new Float32Array(0);
70
+ }
71
+ }
72
+ function buildSuikaOrbGeometry(shape, radius, sphereSegments = 28) {
73
+ switch (shape) {
74
+ case "pyramid": return new THREE.ConeGeometry(radius, radius * 2, 4);
75
+ case "cube": return new THREE.BoxGeometry(radius * 2, radius * 2, radius * 2);
76
+ case "dodecahedron": return new THREE.DodecahedronGeometry(radius, 0);
77
+ case "octahedron": return new THREE.OctahedronGeometry(radius, 0);
78
+ case "icosahedron": return new THREE.IcosahedronGeometry(radius, 0);
79
+ case "geodesic1": return new THREE.IcosahedronGeometry(radius, 1);
80
+ case "geodesic2": return new THREE.IcosahedronGeometry(radius, 2);
81
+ default: return new THREE.SphereGeometry(radius, sphereSegments, sphereSegments);
82
+ }
83
+ }
84
+ function buildSuikaTierScene(tierOrId = 0, options) {
85
+ const tier = getSuikaTier(tierOrId);
86
+ const group = new THREE.Group();
87
+ group.name = `Suika_${tier.code}_${tier.name.replace(/\s+/g, "_")}`;
88
+ group.userData.suikaTier = tier.id;
89
+ const carrier = new THREE.Group();
90
+ carrier.name = `${tier.code}_Carrier`;
91
+ const outerMesh = new THREE.Mesh(buildSuikaOrbGeometry(tier.shape, tier.radius, 32), new THREE.MeshStandardMaterial({
92
+ color: tier.color,
93
+ emissive: tier.emissive,
94
+ emissiveIntensity: tier.emissiveIntensity,
95
+ roughness: tier.roughness,
96
+ metalness: tier.metalness,
97
+ flatShading: true
98
+ }));
99
+ outerMesh.name = `${tier.code}_Shell`;
100
+ const coreMesh = new THREE.Mesh(buildSuikaOrbGeometry(tier.shape, tier.radius * .65, 16), new THREE.MeshBasicMaterial({
101
+ color: tier.emissive,
102
+ transparent: true,
103
+ opacity: .6
104
+ }));
105
+ coreMesh.name = `${tier.code}_Core`;
106
+ carrier.add(outerMesh, coreMesh);
107
+ if (tier.id === 7) {
108
+ const ring = new THREE.Mesh(new THREE.TorusGeometry(tier.radius * 1.25, .12, 12, 32), new THREE.MeshStandardMaterial({
109
+ color: "#ff00aa",
110
+ emissive: "#ff00aa",
111
+ emissiveIntensity: 3
112
+ }));
113
+ ring.name = "T07_PlasmaTorus";
114
+ ring.rotation.set(.5, .5, 0);
115
+ carrier.add(ring);
116
+ } else if (tier.id === 8) {
117
+ const ring = new THREE.Mesh(new THREE.TorusGeometry(tier.radius * 1.35, .18, 12, 36), new THREE.MeshStandardMaterial({
118
+ color: "#ffaa00",
119
+ emissive: "#ffd700",
120
+ emissiveIntensity: 3
121
+ }));
122
+ ring.name = "T08_CoronaTorus";
123
+ ring.rotation.set(1, .4, 0);
124
+ carrier.add(ring);
125
+ } else if (tier.id === 9) {
126
+ const ring = new THREE.Mesh(new THREE.RingGeometry(tier.radius * 1.15, tier.radius * 1.85, 48), new THREE.MeshStandardMaterial({
127
+ color: "#7c4dff",
128
+ emissive: "#aa00ff",
129
+ emissiveIntensity: 4,
130
+ side: THREE.DoubleSide
131
+ }));
132
+ ring.name = "T09_AccretionRing";
133
+ ring.rotation.set(Math.PI / 2, 0, 0);
134
+ carrier.add(ring);
135
+ } else if (tier.id === 10) {
136
+ const lunar = new THREE.Mesh(new THREE.SphereGeometry(tier.radius * 1.002, 36, 36), new THREE.MeshStandardMaterial({
137
+ color: "#cfd8dc",
138
+ roughness: .9,
139
+ metalness: .1
140
+ }));
141
+ lunar.name = "T10_LunarCrust";
142
+ lunar.rotation.set(.4, .8, 0);
143
+ const ring = new THREE.Mesh(new THREE.RingGeometry(tier.radius * 1.3, tier.radius * 1.7, 48), new THREE.MeshBasicMaterial({
144
+ color: "#80deea",
145
+ transparent: true,
146
+ opacity: .65,
147
+ side: THREE.DoubleSide
148
+ }));
149
+ ring.name = "T10_CyanRing";
150
+ ring.rotation.set(.3, .5, 0);
151
+ carrier.add(lunar, ring);
152
+ }
153
+ group.add(carrier);
154
+ if (options?.groundAtZero) {
155
+ group.updateMatrixWorld(true);
156
+ const box = new THREE.Box3().setFromObject(group);
157
+ if (!box.isEmpty()) {
158
+ carrier.position.y -= box.min.y;
159
+ group.updateMatrixWorld(true);
160
+ }
161
+ }
162
+ return group;
163
+ }
164
+ function extractSceneHullVertices(root, maxPoints = 256) {
165
+ root.updateMatrixWorld(true);
166
+ const invRoot = new THREE.Matrix4().copy(root.matrixWorld).invert();
167
+ const rel = new THREE.Matrix4();
168
+ const v = new THREE.Vector3();
169
+ const seen = /* @__PURE__ */ new Set();
170
+ const raw = [];
171
+ root.traverse((obj) => {
172
+ if (!isMeshNode(obj) || !obj.geometry?.attributes?.position) return;
173
+ const pos = obj.geometry.attributes.position;
174
+ rel.multiplyMatrices(invRoot, obj.matrixWorld);
175
+ for (let i = 0; i < pos.count; i++) {
176
+ v.fromBufferAttribute(pos, i).applyMatrix4(rel);
177
+ if (!Number.isFinite(v.x) || !Number.isFinite(v.y) || !Number.isFinite(v.z)) continue;
178
+ const key = `${v.x.toFixed(4)},${v.y.toFixed(4)},${v.z.toFixed(4)}`;
179
+ if (!seen.has(key)) {
180
+ seen.add(key);
181
+ raw.push(v.x, v.y, v.z);
182
+ }
183
+ }
184
+ });
185
+ const totalPts = raw.length / 3;
186
+ if (totalPts <= maxPoints) return new Float32Array(raw);
187
+ const stride = Math.max(1, Math.ceil(totalPts / maxPoints));
188
+ const sampled = [];
189
+ for (let i = 0; i < totalPts; i += stride) sampled.push(raw[i * 3], raw[i * 3 + 1], raw[i * 3 + 2]);
190
+ return new Float32Array(sampled);
191
+ }
192
+ async function parseImportedSuikaGlbBuffer(buffer, tierOrRadius = 0, fileName = "suika_orb.glb") {
193
+ const ab = buffer instanceof Uint8Array ? new Uint8Array(buffer).buffer : buffer;
194
+ if (!ab || ab.byteLength === 0) throw new Error(`Cannot import Suika GLB "${fileName}": empty buffer.`);
195
+ const tier = typeof tierOrRadius === "object" ? tierOrRadius : getSuikaTier(tierOrRadius);
196
+ const targetRadius = typeof tierOrRadius === "number" && tierOrRadius > 0 && !Number.isInteger(tierOrRadius) ? tierOrRadius : tier.radius;
197
+ const gltfScene = (await new GLTFLoader().parseAsync(ab.slice(0), "")).scene;
198
+ let tris = 0, meshCount = 0;
199
+ gltfScene.traverse((obj) => {
200
+ if (isMeshNode(obj) && obj.geometry?.attributes?.position) {
201
+ ensureMeshAttributes(obj, fileName);
202
+ meshCount++;
203
+ const idx = obj.geometry.index;
204
+ tris += idx ? Math.floor(idx.count / 3) : Math.floor(obj.geometry.attributes.position.count / 3);
205
+ }
206
+ });
207
+ if (meshCount === 0) {
208
+ disposeImportedRoot(gltfScene);
209
+ throw new Error(`Suika GLB "${fileName}" contains no renderable meshes.`);
210
+ }
211
+ gltfScene.updateMatrixWorld(true);
212
+ const rawSize = new THREE.Box3().setFromObject(gltfScene).getSize(new THREE.Vector3());
213
+ const maxDim = Math.max(rawSize.x, rawSize.y, rawSize.z);
214
+ if (!Number.isFinite(maxDim) || maxDim <= 1e-6) {
215
+ disposeImportedRoot(gltfScene);
216
+ throw new Error(`Suika GLB "${fileName}" has degenerate bounds.`);
217
+ }
218
+ gltfScene.scale.multiplyScalar(targetRadius * 2 / maxDim);
219
+ gltfScene.updateMatrixWorld(true);
220
+ const normBox = new THREE.Box3().setFromObject(gltfScene);
221
+ const normSize = normBox.getSize(new THREE.Vector3());
222
+ gltfScene.position.sub(normBox.getCenter(new THREE.Vector3()));
223
+ const root = new THREE.Group();
224
+ root.name = fileName;
225
+ root.userData.suikaTier = tier.id;
226
+ root.add(gltfScene);
227
+ root.updateMatrixWorld(true);
228
+ return {
229
+ root,
230
+ fileName,
231
+ tier: tier.id,
232
+ radius: targetRadius,
233
+ hullVertices: extractSceneHullVertices(root),
234
+ bboxSizeM: [
235
+ Number(normSize.x.toFixed(4)),
236
+ Number(normSize.y.toFixed(4)),
237
+ Number(normSize.z.toFixed(4))
238
+ ],
239
+ triCount: tris,
240
+ dispose: () => disposeImportedRoot(root)
241
+ };
242
+ }
243
+ async function loadImportedSuikaGlbUrl(url, tierOrRadius = 0, fileName = "suika_orb.glb") {
244
+ if (!url) throw new Error("No Suika GLB URL provided.");
245
+ const res = await fetch(url);
246
+ if (!res.ok) throw new Error(`Failed to fetch Suika GLB "${fileName}" (${res.status}).`);
247
+ return parseImportedSuikaGlbBuffer(await res.arrayBuffer(), tierOrRadius, fileName);
248
+ }
249
+ export { buildSuikaOrbGeometry, buildSuikaTierScene, extractSceneHullVertices, getConvexHullVertices, loadImportedSuikaGlbUrl, parseImportedSuikaGlbBuffer };
250
+
251
+ //# sourceMappingURL=suikaGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suikaGeometry.js","names":[],"sources":["../../src/suika/suikaGeometry.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { disposeImportedRoot, ensureMeshAttributes, isMeshNode } from \"../junk/junkImportSanitize.js\";\nimport { getSuikaTier, type ImportedSuikaGlbAsset, type OrbShape, type OrbTier } from \"./suikaTypes.js\";\n\nfunction extractUniqueVertices(geometry: THREE.BufferGeometry): number[] {\n const pos = geometry.getAttribute(\"position\");\n const seen = new Set<string>();\n const verts: number[] = [];\n for (let i = 0; i < pos.count; i++) {\n const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);\n const key = `${x.toFixed(4)},${y.toFixed(4)},${z.toFixed(4)}`;\n if (!seen.has(key)) {\n seen.add(key);\n verts.push(x, y, z);\n }\n }\n geometry.dispose();\n return verts;\n}\n\nconst UNIT_DODECAHEDRON_VERTS = extractUniqueVertices(new THREE.DodecahedronGeometry(1, 0));\nconst UNIT_ICOSAHEDRON_VERTS = extractUniqueVertices(new THREE.IcosahedronGeometry(1, 0));\nconst UNIT_GEODESIC1_VERTS = extractUniqueVertices(new THREE.IcosahedronGeometry(1, 1));\nconst UNIT_GEODESIC2_VERTS = extractUniqueVertices(new THREE.IcosahedronGeometry(1, 2));\n\nexport function getConvexHullVertices(shape: OrbShape, radius: number): Float32Array {\n switch (shape) {\n case \"pyramid\":\n return new Float32Array([0, radius, 0, 0, -radius, radius, radius, -radius, 0, 0, -radius, -radius, -radius, -radius, 0]);\n case \"octahedron\":\n return new Float32Array([radius, 0, 0, -radius, 0, 0, 0, radius, 0, 0, -radius, 0, 0, 0, radius, 0, 0, -radius]);\n case \"dodecahedron\":\n return Float32Array.from(UNIT_DODECAHEDRON_VERTS, (v) => v * radius);\n case \"icosahedron\":\n return Float32Array.from(UNIT_ICOSAHEDRON_VERTS, (v) => v * radius);\n case \"geodesic1\":\n return Float32Array.from(UNIT_GEODESIC1_VERTS, (v) => v * radius);\n case \"geodesic2\":\n return Float32Array.from(UNIT_GEODESIC2_VERTS, (v) => v * radius);\n case \"cube\":\n case \"sphere\":\n return new Float32Array(0);\n }\n}\n\nexport function buildSuikaOrbGeometry(shape: OrbShape, radius: number, sphereSegments = 28): THREE.BufferGeometry {\n switch (shape) {\n case \"pyramid\": return new THREE.ConeGeometry(radius, radius * 2, 4);\n case \"cube\": return new THREE.BoxGeometry(radius * 2, radius * 2, radius * 2);\n case \"dodecahedron\": return new THREE.DodecahedronGeometry(radius, 0);\n case \"octahedron\": return new THREE.OctahedronGeometry(radius, 0);\n case \"icosahedron\": return new THREE.IcosahedronGeometry(radius, 0);\n case \"geodesic1\": return new THREE.IcosahedronGeometry(radius, 1);\n case \"geodesic2\": return new THREE.IcosahedronGeometry(radius, 2);\n case \"sphere\":\n default: return new THREE.SphereGeometry(radius, sphereSegments, sphereSegments);\n }\n}\n\nexport function buildSuikaTierScene(\n tierOrId: number | string | OrbTier = 0,\n options?: { readonly groundAtZero?: boolean },\n): THREE.Group {\n const tier = getSuikaTier(tierOrId);\n const group = new THREE.Group();\n group.name = `Suika_${tier.code}_${tier.name.replace(/\\s+/g, \"_\")}`;\n group.userData.suikaTier = tier.id;\n\n const carrier = new THREE.Group();\n carrier.name = `${tier.code}_Carrier`;\n\n const outerMesh = new THREE.Mesh(\n buildSuikaOrbGeometry(tier.shape, tier.radius, 32),\n new THREE.MeshStandardMaterial({\n color: tier.color, emissive: tier.emissive, emissiveIntensity: tier.emissiveIntensity,\n roughness: tier.roughness, metalness: tier.metalness, flatShading: true,\n }),\n );\n outerMesh.name = `${tier.code}_Shell`;\n const coreMesh = new THREE.Mesh(\n buildSuikaOrbGeometry(tier.shape, tier.radius * 0.65, 16),\n new THREE.MeshBasicMaterial({ color: tier.emissive, transparent: true, opacity: 0.6 }),\n );\n coreMesh.name = `${tier.code}_Core`;\n carrier.add(outerMesh, coreMesh);\n\n if (tier.id === 7) {\n const ring = new THREE.Mesh(\n new THREE.TorusGeometry(tier.radius * 1.25, 0.12, 12, 32),\n new THREE.MeshStandardMaterial({ color: \"#ff00aa\", emissive: \"#ff00aa\", emissiveIntensity: 3 }),\n );\n ring.name = \"T07_PlasmaTorus\";\n ring.rotation.set(0.5, 0.5, 0);\n carrier.add(ring);\n } else if (tier.id === 8) {\n const ring = new THREE.Mesh(\n new THREE.TorusGeometry(tier.radius * 1.35, 0.18, 12, 36),\n new THREE.MeshStandardMaterial({ color: \"#ffaa00\", emissive: \"#ffd700\", emissiveIntensity: 3 }),\n );\n ring.name = \"T08_CoronaTorus\";\n ring.rotation.set(1.0, 0.4, 0);\n carrier.add(ring);\n } else if (tier.id === 9) {\n const ring = new THREE.Mesh(\n new THREE.RingGeometry(tier.radius * 1.15, tier.radius * 1.85, 48),\n new THREE.MeshStandardMaterial({ color: \"#7c4dff\", emissive: \"#aa00ff\", emissiveIntensity: 4, side: THREE.DoubleSide }),\n );\n ring.name = \"T09_AccretionRing\";\n ring.rotation.set(Math.PI / 2, 0, 0);\n carrier.add(ring);\n } else if (tier.id === 10) {\n const lunar = new THREE.Mesh(\n new THREE.SphereGeometry(tier.radius * 1.002, 36, 36),\n new THREE.MeshStandardMaterial({ color: \"#cfd8dc\", roughness: 0.9, metalness: 0.1 }),\n );\n lunar.name = \"T10_LunarCrust\";\n lunar.rotation.set(0.4, 0.8, 0);\n const ring = new THREE.Mesh(\n new THREE.RingGeometry(tier.radius * 1.3, tier.radius * 1.7, 48),\n new THREE.MeshBasicMaterial({ color: \"#80deea\", transparent: true, opacity: 0.65, side: THREE.DoubleSide }),\n );\n ring.name = \"T10_CyanRing\";\n ring.rotation.set(0.3, 0.5, 0);\n carrier.add(lunar, ring);\n }\n\n group.add(carrier);\n if (options?.groundAtZero) {\n group.updateMatrixWorld(true);\n const box = new THREE.Box3().setFromObject(group);\n if (!box.isEmpty()) {\n carrier.position.y -= box.min.y;\n group.updateMatrixWorld(true);\n }\n }\n return group;\n}\n\nexport function extractSceneHullVertices(root: THREE.Object3D, maxPoints = 256): Float32Array {\n root.updateMatrixWorld(true);\n const invRoot = new THREE.Matrix4().copy(root.matrixWorld).invert();\n const rel = new THREE.Matrix4();\n const v = new THREE.Vector3();\n const seen = new Set<string>();\n const raw: number[] = [];\n\n root.traverse((obj) => {\n if (!isMeshNode(obj) || !obj.geometry?.attributes?.position) return;\n const pos = obj.geometry.attributes.position;\n rel.multiplyMatrices(invRoot, obj.matrixWorld);\n for (let i = 0; i < pos.count; i++) {\n v.fromBufferAttribute(pos, i).applyMatrix4(rel);\n if (!Number.isFinite(v.x) || !Number.isFinite(v.y) || !Number.isFinite(v.z)) continue;\n const key = `${v.x.toFixed(4)},${v.y.toFixed(4)},${v.z.toFixed(4)}`;\n if (!seen.has(key)) {\n seen.add(key);\n raw.push(v.x, v.y, v.z);\n }\n }\n });\n\n const totalPts = raw.length / 3;\n if (totalPts <= maxPoints) return new Float32Array(raw);\n const stride = Math.max(1, Math.ceil(totalPts / maxPoints));\n const sampled: number[] = [];\n for (let i = 0; i < totalPts; i += stride) sampled.push(raw[i * 3], raw[i * 3 + 1], raw[i * 3 + 2]);\n return new Float32Array(sampled);\n}\n\nexport async function parseImportedSuikaGlbBuffer(\n buffer: ArrayBuffer | Uint8Array,\n tierOrRadius: number | OrbTier = 0,\n fileName = \"suika_orb.glb\",\n): Promise<ImportedSuikaGlbAsset> {\n const ab = buffer instanceof Uint8Array ? new Uint8Array(buffer).buffer : buffer;\n if (!ab || ab.byteLength === 0) throw new Error(`Cannot import Suika GLB \"${fileName}\": empty buffer.`);\n const tier = typeof tierOrRadius === \"object\" ? tierOrRadius : getSuikaTier(tierOrRadius);\n const targetRadius = typeof tierOrRadius === \"number\" && tierOrRadius > 0 && !Number.isInteger(tierOrRadius) ? tierOrRadius : tier.radius;\n\n const gltf = await new GLTFLoader().parseAsync(ab.slice(0), \"\");\n const gltfScene = gltf.scene;\n let tris = 0, meshCount = 0;\n gltfScene.traverse((obj) => {\n if (isMeshNode(obj) && obj.geometry?.attributes?.position) {\n ensureMeshAttributes(obj, fileName);\n meshCount++;\n const idx = obj.geometry.index;\n tris += idx ? Math.floor(idx.count / 3) : Math.floor(obj.geometry.attributes.position.count / 3);\n }\n });\n if (meshCount === 0) {\n disposeImportedRoot(gltfScene);\n throw new Error(`Suika GLB \"${fileName}\" contains no renderable meshes.`);\n }\n\n gltfScene.updateMatrixWorld(true);\n const rawSize = new THREE.Box3().setFromObject(gltfScene).getSize(new THREE.Vector3());\n const maxDim = Math.max(rawSize.x, rawSize.y, rawSize.z);\n if (!Number.isFinite(maxDim) || maxDim <= 1e-6) {\n disposeImportedRoot(gltfScene);\n throw new Error(`Suika GLB \"${fileName}\" has degenerate bounds.`);\n }\n\n gltfScene.scale.multiplyScalar((targetRadius * 2) / maxDim);\n gltfScene.updateMatrixWorld(true);\n const normBox = new THREE.Box3().setFromObject(gltfScene);\n const normSize = normBox.getSize(new THREE.Vector3());\n gltfScene.position.sub(normBox.getCenter(new THREE.Vector3()));\n\n const root = new THREE.Group();\n root.name = fileName;\n root.userData.suikaTier = tier.id;\n root.add(gltfScene);\n root.updateMatrixWorld(true);\n\n return {\n root, fileName, tier: tier.id, radius: targetRadius,\n hullVertices: extractSceneHullVertices(root),\n bboxSizeM: [Number(normSize.x.toFixed(4)), Number(normSize.y.toFixed(4)), Number(normSize.z.toFixed(4))],\n triCount: tris,\n dispose: () => disposeImportedRoot(root),\n };\n}\n\nexport async function loadImportedSuikaGlbUrl(\n url: string,\n tierOrRadius: number | OrbTier = 0,\n fileName = \"suika_orb.glb\",\n): Promise<ImportedSuikaGlbAsset> {\n if (!url) throw new Error(\"No Suika GLB URL provided.\");\n const res = await fetch(url);\n if (!res.ok) throw new Error(`Failed to fetch Suika GLB \"${fileName}\" (${res.status}).`);\n return parseImportedSuikaGlbBuffer(await res.arrayBuffer(), tierOrRadius, fileName);\n}\n"],"mappings":";;;;;AAKA,SAAS,sBAAsB,UAA0C;CACrE,MAAM,MAAM,SAAS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AS,YAAY,KAAK;CAC/B,KAAK,IAAI,SAAS;CAClB,KAAK,kBAAkB,IAAI;CAE3B,OAAO;EACH;EAAM;EAAU,MAAM,KAAK;EAAI,QAAQ;EACvC,cAAc,yBAAyB,IAAI;EAC3C,WAAW;GAAC,OAAO,SAAS,EAAE,QAAQ,CAAC,CAAC;GAAG,OAAO,SAAS,EAAE,QAAQ,CAAC,CAAC;GAAG,OAAO,SAAS,EAAE,QAAQ,CAAC,CAAC;EAAC;EACvG,UAAU;EACV,eAAe,oBAAoB,IAAI;CAC3C;AACJ;AAEA,eAAsB,wBAClB,KACA,eAAiC,GACjC,WAAW,iBACmB;CAC9B,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,4BAA4B;CACtD,MAAM,MAAM,MAAM,MAAM,GAAG;CAC3B,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,8BAA8B,SAAS,KAAK,IAAI,OAAO,GAAG;CACvF,OAAO,4BAA4B,MAAM,IAAI,YAAY,GAAG,cAAc,QAAQ;AACtF"}
@@ -0,0 +1,74 @@
1
+ import type * as THREE from "three";
2
+ export type OrbShape = "pyramid" | "cube" | "dodecahedron" | "octahedron" | "icosahedron" | "geodesic1" | "geodesic2" | "sphere";
3
+ export interface OrbTier {
4
+ readonly id: number;
5
+ readonly code: string;
6
+ readonly name: string;
7
+ readonly radius: number;
8
+ readonly shape: OrbShape;
9
+ readonly color: string;
10
+ readonly emissive: string;
11
+ readonly emissiveIntensity: number;
12
+ readonly roughness: number;
13
+ readonly metalness: number;
14
+ readonly scoreValue: number;
15
+ readonly mass: number;
16
+ readonly description: string;
17
+ }
18
+ export declare const GOLDEN_RATIO = 1.618;
19
+ export declare const ORB_TIERS: readonly OrbTier[];
20
+ export declare function getSuikaTier(tierOrCode?: number | string | OrbTier): OrbTier;
21
+ export declare function matchSuikaTierByRadius(radiusM: number): OrbTier;
22
+ export interface ActiveSuikaOrb {
23
+ readonly id: string;
24
+ readonly tier: number;
25
+ readonly position: [number, number, number];
26
+ readonly velocity?: [number, number, number];
27
+ readonly linearDamping?: number;
28
+ readonly importedUrl?: string | null;
29
+ readonly spawnTime: number;
30
+ }
31
+ export type ActiveOrb = ActiveSuikaOrb;
32
+ export interface SuikaSpawnInput {
33
+ readonly id?: string;
34
+ readonly tier?: number;
35
+ readonly position?: readonly [number, number, number];
36
+ readonly velocity?: readonly [number, number, number];
37
+ readonly linearDamping?: number;
38
+ readonly importedUrl?: string | null;
39
+ }
40
+ export interface SuikaMergeEvent {
41
+ readonly consumedIds: readonly [string, string];
42
+ readonly fromTier: number;
43
+ readonly toTier: number;
44
+ readonly midpoint: readonly [number, number, number];
45
+ readonly spawned: ActiveSuikaOrb;
46
+ readonly scoreGain: number;
47
+ readonly combo: number;
48
+ }
49
+ export interface SuikaBurstEffect {
50
+ readonly id: string;
51
+ readonly position: [number, number, number];
52
+ readonly color: string;
53
+ readonly radius: number;
54
+ readonly createdAt: number;
55
+ }
56
+ export type ParticleBurst = SuikaBurstEffect;
57
+ export interface SuikaScorePopup {
58
+ readonly id: string;
59
+ readonly text: string;
60
+ readonly position: [number, number, number];
61
+ readonly color: string;
62
+ readonly createdAt: number;
63
+ }
64
+ export type FloatingScore = SuikaScorePopup;
65
+ export interface ImportedSuikaGlbAsset {
66
+ readonly root: THREE.Group;
67
+ readonly fileName: string;
68
+ readonly tier: number;
69
+ readonly radius: number;
70
+ readonly hullVertices: Float32Array;
71
+ readonly bboxSizeM: [number, number, number];
72
+ readonly triCount: number;
73
+ readonly dispose: () => void;
74
+ }
@@ -0,0 +1,196 @@
1
+ // src/suika/suikaTypes.ts
2
+ var GOLDEN_RATIO = 1.618;
3
+ var ORB_TIERS = Object.freeze([
4
+ {
5
+ id: 0,
6
+ code: "T00",
7
+ name: "Ruby Core",
8
+ radius: .14,
9
+ shape: "pyramid",
10
+ color: "#ff1744",
11
+ emissive: "#ff5252",
12
+ emissiveIntensity: .7,
13
+ roughness: .15,
14
+ metalness: .3,
15
+ scoreValue: 10,
16
+ mass: 1,
17
+ description: "Base kinetic pyramid."
18
+ },
19
+ {
20
+ id: 1,
21
+ code: "T01",
22
+ name: "Amber Cell",
23
+ radius: .22652,
24
+ shape: "cube",
25
+ color: "#ff6d00",
26
+ emissive: "#ff9100",
27
+ emissiveIntensity: .8,
28
+ roughness: .2,
29
+ metalness: .2,
30
+ scoreValue: 25,
31
+ mass: 2.2,
32
+ description: "Thermal plasma cube."
33
+ },
34
+ {
35
+ id: 2,
36
+ code: "T02",
37
+ name: "Helios Charge",
38
+ radius: .36651,
39
+ shape: "dodecahedron",
40
+ color: "#ffd600",
41
+ emissive: "#ffea00",
42
+ emissiveIntensity: .85,
43
+ roughness: .2,
44
+ metalness: .2,
45
+ scoreValue: 60,
46
+ mass: 4.8,
47
+ description: "Pentagonal dodecahedron condensate."
48
+ },
49
+ {
50
+ id: 3,
51
+ code: "T03",
52
+ name: "Beryl Lattice",
53
+ radius: .59301,
54
+ shape: "octahedron",
55
+ color: "#00e676",
56
+ emissive: "#69f0ae",
57
+ emissiveIntensity: .9,
58
+ roughness: .25,
59
+ metalness: .1,
60
+ scoreValue: 120,
61
+ mass: 10.5,
62
+ description: "Octahedral crystal lattice."
63
+ },
64
+ {
65
+ id: 4,
66
+ code: "T04",
67
+ name: "Cerenkov Drop",
68
+ radius: .95949,
69
+ shape: "icosahedron",
70
+ color: "#00e5ff",
71
+ emissive: "#18ffff",
72
+ emissiveIntensity: 1,
73
+ roughness: .1,
74
+ metalness: .4,
75
+ scoreValue: 250,
76
+ mass: 22,
77
+ description: "Icosahedral coolant core."
78
+ },
79
+ {
80
+ id: 5,
81
+ code: "T05",
82
+ name: "Cobalt Well",
83
+ radius: 1.55246,
84
+ shape: "geodesic1",
85
+ color: "#2979ff",
86
+ emissive: "#448aff",
87
+ emissiveIntensity: 1.1,
88
+ roughness: .15,
89
+ metalness: .5,
90
+ scoreValue: 500,
91
+ mass: 48,
92
+ description: "Geodesic magnetic shell."
93
+ },
94
+ {
95
+ id: 6,
96
+ code: "T06",
97
+ name: "Violet Geode",
98
+ radius: 2.51188,
99
+ shape: "geodesic2",
100
+ color: "#aa00ff",
101
+ emissive: "#e040fb",
102
+ emissiveIntensity: 1.2,
103
+ roughness: .2,
104
+ metalness: .5,
105
+ scoreValue: 1e3,
106
+ mass: 105,
107
+ description: "Subdivided geodesic resonator."
108
+ },
109
+ {
110
+ id: 7,
111
+ code: "T07",
112
+ name: "Magenta Torus",
113
+ radius: 4.06422,
114
+ shape: "sphere",
115
+ color: "#ff007f",
116
+ emissive: "#ff4081",
117
+ emissiveIntensity: 1.5,
118
+ roughness: .05,
119
+ metalness: .7,
120
+ scoreValue: 2500,
121
+ mass: 230,
122
+ description: "Ring-stabilized plasma mass."
123
+ },
124
+ {
125
+ id: 8,
126
+ code: "T08",
127
+ name: "Corona Star",
128
+ radius: 6.57595,
129
+ shape: "sphere",
130
+ color: "#ffab00",
131
+ emissive: "#ffd54f",
132
+ emissiveIntensity: 1.8,
133
+ roughness: .1,
134
+ metalness: .6,
135
+ scoreValue: 5e3,
136
+ mass: 500,
137
+ description: "Self-luminous stellar core."
138
+ },
139
+ {
140
+ id: 9,
141
+ code: "T09",
142
+ name: "Event Horizon",
143
+ radius: 10.63988,
144
+ shape: "sphere",
145
+ color: "#311b92",
146
+ emissive: "#7c4dff",
147
+ emissiveIntensity: 2.2,
148
+ roughness: 0,
149
+ metalness: .9,
150
+ scoreValue: 12e3,
151
+ mass: 1100,
152
+ description: "Accretion-ringed singularity."
153
+ },
154
+ {
155
+ id: 10,
156
+ code: "T10",
157
+ name: "Titania",
158
+ radius: 17.21533,
159
+ shape: "sphere",
160
+ color: "#eceff1",
161
+ emissive: "#80deea",
162
+ emissiveIntensity: 2.5,
163
+ roughness: .35,
164
+ metalness: .4,
165
+ scoreValue: 3e4,
166
+ mass: 2500,
167
+ description: "Satellite-scale orbital body."
168
+ }
169
+ ]);
170
+ function getSuikaTier(tierOrCode = 0) {
171
+ if (typeof tierOrCode === "object" && tierOrCode !== null && "id" in tierOrCode) return tierOrCode;
172
+ if (typeof tierOrCode === "number") return ORB_TIERS[Math.max(0, Math.min(ORB_TIERS.length - 1, Math.trunc(tierOrCode)))];
173
+ const clean = tierOrCode.trim().toLowerCase();
174
+ const codeMatch = /(?:^|[^a-z0-9])t(0\d|10)(?:$|[^a-z0-9])/i.exec(clean);
175
+ if (codeMatch) {
176
+ const idx = Number(codeMatch[1]);
177
+ if (ORB_TIERS[idx]) return ORB_TIERS[idx];
178
+ }
179
+ return ORB_TIERS.find((t) => t.code.toLowerCase() === clean || t.name.toLowerCase() === clean || clean.includes(t.name.toLowerCase().replace(/\s+/g, "_"))) ?? ORB_TIERS[0];
180
+ }
181
+ function matchSuikaTierByRadius(radiusM) {
182
+ if (!Number.isFinite(radiusM) || radiusM <= 0) return ORB_TIERS[0];
183
+ let best = ORB_TIERS[0];
184
+ let bestDiff = Math.abs(best.radius - radiusM);
185
+ for (const t of ORB_TIERS) {
186
+ const d = Math.abs(t.radius - radiusM);
187
+ if (d < bestDiff) {
188
+ best = t;
189
+ bestDiff = d;
190
+ }
191
+ }
192
+ return best;
193
+ }
194
+ export { GOLDEN_RATIO, ORB_TIERS, getSuikaTier, matchSuikaTierByRadius };
195
+
196
+ //# sourceMappingURL=suikaTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suikaTypes.js","names":[],"sources":["../../src/suika/suikaTypes.ts"],"sourcesContent":["import type * as THREE from \"three\";\n\nexport type OrbShape =\n | \"pyramid\"\n | \"cube\"\n | \"dodecahedron\"\n | \"octahedron\"\n | \"icosahedron\"\n | \"geodesic1\"\n | \"geodesic2\"\n | \"sphere\";\n\nexport interface OrbTier {\n readonly id: number;\n readonly code: string;\n readonly name: string;\n readonly radius: number;\n readonly shape: OrbShape;\n readonly color: string;\n readonly emissive: string;\n readonly emissiveIntensity: number;\n readonly roughness: number;\n readonly metalness: number;\n readonly scoreValue: number;\n readonly mass: number;\n readonly description: string;\n}\n\nexport const GOLDEN_RATIO = 1.618;\n\nexport const ORB_TIERS: readonly OrbTier[] = Object.freeze([\n { id: 0, code: \"T00\", name: \"Ruby Core\", radius: 0.14, shape: \"pyramid\", color: \"#ff1744\", emissive: \"#ff5252\", emissiveIntensity: 0.7, roughness: 0.15, metalness: 0.3, scoreValue: 10, mass: 1.0, description: \"Base kinetic pyramid.\" },\n { id: 1, code: \"T01\", name: \"Amber Cell\", radius: 0.22652, shape: \"cube\", color: \"#ff6d00\", emissive: \"#ff9100\", emissiveIntensity: 0.8, roughness: 0.2, metalness: 0.2, scoreValue: 25, mass: 2.2, description: \"Thermal plasma cube.\" },\n { id: 2, code: \"T02\", name: \"Helios Charge\", radius: 0.36651, shape: \"dodecahedron\", color: \"#ffd600\", emissive: \"#ffea00\", emissiveIntensity: 0.85, roughness: 0.2, metalness: 0.2, scoreValue: 60, mass: 4.8, description: \"Pentagonal dodecahedron condensate.\" },\n { id: 3, code: \"T03\", name: \"Beryl Lattice\", radius: 0.59301, shape: \"octahedron\", color: \"#00e676\", emissive: \"#69f0ae\", emissiveIntensity: 0.9, roughness: 0.25, metalness: 0.1, scoreValue: 120, mass: 10.5, description: \"Octahedral crystal lattice.\" },\n { id: 4, code: \"T04\", name: \"Cerenkov Drop\", radius: 0.95949, shape: \"icosahedron\", color: \"#00e5ff\", emissive: \"#18ffff\", emissiveIntensity: 1.0, roughness: 0.1, metalness: 0.4, scoreValue: 250, mass: 22.0, description: \"Icosahedral coolant core.\" },\n { id: 5, code: \"T05\", name: \"Cobalt Well\", radius: 1.55246, shape: \"geodesic1\", color: \"#2979ff\", emissive: \"#448aff\", emissiveIntensity: 1.1, roughness: 0.15, metalness: 0.5, scoreValue: 500, mass: 48.0, description: \"Geodesic magnetic shell.\" },\n { id: 6, code: \"T06\", name: \"Violet Geode\", radius: 2.51188, shape: \"geodesic2\", color: \"#aa00ff\", emissive: \"#e040fb\", emissiveIntensity: 1.2, roughness: 0.2, metalness: 0.5, scoreValue: 1000, mass: 105.0, description: \"Subdivided geodesic resonator.\" },\n { id: 7, code: \"T07\", name: \"Magenta Torus\", radius: 4.06422, shape: \"sphere\", color: \"#ff007f\", emissive: \"#ff4081\", emissiveIntensity: 1.5, roughness: 0.05, metalness: 0.7, scoreValue: 2500, mass: 230.0, description: \"Ring-stabilized plasma mass.\" },\n { id: 8, code: \"T08\", name: \"Corona Star\", radius: 6.57595, shape: \"sphere\", color: \"#ffab00\", emissive: \"#ffd54f\", emissiveIntensity: 1.8, roughness: 0.1, metalness: 0.6, scoreValue: 5000, mass: 500.0, description: \"Self-luminous stellar core.\" },\n { id: 9, code: \"T09\", name: \"Event Horizon\", radius: 10.63988, shape: \"sphere\", color: \"#311b92\", emissive: \"#7c4dff\", emissiveIntensity: 2.2, roughness: 0.0, metalness: 0.9, scoreValue: 12000, mass: 1100.0, description: \"Accretion-ringed singularity.\" },\n { id: 10, code: \"T10\", name: \"Titania\", radius: 17.21533, shape: \"sphere\", color: \"#eceff1\", emissive: \"#80deea\", emissiveIntensity: 2.5, roughness: 0.35, metalness: 0.4, scoreValue: 30000, mass: 2500.0, description: \"Satellite-scale orbital body.\" },\n]);\n\nexport function getSuikaTier(tierOrCode: number | string | OrbTier = 0): OrbTier {\n if (typeof tierOrCode === \"object\" && tierOrCode !== null && \"id\" in tierOrCode) {\n return tierOrCode;\n }\n if (typeof tierOrCode === \"number\") {\n const idx = Math.max(0, Math.min(ORB_TIERS.length - 1, Math.trunc(tierOrCode)));\n return ORB_TIERS[idx];\n }\n const clean = tierOrCode.trim().toLowerCase();\n const codeMatch = /(?:^|[^a-z0-9])t(0\\d|10)(?:$|[^a-z0-9])/i.exec(clean);\n if (codeMatch) {\n const idx = Number(codeMatch[1]);\n if (ORB_TIERS[idx]) return ORB_TIERS[idx];\n }\n return (\n ORB_TIERS.find(\n (t) =>\n t.code.toLowerCase() === clean ||\n t.name.toLowerCase() === clean ||\n clean.includes(t.name.toLowerCase().replace(/\\s+/g, \"_\")),\n ) ?? ORB_TIERS[0]\n );\n}\n\nexport function matchSuikaTierByRadius(radiusM: number): OrbTier {\n if (!Number.isFinite(radiusM) || radiusM <= 0) return ORB_TIERS[0];\n let best = ORB_TIERS[0];\n let bestDiff = Math.abs(best.radius - radiusM);\n for (const t of ORB_TIERS) {\n const d = Math.abs(t.radius - radiusM);\n if (d < bestDiff) {\n best = t;\n bestDiff = d;\n }\n }\n return best;\n}\n\nexport interface ActiveSuikaOrb {\n readonly id: string;\n readonly tier: number;\n readonly position: [number, number, number];\n readonly velocity?: [number, number, number];\n readonly linearDamping?: number;\n readonly importedUrl?: string | null;\n readonly spawnTime: number;\n}\nexport type ActiveOrb = ActiveSuikaOrb;\n\nexport interface SuikaSpawnInput {\n readonly id?: string;\n readonly tier?: number;\n readonly position?: readonly [number, number, number];\n readonly velocity?: readonly [number, number, number];\n readonly linearDamping?: number;\n readonly importedUrl?: string | null;\n}\n\nexport interface SuikaMergeEvent {\n readonly consumedIds: readonly [string, string];\n readonly fromTier: number;\n readonly toTier: number;\n readonly midpoint: readonly [number, number, number];\n readonly spawned: ActiveSuikaOrb;\n readonly scoreGain: number;\n readonly combo: number;\n}\n\nexport interface SuikaBurstEffect {\n readonly id: string;\n readonly position: [number, number, number];\n readonly color: string;\n readonly radius: number;\n readonly createdAt: number;\n}\nexport type ParticleBurst = SuikaBurstEffect;\n\nexport interface SuikaScorePopup {\n readonly id: string;\n readonly text: string;\n readonly position: [number, number, number];\n readonly color: string;\n readonly createdAt: number;\n}\nexport type FloatingScore = SuikaScorePopup;\n\nexport interface ImportedSuikaGlbAsset {\n readonly root: THREE.Group;\n readonly fileName: string;\n readonly tier: number;\n readonly radius: number;\n readonly hullVertices: Float32Array;\n readonly bboxSizeM: [number, number, number];\n readonly triCount: number;\n readonly dispose: () => void;\n}\n"],"mappings":";AA4BA,IAAa,eAAe;AAE5B,IAAa,YAAgC,OAAO,OAAO;CACvD;EAAE,IAAI;EAAG,MAAM;EAAO,MAAM;EAAa,QAAQ;EAAM,OAAO;EAAW,OAAO;EAAW,UAAU;EAAW,mBAA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OAAO,SAAS,OAAO,KAAK,WAAW,GAAG,OAAO,UAAU;CAChE,IAAI,OAAO,UAAU;CACrB,IAAI,WAAW,KAAK,IAAI,KAAK,SAAS,OAAO;CAC7C,KAAK,MAAM,KAAK,WAAW;EACvB,MAAM,IAAI,KAAK,IAAI,EAAE,SAAS,OAAO;EACrC,IAAI,IAAI,UAAU;GACd,OAAO;GACP,WAAW;EACf;CACJ;CACA,OAAO;AACX"}
@@ -3,7 +3,7 @@ export { closedRoadFromPoints, growRoad, maxGrade, roadFromPoints, type GrowRoad
3
3
  export { SHOULDER_K, makeTerrain, sampleHeightfield, type NearestOnRoad, type RoadSplatSample, type Terrain, type TerrainOptions } from "./terrain.js";
4
4
  export { frontage, type FrontageLot, type FrontageOptions } from "./frontage.js";
5
5
  export { makeIslandHeightfn, planIslandWorld, type IslandOptions, type IslandWorldPlan } from "./island.js";
6
- export { SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, hashSeed, type WorldGenConfig, type WorldGenResult } from "./worldTypes.js";
6
+ export { SEED8_ALPHABET, SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, generateSeed8, hashSeed, isValidSeed8, normalizeSeed8, type WorldGenConfig, type WorldGenResult, } from "./worldTypes.js";
7
7
  export { buildDodecagonalCivicHub, routeMacroKnightAStar } from "./macroKnightAStar.js";
8
8
  export { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, InfiniteLongDrivePlanner, MACRO_SIZE_M, TILES_PER_MACRO, quantizeFloatingOrigin192, type FloatingOriginFrame, type MacroCellPlan2D, type MacroSettlementTier, type RoadsideStop2D, type RoadsideStopKind, type SharedBorderPortal, type ZonedParcel2D, } from "./infiniteWorld2D.js";
9
9
  export { buildCarvedTerrainGeometry, buildHighwayAsphaltTexture, buildRoadRibbonGeometry, planDirtSpurs, type BuiltCarvedTerrain, type BuiltRoadRibbon, type CarvedTerrainUvDomain, type RoadRibbonOptions, type TJunctionSpec, } from "./roadRibbon.js";
@@ -5,8 +5,8 @@ import { SHOULDER_K, makeTerrain, sampleHeightfield } from "./terrain.js";
5
5
  import { frontage } from "./frontage.js";
6
6
  import { buildCarvedTerrainGeometry, buildHighwayAsphaltTexture } from "./terrainGeometry.js";
7
7
  import { makeIslandHeightfn, planIslandWorld } from "./island.js";
8
- import { SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, hashSeed } from "./worldTypes.js";
8
+ import { SEED8_ALPHABET, SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, generateSeed8, hashSeed, isValidSeed8, normalizeSeed8 } from "./worldTypes.js";
9
9
  import { buildDodecagonalCivicHub, routeMacroKnightAStar } from "./macroKnightAStar.js";
10
10
  import { InfiniteLongDrivePlanner } from "./infiniteWorld2D.js";
11
11
  import { buildRoadRibbonGeometry, planDirtSpurs } from "./roadRibbon.js";
12
- export { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, InfiniteLongDrivePlanner, MACRO_SIZE_M, SHOULDER_K, SeededSimplex2D, SplitMix32, TILES_PER_MACRO, bakeWorldSplatMaps, buildCarvedTerrainGeometry, buildDodecagonalCivicHub, buildHighwayAsphaltTexture, buildRoadRibbonGeometry, childSeed, closedRoadFromPoints, fbm2, frontage, growRoad, hashSeed, makeIslandHeightfn, makeTerrain, maxGrade, mulberry32, planDirtSpurs, planIslandWorld, quantizeFloatingOrigin192, roadFromPoints, routeMacroKnightAStar, sampleHeightfield, seedFrom, valueNoise2 };
12
+ export { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, InfiniteLongDrivePlanner, MACRO_SIZE_M, SEED8_ALPHABET, SHOULDER_K, SeededSimplex2D, SplitMix32, TILES_PER_MACRO, bakeWorldSplatMaps, buildCarvedTerrainGeometry, buildDodecagonalCivicHub, buildHighwayAsphaltTexture, buildRoadRibbonGeometry, childSeed, closedRoadFromPoints, fbm2, frontage, generateSeed8, growRoad, hashSeed, isValidSeed8, makeIslandHeightfn, makeTerrain, maxGrade, mulberry32, normalizeSeed8, planDirtSpurs, planIslandWorld, quantizeFloatingOrigin192, roadFromPoints, routeMacroKnightAStar, sampleHeightfield, seedFrom, valueNoise2 };
@@ -4,6 +4,10 @@
4
4
  */
5
5
  import type { IslandWorldPlan } from "./island.js";
6
6
  import type { Road } from "./road.js";
7
+ export declare const SEED8_ALPHABET = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
8
+ export declare function isValidSeed8(raw: string): boolean;
9
+ export declare function generateSeed8(rng?: () => number): string;
10
+ export declare function normalizeSeed8(raw: string): string;
7
11
  export declare function hashSeed(seed: string | number): number;
8
12
  export declare class SplitMix32 {
9
13
  private state;
@@ -1,6 +1,26 @@
1
1
  import { childSeed, fbm2 } from "./random.js";
2
2
  import { makeTerrain } from "./terrain.js";
3
3
  // src/world/worldTypes.ts
4
+ var SEED8_ALPHABET = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
5
+ function isValidSeed8(raw) {
6
+ return /^[1-9A-Z]{8}$/.test(raw);
7
+ }
8
+ function generateSeed8(rng = Math.random) {
9
+ let out = "";
10
+ for (let i = 0; i < 8; i++) out += SEED8_ALPHABET[Math.floor(rng() * 35) % 35];
11
+ return out;
12
+ }
13
+ function normalizeSeed8(raw) {
14
+ const cleaned = raw.toUpperCase().replace(/0/g, "O").replace(/[^1-9A-Z]/g, "");
15
+ if (cleaned.length >= 8) return cleaned.slice(0, 8);
16
+ let out = cleaned;
17
+ let h = hashSeed(cleaned || "LONGLINE") >>> 0;
18
+ while (out.length < 8) {
19
+ h = Math.imul(h ^ h >>> 13, 1274126177) + 2654435769 >>> 0;
20
+ out += SEED8_ALPHABET[h % 35];
21
+ }
22
+ return out;
23
+ }
4
24
  function hashSeed(seed) {
5
25
  if (typeof seed === "number") return seed | 0;
6
26
  let h = 2166136261;
@@ -172,6 +192,6 @@ function bakeWorldSplatMaps(plan, gridCells = 256, dirtRoads = []) {
172
192
  alphaMap
173
193
  };
174
194
  }
175
- export { SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, hashSeed };
195
+ export { SEED8_ALPHABET, SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, generateSeed8, hashSeed, isValidSeed8, normalizeSeed8 };
176
196
 
177
197
  //# sourceMappingURL=worldTypes.js.map