@pinkaphant/kolmo 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/kolmo.mjs +1 -1
- package/dist/engine/kolmoActor.js +125 -83
- package/dist/engine/kolmoLongDrive.js +136 -91
- package/dist/engine/kolmoStore.d.ts +6 -5
- package/dist/engine/kolmoStore.js +115 -79
- package/dist/engine/kolmoVehicle.d.ts +1 -1
- package/dist/engine/kolmoVehicle.js +160 -147
- package/dist/engine/kolmoVehicleDriver.d.ts +12 -4
- package/dist/engine/kolmoVehicleDriver.js +40 -20
- package/dist/engine/kolmoWorld.js +55 -35
- package/dist/importer/CabinPreviewRig.d.ts +13 -0
- package/dist/importer/CabinPreviewRig.js +138 -0
- package/dist/importer/CabinStepSection.d.ts +17 -0
- package/dist/importer/CabinStepSection.js +222 -0
- package/dist/importer/ChopShopPanel.d.ts +31 -1
- package/dist/importer/ChopShopPanel.js +474 -380
- package/dist/importer/GateHudBar.d.ts +3 -0
- package/dist/importer/GateHudBar.js +8 -2
- package/dist/importer/GlbImportGate.js +183 -147
- package/dist/importer/ImporterPlinthUikitTags.d.ts +2 -1
- package/dist/importer/ImporterPlinthUikitTags.js +23 -16
- package/dist/importer/Step1CalibrationPlinth.d.ts +10 -0
- package/dist/importer/Step1CalibrationPlinth.js +203 -141
- package/dist/importer/Step2UniversalPad.d.ts +8 -1
- package/dist/importer/Step2UniversalPad.js +112 -90
- package/dist/importer/cabinMeshBuilders.d.ts +13 -0
- package/dist/importer/cabinMeshBuilders.js +104 -0
- package/dist/importer/cabinMixamoRig.d.ts +53 -0
- package/dist/importer/cabinMixamoRig.js +150 -0
- package/dist/importer/chopShopActions.d.ts +6 -0
- package/dist/importer/chopShopActions.js +86 -61
- package/dist/importer/chopShopUiComponents.d.ts +22 -0
- package/dist/importer/chopShopUiComponents.js +91 -0
- package/dist/importer/gateStore.d.ts +5 -2
- package/dist/importer/gateStore.js +13 -10
- package/dist/importer/glbNormalizer.d.ts +10 -1
- package/dist/importer/glbNormalizer.js +114 -49
- package/dist/importer/importerWebMcp.js +4 -1
- package/dist/importer/index.d.ts +4 -2
- package/dist/importer/index.js +24 -21
- package/dist/importer/khrCompiler.d.ts +20 -1
- package/dist/importer/khrCompiler.js +539 -290
- package/dist/importer/launcherBake.js +12 -8
- package/dist/importer/meshIslands.d.ts +4 -0
- package/dist/importer/meshIslands.js +104 -99
- package/dist/importer/surfaceCutter.d.ts +12 -3
- package/dist/importer/surfaceCutter.js +220 -127
- package/dist/importer/surfaceTopology.d.ts +13 -2
- package/dist/importer/surfaceTopology.js +57 -29
- package/dist/importer/universalGateBake.d.ts +7 -1
- package/dist/importer/universalGateBake.js +63 -60
- package/dist/importer/usdToGlb.js +19 -7
- package/dist/importer/useChopShopController.d.ts +27 -1
- package/dist/importer/useChopShopController.js +369 -255
- package/dist/importer/wheelAxlePairing.d.ts +3 -1
- package/dist/importer/wheelAxlePairing.js +82 -33
- package/dist/index.js +31 -28
- package/dist/junk/ShardPieces.js +3 -3
- package/dist/physics/index.d.ts +7 -0
- package/dist/physics/index.js +66 -40
- package/package.json +1 -1
package/bin/kolmo.mjs
CHANGED
|
@@ -102,7 +102,7 @@ fs.writeFileSync(path.join(targetDir, "wrangler.jsonc"), JSON.stringify({
|
|
|
102
102
|
assets: { directory: "./dist", not_found_handling: "single-page-application" },
|
|
103
103
|
}, null, 2));
|
|
104
104
|
|
|
105
|
-
fs.writeFileSync(path.join(targetDir, "index.html"), `<!doctype html><html><head><meta charset="utf-8"/><meta
|
|
105
|
+
fs.writeFileSync(path.join(targetDir, "index.html"), `<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>${pkgName}</title><style>html,body,#root{margin:0;width:100%;height:100%;overflow:hidden;background:#05070e}</style></head><body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body></html>\n`);
|
|
106
106
|
|
|
107
107
|
const appSrc = template === "garage"
|
|
108
108
|
? `import { GlbImportGate } from "@pinkaphant/kolmo/importer";\nexport function App() {\n return <GlbImportGate />;\n}\n`
|
|
@@ -1,46 +1,65 @@
|
|
|
1
|
-
import { KolmoGravityContext as e } from "../physics/index.js";
|
|
2
|
-
import { applyRetroMaterial as
|
|
3
|
-
import { useKolmoInput as
|
|
4
|
-
import { ActorTrait as
|
|
5
|
-
import { useCallback as
|
|
6
|
-
import * as
|
|
7
|
-
import { useFrame as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import {
|
|
10
|
-
import { Ecctrl as w } from "@pinkaphant/ecctrl";
|
|
1
|
+
import { KolmoGravityContext as e, KolmoTimeContext as t, isKolmoPhysicsStepping as n } from "../physics/index.js";
|
|
2
|
+
import { applyRetroMaterial as r } from "../shaders/retroShader.js";
|
|
3
|
+
import { useKolmoInput as i } from "./kolmoInput.js";
|
|
4
|
+
import { ActorTrait as a, InteractableTrait as o, VehicleTrait as s, WorldSessionTrait as c, ensureWorldSession as l, kolmoActions as u, kolmoTelemetry as d, setWorldCameraControls as f, useActiveKolmoWorld as p, useWorldTrait as m } from "./kolmoStore.js";
|
|
5
|
+
import { useCallback as h, useContext as g, useLayoutEffect as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
6
|
+
import * as x from "three";
|
|
7
|
+
import { useFrame as S, useThree as ee } from "@react-three/fiber";
|
|
8
|
+
import { Fragment as te, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
9
|
+
import { Ecctrl as ne } from "@pinkaphant/ecctrl";
|
|
11
10
|
import { EcctrlCameraControls as T } from "@pinkaphant/ecctrl/camera";
|
|
12
11
|
// src/engine/kolmoActor.tsx
|
|
13
|
-
var E = new
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
var E = new x.Vector3(), D = new x.Vector3(), O = new x.Vector3(), k = new x.Vector3(), A = new x.Vector3(), j = new x.Vector3();
|
|
13
|
+
function M(e, t) {
|
|
14
|
+
if (Array.isArray(e) && e.length >= 3) return [
|
|
15
|
+
Number(e[0]) || 0,
|
|
16
|
+
Number(e[1]) || 0,
|
|
17
|
+
Number(e[2]) || 0
|
|
18
|
+
];
|
|
19
|
+
if (e && typeof e == "object" && "x" in e && "y" in e && "z" in e) {
|
|
20
|
+
let t = e;
|
|
21
|
+
return [
|
|
22
|
+
t.x,
|
|
23
|
+
t.y,
|
|
24
|
+
t.z
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
return [
|
|
28
|
+
t[0],
|
|
29
|
+
t[1],
|
|
30
|
+
t[2]
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
function N() {
|
|
34
|
+
let e = v(() => ({
|
|
35
|
+
suitGeo: new x.CapsuleGeometry(.28, .56, 6, 12),
|
|
36
|
+
visorGeo: new x.BoxGeometry(.34, .16, .14),
|
|
37
|
+
packGeo: new x.BoxGeometry(.32, .42, .16),
|
|
38
|
+
suitMat: r(new x.MeshStandardMaterial({
|
|
20
39
|
color: "#e2e8f0",
|
|
21
40
|
roughness: .55,
|
|
22
41
|
metalness: .15
|
|
23
42
|
})),
|
|
24
|
-
visorMat:
|
|
43
|
+
visorMat: r(new x.MeshStandardMaterial({
|
|
25
44
|
color: "#38bdf8",
|
|
26
45
|
emissive: "#0284c7",
|
|
27
46
|
emissiveIntensity: .55,
|
|
28
47
|
roughness: .2
|
|
29
48
|
})),
|
|
30
|
-
packMat:
|
|
49
|
+
packMat: r(new x.MeshStandardMaterial({
|
|
31
50
|
color: "#334155",
|
|
32
51
|
roughness: .7
|
|
33
52
|
}))
|
|
34
53
|
}), []);
|
|
35
|
-
return
|
|
54
|
+
return _(() => () => {
|
|
36
55
|
e.suitGeo.dispose(), e.visorGeo.dispose(), e.packGeo.dispose(), e.suitMat.dispose(), e.visorMat.dispose(), e.packMat.dispose();
|
|
37
|
-
}, [e]), /* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
56
|
+
}, [e]), /* @__PURE__ */ w("group", { children: [
|
|
57
|
+
/* @__PURE__ */ C("mesh", {
|
|
39
58
|
castShadow: !0,
|
|
40
59
|
geometry: e.suitGeo,
|
|
41
60
|
material: e.suitMat
|
|
42
61
|
}),
|
|
43
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ C("mesh", {
|
|
44
63
|
position: [
|
|
45
64
|
0,
|
|
46
65
|
.24,
|
|
@@ -49,7 +68,7 @@ function k() {
|
|
|
49
68
|
geometry: e.visorGeo,
|
|
50
69
|
material: e.visorMat
|
|
51
70
|
}),
|
|
52
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ C("mesh", {
|
|
53
72
|
position: [
|
|
54
73
|
0,
|
|
55
74
|
.06,
|
|
@@ -61,75 +80,81 @@ function k() {
|
|
|
61
80
|
})
|
|
62
81
|
] });
|
|
63
82
|
}
|
|
64
|
-
function
|
|
83
|
+
function P({ position: r = [
|
|
65
84
|
0,
|
|
66
85
|
1.4,
|
|
67
86
|
0
|
|
68
|
-
], enabled:
|
|
69
|
-
let
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, [
|
|
73
|
-
let
|
|
87
|
+
], enabled: P = !0, getInput: F, ecctrlProps: I, cameraProps: L, children: re }) {
|
|
88
|
+
let ie = g(e), R = g(t), z = p();
|
|
89
|
+
_(() => {
|
|
90
|
+
l(z);
|
|
91
|
+
}, [z]);
|
|
92
|
+
let ae = m(z, c), oe = i(F), se = ee((e) => typeof e.gl?.domElement?.setAttribute == "function"), B = y(null), V = y(null), H = y(new x.Vector3()), U = y(new x.Vector3(0, 1, 0)), W = y(!1), G = y(0), K = y({
|
|
74
93
|
pos: null,
|
|
75
|
-
yaw: 0
|
|
76
|
-
|
|
94
|
+
yaw: 0,
|
|
95
|
+
rot: null
|
|
96
|
+
}), q = y(null), ce = y({
|
|
77
97
|
forward: !1,
|
|
78
98
|
backward: !1,
|
|
79
99
|
leftward: !1,
|
|
80
100
|
rightward: !1,
|
|
81
101
|
run: !1,
|
|
82
102
|
jump: !1
|
|
83
|
-
}), Y =
|
|
103
|
+
}), J = n(R), [le, ue] = b(J), Y = y(J), X = h((e, t) => {
|
|
84
104
|
H.current.x -= e, H.current.z -= t, B.current && (B.current.currPos.x -= e, B.current.currPos.z -= t);
|
|
85
105
|
let n = V.current;
|
|
86
|
-
n
|
|
87
|
-
}, [])
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
n && (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));
|
|
107
|
+
}, []), de = h((e) => {
|
|
108
|
+
V.current = e, f(z, e);
|
|
109
|
+
}, [z]);
|
|
110
|
+
_(() => {
|
|
111
|
+
let e = z.spawn(a({
|
|
90
112
|
id: "pilot",
|
|
91
113
|
handle: B.current,
|
|
92
114
|
exitSpawnPos: null,
|
|
93
115
|
exitSpawnYaw: 0,
|
|
116
|
+
exitSpawnRot: null,
|
|
94
117
|
exitLinVel: null,
|
|
95
|
-
onOriginShift:
|
|
96
|
-
})), t =
|
|
118
|
+
onOriginShift: X
|
|
119
|
+
})), t = z.onChange(a, (t) => {
|
|
97
120
|
if (t !== e) return;
|
|
98
|
-
let n = e.get(
|
|
121
|
+
let n = e.get(a);
|
|
99
122
|
n && (K.current = {
|
|
100
123
|
pos: n.exitSpawnPos,
|
|
101
|
-
yaw: n.exitSpawnYaw
|
|
124
|
+
yaw: n.exitSpawnYaw,
|
|
125
|
+
rot: n.exitSpawnRot ?? null
|
|
102
126
|
});
|
|
103
127
|
});
|
|
104
128
|
return () => {
|
|
105
|
-
t(), e.destroy();
|
|
129
|
+
t(), f(z, null), e.destroy();
|
|
106
130
|
};
|
|
107
|
-
}, [
|
|
108
|
-
let
|
|
131
|
+
}, [z, X]);
|
|
132
|
+
let Z = h((e) => {
|
|
109
133
|
B.current = e;
|
|
110
|
-
let t =
|
|
134
|
+
let t = z.queryFirst(a);
|
|
111
135
|
if (!t) return;
|
|
112
|
-
let n = t.get(
|
|
136
|
+
let n = t.get(a);
|
|
113
137
|
e?.body && n?.exitLinVel && e.body.setLinvel({
|
|
114
138
|
x: n.exitLinVel[0],
|
|
115
139
|
y: n.exitLinVel[1],
|
|
116
140
|
z: n.exitLinVel[2]
|
|
117
|
-
}, !0), e?.body && (K.current.pos = null), t.set(
|
|
141
|
+
}, !0), e?.body && (K.current.pos = null, K.current.rot = null), t.set(a, {
|
|
118
142
|
id: n?.id ?? "pilot",
|
|
119
143
|
handle: e,
|
|
120
144
|
exitSpawnPos: e?.body ? null : n?.exitSpawnPos ?? null,
|
|
121
145
|
exitSpawnYaw: n?.exitSpawnYaw ?? 0,
|
|
146
|
+
exitSpawnRot: e?.body ? null : n?.exitSpawnRot ?? null,
|
|
122
147
|
exitLinVel: e?.body ? null : n?.exitLinVel ?? null,
|
|
123
|
-
onOriginShift:
|
|
148
|
+
onOriginShift: X
|
|
124
149
|
});
|
|
125
|
-
}, [
|
|
150
|
+
}, [z, X]), Q = ae?.activeVehicleId || "", $ = P && !Q;
|
|
126
151
|
if (!$) q.current = null;
|
|
127
152
|
else if (!q.current) {
|
|
128
|
-
let e = K.current.pos ?? M?.position
|
|
153
|
+
let e = K.current.pos ?? M(I?.position, r), t = K.current.rot ?? [
|
|
129
154
|
0,
|
|
130
155
|
K.current.yaw,
|
|
131
156
|
0
|
|
132
|
-
];
|
|
157
|
+
], n = I?.rotation !== void 0 && !K.current.pos ? M(I.rotation, t) : t;
|
|
133
158
|
q.current = {
|
|
134
159
|
pos: [
|
|
135
160
|
e[0],
|
|
@@ -143,8 +168,8 @@ function A({ position: t = [
|
|
|
143
168
|
]
|
|
144
169
|
};
|
|
145
170
|
}
|
|
146
|
-
let
|
|
147
|
-
let e =
|
|
171
|
+
let fe = v(() => {
|
|
172
|
+
let e = I?.userData ?? {}, t = e.ecctrl ?? {};
|
|
148
173
|
return {
|
|
149
174
|
...e,
|
|
150
175
|
ecctrl: {
|
|
@@ -152,47 +177,64 @@ function A({ position: t = [
|
|
|
152
177
|
...t
|
|
153
178
|
}
|
|
154
179
|
};
|
|
155
|
-
}, [
|
|
156
|
-
|
|
157
|
-
if (!
|
|
158
|
-
let
|
|
159
|
-
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
|
|
180
|
+
}, [I?.userData]);
|
|
181
|
+
if (S((e, t) => {
|
|
182
|
+
if (!P) return;
|
|
183
|
+
let r = n(R);
|
|
184
|
+
r !== Y.current && (Y.current = r, ue(r));
|
|
185
|
+
let i = Math.min(Math.max(t, 1e-4), 1 / 30);
|
|
186
|
+
G.current > 0 && (G.current = Math.max(0, G.current - i));
|
|
187
|
+
let a = oe(), c = a.interact && !W.current;
|
|
188
|
+
if (W.current = a.interact, Q) {
|
|
189
|
+
c && G.current === 0 && (G.current = .25, u(z).exitVehicle());
|
|
163
190
|
return;
|
|
164
191
|
}
|
|
165
|
-
let
|
|
166
|
-
if (!
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
192
|
+
let l = B.current;
|
|
193
|
+
if (!l || !l.body) return;
|
|
194
|
+
if (r) {
|
|
195
|
+
let e = ce.current;
|
|
196
|
+
e.forward = a.forward, e.backward = a.backward, e.leftward = a.left, e.rightward = a.right, e.run = a.boost, e.jump = a.brake, l.setMovement(e);
|
|
197
|
+
}
|
|
198
|
+
d.mode = "foot", d.speedKmh = l.moveSpeed * 3.6, d.rpm = 0, d.gear = 0, d.throttle = +!!l.isMoving, d.boost = a.boost && l.isMoving ? 1 : 0;
|
|
199
|
+
let f = null, p = Infinity;
|
|
200
|
+
for (let e of z.query(s, o)) {
|
|
201
|
+
let t = e.get(s), n = e.get(o);
|
|
172
202
|
if (!t?.handle || !n) continue;
|
|
173
203
|
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 =
|
|
175
|
-
r <= n.radius * n.radius && r <
|
|
204
|
+
let r = l.currPos.distanceToSquared(E);
|
|
205
|
+
r <= n.radius * n.radius && r < p && (p = r, f = t.id);
|
|
206
|
+
}
|
|
207
|
+
if (d.nearVehicleId = f, c && f && G.current === 0) {
|
|
208
|
+
G.current = .25, u(z).boardVehicle(f);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
let m = V.current;
|
|
212
|
+
if (m && l.currPos.lengthSq() > 0 && (m.enabled ||= !0, H.current.copy(l.currPos).addScaledVector(l.bodyYAxis, .55), m.moveTo(H.current.x, H.current.y, H.current.z, !0), U.current.copy(l.upAxis), U.current.lengthSq() > 1e-6 && (U.current.normalize(), e.camera.up.lerp(U.current, 1 - Math.exp(-8 * i)), m.setUp(e.camera.up), l.isOnPlatform && (e.camera.getWorldDirection(k).projectOnPlane(U.current), k.lengthSq() > 1e-6)))) {
|
|
213
|
+
k.normalize(), A.copy(k).applyQuaternion(l.turnOnYQuat), j.crossVectors(k, A);
|
|
214
|
+
let e = x.MathUtils.clamp(k.dot(A), -1, 1);
|
|
215
|
+
Math.abs(e) < 1e-10 && (e = 0), m.rotate(Math.atan2(j.dot(U.current), e), 0, !0);
|
|
176
216
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
217
|
+
}), !P) return null;
|
|
218
|
+
let pe = !R.paused && le && (I?.enable ?? !0);
|
|
219
|
+
return /* @__PURE__ */ w(te, { children: [se && L !== !1 && L !== null && /* @__PURE__ */ C(T, {
|
|
220
|
+
ref: de,
|
|
180
221
|
makeDefault: !0,
|
|
181
222
|
minPolarAngle: .12,
|
|
182
223
|
maxPolarAngle: Math.PI - .12,
|
|
183
224
|
smoothTime: .08,
|
|
184
|
-
...
|
|
185
|
-
}), /* @__PURE__ */
|
|
186
|
-
ref:
|
|
187
|
-
enableCustomGravity:
|
|
225
|
+
...L ?? {}
|
|
226
|
+
}), $ && /* @__PURE__ */ C(ne, {
|
|
227
|
+
ref: Z,
|
|
228
|
+
enableCustomGravity: ie,
|
|
188
229
|
maxWalkVel: 3.2,
|
|
189
230
|
maxRunVel: 7.2,
|
|
190
231
|
jumpVel: 5.8,
|
|
191
|
-
...
|
|
232
|
+
...I,
|
|
233
|
+
enable: pe,
|
|
192
234
|
position: q.current.pos,
|
|
193
235
|
rotation: q.current.rot,
|
|
194
|
-
userData:
|
|
195
|
-
children:
|
|
196
|
-
})] })
|
|
236
|
+
userData: fe,
|
|
237
|
+
children: re ?? /* @__PURE__ */ C(N, {})
|
|
238
|
+
})] });
|
|
197
239
|
}
|
|
198
|
-
export {
|
|
240
|
+
export { P as KolmoActor };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { createPS2RoadMaterialWebGL as e } from "../shaders/ps2RoadWebGL.js";
|
|
2
2
|
import { createPS2WorldTextures as t } from "../shaders/ps2Textures.js";
|
|
3
|
-
import { MACRO_SIZE_M as n
|
|
4
|
-
import { InfiniteLongDrivePlanner as
|
|
5
|
-
import { bakeWorldSplatMaps as
|
|
6
|
-
import { buildRoadRibbonGeometry as
|
|
7
|
-
import { ShiftedFixedBody as
|
|
8
|
-
import { roadFromPoints as
|
|
9
|
-
import { KolmoIsland as
|
|
10
|
-
import { readFloatingOriginAnchorXZ as
|
|
11
|
-
import { InstancedC12Piece as
|
|
12
|
-
import { MainlandMacroCell as
|
|
13
|
-
import { useEffect as
|
|
14
|
-
import * as
|
|
15
|
-
import { useFrame as
|
|
16
|
-
import { jsx as
|
|
17
|
-
import { TrimeshCollider as
|
|
3
|
+
import { MACRO_SIZE_M as n } from "../world/macroCellSchema.js";
|
|
4
|
+
import { InfiniteLongDrivePlanner as r } from "../world/infiniteWorld2D.js";
|
|
5
|
+
import { bakeWorldSplatMaps as i } from "../world/worldTypes.js";
|
|
6
|
+
import { buildRoadRibbonGeometry as a } from "../world/roadRibbon.js";
|
|
7
|
+
import { ShiftedFixedBody as o } from "./shiftedFixedBody.js";
|
|
8
|
+
import { roadFromPoints as s } from "../world/road.js";
|
|
9
|
+
import { KolmoIsland as c, getCachedIslandPlan as l } from "./kolmoIsland.js";
|
|
10
|
+
import { readFloatingOriginAnchorXZ as u, shiftFloatingOriginEntities as d, useActiveKolmoWorld as f } from "./kolmoStore.js";
|
|
11
|
+
import { InstancedC12Piece as p, InstancedWorldGlb as m } from "./longDriveKit.js";
|
|
12
|
+
import { MainlandMacroCell as h } from "./mainlandMacroCell.js";
|
|
13
|
+
import { useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
14
|
+
import * as b from "three";
|
|
15
|
+
import { useFrame as x, useThree as S } from "@react-three/fiber";
|
|
16
|
+
import { jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
17
|
+
import { TrimeshCollider as T, useRapier as E } from "@react-three/rapier";
|
|
18
18
|
// src/engine/kolmoLongDrive.tsx
|
|
19
|
-
function
|
|
20
|
-
let n =
|
|
19
|
+
function D(e = 77, t = 960) {
|
|
20
|
+
let n = l(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 {
|
|
23
23
|
vehiclePos: [
|
|
@@ -37,10 +37,10 @@ function O(e = 77, t = 960) {
|
|
|
37
37
|
]
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
let
|
|
40
|
+
function O(e = 77, t = 1, n = 0) {
|
|
41
|
+
let i = new r(e), a = i.generateMacroCell2D(t, n), o = a.highwayPolylines[0];
|
|
42
42
|
if (o && o.length >= 2) {
|
|
43
|
-
let e = o[1], t = o[Math.min(o.length - 1, 2)], n = Math.max(2,
|
|
43
|
+
let e = o[1], t = o[Math.min(o.length - 1, 2)], n = Math.max(2, i.sampleMainlandHeight(e[0], e[1])), r = Math.atan2(t[0] - e[0], t[1] - e[1]);
|
|
44
44
|
return {
|
|
45
45
|
vehiclePos: [
|
|
46
46
|
e[0],
|
|
@@ -49,7 +49,7 @@ function k(e = 77, t = 1, n = 0) {
|
|
|
49
49
|
],
|
|
50
50
|
vehicleRot: [
|
|
51
51
|
0,
|
|
52
|
-
|
|
52
|
+
r,
|
|
53
53
|
0
|
|
54
54
|
],
|
|
55
55
|
actorPos: [
|
|
@@ -59,7 +59,7 @@ function k(e = 77, t = 1, n = 0) {
|
|
|
59
59
|
]
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
let s = Math.max(2.5,
|
|
62
|
+
let s = Math.max(2.5, i.sampleMainlandHeight(a.hubX, a.hubZ));
|
|
63
63
|
return {
|
|
64
64
|
vehiclePos: [
|
|
65
65
|
a.hubX,
|
|
@@ -78,23 +78,23 @@ function k(e = 77, t = 1, n = 0) {
|
|
|
78
78
|
]
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
let d =
|
|
83
|
-
let i =
|
|
84
|
-
for (let e of i.road.samples) e.pos[0] >
|
|
85
|
-
let
|
|
81
|
+
function k({ seed: e, islandSize: t, planner: r, roadMat: i, offX: c, offZ: u }) {
|
|
82
|
+
let d = _(() => {
|
|
83
|
+
let i = l(e, t), o = i.road.samples[0];
|
|
84
|
+
for (let e of i.road.samples) e.pos[0] > o.pos[0] && (o = e);
|
|
85
|
+
let c = r.evalVerticalBorder(0, 0), u = n * .5, d = c.offsetMeters, f = r.sampleMainlandHeight(u, d), p = [];
|
|
86
86
|
for (let e = 0; e <= 28; e++) {
|
|
87
|
-
let t = e / 28, n = Math.sin(Math.PI * t), r =
|
|
87
|
+
let t = e / 28, n = Math.sin(Math.PI * t), r = o.pos[0] + (u - o.pos[0]) * t, i = o.pos[2] + (d - o.pos[2]) * (t * t * (3 - 2 * t)), a = o.pos[1] * (1 - t) + f * t;
|
|
88
88
|
p.push([
|
|
89
89
|
r,
|
|
90
|
-
|
|
90
|
+
a * (1 - n) + 14 * n,
|
|
91
91
|
i
|
|
92
92
|
]);
|
|
93
93
|
}
|
|
94
|
-
let m =
|
|
94
|
+
let m = s(p, 5, 3, !1), h = a(m, {
|
|
95
95
|
skirtDrop: .6,
|
|
96
96
|
crownHeight: .04
|
|
97
|
-
}), g = [], _ = [], v = new
|
|
97
|
+
}), g = [], _ = [], v = new b.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]) {
|
|
@@ -113,28 +113,28 @@ function A({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l })
|
|
|
113
113
|
t,
|
|
114
114
|
r
|
|
115
115
|
]);
|
|
116
|
-
return
|
|
116
|
+
return g(() => () => {
|
|
117
117
|
d.ribbon.geometry.dispose();
|
|
118
|
-
}, [d]), /* @__PURE__ */
|
|
119
|
-
x:
|
|
120
|
-
z:
|
|
118
|
+
}, [d]), /* @__PURE__ */ w("group", { children: [/* @__PURE__ */ w(o, {
|
|
119
|
+
x: c,
|
|
120
|
+
z: u,
|
|
121
121
|
friction: 1.05,
|
|
122
|
-
children: [/* @__PURE__ */
|
|
122
|
+
children: [/* @__PURE__ */ C(T, { args: [d.ribbon.colliderVertices, d.ribbon.colliderIndices] }), /* @__PURE__ */ C("mesh", {
|
|
123
123
|
geometry: d.ribbon.geometry,
|
|
124
124
|
material: i,
|
|
125
125
|
receiveShadow: !0
|
|
126
126
|
})]
|
|
127
|
-
}), /* @__PURE__ */
|
|
127
|
+
}), /* @__PURE__ */ w("group", {
|
|
128
128
|
position: [
|
|
129
|
-
|
|
129
|
+
c,
|
|
130
130
|
0,
|
|
131
|
-
|
|
131
|
+
u
|
|
132
132
|
],
|
|
133
|
-
children: [/* @__PURE__ */
|
|
133
|
+
children: [/* @__PURE__ */ C(p, {
|
|
134
134
|
matrices: d.piers,
|
|
135
135
|
kind: "square",
|
|
136
136
|
color: "#64748b"
|
|
137
|
-
}), /* @__PURE__ */
|
|
137
|
+
}), /* @__PURE__ */ C(m, {
|
|
138
138
|
kitKey: "light_pole",
|
|
139
139
|
fitSpan: [
|
|
140
140
|
.6,
|
|
@@ -145,79 +145,124 @@ function A({ seed: e, islandSize: t, planner: r, roadMat: i, offX: a, offZ: l })
|
|
|
145
145
|
})]
|
|
146
146
|
})] });
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
let
|
|
150
|
-
let e = Math.max(1, Math.round(
|
|
151
|
-
return
|
|
148
|
+
function A({ seed: a = 77, pureMainland: o = !1, initialOrigin: s = [0, 0], onOriginRebase: p, renderCellExtra: m }) {
|
|
149
|
+
let b = f(), T = S((e) => e.camera), D = E(), O = _(() => new r(a), [a]), [A, j] = y(s), M = v([s[0], s[1]]), N = v([s[0], s[1]]), [P, F] = y(() => [Math.max(+!!o, Math.round(s[0] / n)), Math.round(s[1] / n)]), I = v([P[0], P[1]]), [L, R] = y(() => {
|
|
150
|
+
let e = Math.max(1, Math.round(s[0] / n)), t = Math.round(s[1] / n);
|
|
151
|
+
return o ? [
|
|
152
152
|
[e, t],
|
|
153
153
|
[e, t - 1],
|
|
154
154
|
[e, t + 1],
|
|
155
155
|
[e + 1, t]
|
|
156
156
|
] : [[1, 0]];
|
|
157
|
-
}), z = v(
|
|
158
|
-
|
|
157
|
+
}), z = v(L);
|
|
158
|
+
z.current = L;
|
|
159
|
+
let B = v(!1), V = v([0, 0]), H = _(() => {
|
|
160
|
+
let n = l(a, 960), r = t(i(n, 64));
|
|
159
161
|
return {
|
|
160
162
|
tex: r,
|
|
161
163
|
roadMat: e(r, { preset: "ASPHALT" }).material
|
|
162
164
|
};
|
|
163
|
-
}, [
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}, [
|
|
167
|
-
let
|
|
168
|
-
let [e, t] =
|
|
165
|
+
}, [a]);
|
|
166
|
+
g(() => () => {
|
|
167
|
+
H.roadMat.dispose(), H.tex.dispose();
|
|
168
|
+
}, [H]);
|
|
169
|
+
let U = _(() => {
|
|
170
|
+
let [e, t] = P, n = [];
|
|
169
171
|
for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) {
|
|
170
172
|
let a = e + r, o = t + i;
|
|
171
173
|
a >= 1 && n.push([a, o]);
|
|
172
174
|
}
|
|
173
|
-
return n.sort((n, r) => Math.hypot(n[0] - e, n[1] - t) - Math.hypot(r[0] - e, r[1] - t)), n;
|
|
174
|
-
}, [
|
|
175
|
-
|
|
176
|
-
let e =
|
|
177
|
-
(e !== 0 || t !== 0) && (
|
|
175
|
+
return n.sort((n, r) => Math.hypot(n[0] - e, n[1] - t) - Math.hypot(r[0] - e, r[1] - t)), B.current = !1, n;
|
|
176
|
+
}, [P]);
|
|
177
|
+
g(() => {
|
|
178
|
+
let e = A[0] - M.current[0], t = A[1] - M.current[1];
|
|
179
|
+
(e !== 0 || t !== 0) && (M.current = [A[0], A[1]], N.current = [A[0], A[1]], d(b, T, e, t, D), p?.(A[0], A[1], e, t));
|
|
178
180
|
}, [
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
]),
|
|
185
|
-
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
181
|
+
A,
|
|
182
|
+
b,
|
|
183
|
+
T,
|
|
184
|
+
D,
|
|
185
|
+
p
|
|
186
|
+
]), x(() => {
|
|
187
|
+
if (!B.current) {
|
|
188
|
+
let e = z.current, t = !1;
|
|
189
|
+
for (let n = 0; n < e.length; n++) {
|
|
190
|
+
let r = e[n], i = !1;
|
|
191
|
+
for (let e = 0; e < U.length; e++) {
|
|
192
|
+
let t = U[e];
|
|
193
|
+
if (t[0] === r[0] && t[1] === r[1]) {
|
|
194
|
+
i = !0;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (!i) {
|
|
199
|
+
t = !0;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let n = null;
|
|
204
|
+
for (let t = 0; t < U.length; t++) {
|
|
205
|
+
let r = U[t], i = !1;
|
|
206
|
+
for (let t = 0; t < e.length; t++) {
|
|
207
|
+
let n = e[t];
|
|
208
|
+
if (n[0] === r[0] && n[1] === r[1]) {
|
|
209
|
+
i = !0;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!i) {
|
|
214
|
+
n = r;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (!t && !n) B.current = !0;
|
|
219
|
+
else {
|
|
220
|
+
let t = [];
|
|
221
|
+
for (let n = 0; n < e.length; n++) {
|
|
222
|
+
let r = e[n];
|
|
223
|
+
for (let e = 0; e < U.length; e++) {
|
|
224
|
+
let n = U[e];
|
|
225
|
+
if (n[0] === r[0] && n[1] === r[1]) {
|
|
226
|
+
t.push(r);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
n && t.push(n), z.current = t, R(t);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
let e = M.current[0], t = M.current[1], r = u(b, T, V.current), i = e + r[0], a = t + r[1], s = Math.round(i / 192) * 192, c = Math.round(a / 192) * 192, l = s - e, d = c - t;
|
|
235
|
+
(Math.abs(l) >= 192 || Math.abs(d) >= 192) && (s !== N.current[0] || c !== N.current[1]) && (N.current[0] = s, N.current[1] = c, j([s, c]));
|
|
236
|
+
let f = Math.max(+!!o, Math.round(i / n)), p = Math.round(a / n);
|
|
237
|
+
(f !== I.current[0] || p !== I.current[1]) && (I.current[0] = f, I.current[1] = p, F([f, p]));
|
|
193
238
|
});
|
|
194
|
-
let
|
|
195
|
-
return /* @__PURE__ */
|
|
196
|
-
!
|
|
197
|
-
seed:
|
|
239
|
+
let W = -A[0], G = -A[1];
|
|
240
|
+
return /* @__PURE__ */ w("group", { children: [
|
|
241
|
+
!o && P[0] <= 1 && Math.abs(P[1]) <= 1 && /* @__PURE__ */ C(c, {
|
|
242
|
+
seed: a,
|
|
198
243
|
size: 960,
|
|
199
244
|
segments: 144,
|
|
200
245
|
settlementTier: "town",
|
|
201
|
-
offX:
|
|
202
|
-
offZ:
|
|
246
|
+
offX: W,
|
|
247
|
+
offZ: G
|
|
203
248
|
}),
|
|
204
|
-
!
|
|
205
|
-
seed:
|
|
249
|
+
!o && P[0] <= 2 && Math.abs(P[1]) <= 1 && /* @__PURE__ */ C(k, {
|
|
250
|
+
seed: a,
|
|
206
251
|
islandSize: 960,
|
|
207
|
-
planner:
|
|
208
|
-
roadMat:
|
|
209
|
-
offX:
|
|
210
|
-
offZ:
|
|
252
|
+
planner: O,
|
|
253
|
+
roadMat: H.roadMat,
|
|
254
|
+
offX: W,
|
|
255
|
+
offZ: G
|
|
211
256
|
}),
|
|
212
|
-
L.map(([e, t]) => /* @__PURE__ */
|
|
257
|
+
L.map(([e, t]) => /* @__PURE__ */ C(h, {
|
|
213
258
|
mx: e,
|
|
214
259
|
mz: t,
|
|
215
|
-
planner:
|
|
216
|
-
roadMat:
|
|
217
|
-
offX:
|
|
218
|
-
offZ:
|
|
219
|
-
renderExtra:
|
|
260
|
+
planner: O,
|
|
261
|
+
roadMat: H.roadMat,
|
|
262
|
+
offX: W,
|
|
263
|
+
offZ: G,
|
|
264
|
+
renderExtra: m
|
|
220
265
|
}, `mc_${e}_${t}`))
|
|
221
266
|
] });
|
|
222
267
|
}
|
|
223
|
-
export {
|
|
268
|
+
export { A as KolmoLongDrive, D as computeLongDriveBridgeheadSpawn, O as computeLongDriveMainlandSpawn };
|