@pinkaphant/kolmo 0.1.2 → 0.2.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/LICENSE +21 -0
- package/README.md +16 -14
- package/bin/kolmo.mjs +22 -54
- package/dist/body/HeldItem.js +171 -0
- package/dist/body/KhrBody.js +171 -0
- package/dist/body/bodySi.d.ts +0 -11
- package/dist/body/bodySi.js +52 -0
- package/dist/body/index.d.ts +1 -1
- package/dist/body/index.js +4 -1
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +12 -3
- package/dist/engine/kolmoActor.d.ts +11 -4
- package/dist/engine/kolmoActor.js +197 -0
- package/dist/engine/kolmoInput.d.ts +17 -0
- package/dist/engine/kolmoInput.js +78 -0
- package/dist/engine/kolmoIsland.d.ts +3 -1
- package/dist/engine/kolmoIsland.js +311 -0
- package/dist/engine/kolmoLongDrive.js +223 -0
- package/dist/engine/kolmoRigs.js +59 -0
- package/dist/engine/kolmoStore.d.ts +53 -27
- package/dist/engine/kolmoStore.js +211 -0
- package/dist/engine/kolmoSurface.d.ts +1 -1
- package/dist/engine/kolmoSurface.js +182 -0
- package/dist/engine/kolmoVehicle.d.ts +3 -1
- package/dist/engine/kolmoVehicle.js +250 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
- package/dist/engine/kolmoVehicleDriver.js +29 -0
- package/dist/engine/kolmoWorld.d.ts +7 -15
- package/dist/engine/kolmoWorld.js +139 -0
- package/dist/engine/longDriveKit.d.ts +4 -2
- package/dist/engine/longDriveKit.js +254 -0
- package/dist/engine/mainlandMacroCell.d.ts +3 -7
- package/dist/engine/mainlandMacroCell.js +247 -0
- package/dist/engine/shiftedFixedBody.d.ts +13 -0
- package/dist/engine/shiftedFixedBody.js +64 -0
- package/dist/importer/ChopShopPanel.js +465 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
- package/dist/importer/DomainWorkshopPanel.js +385 -0
- package/dist/importer/GateHudBar.js +312 -0
- package/dist/importer/GlbImportGate.js +250 -0
- package/dist/importer/ImperativeVehicleRig.js +336 -0
- package/dist/importer/ImporterPlinthUikitTags.js +112 -0
- package/dist/importer/Step1CalibrationPlinth.js +275 -0
- package/dist/importer/Step2UniversalPad.js +244 -0
- package/dist/importer/VfxEmitterPool.js +91 -0
- package/dist/importer/chopShopActions.d.ts +22 -2
- package/dist/importer/chopShopActions.js +232 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +92 -0
- package/dist/importer/glbNormalizer.js +133 -0
- package/dist/importer/importerWebMcp.d.ts +17 -6
- package/dist/importer/importerWebMcp.js +343 -0
- package/dist/importer/index.js +22 -3
- package/dist/importer/khrCompiler.d.ts +1 -1
- package/dist/importer/khrCompiler.js +434 -0
- package/dist/importer/launcherBake.js +51 -0
- package/dist/importer/meshIslands.d.ts +1 -1
- package/dist/importer/meshIslands.js +301 -0
- package/dist/importer/surfaceCutter.js +254 -0
- package/dist/importer/surfaceTopology.js +183 -0
- package/dist/importer/universalGateBake.js +162 -0
- package/dist/importer/usdToGlb.js +294 -0
- package/dist/importer/useChopShopController.d.ts +11 -2
- package/dist/importer/useChopShopController.js +364 -0
- package/dist/importer/vehiclePanelAnim.js +214 -0
- package/dist/importer/wheelAxlePairing.d.ts +1 -2
- package/dist/importer/wheelAxlePairing.js +102 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -13
- package/dist/junk/DestructibleTarget.js +154 -0
- package/dist/junk/KolmoJunk.js +65 -0
- package/dist/junk/ShardPieces.d.ts +6 -4
- package/dist/junk/ShardPieces.js +74 -0
- package/dist/junk/TargetDecals.js +51 -0
- package/dist/junk/bvhShatter.js +55 -0
- package/dist/junk/bvhTriCollector.js +78 -0
- package/dist/junk/index.js +11 -1
- package/dist/junk/junkGeometry.js +69 -0
- package/dist/junk/junkImportSanitize.js +54 -0
- package/dist/junk/junkImporter.js +95 -0
- package/dist/junk/junkLabelCanvas.js +67 -0
- package/dist/junk/junkLabels.js +35 -0
- package/dist/junk/targetHelpers.js +103 -0
- package/dist/junk/targetHitLogic.js +128 -0
- package/dist/junk/useTargetAssets.js +102 -0
- package/dist/physics/index.d.ts +26 -0
- package/dist/physics/index.js +84 -0
- package/dist/schema/kolmoSchema.d.ts +2 -1
- package/dist/schema/kolmoSchema.js +184 -0
- package/dist/shaders/celestialBackdrop.d.ts +1 -1
- package/dist/shaders/celestialBackdrop.js +344 -0
- package/dist/shaders/index.d.ts +0 -1
- package/dist/shaders/index.js +9 -1
- package/dist/shaders/plumeAndSparkle.js +271 -0
- package/dist/shaders/ps2GlslShared.d.ts +1 -1
- package/dist/shaders/ps2GlslShared.js +3 -0
- package/dist/shaders/ps2MaterialsTSL.js +65 -0
- package/dist/shaders/ps2MaterialsWebGL.js +40 -0
- package/dist/shaders/ps2RoadWebGL.js +101 -0
- package/dist/shaders/ps2TerrainWebGL.js +54 -0
- package/dist/shaders/ps2Textures.js +224 -0
- package/dist/shaders/retroPalettes.js +188 -0
- package/dist/shaders/retroShader.d.ts +31 -3
- package/dist/shaders/retroShader.js +249 -0
- package/dist/shaders/tsl.d.ts +1 -0
- package/dist/shaders/tsl.js +1 -0
- package/dist/vite/index.d.ts +15 -0
- package/dist/vite/index.js +90 -0
- package/dist/world/frontage.js +32 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +11 -3
- package/dist/world/infiniteWorld2D.js +244 -0
- package/dist/world/island.js +201 -0
- package/dist/world/macroCellSchema.js +27 -0
- package/dist/world/macroKnightAStar.js +171 -0
- package/dist/world/random.js +33 -0
- package/dist/world/road.js +136 -0
- package/dist/world/roadRibbon.d.ts +6 -6
- package/dist/world/roadRibbon.js +161 -0
- package/dist/world/terrain.js +87 -0
- package/dist/world/worldTypes.js +111 -0
- package/package.json +32 -18
- package/dist/body-B7FTf67o.js +0 -362
- package/dist/engine-BeKvBM8d.js +0 -1745
- package/dist/importer-B2-S-N_e.js +0 -5113
- package/dist/junk-B4bC1zAl.js +0 -1049
- package/dist/kolmoSurface-DTnrFXH0.js +0 -558
- package/dist/shaders-GS71Ek1A.js +0 -1383
- package/dist/world-PRWPYrlx.js +0 -947
- package/dist/worldTypes-Z0KfdCd0.js +0 -226
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { applyRetroMaterial as e, applySceneRetroMaterials as t } from "../shaders/retroShader.js";
|
|
2
|
+
import { ShiftedFixedBody as n } from "./shiftedFixedBody.js";
|
|
3
|
+
import { useCallback as r, useEffect as i, useLayoutEffect as a, useMemo as o, useRef as s } from "react";
|
|
4
|
+
import * as c from "three";
|
|
5
|
+
import { KhrAssembly as l, cloneKhrBundle as u, useKhrGlb as d } from "@khr3/core";
|
|
6
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
7
|
+
import { CuboidCollider as m } from "@react-three/rapier";
|
|
8
|
+
// src/engine/kolmoSurface.tsx
|
|
9
|
+
function h(e) {
|
|
10
|
+
let t = /* @__PURE__ */ new Uint8Array(16384);
|
|
11
|
+
for (let e = 0; e < 64; e++) for (let n = 0; n < 64; n++) {
|
|
12
|
+
let r = (e * 64 + n) * 4;
|
|
13
|
+
if (n === 0 || e === 0) t[r] = 56, t[r + 1] = 178, t[r + 2] = 216;
|
|
14
|
+
else if (n === 32 || e === 32) t[r] = 44, t[r + 1] = 58, t[r + 2] = 78;
|
|
15
|
+
else {
|
|
16
|
+
let i = (n >> 4) + (e >> 4) & 1 ? 30 : 35;
|
|
17
|
+
t[r] = i, t[r + 1] = i + 3, t[r + 2] = i + 9;
|
|
18
|
+
}
|
|
19
|
+
t[r + 3] = 255;
|
|
20
|
+
}
|
|
21
|
+
let n = new c.DataTexture(t, 64, 64, c.RGBAFormat);
|
|
22
|
+
return n.colorSpace = c.SRGBColorSpace, n.wrapS = c.RepeatWrapping, n.wrapT = c.RepeatWrapping, n.magFilter = c.NearestFilter, n.minFilter = c.NearestFilter, n.repeat.set(e, e), n.needsUpdate = !0, n;
|
|
23
|
+
}
|
|
24
|
+
function g({ size: t, position: r }) {
|
|
25
|
+
let a = o(() => {
|
|
26
|
+
let n = h(Math.max(4, Math.round(t / 8)));
|
|
27
|
+
return {
|
|
28
|
+
tex: n,
|
|
29
|
+
geo: new c.BoxGeometry(t, 1, t),
|
|
30
|
+
mat: e(new c.MeshStandardMaterial({
|
|
31
|
+
map: n,
|
|
32
|
+
roughness: .92,
|
|
33
|
+
metalness: .06
|
|
34
|
+
}), { flatShading: !1 })
|
|
35
|
+
};
|
|
36
|
+
}, [t]);
|
|
37
|
+
return i(() => () => {
|
|
38
|
+
a.geo.dispose(), a.mat.dispose(), a.tex.dispose();
|
|
39
|
+
}, [a]), /* @__PURE__ */ p(n, {
|
|
40
|
+
x: r[0],
|
|
41
|
+
y: r[1] - .5,
|
|
42
|
+
z: r[2],
|
|
43
|
+
friction: .95,
|
|
44
|
+
children: [/* @__PURE__ */ f(m, {
|
|
45
|
+
args: [
|
|
46
|
+
t * .5,
|
|
47
|
+
.5,
|
|
48
|
+
t * .5
|
|
49
|
+
],
|
|
50
|
+
restitution: .04
|
|
51
|
+
}), /* @__PURE__ */ f("mesh", {
|
|
52
|
+
name: "KolmoArenaSlab",
|
|
53
|
+
geometry: a.geo,
|
|
54
|
+
material: a.mat,
|
|
55
|
+
receiveShadow: !0
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function _(e, n) {
|
|
60
|
+
let r = u(e), i = [];
|
|
61
|
+
return ((e) => {
|
|
62
|
+
e.traverse((e) => {
|
|
63
|
+
let t = e;
|
|
64
|
+
if (t.material) {
|
|
65
|
+
if (Array.isArray(t.material)) t.material = t.material.map((e) => {
|
|
66
|
+
let t = e.clone();
|
|
67
|
+
return i.push(t), t;
|
|
68
|
+
});
|
|
69
|
+
else {
|
|
70
|
+
let e = t.material.clone();
|
|
71
|
+
i.push(e), t.material = e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
})(r.scene), t(r.scene, n === void 0 ? void 0 : { flatShading: n }), {
|
|
76
|
+
cloned: r,
|
|
77
|
+
disposeMats: () => {
|
|
78
|
+
for (let e of i) e.dispose();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function v({ bundle: e, position: t }) {
|
|
83
|
+
let { cloned: n, disposeMats: r } = o(() => _(e, !1), [e]);
|
|
84
|
+
return a(() => () => r(), [r]), /* @__PURE__ */ f(l, {
|
|
85
|
+
bundle: n,
|
|
86
|
+
position: t,
|
|
87
|
+
fixedRoot: !0
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function y({ src: e, position: t }) {
|
|
91
|
+
return /* @__PURE__ */ f(v, {
|
|
92
|
+
bundle: d(e),
|
|
93
|
+
position: t
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function b({ src: e, bundle: t, size: n = 200, position: r = [
|
|
97
|
+
0,
|
|
98
|
+
0,
|
|
99
|
+
0
|
|
100
|
+
] }) {
|
|
101
|
+
return t ? /* @__PURE__ */ f(v, {
|
|
102
|
+
bundle: t,
|
|
103
|
+
position: r
|
|
104
|
+
}) : e ? /* @__PURE__ */ f(y, {
|
|
105
|
+
src: e,
|
|
106
|
+
position: r
|
|
107
|
+
}) : /* @__PURE__ */ f(g, {
|
|
108
|
+
size: n,
|
|
109
|
+
position: r
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function x(e) {
|
|
113
|
+
if (!e) return {
|
|
114
|
+
open: 1.35,
|
|
115
|
+
closed: 0
|
|
116
|
+
};
|
|
117
|
+
let [t, n] = e;
|
|
118
|
+
return {
|
|
119
|
+
open: Math.abs(n) >= Math.abs(t) ? n : t,
|
|
120
|
+
closed: Math.min(n, Math.max(t, 0))
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function S(e, t, n, r, i) {
|
|
124
|
+
if (!e) return n;
|
|
125
|
+
if (r && i) {
|
|
126
|
+
let n = r;
|
|
127
|
+
for (; n;) {
|
|
128
|
+
let r = t.bodies.find((e) => e.object === n && e.joint?.drive?.stiffness !== void 0);
|
|
129
|
+
if (r) {
|
|
130
|
+
let t = !(i.get(r.nodeName) ?? !1);
|
|
131
|
+
i.set(r.nodeName, t);
|
|
132
|
+
let { open: n, closed: a } = x(r.joint?.limits);
|
|
133
|
+
return e.setJointTarget(r.nodeName, t ? n : a), t;
|
|
134
|
+
}
|
|
135
|
+
n = n.parent;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let a = !n;
|
|
139
|
+
for (let n of t.bodies) {
|
|
140
|
+
if (!n.joint?.drive || n.joint.drive.stiffness === void 0) continue;
|
|
141
|
+
let { open: t, closed: r } = x(n.joint.limits);
|
|
142
|
+
i?.set(n.nodeName, a), e.setJointTarget(n.nodeName, a ? t : r);
|
|
143
|
+
}
|
|
144
|
+
return a;
|
|
145
|
+
}
|
|
146
|
+
function C({ bundle: e, position: t, fixed: n }) {
|
|
147
|
+
let i = s(null), c = s(!1), u = s(/* @__PURE__ */ new Map()), { cloned: d, disposeMats: p } = o(() => _(e), [e]);
|
|
148
|
+
a(() => () => p(), [p]);
|
|
149
|
+
let m = r((e) => {
|
|
150
|
+
e?.stopPropagation?.(), c.current = S(i.current, d, c.current, e?.object ?? null, u.current);
|
|
151
|
+
}, [d]);
|
|
152
|
+
return /* @__PURE__ */ f(l, {
|
|
153
|
+
ref: i,
|
|
154
|
+
bundle: d,
|
|
155
|
+
position: t,
|
|
156
|
+
fixedRoot: n,
|
|
157
|
+
onClick: m
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function w({ src: e, position: t, fixed: n }) {
|
|
161
|
+
return /* @__PURE__ */ f(C, {
|
|
162
|
+
bundle: d(e),
|
|
163
|
+
position: t,
|
|
164
|
+
fixed: n
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function T({ src: e, bundle: t, position: n = [
|
|
168
|
+
0,
|
|
169
|
+
0,
|
|
170
|
+
0
|
|
171
|
+
], fixed: r = !1 }) {
|
|
172
|
+
return t ? /* @__PURE__ */ f(C, {
|
|
173
|
+
bundle: t,
|
|
174
|
+
position: n,
|
|
175
|
+
fixed: r
|
|
176
|
+
}) : e ? /* @__PURE__ */ f(w, {
|
|
177
|
+
src: e,
|
|
178
|
+
position: n,
|
|
179
|
+
fixed: r
|
|
180
|
+
}) : null;
|
|
181
|
+
}
|
|
182
|
+
export { T as KolmoProp, b as KolmoSurface, S as togglePropJoint };
|
|
@@ -4,6 +4,7 @@ import type { CollisionEnterPayload } from "@react-three/rapier";
|
|
|
4
4
|
import { type KhrAssetBundle } from "@khr3/core";
|
|
5
5
|
import { type KhrVehicleProps } from "@khr3/core/vehicle";
|
|
6
6
|
import type { DroneConfigType, EcctrlVehicleHandle } from "@pinkaphant/ecctrl/vehicle";
|
|
7
|
+
import { type KolmoInputGetter } from "./kolmoInput.js";
|
|
7
8
|
export interface KolmoVehicleProps {
|
|
8
9
|
id: string;
|
|
9
10
|
src?: string;
|
|
@@ -14,7 +15,6 @@ export interface KolmoVehicleProps {
|
|
|
14
15
|
piloted?: boolean;
|
|
15
16
|
flightMode?: boolean;
|
|
16
17
|
vehicleMode?: "drive" | "rocket";
|
|
17
|
-
twoWheel?: boolean;
|
|
18
18
|
enable?: boolean;
|
|
19
19
|
ccd?: boolean;
|
|
20
20
|
linearDamping?: number;
|
|
@@ -22,9 +22,11 @@ export interface KolmoVehicleProps {
|
|
|
22
22
|
userData?: Record<string, unknown>;
|
|
23
23
|
onCollisionEnter?: (payload: CollisionEnterPayload) => void;
|
|
24
24
|
wheelConfig?: KhrVehicleProps["wheelConfig"];
|
|
25
|
+
propellerConfig?: KhrVehicleProps["propellerConfig"];
|
|
25
26
|
carConfig?: Record<string, unknown>;
|
|
26
27
|
droneConfig?: Partial<DroneConfigType>;
|
|
27
28
|
vehicleRef?: React.RefObject<EcctrlVehicleHandle | null>;
|
|
29
|
+
getInput?: KolmoInputGetter;
|
|
28
30
|
driver?: (veh: EcctrlVehicleHandle, dt: number, state: RootState) => void;
|
|
29
31
|
cameraController?: (veh: EcctrlVehicleHandle, dt: number, state: RootState) => void;
|
|
30
32
|
children?: ReactNode;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { KolmoGravityContext as e } from "../physics/index.js";
|
|
2
|
+
import { KOLMO_EXTENSION_NAME as t, createDefaultSignals as n, decodeKolmoRig as r } from "../schema/kolmoSchema.js";
|
|
3
|
+
import { createVehiclePanelAnimator as i } from "../importer/vehiclePanelAnim.js";
|
|
4
|
+
import { KolmoEmitterRig as a } from "../shaders/plumeAndSparkle.js";
|
|
5
|
+
import { applySceneRetroMaterials as o } from "../shaders/retroShader.js";
|
|
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 ie } from "./kolmoStore.js";
|
|
8
|
+
import { stepKolmoVehicleFrame as ae } from "./kolmoVehicleDriver.js";
|
|
9
|
+
import { useCallback as u, useContext as d, 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 { KhrVehicle as ue } from "@khr3/core/vehicle";
|
|
15
|
+
// src/engine/kolmoVehicle.tsx
|
|
16
|
+
function b(e) {
|
|
17
|
+
e.traverse((e) => {
|
|
18
|
+
let n = e.userData?.gltfExtensions?.[t];
|
|
19
|
+
n && !e.userData.KOLMO_emitter && (e.userData[t] = n);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function de(e) {
|
|
23
|
+
let t = [];
|
|
24
|
+
for (let n of e) n.traverse((e) => {
|
|
25
|
+
let n = e;
|
|
26
|
+
if (n.material) {
|
|
27
|
+
if (Array.isArray(n.material)) n.material = n.material.map((e) => {
|
|
28
|
+
let n = e.clone();
|
|
29
|
+
return t.push(n), n;
|
|
30
|
+
});
|
|
31
|
+
else {
|
|
32
|
+
let e = n.material.clone();
|
|
33
|
+
t.push(e), n.material = e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}), o(n);
|
|
37
|
+
return () => {
|
|
38
|
+
for (let e of t) e.dispose();
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function x({ id: t, sourceBundle: o, rawGlbBytes: g, position: _ = [
|
|
42
|
+
0,
|
|
43
|
+
.35,
|
|
44
|
+
0
|
|
45
|
+
], rotation: v, piloted: x = !1, flightMode: S = !1, vehicleMode: C, enable: fe = !0, ccd: w, linearDamping: T, angularDamping: E, userData: D, onCollisionEnter: O, wheelConfig: k, propellerConfig: A, carConfig: j, droneConfig: M, vehicleRef: N, getInput: pe, driver: P, cameraController: F, children: I }) {
|
|
46
|
+
let L = d(e), R = re();
|
|
47
|
+
p(() => {
|
|
48
|
+
ne(R);
|
|
49
|
+
}, [R]);
|
|
50
|
+
let z = ie(R, c), me = ee(pe), B = m(() => ce(o), [o]), V = m(() => i(B), [B]), H = m(() => (b(B.scene), r(B.scene, g)), [B, g]);
|
|
51
|
+
p(() => de([
|
|
52
|
+
B.scene,
|
|
53
|
+
...B.wheels.map((e) => e.object),
|
|
54
|
+
...B.propellers.map((e) => e.object)
|
|
55
|
+
]), [B]);
|
|
56
|
+
let U = !!(C === "rocket" || S || C !== "drive" && B.propellers.length > 0), W = m(() => H.sockets.find((e) => e.role === "seat" || e.role === "optic")?.localPosition ?? [
|
|
57
|
+
0,
|
|
58
|
+
.65,
|
|
59
|
+
0
|
|
60
|
+
], [H]), G = m(() => H.sockets.find((e) => e.role === "exit")?.localPosition ?? [
|
|
61
|
+
-1.55,
|
|
62
|
+
.45,
|
|
63
|
+
0
|
|
64
|
+
], [H]), K = m(() => {
|
|
65
|
+
if (k || C !== void 0) return {
|
|
66
|
+
...C === void 0 ? {} : { enable: C === "drive" },
|
|
67
|
+
...k ?? {}
|
|
68
|
+
};
|
|
69
|
+
}, [k, C]), q = m(() => {
|
|
70
|
+
if (A || C !== void 0) return {
|
|
71
|
+
...C === void 0 ? {} : { enable: C === "rocket" },
|
|
72
|
+
...A ?? {}
|
|
73
|
+
};
|
|
74
|
+
}, [A, C]), J = m(() => U ? {
|
|
75
|
+
controlMode: "VELOCITY",
|
|
76
|
+
maxHorizSpeed: 46,
|
|
77
|
+
maxVertSpeed: 16,
|
|
78
|
+
maxYawRate: 2.3,
|
|
79
|
+
maxTiltAngle: .52,
|
|
80
|
+
HORIZ_VEL_P: 1.8,
|
|
81
|
+
VERT_VEL_P: 2.8,
|
|
82
|
+
...B.droneTune ?? {},
|
|
83
|
+
...M ?? {}
|
|
84
|
+
} : M, [
|
|
85
|
+
U,
|
|
86
|
+
B.droneTune,
|
|
87
|
+
M
|
|
88
|
+
]), Y = h(null), he = h([
|
|
89
|
+
_[0],
|
|
90
|
+
_[1],
|
|
91
|
+
_[2]
|
|
92
|
+
]), X = h(v ? [
|
|
93
|
+
v[0],
|
|
94
|
+
v[1],
|
|
95
|
+
v[2]
|
|
96
|
+
] : void 0), Z = h(n()), Q = h(new oe.Vector3()), ge = h({
|
|
97
|
+
camInit: !1,
|
|
98
|
+
cockpit: !1,
|
|
99
|
+
prevCam: !1,
|
|
100
|
+
prevL: !1,
|
|
101
|
+
prevR: !1,
|
|
102
|
+
turnL: !1,
|
|
103
|
+
turnR: !1
|
|
104
|
+
}), _e = h({
|
|
105
|
+
forward: !1,
|
|
106
|
+
backward: !1,
|
|
107
|
+
steerLeft: !1,
|
|
108
|
+
steerRight: !1,
|
|
109
|
+
brake: !1,
|
|
110
|
+
throttleUp: !1,
|
|
111
|
+
throttleDown: !1,
|
|
112
|
+
yawLeft: !1,
|
|
113
|
+
yawRight: !1,
|
|
114
|
+
pitchForward: !1,
|
|
115
|
+
pitchBackward: !1,
|
|
116
|
+
rollLeft: !1,
|
|
117
|
+
rollRight: !1
|
|
118
|
+
}), $ = u((e, t) => {
|
|
119
|
+
Q.current.x -= e, Q.current.z -= t;
|
|
120
|
+
let n = Y.current;
|
|
121
|
+
if (n) {
|
|
122
|
+
n.currPos.x -= e, n.currPos.z -= t;
|
|
123
|
+
for (let r of n.wheelsInfo.values()) {
|
|
124
|
+
let n = r.current;
|
|
125
|
+
n.rayPos.x -= e, n.rayPos.z -= t, n.supPos.x -= e, n.supPos.z -= t, n.rayHitPos.x -= e, n.rayHitPos.z -= t;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, []);
|
|
129
|
+
f(() => {
|
|
130
|
+
let e = R.spawn(s({
|
|
131
|
+
id: t,
|
|
132
|
+
handle: Y.current,
|
|
133
|
+
centerOfMass: [...B.centerOfMass],
|
|
134
|
+
seatOffset: W,
|
|
135
|
+
exitOffset: G,
|
|
136
|
+
isFlight: U,
|
|
137
|
+
onOriginShift: $
|
|
138
|
+
}), te({
|
|
139
|
+
id: t,
|
|
140
|
+
radius: 4.2,
|
|
141
|
+
kind: "vehicle"
|
|
142
|
+
}));
|
|
143
|
+
return x && !R.get(c)?.activeVehicleId && l(R).boardVehicle(t), () => {
|
|
144
|
+
R.get(c)?.activeVehicleId === t && l(R).exitVehicle(), e.destroy();
|
|
145
|
+
};
|
|
146
|
+
}, [
|
|
147
|
+
R,
|
|
148
|
+
t,
|
|
149
|
+
B,
|
|
150
|
+
W,
|
|
151
|
+
G,
|
|
152
|
+
U,
|
|
153
|
+
x,
|
|
154
|
+
$
|
|
155
|
+
]);
|
|
156
|
+
let ve = u((e) => {
|
|
157
|
+
Y.current = e, N && (N.current = e);
|
|
158
|
+
for (let n of R.query(s)) {
|
|
159
|
+
let r = n.get(s);
|
|
160
|
+
r && r.id === t && n.set(s, {
|
|
161
|
+
...r,
|
|
162
|
+
handle: e,
|
|
163
|
+
onOriginShift: $
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}, [
|
|
167
|
+
R,
|
|
168
|
+
t,
|
|
169
|
+
N,
|
|
170
|
+
$
|
|
171
|
+
]), ye = z?.activeVehicleId === t || x && !z?.activeVehicleId;
|
|
172
|
+
return se((e, n) => {
|
|
173
|
+
let r = Math.min(Math.max(n, 1e-4), .05);
|
|
174
|
+
V.step(r);
|
|
175
|
+
let i = Y.current;
|
|
176
|
+
i && i.body && (P ? (P(i, r, e), F && F(i, r, e)) : ae({
|
|
177
|
+
id: t,
|
|
178
|
+
veh: i,
|
|
179
|
+
keys: me(),
|
|
180
|
+
cmd: _e.current,
|
|
181
|
+
sig: Z.current,
|
|
182
|
+
st: ge.current,
|
|
183
|
+
camTarget: Q.current,
|
|
184
|
+
centerOfMass: B.centerOfMass,
|
|
185
|
+
seatOffset: W,
|
|
186
|
+
isPiloted: ye,
|
|
187
|
+
isFlight: U,
|
|
188
|
+
dt: r,
|
|
189
|
+
state: e,
|
|
190
|
+
cameraController: F
|
|
191
|
+
}));
|
|
192
|
+
}), /* @__PURE__ */ y("group", {
|
|
193
|
+
onClick: (e) => {
|
|
194
|
+
e.delta <= 5 && V.toggleHitObject(e.object) && e.stopPropagation();
|
|
195
|
+
},
|
|
196
|
+
children: /* @__PURE__ */ le(ue, {
|
|
197
|
+
ref: ve,
|
|
198
|
+
bundle: B,
|
|
199
|
+
position: he.current,
|
|
200
|
+
enable: fe,
|
|
201
|
+
enableCustomGravity: L,
|
|
202
|
+
...X.current === void 0 ? {} : { rotation: X.current },
|
|
203
|
+
...w === void 0 ? {} : { ccd: w },
|
|
204
|
+
...T === void 0 ? {} : { linearDamping: T },
|
|
205
|
+
...E === void 0 ? {} : { angularDamping: E },
|
|
206
|
+
...D === void 0 ? {} : { userData: D },
|
|
207
|
+
...O === void 0 ? {} : { onCollisionEnter: O },
|
|
208
|
+
...K === void 0 ? {} : { wheelConfig: K },
|
|
209
|
+
...q === void 0 ? {} : { propellerConfig: q },
|
|
210
|
+
...j === void 0 ? {} : { carConfig: j },
|
|
211
|
+
...J === void 0 ? {} : { droneConfig: J },
|
|
212
|
+
children: [/* @__PURE__ */ y(a, {
|
|
213
|
+
emitters: H.emitters,
|
|
214
|
+
signalsRef: Z
|
|
215
|
+
}), I]
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function S(e) {
|
|
220
|
+
return /* @__PURE__ */ y(x, {
|
|
221
|
+
...e,
|
|
222
|
+
sourceBundle: v(e.src)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function C(e) {
|
|
226
|
+
let [t, n] = g(null);
|
|
227
|
+
return f(() => {
|
|
228
|
+
if (e.bundle || e.src || !e.rawGlbBytes) return;
|
|
229
|
+
let t = !0;
|
|
230
|
+
return _(e.rawGlbBytes).then((e) => {
|
|
231
|
+
t && n(e);
|
|
232
|
+
}), () => {
|
|
233
|
+
t = !1;
|
|
234
|
+
};
|
|
235
|
+
}, [
|
|
236
|
+
e.bundle,
|
|
237
|
+
e.src,
|
|
238
|
+
e.rawGlbBytes
|
|
239
|
+
]), e.bundle ? /* @__PURE__ */ y(x, {
|
|
240
|
+
...e,
|
|
241
|
+
sourceBundle: e.bundle
|
|
242
|
+
}) : e.src ? /* @__PURE__ */ y(S, {
|
|
243
|
+
...e,
|
|
244
|
+
src: e.src
|
|
245
|
+
}) : t ? /* @__PURE__ */ y(x, {
|
|
246
|
+
...e,
|
|
247
|
+
sourceBundle: t
|
|
248
|
+
}) : null;
|
|
249
|
+
}
|
|
250
|
+
export { C as KolmoVehicle };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import type { RootState } from "@react-three/fiber";
|
|
3
|
+
import type { EcctrlVehicleHandle, VehicleInput } from "@pinkaphant/ecctrl/vehicle";
|
|
4
|
+
import type { KolmoSignalState } from "../schema/kolmoSchema.js";
|
|
5
|
+
import type { KolmoInputState } from "./kolmoInput.js";
|
|
6
|
+
export interface KolmoVehicleFrameState {
|
|
7
|
+
camInit: boolean;
|
|
8
|
+
cockpit: boolean;
|
|
9
|
+
prevCam: boolean;
|
|
10
|
+
prevL: boolean;
|
|
11
|
+
prevR: boolean;
|
|
12
|
+
turnL: boolean;
|
|
13
|
+
turnR: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function stepKolmoVehicleFrame(params: {
|
|
16
|
+
id: string;
|
|
17
|
+
veh: EcctrlVehicleHandle;
|
|
18
|
+
keys: Readonly<KolmoInputState>;
|
|
19
|
+
cmd: VehicleInput;
|
|
20
|
+
sig: KolmoSignalState;
|
|
21
|
+
st: KolmoVehicleFrameState;
|
|
22
|
+
camTarget: THREE.Vector3;
|
|
23
|
+
centerOfMass: readonly [number, number, number];
|
|
24
|
+
seatOffset: readonly [number, number, number];
|
|
25
|
+
isPiloted: boolean;
|
|
26
|
+
isFlight: boolean;
|
|
27
|
+
dt: number;
|
|
28
|
+
state: RootState;
|
|
29
|
+
cameraController?: (veh: EcctrlVehicleHandle, dt: number, state: RootState) => void;
|
|
30
|
+
}): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { kolmoTelemetry as e } from "./kolmoStore.js";
|
|
2
|
+
import * as t from "three";
|
|
3
|
+
import { easing as n } from "maath";
|
|
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 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;
|
|
14
|
+
}
|
|
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);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
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);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
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);
|
|
28
|
+
}
|
|
29
|
+
export { s as stepKolmoVehicleFrame };
|
|
@@ -2,20 +2,11 @@ import React, { type CSSProperties, type ReactNode } from "react";
|
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { type KeyboardControlsEntry } from "@react-three/drei";
|
|
4
4
|
import type { World } from "koota";
|
|
5
|
-
import { type
|
|
5
|
+
import { KolmoGravityContext, KolmoPhysics, useIsKolmoCustomGravity, useOptionalKootaWorld, type KolmoGravityCallback, type KolmoGravitySpec, type KolmoPhysicsProps, type KolmoPointGravity, type KolmoTimeControlValue } from "../physics/index.js";
|
|
6
|
+
import { type RetroPresetId } from "../shaders/retroShader.js";
|
|
7
|
+
import { EMPTY_KOLMO_INPUT, KOLMO_KEY_MAP, useKolmoInput, type KolmoInputGetter, type KolmoInputState, type KolmoKeyAction } from "./kolmoInput.js";
|
|
6
8
|
import { RetroViewportSync, RoomEnvRig, ShadowSnapRig, type RetroViewportSyncProps, type RoomEnvRigProps } from "./kolmoRigs.js";
|
|
7
|
-
export { RetroViewportSync, RoomEnvRig, ShadowSnapRig, type RetroViewportSyncProps, type RoomEnvRigProps };
|
|
8
|
-
export type KolmoPointGravity = {
|
|
9
|
-
kind: "point";
|
|
10
|
-
center: [number, number, number];
|
|
11
|
-
surfaceG: number;
|
|
12
|
-
radius: number;
|
|
13
|
-
};
|
|
14
|
-
export type KolmoGravityCallback = (pos: THREE.Vector3, out: THREE.Vector3) => THREE.Vector3;
|
|
15
|
-
export type KolmoGravitySpec = "planar" | "zero" | [number, number, number] | KolmoPointGravity | KolmoGravityCallback;
|
|
16
|
-
export type KolmoKeyAction = "forward" | "backward" | "left" | "right" | "brake" | "boost" | "interact" | "turnLeft" | "turnRight" | "descend" | "cameraView";
|
|
17
|
-
export declare const KOLMO_KEY_MAP: KeyboardControlsEntry<KolmoKeyAction>[];
|
|
18
|
-
export declare const KolmoGravityContext: React.Context<boolean>;
|
|
9
|
+
export { EMPTY_KOLMO_INPUT, KOLMO_KEY_MAP, KolmoGravityContext, KolmoPhysics, RetroViewportSync, RoomEnvRig, ShadowSnapRig, useIsKolmoCustomGravity, useKolmoInput, useOptionalKootaWorld, type KolmoGravityCallback, type KolmoGravitySpec, type KolmoInputGetter, type KolmoInputState, type KolmoKeyAction, type KolmoPhysicsProps, type KolmoPointGravity, type KolmoTimeControlValue, type RetroViewportSyncProps, type RoomEnvRigProps, };
|
|
19
10
|
export interface KolmoCanvasProps {
|
|
20
11
|
children: ReactNode;
|
|
21
12
|
className?: string;
|
|
@@ -36,7 +27,8 @@ export declare function KolmoCanvas({ children, className, style, fov, near, far
|
|
|
36
27
|
export interface KolmoWorldProps {
|
|
37
28
|
gravity?: KolmoGravitySpec;
|
|
38
29
|
paused?: boolean;
|
|
39
|
-
timeScale?:
|
|
30
|
+
timeScale?: KolmoTimeControlValue;
|
|
31
|
+
maxDelta?: KolmoTimeControlValue;
|
|
40
32
|
physicsDebug?: boolean;
|
|
41
33
|
retroPreset?: RetroPresetId;
|
|
42
34
|
skybox?: "nebula" | "day" | "none";
|
|
@@ -48,4 +40,4 @@ export interface KolmoWorldProps {
|
|
|
48
40
|
keyboardMap?: KeyboardControlsEntry<string>[] | null;
|
|
49
41
|
children: ReactNode;
|
|
50
42
|
}
|
|
51
|
-
export declare function KolmoWorld({ gravity, paused, timeScale, physicsDebug, retroPreset, skybox, lighting, fogExp2, sunLightRef, shadowSnap, world, keyboardMap, children, }: KolmoWorldProps): React.JSX.Element;
|
|
43
|
+
export declare function KolmoWorld({ gravity, paused, timeScale, maxDelta, physicsDebug, retroPreset, skybox, lighting, fogExp2, sunLightRef, shadowSnap, world, keyboardMap, children, }: KolmoWorldProps): React.JSX.Element;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { KolmoGravityContext as e, KolmoPhysics as t, useIsKolmoCustomGravity as n, useOptionalKootaWorld as r } from "../physics/index.js";
|
|
2
|
+
import { KolmoSkybox as i } from "../shaders/celestialBackdrop.js";
|
|
3
|
+
import { syncRetroUniforms as a } from "../shaders/retroShader.js";
|
|
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
|
+
// src/engine/kolmoWorld.tsx
|
|
14
|
+
function O({ children: e, className: t, style: n, fov: r = 56, near: i = .15, far: a = 6500, cameraPosition: o = [
|
|
15
|
+
0,
|
|
16
|
+
3.2,
|
|
17
|
+
-8.5
|
|
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
|
+
className: t,
|
|
21
|
+
style: n ?? {
|
|
22
|
+
width: "100%",
|
|
23
|
+
height: "100%",
|
|
24
|
+
display: "block"
|
|
25
|
+
},
|
|
26
|
+
shadows: l,
|
|
27
|
+
dpr: s,
|
|
28
|
+
frameloop: c,
|
|
29
|
+
gl: {
|
|
30
|
+
antialias: !1,
|
|
31
|
+
powerPreference: "high-performance",
|
|
32
|
+
...u === void 0 ? {} : { toneMapping: u }
|
|
33
|
+
},
|
|
34
|
+
camera: {
|
|
35
|
+
fov: r,
|
|
36
|
+
near: i,
|
|
37
|
+
far: a,
|
|
38
|
+
position: o
|
|
39
|
+
},
|
|
40
|
+
onCreated: ({ gl: e }) => {
|
|
41
|
+
e.outputColorSpace = x.SRGBColorSpace;
|
|
42
|
+
let t = e.domElement;
|
|
43
|
+
d?.(t), p && (t.addEventListener("webglcontextlost", (e) => {
|
|
44
|
+
e.preventDefault(), p(!0);
|
|
45
|
+
}), t.addEventListener("webglcontextrestored", () => p(!1)));
|
|
46
|
+
},
|
|
47
|
+
children: [m !== !1 && /* @__PURE__ */ E(f, { intensity: typeof m == "number" ? m : .65 }), e]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function k({ world: e, retroPreset: t }) {
|
|
51
|
+
b(() => {
|
|
52
|
+
e && h(e);
|
|
53
|
+
}, [e]);
|
|
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
|
+
}, [
|
|
58
|
+
e,
|
|
59
|
+
t,
|
|
60
|
+
n?.activeRetroPreset
|
|
61
|
+
]), null;
|
|
62
|
+
}
|
|
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
|
+
}),
|
|
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
|
+
attach: "background",
|
|
77
|
+
args: ["#6ba6d6"]
|
|
78
|
+
}), !g && /* @__PURE__ */ E("fog", {
|
|
79
|
+
attach: "fog",
|
|
80
|
+
args: [
|
|
81
|
+
"#9dc4e2",
|
|
82
|
+
110,
|
|
83
|
+
520
|
|
84
|
+
]
|
|
85
|
+
})] }),
|
|
86
|
+
g && /* @__PURE__ */ E("fogExp2", {
|
|
87
|
+
attach: "fog",
|
|
88
|
+
args: g
|
|
89
|
+
}),
|
|
90
|
+
m === "default" && /* @__PURE__ */ D(T, { children: [
|
|
91
|
+
/* @__PURE__ */ E("hemisphereLight", { args: [
|
|
92
|
+
"#b8dcff",
|
|
93
|
+
"#241d30",
|
|
94
|
+
.8
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ E("directionalLight", {
|
|
97
|
+
ref: v,
|
|
98
|
+
position: [
|
|
99
|
+
48,
|
|
100
|
+
76,
|
|
101
|
+
36
|
|
102
|
+
],
|
|
103
|
+
intensity: 1.85,
|
|
104
|
+
color: "#fff3dc",
|
|
105
|
+
castShadow: !0,
|
|
106
|
+
"shadow-mapSize": [1024, 1024]
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ E("directionalLight", {
|
|
109
|
+
position: [
|
|
110
|
+
-42,
|
|
111
|
+
28,
|
|
112
|
+
-50
|
|
113
|
+
],
|
|
114
|
+
intensity: .55,
|
|
115
|
+
color: "#68a8ff"
|
|
116
|
+
})
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ E(t, {
|
|
119
|
+
gravity: e,
|
|
120
|
+
paused: n,
|
|
121
|
+
timeScale: a,
|
|
122
|
+
maxDelta: o,
|
|
123
|
+
physicsDebug: u,
|
|
124
|
+
world: null,
|
|
125
|
+
children: O
|
|
126
|
+
})
|
|
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;
|
|
138
|
+
}
|
|
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 };
|