@pinkaphant/kolmo 0.1.0 → 0.1.1

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.
@@ -3,28 +3,28 @@ import { c as l, l as u, o as d, u as f } from "./kolmoSurface-DTnrFXH0.js";
3
3
  import { c as p, o as m, r as h, u as g } from "./worldTypes-Z0KfdCd0.js";
4
4
  import { a as _, b as v, d as y, h as b, i as x, l as S, o as C, r as w, t as T } from "./world-PRWPYrlx.js";
5
5
  import { t as ee } from "./junk-B4bC1zAl.js";
6
- import { Suspense as te, createContext as ne, useCallback as re, useContext as ie, useEffect as E, useLayoutEffect as D, useMemo as O, useRef as k, useState as ae } from "react";
7
- import * as A from "three";
8
- import { Canvas as j, useFrame as oe, useThree as se } from "@react-three/fiber";
9
- import { KeyboardControls as M, useGLTF as N, useKeyboardControls as ce } from "@react-three/drei";
10
- import { PhysicsWorld as P, cloneKhrBundle as le, loadKhrGlb as F, useKhrGlb as ue } from "@khr3/core";
11
- import { useCustomGravity as de } from "@pinkaphant/ecctrl/gravity";
12
- import { WorldProvider as fe, useTrait as pe } from "koota/react";
13
- import { Fragment as me, jsx as I, jsxs as L } from "react/jsx-runtime";
14
- import { CuboidCollider as he, RigidBody as R, TrimeshCollider as z } from "@react-three/rapier";
15
- import { RoomEnvironment as ge } from "three/examples/jsm/environments/RoomEnvironment.js";
16
- import { createActions as _e, createWorld as ve, relation as B, trait as ye } from "koota";
17
- import { easing as be } from "maath";
18
- import { KhrVehicle as xe } from "@khr3/core/vehicle";
19
- import { Ecctrl as Se } from "@pinkaphant/ecctrl";
20
- import { EcctrlCameraControls as Ce } from "@pinkaphant/ecctrl/camera";
21
- import { instanceBatches as we, planSettlement as Te, poseToFloat as Ee } from "@khr3/c12";
22
- import { mergeGeometries as De } from "three/examples/jsm/utils/BufferGeometryUtils.js";
6
+ import { Suspense as te, createContext as E, useCallback as ne, useContext as re, useEffect as D, useLayoutEffect as O, useMemo as k, useRef as A, useState as j } from "react";
7
+ import * as M from "three";
8
+ import { Canvas as ie, useFrame as ae, useThree as N } from "@react-three/fiber";
9
+ import { KeyboardControls as oe, useGLTF as P, useKeyboardControls as se } from "@react-three/drei";
10
+ import { PhysicsWorld as F, cloneKhrBundle as ce, loadKhrGlb as I, useKhrGlb as le } from "@khr3/core";
11
+ import { useCustomGravity as ue } from "@pinkaphant/ecctrl/gravity";
12
+ import { WorldProvider as de, useTrait as fe, useWorld as pe } from "koota/react";
13
+ import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
14
+ import { CuboidCollider as me, RigidBody as B, TrimeshCollider as V } from "@react-three/rapier";
15
+ import { RoomEnvironment as he } from "three/examples/jsm/environments/RoomEnvironment.js";
16
+ import { createActions as ge, createWorld as _e, relation as H, trait as ve } from "koota";
17
+ import { easing as ye } from "maath";
18
+ import { KhrVehicle as be } from "@khr3/core/vehicle";
19
+ import { Ecctrl as xe } from "@pinkaphant/ecctrl";
20
+ import { EcctrlCameraControls as Se } from "@pinkaphant/ecctrl/camera";
21
+ import { instanceBatches as Ce, planSettlement as we, poseToFloat as Te } from "@khr3/c12";
22
+ import { mergeGeometries as Ee } from "three/examples/jsm/utils/BufferGeometryUtils.js";
23
23
  // src/engine/kolmoRigs.tsx
