@pinkaphant/kolmo 0.2.0 → 0.2.2

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.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # `@pinkaphant/kolmo` — 3D Game Engine (`ecctrl 2` + `khr3`), `Longline`, `Dust` & Universal KHR3 Gate
2
2
 
3
- `@pinkaphant/kolmo` is the publishable 3D game engine and browser asset studio built on `@khr3/*` and `@pinkaphant/ecctrl` (`^2.0.4-beta.3`). Every module in `src/` and `games/` stays strictly `<= 300` SLOC with 60Hz imperative `useFrame` + ref discipline, Zustand for discrete UI, and Koota for ECS.
3
+ `@pinkaphant/kolmo` is the publishable 3D game engine and browser asset studio built on `@khr3/*` and `@pinkaphant/ecctrl` (`2.0.4-beta.2`). Every module in `src/` and `games/` stays strictly `<= 300` SLOC with 60Hz imperative `useFrame` + ref discipline, Zustand for discrete UI, and Koota for ECS.
4
4
 
5
5
  ## Quickstart (`npm install` or `npx` Scaffolder)
6
6
 
7
7
  ```sh
8
8
  # Install into an existing R3F / Vite app:
9
- npm install @pinkaphant/kolmo @pinkaphant/ecctrl@^2.0.4-beta.3 @dimforge/rapier3d-compat@0.19.2 @khr3/core @khr3/assets @khr3/c12 @khr3/vehicles @khr3/launchers
9
+ npm install @pinkaphant/kolmo @pinkaphant/ecctrl@2.0.4-beta.2 @dimforge/rapier3d-compat@0.19.2 @khr3/core @khr3/assets @khr3/c12 @khr3/vehicles @khr3/launchers
10
10
 
11
11
  # Or scaffold your own standalone game (configured for your own Cloudflare Workers/R2 account):
12
12
  npx @pinkaphant/kolmo create my-road-game --template longline
@@ -16,7 +16,7 @@ npx @pinkaphant/kolmo create my-chop-shop --template garage
16
16
 
17
17
  ## Subpath Exports & Architecture Map
18
18
 
19
- All five `@khr3/*` packages (`@khr3/core`, `@khr3/assets`, `@khr3/c12`, `@khr3/vehicles`, `@khr3/launchers`) are **zero-`koota`** reusable libraries. **`@pinkaphant/kolmo` owns `koota`**, uniting all five `@khr3/*` packages with ECS state, spatial gravity physics, procedural floating-origin worlds, character body, destructible junk, retro shaders, Vite 8 WASM/Rolldown helpers, and the Universal KHR3 Gate:
19
+ All five `@khr3/*` packages (`@khr3/core`, `@khr3/assets`, `@khr3/c12`, `@khr3/vehicles`, `@khr3/launchers`) are **zero-`koota`** reusable libraries. **`@pinkaphant/kolmo` owns `koota`**, uniting all five `@khr3/*` packages with ECS state, spatial gravity physics, procedural floating-origin worlds, `<KolmoActor>` / `<KolmoVehicle>`, destructible junk, retro shaders, Vite 8 WASM/Rolldown helpers, and the Universal KHR3 Gate:
20
20
 
21
21
  | Import Subpath | Source Entrypoint | Owns |
22
22
  | --- | --- | --- |
@@ -28,7 +28,6 @@ All five `@khr3/*` packages (`@khr3/core`, `@khr3/assets`, `@khr3/c12`, `@khr3/v
28
28
  | `@pinkaphant/kolmo/shaders` | [src/shaders/index.ts](./src/shaders/index.ts) | 6-mode retro quantizer ([retroShader.ts](./src/shaders/retroShader.ts)), `192 m`-periodic PS2 world-locked splat shaders ([ps2TerrainWebGL.ts](./src/shaders/ps2TerrainWebGL.ts), [ps2RoadWebGL.ts](./src/shaders/ps2RoadWebGL.ts)), `<KolmoSkybox>`, `<KolmoExoplanet>`, plus WebGPU TSL opt-in at `@pinkaphant/kolmo/shaders/tsl` |
29
29
  | `@pinkaphant/kolmo/importer` | [src/importer/index.ts](./src/importer/index.ts) | `<GlbImportGate>` ([GlbImportGate.tsx](./src/importer/GlbImportGate.tsx)), `<ChopShopPanel>`, `<DomainWorkshopPanel>` (`c12`, `launcher`, `person`, authenticated R2 vault upload), zero-WASM USD intake ([usdToGlb.ts](./src/importer/usdToGlb.ts)), and W3C WebMCP (`importer_*` tools in [importerWebMcp.ts](./src/importer/importerWebMcp.ts)) |
30
30
  | `@pinkaphant/kolmo/junk` | [src/junk/index.ts](./src/junk/index.ts) | `<KolmoJunk>` ([KolmoJunk.tsx](./src/junk/KolmoJunk.tsx)), `<DestructibleTarget>`, multi-LOD cans & bottles, world-space decals, and BVH shattering (`<ShardPieces>`) |
31
- | `@pinkaphant/kolmo/body` | [src/body/index.ts](./src/body/index.ts) | `1.75 m` SI standing capsule (`BODY_SI`, `bodySpawnPosition`, `withExcludeCharacterRay`), `<KhrBody>`, and zero-lag `<HeldItem>` |
32
31
 
33
32
  ## Flagship Games Inside `Kolmo/games/` (Excluded from npm Tarball)
34
33
 
@@ -6,11 +6,12 @@ import { useCallback as f, useContext as p, useLayoutEffect as m, useMemo as h,
6
6
  import * as _ from "three";
7
7
  import { useFrame as v, useThree as y } from "@react-three/fiber";
8
8
  import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
9
- import { Ecctrl as C } from "@pinkaphant/ecctrl";
10
- import { EcctrlCameraControls as w } from "@pinkaphant/ecctrl/camera";
9
+ import { useRapier as C } from "@react-three/rapier";
10
+ import { Ecctrl as w } from "@pinkaphant/ecctrl";
11
+ import { EcctrlCameraControls as T } from "@pinkaphant/ecctrl/camera";
11
12
  // src/engine/kolmoActor.tsx
12
- var T = new _.Vector3(), E = new _.Vector3(), D = new _.Vector3();
13
- function O() {
13
+ var E = new _.Vector3(), D = new _.Vector3(), O = new _.Vector3();
14
+ function k() {
14
15
  let e = h(() => ({
15
16
  suitGeo: new _.CapsuleGeometry(.28, .56, 6, 12),
16
17
  visorGeo: new _.BoxGeometry(.34, .16, .14),
@@ -60,42 +61,42 @@ function O() {
60
61
  })
61
62
  ] });
62
63
  }
63
- function k({ position: t = [
64
+ function A({ position: t = [
64
65
  0,
65
66
  1.4,
66
67
  0
67
- ], enabled: k = !0, getInput: A, ecctrlProps: j, cameraProps: M, children: N }) {
68
- let P = p(e), F = u();
68
+ ], enabled: A = !0, getInput: j, ecctrlProps: M, cameraProps: N, children: P }) {
69
+ let F = p(e), I = u();
69
70
  m(() => {
70
- s(F);
71
- }, [F]);
72
- let I = d(F, o), L = n(A), R = y((e) => typeof e.gl?.domElement?.setAttribute == "function"), z = g(null), B = g(null), V = g(new _.Vector3()), H = g(new _.Vector3(0, 1, 0)), U = g(!1), W = g(0), G = g({
71
+ s(I);
72
+ }, [I]);
73
+ let L = d(I, o), R = n(j), z = y((e) => typeof e.gl?.domElement?.setAttribute == "function"), B = g(null), V = g(null), H = g(new _.Vector3()), U = g(new _.Vector3(0, 1, 0)), W = g(!1), G = g(0), K = g({
73
74
  pos: null,
74
75
  yaw: 0
75
- }), K = g(null), q = g({
76
+ }), q = g(null), J = g({
76
77
  forward: !1,
77
78
  backward: !1,
78
79
  leftward: !1,
79
80
  rightward: !1,
80
81
  run: !1,
81
82
  jump: !1
82
- }), J = f((e, t) => {
83
- V.current.x -= e, V.current.z -= t, z.current && (z.current.currPos.x -= e, z.current.currPos.z -= t);
84
- let n = B.current;
85
- n?.getPosition && n?.getTarget && n?.setLookAt && (n.getPosition(E), n.getTarget(D), n.setLookAt(E.x - e, E.y, E.z - t, D.x - e, D.y, D.z - t, !1));
83
+ }), Y = f((e, t) => {
84
+ H.current.x -= e, H.current.z -= t, B.current && (B.current.currPos.x -= e, B.current.currPos.z -= t);
85
+ let n = V.current;
86
+ n?.getPosition && n?.getTarget && n?.setLookAt && (n.getPosition(D), n.getTarget(O), n.setLookAt(D.x - e, D.y, D.z - t, O.x - e, O.y, O.z - t, !1));
86
87
  }, []);
87
88
  m(() => {
88
- let e = F.spawn(r({
89
+ let e = I.spawn(r({
89
90
  id: "pilot",
90
- handle: z.current,
91
+ handle: B.current,
91
92
  exitSpawnPos: null,
92
93
  exitSpawnYaw: 0,
93
94
  exitLinVel: null,
94
- onOriginShift: J
95
- })), t = F.onChange(r, (t) => {
95
+ onOriginShift: Y
96
+ })), t = I.onChange(r, (t) => {
96
97
  if (t !== e) return;
97
98
  let n = e.get(r);
98
- n && (G.current = {
99
+ n && (K.current = {
99
100
  pos: n.exitSpawnPos,
100
101
  yaw: n.exitSpawnYaw
101
102
  });
@@ -103,33 +104,33 @@ function k({ position: t = [
103
104
  return () => {
104
105
  t(), e.destroy();
105
106
  };
106
- }, [F, J]);
107
- let Y = f((e) => {
108
- z.current = e;
109
- let t = F.queryFirst(r);
107
+ }, [I, Y]);
108
+ let X = f((e) => {
109
+ B.current = e;
110
+ let t = I.queryFirst(r);
110
111
  if (!t) return;
111
112
  let n = t.get(r);
112
113
  e?.body && n?.exitLinVel && e.body.setLinvel({
113
114
  x: n.exitLinVel[0],
114
115
  y: n.exitLinVel[1],
115
116
  z: n.exitLinVel[2]
116
- }, !0), e?.body && (G.current.pos = null), t.set(r, {
117
+ }, !0), e?.body && (K.current.pos = null), t.set(r, {
117
118
  id: n?.id ?? "pilot",
118
119
  handle: e,
119
120
  exitSpawnPos: e?.body ? null : n?.exitSpawnPos ?? null,
120
121
  exitSpawnYaw: n?.exitSpawnYaw ?? 0,
121
122
  exitLinVel: e?.body ? null : n?.exitLinVel ?? null,
122
- onOriginShift: J
123
+ onOriginShift: Y
123
124
  });
124
- }, [F, J]), X = I?.activeVehicleId || "", Z = k && !X;
125
- if (!Z) K.current = null;
126
- else if (!K.current) {
127
- let e = G.current.pos ?? j?.position ?? t, n = j?.rotation ?? [
125
+ }, [I, Y]), { world: Z } = C(), Q = L?.activeVehicleId || "", $ = A && !Q;
126
+ if (!$) q.current = null;
127
+ else if (!q.current) {
128
+ let e = K.current.pos ?? M?.position ?? t, n = M?.rotation ?? [
128
129
  0,
129
- G.current.yaw,
130
+ K.current.yaw,
130
131
  0
131
132
  ];
132
- K.current = {
133
+ q.current = {
133
134
  pos: [
134
135
  e[0],
135
136
  e[1],
@@ -142,8 +143,8 @@ function k({ position: t = [
142
143
  ]
143
144
  };
144
145
  }
145
- let Q = h(() => {
146
- let e = j?.userData ?? {}, t = e.ecctrl ?? {};
146
+ let ee = h(() => {
147
+ let e = M?.userData ?? {}, t = e.ecctrl ?? {};
147
148
  return {
148
149
  ...e,
149
150
  ecctrl: {
@@ -151,47 +152,47 @@ function k({ position: t = [
151
152
  ...t
152
153
  }
153
154
  };
154
- }, [j?.userData]);
155
+ }, [M?.userData]);
155
156
  return v((e, t) => {
156
- if (!k) return;
157
- let n = Math.min(Math.max(t, 1e-4), .05);
158
- W.current > 0 && (W.current = Math.max(0, W.current - n));
159
- let r = L(), o = r.interact && !U.current;
160
- if (U.current = r.interact, X) {
161
- o && W.current === 0 && (W.current = .25, c(F).exitVehicle());
157
+ if (!A) return;
158
+ let n = Z.timestep > 0 ? Z.timestep : Math.min(Math.max(t, 1e-4), 1 / 30);
159
+ G.current > 0 && (G.current = Math.max(0, G.current - n));
160
+ let r = R(), o = r.interact && !W.current;
161
+ if (W.current = r.interact, Q) {
162
+ o && G.current === 0 && (G.current = .25, c(I).exitVehicle());
162
163
  return;
163
164
  }
164
- let s = z.current;
165
+ let s = B.current;
165
166
  if (!s || !s.body) return;
166
- let u = q.current;
167
+ let u = J.current;
167
168
  u.forward = r.forward, u.backward = r.backward, u.leftward = r.left, u.rightward = r.right, u.run = r.boost, u.jump = r.brake, s.setMovement(u), l.mode = "foot", l.speedKmh = s.moveSpeed * 3.6, l.rpm = 0, l.gear = 0, l.throttle = +!!s.isMoving, l.boost = r.boost && s.isMoving ? 1 : 0;
168
169
  let d = null, f = Infinity;
169
- for (let e of F.query(a, i)) {
170
+ for (let e of I.query(a, i)) {
170
171
  let t = e.get(a), n = e.get(i);
171
172
  if (!t?.handle || !n) continue;
172
- T.set(t.seatOffset[0] - t.centerOfMass[0], t.seatOffset[1] - t.centerOfMass[1], t.seatOffset[2] - t.centerOfMass[2]).applyQuaternion(t.handle.currQuat).add(t.handle.currPos);
173
- let r = s.currPos.distanceToSquared(T);
173
+ E.set(t.seatOffset[0] - t.centerOfMass[0], t.seatOffset[1] - t.centerOfMass[1], t.seatOffset[2] - t.centerOfMass[2]).applyQuaternion(t.handle.currQuat).add(t.handle.currPos);
174
+ let r = s.currPos.distanceToSquared(E);
174
175
  r <= n.radius * n.radius && r < f && (f = r, d = t.id);
175
176
  }
176
- l.nearVehicleId = d, o && d && W.current === 0 ? (W.current = .25, c(F).boardVehicle(d)) : B.current && s.currPos.lengthSq() > 0 && (V.current.copy(s.currPos).addScaledVector(s.bodyYAxis, .55), H.current.copy(s.upAxis), B.current.moveTo(V.current.x, V.current.y, V.current.z, !0), e.camera.up.lerp(H.current, .14), B.current.setUp(e.camera.up));
177
- }), Z ? /* @__PURE__ */ S(b, { children: [R && M !== !1 && M !== null && /* @__PURE__ */ x(w, {
178
- ref: B,
177
+ l.nearVehicleId = d, o && d && G.current === 0 ? (G.current = .25, c(I).boardVehicle(d)) : V.current && s.currPos.lengthSq() > 0 && (H.current.copy(s.currPos).addScaledVector(s.bodyYAxis, .55), U.current.copy(s.upAxis), V.current.moveTo(H.current.x, H.current.y, H.current.z, !0), e.camera.up.lerp(U.current, .14), V.current.setUp(e.camera.up));
178
+ }), $ ? /* @__PURE__ */ S(b, { children: [z && N !== !1 && N !== null && /* @__PURE__ */ x(T, {
179
+ ref: V,
179
180
  makeDefault: !0,
180
181
  minPolarAngle: .12,
181
182
  maxPolarAngle: Math.PI - .12,
182
183
  smoothTime: .08,
183
- ...M ?? {}
184
- }), /* @__PURE__ */ x(C, {
185
- ref: Y,
186
- enableCustomGravity: P,
184
+ ...N ?? {}
185
+ }), /* @__PURE__ */ x(w, {
186
+ ref: X,
187
+ enableCustomGravity: F,
187
188
  maxWalkVel: 3.2,
188
189
  maxRunVel: 7.2,
189
190
  jumpVel: 5.8,
190
- ...j,
191
- position: K.current.pos,
192
- rotation: K.current.rot,
193
- userData: Q,
194
- children: N ?? /* @__PURE__ */ x(O, {})
191
+ ...M,
192
+ position: q.current.pos,
193
+ rotation: q.current.rot,
194
+ userData: ee,
195
+ children: P ?? /* @__PURE__ */ x(k, {})
195
196
  })] }) : null;
196
197
  }
197
- export { k as KolmoActor };
198
+ export { A as KolmoActor };
@@ -8,7 +8,7 @@ export type KolmoKeyAction = "forward" | "backward" | "left" | "right" | "brake"
8
8
  export type KolmoInputState = Record<KolmoKeyAction, boolean>;
9
9
  export type KolmoInputGetter = () => Partial<KolmoInputState>;
10
10
  export declare const EMPTY_KOLMO_INPUT: Readonly<KolmoInputState>;
11
- export declare const KOLMO_KEY_MAP: KeyboardControlsEntry<KolmoKeyAction>[];
11
+ export declare const KOLMO_KEY_MAP: KeyboardControlsEntry<string>[];
12
12
  /**
13
13
  * Safe zero-allocation input reader that falls back cleanly to `EMPTY_KOLMO_INPUT`
14
14
  * when `<KeyboardControls>` is omitted (`keyboardMap={null}` or `<KolmoPhysics>`),
@@ -62,6 +62,58 @@ var c = Object.freeze({
62
62
  {
63
63
  name: "cameraView",
64
64
  keys: ["KeyV"]
65
+ },
66
+ {
67
+ name: "W",
68
+ keys: ["KeyW"]
69
+ },
70
+ {
71
+ name: "S",
72
+ keys: ["KeyS"]
73
+ },
74
+ {
75
+ name: "A",
76
+ keys: ["KeyA"]
77
+ },
78
+ {
79
+ name: "D",
80
+ keys: ["KeyD"]
81
+ },
82
+ {
83
+ name: "Space",
84
+ keys: ["Space"]
85
+ },
86
+ {
87
+ name: "Shift",
88
+ keys: [
89
+ "ShiftLeft",
90
+ "ShiftRight",
91
+ "Shift"
92
+ ]
93
+ },
94
+ {
95
+ name: "F",
96
+ keys: ["KeyF"]
97
+ },
98
+ {
99
+ name: "R",
100
+ keys: ["KeyR"]
101
+ },
102
+ {
103
+ name: "Up",
104
+ keys: ["ArrowUp"]
105
+ },
106
+ {
107
+ name: "Down",
108
+ keys: ["ArrowDown"]
109
+ },
110
+ {
111
+ name: "Left",
112
+ keys: ["ArrowLeft"]
113
+ },
114
+ {
115
+ name: "Right",
116
+ keys: ["ArrowRight"]
65
117
  }
66
118
  ];
67
119
  function u(e) {
@@ -72,7 +124,7 @@ function u(e) {
72
124
  let e = a.current?.();
73
125
  if (!t && !e) return c;
74
126
  let n = t ? t() : c, r = s.current;
75
- return r.forward = !!(e?.forward ?? n.forward), r.backward = !!(e?.backward ?? n.backward), r.left = !!(e?.left ?? n.left), r.right = !!(e?.right ?? n.right), r.brake = !!(e?.brake ?? n.brake), r.boost = !!(e?.boost ?? n.boost), r.interact = !!(e?.interact ?? n.interact), r.turnLeft = !!(e?.turnLeft ?? n.turnLeft), r.turnRight = !!(e?.turnRight ?? n.turnRight), r.descend = !!(e?.descend ?? n.descend), r.cameraView = !!(e?.cameraView ?? n.cameraView), r;
127
+ return r.forward = !!(e?.forward ?? (n.forward || n.W || n.Up)), r.backward = !!(e?.backward ?? (n.backward || n.S || n.Down)), r.left = !!(e?.left ?? (n.left || n.A || n.Left)), r.right = !!(e?.right ?? (n.right || n.D || n.Right)), r.brake = !!(e?.brake ?? (n.brake || n.Space)), r.boost = !!(e?.boost ?? (n.boost || n.Shift)), r.interact = !!(e?.interact ?? (n.interact || n.F)), r.turnLeft = !!(e?.turnLeft ?? n.turnLeft), r.turnRight = !!(e?.turnRight ?? n.turnRight), r.descend = !!(e?.descend ?? n.descend), r.cameraView = !!(e?.cameraView ?? n.cameraView), r;
76
128
  }, [t]);
77
129
  }
78
130
  export { c as EMPTY_KOLMO_INPUT, l as KOLMO_KEY_MAP, s as KolmoKeyboardBridge, o as KolmoKeyboardContext, u as useKolmoInput };
@@ -10,13 +10,13 @@ import { KolmoIsland as l, getCachedIslandPlan as u } from "./kolmoIsland.js";
10
10
  import { readFloatingOriginAnchorXZ as d, shiftFloatingOriginEntities as f, useActiveKolmoWorld as p } from "./kolmoStore.js";
11
11
  import { InstancedC12Piece as m, InstancedWorldGlb as h } from "./longDriveKit.js";
12
12
  import { MainlandMacroCell as g } from "./mainlandMacroCell.js";
13
- import { useEffect as _, useLayoutEffect as v, useMemo as y, useRef as b, useState as x } from "react";
14
- import * as S from "three";
15
- import { useFrame as C, useThree as w } from "@react-three/fiber";
16
- import { jsx as T, jsxs as E } from "react/jsx-runtime";
17
- import { TrimeshCollider as D, useRapier as O } from "@react-three/rapier";
13
+ import { useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
14
+ import * as x from "three";
15
+ import { useFrame as S, useThree as C } from "@react-three/fiber";
16
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
17
+ import { TrimeshCollider as E, useRapier as D } from "@react-three/rapier";
18
18
  // src/engine/kolmoLongDrive.tsx
19
- function k(e = 77, t = 960) {
19
+ function O(e = 77, t = 960) {
20
20
  let n = u(e, t), r = n.road.samples[0];
21
21
  for (let e of n.road.samples) e.pos[0] > r.pos[0] && (r = e);
22
22
  return {
@@ -37,7 +37,7 @@ function k(e = 77, t = 960) {
37
37
  ]
38
38
  };
39
39
  }
40
- function A(e = 77, t = 1, n = 0) {
40
+ function k(e = 77, t = 1, n = 0) {
41
41
  let r = new i(e), a = r.generateMacroCell2D(t, n), o = a.highwayPolylines[0];
42
42
  if (o && o.length >= 2) {
43
43
  let e = o[1], t = o[Math.min(o.length - 1, 2)], n = Math.max(2, r.sampleMainlandHeight(e[0], e[1])), i = Math.atan2(t[0] - e[0], t[1] - e[1]);
@@ -78,8 +78,8 @@ function A(e = 77, t = 1, n = 0) {
78
78
  ]
79
79
  };
80
80
  }
81
- function j({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l }) {
82
- let d = y(() => {
81
+ function A({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l }) {
82
+ let d = v(() => {
83
83
  let i = u(e, t), a = i.road.samples[0];
84
84
  for (let e of i.road.samples) e.pos[0] > a.pos[0] && (a = e);
85
85
  let s = r.evalVerticalBorder(0, 0), l = n * .5, d = s.offsetMeters, f = r.sampleMainlandHeight(l, d), p = [];
@@ -94,7 +94,7 @@ function j({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l })
94
94
  let m = c(p, 5, 3, !1), h = o(m, {
95
95
  skirtDrop: .6,
96
96
  crownHeight: .04
97
- }), g = [], _ = [], v = new S.Object3D();
97
+ }), g = [], _ = [], v = new x.Object3D();
98
98
  for (let e = 24; e < m.length - 24; e += 24) {
99
99
  let t = m.at(e), n = Math.atan2(t.tangent[0], t.tangent[2]);
100
100
  for (let e of [-3.6, 3.6]) {
@@ -115,26 +115,26 @@ function j({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l })
115
115
  ]);
116
116
  return _(() => () => {
117
117
  d.ribbon.geometry.dispose();
118
- }, [d]), /* @__PURE__ */ E("group", { children: [/* @__PURE__ */ E(s, {
118
+ }, [d]), /* @__PURE__ */ T("group", { children: [/* @__PURE__ */ T(s, {
119
119
  x: a,
120
120
  z: l,
121
121
  friction: 1.05,
122
- children: [/* @__PURE__ */ T(D, { args: [d.ribbon.colliderVertices, d.ribbon.colliderIndices] }), /* @__PURE__ */ T("mesh", {
122
+ children: [/* @__PURE__ */ w(E, { args: [d.ribbon.colliderVertices, d.ribbon.colliderIndices] }), /* @__PURE__ */ w("mesh", {
123
123
  geometry: d.ribbon.geometry,
124
124
  material: i,
125
125
  receiveShadow: !0
126
126
  })]
127
- }), /* @__PURE__ */ E("group", {
127
+ }), /* @__PURE__ */ T("group", {
128
128
  position: [
129
129
  a,
130
130
  0,
131
131
  l
132
132
  ],
133
- children: [/* @__PURE__ */ T(m, {
133
+ children: [/* @__PURE__ */ w(m, {
134
134
  matrices: d.piers,
135
135
  kind: "square",
136
136
  color: "#64748b"
137
- }), /* @__PURE__ */ T(h, {
137
+ }), /* @__PURE__ */ w(h, {
138
138
  kitKey: "light_pole",
139
139
  fitSpan: [
140
140
  .6,
@@ -145,8 +145,8 @@ function j({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l })
145
145
  })]
146
146
  })] });
147
147
  }
148
- function M({ seed: o = 77, pureMainland: s = !1, initialOrigin: c = [0, 0], onOriginRebase: m, renderCellExtra: h }) {
149
- let S = p(), D = w((e) => e.camera), k = O(), A = y(() => new i(o), [o]), [M, N] = x(c), P = b([c[0], c[1]]), F = b([c[0], c[1]]), [I, L] = x(() => [Math.max(+!!s, Math.round(c[0] / n)), Math.round(c[1] / n)]), [R, z] = x(() => {
148
+ function j({ seed: o = 77, pureMainland: s = !1, initialOrigin: c = [0, 0], onOriginRebase: m, renderCellExtra: h }) {
149
+ let x = p(), E = C((e) => e.camera), O = D(), k = v(() => new i(o), [o]), [j, M] = b(c), N = y([c[0], c[1]]), P = y([c[0], c[1]]), [F, I] = b(() => [Math.max(+!!s, Math.round(c[0] / n)), Math.round(c[1] / n)]), [L, R] = b(() => {
150
150
  let e = Math.max(1, Math.round(c[0] / n)), t = Math.round(c[1] / n);
151
151
  return s ? [
152
152
  [e, t],
@@ -154,7 +154,7 @@ function M({ seed: o = 77, pureMainland: s = !1, initialOrigin: c = [0, 0], onOr
154
154
  [e, t + 1],
155
155
  [e + 1, t]
156
156
  ] : [[1, 0]];
157
- }), B = y(() => {
157
+ }), z = v(() => {
158
158
  let n = u(o, 960), r = t(a(n, 64));
159
159
  return {
160
160
  tex: r,
@@ -162,62 +162,62 @@ function M({ seed: o = 77, pureMainland: s = !1, initialOrigin: c = [0, 0], onOr
162
162
  };
163
163
  }, [o]);
164
164
  _(() => () => {
165
- B.roadMat.dispose(), B.tex.dispose();
166
- }, [B]);
167
- let V = y(() => {
168
- let [e, t] = I, n = [];
165
+ z.roadMat.dispose(), z.tex.dispose();
166
+ }, [z]);
167
+ let B = v(() => {
168
+ let [e, t] = F, n = [];
169
169
  for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) {
170
170
  let a = e + r, o = t + i;
171
171
  a >= 1 && n.push([a, o]);
172
172
  }
173
173
  return n.sort((n, r) => Math.hypot(n[0] - e, n[1] - t) - Math.hypot(r[0] - e, r[1] - t)), n;
174
- }, [I]);
175
- v(() => {
176
- let e = M[0] - P.current[0], t = M[1] - P.current[1];
177
- (e !== 0 || t !== 0) && (P.current = [M[0], M[1]], F.current = [M[0], M[1]], f(S, D, e, t, k), m?.(M[0], M[1], e, t));
174
+ }, [F]);
175
+ _(() => {
176
+ let e = j[0] - N.current[0], t = j[1] - N.current[1];
177
+ (e !== 0 || t !== 0) && (N.current = [j[0], j[1]], P.current = [j[0], j[1]], f(x, E, e, t, O), m?.(j[0], j[1], e, t));
178
178
  }, [
179
- M,
180
- S,
181
- D,
182
- k,
179
+ j,
180
+ x,
181
+ E,
182
+ O,
183
183
  m
184
- ]), C(() => {
185
- z((e) => {
186
- let t = e.filter(([e, t]) => V.some(([n, r]) => n === e && r === t)), n = V.find(([e, n]) => !t.some(([t, r]) => t === e && r === n));
184
+ ]), S(() => {
185
+ R((e) => {
186
+ let t = e.filter(([e, t]) => B.some(([n, r]) => n === e && r === t)), n = B.find(([e, n]) => !t.some(([t, r]) => t === e && r === n));
187
187
  return !n && t.length === e.length ? e : n ? [...t, n] : t;
188
188
  });
189
- let [e, t] = P.current, [i, a] = d(S, D), o = e + i, c = t + a, l = r(o, c), u = l.chunkOriginX - e, f = l.chunkOriginZ - t;
190
- (Math.abs(u) >= 192 || Math.abs(f) >= 192) && (l.chunkOriginX !== F.current[0] || l.chunkOriginZ !== F.current[1]) && (F.current = [l.chunkOriginX, l.chunkOriginZ], N([l.chunkOriginX, l.chunkOriginZ]));
189
+ let [e, t] = N.current, [i, a] = d(x, E), o = e + i, c = t + a, l = r(o, c), u = l.chunkOriginX - e, f = l.chunkOriginZ - t;
190
+ (Math.abs(u) >= 192 || Math.abs(f) >= 192) && (l.chunkOriginX !== P.current[0] || l.chunkOriginZ !== P.current[1]) && (P.current = [l.chunkOriginX, l.chunkOriginZ], M([l.chunkOriginX, l.chunkOriginZ]));
191
191
  let p = Math.max(+!!s, Math.round(o / n)), m = Math.round(c / n);
192
- (p !== I[0] || m !== I[1]) && L([p, m]);
192
+ (p !== F[0] || m !== F[1]) && I([p, m]);
193
193
  });
194
- let H = -M[0], U = -M[1];
195
- return /* @__PURE__ */ E("group", { children: [
196
- !s && I[0] <= 1 && Math.abs(I[1]) <= 1 && /* @__PURE__ */ T(l, {
194
+ let V = -j[0], H = -j[1];
195
+ return /* @__PURE__ */ T("group", { children: [
196
+ !s && F[0] <= 1 && Math.abs(F[1]) <= 1 && /* @__PURE__ */ w(l, {
197
197
  seed: o,
198
198
  size: 960,
199
199
  segments: 144,
200
200
  settlementTier: "town",
201
- offX: H,
202
- offZ: U
201
+ offX: V,
202
+ offZ: H
203
203
  }),
204
- !s && I[0] <= 2 && Math.abs(I[1]) <= 1 && /* @__PURE__ */ T(j, {
204
+ !s && F[0] <= 2 && Math.abs(F[1]) <= 1 && /* @__PURE__ */ w(A, {
205
205
  seed: o,
206
206
  islandSize: 960,
207
- planner: A,
208
- roadMat: B.roadMat,
209
- offX: H,
210
- offZ: U
207
+ planner: k,
208
+ roadMat: z.roadMat,
209
+ offX: V,
210
+ offZ: H
211
211
  }),
212
- R.map(([e, t]) => /* @__PURE__ */ T(g, {
212
+ L.map(([e, t]) => /* @__PURE__ */ w(g, {
213
213
  mx: e,
214
214
  mz: t,
215
- planner: A,
216
- roadMat: B.roadMat,
217
- offX: H,
218
- offZ: U,
215
+ planner: k,
216
+ roadMat: z.roadMat,
217
+ offX: V,
218
+ offZ: H,
219
219
  renderExtra: h
220
220
  }, `mc_${e}_${t}`))
221
221
  ] });
222
222
  }
223
- export { M as KolmoLongDrive, k as computeLongDriveBridgeheadSpawn, A as computeLongDriveMainlandSpawn };
223
+ export { j as KolmoLongDrive, O as computeLongDriveBridgeheadSpawn, k as computeLongDriveMainlandSpawn };
@@ -1,6 +1,6 @@
1
1
  import React, { type ReactNode } from "react";
2
2
  import { type RootState } from "@react-three/fiber";
3
- import type { CollisionEnterPayload } from "@react-three/rapier";
3
+ import { type CollisionEnterPayload } from "@react-three/rapier";
4
4
  import { type KhrAssetBundle } from "@khr3/core";
5
5
  import { type KhrVehicleProps } from "@khr3/core/vehicle";
6
6
  import type { DroneConfigType, EcctrlVehicleHandle } from "@pinkaphant/ecctrl/vehicle";