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