@pinkaphant/kolmo 0.1.3 → 0.2.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.
- package/README.md +3 -4
- package/bin/kolmo.mjs +9 -7
- package/dist/engine/kolmoActor.js +60 -59
- package/dist/engine/kolmoInput.d.ts +6 -1
- package/dist/engine/kolmoInput.js +72 -22
- package/dist/engine/kolmoLongDrive.js +52 -52
- package/dist/engine/kolmoVehicle.d.ts +2 -1
- package/dist/engine/kolmoVehicle.js +110 -103
- package/dist/engine/kolmoVehicleDriver.js +19 -28
- package/dist/engine/kolmoWorld.js +57 -54
- package/dist/engine/shiftedFixedBody.js +12 -28
- package/dist/importer/DomainWorkshopPanel.js +97 -98
- package/dist/importer/ImperativeVehicleRig.js +1 -3
- package/dist/importer/khrCompiler.js +0 -2
- package/dist/importer/universalGateBake.js +1 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +21 -24
- package/dist/junk/DestructibleTarget.js +1 -1
- package/dist/junk/targetHitLogic.js +0 -1
- package/dist/shaders/celestialBackdrop.d.ts +2 -2
- package/dist/shaders/celestialBackdrop.js +1 -1
- package/dist/shaders/plumeAndSparkle.d.ts +2 -2
- package/dist/shaders/plumeAndSparkle.js +4 -3
- package/dist/shaders/ps2RoadWebGL.js +1 -1
- package/dist/shaders/retroShader.d.ts +1 -1
- package/dist/shaders/retroShader.js +30 -14
- package/package.json +5 -9
- package/dist/body/HeldItem.d.ts +0 -22
- package/dist/body/HeldItem.js +0 -171
- package/dist/body/KhrBody.d.ts +0 -26
- package/dist/body/KhrBody.js +0 -179
- package/dist/body/bodySi.d.ts +0 -59
- package/dist/body/bodySi.js +0 -61
- package/dist/body/index.d.ts +0 -3
- package/dist/body/index.js +0 -4
|
@@ -4,22 +4,23 @@ import { createVehiclePanelAnimator as i } from "../importer/vehiclePanelAnim.js
|
|
|
4
4
|
import { KolmoEmitterRig as a } from "../shaders/plumeAndSparkle.js";
|
|
5
5
|
import { applySceneRetroMaterials as o } from "../shaders/retroShader.js";
|
|
6
6
|
import { useKolmoInput as ee } from "./kolmoInput.js";
|
|
7
|
-
import { InteractableTrait as te, VehicleTrait as s, WorldSessionTrait as c, ensureWorldSession as ne, kolmoActions as l, useActiveKolmoWorld as re, useWorldTrait as
|
|
8
|
-
import { stepKolmoVehicleFrame as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import * as
|
|
11
|
-
import { useFrame as
|
|
12
|
-
import { cloneKhrBundle as
|
|
13
|
-
import { jsx as
|
|
7
|
+
import { InteractableTrait as te, VehicleTrait as s, WorldSessionTrait as c, ensureWorldSession as ne, kolmoActions as l, useActiveKolmoWorld as re, useWorldTrait as u } from "./kolmoStore.js";
|
|
8
|
+
import { stepKolmoVehicleFrame as ie } from "./kolmoVehicleDriver.js";
|
|
9
|
+
import { useCallback as d, useContext as ae, useEffect as f, useLayoutEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
10
|
+
import * as oe from "three";
|
|
11
|
+
import { useFrame as se } from "@react-three/fiber";
|
|
12
|
+
import { cloneKhrBundle as ce, loadKhrGlb as _, useKhrGlb as v } from "@khr3/core";
|
|
13
|
+
import { jsx as y, jsxs as le } from "react/jsx-runtime";
|
|
14
|
+
import { useRapier as ue } from "@react-three/rapier";
|
|
14
15
|
import { KhrVehicle as b } from "@khr3/core/vehicle";
|
|
15
16
|
// src/engine/kolmoVehicle.tsx
|
|
16
|
-
function
|
|
17
|
+
function de(e) {
|
|
17
18
|
e.traverse((e) => {
|
|
18
19
|
let n = e.userData?.gltfExtensions?.[t];
|
|
19
20
|
n && !e.userData.KOLMO_emitter && (e.userData[t] = n);
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function fe(e) {
|
|
23
24
|
let t = [];
|
|
24
25
|
for (let n of e) n.traverse((e) => {
|
|
25
26
|
let n = e;
|
|
@@ -38,35 +39,40 @@ function de(e) {
|
|
|
38
39
|
for (let e of t) e.dispose();
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
function x({ id: t, sourceBundle: o, rawGlbBytes:
|
|
42
|
+
function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
42
43
|
0,
|
|
43
44
|
.35,
|
|
44
45
|
0
|
|
45
|
-
], rotation:
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
ne(
|
|
49
|
-
}, [
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...
|
|
54
|
-
...
|
|
55
|
-
]), [
|
|
56
|
-
let
|
|
46
|
+
], rotation: v, piloted: x = !1, flightMode: S = !1, vehicleMode: C, enable: pe = !0, ccd: w, linearDamping: T, angularDamping: E, userData: D, onCollisionEnter: O, wheelConfig: k, propellerConfig: A, carConfig: j, droneConfig: M, vehicleRef: N, getInput: me, driver: P, cameraController: F, children: he }) {
|
|
47
|
+
let I = ae(e), L = re();
|
|
48
|
+
p(() => {
|
|
49
|
+
ne(L);
|
|
50
|
+
}, [L]);
|
|
51
|
+
let R = u(L, c), ge = ee(me), z = m(() => ce(o), [o]), B = m(() => i(z), [z]), V = m(() => (de(z.scene), r(z.scene, g)), [z, g]);
|
|
52
|
+
p(() => fe([
|
|
53
|
+
z.scene,
|
|
54
|
+
...z.wheels.map((e) => e.object),
|
|
55
|
+
...z.propellers.map((e) => e.object)
|
|
56
|
+
]), [z]);
|
|
57
|
+
let H = !!(C === "rocket" || S || C !== "drive" && z.propellers.length > 0), U = m(() => V.sockets.find((e) => e.role === "seat" || e.role === "optic")?.localPosition ?? [
|
|
57
58
|
0,
|
|
58
59
|
.65,
|
|
59
60
|
0
|
|
60
|
-
], [
|
|
61
|
+
], [V]), W = m(() => V.sockets.find((e) => e.role === "exit")?.localPosition ?? [
|
|
61
62
|
-1.55,
|
|
62
63
|
.45,
|
|
63
64
|
0
|
|
64
|
-
], [
|
|
65
|
-
if (
|
|
65
|
+
], [V]), G = m(() => {
|
|
66
|
+
if (k || C !== void 0) return {
|
|
66
67
|
...C === void 0 ? {} : { enable: C === "drive" },
|
|
68
|
+
...k ?? {}
|
|
69
|
+
};
|
|
70
|
+
}, [k, C]), K = m(() => {
|
|
71
|
+
if (A || C !== void 0) return {
|
|
72
|
+
...C === void 0 ? {} : { enable: C === "rocket" },
|
|
67
73
|
...A ?? {}
|
|
68
74
|
};
|
|
69
|
-
}, [A, C]),
|
|
75
|
+
}, [A, C]), q = m(() => H ? {
|
|
70
76
|
controlMode: "VELOCITY",
|
|
71
77
|
maxHorizSpeed: 46,
|
|
72
78
|
maxVertSpeed: 16,
|
|
@@ -74,21 +80,21 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: h, position: g = [
|
|
|
74
80
|
maxTiltAngle: .52,
|
|
75
81
|
HORIZ_VEL_P: 1.8,
|
|
76
82
|
VERT_VEL_P: 2.8,
|
|
77
|
-
...
|
|
83
|
+
...z.droneTune ?? {},
|
|
78
84
|
...M ?? {}
|
|
79
85
|
} : M, [
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
H,
|
|
87
|
+
z.droneTune,
|
|
82
88
|
M
|
|
83
|
-
]),
|
|
84
|
-
g[0],
|
|
85
|
-
g[1],
|
|
86
|
-
g[2]
|
|
87
|
-
]), X = m(_ ? [
|
|
89
|
+
]), J = h(null), _e = h([
|
|
88
90
|
_[0],
|
|
89
91
|
_[1],
|
|
90
92
|
_[2]
|
|
91
|
-
]
|
|
93
|
+
]), Y = h(v ? [
|
|
94
|
+
v[0],
|
|
95
|
+
v[1],
|
|
96
|
+
v[2]
|
|
97
|
+
] : void 0), X = h(n()), Z = h(new oe.Vector3()), ve = h({
|
|
92
98
|
camInit: !1,
|
|
93
99
|
cockpit: !1,
|
|
94
100
|
prevCam: !1,
|
|
@@ -96,7 +102,7 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: h, position: g = [
|
|
|
96
102
|
prevR: !1,
|
|
97
103
|
turnL: !1,
|
|
98
104
|
turnR: !1
|
|
99
|
-
}),
|
|
105
|
+
}), ye = h({
|
|
100
106
|
forward: !1,
|
|
101
107
|
backward: !1,
|
|
102
108
|
steerLeft: !1,
|
|
@@ -110,9 +116,9 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: h, position: g = [
|
|
|
110
116
|
pitchBackward: !1,
|
|
111
117
|
rollLeft: !1,
|
|
112
118
|
rollRight: !1
|
|
113
|
-
}),
|
|
114
|
-
|
|
115
|
-
let n =
|
|
119
|
+
}), Q = d((e, t) => {
|
|
120
|
+
Z.current.x -= e, Z.current.z -= t;
|
|
121
|
+
let n = J.current;
|
|
116
122
|
if (n) {
|
|
117
123
|
n.currPos.x -= e, n.currPos.z -= t;
|
|
118
124
|
for (let r of n.wheelsInfo.values()) {
|
|
@@ -121,107 +127,108 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: h, position: g = [
|
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
}, []);
|
|
124
|
-
|
|
125
|
-
let e =
|
|
130
|
+
f(() => {
|
|
131
|
+
let e = L.spawn(s({
|
|
126
132
|
id: t,
|
|
127
|
-
handle:
|
|
128
|
-
centerOfMass: [...
|
|
129
|
-
seatOffset:
|
|
130
|
-
exitOffset:
|
|
131
|
-
isFlight:
|
|
132
|
-
onOriginShift:
|
|
133
|
+
handle: J.current,
|
|
134
|
+
centerOfMass: [...z.centerOfMass],
|
|
135
|
+
seatOffset: U,
|
|
136
|
+
exitOffset: W,
|
|
137
|
+
isFlight: H,
|
|
138
|
+
onOriginShift: Q
|
|
133
139
|
}), te({
|
|
134
140
|
id: t,
|
|
135
141
|
radius: 4.2,
|
|
136
142
|
kind: "vehicle"
|
|
137
143
|
}));
|
|
138
|
-
return x && !
|
|
139
|
-
|
|
144
|
+
return x && !L.get(c)?.activeVehicleId && l(L).boardVehicle(t), () => {
|
|
145
|
+
L.get(c)?.activeVehicleId === t && l(L).exitVehicle(), e.destroy();
|
|
140
146
|
};
|
|
141
147
|
}, [
|
|
142
|
-
|
|
148
|
+
L,
|
|
143
149
|
t,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
K,
|
|
150
|
+
z,
|
|
151
|
+
U,
|
|
147
152
|
W,
|
|
153
|
+
H,
|
|
148
154
|
x,
|
|
149
|
-
|
|
155
|
+
Q
|
|
150
156
|
]);
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
for (let n of
|
|
157
|
+
let be = d((e) => {
|
|
158
|
+
J.current = e, N && (N.current = e);
|
|
159
|
+
for (let n of L.query(s)) {
|
|
154
160
|
let r = n.get(s);
|
|
155
161
|
r && r.id === t && n.set(s, {
|
|
156
162
|
...r,
|
|
157
163
|
handle: e,
|
|
158
|
-
onOriginShift:
|
|
164
|
+
onOriginShift: Q
|
|
159
165
|
});
|
|
160
166
|
}
|
|
161
167
|
}, [
|
|
162
|
-
|
|
168
|
+
L,
|
|
163
169
|
t,
|
|
164
170
|
N,
|
|
165
|
-
|
|
166
|
-
]),
|
|
167
|
-
return
|
|
168
|
-
let r = Math.min(Math.max(n, 1e-4),
|
|
169
|
-
|
|
170
|
-
let i =
|
|
171
|
-
i && i.body && (P ? (P(i, r, e), F && F(i, r, e)) :
|
|
171
|
+
Q
|
|
172
|
+
]), { world: $ } = ue(), xe = R?.activeVehicleId === t || x && !R?.activeVehicleId;
|
|
173
|
+
return se((e, n) => {
|
|
174
|
+
let r = $.timestep > 0 ? $.timestep : Math.min(Math.max(n, 1e-4), 1 / 30);
|
|
175
|
+
B.step(r);
|
|
176
|
+
let i = J.current;
|
|
177
|
+
i && i.body && (P ? (P(i, r, e), F && F(i, r, e)) : ie({
|
|
172
178
|
id: t,
|
|
173
179
|
veh: i,
|
|
174
|
-
keys:
|
|
175
|
-
cmd:
|
|
176
|
-
sig:
|
|
177
|
-
st:
|
|
178
|
-
camTarget:
|
|
179
|
-
centerOfMass:
|
|
180
|
-
seatOffset:
|
|
181
|
-
isPiloted:
|
|
182
|
-
isFlight:
|
|
180
|
+
keys: ge(),
|
|
181
|
+
cmd: ye.current,
|
|
182
|
+
sig: X.current,
|
|
183
|
+
st: ve.current,
|
|
184
|
+
camTarget: Z.current,
|
|
185
|
+
centerOfMass: z.centerOfMass,
|
|
186
|
+
seatOffset: U,
|
|
187
|
+
isPiloted: xe,
|
|
188
|
+
isFlight: H,
|
|
183
189
|
dt: r,
|
|
184
190
|
state: e,
|
|
185
191
|
cameraController: F
|
|
186
192
|
}));
|
|
187
|
-
}), /* @__PURE__ */
|
|
193
|
+
}), /* @__PURE__ */ y("group", {
|
|
188
194
|
onClick: (e) => {
|
|
189
|
-
e.delta <= 5 &&
|
|
195
|
+
e.delta <= 5 && B.toggleHitObject(e.object) && e.stopPropagation();
|
|
190
196
|
},
|
|
191
|
-
children: /* @__PURE__ */
|
|
192
|
-
ref:
|
|
193
|
-
bundle:
|
|
194
|
-
position:
|
|
195
|
-
enable:
|
|
196
|
-
enableCustomGravity:
|
|
197
|
-
...
|
|
198
|
-
...
|
|
199
|
-
...
|
|
200
|
-
...
|
|
201
|
-
...
|
|
202
|
-
...
|
|
203
|
-
...
|
|
197
|
+
children: /* @__PURE__ */ le(b, {
|
|
198
|
+
ref: be,
|
|
199
|
+
bundle: z,
|
|
200
|
+
position: _e.current,
|
|
201
|
+
enable: pe,
|
|
202
|
+
enableCustomGravity: I,
|
|
203
|
+
...Y.current === void 0 ? {} : { rotation: Y.current },
|
|
204
|
+
...w === void 0 ? {} : { ccd: w },
|
|
205
|
+
...T === void 0 ? {} : { linearDamping: T },
|
|
206
|
+
...E === void 0 ? {} : { angularDamping: E },
|
|
207
|
+
...D === void 0 ? {} : { userData: D },
|
|
208
|
+
...O === void 0 ? {} : { onCollisionEnter: O },
|
|
209
|
+
...G === void 0 ? {} : { wheelConfig: G },
|
|
210
|
+
...K === void 0 ? {} : { propellerConfig: K },
|
|
204
211
|
...j === void 0 ? {} : { carConfig: j },
|
|
205
|
-
...
|
|
206
|
-
children: [/* @__PURE__ */
|
|
207
|
-
emitters:
|
|
208
|
-
signalsRef:
|
|
209
|
-
}),
|
|
212
|
+
...q === void 0 ? {} : { droneConfig: q },
|
|
213
|
+
children: [/* @__PURE__ */ y(a, {
|
|
214
|
+
emitters: V.emitters,
|
|
215
|
+
signalsRef: X
|
|
216
|
+
}), he]
|
|
210
217
|
})
|
|
211
218
|
});
|
|
212
219
|
}
|
|
213
220
|
function S(e) {
|
|
214
|
-
return /* @__PURE__ */
|
|
221
|
+
return /* @__PURE__ */ y(x, {
|
|
215
222
|
...e,
|
|
216
|
-
sourceBundle:
|
|
223
|
+
sourceBundle: v(e.src)
|
|
217
224
|
});
|
|
218
225
|
}
|
|
219
226
|
function C(e) {
|
|
220
|
-
let [t, n] =
|
|
221
|
-
return
|
|
227
|
+
let [t, n] = g(null);
|
|
228
|
+
return f(() => {
|
|
222
229
|
if (e.bundle || e.src || !e.rawGlbBytes) return;
|
|
223
230
|
let t = !0;
|
|
224
|
-
return
|
|
231
|
+
return _(e.rawGlbBytes).then((e) => {
|
|
225
232
|
t && n(e);
|
|
226
233
|
}), () => {
|
|
227
234
|
t = !1;
|
|
@@ -230,13 +237,13 @@ function C(e) {
|
|
|
230
237
|
e.bundle,
|
|
231
238
|
e.src,
|
|
232
239
|
e.rawGlbBytes
|
|
233
|
-
]), e.bundle ? /* @__PURE__ */
|
|
240
|
+
]), e.bundle ? /* @__PURE__ */ y(x, {
|
|
234
241
|
...e,
|
|
235
242
|
sourceBundle: e.bundle
|
|
236
|
-
}) : e.src ? /* @__PURE__ */
|
|
243
|
+
}) : e.src ? /* @__PURE__ */ y(S, {
|
|
237
244
|
...e,
|
|
238
245
|
src: e.src
|
|
239
|
-
}) : t ? /* @__PURE__ */
|
|
246
|
+
}) : t ? /* @__PURE__ */ y(x, {
|
|
240
247
|
...e,
|
|
241
248
|
sourceBundle: t
|
|
242
249
|
}) : null;
|
|
@@ -2,37 +2,28 @@ import { kolmoTelemetry as e } from "./kolmoStore.js";
|
|
|
2
2
|
import * as t from "three";
|
|
3
3
|
import { easing as n } from "maath";
|
|
4
4
|
// src/engine/kolmoVehicleDriver.ts
|
|
5
|
-
var r = new t.Vector3(), i = new t.Vector3(), a = new t.Vector3(), o = new t.Vector3()
|
|
6
|
-
function
|
|
7
|
-
let { id:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
l.setMovement(d);
|
|
5
|
+
var r = new t.Vector3(), i = new t.Vector3(), a = new t.Vector3(), o = new t.Vector3();
|
|
6
|
+
function s(t) {
|
|
7
|
+
let { id: s, veh: c, keys: l, cmd: u, sig: d, st: f, camTarget: p, centerOfMass: m, seatOffset: h, isPiloted: g, isFlight: _, dt: v, state: y, cameraController: b } = t;
|
|
8
|
+
g && (l.cameraView && !f.prevCam && (f.cockpit = !f.cockpit), f.prevCam = l.cameraView, _ ? (u.pitchForward = l.forward, u.pitchBackward = l.backward, u.yawLeft = l.left, u.yawRight = l.right, u.rollLeft = l.turnLeft, u.rollRight = l.turnRight, u.throttleUp = l.brake, u.throttleDown = l.descend, u.forward = !1, u.backward = !1, u.steerLeft = !1, u.steerRight = !1, u.brake = !1) : (l.turnLeft && !f.prevL && (f.turnL = !f.turnL, f.turnR = !1), l.turnRight && !f.prevR && (f.turnR = !f.turnR, f.turnL = !1), f.prevL = l.turnLeft, f.prevR = l.turnRight, u.forward = l.forward, u.backward = l.backward, u.steerLeft = l.left, u.steerRight = l.right, u.brake = l.brake, u.pitchForward = !1, u.pitchBackward = !1, u.throttleUp = !1, u.throttleDown = !1, u.yawLeft = !1, u.yawRight = !1, u.rollLeft = !1, u.rollRight = !1), c.setMovement(u));
|
|
9
|
+
let x = 0, S = 0;
|
|
10
|
+
for (let e of c.wheelsInfo.values()) e.current.rayHit && e.current.slipStrength > x && (x = e.current.slipStrength);
|
|
11
|
+
if (c.propellersInfo.size > 0) {
|
|
12
|
+
for (let e of c.propellersInfo.values()) S += e.current.finalThrottle;
|
|
13
|
+
S /= c.propellersInfo.size;
|
|
17
14
|
}
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
if (l.
|
|
21
|
-
|
|
22
|
-
C /= l.propellersInfo.size;
|
|
23
|
-
}
|
|
24
|
-
let w = l.currLinVel.dot(l.bodyZAxis);
|
|
25
|
-
if (f.throttle = _ ? v ? u.forward || u.brake ? 1 : Math.max(.22, C) : +!!u.forward : 0, f.boost = _ ? v ? u.boost ? 1 : u.forward ? .58 : .16 : u.boost && u.forward ? 1 : 0 : 0, f.brake = _ && !v && (u.brake || u.backward && w > 1) ? 1 : 0, f.reverse = _ && !v && u.backward && w <= 1 ? 1 : 0, f.slip = Math.min(1, S), f.turn_l = +!!p.turnL, f.turn_r = +!!p.turnR, f.headlight = 1, f.always = 1, !_) return;
|
|
26
|
-
if (e.speedKmh = l.currLinVel.length() * 3.6, e.rpm = Math.round(v ? 1800 + f.throttle * 6200 + f.boost * 4200 : l.engineRPM), e.gear = v ? u.boost ? 2 : 1 : l.gearIndex + 1, e.throttle = f.throttle, e.boost = f.boost, e.mode = v ? "flight" : "car", e.activeVehicleId = c, x) {
|
|
27
|
-
x(l, y, b);
|
|
15
|
+
let C = c.currLinVel.dot(c.bodyZAxis);
|
|
16
|
+
if (d.throttle = g ? _ ? l.forward || l.brake ? 1 : Math.max(.22, S) : +!!l.forward : 0, d.boost = g ? _ ? l.boost ? 1 : l.forward ? .58 : .16 : l.boost && l.forward ? 1 : 0 : 0, d.brake = g && !_ && (l.brake || l.backward && C > 1) ? 1 : 0, d.reverse = g && !_ && l.backward && C <= 1 ? 1 : 0, d.slip = Math.min(1, x), d.turn_l = +!!f.turnL, d.turn_r = +!!f.turnR, d.headlight = 1, d.always = 1, !g) return;
|
|
17
|
+
if (e.speedKmh = c.currLinVel.length() * 3.6, e.rpm = Math.round(_ ? 1800 + d.throttle * 6200 + d.boost * 4200 : c.engineRPM), e.gear = _ ? l.boost ? 2 : 1 : c.gearIndex + 1, e.throttle = d.throttle, e.boost = d.boost, e.mode = _ ? "flight" : "car", e.activeVehicleId = s, b) {
|
|
18
|
+
b(c, v, y);
|
|
28
19
|
return;
|
|
29
20
|
}
|
|
30
|
-
if (r.copy(
|
|
31
|
-
a.set(
|
|
21
|
+
if (r.copy(c.upAxis), r.lengthSq() < 1e-6 && r.copy(c.bodyYAxis), f.cockpit) {
|
|
22
|
+
a.set(h[0] - m[0], h[1] - m[1] + .32, h[2] - m[2]).applyQuaternion(c.currQuat).add(c.currPos), o.copy(a).addScaledVector(c.bodyZAxis, 24), n.damp3(y.camera.position, a, .04, v), n.damp3(y.camera.up, c.bodyYAxis, .08, v), y.camera.lookAt(o);
|
|
32
23
|
return;
|
|
33
24
|
}
|
|
34
|
-
i.copy(
|
|
35
|
-
let
|
|
36
|
-
a.copy(
|
|
25
|
+
i.copy(c.bodyZAxis), _ || i.projectOnPlane(r).normalize(), i.lengthSq() < 1e-6 && i.copy(c.bodyZAxis);
|
|
26
|
+
let w = _ ? 11.2 : 6.8, T = _ ? 3.1 : 2.15;
|
|
27
|
+
a.copy(c.currPos).addScaledVector(i, -w).addScaledVector(r, T), o.copy(c.currPos).addScaledVector(i, _ ? 7.5 : 3.6).addScaledVector(r, .65), f.camInit ||= (y.camera.position.copy(a), p.copy(o), !0), n.damp3(y.camera.position, a, .14, v), n.damp3(p, o, .08, v), n.damp3(y.camera.up, r, .16, v), y.camera.lookAt(p);
|
|
37
28
|
}
|
|
38
|
-
export {
|
|
29
|
+
export { s as stepKolmoVehicleFrame };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { KolmoGravityContext as e, KolmoPhysics as t, useIsKolmoCustomGravity as n, useOptionalKootaWorld as r } from "../physics/index.js";
|
|
2
2
|
import { KolmoSkybox as i } from "../shaders/celestialBackdrop.js";
|
|
3
3
|
import { syncRetroUniforms as a } from "../shaders/retroShader.js";
|
|
4
|
-
import { EMPTY_KOLMO_INPUT as o, KOLMO_KEY_MAP as s,
|
|
5
|
-
import { RetroViewportSync as
|
|
6
|
-
import { WorldSessionTrait as
|
|
7
|
-
import { useEffect as
|
|
8
|
-
import * as
|
|
9
|
-
import { Canvas as
|
|
10
|
-
import { KeyboardControls as
|
|
11
|
-
import { WorldProvider as
|
|
12
|
-
import { Fragment as
|
|
4
|
+
import { EMPTY_KOLMO_INPUT as o, KOLMO_KEY_MAP as s, KolmoKeyboardBridge as c, KolmoKeyboardContext as l, useKolmoInput as u } from "./kolmoInput.js";
|
|
5
|
+
import { RetroViewportSync as d, RoomEnvRig as f, ShadowSnapRig as p } from "./kolmoRigs.js";
|
|
6
|
+
import { WorldSessionTrait as m, ensureWorldSession as h, kolmoActions as g, kolmoWorld as _, useWorldTrait as v } from "./kolmoStore.js";
|
|
7
|
+
import { useEffect as y, useLayoutEffect as b } from "react";
|
|
8
|
+
import * as x from "three";
|
|
9
|
+
import { Canvas as S } from "@react-three/fiber";
|
|
10
|
+
import { KeyboardControls as C } from "@react-three/drei";
|
|
11
|
+
import { WorldProvider as w } from "koota/react";
|
|
12
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
13
13
|
// src/engine/kolmoWorld.tsx
|
|
14
|
-
function
|
|
14
|
+
function O({ children: e, className: t, style: n, fov: r = 56, near: i = .15, far: a = 6500, cameraPosition: o = [
|
|
15
15
|
0,
|
|
16
16
|
3.2,
|
|
17
17
|
-8.5
|
|
18
|
-
], dpr: s = [1, 1.5], frameloop: c = "always", shadows: l = "basic", toneMapping:
|
|
19
|
-
return /* @__PURE__ */
|
|
18
|
+
], dpr: s = [1, 1.5], frameloop: c = "always", shadows: l = "basic", toneMapping: u, onCanvasReady: d, onContextLost: p, roomEnv: m = !1 }) {
|
|
19
|
+
return /* @__PURE__ */ D(S, {
|
|
20
20
|
className: t,
|
|
21
21
|
style: n ?? {
|
|
22
22
|
width: "100%",
|
|
@@ -29,7 +29,7 @@ function E({ children: e, className: t, style: n, fov: r = 56, near: i = .15, fa
|
|
|
29
29
|
gl: {
|
|
30
30
|
antialias: !1,
|
|
31
31
|
powerPreference: "high-performance",
|
|
32
|
-
...
|
|
32
|
+
...u === void 0 ? {} : { toneMapping: u }
|
|
33
33
|
},
|
|
34
34
|
camera: {
|
|
35
35
|
fov: r,
|
|
@@ -38,44 +38,44 @@ function E({ children: e, className: t, style: n, fov: r = 56, near: i = .15, fa
|
|
|
38
38
|
position: o
|
|
39
39
|
},
|
|
40
40
|
onCreated: ({ gl: e }) => {
|
|
41
|
-
e.outputColorSpace =
|
|
41
|
+
e.outputColorSpace = x.SRGBColorSpace;
|
|
42
42
|
let t = e.domElement;
|
|
43
|
-
|
|
43
|
+
d?.(t), p && (t.addEventListener("webglcontextlost", (e) => {
|
|
44
44
|
e.preventDefault(), p(!0);
|
|
45
45
|
}), t.addEventListener("webglcontextrestored", () => p(!1)));
|
|
46
46
|
},
|
|
47
|
-
children: [m !== !1 && /* @__PURE__ */
|
|
47
|
+
children: [m !== !1 && /* @__PURE__ */ E(f, { intensity: typeof m == "number" ? m : .65 }), e]
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
e &&
|
|
50
|
+
function k({ world: e, retroPreset: t }) {
|
|
51
|
+
b(() => {
|
|
52
|
+
e && h(e);
|
|
53
53
|
}, [e]);
|
|
54
|
-
let n =
|
|
55
|
-
return
|
|
56
|
-
e ? t ?
|
|
54
|
+
let n = v(e, m);
|
|
55
|
+
return y(() => {
|
|
56
|
+
e ? t ? g(e).setRetroPreset(t) : n?.activeRetroPreset && a(n.activeRetroPreset) : t && a(t);
|
|
57
57
|
}, [
|
|
58
58
|
e,
|
|
59
59
|
t,
|
|
60
60
|
n?.activeRetroPreset
|
|
61
61
|
]), null;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, [
|
|
68
|
-
let
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
world:
|
|
71
|
-
retroPreset:
|
|
63
|
+
function A({ gravity: e = "planar", paused: n = !1, timeScale: a = 1, maxDelta: o, physicsDebug: u = !1, retroPreset: d, skybox: f = "nebula", lighting: m = "default", fogExp2: g, sunLightRef: v, shadowSnap: y = !1, world: x = _, keyboardMap: S = s, children: O }) {
|
|
64
|
+
let A = r(), j = x === null ? A : x;
|
|
65
|
+
b(() => {
|
|
66
|
+
j && h(j);
|
|
67
|
+
}, [j]);
|
|
68
|
+
let M = /* @__PURE__ */ D(T, { children: [
|
|
69
|
+
/* @__PURE__ */ E(k, {
|
|
70
|
+
world: j,
|
|
71
|
+
retroPreset: d
|
|
72
72
|
}),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
y && v && /* @__PURE__ */ E(p, { sunLightRef: v }),
|
|
74
|
+
f === "nebula" && /* @__PURE__ */ E(i, {}),
|
|
75
|
+
f === "day" && /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E("color", {
|
|
76
76
|
attach: "background",
|
|
77
77
|
args: ["#6ba6d6"]
|
|
78
|
-
}), !
|
|
78
|
+
}), !g && /* @__PURE__ */ E("fog", {
|
|
79
79
|
attach: "fog",
|
|
80
80
|
args: [
|
|
81
81
|
"#9dc4e2",
|
|
@@ -83,18 +83,18 @@ function O({ gravity: e = "planar", paused: n = !1, timeScale: a = 1, maxDelta:
|
|
|
83
83
|
520
|
|
84
84
|
]
|
|
85
85
|
})] }),
|
|
86
|
-
|
|
86
|
+
g && /* @__PURE__ */ E("fogExp2", {
|
|
87
87
|
attach: "fog",
|
|
88
|
-
args:
|
|
88
|
+
args: g
|
|
89
89
|
}),
|
|
90
|
-
|
|
91
|
-
/* @__PURE__ */
|
|
90
|
+
m === "default" && /* @__PURE__ */ D(T, { children: [
|
|
91
|
+
/* @__PURE__ */ E("hemisphereLight", { args: [
|
|
92
92
|
"#b8dcff",
|
|
93
93
|
"#241d30",
|
|
94
94
|
.8
|
|
95
95
|
] }),
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
ref:
|
|
96
|
+
/* @__PURE__ */ E("directionalLight", {
|
|
97
|
+
ref: v,
|
|
98
98
|
position: [
|
|
99
99
|
48,
|
|
100
100
|
76,
|
|
@@ -105,7 +105,7 @@ function O({ gravity: e = "planar", paused: n = !1, timeScale: a = 1, maxDelta:
|
|
|
105
105
|
castShadow: !0,
|
|
106
106
|
"shadow-mapSize": [1024, 1024]
|
|
107
107
|
}),
|
|
108
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ E("directionalLight", {
|
|
109
109
|
position: [
|
|
110
110
|
-42,
|
|
111
111
|
28,
|
|
@@ -115,22 +115,25 @@ function O({ gravity: e = "planar", paused: n = !1, timeScale: a = 1, maxDelta:
|
|
|
115
115
|
color: "#68a8ff"
|
|
116
116
|
})
|
|
117
117
|
] }),
|
|
118
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ E(t, {
|
|
119
119
|
gravity: e,
|
|
120
120
|
paused: n,
|
|
121
121
|
timeScale: a,
|
|
122
122
|
maxDelta: o,
|
|
123
|
-
physicsDebug:
|
|
123
|
+
physicsDebug: u,
|
|
124
124
|
world: null,
|
|
125
|
-
children:
|
|
125
|
+
children: O
|
|
126
126
|
})
|
|
127
|
-
] }),
|
|
128
|
-
map:
|
|
129
|
-
children:
|
|
130
|
-
}) :
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
] }), N = S ? /* @__PURE__ */ E(C, {
|
|
128
|
+
map: S,
|
|
129
|
+
children: /* @__PURE__ */ E(c, { children: M })
|
|
130
|
+
}) : /* @__PURE__ */ E(l.Provider, {
|
|
131
|
+
value: null,
|
|
132
|
+
children: M
|
|
133
|
+
});
|
|
134
|
+
return x !== null && x !== A ? /* @__PURE__ */ E(w, {
|
|
135
|
+
world: x,
|
|
136
|
+
children: N
|
|
137
|
+
}) : N;
|
|
135
138
|
}
|
|
136
|
-
export { o as EMPTY_KOLMO_INPUT, s as KOLMO_KEY_MAP,
|
|
139
|
+
export { o as EMPTY_KOLMO_INPUT, s as KOLMO_KEY_MAP, O as KolmoCanvas, e as KolmoGravityContext, t as KolmoPhysics, A as KolmoWorld, d as RetroViewportSync, f as RoomEnvRig, p as ShadowSnapRig, n as useIsKolmoCustomGravity, u as useKolmoInput, r as useOptionalKootaWorld };
|
|
@@ -1,44 +1,28 @@
|
|
|
1
1
|
import { MACRO_SIZE_M as e } from "../world/macroCellSchema.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { RigidBody as a } from "@react-three/rapier";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
import { RigidBody as n } from "@react-three/rapier";
|
|
6
5
|
// src/engine/shiftedFixedBody.tsx
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let p = n(null);
|
|
10
|
-
return t(() => {
|
|
11
|
-
let t = p.current;
|
|
12
|
-
t && (t.setTranslation({
|
|
13
|
-
x: e,
|
|
14
|
-
y: r,
|
|
15
|
-
z: c
|
|
16
|
-
}, !1), o.set(0, l, 0), s.setFromEuler(o), t.setRotation(s, !1));
|
|
17
|
-
}, [
|
|
18
|
-
e,
|
|
19
|
-
r,
|
|
20
|
-
c,
|
|
21
|
-
l
|
|
22
|
-
]), /* @__PURE__ */ i(a, {
|
|
23
|
-
ref: p,
|
|
6
|
+
function r({ x: e, y: r = 0, z: i, yaw: a = 0, friction: o = 1, userData: s, children: c }) {
|
|
7
|
+
return /* @__PURE__ */ t(n, {
|
|
24
8
|
type: "fixed",
|
|
25
9
|
position: [
|
|
26
10
|
e,
|
|
27
11
|
r,
|
|
28
|
-
|
|
12
|
+
i
|
|
29
13
|
],
|
|
30
14
|
rotation: [
|
|
31
15
|
0,
|
|
32
|
-
|
|
16
|
+
a,
|
|
33
17
|
0
|
|
34
18
|
],
|
|
35
19
|
colliders: !1,
|
|
36
|
-
friction:
|
|
37
|
-
...
|
|
38
|
-
children:
|
|
20
|
+
friction: o,
|
|
21
|
+
...s === void 0 ? {} : { userData: s },
|
|
22
|
+
children: c
|
|
39
23
|
});
|
|
40
24
|
}
|
|
41
|
-
function
|
|
25
|
+
function i(t, n, r, i) {
|
|
42
26
|
let a = e * .5, o = /* @__PURE__ */ new Uint8Array(9216);
|
|
43
27
|
o.fill(255);
|
|
44
28
|
let s = /* @__PURE__ */ new Uint8Array(36864), c = /* @__PURE__ */ new Uint8Array(36864);
|
|
@@ -61,4 +45,4 @@ function l(t, n, r, i) {
|
|
|
61
45
|
splat1: c
|
|
62
46
|
};
|
|
63
47
|
}
|
|
64
|
-
export {
|
|
48
|
+
export { r as ShiftedFixedBody, i as bakeMacroCellSplat };
|