@pinkaphant/kolmo 0.2.3 → 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import { type Trait, type TraitRecord, type World } from "koota";
|
|
3
3
|
import type { EcctrlHandle } from "@pinkaphant/ecctrl";
|
|
4
|
+
import type { EcctrlCameraControlsHandle } from "@pinkaphant/ecctrl/camera";
|
|
4
5
|
import type { EcctrlVehicleHandle } from "@pinkaphant/ecctrl/vehicle";
|
|
5
6
|
import { type RetroPresetId } from "../shaders/retroShader.js";
|
|
6
7
|
export type KolmoControlMode = "foot" | "car" | "flight";
|
|
@@ -18,9 +19,12 @@ export interface ActorTraitData {
|
|
|
18
19
|
handle: EcctrlHandle | null;
|
|
19
20
|
exitSpawnPos: [number, number, number] | null;
|
|
20
21
|
exitSpawnYaw: number;
|
|
22
|
+
exitSpawnRot?: [number, number, number] | null;
|
|
21
23
|
exitLinVel: [number, number, number] | null;
|
|
22
24
|
onOriginShift?: (dx: number, dz: number) => void;
|
|
23
25
|
}
|
|
26
|
+
export declare const setWorldCameraControls: (w: World, ctrl: EcctrlCameraControlsHandle | null) => void;
|
|
27
|
+
export declare const getWorldCameraControls: (w: World) => EcctrlCameraControlsHandle | null;
|
|
24
28
|
export declare const VehicleTrait: Trait<() => VehicleTraitData>;
|
|
25
29
|
export declare const ActorTrait: Trait<() => ActorTraitData>;
|
|
26
30
|
export declare const InteractableTrait: Trait<{
|
|
@@ -73,12 +77,9 @@ export declare const WorldSessionTrait: Trait<{
|
|
|
73
77
|
export declare const kolmoWorld: World;
|
|
74
78
|
export declare function useActiveKolmoWorld(): World;
|
|
75
79
|
export declare function ensureWorldSession(w: World): void;
|
|
76
|
-
/**
|
|
77
|
-
* Subscribes to a world-level Koota trait directly on `world` without calling `useWorld()`,
|
|
78
|
-
* so `<KolmoWorld world={null}>` and standalone `<KolmoPhysics>` never throw without `<WorldProvider>`.
|
|
79
|
-
*/
|
|
80
|
+
/** Subscribes to a world-level Koota trait without requiring `<WorldProvider>`. */
|
|
80
81
|
export declare function useWorldTrait<T extends Trait>(world: World | null | undefined, t: T): TraitRecord<T> | undefined;
|
|
81
|
-
export declare function readFloatingOriginAnchorXZ(world: World, camera: THREE.Camera | null): [number, number];
|
|
82
|
+
export declare function readFloatingOriginAnchorXZ(world: World, camera: THREE.Camera | null, out?: [number, number]): [number, number];
|
|
82
83
|
export declare function shiftFloatingOriginEntities(world: World, camera: THREE.Camera | null, dx: number, dz: number, rapier?: FloatingOriginRapierSync | null): void;
|
|
83
84
|
export interface KolmoTelemetryState {
|
|
84
85
|
speedKmh: number;
|
|
@@ -4,7 +4,34 @@ import * as i from "three";
|
|
|
4
4
|
import { useWorld as a } from "koota/react";
|
|
5
5
|
import { createActions as o, createWorld as s, relation as c, trait as l } from "koota";
|
|
6
6
|
// src/engine/kolmoStore.ts
|
|
7
|
-
var u =
|
|
7
|
+
var u = /* @__PURE__ */ new WeakMap(), d = (e, t) => {
|
|
8
|
+
u.set(e, t);
|
|
9
|
+
}, f = (e) => u.get(e) ?? null, p = Object.freeze({
|
|
10
|
+
forward: !1,
|
|
11
|
+
backward: !1,
|
|
12
|
+
steerLeft: !1,
|
|
13
|
+
steerRight: !1,
|
|
14
|
+
brake: !1,
|
|
15
|
+
throttleUp: !1,
|
|
16
|
+
throttleDown: !1,
|
|
17
|
+
yawLeft: !1,
|
|
18
|
+
yawRight: !1,
|
|
19
|
+
pitchForward: !1,
|
|
20
|
+
pitchBackward: !1,
|
|
21
|
+
rollLeft: !1,
|
|
22
|
+
rollRight: !1,
|
|
23
|
+
joystickL: Object.freeze({
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0
|
|
26
|
+
}),
|
|
27
|
+
joystickR: Object.freeze({
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0
|
|
30
|
+
})
|
|
31
|
+
}), m = Object.freeze({
|
|
32
|
+
...p,
|
|
33
|
+
brake: !0
|
|
34
|
+
}), h = l(() => ({
|
|
8
35
|
id: "",
|
|
9
36
|
handle: null,
|
|
10
37
|
centerOfMass: [
|
|
@@ -23,72 +50,73 @@ var u = l(() => ({
|
|
|
23
50
|
0
|
|
24
51
|
],
|
|
25
52
|
isFlight: !1
|
|
26
|
-
})),
|
|
53
|
+
})), g = l(() => ({
|
|
27
54
|
id: "pilot",
|
|
28
55
|
handle: null,
|
|
29
56
|
exitSpawnPos: null,
|
|
30
57
|
exitSpawnYaw: 0,
|
|
58
|
+
exitSpawnRot: null,
|
|
31
59
|
exitLinVel: null
|
|
32
|
-
})),
|
|
60
|
+
})), _ = l({
|
|
33
61
|
id: "",
|
|
34
62
|
radius: 4,
|
|
35
63
|
kind: "vehicle"
|
|
36
|
-
}),
|
|
64
|
+
}), v = l(() => ({
|
|
37
65
|
id: "",
|
|
38
66
|
getBody: () => null
|
|
39
|
-
})),
|
|
67
|
+
})), y = c({ exclusive: !0 }), b = l({
|
|
40
68
|
activeVehicleId: "",
|
|
41
69
|
activeRetroPreset: "dreamcast"
|
|
42
|
-
}),
|
|
43
|
-
function
|
|
70
|
+
}), x = s(b);
|
|
71
|
+
function S() {
|
|
44
72
|
try {
|
|
45
73
|
return a();
|
|
46
74
|
} catch {
|
|
47
|
-
return
|
|
75
|
+
return x;
|
|
48
76
|
}
|
|
49
77
|
}
|
|
50
|
-
function
|
|
51
|
-
e.has(
|
|
78
|
+
function C(e) {
|
|
79
|
+
e.has(b) || e.add(b);
|
|
52
80
|
}
|
|
53
|
-
function
|
|
81
|
+
function w(e, i) {
|
|
54
82
|
let [, a] = n((e) => e + 1, 0), o = r(e && e.has(i) ? e.get(i) : void 0);
|
|
55
83
|
return o.current = e && e.has(i) ? e.get(i) : void 0, t(() => {
|
|
56
84
|
if (!e) return;
|
|
57
85
|
let t = () => {
|
|
58
86
|
o.current = e.has(i) ? e.get(i) : void 0, a();
|
|
59
|
-
}, n = e.onAdd(i,
|
|
87
|
+
}, n = e.onAdd(i, t), r = e.onChange(i, t), s = e.onRemove(i, t);
|
|
60
88
|
return (e.has(i) ? e.get(i) : void 0) !== o.current && t(), () => {
|
|
61
89
|
n(), r(), s();
|
|
62
90
|
};
|
|
63
91
|
}, [e, i]), o.current;
|
|
64
92
|
}
|
|
65
|
-
function
|
|
66
|
-
let n = e.has(
|
|
67
|
-
if (
|
|
68
|
-
let e = t.get(
|
|
69
|
-
if (e?.id ===
|
|
93
|
+
function T(e, t, n) {
|
|
94
|
+
let r = (e, t) => n ? (n[0] = e, n[1] = t, n) : [e, t], i = e.has(b) ? e.get(b)?.activeVehicleId : "";
|
|
95
|
+
if (i) for (let t of e.query(h)) {
|
|
96
|
+
let e = t.get(h);
|
|
97
|
+
if (e?.id === i && e.handle?.body) {
|
|
70
98
|
let t = e.handle.body.translation();
|
|
71
|
-
return
|
|
99
|
+
return r(t.x, t.z);
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
|
-
for (let t of e.query(
|
|
75
|
-
let e = t.get(
|
|
102
|
+
for (let t of e.query(g)) {
|
|
103
|
+
let e = t.get(g)?.handle?.body;
|
|
76
104
|
if (e) {
|
|
77
105
|
let t = e.translation();
|
|
78
|
-
return
|
|
106
|
+
return r(t.x, t.z);
|
|
79
107
|
}
|
|
80
108
|
}
|
|
81
|
-
for (let t of e.query(
|
|
82
|
-
let e = t.get(
|
|
109
|
+
for (let t of e.query(h)) {
|
|
110
|
+
let e = t.get(h)?.handle?.body;
|
|
83
111
|
if (e) {
|
|
84
112
|
let t = e.translation();
|
|
85
|
-
return
|
|
113
|
+
return r(t.x, t.z);
|
|
86
114
|
}
|
|
87
115
|
}
|
|
88
|
-
return
|
|
116
|
+
return r(t?.position.x ?? 0, t?.position.z ?? 0);
|
|
89
117
|
}
|
|
90
|
-
var
|
|
91
|
-
function
|
|
118
|
+
var E = new i.Vector3(), D = new i.Quaternion(), O = new i.Matrix4(), k = new i.Vector3(), A = new i.Quaternion(), j = new i.Vector3();
|
|
119
|
+
function M(e, t, n, r) {
|
|
92
120
|
let i = e.translation(), a = i.x - t, o = i.z - n;
|
|
93
121
|
if (e.setTranslation({
|
|
94
122
|
x: a,
|
|
@@ -98,17 +126,17 @@ function D(e, t, n, r) {
|
|
|
98
126
|
let s = r.rigidBodyStates.get(e.handle);
|
|
99
127
|
if (!s || s.meshType === "instancedMesh") return;
|
|
100
128
|
let c = typeof e.rotation == "function" ? e.rotation() : null;
|
|
101
|
-
|
|
129
|
+
E.set(a, i.y, o), c ? D.set(c.x, c.y, c.z, c.w) : D.identity(), O.compose(E, D, s.scale).premultiply(s.invertedWorldMatrix).decompose(k, A, j), s.object.position.copy(k), c && s.object.quaternion.copy(A), s.object.updateMatrixWorld(!0);
|
|
102
130
|
}
|
|
103
|
-
function
|
|
131
|
+
function N(e, t, n, r, i) {
|
|
104
132
|
t && (t.position.x -= n, t.position.z -= r);
|
|
105
|
-
for (let t of e.query(
|
|
106
|
-
let e = t.get(
|
|
107
|
-
a &&
|
|
133
|
+
for (let t of e.query(h)) {
|
|
134
|
+
let e = t.get(h), a = e?.handle?.body;
|
|
135
|
+
a && M(a, n, r, i), e?.onOriginShift?.(n, r);
|
|
108
136
|
}
|
|
109
|
-
for (let t of e.query(
|
|
110
|
-
let e = t.get(
|
|
111
|
-
a &&
|
|
137
|
+
for (let t of e.query(g)) {
|
|
138
|
+
let e = t.get(g), a = e?.handle?.body;
|
|
139
|
+
a && M(a, n, r, i), e?.exitSpawnPos && t.set(g, {
|
|
112
140
|
...e,
|
|
113
141
|
exitSpawnPos: [
|
|
114
142
|
e.exitSpawnPos[0] - n,
|
|
@@ -117,9 +145,9 @@ function O(e, t, n, r, i) {
|
|
|
117
145
|
]
|
|
118
146
|
}), e?.onOriginShift?.(n, r);
|
|
119
147
|
}
|
|
120
|
-
for (let t of e.query(
|
|
121
|
-
let e = t.get(
|
|
122
|
-
e &&
|
|
148
|
+
for (let t of e.query(v)) {
|
|
149
|
+
let e = t.get(v)?.getBody();
|
|
150
|
+
e && M(e, n, r, i);
|
|
123
151
|
}
|
|
124
152
|
if (i?.world) {
|
|
125
153
|
let e = i.world;
|
|
@@ -128,7 +156,7 @@ function O(e, t, n, r, i) {
|
|
|
128
156
|
e.timestep = 0, e.step(), e.timestep = t;
|
|
129
157
|
}
|
|
130
158
|
}
|
|
131
|
-
var
|
|
159
|
+
var P = {
|
|
132
160
|
speedKmh: 0,
|
|
133
161
|
rpm: 0,
|
|
134
162
|
gear: 1,
|
|
@@ -138,59 +166,67 @@ var k = {
|
|
|
138
166
|
activeVehicleId: null,
|
|
139
167
|
activeRetroPreset: "dreamcast",
|
|
140
168
|
nearVehicleId: null
|
|
141
|
-
},
|
|
169
|
+
}, F = new i.Vector3(), I = new i.Vector3(), L = new i.Vector3(), R = new i.Vector3(), z = new i.Matrix4(), B = new i.Euler();
|
|
170
|
+
function V(e) {
|
|
171
|
+
e.handle && e.handle.setMovement(e.handle.wheelsInfo.size > 0 && !e.isFlight ? m : p);
|
|
172
|
+
}
|
|
173
|
+
var H = o((t) => ({
|
|
142
174
|
boardVehicle: (e) => {
|
|
143
|
-
|
|
144
|
-
let n = t.queryFirst(
|
|
145
|
-
for (let
|
|
146
|
-
|
|
147
|
-
|
|
175
|
+
C(t);
|
|
176
|
+
let n = t.get(b), r = n?.activeVehicleId || "", i = t.queryFirst(g);
|
|
177
|
+
for (let n of t.query(h)) {
|
|
178
|
+
let t = n.get(h);
|
|
179
|
+
t && (r && r !== e && t.id === r && V(t), t.id === e && i && i.add(y(n)));
|
|
148
180
|
}
|
|
149
|
-
|
|
150
|
-
t.set(h, {
|
|
181
|
+
t.set(b, {
|
|
151
182
|
activeVehicleId: e,
|
|
152
|
-
activeRetroPreset:
|
|
153
|
-
}),
|
|
183
|
+
activeRetroPreset: n?.activeRetroPreset ?? "dreamcast"
|
|
184
|
+
}), P.activeVehicleId = e, P.nearVehicleId = null;
|
|
154
185
|
},
|
|
155
186
|
exitVehicle: () => {
|
|
156
|
-
|
|
157
|
-
let e = t.get(
|
|
158
|
-
for (let e of t.query(
|
|
159
|
-
let t = e.get(
|
|
187
|
+
C(t);
|
|
188
|
+
let e = t.get(b), n = e?.activeVehicleId || "", r = t.queryFirst(g);
|
|
189
|
+
for (let e of t.query(h)) {
|
|
190
|
+
let t = e.get(h);
|
|
160
191
|
if (t && n && t.id === n) {
|
|
161
|
-
if (r && (r.has(
|
|
162
|
-
|
|
163
|
-
let e =
|
|
164
|
-
|
|
165
|
-
|
|
192
|
+
if (r && (r.has(y(e)) && r.remove(y(e)), t.handle)) {
|
|
193
|
+
F.set(t.exitOffset[0] - t.centerOfMass[0], t.exitOffset[1] - t.centerOfMass[1], t.exitOffset[2] - t.centerOfMass[2]).applyQuaternion(t.handle.currQuat).add(t.handle.currPos), I.copy(t.handle.upAxis), I.lengthSq() < 1e-6 ? I.set(0, 1, 0) : I.normalize(), L.copy(t.handle.bodyZAxis).projectOnPlane(I);
|
|
194
|
+
let e = 0, n = [
|
|
195
|
+
0,
|
|
196
|
+
0,
|
|
197
|
+
0
|
|
198
|
+
];
|
|
199
|
+
L.lengthSq() > 1e-6 && (L.normalize(), e = Math.atan2(L.x, L.z), R.crossVectors(I, L).normalize(), z.makeBasis(R, I, L), B.setFromRotationMatrix(z, "YXZ"), n = [
|
|
200
|
+
B.x,
|
|
201
|
+
B.y,
|
|
202
|
+
B.z
|
|
203
|
+
]);
|
|
204
|
+
let i = t.handle.currLinVel, a = r.get(g);
|
|
205
|
+
r.set(g, {
|
|
206
|
+
id: a?.id ?? "pilot",
|
|
166
207
|
handle: null,
|
|
167
208
|
exitSpawnPos: [
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
209
|
+
F.x,
|
|
210
|
+
F.y,
|
|
211
|
+
F.z
|
|
171
212
|
],
|
|
172
213
|
exitSpawnYaw: e,
|
|
214
|
+
exitSpawnRot: n,
|
|
173
215
|
exitLinVel: [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
i.x,
|
|
217
|
+
i.y,
|
|
218
|
+
i.z
|
|
177
219
|
],
|
|
178
|
-
onOriginShift:
|
|
220
|
+
onOriginShift: a?.onOriginShift
|
|
179
221
|
});
|
|
180
222
|
}
|
|
181
|
-
t
|
|
182
|
-
forward: !1,
|
|
183
|
-
backward: !1,
|
|
184
|
-
steerLeft: !1,
|
|
185
|
-
steerRight: !1,
|
|
186
|
-
brake: !t.isFlight
|
|
187
|
-
});
|
|
223
|
+
V(t);
|
|
188
224
|
}
|
|
189
225
|
}
|
|
190
|
-
t.set(
|
|
226
|
+
t.set(b, {
|
|
191
227
|
activeVehicleId: "",
|
|
192
228
|
activeRetroPreset: e?.activeRetroPreset ?? "dreamcast"
|
|
193
|
-
}), Object.assign(
|
|
229
|
+
}), Object.assign(P, {
|
|
194
230
|
activeVehicleId: null,
|
|
195
231
|
mode: "foot",
|
|
196
232
|
speedKmh: 0,
|
|
@@ -200,12 +236,12 @@ var k = {
|
|
|
200
236
|
});
|
|
201
237
|
},
|
|
202
238
|
setRetroPreset: (n) => {
|
|
203
|
-
|
|
204
|
-
let r = t.get(
|
|
205
|
-
t.set(
|
|
239
|
+
C(t), e(n);
|
|
240
|
+
let r = t.get(b);
|
|
241
|
+
t.set(b, {
|
|
206
242
|
activeVehicleId: r?.activeVehicleId ?? "",
|
|
207
243
|
activeRetroPreset: n
|
|
208
|
-
}),
|
|
244
|
+
}), P.activeRetroPreset = n;
|
|
209
245
|
}
|
|
210
246
|
}));
|
|
211
|
-
export {
|
|
247
|
+
export { g as ActorTrait, v as FloatingBodyTrait, _ as InteractableTrait, y as PilotLink, h as VehicleTrait, b as WorldSessionTrait, C as ensureWorldSession, f as getWorldCameraControls, H as kolmoActions, P as kolmoTelemetry, x as kolmoWorld, T as readFloatingOriginAnchorXZ, d as setWorldCameraControls, N as shiftFloatingOriginEntities, S as useActiveKolmoWorld, w as useWorldTrait };
|
|
@@ -23,7 +23,7 @@ export interface KolmoVehicleProps {
|
|
|
23
23
|
onCollisionEnter?: (payload: CollisionEnterPayload) => void;
|
|
24
24
|
wheelConfig?: KhrVehicleProps["wheelConfig"];
|
|
25
25
|
propellerConfig?: KhrVehicleProps["propellerConfig"];
|
|
26
|
-
carConfig?:
|
|
26
|
+
carConfig?: KhrVehicleProps["carConfig"];
|
|
27
27
|
droneConfig?: Partial<DroneConfigType>;
|
|
28
28
|
vehicleRef?: React.RefObject<EcctrlVehicleHandle | null>;
|
|
29
29
|
getInput?: KolmoInputGetter;
|