@pinkaphant/kolmo 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -14
  3. package/bin/kolmo.mjs +22 -54
  4. package/dist/body/HeldItem.js +171 -0
  5. package/dist/body/KhrBody.js +171 -0
  6. package/dist/body/bodySi.d.ts +0 -11
  7. package/dist/body/bodySi.js +52 -0
  8. package/dist/body/index.d.ts +1 -1
  9. package/dist/body/index.js +4 -1
  10. package/dist/engine/index.d.ts +4 -4
  11. package/dist/engine/index.js +12 -3
  12. package/dist/engine/kolmoActor.d.ts +11 -4
  13. package/dist/engine/kolmoActor.js +197 -0
  14. package/dist/engine/kolmoInput.d.ts +17 -0
  15. package/dist/engine/kolmoInput.js +78 -0
  16. package/dist/engine/kolmoIsland.d.ts +3 -1
  17. package/dist/engine/kolmoIsland.js +311 -0
  18. package/dist/engine/kolmoLongDrive.js +223 -0
  19. package/dist/engine/kolmoRigs.js +59 -0
  20. package/dist/engine/kolmoStore.d.ts +53 -27
  21. package/dist/engine/kolmoStore.js +211 -0
  22. package/dist/engine/kolmoSurface.d.ts +1 -1
  23. package/dist/engine/kolmoSurface.js +182 -0
  24. package/dist/engine/kolmoVehicle.d.ts +3 -1
  25. package/dist/engine/kolmoVehicle.js +250 -0
  26. package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
  27. package/dist/engine/kolmoVehicleDriver.js +29 -0
  28. package/dist/engine/kolmoWorld.d.ts +7 -15
  29. package/dist/engine/kolmoWorld.js +139 -0
  30. package/dist/engine/longDriveKit.d.ts +4 -2
  31. package/dist/engine/longDriveKit.js +254 -0
  32. package/dist/engine/mainlandMacroCell.d.ts +3 -7
  33. package/dist/engine/mainlandMacroCell.js +247 -0
  34. package/dist/engine/shiftedFixedBody.d.ts +13 -0
  35. package/dist/engine/shiftedFixedBody.js +64 -0
  36. package/dist/importer/ChopShopPanel.js +465 -0
  37. package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
  38. package/dist/importer/DomainWorkshopPanel.js +385 -0
  39. package/dist/importer/GateHudBar.js +312 -0
  40. package/dist/importer/GlbImportGate.js +250 -0
  41. package/dist/importer/ImperativeVehicleRig.js +336 -0
  42. package/dist/importer/ImporterPlinthUikitTags.js +112 -0
  43. package/dist/importer/Step1CalibrationPlinth.js +275 -0
  44. package/dist/importer/Step2UniversalPad.js +244 -0
  45. package/dist/importer/VfxEmitterPool.js +91 -0
  46. package/dist/importer/chopShopActions.d.ts +22 -2
  47. package/dist/importer/chopShopActions.js +232 -0
  48. package/dist/importer/gateStore.d.ts +1 -1
  49. package/dist/importer/gateStore.js +92 -0
  50. package/dist/importer/glbNormalizer.js +133 -0
  51. package/dist/importer/importerWebMcp.d.ts +17 -6
  52. package/dist/importer/importerWebMcp.js +343 -0
  53. package/dist/importer/index.js +22 -3
  54. package/dist/importer/khrCompiler.d.ts +1 -1
  55. package/dist/importer/khrCompiler.js +434 -0
  56. package/dist/importer/launcherBake.js +51 -0
  57. package/dist/importer/meshIslands.d.ts +1 -1
  58. package/dist/importer/meshIslands.js +301 -0
  59. package/dist/importer/surfaceCutter.js +254 -0
  60. package/dist/importer/surfaceTopology.js +183 -0
  61. package/dist/importer/universalGateBake.js +162 -0
  62. package/dist/importer/usdToGlb.js +294 -0
  63. package/dist/importer/useChopShopController.d.ts +11 -2
  64. package/dist/importer/useChopShopController.js +364 -0
  65. package/dist/importer/vehiclePanelAnim.js +214 -0
  66. package/dist/importer/wheelAxlePairing.d.ts +1 -2
  67. package/dist/importer/wheelAxlePairing.js +102 -0
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +69 -13
  70. package/dist/junk/DestructibleTarget.js +154 -0
  71. package/dist/junk/KolmoJunk.js +65 -0
  72. package/dist/junk/ShardPieces.d.ts +6 -4
  73. package/dist/junk/ShardPieces.js +74 -0
  74. package/dist/junk/TargetDecals.js +51 -0
  75. package/dist/junk/bvhShatter.js +55 -0
  76. package/dist/junk/bvhTriCollector.js +78 -0
  77. package/dist/junk/index.js +11 -1
  78. package/dist/junk/junkGeometry.js +69 -0
  79. package/dist/junk/junkImportSanitize.js +54 -0
  80. package/dist/junk/junkImporter.js +95 -0
  81. package/dist/junk/junkLabelCanvas.js +67 -0
  82. package/dist/junk/junkLabels.js +35 -0
  83. package/dist/junk/targetHelpers.js +103 -0
  84. package/dist/junk/targetHitLogic.js +128 -0
  85. package/dist/junk/useTargetAssets.js +102 -0
  86. package/dist/physics/index.d.ts +26 -0
  87. package/dist/physics/index.js +84 -0
  88. package/dist/schema/kolmoSchema.d.ts +2 -1
  89. package/dist/schema/kolmoSchema.js +184 -0
  90. package/dist/shaders/celestialBackdrop.d.ts +1 -1
  91. package/dist/shaders/celestialBackdrop.js +344 -0
  92. package/dist/shaders/index.d.ts +0 -1
  93. package/dist/shaders/index.js +9 -1
  94. package/dist/shaders/plumeAndSparkle.js +271 -0
  95. package/dist/shaders/ps2GlslShared.d.ts +1 -1
  96. package/dist/shaders/ps2GlslShared.js +3 -0
  97. package/dist/shaders/ps2MaterialsTSL.js +65 -0
  98. package/dist/shaders/ps2MaterialsWebGL.js +40 -0
  99. package/dist/shaders/ps2RoadWebGL.js +101 -0
  100. package/dist/shaders/ps2TerrainWebGL.js +54 -0
  101. package/dist/shaders/ps2Textures.js +224 -0
  102. package/dist/shaders/retroPalettes.js +188 -0
  103. package/dist/shaders/retroShader.d.ts +31 -3
  104. package/dist/shaders/retroShader.js +249 -0
  105. package/dist/shaders/tsl.d.ts +1 -0
  106. package/dist/shaders/tsl.js +1 -0
  107. package/dist/vite/index.d.ts +15 -0
  108. package/dist/vite/index.js +90 -0
  109. package/dist/world/frontage.js +32 -0
  110. package/dist/world/index.d.ts +1 -1
  111. package/dist/world/index.js +11 -3
  112. package/dist/world/infiniteWorld2D.js +244 -0
  113. package/dist/world/island.js +201 -0
  114. package/dist/world/macroCellSchema.js +27 -0
  115. package/dist/world/macroKnightAStar.js +171 -0
  116. package/dist/world/random.js +33 -0
  117. package/dist/world/road.js +136 -0
  118. package/dist/world/roadRibbon.d.ts +6 -6
  119. package/dist/world/roadRibbon.js +161 -0
  120. package/dist/world/terrain.js +87 -0
  121. package/dist/world/worldTypes.js +111 -0
  122. package/package.json +32 -18
  123. package/dist/body-B7FTf67o.js +0 -362
  124. package/dist/engine-BeKvBM8d.js +0 -1745
  125. package/dist/importer-B2-S-N_e.js +0 -5113
  126. package/dist/junk-B4bC1zAl.js +0 -1049
  127. package/dist/kolmoSurface-DTnrFXH0.js +0 -558
  128. package/dist/shaders-GS71Ek1A.js +0 -1383
  129. package/dist/world-PRWPYrlx.js +0 -947
  130. package/dist/worldTypes-Z0KfdCd0.js +0 -226
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import type { RoadsideStop2D } from "../world/index.js";
3
3
  export type WorldGlbKey = "road_straight" | "road_crosswalk" | "road_intersection" | "curb_straight" | "curb_ramp" | "curb_driveway" | "light_pole";