24
- function Oe({ intensity: e = .65 }) {
25
- let { gl: t, scene: n } = se();
26
- return E(() => {
27
- let r = new A.PMREMGenerator(t), i = new ge(), a = r.fromScene(i, .04), o = n.environment, s = n.environmentIntensity;
24
+ function De({ intensity: e = .65 }) {
25
+ let { gl: t, scene: n } = N();
26
+ return D(() => {
27
+ let r = new M.PMREMGenerator(t), i = new he(), a = r.fromScene(i, .04), o = n.environment, s = n.environmentIntensity;
28
28
  return n.environment = a.texture, n.environmentIntensity = e, i.dispose(), r.dispose(), () => {
29
29
  n.environment = o, n.environmentIntensity = s, a.dispose();
30
30
  };
@@ -34,38 +34,38 @@ function Oe({ intensity: e = .65 }) {
34
34
  e
35
35
  ]), null;
36
36
  }
37
- var V = new A.Vector2();
38
- function ke({ onViewportChange: e } = {}) {
39
- let { gl: n } = se(), r = k({
37
+ var U = new M.Vector2();
38
+ function Oe({ onViewportChange: e } = {}) {
39
+ let { gl: n } = N(), r = A({
40
40
  w: 0,
41
41
  h: 0,
42
42
  dpr: 0
43
43
  });
44
- return E(() => {
45
- n.getDrawingBufferSize(V);
44
+ return D(() => {
45
+ n.getDrawingBufferSize(U);
46
46
  let i = n.getPixelRatio();
47
47
  r.current = {
48
- w: V.x,
49
- h: V.y,
48
+ w: U.x,
49
+ h: U.y,
50
50
  dpr: i
51
- }, t(V.x, V.y, i), e?.(V.x, V.y, i);
52
- }, [n, e]), oe(() => {
53
- n.getDrawingBufferSize(V);
51
+ }, t(U.x, U.y, i), e?.(U.x, U.y, i);
52
+ }, [n, e]), ae(() => {
53
+ n.getDrawingBufferSize(U);
54
54
  let i = n.getPixelRatio(), a = r.current;
55
- (V.x !== a.w || V.y !== a.h || i !== a.dpr) && (a.w = V.x, a.h = V.y, a.dpr = i, t(V.x, V.y, i), e?.(V.x, V.y, i));
55
+ (U.x !== a.w || U.y !== a.h || i !== a.dpr) && (a.w = U.x, a.h = U.y, a.dpr = i, t(U.x, U.y, i), e?.(U.x, U.y, i));
56
56
  }), null;
57
57
  }
58
- var Ae = new A.Vector3(-120, 85, -120), je = new A.Vector3(0, 0, 0), Me = new A.Vector3(0, 1, 0), Ne = new A.Vector3(), Pe = new A.Vector3(), Fe = new A.Vector3();
59
- new A.Matrix4().lookAt(Ae, je, Me).extractBasis(Ne, Pe, Fe);
60
- function Ie({ sunLightRef: e }) {
61
- return E(() => {
58
+ var ke = new M.Vector3(-120, 85, -120), Ae = new M.Vector3(0, 0, 0), je = new M.Vector3(0, 1, 0), Me = new M.Vector3(), Ne = new M.Vector3(), Pe = new M.Vector3();
59
+ new M.Matrix4().lookAt(ke, Ae, je).extractBasis(Me, Ne, Pe);
60
+ function Fe({ sunLightRef: e }) {
61
+ return D(() => {
62
62
  let t = e.current;
63
63
  if (!t) return;
64
64
  let n = t.shadow, r = n.updateMatrices;
65
65
  return n.updateMatrices = function(e) {
66
66
  if (e === t && t.castShadow) {
67
- let e = n.camera, r = n.mapSize.x || 1024, i = Math.max(1, e.right - e.left) / r, a = Math.round(t.target.position.dot(Ne) / i) * i, o = Math.round(t.target.position.dot(Pe) / i) * i, s = t.target.position.dot(Fe);
68
- t.target.position.set(0, 0, 0).addScaledVector(Ne, a).addScaledVector(Pe, o).addScaledVector(Fe, s), t.position.copy(t.target.position).add(Ae), t.updateMatrixWorld(), t.target.updateMatrixWorld();
67
+ let e = n.camera, r = n.mapSize.x || 1024, i = Math.max(1, e.right - e.left) / r, a = Math.round(t.target.position.dot(Me) / i) * i, o = Math.round(t.target.position.dot(Ne) / i) * i, s = t.target.position.dot(Pe);
68
+ t.target.position.set(0, 0, 0).addScaledVector(Me, a).addScaledVector(Ne, o).addScaledVector(Pe, s), t.position.copy(t.target.position).add(ke), t.updateMatrixWorld(), t.target.updateMatrixWorld();
69
69
  }
70
70
  return r.call(this, e);
71
71
  }, () => {
@@ -74,7 +74,7 @@ function Ie({ sunLightRef: e }) {
74
74
  }, [e]), null;
75
75
  }
76
76
  // src/engine/kolmoStore.ts
77
- var H = ye(() => ({
77
+ var W = ve(() => ({
78
78
  id: "",
79
79
  handle: null,
80
80
  centerOfMass: [
@@ -94,23 +94,34 @@ var H = ye(() => ({
94
94
  ],
95
95
  isFlight: !1,
96
96
  isTwoWheel: !1
97
- })), U = ye(() => ({
97
+ })), G = ve(() => ({
98
98
  id: "pilot",
99
99
  handle: null,
100
100
  exitSpawnPos: null,
101
101
  exitSpawnYaw: 0,
102
102
  exitLinVel: null
103
- })), Le = ye(() => ({
103
+ })), Ie = ve({
104
104
  id: "",
105
105
  radius: 4,
106
106
  kind: "vehicle"
107
- })), Re = ye(() => ({
107
+ }), Le = ve(() => ({
108
108
  id: "",
109
109
  getBody: () => null
110
- })), ze = B({ exclusive: !0 }), W = ye(() => ({
111
- activeVehicleId: null,
110
+ })), Re = H({ exclusive: !0 }), K = ve({
111
+ activeVehicleId: "",
112
112
  activeRetroPreset: "dreamcast"
113
- })), G = ve(W), K = {
113
+ }), ze = _e(K);
114
+ function Be() {
115
+ try {
116
+ return pe();
117
+ } catch {
118
+ return ze;
119
+ }
120
+ }
121
+ function q(e) {
122
+ e.has(K) || e.add(K);
123
+ }
124
+ var J = {
114
125
  speedKmh: 0,
115
126
  rpm: 0,
116
127
  gear: 1,
@@ -120,34 +131,36 @@ var H = ye(() => ({
120
131
  activeVehicleId: null,
121
132
  activeRetroPreset: "dreamcast",
122
133
  nearVehicleId: null
123
- }, Be = new A.Vector3(), Ve = new A.Vector3(), q = _e((e) => ({
134
+ }, Ve = new M.Vector3(), He = new M.Vector3(), Ue = ge((e) => ({
124
135
  boardVehicle: (t) => {
125
- let n = e.queryFirst(U);
126
- for (let r of e.query(H)) if (r.get(H)?.id === t) {
127
- n && n.add(ze(r));
136
+ q(e);
137
+ let n = e.queryFirst(G);
138
+ for (let r of e.query(W)) if (r.get(W)?.id === t) {
139
+ n && n.add(Re(r));
128
140
  break;
129
141
  }
130
- let r = e.get(W);
131
- e.set(W, {
142
+ let r = e.get(K);
143
+ e.set(K, {
132
144
  activeVehicleId: t,
133
145
  activeRetroPreset: r?.activeRetroPreset ?? "dreamcast"
134
- }), K.activeVehicleId = t, K.nearVehicleId = null;
146
+ }), J.activeVehicleId = t, J.nearVehicleId = null;
135
147
  },
136
148
  exitVehicle: () => {
137
- let t = e.get(W), n = t?.activeVehicleId, r = e.queryFirst(U);
138
- for (let t of e.query(H)) {
139
- let e = t.get(H);
140
- if (e && e.id === n) {
141
- if (r && (r.has(ze(t)) && r.remove(ze(t)), e.handle)) {
142
- Be.set(e.exitOffset[0] - e.centerOfMass[0], e.exitOffset[1] - e.centerOfMass[1], e.exitOffset[2] - e.centerOfMass[2]).applyQuaternion(e.handle.currQuat).add(e.handle.currPos), Ve.copy(e.handle.bodyZAxis).projectOnPlane(e.handle.upAxis).normalize();
143
- let t = Ve.lengthSq() > 1e-6 ? Math.atan2(Ve.x, Ve.z) : 0, n = e.handle.currLinVel;
144
- r.set(U, {
145
- id: r.get(U)?.id ?? "pilot",
149
+ q(e);
150
+ let t = e.get(K), n = t?.activeVehicleId || "", r = e.queryFirst(G);
151
+ for (let t of e.query(W)) {
152
+ let e = t.get(W);
153
+ if (e && n && e.id === n) {
154
+ if (r && (r.has(Re(t)) && r.remove(Re(t)), e.handle)) {
155
+ Ve.set(e.exitOffset[0] - e.centerOfMass[0], e.exitOffset[1] - e.centerOfMass[1], e.exitOffset[2] - e.centerOfMass[2]).applyQuaternion(e.handle.currQuat).add(e.handle.currPos), He.copy(e.handle.bodyZAxis).projectOnPlane(e.handle.upAxis).normalize();
156
+ let t = He.lengthSq() > 1e-6 ? Math.atan2(He.x, He.z) : 0, n = e.handle.currLinVel;
157
+ r.set(G, {
158
+ id: r.get(G)?.id ?? "pilot",
146
159
  handle: null,
147
160
  exitSpawnPos: [
148
- Be.x,
149
- Be.y,
150
- Be.z
161
+ Ve.x,
162
+ Ve.y,
163
+ Ve.z
151
164
  ],
152
165
  exitSpawnYaw: t,
153
166
  exitLinVel: [
@@ -166,10 +179,10 @@ var H = ye(() => ({
166
179
  });
167
180
  }
168
181
  }
169
- e.set(W, {
170
- activeVehicleId: null,
182
+ e.set(K, {
183
+ activeVehicleId: "",
171
184
  activeRetroPreset: t?.activeRetroPreset ?? "dreamcast"
172
- }), Object.assign(K, {
185
+ }), Object.assign(J, {
173
186
  activeVehicleId: null,
174
187
  mode: "foot",
175
188
  speedKmh: 0,
@@ -179,14 +192,14 @@ var H = ye(() => ({
179
192
  });
180
193
  },
181
194
  setRetroPreset: (t) => {
182
- o(t);
183
- let n = e.get(W);
184
- e.set(W, {
185
- activeVehicleId: n?.activeVehicleId ?? null,
195
+ q(e), o(t);
196
+ let n = e.get(K);
197
+ e.set(K, {
198
+ activeVehicleId: n?.activeVehicleId ?? "",
186
199
  activeRetroPreset: t
187
- }), K.activeRetroPreset = t;
200
+ }), J.activeRetroPreset = t;
188
201
  }
189
- })), He = [
202
+ })), We = [
190
203
  {
191
204
  name: "forward",
192
205
  keys: ["KeyW", "ArrowUp"]
@@ -231,13 +244,13 @@ var H = ye(() => ({
231
244
  name: "cameraView",
232
245
  keys: ["KeyV"]
233
246
  }
234
- ], Ue = ne(!1), We = new A.Vector3(), J = new A.Vector3();
235
- function Ge({ children: e, className: t, style: n, fov: r = 56, near: i = .15, far: a = 6500, cameraPosition: o = [
247
+ ], Ge = E(!1), Ke = new M.Vector3(), Y = new M.Vector3();
248
+ function qe({ children: e, className: t, style: n, fov: r = 56, near: i = .15, far: a = 6500, cameraPosition: o = [
236
249
  0,
237
250
  3.2,
238
251
  -8.5
239
252
  ], dpr: s = [1, 1.5], frameloop: c = "always", shadows: l = "basic", toneMapping: u, onCanvasReady: d, onContextLost: f, roomEnv: p = !1 }) {
240
- return /* @__PURE__ */ L(j, {
253
+ return /* @__PURE__ */ z(ie, {
241
254
  className: t,
242
255
  style: n ?? {
243
256
  width: "100%",
@@ -259,23 +272,29 @@ function Ge({ children: e, className: t, style: n, fov: r = 56, near: i = .15, f
259
272
  position: o
260
273
  },
261
274
  onCreated: ({ gl: e }) => {
262
- e.outputColorSpace = A.SRGBColorSpace;
275
+ e.outputColorSpace = M.SRGBColorSpace;
263
276
  let t = e.domElement;
264
277
  d?.(t), f && (t.addEventListener("webglcontextlost", (e) => {
265
278
  e.preventDefault(), f(!0);
266
279
  }), t.addEventListener("webglcontextrestored", () => f(!1)));
267
280
  },
268
- children: [p !== !1 && /* @__PURE__ */ I(Oe, { intensity: typeof p == "number" ? p : .65 }), e]
281
+ children: [p !== !1 && /* @__PURE__ */ R(De, { intensity: typeof p == "number" ? p : .65 }), e]
269
282
  });
270
283
  }
271
- function Ke({ retroPreset: e }) {
272
- let t = pe(G, W);
273
- return E(() => {
274
- e ? q(G).setRetroPreset(e) : t?.activeRetroPreset && o(t.activeRetroPreset);
275
- }, [e, t?.activeRetroPreset]), null;
284
+ function Je({ retroPreset: e }) {
285
+ let t = Be();
286
+ q(t);
287
+ let n = fe(t, K);
288
+ return D(() => {
289
+ e ? Ue(t).setRetroPreset(e) : n?.activeRetroPreset && o(n.activeRetroPreset);
290
+ }, [
291
+ t,
292
+ e,
293
+ n?.activeRetroPreset
294
+ ]), null;
276
295
  }
277
- function qe({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDebug: r = !1, retroPreset: i, skybox: a = "nebula", lighting: o = "default", fogExp2: c, sunLightRef: l, shadowSnap: u = !1, world: d = G, keyboardMap: f = He, children: p }) {
278
- let m = typeof e == "function", h = Array.isArray(e), g = !m && !h && typeof e == "object" && e.kind === "point", _ = m || g, v = g ? e.center[0] : 0, y = g ? e.center[1] : 0, b = g ? e.center[2] : 0, x = g ? e.surfaceG : e === "zero" ? 0 : 9.81, S = O(() => h ? [
296
+ function Ye({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDebug: r = !1, retroPreset: i, skybox: a = "nebula", lighting: o = "default", fogExp2: c, sunLightRef: l, shadowSnap: u = !1, world: d = ze, keyboardMap: f = We, children: p }) {
297
+ let m = typeof e == "function", h = Array.isArray(e), g = !m && !h && typeof e == "object" && e.kind === "point", _ = m || g, v = g ? e.center[0] : 0, y = g ? e.center[1] : 0, b = g ? e.center[2] : 0, x = g ? e.surfaceG : e === "zero" ? 0 : 9.81, S = k(() => h ? [
279
298
  e[0],
280
299
  e[1],
281
300
  e[2]
@@ -292,18 +311,18 @@ function qe({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDe
292
311
  _,
293
312
  e
294
313
  ]);
295
- E(() => {
296
- let t = de.getState().setGravityField;
297
- if (m) t((t) => e(t, J));
298
- else if (g) We.set(v, y, b), t((e) => {
299
- J.subVectors(e, We);
300
- let t = J.lengthSq();
301
- return t < 1e-8 ? J.set(0, -x, 0) : J.multiplyScalar(-x / Math.sqrt(t));
314
+ D(() => {
315
+ let t = ue.getState().setGravityField;
316
+ if (m) t((t) => e(t, Y));
317
+ else if (g) Ke.set(v, y, b), t((e) => {
318
+ Y.subVectors(e, Ke);
319
+ let t = Y.lengthSq();
320
+ return t < 1e-8 ? Y.set(0, -x, 0) : Y.multiplyScalar(-x / Math.sqrt(t));
302
321
  });
303
322
  else if (h) {
304
323
  let n = e[0], r = e[1], i = e[2];
305
- t(() => J.set(n, r, i));
306
- } else t(e === "zero" ? () => J.set(0, 0, 0) : () => J.set(0, -9.81, 0));
324
+ t(() => Y.set(n, r, i));
325
+ } else t(e === "zero" ? () => Y.set(0, 0, 0) : () => Y.set(0, -9.81, 0));
307
326
  }, [
308
327
  m,
309
328
  g,
@@ -314,14 +333,14 @@ function qe({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDe
314
333
  b,
315
334
  x
316
335
  ]);
317
- let C = /* @__PURE__ */ L(me, { children: [
318
- /* @__PURE__ */ I(Ke, { retroPreset: i }),
319
- u && l && /* @__PURE__ */ I(Ie, { sunLightRef: l }),
320
- a === "nebula" && /* @__PURE__ */ I(s, {}),
321
- a === "day" && /* @__PURE__ */ L(me, { children: [/* @__PURE__ */ I("color", {
336
+ let C = /* @__PURE__ */ z(L, { children: [
337
+ /* @__PURE__ */ R(Je, { retroPreset: i }),
338
+ u && l && /* @__PURE__ */ R(Fe, { sunLightRef: l }),
339
+ a === "nebula" && /* @__PURE__ */ R(s, {}),
340
+ a === "day" && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("color", {
322
341
  attach: "background",
323
342
  args: ["#6ba6d6"]
324
- }), !c && /* @__PURE__ */ I("fog", {
343
+ }), !c && /* @__PURE__ */ R("fog", {
325
344
  attach: "fog",
326
345
  args: [
327
346
  "#9dc4e2",
@@ -329,17 +348,17 @@ function qe({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDe
329
348
  520
330
349
  ]
331
350
  })] }),
332
- c && /* @__PURE__ */ I("fogExp2", {
351
+ c && /* @__PURE__ */ R("fogExp2", {
333
352
  attach: "fog",
334
353
  args: c
335
354
  }),
336
- o === "default" && /* @__PURE__ */ L(me, { children: [
337
- /* @__PURE__ */ I("hemisphereLight", { args: [
355
+ o === "default" && /* @__PURE__ */ z(L, { children: [
356
+ /* @__PURE__ */ R("hemisphereLight", { args: [
338
357
  "#b8dcff",
339
358
  "#241d30",
340
359
  .8
341
360
  ] }),
342
- /* @__PURE__ */ I("directionalLight", {
361
+ /* @__PURE__ */ R("directionalLight", {
343
362
  ref: l,
344
363
  position: [
345
364
  48,
@@ -351,7 +370,7 @@ function qe({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDe
351
370
  castShadow: !0,
352
371
  "shadow-mapSize": [1024, 1024]
353
372
  }),
354
- /* @__PURE__ */ I("directionalLight", {
373
+ /* @__PURE__ */ R("directionalLight", {
355
374
  position: [
356
375
  -42,
357
376
  28,
@@ -361,72 +380,74 @@ function qe({ gravity: e = "planar", paused: t = !1, timeScale: n = 1, physicsDe
361
380
  color: "#68a8ff"
362
381
  })
363
382
  ] }),
364
- /* @__PURE__ */ I(P, {
383
+ /* @__PURE__ */ R(F, {
365
384
  paused: t,
366
385
  timeScale: n,
367
386
  gravity: S,
368
387
  debug: r,
369
- children: /* @__PURE__ */ I(te, {
388
+ children: /* @__PURE__ */ R(te, {
370
389
  fallback: null,
371
390
  children: p
372
391
  })
373
392
  })
374
- ] }), w = f ? /* @__PURE__ */ I(M, {
393
+ ] }), w = f ? /* @__PURE__ */ R(oe, {
375
394
  map: f,
376
395
  children: C
377
- }) : C, T = /* @__PURE__ */ I(Ue.Provider, {
396
+ }) : C, T = /* @__PURE__ */ R(Ge.Provider, {
378
397
  value: _,
379
398
  children: w
380
399
  });
381
- return d ? /* @__PURE__ */ I(fe, {
400
+ return d && q(d), d ? /* @__PURE__ */ R(de, {
382
401
  world: d,
383
402
  children: T
384
403
  }) : T;
385
404
  }
386
405
  // src/engine/kolmoVehicle.tsx
387
- var Y = new A.Vector3(), X = new A.Vector3(), Je = new A.Vector3(), Ye = new A.Vector3(), Xe = new A.Vector3();
388
- function Ze(e) {
406
+ var X = new M.Vector3(), Xe = new M.Vector3(), Ze = new M.Vector3(), Qe = new M.Vector3(), $e = new M.Vector3();
407
+ function et(e) {
389
408
  e.traverse((e) => {
390
409
  let t = e.userData?.gltfExtensions?.[l];
391
410
  t && !e.userData.KOLMO_emitter && (e.userData[l] = t);
392
411
  });
393
412
  }
394
- function Qe({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
413
+ function tt({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
395
414
  0,
396
415
  .35,
397
416
  0
398
417
  ], rotation: o, piloted: s = !1, flightMode: c = !1, vehicleMode: l, twoWheel: p = !1, enable: m = !0, ccd: h, linearDamping: g, angularDamping: _, userData: v, onCollisionEnter: y, wheelConfig: b, carConfig: x, droneConfig: S, vehicleRef: C, driver: w, cameraController: T, children: ee }) {
399
- let te = ie(Ue), ne = pe(G, W), [, ae] = ce(), j = O(() => le(t), [t]), se = O(() => d(j), [j]), M = O(() => (Ze(j.scene), f(j.scene, r)), [j, r]);
400
- D(() => {
401
- n(j.scene);
402
- for (let e of j.wheels) n(e.object);
403
- for (let e of j.propellers) n(e.object);
404
- }, [j]);
405
- let N = !!(l === "rocket" || c || l !== "drive" && j.propellers.length > 0), P = O(() => p || !!j.tune?.twoWheelBalance || j.wheels.length === 2 && Math.abs(j.wheels[0].position[0] - j.wheels[1].position[0]) < .25, [p, j]), F = O(() => M.sockets.find((e) => e.role === "seat" || e.role === "optic")?.localPosition ?? [
418
+ let te = re(Ge), E = Be();
419
+ q(E);
420
+ let j = fe(E, K), [, ie] = se(), N = k(() => ce(t), [t]), oe = k(() => d(N), [N]), P = k(() => (et(N.scene), f(N.scene, r)), [N, r]);
421
+ O(() => {
422
+ n(N.scene);
423
+ for (let e of N.wheels) n(e.object);
424
+ for (let e of N.propellers) n(e.object);
425
+ }, [N]);
426
+ let F = !!(l === "rocket" || c || l !== "drive" && N.propellers.length > 0), I = k(() => p || !!N.tune?.twoWheelBalance || N.wheels.length === 2 && Math.abs(N.wheels[0].position[0] - N.wheels[1].position[0]) < .25, [p, N]), le = k(() => P.sockets.find((e) => e.role === "seat" || e.role === "optic")?.localPosition ?? [
406
427
  0,
407
428
  .65,
408
429
  0
409
- ], [M]), ue = O(() => M.sockets.find((e) => e.role === "exit")?.localPosition ?? [
430
+ ], [P]), ue = k(() => P.sockets.find((e) => e.role === "exit")?.localPosition ?? [
410
431
  -1.55,
411
432
  .45,
412
433
  0
413
- ], [M]), de = O(() => ({
414
- ...P ? {
434
+ ], [P]), de = k(() => ({
435
+ ...I ? {
415
436
  twoWheelBalance: !0,
416
437
  maxLeanAngle: .78
417
438
  } : {},
418
- ...j.tune ?? {},
439
+ ...N.tune ?? {},
419
440
  ...x ?? {}
420
441
  }), [
421
- P,
422
- j.tune,
442
+ I,
443
+ N.tune,
423
444
  x
424
- ]), fe = O(() => {
445
+ ]), pe = k(() => {
425
446
  if (b || l !== void 0) return {
426
447
  ...l === void 0 ? {} : { enable: l === "drive" },
427
448
  ...b ?? {}
428
449
  };
429
- }, [b, l]), me = O(() => N ? {
450
+ }, [b, l]), L = k(() => F ? {
430
451
  controlMode: "VELOCITY",
431
452
  maxHorizSpeed: 46,
432
453
  maxVertSpeed: 16,
@@ -434,13 +455,13 @@ function Qe({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
434
455
  maxTiltAngle: .52,
435
456
  HORIZ_VEL_P: 1.8,
436
457
  VERT_VEL_P: 2.8,
437
- ...j.droneTune ?? {},
458
+ ...N.droneTune ?? {},
438
459
  ...S ?? {}
439
460
  } : S, [
440
- N,
441
- j.droneTune,
461
+ F,
462
+ N.droneTune,
442
463
  S
443
- ]), he = k(null), R = k(u()), z = k(new A.Vector3()), ge = k({
464
+ ]), me = A(null), B = A(u()), V = A(new M.Vector3()), he = A({
444
465
  camInit: !1,
445
466
  cockpit: !1,
446
467
  prevCam: !1,
@@ -448,7 +469,7 @@ function Qe({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
448
469
  prevR: !1,
449
470
  turnL: !1,
450
471
  turnR: !1
451
- }), _e = k({
472
+ }), ge = A({
452
473
  forward: !1,
453
474
  backward: !1,
454
475
  steerLeft: !1,
@@ -463,57 +484,62 @@ function Qe({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
463
484
  rollLeft: !1,
464
485
  rollRight: !1
465
486
  });
466
- E(() => {
467
- let t = G.spawn(H({
487
+ D(() => {
488
+ let t = E.spawn(W({
468
489
  id: e,
469
- handle: he.current,
470
- centerOfMass: [...j.centerOfMass],
471
- seatOffset: F,
490
+ handle: me.current,
491
+ centerOfMass: [...N.centerOfMass],
492
+ seatOffset: le,
472
493
  exitOffset: ue,
473
- isFlight: N,
474
- isTwoWheel: P
475
- }), Le({
494
+ isFlight: F,
495
+ isTwoWheel: I
496
+ }), Ie({
476
497
  id: e,
477
498
  radius: 4.2,
478
499
  kind: "vehicle"
479
500
  }));
480
- return s && G.get(W)?.activeVehicleId === null && q(G).boardVehicle(e), () => {
481
- G.get(W)?.activeVehicleId === e && q(G).exitVehicle(), t.destroy();
501
+ return s && !E.get(K)?.activeVehicleId && Ue(E).boardVehicle(e), () => {
502
+ E.get(K)?.activeVehicleId === e && Ue(E).exitVehicle(), t.destroy();
482
503
  };
483
504
  }, [
505
+ E,
484
506
  e,
485
- j,
486
- F,
487
- ue,
488
507
  N,
489
- P,
508
+ le,
509
+ ue,
510
+ F,
511
+ I,
490
512
  s
491
513
  ]);
492
- let ve = re((t) => {
493
- he.current = t, C && (C.current = t);
494
- for (let n of G.query(H)) {
495
- let r = n.get(H);
496
- r && r.id === e && n.set(H, {
514
+ let _e = ne((t) => {
515
+ me.current = t, C && (C.current = t);
516
+ for (let n of E.query(W)) {
517
+ let r = n.get(W);
518
+ r && r.id === e && n.set(W, {
497
519
  ...r,
498
520
  handle: t
499
521
  });
500
522
  }
501
- }, [e, C]), B = ne?.activeVehicleId === e || s && ne?.activeVehicleId === null;
502
- return oe((t, n) => {
523
+ }, [
524
+ E,
525
+ e,
526
+ C
527
+ ]), H = j?.activeVehicleId === e || s && !j?.activeVehicleId;
528
+ return ae((t, n) => {
503
529
  let r = Math.min(Math.max(n, 1e-4), .05);
504
- se.step(r);
505
- let i = he.current;
530
+ oe.step(r);
531
+ let i = me.current;
506
532
  if (!i || !i.body) return;
507
533
  if (w) {
508
534
  w(i, r, t), T && T(i, r, t);
509
535
  return;
510
536
  }
511
- let a = ae(), o = _e.current, s = R.current, c = ge.current;
512
- if (B) {
513
- if (a.cameraView && !c.prevCam && (c.cockpit = !c.cockpit), c.prevCam = a.cameraView, N) o.pitchForward = a.forward, o.pitchBackward = a.backward, o.yawLeft = a.left, o.yawRight = a.right, o.rollLeft = a.turnLeft, o.rollRight = a.turnRight, o.throttleUp = a.brake, o.throttleDown = a.descend, o.forward = !1, o.backward = !1, o.steerLeft = !1, o.steerRight = !1, o.brake = !1, a.boost && i.body.applyImpulse(Xe.copy(i.bodyZAxis).multiplyScalar(i.body.mass() * 14 * r), !1);
537
+ let a = ie(), o = ge.current, s = B.current, c = he.current;
538
+ if (H) {
539
+ if (a.cameraView && !c.prevCam && (c.cockpit = !c.cockpit), c.prevCam = a.cameraView, F) o.pitchForward = a.forward, o.pitchBackward = a.backward, o.yawLeft = a.left, o.yawRight = a.right, o.rollLeft = a.turnLeft, o.rollRight = a.turnRight, o.throttleUp = a.brake, o.throttleDown = a.descend, o.forward = !1, o.backward = !1, o.steerLeft = !1, o.steerRight = !1, o.brake = !1, a.boost && i.body.applyImpulse($e.copy(i.bodyZAxis).multiplyScalar(i.body.mass() * 14 * r), !1);
514
540
  else if (a.turnLeft && !c.prevL && (c.turnL = !c.turnL, c.turnR = !1), a.turnRight && !c.prevR && (c.turnR = !c.turnR, c.turnL = !1), c.prevL = a.turnLeft, c.prevR = a.turnRight, o.forward = a.forward, o.backward = a.backward, o.steerLeft = a.left, o.steerRight = a.right, o.brake = a.brake, o.pitchForward = !1, o.pitchBackward = !1, o.throttleUp = !1, o.throttleDown = !1, o.yawLeft = !1, o.yawRight = !1, o.rollLeft = !1, o.rollRight = !1, a.boost && a.forward) {
515
541
  for (let e of i.wheelsInfo.values()) if (e.current.rayHit) {
516
- i.body.applyImpulse(Xe.copy(i.bodyZAxis).multiplyScalar(i.body.mass() * 6.5 * r), !1);
542
+ i.body.applyImpulse($e.copy(i.bodyZAxis).multiplyScalar(i.body.mass() * 6.5 * r), !1);
517
543
  break;
518
544
  }
519
545
  }
@@ -526,26 +552,26 @@ function Qe({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
526
552
  u /= i.propellersInfo.size;
527
553
  }
528
554
  let d = i.currLinVel.dot(i.bodyZAxis);
529
- if (s.throttle = B ? N ? a.forward || a.brake ? 1 : Math.max(.22, u) : +!!a.forward : 0, s.boost = B ? N ? a.boost ? 1 : a.forward ? .58 : .16 : a.boost && a.forward ? 1 : 0 : 0, s.brake = B && !N && (a.brake || a.backward && d > 1) ? 1 : 0, s.reverse = B && !N && a.backward && d <= 1 ? 1 : 0, s.slip = Math.min(1, l), s.turn_l = +!!c.turnL, s.turn_r = +!!c.turnR, s.headlight = 1, s.always = 1, !B) return;
530
- if (K.speedKmh = i.currLinVel.length() * 3.6, K.rpm = Math.round(N ? 1800 + s.throttle * 6200 + s.boost * 4200 : i.engineRPM), K.gear = N ? a.boost ? 2 : 1 : i.gearIndex + 1, K.throttle = s.throttle, K.boost = s.boost, K.mode = N ? "flight" : P ? "motorcycle" : "car", K.activeVehicleId = e, T) {
555
+ if (s.throttle = H ? F ? a.forward || a.brake ? 1 : Math.max(.22, u) : +!!a.forward : 0, s.boost = H ? F ? a.boost ? 1 : a.forward ? .58 : .16 : a.boost && a.forward ? 1 : 0 : 0, s.brake = H && !F && (a.brake || a.backward && d > 1) ? 1 : 0, s.reverse = H && !F && a.backward && d <= 1 ? 1 : 0, s.slip = Math.min(1, l), s.turn_l = +!!c.turnL, s.turn_r = +!!c.turnR, s.headlight = 1, s.always = 1, !H) return;
556
+ if (J.speedKmh = i.currLinVel.length() * 3.6, J.rpm = Math.round(F ? 1800 + s.throttle * 6200 + s.boost * 4200 : i.engineRPM), J.gear = F ? a.boost ? 2 : 1 : i.gearIndex + 1, J.throttle = s.throttle, J.boost = s.boost, J.mode = F ? "flight" : I ? "motorcycle" : "car", J.activeVehicleId = e, T) {
531
557
  T(i, r, t);
532
558
  return;
533
559
  }
534
- if (Y.copy(i.upAxis), Y.lengthSq() < 1e-6 && Y.copy(i.bodyYAxis), c.cockpit) {
535
- let e = j.centerOfMass;
536
- Je.set(F[0] - e[0], F[1] - e[1] + .32, F[2] - e[2]).applyQuaternion(i.currQuat).add(i.currPos), Ye.copy(Je).addScaledVector(i.bodyZAxis, 24), be.damp3(t.camera.position, Je, .04, r), be.damp3(t.camera.up, i.bodyYAxis, .08, r), t.camera.lookAt(Ye);
560
+ if (X.copy(i.upAxis), X.lengthSq() < 1e-6 && X.copy(i.bodyYAxis), c.cockpit) {
561
+ let e = N.centerOfMass;
562
+ Ze.set(le[0] - e[0], le[1] - e[1] + .32, le[2] - e[2]).applyQuaternion(i.currQuat).add(i.currPos), Qe.copy(Ze).addScaledVector(i.bodyZAxis, 24), ye.damp3(t.camera.position, Ze, .04, r), ye.damp3(t.camera.up, i.bodyYAxis, .08, r), t.camera.lookAt(Qe);
537
563
  return;
538
564
  }
539
- X.copy(i.bodyZAxis), N || X.projectOnPlane(Y).normalize(), X.lengthSq() < 1e-6 && X.copy(i.bodyZAxis);
540
- let f = N ? 11.2 : P ? 5.2 : 6.8, p = N ? 3.1 : P ? 1.85 : 2.15;
541
- Je.copy(i.currPos).addScaledVector(X, -f).addScaledVector(Y, p), Ye.copy(i.currPos).addScaledVector(X, N ? 7.5 : 3.6).addScaledVector(Y, .65), c.camInit ||= (t.camera.position.copy(Je), z.current.copy(Ye), !0), be.damp3(t.camera.position, Je, .14, r), be.damp3(z.current, Ye, .08, r), be.damp3(t.camera.up, Y, .16, r), t.camera.lookAt(z.current);
542
- }), /* @__PURE__ */ I("group", {
565
+ Xe.copy(i.bodyZAxis), F || Xe.projectOnPlane(X).normalize(), Xe.lengthSq() < 1e-6 && Xe.copy(i.bodyZAxis);
566
+ let f = F ? 11.2 : I ? 5.2 : 6.8, p = F ? 3.1 : I ? 1.85 : 2.15;
567
+ Ze.copy(i.currPos).addScaledVector(Xe, -f).addScaledVector(X, p), Qe.copy(i.currPos).addScaledVector(Xe, F ? 7.5 : 3.6).addScaledVector(X, .65), c.camInit ||= (t.camera.position.copy(Ze), V.current.copy(Qe), !0), ye.damp3(t.camera.position, Ze, .14, r), ye.damp3(V.current, Qe, .08, r), ye.damp3(t.camera.up, X, .16, r), t.camera.lookAt(V.current);
568
+ }), /* @__PURE__ */ R("group", {
543
569
  onClick: (e) => {
544
- e.delta <= 5 && se.toggleHitObject(e.object) && e.stopPropagation();
570
+ e.delta <= 5 && oe.toggleHitObject(e.object) && e.stopPropagation();
545
571
  },
546
- children: /* @__PURE__ */ L(xe, {
547
- ref: ve,
548
- bundle: j,
572
+ children: /* @__PURE__ */ z(be, {
573
+ ref: _e,
574
+ bundle: N,
549
575
  position: a,
550
576
  rotation: o,
551
577
  enable: m,
@@ -555,28 +581,28 @@ function Qe({ id: e, sourceBundle: t, rawGlbBytes: r, position: a = [
555
581
  userData: v,
556
582
  onCollisionEnter: y,
557
583
  enableCustomGravity: te,
558
- wheelConfig: fe,
584
+ wheelConfig: pe,
559
585
  carConfig: de,
560
- droneConfig: me,
561
- children: [/* @__PURE__ */ I(i, {
562
- emitters: M.emitters,
563
- signalsRef: R
586
+ droneConfig: L,
587
+ children: [/* @__PURE__ */ R(i, {
588
+ emitters: P.emitters,
589
+ signalsRef: B
564
590
  }), ee]
565
591
  })
566
592
  });
567
593
  }
568
- function $e(e) {
569
- return /* @__PURE__ */ I(Qe, {
594
+ function nt(e) {
595
+ return /* @__PURE__ */ R(tt, {
570
596
  ...e,
571
- sourceBundle: ue(e.src)
597
+ sourceBundle: le(e.src)
572
598
  });
573
599
  }
574
- function et(e) {
575
- let [t, n] = ae(null);
576
- return E(() => {
600
+ function rt(e) {
601
+ let [t, n] = j(null);
602
+ return D(() => {
577
603
  if (e.bundle || e.src || !e.rawGlbBytes) return;
578
604
  let t = !0;
579
- return F(e.rawGlbBytes).then((e) => {
605
+ return I(e.rawGlbBytes).then((e) => {
580
606
  t && n(e);
581
607
  }), () => {
582
608
  t = !1;
@@ -585,64 +611,64 @@ function et(e) {
585
611
  e.bundle,
586
612
  e.src,
587
613
  e.rawGlbBytes
588
- ]), e.bundle ? /* @__PURE__ */ I(Qe, {
614
+ ]), e.bundle ? /* @__PURE__ */ R(tt, {
589
615
  ...e,
590
616
  sourceBundle: e.bundle
591
- }) : e.src ? /* @__PURE__ */ I($e, {
617
+ }) : e.src ? /* @__PURE__ */ R(nt, {
592
618
  ...e,
593
619
  src: e.src
594
- }) : t ? /* @__PURE__ */ I(Qe, {
620
+ }) : t ? /* @__PURE__ */ R(tt, {
595
621
  ...e,
596
622
  sourceBundle: t
597
623
  }) : null;
598
624
  }
599
625
  // src/engine/kolmoActor.tsx
600
- var tt = new A.Vector3();
601
- function nt() {
602
- let t = O(() => ({
603
- suit: e(new A.MeshStandardMaterial({
626
+ var it = new M.Vector3();
627
+ function at() {
628
+ let t = k(() => ({
629
+ suit: e(new M.MeshStandardMaterial({
604
630
  color: "#e2e8f0",
605
631
  roughness: .55,
606
632
  metalness: .15
607
633
  })),
608
- visor: e(new A.MeshStandardMaterial({
634
+ visor: e(new M.MeshStandardMaterial({
609
635
  color: "#38bdf8",
610
636
  emissive: "#0284c7",
611
637
  emissiveIntensity: .55,
612
638
  roughness: .2
613
639
  })),
614
- pack: e(new A.MeshStandardMaterial({
640
+ pack: e(new M.MeshStandardMaterial({
615
641
  color: "#334155",
616
642
  roughness: .7
617
643
  }))
618
644
  }), []);
619
- return D(() => () => {
645
+ return O(() => () => {
620
646
  t.suit.dispose(), t.visor.dispose(), t.pack.dispose();
621
- }, [t]), /* @__PURE__ */ L("group", { children: [
622
- /* @__PURE__ */ I("mesh", {
647
+ }, [t]), /* @__PURE__ */ z("group", { children: [
648
+ /* @__PURE__ */ R("mesh", {
623
649
  castShadow: !0,
624
650
  material: t.suit,
625
- children: /* @__PURE__ */ I("capsuleGeometry", { args: [
651
+ children: /* @__PURE__ */ R("capsuleGeometry", { args: [
626
652
  .28,
627
653
  .56,
628
654
  6,
629
655
  12
630
656
  ] })
631
657
  }),
632
- /* @__PURE__ */ I("mesh", {
658
+ /* @__PURE__ */ R("mesh", {
633
659
  position: [
634
660
  0,
635
661
  .24,
636
662
  .22
637
663
  ],
638
664
  material: t.visor,
639
- children: /* @__PURE__ */ I("boxGeometry", { args: [
665
+ children: /* @__PURE__ */ R("boxGeometry", { args: [
640
666
  .34,
641
667
  .16,
642
668
  .14
643
669
  ] })
644
670
  }),
645
- /* @__PURE__ */ I("mesh", {
671
+ /* @__PURE__ */ R("mesh", {
646
672
  position: [
647
673
  0,
648
674
  .06,
@@ -650,7 +676,7 @@ function nt() {
650
676
  ],
651
677
  castShadow: !0,
652
678
  material: t.pack,
653
- children: /* @__PURE__ */ I("boxGeometry", { args: [
679
+ children: /* @__PURE__ */ R("boxGeometry", { args: [
654
680
  .32,
655
681
  .42,
656
682
  .16
@@ -658,12 +684,14 @@ function nt() {
658
684
  })
659
685
  ] });
660
686
  }
661
- function rt({ position: e = [
687
+ function ot({ position: e = [
662
688
  0,
663
689
  1.4,
664
690
  0
665
691
  ], enabled: t = !0 }) {
666
- let n = ie(Ue), r = pe(G, W), [, i] = ce(), a = k(null), o = k(null), s = k(new A.Vector3()), c = k(new A.Vector3(0, 1, 0)), l = k(!1), u = k(0), d = k({
692
+ let n = re(Ge), r = Be();
693
+ q(r);
694
+ let i = fe(r, K), [, a] = se(), o = A(null), s = A(null), c = A(new M.Vector3()), l = A(new M.Vector3(0, 1, 0)), u = A(!1), d = A(0), f = A({
667
695
  forward: !1,
668
696
  backward: !1,
669
697
  leftward: !1,
@@ -671,8 +699,8 @@ function rt({ position: e = [
671
699
  run: !1,
672
700
  jump: !1
673
701
  });
674
- E(() => {
675
- let e = G.spawn(U({
702
+ D(() => {
703
+ let e = r.spawn(G({
676
704
  id: "pilot",
677
705
  handle: null,
678
706
  exitSpawnPos: null,
@@ -682,17 +710,17 @@ function rt({ position: e = [
682
710
  return () => {
683
711
  e.destroy();
684
712
  };
685
- }, []);
686
- let f = re((e) => {
687
- a.current = e;
688
- let t = G.queryFirst(U);
713
+ }, [r]);
714
+ let p = ne((e) => {
715
+ o.current = e;
716
+ let t = r.queryFirst(G);
689
717
  if (t) {
690
- let n = t.get(U);
718
+ let n = t.get(G);
691
719
  e?.body && n?.exitLinVel && e.body.setLinvel({
692
720
  x: n.exitLinVel[0],
693
721
  y: n.exitLinVel[1],
694
722
  z: n.exitLinVel[2]
695
- }, !0), t.set(U, {
723
+ }, !0), t.set(G, {
696
724
  id: n?.id ?? "pilot",
697
725
  handle: e,
698
726
  exitSpawnPos: n?.exitSpawnPos ?? null,
@@ -700,59 +728,59 @@ function rt({ position: e = [
700
728
  exitLinVel: e?.body ? null : n?.exitLinVel ?? null
701
729
  });
702
730
  }
703
- }, []), p = r?.activeVehicleId ?? null, m = t && p === null, h = G.queryFirst(U)?.get(U), g = h?.exitSpawnPos ?? e, _ = O(() => [
731
+ }, [r]), m = i?.activeVehicleId || "", h = t && !m, g = r.queryFirst(G)?.get(G), _ = g?.exitSpawnPos ?? e, v = k(() => [
704
732
  0,
705
- h?.exitSpawnYaw ?? 0,
733
+ g?.exitSpawnYaw ?? 0,
706
734
  0
707
- ], [h?.exitSpawnYaw]);
708
- return oe((e, n) => {
735
+ ], [g?.exitSpawnYaw]);
736
+ return ae((e, n) => {
709
737
  if (!t) return;
710
- let r = Math.min(Math.max(n, 1e-4), .05);
711
- u.current > 0 && (u.current = Math.max(0, u.current - r));
712
- let f = i(), m = f.interact && !l.current;
713
- if (l.current = f.interact, p !== null) {
714
- m && u.current === 0 && (u.current = .25, q(G).exitVehicle());
738
+ let i = Math.min(Math.max(n, 1e-4), .05);
739
+ d.current > 0 && (d.current = Math.max(0, d.current - i));
740
+ let p = a(), h = p.interact && !u.current;
741
+ if (u.current = p.interact, m) {
742
+ h && d.current === 0 && (d.current = .25, Ue(r).exitVehicle());
715
743
  return;
716
744
  }
717
- let h = a.current;
718
- if (!h || !h.body) return;
719
- let g = d.current;
720
- g.forward = f.forward, g.backward = f.backward, g.leftward = f.left, g.rightward = f.right, g.run = f.boost, g.jump = f.brake, h.setMovement(g), K.mode = "foot", K.speedKmh = h.moveSpeed * 3.6, K.rpm = 0, K.gear = 0, K.throttle = +!!h.isMoving, K.boost = f.boost && h.isMoving ? 1 : 0;
721
- let _ = null, v = Infinity;
722
- for (let e of G.query(H, Le)) {
723
- let t = e.get(H), n = e.get(Le);
745
+ let g = o.current;
746
+ if (!g || !g.body) return;
747
+ let _ = f.current;
748
+ _.forward = p.forward, _.backward = p.backward, _.leftward = p.left, _.rightward = p.right, _.run = p.boost, _.jump = p.brake, g.setMovement(_), J.mode = "foot", J.speedKmh = g.moveSpeed * 3.6, J.rpm = 0, J.gear = 0, J.throttle = +!!g.isMoving, J.boost = p.boost && g.isMoving ? 1 : 0;
749
+ let v = null, y = Infinity;
750
+ for (let e of r.query(W, Ie)) {
751
+ let t = e.get(W), n = e.get(Ie);
724
752
  if (!t?.handle || !n) continue;
725
- tt.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);
726
- let r = h.currPos.distanceToSquared(tt);
727
- r <= n.radius * n.radius && r < v && (v = r, _ = t.id);
753
+ it.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);
754
+ let r = g.currPos.distanceToSquared(it);
755
+ r <= n.radius * n.radius && r < y && (y = r, v = t.id);
728
756
  }
729
- K.nearVehicleId = _, m && _ && u.current === 0 ? (u.current = .25, q(G).boardVehicle(_)) : o.current && h.currPos.lengthSq() > 0 && (s.current.copy(h.currPos).addScaledVector(h.bodyYAxis, .55), c.current.copy(h.upAxis), o.current.moveTo(s.current.x, s.current.y, s.current.z, !0), e.camera.up.lerp(c.current, .14), o.current.setUp(e.camera.up));
730
- }), m ? /* @__PURE__ */ L(me, { children: [/* @__PURE__ */ I(Ce, {
731
- ref: o,
757
+ J.nearVehicleId = v, h && v && d.current === 0 ? (d.current = .25, Ue(r).boardVehicle(v)) : s.current && g.currPos.lengthSq() > 0 && (c.current.copy(g.currPos).addScaledVector(g.bodyYAxis, .55), l.current.copy(g.upAxis), s.current.moveTo(c.current.x, c.current.y, c.current.z, !0), e.camera.up.lerp(l.current, .14), s.current.setUp(e.camera.up));
758
+ }), h ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(Se, {
759
+ ref: s,
732
760
  makeDefault: !0,
733
761
  minPolarAngle: .12,
734
762
  maxPolarAngle: Math.PI - .12,
735
763
  smoothTime: .08
736
- }), /* @__PURE__ */ I(Se, {
737
- ref: f,
738
- position: g,
739
- rotation: _,
764
+ }), /* @__PURE__ */ R(xe, {
765
+ ref: p,
766
+ position: _,
767
+ rotation: v,
740
768
  enableCustomGravity: n,
741
769
  maxWalkVel: 3.2,
742
770
  maxRunVel: 7.2,
743
771
  jumpVel: 5.8,
744
772
  userData: { ecctrl: { excludeVehicleRay: !0 } },
745
- children: /* @__PURE__ */ I(nt, {})
773
+ children: /* @__PURE__ */ R(at, {})
746
774
  })] }) : null;
747
775
  }
748
776
  // src/engine/kolmoIsland.tsx
749
- var it = /* @__PURE__ */ new Map();
750
- function at(e = 77, t = 960) {
751
- let n = `${e}:${t}`, r = it.get(n);
752
- return r || (r = b(e, { size: t }), it.set(n, r)), r;
777
+ var st = /* @__PURE__ */ new Map();
778
+ function ct(e = 77, t = 960) {
779
+ let n = `${e}:${t}`, r = st.get(n);
780
+ return r || (r = b(e, { size: t }), st.set(n, r)), r;
753
781
  }
754
- function ot(e = 77, t = 960) {
755
- let n = at(e, t), r = n.road.at(n.road.length * .48), i = Math.atan2(r.tangent[0], r.tangent[2]);
782
+ function lt(e = 77, t = 960) {
783
+ let n = ct(e, t), r = n.road.at(n.road.length * .48), i = Math.atan2(r.tangent[0], r.tangent[2]);
756
784
  return {
757
785
  vehiclePos: [
758
786
  r.pos[0],
@@ -771,68 +799,68 @@ function ot(e = 77, t = 960) {
771
799
  ]
772
800
  };
773
801
  }
774
- function st(e) {
802
+ function ut(e) {
775
803
  if (e === "FoundationSquare") {
776
- let e = new A.BoxGeometry(3, .36, 3);
804
+ let e = new M.BoxGeometry(3, .36, 3);
777
805
  return e.translate(0, -.18, 0), {
778
806
  geo: e,
779
807
  color: "#64748b"
780
808
  };
781
809
  }
782
810
  if (e === "Street") {
783
- let e = new A.BoxGeometry(3, .14, 3);
811
+ let e = new M.BoxGeometry(3, .14, 3);
784
812
  return e.translate(0, .05, 0), {
785
813
  geo: e,
786
814
  color: "#475569"
787
815
  };
788
816
  }
789
817
  if (e === "Wall") {
790
- let e = new A.BoxGeometry(3, 3, .22);
818
+ let e = new M.BoxGeometry(3, 3, .22);
791
819
  return e.translate(0, 1.5, 0), {
792
820
  geo: e,
793
821
  color: "#cbd5e1"
794
822
  };
795
823
  }
796
824
  if (e === "Doorway") {
797
- let e = new A.BoxGeometry(3, .85, .24);
825
+ let e = new M.BoxGeometry(3, .85, .24);
798
826
  return e.translate(0, 2.575, 0), {
799
827
  geo: e,
800
828
  color: "#94a3b8"
801
829
  };
802
830
  }
803
831
  if (e === "DoorLeaf") {
804
- let e = new A.BoxGeometry(.92, 2.12, .1);
832
+ let e = new M.BoxGeometry(.92, 2.12, .1);
805
833
  return e.translate(0, 1.06, 0), {
806
834
  geo: e,
807
835
  color: "#d97706"
808
836
  };
809
837
  }
810
838
  if (e === "Stairs") {
811
- let e = new A.BoxGeometry(1.4, .24, 3.8);
839
+ let e = new M.BoxGeometry(1.4, .24, 3.8);
812
840
  return e.rotateX(-Math.PI / 4), e.translate(0, 1.5, 0), {
813
841
  geo: e,
814
842
  color: "#a16207"
815
843
  };
816
844
  }
817
845
  if (e === "Roof") {
818
- let e = new A.BoxGeometry(3.16, .26, 3.16);
846
+ let e = new M.BoxGeometry(3.16, .26, 3.16);
819
847
  return e.translate(0, .13, 0), {
820
848
  geo: e,
821
849
  color: "#be123c"
822
850
  };
823
851
  }
824
- let t = new A.BoxGeometry(3, .2, 3);
852
+ let t = new M.BoxGeometry(3, .2, 3);
825
853
  return t.translate(0, .1, 0), {
826
854
  geo: t,
827
855
  color: "#94a3b8"
828
856
  };
829
857
  }
830
- function ct({ matrices: e, count: t, geo: n, mat: r }) {
831
- let i = k(null);
832
- return D(() => {
858
+ function dt({ matrices: e, count: t, geo: n, mat: r }) {
859
+ let i = A(null);
860
+ return O(() => {
833
861
  let t = i.current;
834
862
  t && (t.instanceMatrix.array.set(e), t.instanceMatrix.needsUpdate = !0, t.computeBoundingSphere());
835
- }, [e, t]), /* @__PURE__ */ I("instancedMesh", {
863
+ }, [e, t]), /* @__PURE__ */ R("instancedMesh", {
836
864
  ref: i,
837
865
  args: [
838
866
  n,
@@ -842,12 +870,12 @@ function ct({ matrices: e, count: t, geo: n, mat: r }) {
842
870
  frustumCulled: !1
843
871
  });
844
872
  }
845
- function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o = "town" }) {
846
- let s = O(() => at(t, n), [t, n]), { spurs: l, junctions: u } = O(() => x(s, 2), [s]), d = O(() => h(s, 256, l), [s, l]), f = O(() => T(s.terrain, s.size, i), [s, i]), m = O(() => w(s.road, { tJunctions: u }), [s, u]), _ = O(() => l.map((e) => w(e, { crownHeight: .03 })), [l]), v = O(() => Te(s.road, o, t), [
873
+ function ft({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o = "town" }) {
874
+ let s = k(() => ct(t, n), [t, n]), { spurs: l, junctions: u } = k(() => x(s, 2), [s]), d = k(() => h(s, 256, l), [s, l]), f = k(() => T(s.terrain, s.size, i), [s, i]), m = k(() => w(s.road, { tJunctions: u }), [s, u]), _ = k(() => l.map((e) => w(e, { crownHeight: .03 })), [l]), v = k(() => we(s.road, o, t), [
847
875
  s,
848
876
  o,
849
877
  t
850
- ]), y = O(() => we(v.pieces), [v]), b = O(() => {
878
+ ]), y = k(() => Ce(v.pieces), [v]), b = k(() => {
851
879
  let t = c(d), { material: n, depthMaterial: i } = a(t, {
852
880
  ditherTexelsPerMeter: 16,
853
881
  ps2ColorQuantize: .85
@@ -859,12 +887,12 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
859
887
  preset: "DIRT",
860
888
  ditherTexelsPerMeter: 16,
861
889
  ps2ColorQuantize: .85
862
- }), l = new A.MeshLambertMaterial({
890
+ }), l = new M.MeshLambertMaterial({
863
891
  color: "#125274",
864
892
  transparent: !0,
865
893
  opacity: .84,
866
894
  fog: !0
867
- }), u = new A.MeshLambertMaterial({
895
+ }), u = new M.MeshLambertMaterial({
868
896
  color: "#2d4c24",
869
897
  flatShading: !0,
870
898
  fog: !0
@@ -878,10 +906,10 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
878
906
  waterMat: l,
879
907
  treeMat: u
880
908
  };
881
- }, [d]), S = O(() => {
909
+ }, [d]), S = k(() => {
882
910
  let t = /* @__PURE__ */ new Map();
883
911
  for (let n of y) {
884
- let { geo: r, color: i } = st(n.kind), a = new A.MeshStandardMaterial({
912
+ let { geo: r, color: i } = ut(n.kind), a = new M.MeshStandardMaterial({
885
913
  color: i,
886
914
  roughness: .82,
887
915
  flatShading: !0
@@ -892,9 +920,9 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
892
920
  });
893
921
  }
894
922
  return t;
895
- }, [y]), C = O(() => {
896
- let e = g(p(t, "island-trees")), n = [], r = new A.Object3D(), i = v.buildings.map((e) => ({
897
- p: Ee(e.pose).position,
923
+ }, [y]), C = k(() => {
924
+ let e = g(p(t, "island-trees")), n = [], r = new M.Object3D(), i = v.buildings.map((e) => ({
925
+ p: Te(e.pose).position,
898
926
  r: Math.hypot(e.width, e.depth) * 2.2
899
927
  }));
900
928
  for (let t = 0; t < 950 && n.length < 3520; t++) {
@@ -904,7 +932,7 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
904
932
  r.position.set(t, o + 2.1 * c, a), r.rotation.set(0, e() * Math.PI * 2, 0), r.scale.set(c, c, c), r.updateMatrix(), n.push(...r.matrix.elements);
905
933
  }
906
934
  return {
907
- geo: new A.ConeGeometry(1.5, 4.6, 6),
935
+ geo: new M.ConeGeometry(1.5, 4.6, 6),
908
936
  matrices: new Float32Array(n),
909
937
  count: n.length / 16
910
938
  };
@@ -913,7 +941,7 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
913
941
  v,
914
942
  t
915
943
  ]);
916
- return E(() => () => {
944
+ return D(() => () => {
917
945
  b.tex.dispose(), f.geometry.dispose(), m.geometry.dispose(), _.forEach((e) => e.geometry.dispose()), C.geo.dispose();
918
946
  }, [
919
947
  b,
@@ -921,21 +949,21 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
921
949
  m,
922
950
  _,
923
951
  C
924
- ]), /* @__PURE__ */ L("group", { children: [
925
- /* @__PURE__ */ I("fogExp2", {
952
+ ]), /* @__PURE__ */ z("group", { children: [
953
+ /* @__PURE__ */ R("fogExp2", {
926
954
  attach: "fog",
927
955
  args: [10335428, .00145]
928
956
  }),
929
- /* @__PURE__ */ I("hemisphereLight", { args: [
957
+ /* @__PURE__ */ R("hemisphereLight", { args: [
930
958
  11059416,
931
959
  5392440,
932
960
  .72
933
961
  ] }),
934
- /* @__PURE__ */ L(R, {
962
+ /* @__PURE__ */ z(B, {
935
963
  type: "fixed",
936
964
  colliders: !1,
937
965
  friction: .9,
938
- children: [/* @__PURE__ */ I(z, { args: [f.colliderVertices, f.colliderIndices] }), /* @__PURE__ */ I("mesh", {
966
+ children: [/* @__PURE__ */ R(V, { args: [f.colliderVertices, f.colliderIndices] }), /* @__PURE__ */ R("mesh", {
939
967
  geometry: f.geometry,
940
968
  material: b.terrainMat,
941
969
  customDepthMaterial: b.terrainDepthMat,
@@ -943,27 +971,27 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
943
971
  receiveShadow: !0
944
972
  })]
945
973
  }),
946
- /* @__PURE__ */ L(R, {
974
+ /* @__PURE__ */ z(B, {
947
975
  type: "fixed",
948
976
  colliders: !1,
949
977
  friction: 1.05,
950
- children: [/* @__PURE__ */ I(z, { args: [m.colliderVertices, m.colliderIndices] }), /* @__PURE__ */ I("mesh", {
978
+ children: [/* @__PURE__ */ R(V, { args: [m.colliderVertices, m.colliderIndices] }), /* @__PURE__ */ R("mesh", {
951
979
  geometry: m.geometry,
952
980
  material: b.asphaltMat,
953
981
  receiveShadow: !0
954
982
  })]
955
983
  }),
956
- _.map((e, t) => /* @__PURE__ */ L(R, {
984
+ _.map((e, t) => /* @__PURE__ */ z(B, {
957
985
  type: "fixed",
958
986
  colliders: !1,
959
987
  friction: .85,
960
- children: [/* @__PURE__ */ I(z, { args: [e.colliderVertices, e.colliderIndices] }), /* @__PURE__ */ I("mesh", {
988
+ children: [/* @__PURE__ */ R(V, { args: [e.colliderVertices, e.colliderIndices] }), /* @__PURE__ */ R("mesh", {
961
989
  geometry: e.geometry,
962
990
  material: b.dirtMat,
963
991
  receiveShadow: !0
964
992
  })]
965
993
  }, `spur_${t}`)),
966
- /* @__PURE__ */ I("mesh", {
994
+ /* @__PURE__ */ R("mesh", {
967
995
  position: [
968
996
  0,
969
997
  s.waterLevel,
@@ -975,23 +1003,23 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
975
1003
  0
976
1004
  ],
977
1005
  material: b.waterMat,
978
- children: /* @__PURE__ */ I("planeGeometry", { args: [s.size * 1.8, s.size * 1.8] })
1006
+ children: /* @__PURE__ */ R("planeGeometry", { args: [s.size * 1.8, s.size * 1.8] })
979
1007
  }),
980
1008
  y.map((e) => {
981
1009
  let t = S.get(e.kind);
982
- return /* @__PURE__ */ I(ct, {
1010
+ return /* @__PURE__ */ R(dt, {
983
1011
  matrices: e.matrices,
984
1012
  count: e.count,
985
1013
  geo: t.geo,
986
1014
  mat: t.mat
987
1015
  }, e.kind);
988
1016
  }),
989
- /* @__PURE__ */ I(R, {
1017
+ /* @__PURE__ */ R(B, {
990
1018
  type: "fixed",
991
1019
  colliders: !1,
992
1020
  children: v.buildings.map((e) => {
993
- let { position: t, yaw: n } = Ee(e.pose);
994
- return /* @__PURE__ */ I(he, {
1021
+ let { position: t, yaw: n } = Te(e.pose);
1022
+ return /* @__PURE__ */ R(me, {
995
1023
  position: [
996
1024
  t[0],
997
1025
  t[1] + e.storeys * 1.5,
@@ -1010,7 +1038,7 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
1010
1038
  }, e.id);
1011
1039
  })
1012
1040
  }),
1013
- C.count > 0 && /* @__PURE__ */ I(ct, {
1041
+ C.count > 0 && /* @__PURE__ */ R(dt, {
1014
1042
  matrices: C.matrices,
1015
1043
  count: C.count,
1016
1044
  geo: C.geo,
@@ -1019,7 +1047,7 @@ function lt({ seed: t = 77, size: n = 960, segments: i = 160, settlementTier: o
1019
1047
  ] });
1020
1048
  }
1021
1049
  // src/engine/longDriveKit.tsx
1022
- var Z = "https://khr3.optimuspi.workers.dev/assets", ut = {
1050
+ var Z = "https://khr3.optimuspi.workers.dev/assets", pt = {
1023
1051
  road_straight: `${Z}/city/R_Straight_6x6.glb`,
1024
1052
  road_crosswalk: `${Z}/city/R_Crosswalk_6x6.glb`,
1025
1053
  road_intersection: `${Z}/city/R_Intersection_6x6.glb`,
@@ -1027,32 +1055,32 @@ var Z = "https://khr3.optimuspi.workers.dev/assets", ut = {
1027
1055
  curb_ramp: `${Z}/city/S_AccessibleRamp_3x6.glb`,
1028
1056
  curb_driveway: `${Z}/city/S_Driveway_3x6.glb`,
1029
1057
  light_pole: `${Z}/city/L_LightPole_12gon.glb`
1030
- }, dt = {
1058
+ }, mt = {
1031
1059
  canopy: `${Z}/city/gas-canopy-roof.glb`,
1032
1060
  pump: `${Z}/city/gas-pump-twin.glb`,
1033
1061
  sign: `${Z}/city/neon-petro-sign.glb`
1034
- }, ft = /* @__PURE__ */ new Map();
1035
- function pt(t, n, r) {
1036
- let i = ft.get(n);
1062
+ }, ht = /* @__PURE__ */ new Map();
1063
+ function gt(t, n, r) {
1064
+ let i = ht.get(n);
1037
1065
  if (i) return i;
1038
1066
  t.updateMatrixWorld(!0);
1039
- let a = new A.Matrix4().copy(t.matrixWorld).invert(), o = new A.Matrix4(), s = [], c = null;
1067
+ let a = new M.Matrix4().copy(t.matrixWorld).invert(), o = new M.Matrix4(), s = [], c = null;
1040
1068
  t.traverse((e) => {
1041
- if (!(e instanceof A.Mesh) || !e.geometry) return;
1069
+ if (!(e instanceof M.Mesh) || !e.geometry) return;
1042
1070
  let t = e.geometry.index ? e.geometry.toNonIndexed() : e.geometry.clone();
1043
1071
  t.applyMatrix4(o.multiplyMatrices(a, e.matrixWorld));
1044
1072
  for (let e of Object.keys(t.attributes)) e !== "position" && e !== "normal" && e !== "uv" && e !== "color" && t.deleteAttribute(e);
1045
1073
  if (t.getAttribute("normal") || t.computeVertexNormals(), !t.getAttribute("uv")) {
1046
1074
  let e = t.getAttribute("position").count;
1047
- t.setAttribute("uv", new A.BufferAttribute(new Float32Array(e * 2), 2));
1075
+ t.setAttribute("uv", new M.BufferAttribute(new Float32Array(e * 2), 2));
1048
1076
  }
1049
1077
  s.push(t), !c && e.material && (c = (Array.isArray(e.material) ? e.material[0] : e.material).clone());
1050
1078
  });
1051
- let l = s.length > 0 ? De(s, !1) ?? s[0] : new A.BoxGeometry(r[0], r[1], r[2]);
1079
+ let l = s.length > 0 ? Ee(s, !1) ?? s[0] : new M.BoxGeometry(r[0], r[1], r[2]);
1052
1080
  l.computeBoundingBox();
1053
- let u = l.boundingBox, d = u.getSize(new A.Vector3()), f = u.getCenter(new A.Vector3()), p = r[0] / Math.max(d.x, 1e-4), m = r[1] / Math.max(d.y, 1e-4), h = r[2] / Math.max(d.z, 1e-4), g = n === "light_pole" ? m : Math.min(p, h);
1081
+ let u = l.boundingBox, d = u.getSize(new M.Vector3()), f = u.getCenter(new M.Vector3()), p = r[0] / Math.max(d.x, 1e-4), m = r[1] / Math.max(d.y, 1e-4), h = r[2] / Math.max(d.z, 1e-4), g = n === "light_pole" ? m : Math.min(p, h);
1054
1082
  l.translate(-f.x, -u.min.y, -f.z), l.scale(n === "light_pole" ? g : p, n === "light_pole" ? m : g, n === "light_pole" ? g : h), l.computeBoundingSphere();
1055
- let _ = c ?? new A.MeshLambertMaterial({
1083
+ let _ = c ?? new M.MeshLambertMaterial({
1056
1084
  color: "#64748b",
1057
1085
  flatShading: !0
1058
1086
  });
@@ -1061,17 +1089,17 @@ function pt(t, n, r) {
1061
1089
  geometry: l,
1062
1090
  material: _
1063
1091
  };
1064
- return ft.set(n, v), v;
1092
+ return ht.set(n, v), v;
1065
1093
  }
1066
1094
  function Q({ kitKey: e, fitSpan: t, matrices: n }) {
1067
- let r = n.length / 16, i = N(ut[e]), a = k(null), o = O(() => pt(i.scene, e, t), [
1095
+ let r = n.length / 16, i = P(pt[e]), a = A(null), o = k(() => gt(i.scene, e, t), [
1068
1096
  i.scene,
1069
1097
  e,
1070
1098
  t
1071
1099
  ]);
1072
- return D(() => {
1100
+ return O(() => {
1073
1101
  a.current && r !== 0 && (a.current.instanceMatrix.array.set(n), a.current.instanceMatrix.needsUpdate = !0, a.current.computeBoundingSphere());
1074
- }, [n, r]), r > 0 ? /* @__PURE__ */ I("instancedMesh", {
1102
+ }, [n, r]), r > 0 ? /* @__PURE__ */ R("instancedMesh", {
1075
1103
  ref: a,
1076
1104
  args: [
1077
1105
  o.geometry,
@@ -1083,26 +1111,26 @@ function Q({ kitKey: e, fitSpan: t, matrices: n }) {
1083
1111
  }) : null;
1084
1112
  }
1085
1113
  function $({ matrices: t, kind: n, color: r }) {
1086
- let i = k(null), a = t.length / 16, o = O(() => {
1114
+ let i = A(null), a = t.length / 16, o = k(() => {
1087
1115
  if (n === "triangle") {
1088
- let e = 3 * Math.sqrt(3) * .5, t = new A.Shape([
1089
- new A.Vector2(-1.5, 0),
1090
- new A.Vector2(1.5, 0),
1091
- new A.Vector2(0, e)
1092
- ]), n = new A.ExtrudeGeometry(t, {
1116
+ let e = 3 * Math.sqrt(3) * .5, t = new M.Shape([
1117
+ new M.Vector2(-1.5, 0),
1118
+ new M.Vector2(1.5, 0),
1119
+ new M.Vector2(0, e)
1120
+ ]), n = new M.ExtrudeGeometry(t, {
1093
1121
  depth: .24,
1094
1122
  bevelEnabled: !1
1095
1123
  });
1096
1124
  return n.rotateX(-Math.PI * .5), n;
1097
1125
  }
1098
- return n === "wall" ? new A.BoxGeometry(3, 3, .22) : n === "roof" ? new A.BoxGeometry(3.08, .24, 3.08) : new A.BoxGeometry(3, .24, 3);
1099
- }, [n]), s = O(() => e(new A.MeshLambertMaterial({
1126
+ return n === "wall" ? new M.BoxGeometry(3, 3, .22) : n === "roof" ? new M.BoxGeometry(3.08, .24, 3.08) : new M.BoxGeometry(3, .24, 3);
1127
+ }, [n]), s = k(() => e(new M.MeshLambertMaterial({
1100
1128
  color: r,
1101
1129
  flatShading: !0
1102
1130
  }), { flatShading: !0 }), [r]);
1103
- return D(() => {
1131
+ return O(() => {
1104
1132
  i.current && a !== 0 && (i.current.instanceMatrix.array.set(t), i.current.instanceMatrix.needsUpdate = !0, i.current.computeBoundingSphere());
1105
- }, [t, a]), a > 0 ? /* @__PURE__ */ I("instancedMesh", {
1133
+ }, [t, a]), a > 0 ? /* @__PURE__ */ R("instancedMesh", {
1106
1134
  ref: i,
1107
1135
  args: [
1108
1136
  o,
@@ -1114,12 +1142,12 @@ function $({ matrices: t, kind: n, color: r }) {
1114
1142
  receiveShadow: !0
1115
1143
  }) : null;
1116
1144
  }
1117
- function mt({ stop: e, groundY: t, cellTag: r }) {
1118
- let i = N(dt.canopy), a = N(dt.pump), o = N(dt.sign), s = O(() => {
1145
+ function _t({ stop: e, groundY: t, cellTag: r }) {
1146
+ let i = P(mt.canopy), a = P(mt.pump), o = P(mt.sign), s = k(() => {
1119
1147
  let e = (e, t) => {
1120
1148
  let r = e.clone(!0);
1121
1149
  r.updateMatrixWorld(!0);
1122
- let i = new A.Box3().setFromObject(r), a = i.getSize(new A.Vector3()), o = i.getCenter(new A.Vector3()), s = t / Math.max(a.y, .1);
1150
+ let i = new M.Box3().setFromObject(r), a = i.getSize(new M.Vector3()), o = i.getCenter(new M.Vector3()), s = t / Math.max(a.y, .1);
1123
1151
  return r.scale.setScalar(s), r.position.set(-o.x * s, -i.min.y * s, -o.z * s), n(r), r;
1124
1152
  };
1125
1153
  return {
@@ -1133,7 +1161,7 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1133
1161
  a.scene,
1134
1162
  o.scene
1135
1163
  ]);
1136
- return /* @__PURE__ */ L("group", {
1164
+ return /* @__PURE__ */ z("group", {
1137
1165
  position: [
1138
1166
  e.worldX,
1139
1167
  t,
@@ -1145,10 +1173,10 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1145
1173
  0
1146
1174
  ],
1147
1175
  children: [
1148
- /* @__PURE__ */ L(R, {
1176
+ /* @__PURE__ */ z(B, {
1149
1177
  type: "fixed",
1150
1178
  colliders: !1,
1151
- children: [/* @__PURE__ */ I(he, {
1179
+ children: [/* @__PURE__ */ R(me, {
1152
1180
  args: [
1153
1181
  e.widthMeters * .5,
1154
1182
  .12,
@@ -1159,24 +1187,24 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1159
1187
  .12,
1160
1188
  0
1161
1189
  ]
1162
- }), /* @__PURE__ */ L("mesh", {
1190
+ }), /* @__PURE__ */ z("mesh", {
1163
1191
  position: [
1164
1192
  0,
1165
1193
  .08,
1166
1194
  0
1167
1195
  ],
1168
1196
  receiveShadow: !0,
1169
- children: [/* @__PURE__ */ I("boxGeometry", { args: [
1197
+ children: [/* @__PURE__ */ R("boxGeometry", { args: [
1170
1198
  e.widthMeters,
1171
1199
  .16,
1172
1200
  e.depthMeters
1173
- ] }), /* @__PURE__ */ I("meshLambertMaterial", {
1201
+ ] }), /* @__PURE__ */ R("meshLambertMaterial", {
1174
1202
  color: "#475569",
1175
1203
  flatShading: !0
1176
1204
  })]
1177
1205
  })]
1178
1206
  }),
1179
- /* @__PURE__ */ I("primitive", {
1207
+ /* @__PURE__ */ R("primitive", {
1180
1208
  object: s.canopy,
1181
1209
  position: [
1182
1210
  0,
@@ -1184,8 +1212,8 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1184
1212
  0
1185
1213
  ]
1186
1214
  }),
1187
- e.kind === "GAS_STATION" && /* @__PURE__ */ L(me, { children: [
1188
- /* @__PURE__ */ I("primitive", {
1215
+ e.kind === "GAS_STATION" && /* @__PURE__ */ z(L, { children: [
1216
+ /* @__PURE__ */ R("primitive", {
1189
1217
  object: s.pumpA,
1190
1218
  position: [
1191
1219
  -2.4,
@@ -1193,7 +1221,7 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1193
1221
  0
1194
1222
  ]
1195
1223
  }),
1196
- /* @__PURE__ */ I("primitive", {
1224
+ /* @__PURE__ */ R("primitive", {
1197
1225
  object: s.pumpB,
1198
1226
  position: [
1199
1227
  2.4,
@@ -1201,7 +1229,7 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1201
1229
  0
1202
1230
  ]
1203
1231
  }),
1204
- /* @__PURE__ */ I("primitive", {
1232
+ /* @__PURE__ */ R("primitive", {
1205
1233
  object: s.sign,
1206
1234
  position: [
1207
1235
  e.widthMeters * .42,
@@ -1210,7 +1238,7 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1210
1238
  ]
1211
1239
  })
1212
1240
  ] }),
1213
- /* @__PURE__ */ I(ee, {
1241
+ /* @__PURE__ */ R(ee, {
1214
1242
  id: `${r}_can`,
1215
1243
  kind: "tin-can",
1216
1244
  labelId: "tris-soda",
@@ -1220,7 +1248,7 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1220
1248
  1.4
1221
1249
  ]
1222
1250
  }),
1223
- /* @__PURE__ */ I(ee, {
1251
+ /* @__PURE__ */ R(ee, {
1224
1252
  id: `${r}_bot`,
1225
1253
  kind: "glass-bottle",
1226
1254
  position: [
@@ -1233,15 +1261,15 @@ function mt({ stop: e, groundY: t, cellTag: r }) {
1233
1261
  });
1234
1262
  }
1235
1263
  // src/engine/mainlandMacroCell.tsx
1236
- function ht({ x: e, z: t, friction: n = 1, children: r }) {
1237
- let i = k(null);
1238
- return D(() => {
1264
+ function vt({ x: e, z: t, friction: n = 1, children: r }) {
1265
+ let i = A(null);
1266
+ return O(() => {
1239
1267
  i.current?.setTranslation({
1240
1268
  x: e,
1241
1269
  y: 0,
1242
1270
  z: t
1243
1271
  }, !1);
1244
- }, [e, t]), /* @__PURE__ */ I(R, {
1272
+ }, [e, t]), /* @__PURE__ */ R(B, {
1245
1273
  ref: i,
1246
1274
  type: "fixed",
1247
1275
  position: [
@@ -1254,8 +1282,8 @@ function ht({ x: e, z: t, friction: n = 1, children: r }) {
1254
1282
  children: r
1255
1283
  });
1256
1284
  }
1257
- function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ: o, renderExtra: s }) {
1258
- let c = O(() => {
1285
+ function yt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ: o, renderExtra: s }) {
1286
+ let c = k(() => {
1259
1287
  let r = n.generateMacroCell2D(e, t), i = r.highwayPolylines.filter((e) => e.length >= 2).map((e) => {
1260
1288
  let t = e.map(([e, t]) => [
1261
1289
  e,
@@ -1295,7 +1323,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1295
1323
  height: (e, t) => l.height(r.originWorldX + e, r.originWorldZ + t),
1296
1324
  visualHeight: (e, t, n) => l.visualHeight(r.originWorldX + e, r.originWorldZ + t, n),
1297
1325
  roadMask: (e, t) => l.roadMask(r.originWorldX + e, r.originWorldZ + t)
1298
- }, d = T(u, S, 96), f = new A.Object3D(), p = [], h = [], g = [], _ = [], y = [], b = [], x = [], ee = [], te = [], ne = [], re = [];
1326
+ }, d = T(u, S, 96), f = new M.Object3D(), p = [], h = [], g = [], _ = [], y = [], b = [], x = [], ee = [], te = [], E = [], ne = [];
1299
1327
  for (let e of i) for (let t = 36; t < e.length - 36; t += 48) {
1300
1328
  let n = e.at(t);
1301
1329
  f.position.set(n.pos[0] + n.left[0] * 6.8, n.pos[1], n.pos[2] + n.left[2] * 6.8), f.rotation.set(0, Math.atan2(n.tangent[0], n.tangent[2]), 0), f.scale.set(1, 1, 1), f.updateMatrix(), p.push(...f.matrix.elements);
@@ -1307,15 +1335,15 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1307
1335
  s < C.ROAD_LANE || s > C.C12_PLAZA_HUB || (f.position.set(e, o + .02, a), f.rotation.set(0, 0, 0), f.scale.set(1, 1, 1), f.updateMatrix(), s === C.CROSSWALK ? g.push(...f.matrix.elements) : s === C.INTERSECTION_BOX || s === C.C12_PLAZA_HUB ? _.push(...f.matrix.elements) : s === C.CURB_RAMP_CORNER ? b.push(...f.matrix.elements) : s === C.CURB_DRIVEWAY ? x.push(...f.matrix.elements) : s === C.CURB_STRAIGHT || s === C.BOULEVARD_MEDIAN ? y.push(...f.matrix.elements) : h.push(...f.matrix.elements));
1308
1336
  }
1309
1337
  for (let e of r.parcels.slice(0, 140)) {
1310
- let t = e.zone === "COMMERCIAL" ? 4 : e.zone === "INDUSTRIAL" ? 2 : 1, n = e.zone === "COMMERCIAL" ? te : e.zone === "INDUSTRIAL" ? ne : ee, r = Math.max(2, Math.floor((e.width - 3) / 3)), i = Math.max(2, Math.floor((e.depth - 3) / 3));
1338
+ let t = e.zone === "COMMERCIAL" ? 4 : e.zone === "INDUSTRIAL" ? 2 : 1, n = e.zone === "COMMERCIAL" ? te : e.zone === "INDUSTRIAL" ? E : ee, r = Math.max(2, Math.floor((e.width - 3) / 3)), i = Math.max(2, Math.floor((e.depth - 3) / 3));
1311
1339
  for (let a = 0; a < t; a++) {
1312
1340
  let t = o + a * 3 + 1.5;
1313
1341
  for (let a = 0; a < r; a++) for (let [r, o] of [[0, 0], [i * 3, Math.PI]]) f.position.set(e.minX + 1.5 + a * 3 + 1.5, t, e.minZ + 1.5 + r), f.rotation.set(0, o, 0), f.scale.set(1, 1, 1), f.updateMatrix(), n.push(...f.matrix.elements);
1314
1342
  }
1315
- for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) f.position.set(e.minX + 3 + i * 3, o + t * 3 + .12, e.minZ + 3 + n * 3), f.rotation.set(0, 0, 0), f.scale.set(1, 1, 1), f.updateMatrix(), re.push(...f.matrix.elements);
1343
+ for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) f.position.set(e.minX + 3 + i * 3, o + t * 3 + .12, e.minZ + 3 + n * 3), f.rotation.set(0, 0, 0), f.scale.set(1, 1, 1), f.updateMatrix(), ne.push(...f.matrix.elements);
1316
1344
  }
1317
1345
  }
1318
- let ie = r.civicHubBatches.find((e) => e.kind === "FoundationSquare")?.matrices ?? /* @__PURE__ */ new Float32Array(), E = r.civicHubBatches.find((e) => e.kind === "FoundationTriangle")?.matrices ?? /* @__PURE__ */ new Float32Array();
1346
+ let re = r.civicHubBatches.find((e) => e.kind === "FoundationSquare")?.matrices ?? /* @__PURE__ */ new Float32Array(), D = r.civicHubBatches.find((e) => e.kind === "FoundationTriangle")?.matrices ?? /* @__PURE__ */ new Float32Array();
1319
1347
  return {
1320
1348
  plan2d: r,
1321
1349
  ribbons: a,
@@ -1329,45 +1357,45 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1329
1357
  cbDrv: new Float32Array(x),
1330
1358
  wallRes: new Float32Array(ee),
1331
1359
  wallCom: new Float32Array(te),
1332
- wallInd: new Float32Array(ne),
1333
- roofAll: new Float32Array(re),
1334
- sqHub: ie,
1335
- triHub: E
1360
+ wallInd: new Float32Array(E),
1361
+ roofAll: new Float32Array(ne),
1362
+ sqHub: re,
1363
+ triHub: D
1336
1364
  };
1337
1365
  }, [
1338
1366
  e,
1339
1367
  t,
1340
1368
  n
1341
1369
  ]);
1342
- return /* @__PURE__ */ L("group", { children: [
1343
- /* @__PURE__ */ L(ht, {
1370
+ return /* @__PURE__ */ z("group", { children: [
1371
+ /* @__PURE__ */ z(vt, {
1344
1372
  x: c.plan2d.originWorldX + a,
1345
1373
  z: c.plan2d.originWorldZ + o,
1346
1374
  friction: .9,
1347
- children: [/* @__PURE__ */ I(z, { args: [c.terrainGeo.colliderVertices, c.terrainGeo.colliderIndices] }), /* @__PURE__ */ I("mesh", {
1375
+ children: [/* @__PURE__ */ R(V, { args: [c.terrainGeo.colliderVertices, c.terrainGeo.colliderIndices] }), /* @__PURE__ */ R("mesh", {
1348
1376
  geometry: c.terrainGeo.geometry,
1349
1377
  material: i,
1350
1378
  receiveShadow: !0
1351
1379
  })]
1352
1380
  }),
1353
- c.ribbons.map((e, t) => /* @__PURE__ */ L(ht, {
1381
+ c.ribbons.map((e, t) => /* @__PURE__ */ z(vt, {
1354
1382
  x: a,
1355
1383
  z: o,
1356
1384
  friction: 1.05,
1357
- children: [/* @__PURE__ */ I(z, { args: [e.colliderVertices, e.colliderIndices] }), /* @__PURE__ */ I("mesh", {
1385
+ children: [/* @__PURE__ */ R(V, { args: [e.colliderVertices, e.colliderIndices] }), /* @__PURE__ */ R("mesh", {
1358
1386
  geometry: e.geometry,
1359
1387
  material: r,
1360
1388
  receiveShadow: !0
1361
1389
  })]
1362
1390
  }, `hwy_${t}`)),
1363
- /* @__PURE__ */ L("group", {
1391
+ /* @__PURE__ */ z("group", {
1364
1392
  position: [
1365
1393
  a,
1366
1394
  0,
1367
1395
  o
1368
1396
  ],
1369
1397
  children: [
1370
- /* @__PURE__ */ I(Q, {
1398
+ /* @__PURE__ */ R(Q, {
1371
1399
  kitKey: "light_pole",
1372
1400
  fitSpan: [
1373
1401
  .6,
@@ -1376,7 +1404,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1376
1404
  ],
1377
1405
  matrices: c.poles
1378
1406
  }),
1379
- /* @__PURE__ */ I(Q, {
1407
+ /* @__PURE__ */ R(Q, {
1380
1408
  kitKey: "road_straight",
1381
1409
  fitSpan: [
1382
1410
  3,
@@ -1385,7 +1413,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1385
1413
  ],
1386
1414
  matrices: c.rdStr
1387
1415
  }),
1388
- /* @__PURE__ */ I(Q, {
1416
+ /* @__PURE__ */ R(Q, {
1389
1417
  kitKey: "road_crosswalk",
1390
1418
  fitSpan: [
1391
1419
  3,
@@ -1394,7 +1422,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1394
1422
  ],
1395
1423
  matrices: c.rdCw
1396
1424
  }),
1397
- /* @__PURE__ */ I(Q, {
1425
+ /* @__PURE__ */ R(Q, {
1398
1426
  kitKey: "road_intersection",
1399
1427
  fitSpan: [
1400
1428
  3,
@@ -1403,7 +1431,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1403
1431
  ],
1404
1432
  matrices: c.rdInt
1405
1433
  }),
1406
- /* @__PURE__ */ I(Q, {
1434
+ /* @__PURE__ */ R(Q, {
1407
1435
  kitKey: "curb_straight",
1408
1436
  fitSpan: [
1409
1437
  3,
@@ -1412,7 +1440,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1412
1440
  ],
1413
1441
  matrices: c.cbStr
1414
1442
  }),
1415
- /* @__PURE__ */ I(Q, {
1443
+ /* @__PURE__ */ R(Q, {
1416
1444
  kitKey: "curb_ramp",
1417
1445
  fitSpan: [
1418
1446
  3,
@@ -1421,7 +1449,7 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1421
1449
  ],
1422
1450
  matrices: c.cbRmp
1423
1451
  }),
1424
- /* @__PURE__ */ I(Q, {
1452
+ /* @__PURE__ */ R(Q, {
1425
1453
  kitKey: "curb_driveway",
1426
1454
  fitSpan: [
1427
1455
  3,
@@ -1430,37 +1458,37 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1430
1458
  ],
1431
1459
  matrices: c.cbDrv
1432
1460
  }),
1433
- /* @__PURE__ */ I($, {
1461
+ /* @__PURE__ */ R($, {
1434
1462
  matrices: c.sqHub,
1435
1463
  kind: "square",
1436
1464
  color: "#94a3b8"
1437
1465
  }),
1438
- /* @__PURE__ */ I($, {
1466
+ /* @__PURE__ */ R($, {
1439
1467
  matrices: c.triHub,
1440
1468
  kind: "triangle",
1441
1469
  color: "#cbd5e1"
1442
1470
  }),
1443
- /* @__PURE__ */ I($, {
1471
+ /* @__PURE__ */ R($, {
1444
1472
  matrices: c.wallRes,
1445
1473
  kind: "wall",
1446
1474
  color: "#d6c7b2"
1447
1475
  }),
1448
- /* @__PURE__ */ I($, {
1476
+ /* @__PURE__ */ R($, {
1449
1477
  matrices: c.wallCom,
1450
1478
  kind: "wall",
1451
1479
  color: "#38bdf8"
1452
1480
  }),
1453
- /* @__PURE__ */ I($, {
1481
+ /* @__PURE__ */ R($, {
1454
1482
  matrices: c.wallInd,
1455
1483
  kind: "wall",
1456
1484
  color: "#b45309"
1457
1485
  }),
1458
- /* @__PURE__ */ I($, {
1486
+ /* @__PURE__ */ R($, {
1459
1487
  matrices: c.roofAll,
1460
1488
  kind: "roof",
1461
1489
  color: "#334155"
1462
1490
  }),
1463
- c.plan2d.roadsideStops.map((r, i) => /* @__PURE__ */ I(mt, {
1491
+ c.plan2d.roadsideStops.map((r, i) => /* @__PURE__ */ R(_t, {
1464
1492
  stop: r,
1465
1493
  groundY: Math.max(2, n.sampleMainlandHeight(r.worldX, r.worldZ)),
1466
1494
  cellTag: `stop_${e}_${t}_${i}`
@@ -1471,8 +1499,8 @@ function gt({ mx: e, mz: t, planner: n, roadMat: r, terrainMat: i, offX: a, offZ
1471
1499
  ] });
1472
1500
  }
1473
1501
  // src/engine/kolmoLongDrive.tsx
1474
- function _t(e = 77, t = 960) {
1475
- let n = at(e, t), r = n.road.samples[0];
1502
+ function bt(e = 77, t = 960) {
1503
+ let n = ct(e, t), r = n.road.samples[0];
1476
1504
  for (let e of n.road.samples) e.pos[0] > r.pos[0] && (r = e);
1477
1505
  return {
1478
1506
  vehiclePos: [
@@ -1492,7 +1520,7 @@ function _t(e = 77, t = 960) {
1492
1520
  ]
1493
1521
  };
1494
1522
  }
1495
- function vt(e = 77, t = 1, n = 0) {
1523
+ function xt(e = 77, t = 1, n = 0) {
1496
1524
  let r = new _(e), i = r.generateMacroCell2D(t, n), a = i.highwayPolylines[0];
1497
1525
  if (a && a.length >= 2) {
1498
1526
  let e = a[1], t = a[Math.min(a.length - 1, 2)], n = Math.max(2, r.sampleMainlandHeight(e[0], e[1])), i = Math.atan2(t[0] - e[0], t[1] - e[1]);
@@ -1533,9 +1561,9 @@ function vt(e = 77, t = 1, n = 0) {
1533
1561
  ]
1534
1562
  };
1535
1563
  }
1536
- function yt({ seed: e, islandSize: t, planner: n, roadMat: r, offX: i, offZ: a }) {
1537
- let o = O(() => {
1538
- let r = at(e, t), i = r.road.samples[0];
1564
+ function St({ seed: e, islandSize: t, planner: n, roadMat: r, offX: i, offZ: a }) {
1565
+ let o = k(() => {
1566
+ let r = ct(e, t), i = r.road.samples[0];
1539
1567
  for (let e of r.road.samples) e.pos[0] > i.pos[0] && (i = e);
1540
1568
  let a = n.evalVerticalBorder(0, 0), o = S * .5, s = a.offsetMeters, c = n.sampleMainlandHeight(o, s), l = [];
1541
1569
  for (let e = 0; e <= 28; e++) {
@@ -1549,7 +1577,7 @@ function yt({ seed: e, islandSize: t, planner: n, roadMat: r, offX: i, offZ: a }
1549
1577
  let u = v(l, 5, 3, !1), d = w(u, {
1550
1578
  skirtDrop: .6,
1551
1579
  crownHeight: .04
1552
- }), f = [], p = [], m = new A.Object3D();
1580
+ }), f = [], p = [], m = new M.Object3D();
1553
1581
  for (let e = 24; e < u.length - 24; e += 24) {
1554
1582
  let t = u.at(e), n = Math.atan2(t.tangent[0], t.tangent[2]);
1555
1583
  for (let e of [-3.6, 3.6]) {
@@ -1568,26 +1596,26 @@ function yt({ seed: e, islandSize: t, planner: n, roadMat: r, offX: i, offZ: a }
1568
1596
  t,
1569
1597
  n
1570
1598
  ]);
1571
- return /* @__PURE__ */ L("group", { children: [/* @__PURE__ */ L(ht, {
1599
+ return /* @__PURE__ */ z("group", { children: [/* @__PURE__ */ z(vt, {
1572
1600
  x: i,
1573
1601
  z: a,
1574
1602
  friction: 1.05,
1575
- children: [/* @__PURE__ */ I(z, { args: [o.ribbon.colliderVertices, o.ribbon.colliderIndices] }), /* @__PURE__ */ I("mesh", {
1603
+ children: [/* @__PURE__ */ R(V, { args: [o.ribbon.colliderVertices, o.ribbon.colliderIndices] }), /* @__PURE__ */ R("mesh", {
1576
1604
  geometry: o.ribbon.geometry,
1577
1605
  material: r,
1578
1606
  receiveShadow: !0
1579
1607
  })]
1580
- }), /* @__PURE__ */ L("group", {
1608
+ }), /* @__PURE__ */ z("group", {
1581
1609
  position: [
1582
1610
  i,
1583
1611
  0,
1584
1612
  a
1585
1613
  ],
1586
- children: [/* @__PURE__ */ I($, {
1614
+ children: [/* @__PURE__ */ R($, {
1587
1615
  matrices: o.piers,
1588
1616
  kind: "square",
1589
1617
  color: "#64748b"
1590
- }), /* @__PURE__ */ I(Q, {
1618
+ }), /* @__PURE__ */ R(Q, {
1591
1619
  kitKey: "light_pole",
1592
1620
  fitSpan: [
1593
1621
  .6,
@@ -1598,120 +1626,120 @@ function yt({ seed: e, islandSize: t, planner: n, roadMat: r, offX: i, offZ: a }
1598
1626
  })]
1599
1627
  })] });
1600
1628
  }
1601
- function bt({ seed: e = 77, pureMainland: t = !1, initialOrigin: n = [0, 0], onOriginRebase: i, renderCellExtra: o }) {
1602
- let s = O(() => new _(e), [e]), [l, u] = ae(n), d = k([n[0], n[1]]), [f, p] = ae(() => [Math.max(+!!t, Math.round(n[0] / S)), Math.round(n[1] / S)]), [m, g] = ae(() => t ? [
1629
+ function Ct({ seed: e = 77, pureMainland: t = !1, initialOrigin: n = [0, 0], onOriginRebase: i, renderCellExtra: o }) {
1630
+ let s = Be(), l = k(() => new _(e), [e]), [u, d] = j(n), f = A([n[0], n[1]]), [p, m] = j(() => [Math.max(+!!t, Math.round(n[0] / S)), Math.round(n[1] / S)]), [g, v] = j(() => t ? [
1603
1631
  [1, 0],
1604
1632
  [1, -1],
1605
1633
  [1, 1],
1606
1634
  [2, 0]
1607
- ] : [[1, 0]]), v = O(() => {
1608
- let t = at(e, 960), n = c(h(t, 128));
1635
+ ] : [[1, 0]]), b = k(() => {
1636
+ let t = ct(e, 960), n = c(h(t, 128));
1609
1637
  return {
1610
1638
  terrainMat: a(n).material,
1611
1639
  roadMat: r(n, { preset: "ASPHALT" }).material
1612
1640
  };
1613
- }, [e]), b = O(() => {
1614
- let [e, t] = f, n = [];
1641
+ }, [e]), x = k(() => {
1642
+ let [e, t] = p, n = [];
1615
1643
  for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) {
1616
1644
  let a = e + r, o = t + i;
1617
1645
  a >= 1 && n.push([a, o]);
1618
1646
  }
1619
1647
  return n.sort((n, r) => Math.hypot(n[0] - e, n[1] - t) - Math.hypot(r[0] - e, r[1] - t)), n;
1620
- }, [f, t]);
1621
- E(() => {
1648
+ }, [p, t]);
1649
+ D(() => {
1622
1650
  let e = 0, t = () => {
1623
- g((n) => {
1624
- let r = n.filter(([e, t]) => b.some(([n, r]) => n === e && r === t)), i = b.find(([e, t]) => !r.some(([n, r]) => n === e && r === t));
1651
+ v((n) => {
1652
+ let r = n.filter(([e, t]) => x.some(([n, r]) => n === e && r === t)), i = x.find(([e, t]) => !r.some(([n, r]) => n === e && r === t));
1625
1653
  if (!i && r.length === n.length) return n;
1626
1654
  let a = i ? [...r, i] : r;
1627
- return a.length < b.length && (e = requestAnimationFrame(t)), a;
1655
+ return a.length < x.length && (e = requestAnimationFrame(t)), a;
1628
1656
  });
1629
1657
  };
1630
1658
  return e = requestAnimationFrame(t), () => cancelAnimationFrame(e);
1631
- }, [b]), oe(({ camera: e }) => {
1632
- let [n, r] = d.current, a = e.position.x, o = e.position.z;
1633
- for (let e of G.query(H)) {
1634
- let t = e.get(H)?.handle;
1659
+ }, [x]), ae(({ camera: e }) => {
1660
+ let [n, r] = f.current, a = e.position.x, o = e.position.z;
1661
+ for (let e of s.query(W)) {
1662
+ let t = e.get(W)?.handle;
1635
1663
  if (t?.body) {
1636
1664
  let e = t.body.translation();
1637
1665
  a = e.x, o = e.z;
1638
1666
  break;
1639
1667
  }
1640
1668
  }
1641
- let s = n + a, c = r + o, l = y(s, c), m = l.chunkOriginX - n, h = l.chunkOriginZ - r;
1642
- if (Math.abs(m) >= 192 || Math.abs(h) >= 192) {
1643
- d.current = [l.chunkOriginX, l.chunkOriginZ], e.position.x -= m, e.position.z -= h;
1644
- for (let e of G.query(H)) {
1645
- let t = e.get(H)?.handle?.body;
1669
+ let c = n + a, l = r + o, u = y(c, l), h = u.chunkOriginX - n, g = u.chunkOriginZ - r;
1670
+ if (Math.abs(h) >= 192 || Math.abs(g) >= 192) {
1671
+ f.current = [u.chunkOriginX, u.chunkOriginZ], e.position.x -= h, e.position.z -= g;
1672
+ for (let e of s.query(W)) {
1673
+ let t = e.get(W)?.handle?.body;
1646
1674
  if (t) {
1647
1675
  let e = t.translation();
1648
1676
  t.setTranslation({
1649
- x: e.x - m,
1677
+ x: e.x - h,
1650
1678
  y: e.y,
1651
- z: e.z - h
1679
+ z: e.z - g
1652
1680
  }, !0);
1653
1681
  }
1654
1682
  }
1655
- for (let e of G.query(U)) {
1656
- let t = e.get(U)?.handle?.body;
1683
+ for (let e of s.query(G)) {
1684
+ let t = e.get(G)?.handle?.body;
1657
1685
  if (t) {
1658
1686
  let e = t.translation();
1659
1687
  t.setTranslation({
1660
- x: e.x - m,
1688
+ x: e.x - h,
1661
1689
  y: e.y,
1662
- z: e.z - h
1690
+ z: e.z - g
1663
1691
  }, !0);
1664
1692
  }
1665
1693
  }
1666
- for (let e of G.query(Re)) {
1667
- let t = e.get(Re)?.getBody();
1694
+ for (let e of s.query(Le)) {
1695
+ let t = e.get(Le)?.getBody();
1668
1696
  if (t) {
1669
1697
  let e = t.translation();
1670
1698
  t.setTranslation({
1671
- x: e.x - m,
1699
+ x: e.x - h,
1672
1700
  y: e.y,
1673
- z: e.z - h
1701
+ z: e.z - g
1674
1702
  }, !0);
1675
1703
  }
1676
1704
  }
1677
- i?.(l.chunkOriginX, l.chunkOriginZ, m, h), u([l.chunkOriginX, l.chunkOriginZ]);
1705
+ i?.(u.chunkOriginX, u.chunkOriginZ, h, g), d([u.chunkOriginX, u.chunkOriginZ]);
1678
1706
  }
1679
- let g = Math.max(+!!t, Math.round(s / S)), _ = Math.round(c / S);
1680
- (g !== f[0] || _ !== f[1]) && p([g, _]);
1707
+ let _ = Math.max(+!!t, Math.round(c / S)), v = Math.round(l / S);
1708
+ (_ !== p[0] || v !== p[1]) && m([_, v]);
1681
1709
  });
1682
- let x = -l[0], C = -l[1];
1683
- return /* @__PURE__ */ L("group", { children: [
1684
- !t && f[0] <= 1 && Math.abs(f[1]) <= 1 && /* @__PURE__ */ I("group", {
1710
+ let C = -u[0], w = -u[1];
1711
+ return /* @__PURE__ */ z("group", { children: [
1712
+ !t && p[0] <= 1 && Math.abs(p[1]) <= 1 && /* @__PURE__ */ R("group", {
1685
1713
  position: [
1686
- x,
1714
+ C,
1687
1715
  0,
1688
- C
1716
+ w
1689
1717
  ],
1690
- children: /* @__PURE__ */ I(lt, {
1718
+ children: /* @__PURE__ */ R(ft, {
1691
1719
  seed: e,
1692
1720
  size: 960,
1693
1721
  segments: 144,
1694
1722
  settlementTier: "town"
1695
1723
  })
1696
1724
  }),
1697
- !t && f[0] <= 2 && Math.abs(f[1]) <= 1 && /* @__PURE__ */ I(yt, {
1725
+ !t && p[0] <= 2 && Math.abs(p[1]) <= 1 && /* @__PURE__ */ R(St, {
1698
1726
  seed: e,
1699
1727
  islandSize: 960,
1700
- planner: s,
1701
- roadMat: v.roadMat,
1702
- offX: x,
1703
- offZ: C
1728
+ planner: l,
1729
+ roadMat: b.roadMat,
1730
+ offX: C,
1731
+ offZ: w
1704
1732
  }),
1705
- m.map(([e, t]) => /* @__PURE__ */ I(gt, {
1733
+ g.map(([e, t]) => /* @__PURE__ */ R(yt, {
1706
1734
  mx: e,
1707
1735
  mz: t,
1708
- planner: s,
1709
- roadMat: v.roadMat,
1710
- terrainMat: v.terrainMat,
1711
- offX: x,
1712
- offZ: C,
1736
+ planner: l,
1737
+ roadMat: b.roadMat,
1738
+ terrainMat: b.terrainMat,
1739
+ offX: C,
1740
+ offZ: w,
1713
1741
  renderExtra: o
1714
1742
  }, `mc_${e}_${t}`))
1715
1743
  ] });
1716
1744
  }
1717
- export { ke as C, G as S, Ie as T, ze as _, lt as a, q as b, rt as c, Ge as d, Ue as f, Le as g, Re as h, ht as i, et as l, U as m, _t as n, ot as o, qe as p, vt as r, at as s, bt as t, He as u, H as v, Oe as w, K as x, W as y };
1745
+ export { ze as C, Fe as D, De as E, J as S, Oe as T, Re as _, ft as a, q as b, ot as c, qe as d, Ge as f, Ie as g, Le as h, vt as i, rt as l, G as m, bt as n, lt as o, Ye as p, xt as r, ct as s, Ct as t, We as u, W as v, Be as w, Ue as x, K as y };