@pinkaphant/kolmo 0.2.0 → 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/dist/engine/kolmoActor.js +60 -59
- package/dist/engine/kolmoInput.d.ts +1 -1
- package/dist/engine/kolmoInput.js +53 -1
- package/dist/engine/kolmoLongDrive.js +52 -52
- package/dist/engine/kolmoVehicle.d.ts +1 -1
- package/dist/engine/kolmoVehicle.js +80 -79
- 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 -171
- package/dist/body/bodySi.d.ts +0 -48
- package/dist/body/bodySi.js +0 -52
- 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
|
|
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
10
|
import * as oe from "three";
|
|
11
11
|
import { useFrame as se } from "@react-three/fiber";
|
|
12
12
|
import { cloneKhrBundle as ce, loadKhrGlb as _, useKhrGlb as v } from "@khr3/core";
|
|
13
13
|
import { jsx as y, jsxs as le } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import { useRapier as ue } from "@react-three/rapier";
|
|
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;
|
|
@@ -42,36 +43,36 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
|
42
43
|
0,
|
|
43
44
|
.35,
|
|
44
45
|
0
|
|
45
|
-
], rotation: v, piloted: x = !1, flightMode: S = !1, vehicleMode: C, enable:
|
|
46
|
-
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();
|
|
47
48
|
p(() => {
|
|
48
|
-
ne(
|
|
49
|
-
}, [
|
|
50
|
-
let
|
|
51
|
-
p(() =>
|
|
52
|
-
|
|
53
|
-
...
|
|
54
|
-
...
|
|
55
|
-
]), [
|
|
56
|
-
let
|
|
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
|
+
], [V]), G = m(() => {
|
|
65
66
|
if (k || C !== void 0) return {
|
|
66
67
|
...C === void 0 ? {} : { enable: C === "drive" },
|
|
67
68
|
...k ?? {}
|
|
68
69
|
};
|
|
69
|
-
}, [k, C]),
|
|
70
|
+
}, [k, C]), K = m(() => {
|
|
70
71
|
if (A || C !== void 0) return {
|
|
71
72
|
...C === void 0 ? {} : { enable: C === "rocket" },
|
|
72
73
|
...A ?? {}
|
|
73
74
|
};
|
|
74
|
-
}, [A, C]),
|
|
75
|
+
}, [A, C]), q = m(() => H ? {
|
|
75
76
|
controlMode: "VELOCITY",
|
|
76
77
|
maxHorizSpeed: 46,
|
|
77
78
|
maxVertSpeed: 16,
|
|
@@ -79,21 +80,21 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
|
79
80
|
maxTiltAngle: .52,
|
|
80
81
|
HORIZ_VEL_P: 1.8,
|
|
81
82
|
VERT_VEL_P: 2.8,
|
|
82
|
-
...
|
|
83
|
+
...z.droneTune ?? {},
|
|
83
84
|
...M ?? {}
|
|
84
85
|
} : M, [
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
H,
|
|
87
|
+
z.droneTune,
|
|
87
88
|
M
|
|
88
|
-
]),
|
|
89
|
+
]), J = h(null), _e = h([
|
|
89
90
|
_[0],
|
|
90
91
|
_[1],
|
|
91
92
|
_[2]
|
|
92
|
-
]),
|
|
93
|
+
]), Y = h(v ? [
|
|
93
94
|
v[0],
|
|
94
95
|
v[1],
|
|
95
96
|
v[2]
|
|
96
|
-
] : void 0),
|
|
97
|
+
] : void 0), X = h(n()), Z = h(new oe.Vector3()), ve = h({
|
|
97
98
|
camInit: !1,
|
|
98
99
|
cockpit: !1,
|
|
99
100
|
prevCam: !1,
|
|
@@ -101,7 +102,7 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
|
101
102
|
prevR: !1,
|
|
102
103
|
turnL: !1,
|
|
103
104
|
turnR: !1
|
|
104
|
-
}),
|
|
105
|
+
}), ye = h({
|
|
105
106
|
forward: !1,
|
|
106
107
|
backward: !1,
|
|
107
108
|
steerLeft: !1,
|
|
@@ -115,9 +116,9 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
|
115
116
|
pitchBackward: !1,
|
|
116
117
|
rollLeft: !1,
|
|
117
118
|
rollRight: !1
|
|
118
|
-
}),
|
|
119
|
-
|
|
120
|
-
let n =
|
|
119
|
+
}), Q = d((e, t) => {
|
|
120
|
+
Z.current.x -= e, Z.current.z -= t;
|
|
121
|
+
let n = J.current;
|
|
121
122
|
if (n) {
|
|
122
123
|
n.currPos.x -= e, n.currPos.z -= t;
|
|
123
124
|
for (let r of n.wheelsInfo.values()) {
|
|
@@ -127,92 +128,92 @@ function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
|
127
128
|
}
|
|
128
129
|
}, []);
|
|
129
130
|
f(() => {
|
|
130
|
-
let e =
|
|
131
|
+
let e = L.spawn(s({
|
|
131
132
|
id: t,
|
|
132
|
-
handle:
|
|
133
|
-
centerOfMass: [...
|
|
134
|
-
seatOffset:
|
|
135
|
-
exitOffset:
|
|
136
|
-
isFlight:
|
|
137
|
-
onOriginShift:
|
|
133
|
+
handle: J.current,
|
|
134
|
+
centerOfMass: [...z.centerOfMass],
|
|
135
|
+
seatOffset: U,
|
|
136
|
+
exitOffset: W,
|
|
137
|
+
isFlight: H,
|
|
138
|
+
onOriginShift: Q
|
|
138
139
|
}), te({
|
|
139
140
|
id: t,
|
|
140
141
|
radius: 4.2,
|
|
141
142
|
kind: "vehicle"
|
|
142
143
|
}));
|
|
143
|
-
return x && !
|
|
144
|
-
|
|
144
|
+
return x && !L.get(c)?.activeVehicleId && l(L).boardVehicle(t), () => {
|
|
145
|
+
L.get(c)?.activeVehicleId === t && l(L).exitVehicle(), e.destroy();
|
|
145
146
|
};
|
|
146
147
|
}, [
|
|
147
|
-
|
|
148
|
+
L,
|
|
148
149
|
t,
|
|
149
|
-
|
|
150
|
-
W,
|
|
151
|
-
G,
|
|
150
|
+
z,
|
|
152
151
|
U,
|
|
152
|
+
W,
|
|
153
|
+
H,
|
|
153
154
|
x,
|
|
154
|
-
|
|
155
|
+
Q
|
|
155
156
|
]);
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
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)) {
|
|
159
160
|
let r = n.get(s);
|
|
160
161
|
r && r.id === t && n.set(s, {
|
|
161
162
|
...r,
|
|
162
163
|
handle: e,
|
|
163
|
-
onOriginShift:
|
|
164
|
+
onOriginShift: Q
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
167
|
}, [
|
|
167
|
-
|
|
168
|
+
L,
|
|
168
169
|
t,
|
|
169
170
|
N,
|
|
170
|
-
|
|
171
|
-
]),
|
|
171
|
+
Q
|
|
172
|
+
]), { world: $ } = ue(), xe = R?.activeVehicleId === t || x && !R?.activeVehicleId;
|
|
172
173
|
return se((e, n) => {
|
|
173
|
-
let r = Math.min(Math.max(n, 1e-4),
|
|
174
|
-
|
|
175
|
-
let i =
|
|
176
|
-
i && i.body && (P ? (P(i, r, e), F && F(i, r, e)) :
|
|
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({
|
|
177
178
|
id: t,
|
|
178
179
|
veh: i,
|
|
179
|
-
keys:
|
|
180
|
-
cmd:
|
|
181
|
-
sig:
|
|
182
|
-
st:
|
|
183
|
-
camTarget:
|
|
184
|
-
centerOfMass:
|
|
185
|
-
seatOffset:
|
|
186
|
-
isPiloted:
|
|
187
|
-
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,
|
|
188
189
|
dt: r,
|
|
189
190
|
state: e,
|
|
190
191
|
cameraController: F
|
|
191
192
|
}));
|
|
192
193
|
}), /* @__PURE__ */ y("group", {
|
|
193
194
|
onClick: (e) => {
|
|
194
|
-
e.delta <= 5 &&
|
|
195
|
+
e.delta <= 5 && B.toggleHitObject(e.object) && e.stopPropagation();
|
|
195
196
|
},
|
|
196
|
-
children: /* @__PURE__ */ le(
|
|
197
|
-
ref:
|
|
198
|
-
bundle:
|
|
199
|
-
position:
|
|
200
|
-
enable:
|
|
201
|
-
enableCustomGravity:
|
|
202
|
-
...
|
|
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 },
|
|
203
204
|
...w === void 0 ? {} : { ccd: w },
|
|
204
205
|
...T === void 0 ? {} : { linearDamping: T },
|
|
205
206
|
...E === void 0 ? {} : { angularDamping: E },
|
|
206
207
|
...D === void 0 ? {} : { userData: D },
|
|
207
208
|
...O === void 0 ? {} : { onCollisionEnter: O },
|
|
208
|
-
...
|
|
209
|
-
...
|
|
209
|
+
...G === void 0 ? {} : { wheelConfig: G },
|
|
210
|
+
...K === void 0 ? {} : { propellerConfig: K },
|
|
210
211
|
...j === void 0 ? {} : { carConfig: j },
|
|
211
|
-
...
|
|
212
|
+
...q === void 0 ? {} : { droneConfig: q },
|
|
212
213
|
children: [/* @__PURE__ */ y(a, {
|
|
213
|
-
emitters:
|
|
214
|
-
signalsRef:
|
|
215
|
-
}),
|
|
214
|
+
emitters: V.emitters,
|
|
215
|
+
signalsRef: X
|
|
216
|
+
}), he]
|
|
216
217
|
})
|
|
217
218
|
});
|
|
218
219
|
}
|
|
@@ -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 };
|