4
4
  export declare const KOLMO_R2_BASE = "https://khr3.optimuspi.workers.dev/assets";
5
- export declare function InstancedWorldGlb({ kitKey, fitSpan, matrices, }: {
5
+ export declare function InstancedWorldGlb(props: {
6
6
  readonly kitKey: WorldGlbKey;
7
7
  readonly fitSpan: readonly [number, number, number];
8
8
  readonly matrices: Float32Array;
@@ -12,8 +12,10 @@ export declare function InstancedC12Piece({ matrices, kind, color, }: {
12
12
  readonly kind: "square" | "triangle" | "wall" | "roof";
13
13
  readonly color: string;
14
14
  }): React.JSX.Element | null;
15
- export declare function RoadsideStopCompound({ stop, groundY, cellTag, }: {
15
+ export declare function RoadsideStopCompound({ stop, groundY, offX, offZ, cellTag, }: {
16
16
  readonly stop: RoadsideStop2D;
17
17
  readonly groundY: number;
18
+ readonly offX?: number;
19
+ readonly offZ?: number;
18
20
  readonly cellTag: string;
19
21
  }): React.JSX.Element;
@@ -0,0 +1,254 @@
1
+ import { KolmoJunk as e } from "../junk/KolmoJunk.js";
2
+ import { applyRetroMaterial as t, applySceneRetroMaterials as n } from "../shaders/retroShader.js";
3
+ import { ShiftedFixedBody as r } from "./shiftedFixedBody.js";
4
+ import { Suspense as i, useEffect as a, useLayoutEffect as o, useMemo as s, useRef as c } from "react";
5
+ import * as l from "three";
6
+ import { useGLTF as u } from "@react-three/drei";
7
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
8
+ import { CuboidCollider as m } from "@react-three/rapier";
9
+ import { mergeGeometries as h } from "three/examples/jsm/utils/BufferGeometryUtils.js";
10
+ // src/engine/longDriveKit.tsx
11
+ var g = "https://khr3.optimuspi.workers.dev/assets", _ = {
12
+ road_straight: `${g}/city/R_Straight_6x6.glb`,
13
+ road_crosswalk: `${g}/city/R_Crosswalk_6x6.glb`,
14
+ road_intersection: `${g}/city/R_Intersection_6x6.glb`,
15
+ curb_straight: `${g}/city/S_Straight_3x6.glb`,
16
+ curb_ramp: `${g}/city/S_AccessibleRamp_3x6.glb`,
17
+ curb_driveway: `${g}/city/S_Driveway_3x6.glb`,
18
+ light_pole: `${g}/city/L_LightPole_12gon.glb`
19
+ }, v = {
20
+ canopy: `${g}/city/gas-canopy-roof.glb`,
21
+ pump: `${g}/city/gas-pump-twin.glb`,
22
+ sign: `${g}/city/neon-petro-sign.glb`
23
+ }, y = typeof document < "u" && typeof HTMLImageElement < "u", b = /* @__PURE__ */ new Map();
24
+ function x(e, n, r) {
25
+ let i = b.get(n);
26
+ if (i) return i;
27
+ e.updateMatrixWorld(!0);
28
+ let a = new l.Matrix4().copy(e.matrixWorld).invert(), o = new l.Matrix4(), s = [], c = null;
29
+ e.traverse((e) => {
30
+ if (!(e instanceof l.Mesh) || !e.geometry) return;
31
+ let t = e.geometry.index ? e.geometry.toNonIndexed() : e.geometry.clone();
32
+ t.applyMatrix4(o.multiplyMatrices(a, e.matrixWorld));
33
+ for (let e of Object.keys(t.attributes)) e !== "position" && e !== "normal" && e !== "uv" && e !== "color" && t.deleteAttribute(e);
34
+ if (t.getAttribute("normal") || t.computeVertexNormals(), !t.getAttribute("uv")) {
35
+ let e = t.getAttribute("position").count;
36
+ t.setAttribute("uv", new l.BufferAttribute(new Float32Array(e * 2), 2));
37
+ }
38
+ s.push(t), !c && e.material && (c = (Array.isArray(e.material) ? e.material[0] : e.material).clone());
39
+ });
40
+ let u = s.length > 0 ? h(s, !1) ?? s[0] : new l.BoxGeometry(r[0], r[1], r[2]);
41
+ for (let e of s) e !== u && e.dispose();
42
+ u.computeBoundingBox();
43
+ let d = u.boundingBox, f = d.getSize(new l.Vector3()), p = d.getCenter(new l.Vector3()), m = r[0] / Math.max(f.x, 1e-4), g = r[1] / Math.max(f.y, 1e-4), _ = r[2] / Math.max(f.z, 1e-4), v = n === "light_pole" ? g : Math.min(m, _);
44
+ u.translate(-p.x, -d.min.y, -p.z), u.scale(n === "light_pole" ? v : m, n === "light_pole" ? g : v, n === "light_pole" ? v : _), u.computeBoundingSphere();
45
+ let y = c ?? new l.MeshLambertMaterial({
46
+ color: "#64748b",
47
+ flatShading: !0
48
+ });
49
+ t(y, { flatShading: !0 });
50
+ let x = {
51
+ geometry: u,
52
+ material: y
53
+ };
54
+ return b.set(n, x), x;
55
+ }
56
+ function S({ kitKey: e, fitSpan: t, matrices: n }) {
57
+ let r = n.length / 16, i = u(_[e]), a = c(null), l = s(() => x(i.scene, e, t), [
58
+ i.scene,
59
+ e,
60
+ t
61
+ ]);
62
+ return o(() => {
63
+ a.current && r !== 0 && (a.current.instanceMatrix.array.set(n), a.current.instanceMatrix.needsUpdate = !0, a.current.computeBoundingSphere());
64
+ }, [n, r]), r > 0 ? /* @__PURE__ */ f("instancedMesh", {
65
+ ref: a,
66
+ args: [
67
+ l.geometry,
68
+ l.material,
69
+ r
70
+ ],
71
+ frustumCulled: !1,
72
+ receiveShadow: !0
73
+ }) : null;
74
+ }
75
+ function C(e) {
76
+ return e.matrices.length === 0 || !y ? null : /* @__PURE__ */ f(i, {
77
+ fallback: null,
78
+ children: /* @__PURE__ */ f(S, { ...e })
79
+ });
80
+ }
81
+ function w({ matrices: e, kind: n, color: r }) {
82
+ let i = c(null), u = e.length / 16, d = s(() => {
83
+ if (n === "triangle") {
84
+ let e = 3 * Math.sqrt(3) * .5, t = new l.Shape([
85
+ new l.Vector2(-1.5, 0),
86
+ new l.Vector2(1.5, 0),
87
+ new l.Vector2(0, e)
88
+ ]), n = new l.ExtrudeGeometry(t, {
89
+ depth: .24,
90
+ bevelEnabled: !1
91
+ });
92
+ return n.rotateX(-Math.PI * .5), n;
93
+ }
94
+ return n === "wall" ? new l.BoxGeometry(3, 3, .22) : n === "roof" ? new l.BoxGeometry(3.08, .24, 3.08) : new l.BoxGeometry(3, .24, 3);
95
+ }, [n]), p = s(() => t(new l.MeshLambertMaterial({
96
+ color: r,
97
+ flatShading: !0
98
+ }), { flatShading: !0 }), [r]);
99
+ return a(() => () => {
100
+ d.dispose(), p.dispose();
101
+ }, [d, p]), o(() => {
102
+ i.current && u !== 0 && (i.current.instanceMatrix.array.set(e), i.current.instanceMatrix.needsUpdate = !0, i.current.computeBoundingSphere());
103
+ }, [e, u]), u > 0 ? /* @__PURE__ */ f("instancedMesh", {
104
+ ref: i,
105
+ args: [
106
+ d,
107
+ p,
108
+ u
109
+ ],
110
+ frustumCulled: !1,
111
+ castShadow: !0,
112
+ receiveShadow: !0
113
+ }) : null;
114
+ }
115
+ function T({ stop: e }) {
116
+ let t = u(v.canopy), r = u(v.pump), i = u(v.sign), o = s(() => {
117
+ let e = (e, t) => {
118
+ let r = e.clone(!0);
119
+ r.traverse((e) => {
120
+ let t = e;
121
+ t.material &&= Array.isArray(t.material) ? t.material.map((e) => e.clone()) : t.material.clone();
122
+ }), r.updateMatrixWorld(!0);
123
+ let i = new l.Box3().setFromObject(r), a = i.getSize(new l.Vector3()), o = i.getCenter(new l.Vector3()), s = t / Math.max(a.y, .1);
124
+ return r.scale.setScalar(s), r.position.set(-o.x * s, -i.min.y * s, -o.z * s), n(r), r;
125
+ };
126
+ return {
127
+ canopy: e(t.scene, 4.6),
128
+ pumpA: e(r.scene, 2.1),
129
+ pumpB: e(r.scene, 2.1),
130
+ sign: e(i.scene, 6.8)
131
+ };
132
+ }, [
133
+ t.scene,
134
+ r.scene,
135
+ i.scene
136
+ ]);
137
+ return a(() => () => {
138
+ for (let e of [
139
+ o.canopy,
140
+ o.pumpA,
141
+ o.pumpB,
142
+ o.sign
143
+ ]) e.traverse((e) => {
144
+ let t = e.material;
145
+ if (t) for (let e of Array.isArray(t) ? t : [t]) e.dispose();
146
+ });
147
+ }, [o]), /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("primitive", {
148
+ object: o.canopy,
149
+ position: [
150
+ 0,
151
+ .16,
152
+ 0
153
+ ]
154
+ }), e.kind === "GAS_STATION" && /* @__PURE__ */ p(d, { children: [
155
+ /* @__PURE__ */ f("primitive", {
156
+ object: o.pumpA,
157
+ position: [
158
+ -2.4,
159
+ .16,
160
+ 0
161
+ ]
162
+ }),
163
+ /* @__PURE__ */ f("primitive", {
164
+ object: o.pumpB,
165
+ position: [
166
+ 2.4,
167
+ .16,
168
+ 0
169
+ ]
170
+ }),
171
+ /* @__PURE__ */ f("primitive", {
172
+ object: o.sign,
173
+ position: [
174
+ e.widthMeters * .42,
175
+ .16,
176
+ e.depthMeters * .36
177
+ ]
178
+ })
179
+ ] })] });
180
+ }
181
+ function E({ stop: t, groundY: n, offX: a = 0, offZ: o = 0, cellTag: s }) {
182
+ let c = t.worldX + a, l = t.worldZ + o, u = Math.cos(t.yaw), d = Math.sin(t.yaw), h = [
183
+ c + 1.1 * u + 1.4 * d,
184
+ n + .55,
185
+ l - 1.1 * d + 1.4 * u
186
+ ], g = [
187
+ c - 1.1 * u + 1.4 * d,
188
+ n + .55,
189
+ l + 1.1 * d + 1.4 * u
190
+ ];
191
+ return /* @__PURE__ */ p("group", { children: [
192
+ /* @__PURE__ */ p(r, {
193
+ x: c,
194
+ y: n,
195
+ z: l,
196
+ yaw: t.yaw,
197
+ children: [/* @__PURE__ */ f(m, {
198
+ args: [
199
+ t.widthMeters * .5,
200
+ .12,
201
+ t.depthMeters * .5
202
+ ],
203
+ position: [
204
+ 0,
205
+ .12,
206
+ 0
207
+ ]
208
+ }), /* @__PURE__ */ p("mesh", {
209
+ position: [
210
+ 0,
211
+ .08,
212
+ 0
213
+ ],
214
+ receiveShadow: !0,
215
+ children: [/* @__PURE__ */ f("boxGeometry", { args: [
216
+ t.widthMeters,
217
+ .16,
218
+ t.depthMeters
219
+ ] }), /* @__PURE__ */ f("meshLambertMaterial", {
220
+ color: "#475569",
221
+ flatShading: !0
222
+ })]
223
+ })]
224
+ }),
225
+ y && /* @__PURE__ */ f("group", {
226
+ position: [
227
+ c,
228
+ n,
229
+ l
230
+ ],
231
+ rotation: [
232
+ 0,
233
+ t.yaw,
234
+ 0
235
+ ],
236
+ children: /* @__PURE__ */ f(i, {
237
+ fallback: null,
238
+ children: /* @__PURE__ */ f(T, { stop: t })
239
+ })
240
+ }),
241
+ /* @__PURE__ */ f(e, {
242
+ id: `${s}_can`,
243
+ kind: "tin-can",
244
+ labelId: "tris-soda",
245
+ position: h
246
+ }),
247
+ /* @__PURE__ */ f(e, {
248
+ id: `${s}_bot`,
249
+ kind: "glass-bottle",
250
+ position: g
251
+ })
252
+ ] });
253
+ }
254
+ export { w as InstancedC12Piece, C as InstancedWorldGlb, g as KOLMO_R2_BASE, E as RoadsideStopCompound };
@@ -1,18 +1,14 @@
1
1
  import React from "react";
2
2
  import * as THREE from "three";
3
3
  import { InfiniteLongDrivePlanner, type MacroCellPlan2D } from "../world/index.js";
4
- export declare function ShiftedFixedBody({ x, z, friction, children, }: {
5
- readonly x: number;
6
- readonly z: number;
7
- readonly friction?: number;
8
- readonly children: React.ReactNode;
9
- }): React.JSX.Element;
4
+ import { ShiftedFixedBody, type ShiftedFixedBodyProps } from "./shiftedFixedBody.js";
5
+ export { ShiftedFixedBody, type ShiftedFixedBodyProps };
10
6
  export declare function MainlandMacroCell({ mx, mz, planner, roadMat, terrainMat, offX, offZ, renderExtra, }: {
11
7
  readonly mx: number;
12
8
  readonly mz: number;
13
9
  readonly planner: InfiniteLongDrivePlanner;
14
10
  readonly roadMat: THREE.Material;
15
- readonly terrainMat: THREE.Material;
11
+ readonly terrainMat?: THREE.Material;
16
12
  readonly offX: number;
17
13
  readonly offZ: number;
18
14
  readonly renderExtra?: (mx: number, mz: number, plan: MacroCellPlan2D, offX: number, offZ: number) => React.ReactNode;
@@ -0,0 +1,247 @@
1
+ import { createPS2TerrainMaterialWebGL as e } from "../shaders/ps2TerrainWebGL.js";
2
+ import { createPS2WorldTextures as t } from "../shaders/ps2Textures.js";
3
+ import { C12TileKind as n, MACRO_SIZE_M as r } from "../world/macroCellSchema.js";
4
+ import { buildCarvedTerrainGeometry as i, buildRoadRibbonGeometry as a } from "../world/roadRibbon.js";
5
+ import { makeTerrain as o } from "../world/terrain.js";
6
+ import { roadFromPoints as s } from "../world/road.js";
7
+ import { InstancedC12Piece as c, InstancedWorldGlb as l, RoadsideStopCompound as u } from "./longDriveKit.js";
8
+ import { ShiftedFixedBody as d, bakeMacroCellSplat as f } from "./shiftedFixedBody.js";
9
+ import { useEffect as p, useMemo as m } from "react";
10
+ import * as h from "three";
11
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
12
+ import { TrimeshCollider as v } from "@react-three/rapier";
13
+ // src/engine/mainlandMacroCell.tsx
14
+ function y({ mx: y, mz: b, planner: x, roadMat: S, terrainMat: C, offX: w, offZ: T, renderExtra: E }) {
15
+ let D = m(() => {
16
+ let c = x.generateMacroCell2D(y, b), l = Math.max(2.5, x.sampleMainlandHeight(c.hubX, c.hubZ)), u = (e, t) => {
17
+ let n = x.sampleMainlandHeight(e, t);
18
+ if (c.settlementRadiusM <= 0) return n;
19
+ let r = Math.hypot(e - c.hubX, t - c.hubZ);
20
+ if (r <= c.settlementRadiusM) return l;
21
+ let i = (r - c.settlementRadiusM) / 96;
22
+ return i >= 1 ? n : l + (n - l) * (i * i * (3 - 2 * i));
23
+ }, d = c.highwayPolylines.filter((e) => e.length >= 2).map((e) => {
24
+ let t = e.map(([e, t]) => [
25
+ e,
26
+ Math.max(2, u(e, t)),
27
+ t
28
+ ]);
29
+ for (let e = 0; e < 4; e++) for (let e = 1; e < t.length - 1; e++) t[e] = [
30
+ t[e][0],
31
+ .5 * t[e][1] + .25 * (t[e - 1][1] + t[e + 1][1]),
32
+ t[e][2]
33
+ ];
34
+ return s(t, 4.5, 4, !1);
35
+ }), p = d.map((e) => a(e)), m = d[0] ?? s([[
36
+ c.originWorldX - 20,
37
+ l,
38
+ c.originWorldZ
39
+ ], [
40
+ c.originWorldX + 20,
41
+ l,
42
+ c.originWorldZ
43
+ ]], 4.5, 4, !1), g = o(y * 73856093 ^ b * 19349663, m, {
44
+ amplitude: 28,
45
+ noise: {
46
+ wavelength: 300,
47
+ octaves: 2,
48
+ gain: .5,
49
+ lacunarity: 2
50
+ },
51
+ maxSlope: .55,
52
+ minShoulder: 12,
53
+ verge: 18,
54
+ baseHeight: u,
55
+ maxCutFill: 16,
56
+ extraRoads: d.slice(1)
57
+ }), _ = {
58
+ ...g,
59
+ height: (e, t) => g.height(c.originWorldX + e, c.originWorldZ + t),
60
+ visualHeight: (e, t, n) => g.visualHeight(c.originWorldX + e, c.originWorldZ + t, n),
61
+ roadMask: (e, t) => g.roadMask(c.originWorldX + e, c.originWorldZ + t)
62
+ }, v = i(_, r, 96), S = C ? null : t(f(y, b, c, _)), w = S ? e(S) : null, T = new h.Object3D(), E = [], D = [], O = [], k = [], A = [], j = [], M = [], N = [], P = [], F = [], I = [];
63
+ for (let e of d) for (let t = 36; t < e.length - 36; t += 48) {
64
+ let n = e.at(t);
65
+ T.position.set(n.pos[0] + n.left[0] * 6.8, n.pos[1], n.pos[2] + n.left[2] * 6.8), T.rotation.set(0, Math.atan2(n.tangent[0], n.tangent[2]), 0), T.scale.set(1, 1, 1), T.updateMatrix(), E.push(...T.matrix.elements);
66
+ }
67
+ if (c.settlementRadiusM > 0) {
68
+ let e = Math.min(84, Math.ceil(c.settlementRadiusM / 3));
69
+ for (let t = -e; t <= e; t++) for (let r = -e; r <= e; r++) {
70
+ let e = c.hubX + r * 3 + 1.5, i = c.hubZ + t * 3 + 1.5, a = x.classifySettlementC12Tile(e, i, c);
71
+ a < n.ROAD_LANE || a > n.C12_PLAZA_HUB || (T.position.set(e, l + .02, i), T.rotation.set(0, 0, 0), T.scale.set(1, 1, 1), T.updateMatrix(), a === n.CROSSWALK ? O.push(...T.matrix.elements) : a === n.INTERSECTION_BOX || a === n.C12_PLAZA_HUB ? k.push(...T.matrix.elements) : a === n.CURB_RAMP_CORNER ? j.push(...T.matrix.elements) : a === n.CURB_DRIVEWAY ? M.push(...T.matrix.elements) : a === n.CURB_STRAIGHT || a === n.BOULEVARD_MEDIAN ? A.push(...T.matrix.elements) : D.push(...T.matrix.elements));
72
+ }
73
+ for (let e of c.parcels.slice(0, 140)) {
74
+ let t = e.zone === "COMMERCIAL" ? 4 : e.zone === "INDUSTRIAL" ? 2 : 1, n = e.zone === "COMMERCIAL" ? P : e.zone === "INDUSTRIAL" ? F : N, r = Math.max(2, Math.floor((e.width - 3) / 3)), i = Math.max(2, Math.floor((e.depth - 3) / 3));
75
+ for (let a = 0; a < t; a++) {
76
+ let t = l + a * 3 + 1.5;
77
+ for (let a = 0; a < r; a++) for (let [r, o] of [[0, 0], [i * 3, Math.PI]]) T.position.set(e.minX + 1.5 + a * 3 + 1.5, t, e.minZ + 1.5 + r), T.rotation.set(0, o, 0), T.scale.set(1, 1, 1), T.updateMatrix(), n.push(...T.matrix.elements);
78
+ }
79
+ for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) T.position.set(e.minX + 3 + i * 3, l + t * 3 + .12, e.minZ + 3 + n * 3), T.rotation.set(0, 0, 0), T.scale.set(1, 1, 1), T.updateMatrix(), I.push(...T.matrix.elements);
80
+ }
81
+ }
82
+ let L = c.civicHubBatches.find((e) => e.kind === "FoundationSquare")?.matrices ?? /* @__PURE__ */ new Float32Array(), R = c.civicHubBatches.find((e) => e.kind === "FoundationTriangle")?.matrices ?? /* @__PURE__ */ new Float32Array();
83
+ return {
84
+ plan2d: c,
85
+ ribbons: p,
86
+ terrainGeo: v,
87
+ shiftedTerrain: _,
88
+ cellTex: S,
89
+ cellTerrain: w,
90
+ poles: new Float32Array(E),
91
+ rdStr: new Float32Array(D),
92
+ rdCw: new Float32Array(O),
93
+ rdInt: new Float32Array(k),
94
+ cbStr: new Float32Array(A),
95
+ cbRmp: new Float32Array(j),
96
+ cbDrv: new Float32Array(M),
97
+ wallRes: new Float32Array(N),
98
+ wallCom: new Float32Array(P),
99
+ wallInd: new Float32Array(F),
100
+ roofAll: new Float32Array(I),
101
+ sqHub: L,
102
+ triHub: R
103
+ };
104
+ }, [
105
+ y,
106
+ b,
107
+ x,
108
+ C
109
+ ]);
110
+ p(() => () => {
111
+ D.terrainGeo.geometry.dispose(), D.ribbons.forEach((e) => e.geometry.dispose()), D.cellTerrain?.material.dispose(), D.cellTerrain?.depthMaterial.dispose(), D.cellTex?.dispose();
112
+ }, [D]);
113
+ let O = C ?? D.cellTerrain.material;
114
+ return /* @__PURE__ */ _("group", { children: [
115
+ /* @__PURE__ */ _(d, {
116
+ x: D.plan2d.originWorldX + w,
117
+ z: D.plan2d.originWorldZ + T,
118
+ friction: .9,
119
+ children: [/* @__PURE__ */ g(v, { args: [D.terrainGeo.colliderVertices, D.terrainGeo.colliderIndices] }), /* @__PURE__ */ g("mesh", {
120
+ geometry: D.terrainGeo.geometry,
121
+ material: O,
122
+ receiveShadow: !0
123
+ })]
124
+ }),
125
+ D.ribbons.map((e, t) => /* @__PURE__ */ _(d, {
126
+ x: w,
127
+ z: T,
128
+ friction: 1.05,
129
+ children: [/* @__PURE__ */ g(v, { args: [e.colliderVertices, e.colliderIndices] }), /* @__PURE__ */ g("mesh", {
130
+ geometry: e.geometry,
131
+ material: S,
132
+ receiveShadow: !0
133
+ })]
134
+ }, `hwy_${t}`)),
135
+ /* @__PURE__ */ _("group", {
136
+ position: [
137
+ w,
138
+ 0,
139
+ T
140
+ ],
141
+ children: [
142
+ /* @__PURE__ */ g(l, {
143
+ kitKey: "light_pole",
144
+ fitSpan: [
145
+ .6,
146
+ 6.8,
147
+ .6
148
+ ],
149
+ matrices: D.poles
150
+ }),
151
+ /* @__PURE__ */ g(l, {
152
+ kitKey: "road_straight",
153
+ fitSpan: [
154
+ 3,
155
+ .08,
156
+ 3
157
+ ],
158
+ matrices: D.rdStr
159
+ }),
160
+ /* @__PURE__ */ g(l, {
161
+ kitKey: "road_crosswalk",
162
+ fitSpan: [
163
+ 3,
164
+ .08,
165
+ 3
166
+ ],
167
+ matrices: D.rdCw
168
+ }),
169
+ /* @__PURE__ */ g(l, {
170
+ kitKey: "road_intersection",
171
+ fitSpan: [
172
+ 3,
173
+ .08,
174
+ 3
175
+ ],
176
+ matrices: D.rdInt
177
+ }),
178
+ /* @__PURE__ */ g(l, {
179
+ kitKey: "curb_straight",
180
+ fitSpan: [
181
+ 3,
182
+ .18,
183
+ 3
184
+ ],
185
+ matrices: D.cbStr
186
+ }),
187
+ /* @__PURE__ */ g(l, {
188
+ kitKey: "curb_ramp",
189
+ fitSpan: [
190
+ 3,
191
+ .18,
192
+ 3
193
+ ],
194
+ matrices: D.cbRmp
195
+ }),
196
+ /* @__PURE__ */ g(l, {
197
+ kitKey: "curb_driveway",
198
+ fitSpan: [
199
+ 3,
200
+ .14,
201
+ 3
202
+ ],
203
+ matrices: D.cbDrv
204
+ }),
205
+ /* @__PURE__ */ g(c, {
206
+ matrices: D.sqHub,
207
+ kind: "square",
208
+ color: "#94a3b8"
209
+ }),
210
+ /* @__PURE__ */ g(c, {
211
+ matrices: D.triHub,
212
+ kind: "triangle",
213
+ color: "#cbd5e1"
214
+ }),
215
+ /* @__PURE__ */ g(c, {
216
+ matrices: D.wallRes,
217
+ kind: "wall",
218
+ color: "#d6c7b2"
219
+ }),
220
+ /* @__PURE__ */ g(c, {
221
+ matrices: D.wallCom,
222
+ kind: "wall",
223
+ color: "#38bdf8"
224
+ }),
225
+ /* @__PURE__ */ g(c, {
226
+ matrices: D.wallInd,
227
+ kind: "wall",
228
+ color: "#b45309"
229
+ }),
230
+ /* @__PURE__ */ g(c, {
231
+ matrices: D.roofAll,
232
+ kind: "roof",
233
+ color: "#334155"
234
+ })
235
+ ]
236
+ }),
237
+ D.plan2d.roadsideStops.map((e, t) => /* @__PURE__ */ g(u, {
238
+ stop: e,
239
+ groundY: Math.max(2, D.shiftedTerrain.height(e.worldX - D.plan2d.originWorldX, e.worldZ - D.plan2d.originWorldZ)),
240
+ offX: w,
241
+ offZ: T,
242
+ cellTag: `stop_${y}_${b}_${t}`
243
+ }, `stop_${t}`)),
244
+ E?.(y, b, D.plan2d, w, T)
245
+ ] });
246
+ }
247
+ export { y as MainlandMacroCell, d as ShiftedFixedBody };
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { type MacroCellPlan2D, type Terrain, type WorldGenResult } from "../world/index.js";
3
+ export interface ShiftedFixedBodyProps {
4
+ readonly x: number;
5
+ readonly y?: number;
6
+ readonly z: number;
7
+ readonly yaw?: number;
8
+ readonly friction?: number;
9
+ readonly userData?: Record<string, unknown>;
10
+ readonly children: React.ReactNode;
11
+ }
12
+ export declare function ShiftedFixedBody({ x, y, z, yaw, friction, userData, children, }: ShiftedFixedBodyProps): React.JSX.Element;
13
+ export declare function bakeMacroCellSplat(mx: number, mz: number, plan2d: MacroCellPlan2D, shiftedTerrain: Terrain): WorldGenResult;
@@ -0,0 +1,64 @@
1
+ import { MACRO_SIZE_M as e } from "../world/macroCellSchema.js";
2
+ import { useLayoutEffect as t, useRef as n } from "react";
3
+ import * as r from "three";
4
+ import { jsx as i } from "react/jsx-runtime";
5
+ import { RigidBody as a } from "@react-three/rapier";
6
+ // src/engine/shiftedFixedBody.tsx
7
+ var o = new r.Euler(), s = new r.Quaternion();
8
+ function c({ x: e, y: r = 0, z: c, yaw: l = 0, friction: u = 1, userData: d, children: f }) {
9
+ let p = n(null);
10
+ return t(() => {
11
+ let t = p.current;
12
+ t && (t.setTranslation({
13
+ x: e,
14
+ y: r,
15
+ z: c
16
+ }, !1), o.set(0, l, 0), s.setFromEuler(o), t.setRotation(s, !1));
17
+ }, [
18
+ e,
19
+ r,
20
+ c,
21
+ l
22
+ ]), /* @__PURE__ */ i(a, {
23
+ ref: p,
24
+ type: "fixed",
25
+ position: [
26
+ e,
27
+ r,
28
+ c
29
+ ],
30
+ rotation: [
31
+ 0,
32
+ l,
33
+ 0
34
+ ],
35
+ colliders: !1,
36
+ friction: u,
37
+ ...d === void 0 ? {} : { userData: d },
38
+ children: f
39
+ });
40
+ }
41
+ function l(t, n, r, i) {
42
+ let a = e * .5, o = /* @__PURE__ */ new Uint8Array(9216);
43
+ o.fill(255);
44
+ let s = /* @__PURE__ */ new Uint8Array(36864), c = /* @__PURE__ */ new Uint8Array(36864);
45
+ for (let t = 0; t < 96; t++) {
46
+ let n = -a + t / 95 * e;
47
+ for (let o = 0; o < 96; o++) {
48
+ let l = -a + o / 95 * e, u = (t * 96 + o) * 4, d = i.height(l, n), f = i.roadMask(l, n), p = r.originWorldX + l, m = r.originWorldZ + n, h = r.settlementRadiusM > 0 && Math.hypot(p - r.hubX, m - r.hubZ) <= r.settlementRadiusM;
49
+ f.asphalt > .35 ? (c[u + 3] = 230, c[u] = 25) : f.gravel > .15 || h ? (c[u] = h ? 175 : Math.round(190 * f.gravel), s[u] = 65, s[u + 1] = 35) : d > 44 ? (c[u + 2] = 190, s[u + 3] = 65) : d > 24 ? (s[u + 3] = 125, c[u + 1] = 95, s[u] = 35) : (s[u + 1] = 145, c[u + 1] = 75, s[u] = 35);
50
+ }
51
+ }
52
+ return {
53
+ config: {
54
+ seed: `mc_${t}_${n}`,
55
+ size: e,
56
+ gridCells: 96,
57
+ waterLevel: 0
58
+ },
59
+ alphaMap: o,
60
+ splat0: s,
61
+ splat1: c
62
+ };
63
+ }
64
+ export { c as ShiftedFixedBody, l as bakeMacroCellSplat };