@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,249 @@
1
+ import { PALETTE_CRUNCHY_16 as e, PALETTE_CRUNCHY_64 as t, RETRO_COLOR_MODES as n, applyRetroFilteringToMaterial as r, applyRetroTextureFiltering as i, buildPaletteLutData as a, computeRetroDpr as o, getColorQuantVector as s, getPaletteLutTexture as c } from "./retroPalettes.js";
2
+ import * as l from "three";
3
+ // src/shaders/retroShader.ts
4
+ var u = new l.Vector2(320, 180), d = {
5
+ uPs1Grid: { value: u },
6
+ uDitherMix: { value: .62 },
7
+ uSnapStrength: { value: 0 },
8
+ uDitherScale: { value: 2 },
9
+ uColorQuant: { value: s("rgb555") },
10
+ uPaletteLut: { value: c("fallback") },
11
+ uAffineStrength: { value: 0 },
12
+ uGouraudStrength: { value: 0 },
13
+ uN64FilterStrength: { value: 0 },
14
+ uN64TexSize: { value: 256 }
15
+ };
16
+ function f() {
17
+ return {
18
+ uPs1Grid: d.uPs1Grid,
19
+ uDitherMix: d.uDitherMix,
20
+ uSnapStrength: d.uSnapStrength,
21
+ uDitherScale: d.uDitherScale,
22
+ uColorQuant: d.uColorQuant,
23
+ uPaletteLut: d.uPaletteLut,
24
+ uAffineStrength: d.uAffineStrength,
25
+ uGouraudStrength: d.uGouraudStrength,
26
+ uN64FilterStrength: d.uN64FilterStrength,
27
+ uN64TexSize: d.uN64TexSize
28
+ };
29
+ }
30
+ var p = [
31
+ {
32
+ id: "dreamcast",
33
+ label: "Nu-School Dreamcast",
34
+ renderScale: .67,
35
+ ditherAmount: .62,
36
+ pixelSnapAmount: 0,
37
+ colorMode: "rgb555",
38
+ ditherScale: 2,
39
+ affineAmount: 0,
40
+ gouraudAmount: 0,
41
+ n64FilterAmount: 0,
42
+ fogEnabled: !1
43
+ },
44
+ {
45
+ id: "n64-emu-1080p",
46
+ label: "N64 Emu 1080p ('08)",
47
+ renderScale: 1,
48
+ ditherAmount: .32,
49
+ pixelSnapAmount: 0,
50
+ colorMode: "rgb555",
51
+ ditherScale: 1,
52
+ affineAmount: 0,
53
+ gouraudAmount: .9,
54
+ n64FilterAmount: 1,
55
+ fogEnabled: !1
56
+ },
57
+ {
58
+ id: "n64-psx-hybrid",
59
+ label: "N64 Bouba × PSX Kiki",
60
+ renderScale: .56,
61
+ ditherAmount: .78,
62
+ pixelSnapAmount: .55,
63
+ colorMode: "rgb555",
64
+ ditherScale: 2,
65
+ affineAmount: 0,
66
+ gouraudAmount: .65,
67
+ n64FilterAmount: 1,
68
+ fogEnabled: !1
69
+ },
70
+ {
71
+ id: "psx-plus",
72
+ label: "PSX++ Pixel Snap",
73
+ renderScale: .5,
74
+ ditherAmount: .85,
75
+ pixelSnapAmount: .68,
76
+ colorMode: "rgb555",
77
+ ditherScale: 2,
78
+ affineAmount: 0,
79
+ gouraudAmount: .45,
80
+ n64FilterAmount: 0,
81
+ fogEnabled: !1
82
+ },
83
+ {
84
+ id: "ps2-shinobi",
85
+ label: "PS2 Shinobi",
86
+ renderScale: .58,
87
+ ditherAmount: .8,
88
+ pixelSnapAmount: 0,
89
+ colorMode: "rgb555",
90
+ ditherScale: 2,
91
+ affineAmount: 0,
92
+ gouraudAmount: .28,
93
+ n64FilterAmount: 0,
94
+ fogEnabled: !1
95
+ },
96
+ {
97
+ id: "n64-ultra",
98
+ label: "N64 3-Point RDP",
99
+ renderScale: .5,
100
+ ditherAmount: .55,
101
+ pixelSnapAmount: 0,
102
+ colorMode: "rgb555",
103
+ ditherScale: 2,
104
+ affineAmount: 0,
105
+ gouraudAmount: .85,
106
+ n64FilterAmount: 1,
107
+ fogEnabled: !1
108
+ },
109
+ {
110
+ id: "dsi-crisp",
111
+ label: "DSi Crisp",
112
+ renderScale: .5,
113
+ ditherAmount: .88,
114
+ pixelSnapAmount: .35,
115
+ colorMode: "rgb444",
116
+ ditherScale: 2,
117
+ affineAmount: 0,
118
+ gouraudAmount: .2,
119
+ n64FilterAmount: 0,
120
+ fogEnabled: !1
121
+ },
122
+ {
123
+ id: "psx-chonk",
124
+ label: "PSX Full Chonk",
125
+ renderScale: .33,
126
+ ditherAmount: 1,
127
+ pixelSnapAmount: 1,
128
+ colorMode: "rgb555",
129
+ ditherScale: 2.5,
130
+ affineAmount: 0,
131
+ gouraudAmount: .65,
132
+ n64FilterAmount: 0,
133
+ fogEnabled: !1
134
+ },
135
+ {
136
+ id: "psx-raw-1995",
137
+ label: "PSX 1995 Raw Affine",
138
+ renderScale: .33,
139
+ ditherAmount: 1,
140
+ pixelSnapAmount: 1,
141
+ colorMode: "rgb555",
142
+ ditherScale: 2.5,
143
+ affineAmount: 1,
144
+ gouraudAmount: 1,
145
+ n64FilterAmount: 0,
146
+ fogEnabled: !1
147
+ },
148
+ {
149
+ id: "clean-hd",
150
+ label: "HD Remaster 1:1",
151
+ renderScale: 1,
152
+ ditherAmount: 0,
153
+ pixelSnapAmount: 0,
154
+ colorMode: "off",
155
+ ditherScale: 1,
156
+ affineAmount: 0,
157
+ gouraudAmount: 0,
158
+ n64FilterAmount: 0,
159
+ fogEnabled: !1
160
+ }
161
+ ];
162
+ function m(e) {
163
+ return p.find((t) => t.id === e) ?? p[0];
164
+ }
165
+ var h = 1280, g = 720, _ = 1, v = .67, y = 2;
166
+ function b() {
167
+ d.uDitherScale.value = Math.max(1, Math.round(y * _));
168
+ let e = l.MathUtils.clamp((v - .33) / .67, 0, 1), t = d.uSnapStrength.value, n = (180 + e * 180) * (1.18 - t * .46), r = Math.max(1, Math.round(g / Math.max(90, n))), i = h / (2 * r), a = g / (2 * r), o = Math.min(i, a), s = o > 0 && o < 45 ? 45 / o : 1;
169
+ u.set(Math.max(1, Math.round(i * s)), Math.max(1, Math.round(a * s)));
170
+ }
171
+ function x(e, t = 0, n = .67, r, i, a, o, u) {
172
+ if (typeof e == "string") {
173
+ let t = m(e);
174
+ return x(t.ditherAmount, t.pixelSnapAmount, t.renderScale, t.colorMode, t.ditherScale, t.affineAmount, t.gouraudAmount, t.n64FilterAmount), t;
175
+ }
176
+ Number.isFinite(e) && (d.uDitherMix.value = l.MathUtils.clamp(e, 0, 1)), Number.isFinite(t) && (d.uSnapStrength.value = l.MathUtils.clamp(t, 0, 1)), Number.isFinite(n) && (v = l.MathUtils.clamp(n, .33, 1)), r && (s(r, d.uColorQuant.value), d.uPaletteLut.value = c(r === "crunchy16" || r === "crunchy64" ? r : "fallback")), typeof i == "number" && Number.isFinite(i) && (y = l.MathUtils.clamp(i, .5, 6)), typeof a == "number" && Number.isFinite(a) && (d.uAffineStrength.value = l.MathUtils.clamp(a, 0, 1)), typeof o == "number" && Number.isFinite(o) && (d.uGouraudStrength.value = l.MathUtils.clamp(o, 0, 1)), typeof u == "number" && Number.isFinite(u) && (d.uN64FilterStrength.value = l.MathUtils.clamp(u, 0, 1)), b();
177
+ }
178
+ function S(e, t, n) {
179
+ !Number.isFinite(e) || !Number.isFinite(t) || e <= 0 || t <= 0 || (h = e, g = t, Number.isFinite(n) && n > 0 && (_ = n), b());
180
+ }
181
+ var C = "\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n", w = `
182
+ uniform float uDitherScale; uniform vec4 uColorQuant; uniform sampler2D uPaletteLut;
183
+ ${C}
184
+ float ps1BayerDither(vec2 fragCoord) { return ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)); }
185
+ vec3 ps1SamplePaletteLut(vec3 srgb) {
186
+ vec3 c = clamp(srgb, 0.0, 1.0);
187
+ return texture2D(uPaletteLut, vec2((floor(c.b * 31.0 + 0.5) * 32.0 + floor(c.r * 31.0 + 0.5) + 0.5) / 1024.0, (floor(c.g * 31.0 + 0.5) + 0.5) / 32.0)).rgb;
188
+ }
189
+ vec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {
190
+ if (uColorQuant.w < 0.5) return col;
191
+ vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)), spread = clamp(ditherSpread, 0.0, 1.0);
192
+ if (uColorQuant.w > 1.5) return ps1SamplePaletteLut(ps1LinearToSrgb(clamp(ps1SrgbToLinear(srgb) + (bayer - 0.5) * (uColorQuant.y * spread), 0.0, 1.0)));
193
+ vec3 levels = max(uColorQuant.rgb, vec3(1.0)), c0 = floor(srgb * levels) / levels, c1 = min(c0 + 1.0 / levels, vec3(1.0));
194
+ vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);
195
+ vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);
196
+ return mix(c0, c1, step(vec3(mix(0.5, bayer, spread)), t));
197
+ }
198
+ vec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStrength) {
199
+ vec4 nearestSample = texture2D(tex, uv);
200
+ if (mixStrength <= 0.001) return nearestSample;
201
+ float ts = max(16.0, texSize);
202
+ vec2 p = uv * ts - 0.5;
203
+ vec2 i = floor(p);
204
+ vec2 f = p - i;
205
+ vec2 inv = 1.0 / vec2(ts);
206
+ vec2 uv00 = (i + vec2(0.5, 0.5)) * inv;
207
+ vec2 uv10 = (i + vec2(1.5, 0.5)) * inv;
208
+ vec2 uv01 = (i + vec2(0.5, 1.5)) * inv;
209
+ vec2 uv11 = (i + vec2(1.5, 1.5)) * inv;
210
+ vec4 c10 = texture2D(tex, uv10);
211
+ vec4 c01 = texture2D(tex, uv01);
212
+ vec4 n64Col;
213
+ if (f.x + f.y < 1.0) {
214
+ vec4 c00 = texture2D(tex, uv00);
215
+ n64Col = c00 + f.x * (c10 - c00) + f.y * (c01 - c00);
216
+ } else {
217
+ vec4 c11 = texture2D(tex, uv11);
218
+ n64Col = c11 + (1.0 - f.y) * (c10 - c11) + (1.0 - f.x) * (c01 - c11);
219
+ }
220
+ return mix(nearestSample, n64Col, clamp(mixStrength, 0.0, 1.0));
221
+ }
222
+ `, T = /* @__PURE__ */ new WeakSet();
223
+ function E(e, t) {
224
+ if (!e || T.has(e)) return e;
225
+ T.add(e), e.userData.__kolmoRetroApplied = !0, t?.flatShading !== !1 && "flatShading" in e && (e.flatShading = !0);
226
+ let n = e.onBeforeCompile, r = Object.prototype.hasOwnProperty.call(e, "customProgramCacheKey") ? e.customProgramCacheKey : null, i = t?.snap === void 0 ? d.uSnapStrength : { value: t.snap }, a = t?.dither === void 0 ? d.uDitherMix : { value: t.dither };
227
+ return e.onBeforeCompile = (t, r) => {
228
+ n && n.call(e, t, r), Object.assign(t.uniforms, {
229
+ uPs1Grid: d.uPs1Grid,
230
+ uSnapStrength: i,
231
+ uDitherMix: a,
232
+ uDitherScale: d.uDitherScale,
233
+ uColorQuant: d.uColorQuant,
234
+ uPaletteLut: d.uPaletteLut,
235
+ uAffineStrength: d.uAffineStrength,
236
+ uGouraudStrength: d.uGouraudStrength,
237
+ uN64FilterStrength: d.uN64FilterStrength,
238
+ uN64TexSize: d.uN64TexSize
239
+ }), t.vertexShader = "uniform vec2 uPs1Grid;\nuniform float uSnapStrength;\nuniform float uAffineStrength;\nuniform float uGouraudStrength;\nvarying float vRetroAffineW;\nvarying vec3 vRetroGouraud;\n" + t.vertexShader.replace("#include <project_vertex>", "#include <project_vertex>\n{\n vRetroAffineW = 1.0;\n vRetroGouraud = vec3(1.0);\n if (uSnapStrength > 0.001 && gl_Position.w > 0.001) {\n vec4 snapped = gl_Position; snapped.xyz = gl_Position.xyz / gl_Position.w;\n vec2 ps1SafeGrid = max(uPs1Grid, vec2(1.0));\n snapped.xy = mix(snapped.xy, floor(ps1SafeGrid * snapped.xy + 0.5) / ps1SafeGrid, uSnapStrength);\n snapped.xyz *= gl_Position.w; gl_Position = snapped;\n }\n #ifdef USE_MAP\n if (uAffineStrength > 0.001 && gl_Position.w > 0.001) {\n float ps1W = mix(1.0, max(gl_Position.w, 0.05), uAffineStrength);\n vMapUv *= ps1W; vRetroAffineW = ps1W;\n }\n #endif\n #ifdef USE_NORMAL\n #ifndef FLAT_SHADED\n if (uGouraudStrength > 0.001) {\n vec3 gN = normalize(vNormal);\n vec3 gKey = normalize(vec3(-0.55, 0.72, 0.42));\n vec3 gRim = normalize(vec3(0.58, -0.25, -0.77));\n float gDiff = max(dot(gN, gKey), 0.0) * 0.78 + max(dot(gN, gRim), 0.0) * 0.28 + 0.26;\n float gSpec = pow(max(dot(reflect(-gKey, gN), vec3(0.0, 0.0, 1.0)), 0.0), 14.0) * 0.36;\n vRetroGouraud = mix(vec3(1.0), vec3(gDiff + gSpec), uGouraudStrength);\n }\n #endif\n #endif\n}"), t.fragmentShader = `uniform float uDitherMix;\nuniform float uAffineStrength;\nuniform float uGouraudStrength;\nuniform float uN64FilterStrength;\nuniform float uN64TexSize;\nvarying float vRetroAffineW;\nvarying vec3 vRetroGouraud;\n${w}\n` + t.fragmentShader.replace("#include <map_fragment>", "#ifdef USE_MAP\n{\n vec2 ps1Uv = (uAffineStrength > 0.001 && vRetroAffineW > 0.0001) ? (vMapUv / vRetroAffineW) : vMapUv;\n diffuseColor *= ps1SampleN64ThreePoint( map, ps1Uv, uN64TexSize, uN64FilterStrength );\n}\n#endif").replace("#include <dithering_fragment>", "gl_FragColor.rgb *= mix(vec3(1.0), vRetroGouraud, uGouraudStrength);\ngl_FragColor.rgb = ps1QuantizeRetro(gl_FragColor.rgb, gl_FragCoord.xy, uDitherMix);");
240
+ }, e.customProgramCacheKey = () => r ? `${r.call(e)}_dream_nuschool_retro_v3` : "dream_nuschool_retro_v3", e.needsUpdate = !0, e;
241
+ }
242
+ var D = E;
243
+ function O(e, t) {
244
+ e.traverse((e) => {
245
+ let n = e;
246
+ if (n.isMesh && n.material) for (let e of Array.isArray(n.material) ? n.material : [n.material]) e.isShaderMaterial || E(e, t);
247
+ });
248
+ }
249
+ export { C as GLSL_BAYER_RGB555, w as GLSL_RETRO_QUANTIZE, e as PALETTE_CRUNCHY_16, t as PALETTE_CRUNCHY_64, u as PS1_SNAP_RESOLUTION, n as RETRO_COLOR_MODES, p as RETRO_PRESETS, d as RETRO_UNIFORMS, D as applyPs1Material, r as applyRetroFilteringToMaterial, E as applyRetroMaterial, i as applyRetroTextureFiltering, O as applySceneRetroMaterials, a as buildPaletteLutData, o as computeRetroDpr, s as getColorQuantVector, c as getPaletteLutTexture, m as getRetroPreset, f as getRetroShaderUniforms, x as syncRetroUniforms, S as syncRetroViewport };
@@ -0,0 +1 @@
1
+ export { createPS2RoadMaterialTSL, createPS2TerrainMaterialTSL, } from "./ps2MaterialsTSL.js";
@@ -0,0 +1 @@
1
+ export { createPS2RoadMaterialTSL, createPS2TerrainMaterialTSL } from "./ps2MaterialsTSL.js";
@@ -0,0 +1,15 @@
1
+ import type { Plugin, UserConfig } from "vite";
2
+ /**
3
+ * Extracts `@dimforge/rapier3d-compat`'s ~2.09 MB base64-inlined WASM string out of the JS bundle
4
+ * and emits `rapier_wasm3d_bg.wasm` (~1.53 MB) initialized via `{ module_or_path }` with concurrent-init deduplication.
5
+ */
6
+ export declare function externalizeRapierWasm(): Plugin;
7
+ export declare const KOLMO_SINGLETON_DEDUPE: string[];
8
+ /**
9
+ * Cycle-free DAG leaf chunk splitting for Vite 8 Rolldown:
10
+ * Layer 0 (pure leaves): `vendor-react`, `vendor-rapier`, `vendor-three`
11
+ * Layer 1 (R3F + core state): `vendor-r3f` (`@react-three/fiber`, `drei`, `koota`, `zustand`)
12
+ * Layer 2 (domain leaves above R3F): `vendor-physics` (`rapier`, `ecctrl`, `@khr3/*`), `vendor-uikit` (`uikit*`, `signals`, `yoga`)
13
+ * Layer 3 (engine): `vendor-kolmo` (`@pinkaphant/kolmo`)
14
+ */
15
+ export declare const KOLMO_ROLLDOWN_BUILD: NonNullable<UserConfig["build"]>;
@@ -0,0 +1,90 @@
1
+ import e from "node:fs";
2
+ import t from "node:path";
3
+ // src/vite/index.ts
4
+ function n() {
5
+ return {
6
+ name: "kolmo-externalize-rapier-wasm",
7
+ apply: "build",
8
+ transform(n, r) {
9
+ if (!r.replace(/\\/g, "/").endsWith("/@dimforge/rapier3d-compat/rapier.mjs")) return null;
10
+ let i = t.join(t.dirname(r), "rapier_wasm3d_bg.wasm");
11
+ if (!e.existsSync(i)) throw Error(`kolmo-externalize-rapier-wasm: missing ${i}`);
12
+ let a = this.emitFile({
13
+ type: "asset",
14
+ name: "rapier_wasm3d_bg.wasm",
15
+ source: e.readFileSync(i)
16
+ }), o = n.replace(/([\w$]+)\([\w$]+\.toByteArray\(["']AGFzbQE[A-Za-z0-9+/=]+["']\)\.buffer\)/, `(globalThis.__kolmoRapierWasmInit ??= $1({ module_or_path: import.meta.ROLLUP_FILE_URL_${a} }))`);
17
+ if (o === n && (o = n.replace(/[\w$]+\.toByteArray\(["']AGFzbQE[A-Za-z0-9+/=]+["']\)\.buffer/, `{ module_or_path: import.meta.ROLLUP_FILE_URL_${a} }`)), o === n) throw Error("kolmo-externalize-rapier-wasm: inline WASM payload not found in rapier.mjs");
18
+ return {
19
+ code: o,
20
+ map: null
21
+ };
22
+ }
23
+ };
24
+ }
25
+ var r = [
26
+ "react",
27
+ "react-dom",
28
+ "three",
29
+ "@react-three/fiber",
30
+ "@react-three/drei",
31
+ "@react-three/rapier",
32
+ "@react-three/uikit",
33
+ "@pmndrs/uikit",
34
+ "@pmndrs/uikit-pub-sub",
35
+ "@preact/signals-core",
36
+ "@dimforge/rapier3d-compat",
37
+ "@pinkaphant/ecctrl",
38
+ "@khr3/core",
39
+ "@khr3/c12",
40
+ "koota",
41
+ "maath",
42
+ "zustand"
43
+ ], i = {
44
+ chunkSizeWarningLimit: 1100,
45
+ rolldownOptions: { output: { codeSplitting: { groups: [
46
+ {
47
+ name: "vendor-react",
48
+ test: /[\\/]node_modules[\\/](react|react-dom|scheduler|use-sync-external-store)[\\/]/,
49
+ priority: 60,
50
+ includeDependenciesRecursively: !1
51
+ },
52
+ {
53
+ name: "vendor-rapier",
54
+ test: /[\\/]node_modules[\\/]@dimforge[\\/]rapier3d-compat[\\/]/,
55
+ priority: 55,
56
+ includeDependenciesRecursively: !1
57
+ },
58
+ {
59
+ name: "vendor-three",
60
+ test: /[\\/]node_modules[\\/](three|three-stdlib|maath|camera-controls|meshline)[\\/]/,
61
+ priority: 50,
62
+ includeDependenciesRecursively: !1
63
+ },
64
+ {
65
+ name: "vendor-uikit",
66
+ test: /[\\/]node_modules[\\/](@react-three[\\/]uikit(?:-[^\\/]+)?|@pmndrs[\\/](?:uikit(?:-[^\\/]+)?|pointer-events|msdf-loader)|@preact[\\/]signals-core|yoga-layout)[\\/]/,
67
+ priority: 40,
68
+ includeDependenciesRecursively: !1
69
+ },
70
+ {
71
+ name: "vendor-physics",
72
+ test: /[\\/]node_modules[\\/](@react-three[\\/]rapier|@pinkaphant[\\/]ecctrl|@khr3[\\/][^\\/]+)[\\/]/,
73
+ priority: 35,
74
+ includeDependenciesRecursively: !1
75
+ },
76
+ {
77
+ name: "vendor-kolmo",
78
+ test: /[\\/]node_modules[\\/]@pinkaphant[\\/]kolmo[\\/]/,
79
+ priority: 30,
80
+ includeDependenciesRecursively: !1
81
+ },
82
+ {
83
+ name: "vendor-r3f",
84
+ test: (e) => e === "\0vite/preload-helper.js" || /[\\/]node_modules[\\/]/.test(e),
85
+ priority: 10,
86
+ includeDependenciesRecursively: !1
87
+ }
88
+ ] } } }
89
+ };
90
+ export { i as KOLMO_ROLLDOWN_BUILD, r as KOLMO_SINGLETON_DEDUPE, n as externalizeRapierWasm };
@@ -0,0 +1,32 @@
1
+ // src/world/frontage.ts
2
+ function e(e, t) {
3
+ if (!(t.spacing > 0) || !(t.setback >= 0)) throw RangeError("frontage: spacing must be > 0 and setback >= 0");
4
+ let n = t.margin ?? t.spacing / 2, r = t.sides ?? ["left", "right"], i = [];
5
+ for (let a = n; a <= e.length - n + 1e-9; a += t.spacing) {
6
+ let n = e.at(a);
7
+ for (let o of r) {
8
+ let r = (o === "left" ? 1 : -1) * (e.halfWidth + t.setback);
9
+ i.push({
10
+ s: a,
11
+ side: o,
12
+ front: [
13
+ n.pos[0] + n.left[0] * r,
14
+ n.pos[1],
15
+ n.pos[2] + n.left[2] * r
16
+ ],
17
+ facing: o === "left" ? [
18
+ -n.left[0],
19
+ 0,
20
+ -n.left[2]
21
+ ] : [
22
+ n.left[0],
23
+ 0,
24
+ n.left[2]
25
+ ],
26
+ groundY: n.pos[1]
27
+ });
28
+ }
29
+ }
30
+ return i;
31
+ }
32
+ export { e as frontage };
@@ -6,4 +6,4 @@ export { makeIslandHeightfn, planIslandWorld, type IslandOptions, type IslandWor
6
6
  export { SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, hashSeed, 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
- export { buildCarvedTerrainGeometry, buildHighwayAsphaltTexture, buildRoadRibbonGeometry, planDirtSpurs, type BuiltCarvedTerrain, type BuiltRoadRibbon, type RoadRibbonOptions, type TJunctionSpec, } from "./roadRibbon.js";
9
+ export { buildCarvedTerrainGeometry, buildHighwayAsphaltTexture, buildRoadRibbonGeometry, planDirtSpurs, type BuiltCarvedTerrain, type BuiltRoadRibbon, type CarvedTerrainUvDomain, type RoadRibbonOptions, type TJunctionSpec, } from "./roadRibbon.js";
@@ -1,3 +1,11 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../worldTypes-Z0KfdCd0.js";
2
- import { _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, l as x, m as S, n as C, o as w, p as T, r as E, s as D, t as O, u as k, v as A, y as j } from "../world-PRWPYrlx.js";
3
- export { w as C12TileKind, D as C12_TILE_M, h as FLOATING_ORIGIN_STEP_M, p as InfiniteLongDrivePlanner, x as MACRO_SIZE_M, e as SHOULDER_K, u as SeededSimplex2D, o as SplitMix32, k as TILES_PER_MACRO, c as bakeWorldSplatMaps, O as buildCarvedTerrainGeometry, _ as buildDodecagonalCivicHub, C as buildHighwayAsphaltTexture, E as buildRoadRibbonGeometry, t as childSeed, f as closedRoadFromPoints, a as fbm2, v as frontage, A as growRoad, i as hashSeed, S as makeIslandHeightfn, s as makeTerrain, j as maxGrade, d as mulberry32, b as planDirtSpurs, y as planIslandWorld, g as quantizeFloatingOrigin192, m as roadFromPoints, T as routeMacroKnightAStar, l as sampleHeightfield, n as seedFrom, r as valueNoise2 };
1
+ import { childSeed as e, fbm2 as t, mulberry32 as n, seedFrom as r, valueNoise2 as i } from "./random.js";
2
+ import { closedRoadFromPoints as a, growRoad as o, maxGrade as s, roadFromPoints as c } from "./road.js";
3
+ import { SHOULDER_K as l, makeTerrain as u, sampleHeightfield as d } from "./terrain.js";
4
+ import { frontage as f } from "./frontage.js";
5
+ import { makeIslandHeightfn as p, planIslandWorld as m } from "./island.js";
6
+ import { SeededSimplex2D as h, SplitMix32 as g, bakeWorldSplatMaps as _, hashSeed as v } from "./worldTypes.js";
7
+ import { buildDodecagonalCivicHub as y, routeMacroKnightAStar as b } from "./macroKnightAStar.js";
8
+ import { C12TileKind as x, C12_TILE_M as S, FLOATING_ORIGIN_STEP_M as C, MACRO_SIZE_M as w, TILES_PER_MACRO as T, quantizeFloatingOrigin192 as E } from "./macroCellSchema.js";
9
+ import { InfiniteLongDrivePlanner as D } from "./infiniteWorld2D.js";
10
+ import { buildCarvedTerrainGeometry as O, buildHighwayAsphaltTexture as k, buildRoadRibbonGeometry as A, planDirtSpurs as j } from "./roadRibbon.js";
11
+ export { x as C12TileKind, S as C12_TILE_M, C as FLOATING_ORIGIN_STEP_M, D as InfiniteLongDrivePlanner, w as MACRO_SIZE_M, l as SHOULDER_K, h as SeededSimplex2D, g as SplitMix32, T as TILES_PER_MACRO, _ as bakeWorldSplatMaps, O as buildCarvedTerrainGeometry, y as buildDodecagonalCivicHub, k as buildHighwayAsphaltTexture, A as buildRoadRibbonGeometry, e as childSeed, a as closedRoadFromPoints, t as fbm2, f as frontage, o as growRoad, v as hashSeed, p as makeIslandHeightfn, u as makeTerrain, s as maxGrade, n as mulberry32, j as planDirtSpurs, m as planIslandWorld, E as quantizeFloatingOrigin192, c as roadFromPoints, b as routeMacroKnightAStar, d as sampleHeightfield, r as seedFrom, i as valueNoise2 };
@@ -0,0 +1,244 @@
1
+ import { C12TileKind as e, C12_TILE_M as t, FLOATING_ORIGIN_STEP_M as n, MACRO_SIZE_M as r, TILES_PER_MACRO as i, quantizeFloatingOrigin192 as a } from "./macroCellSchema.js";
2
+ import { buildDodecagonalCivicHub as o, routeMacroKnightAStar as s } from "./macroKnightAStar.js";
3
+ import { SeededSimplex2D as c, SplitMix32 as l, hashSeed as u } from "./worldTypes.js";
4
+ // src/world/infiniteWorld2D.ts
5
+ function d(e, t, n, r) {
6
+ let i = e ^ Math.imul(t, 374761393) ^ Math.imul(n, 668265263) ^ Math.imul(r, 1442695041);
7
+ return i = Math.imul(i ^ i >>> 13, 1274126177), (i ^ i >>> 16) >>> 0;
8
+ }
9
+ var f = (e) => Math.round(e / 3) * 3, p = (e, t, n) => {
10
+ let r = Math.max(0, Math.min(1, (n - e) / (t - e)));
11
+ return r * r * (3 - 2 * r);
12
+ }, m = class {
13
+ seedInt;
14
+ popNoise;
15
+ zoneNoise;
16
+ elevNoise;
17
+ windDir;
18
+ constructor(e) {
19
+ this.seedInt = u(e), this.popNoise = new c(this.seedInt ^ 324508639), this.zoneNoise = new c(this.seedInt ^ 610839776), this.elevNoise = new c(this.seedInt ^ 3735928559);
20
+ let t = (this.seedInt & 65535) / 65536 * Math.PI * 2;
21
+ this.windDir = [Math.cos(t), Math.sin(t)];
22
+ }
23
+ sampleMainlandHeight(e, t) {
24
+ if (e < 980 && Math.hypot(e, t) > 680) {
25
+ let t = p(820, 1080, e);
26
+ return -11 * (1 - t) + t * 3.2;
27
+ }
28
+ let n = this.elevNoise.noise2D(e * 55e-5, t * 55e-5) * 22, r = this.elevNoise.noise2D(e * .0024 + 31.7, t * .0024 - 14.2) * 5.5;
29
+ return 6.5 + n + r;
30
+ }
31
+ evalVerticalBorder(e, t) {
32
+ if (e === 0 && t === 0) return {
33
+ exists: !0,
34
+ isBridgeCauseway: !0,
35
+ offsetMeters: 0
36
+ };
37
+ if (e <= 0 && Math.abs(t) <= 1) return {
38
+ exists: !1,
39
+ isBridgeCauseway: !1,
40
+ offsetMeters: 0
41
+ };
42
+ let n = new l(d(this.seedInt, e, t, 17)), i = t === 0 && e >= 0;
43
+ if (!i && n.next() >= .68) return {
44
+ exists: !1,
45
+ isBridgeCauseway: !1,
46
+ offsetMeters: 0
47
+ };
48
+ let a = e * r + r * .5, o = t * r, s = 0, c = Infinity;
49
+ for (let e = -4; e <= 4; e++) {
50
+ let t = e * 144 + n.range(-48, 48), r = Math.abs(this.elevNoise.noise2D(a * 6e-4, (o + t) * 6e-4));
51
+ r < c && (c = r, s = f(t));
52
+ }
53
+ return {
54
+ exists: !0,
55
+ isBridgeCauseway: !1,
56
+ offsetMeters: i ? f(s * .4) : s
57
+ };
58
+ }
59
+ evalHorizontalBorder(e, t) {
60
+ if (e <= 0 && e >= -1 && (t === 0 || t === -1)) return {
61
+ exists: !1,
62
+ isBridgeCauseway: !1,
63
+ offsetMeters: 0
64
+ };
65
+ let n = new l(d(this.seedInt, e, t, 34));
66
+ if (n.next() >= .68) return {
67
+ exists: !1,
68
+ isBridgeCauseway: !1,
69
+ offsetMeters: 0
70
+ };
71
+ let i = t * r + r * .5, a = e * r, o = 0, s = Infinity;
72
+ for (let e = -4; e <= 4; e++) {
73
+ let t = Math.round((e * 144 + n.range(-48, 48)) / 48) * 48, r = Math.abs(this.elevNoise.noise2D((a + t) * 6e-4, i * 6e-4));
74
+ r < s && (s = r, o = t);
75
+ }
76
+ return {
77
+ exists: !0,
78
+ isBridgeCauseway: !1,
79
+ offsetMeters: o
80
+ };
81
+ }
82
+ rawPopScore(e, t) {
83
+ if (e <= 0 && Math.abs(t) <= 1) return 0;
84
+ let n = this.popNoise.noise2D(e * .23, t * .23) * .5 + .5, r = this.popNoise.noise2D(e * .61 + 19.4, t * .61 - 7.2) * .5 + .5, i = d(this.seedInt, e, t, 51) % 1e3 / 8e3;
85
+ return Math.min(1, n * .64 + r * .34 + i);
86
+ }
87
+ isMetropolisPeak(e, t) {
88
+ if (e < 2 && Math.abs(t) < 2) return !1;
89
+ let n = this.rawPopScore(e, t);
90
+ if (n < .86) return !1;
91
+ for (let r = -2; r <= 2; r++) for (let i = -2; i <= 2; i++) if ((i !== 0 || r !== 0) && this.rawPopScore(e + i, t + r) >= n) return !1;
92
+ return !0;
93
+ }
94
+ isCityPeak(e, t) {
95
+ if (e === 0 && t === 0) return !1;
96
+ let n = this.rawPopScore(e, t);
97
+ if (n < .72 || this.isMetropolisPeak(e, t)) return !1;
98
+ for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) if ((i !== 0 || r !== 0) && this.rawPopScore(e + i, t + r) >= n) return !1;
99
+ return !0;
100
+ }
101
+ resolveSettlementTier(e, t, n) {
102
+ if (e === 0 && t === 0) return "ISLAND_RING";
103
+ if (n === 0) return "NONE_HIGHWAY";
104
+ if (this.isMetropolisPeak(e, t)) return "METROPOLIS";
105
+ for (let n = -1; n <= 1; n++) for (let r = -1; r <= 1; r++) if ((r !== 0 || n !== 0) && this.isMetropolisPeak(e + r, t + n)) return "SUBURBS_BIG_TOWN";
106
+ if (this.isCityPeak(e, t)) return "CITY";
107
+ let r = this.rawPopScore(e, t);
108
+ return r >= .62 && n >= 2 ? "SUBURBS_BIG_TOWN" : r >= .48 && n >= 3 ? "SMALL_TOWN" : r >= .36 && n >= 2 ? "VILLAGE" : "NONE_HIGHWAY";
109
+ }
110
+ generateMacroCell2D(e, t) {
111
+ let n = e * r, i = t * r, a = r * .5, c = this.evalHorizontalBorder(e, t - 1), u = this.evalHorizontalBorder(e, t), p = this.evalVerticalBorder(e - 1, t), m = this.evalVerticalBorder(e, t), h = +!!c.exists + +!!u.exists + +!!p.exists + +!!m.exists, g = this.resolveSettlementTier(e, t, h), _ = new l(d(this.seedInt, e, t, 119)), v = n + (g === "METROPOLIS" || g === "ISLAND_RING" ? 0 : Math.round(_.range(-240, 240) / 48) * 48), y = i + (g === "METROPOLIS" || g === "ISLAND_RING" ? 0 : Math.round(_.range(-240, 240) / 48) * 48), b = {
112
+ ISLAND_RING: 580,
113
+ NONE_HIGHWAY: 0,
114
+ VILLAGE: 96,
115
+ SMALL_TOWN: 192,
116
+ SUBURBS_BIG_TOWN: 336,
117
+ CITY: 528,
118
+ METROPOLIS: 864
119
+ }[g], x = [], S = [];
120
+ if (g === "ISLAND_RING") {
121
+ let e = [];
122
+ for (let t = 0; t <= 48; t++) {
123
+ let n = t / 48 * Math.PI * 2, r = 1 + .12 * this.elevNoise.noise2D(Math.cos(n) * 2.1, Math.sin(n) * 2.1);
124
+ e.push([Math.cos(n) * 580 * r, Math.sin(n) * 580 * r]);
125
+ }
126
+ x.push(e, [
127
+ [e[0][0], e[0][1]],
128
+ [860, m.offsetMeters * .5],
129
+ [a, m.offsetMeters]
130
+ ]);
131
+ } else {
132
+ let r = b, o = [];
133
+ p.exists && o.push([
134
+ n - a,
135
+ i + p.offsetMeters,
136
+ v - r,
137
+ y
138
+ ]), m.exists && o.push([
139
+ n + a,
140
+ i + m.offsetMeters,
141
+ v + r,
142
+ y
143
+ ]), c.exists && o.push([
144
+ n + c.offsetMeters,
145
+ i - a,
146
+ v,
147
+ y - r
148
+ ]), u.exists && o.push([
149
+ n + u.offsetMeters,
150
+ i + a,
151
+ v,
152
+ y + r
153
+ ]);
154
+ for (let [r, a, c, l] of o) {
155
+ let o = s(n, i, r, a, c, l, (e, t) => this.sampleMainlandHeight(e, t));
156
+ if (x.push(o), o.length >= 4 && Math.hypot(c - r, l - a) > 360 && (e === 1 && t === 0 || _.next() < .52)) {
157
+ let e = Math.floor(o.length * .5), t = o[e], n = o[Math.min(o.length - 1, e + 1)], r = .5 * (t[0] + n[0]), i = .5 * (t[1] + n[1]), a = Math.atan2(n[0] - t[0], n[1] - t[1]), s = _.next() < .5 ? 1 : -1, c = _.next() < .58 ? "GAS_STATION" : "REST_STOP", l = c === "GAS_STATION" ? 24 : 30, u = c === "GAS_STATION" ? 18 : 15, d = 10 + u * .5, p = (e) => {
158
+ let t = r - Math.cos(a) * e * d, n = i + Math.sin(a) * e * d, s = Infinity;
159
+ for (let e = 0; e < o.length - 1; e++) {
160
+ let [r, i] = o[e], [a, c] = o[e + 1], l = a - r, u = c - i, d = Math.max(0, Math.min(1, ((t - r) * l + (n - i) * u) / Math.max(1e-6, l * l + u * u)));
161
+ s = Math.min(s, Math.hypot(t - (r + l * d), n - (i + u * d)));
162
+ }
163
+ return s;
164
+ };
165
+ p(-s) > p(s) + .5 && (s = -s);
166
+ let m = Math.atan2(s * Math.cos(a), -s * Math.sin(a)), h = Math.round(m / (Math.PI / 6)) * (Math.PI / 6);
167
+ S.push({
168
+ kind: c,
169
+ worldX: f(r - Math.cos(a) * s * d),
170
+ worldZ: f(i + Math.sin(a) * s * d),
171
+ yaw: h,
172
+ widthMeters: l,
173
+ depthMeters: u
174
+ });
175
+ }
176
+ }
177
+ }
178
+ let C = Math.max(2.5, this.sampleMainlandHeight(v, y)), w = g === "METROPOLIS" ? o(v, y, C) : [], T = [];
179
+ if (b > 0 && g !== "ISLAND_RING") {
180
+ let e = Math.floor(b / 48);
181
+ for (let t = -e; t < e; t++) for (let n = -e; n < e; n++) {
182
+ let e = v + n * 48, r = y + t * 48, i = Math.hypot(e + 24 - v, r + 24 - y);
183
+ if (i > b * (1 + .18 * this.zoneNoise.noise2D(e * .004, r * .004)) || g === "METROPOLIS" && i < 54) continue;
184
+ let a = Math.min(Math.abs(e - v), Math.abs(r - y));
185
+ for (let t = 0; t < 2; t++) {
186
+ let n = r + 12 + t * 18, i = this.evaluateSimCityZone(e + 30, n + 9, v, y, b, a, g), o = i === "INDUSTRIAL" || i === "COMMERCIAL" && g === "METROPOLIS" ? 36 : 12;
187
+ for (let t = 0; t < 36; t += o) T.push({
188
+ zone: i,
189
+ minX: e + 12 + t,
190
+ minZ: n,
191
+ width: o,
192
+ depth: 18,
193
+ yaw: 0
194
+ });
195
+ }
196
+ }
197
+ }
198
+ return {
199
+ mx: e,
200
+ mz: t,
201
+ originWorldX: n,
202
+ originWorldZ: i,
203
+ tier: g,
204
+ hubX: v,
205
+ hubZ: y,
206
+ settlementRadiusM: b,
207
+ portals: {
208
+ north: c,
209
+ south: u,
210
+ west: p,
211
+ east: m
212
+ },
213
+ highwayPolylines: x,
214
+ roadsideStops: S,
215
+ parcels: T,
216
+ civicHubBatches: w
217
+ };
218
+ }
219
+ evaluateSimCityZone(e, t, n, r, i, a, o) {
220
+ let s = e - n, c = t - r, l = Math.hypot(s, c) || 1, u = l / i, d = s / l * this.windDir[0] + c / l * this.windDir[1], f = 1.1 * Math.exp(-a / 32) + .7 * Math.exp(-u / .35) + this.zoneNoise.noise2D(e * .012, t * .012) * .18, m = (o === "VILLAGE" ? .15 : .85) * p(.42, .82, u) + .48 * Math.max(0, d) + this.zoneNoise.noise2D(e * .009 + 55.1, t * .009 - 12.8) * .22, h = .92 * (1 - .45 * Math.exp(-a / 24)) * (1 - p(.78, 1.08, u));
221
+ return f >= m && f >= h ? "COMMERCIAL" : m >= h ? "INDUSTRIAL" : "RESIDENTIAL";
222
+ }
223
+ classifySettlementC12Tile(t, n, r) {
224
+ let i = t - r.hubX, a = n - r.hubZ, o = Math.hypot(i, a);
225
+ if (o > r.settlementRadiusM) return e.EMPTY;
226
+ if (r.tier === "METROPOLIS") {
227
+ if (o < 42) return e.C12_PLAZA_HUB;
228
+ if (o < 54) return e.BOULEVARD_MEDIAN;
229
+ for (let t of [
230
+ Math.PI / 6,
231
+ Math.PI / 3,
232
+ 2 * Math.PI / 3,
233
+ 5 * Math.PI / 6
234
+ ]) if (Math.abs(-i * Math.sin(t) + a * Math.cos(t)) <= 9 && o < r.settlementRadiusM * .85) return e.C12_BOULEVARD_30;
235
+ }
236
+ let s = Math.floor(i / 3), c = Math.floor(a / 3), l = (s % 16 + 16) % 16, u = (c % 16 + 16) % 16, d = l < 4, f = u < 4;
237
+ if (d && f) return (l === 0 || l === 3) && (u === 0 || u === 3) ? e.CURB_RAMP_CORNER : l === 0 || l === 3 || u === 0 || u === 3 ? e.CROSSWALK : e.INTERSECTION_BOX;
238
+ if (d) return l === 0 || l === 3 ? u === 9 ? e.CURB_DRIVEWAY : e.CURB_STRAIGHT : e.ROAD_LANE;
239
+ if (f) return u === 0 || u === 3 ? l === 9 ? e.CURB_DRIVEWAY : e.CURB_STRAIGHT : e.ROAD_LANE;
240
+ let p = this.evaluateSimCityZone(t, n, r.hubX, r.hubZ, r.settlementRadiusM, Math.min(Math.abs(i), Math.abs(a)), r.tier);
241
+ return p === "COMMERCIAL" ? e.ZONE_COMMERCIAL : p === "INDUSTRIAL" ? e.ZONE_INDUSTRIAL : e.ZONE_RESIDENTIAL;
242
+ }
243
+ };
244
+ export { e as C12TileKind, t as C12_TILE_M, n as FLOATING_ORIGIN_STEP_M, m as InfiniteLongDrivePlanner, r as MACRO_SIZE_M, i as TILES_PER_MACRO, a as quantizeFloatingOrigin192 };