@pinkaphant/kolmo 0.1.1 → 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 -54
- package/dist/body/HeldItem.d.ts +22 -0
- package/dist/body/HeldItem.js +171 -0
- package/dist/body/KhrBody.d.ts +26 -0
- package/dist/body/KhrBody.js +179 -0
- package/dist/body/bodySi.d.ts +59 -0
- package/dist/body/bodySi.js +61 -0
- package/dist/body/index.d.ts +3 -0
- package/dist/body/index.js +4 -0
- 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 +2 -3
- package/dist/index.js +69 -14
- 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 +36 -19
- package/dist/engine-BeKvBM8d.js +0 -1745
- package/dist/importer-D9bdcGTh.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,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 };
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import type { RoadsideStop2D } from "../world/index.js";
|
|
3
3
|
export type WorldGlbKey = "road_straight" | "road_crosswalk" | "road_intersection" | "curb_straight" | "curb_ramp" | "curb_driveway" | "light_pole";
|
|
4
4
|
export declare const KOLMO_R2_BASE = "https://khr3.optimuspi.workers.dev/assets";
|
|
5
|
-
export declare function InstancedWorldGlb(
|
|
5
|
+
export declare function InstancedWorldGlb(props: {
|
|
6
6
|
readonly kitKey: WorldGlbKey;
|
|
7
7
|
readonly fitSpan: readonly [number, number, number];
|
|
8
8
|
readonly matrices: Float32Array;
|
|
@@ -12,8 +12,10 @@ export declare function InstancedC12Piece({ matrices, kind, color, }: {
|
|
|
12
12
|
readonly kind: "square" | "triangle" | "wall" | "roof";
|
|
13
13
|
readonly color: string;
|
|
14
14
|
}): React.JSX.Element | null;
|
|
15
|
-
export declare function RoadsideStopCompound({ stop, groundY, cellTag, }: {
|
|
15
|
+
export declare function RoadsideStopCompound({ stop, groundY, offX, offZ, cellTag, }: {
|
|
16
16
|
readonly stop: RoadsideStop2D;
|
|
17
17
|
readonly groundY: number;
|
|
18
|
+
readonly offX?: number;
|
|
19
|
+
readonly offZ?: number;
|
|
18
20
|
readonly cellTag: string;
|
|
19
21
|
}): React.JSX.Element;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { KolmoJunk as e } from "../junk/KolmoJunk.js";
|
|
2
|
+
import { applyRetroMaterial as t, applySceneRetroMaterials as n } from "../shaders/retroShader.js";
|
|
3
|
+
import { ShiftedFixedBody as r } from "./shiftedFixedBody.js";
|
|
4
|
+
import { Suspense as i, useEffect as a, useLayoutEffect as o, useMemo as s, useRef as c } from "react";
|
|
5
|
+
import * as l from "three";
|
|
6
|
+
import { useGLTF as u } from "@react-three/drei";
|
|
7
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
8
|
+
import { CuboidCollider as m } from "@react-three/rapier";
|
|
9
|
+
import { mergeGeometries as h } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
10
|
+
// src/engine/longDriveKit.tsx
|
|
11
|
+
var g = "https://khr3.optimuspi.workers.dev/assets", _ = {
|
|
12
|
+
road_straight: `${g}/city/R_Straight_6x6.glb`,
|
|
13
|
+
road_crosswalk: `${g}/city/R_Crosswalk_6x6.glb`,
|
|
14
|
+
road_intersection: `${g}/city/R_Intersection_6x6.glb`,
|
|
15
|
+
curb_straight: `${g}/city/S_Straight_3x6.glb`,
|
|
16
|
+
curb_ramp: `${g}/city/S_AccessibleRamp_3x6.glb`,
|
|
17
|
+
curb_driveway: `${g}/city/S_Driveway_3x6.glb`,
|
|
18
|
+
light_pole: `${g}/city/L_LightPole_12gon.glb`
|
|
19
|
+
}, v = {
|
|
20
|
+
canopy: `${g}/city/gas-canopy-roof.glb`,
|
|
21
|
+
pump: `${g}/city/gas-pump-twin.glb`,
|
|
22
|
+
sign: `${g}/city/neon-petro-sign.glb`
|
|
23
|
+
}, y = typeof document < "u" && typeof HTMLImageElement < "u", b = /* @__PURE__ */ new Map();
|
|
24
|
+
function x(e, n, r) {
|
|
25
|
+
let i = b.get(n);
|
|
26
|
+
if (i) return i;
|
|
27
|
+
e.updateMatrixWorld(!0);
|
|
28
|
+
let a = new l.Matrix4().copy(e.matrixWorld).invert(), o = new l.Matrix4(), s = [], c = null;
|
|
29
|
+
e.traverse((e) => {
|
|
30
|
+
if (!(e instanceof l.Mesh) || !e.geometry) return;
|
|
31
|
+
let t = e.geometry.index ? e.geometry.toNonIndexed() : e.geometry.clone();
|
|
32
|
+
t.applyMatrix4(o.multiplyMatrices(a, e.matrixWorld));
|
|
33
|
+
for (let e of Object.keys(t.attributes)) e !== "position" && e !== "normal" && e !== "uv" && e !== "color" && t.deleteAttribute(e);
|
|
34
|
+
if (t.getAttribute("normal") || t.computeVertexNormals(), !t.getAttribute("uv")) {
|
|
35
|
+
let e = t.getAttribute("position").count;
|
|
36
|
+
t.setAttribute("uv", new l.BufferAttribute(new Float32Array(e * 2), 2));
|
|
37
|
+
}
|
|
38
|
+
s.push(t), !c && e.material && (c = (Array.isArray(e.material) ? e.material[0] : e.material).clone());
|
|
39
|
+
});
|
|
40
|
+
let u = s.length > 0 ? h(s, !1) ?? s[0] : new l.BoxGeometry(r[0], r[1], r[2]);
|
|
41
|
+
for (let e of s) e !== u && e.dispose();
|
|
42
|
+
u.computeBoundingBox();
|
|
43
|
+
let d = u.boundingBox, f = d.getSize(new l.Vector3()), p = d.getCenter(new l.Vector3()), m = r[0] / Math.max(f.x, 1e-4), g = r[1] / Math.max(f.y, 1e-4), _ = r[2] / Math.max(f.z, 1e-4), v = n === "light_pole" ? g : Math.min(m, _);
|
|
44
|
+
u.translate(-p.x, -d.min.y, -p.z), u.scale(n === "light_pole" ? v : m, n === "light_pole" ? g : v, n === "light_pole" ? v : _), u.computeBoundingSphere();
|
|
45
|
+
let y = c ?? new l.MeshLambertMaterial({
|
|
46
|
+
color: "#64748b",
|
|
47
|
+
flatShading: !0
|
|
48
|
+
});
|
|
49
|
+
t(y, { flatShading: !0 });
|
|
50
|
+
let x = {
|
|
51
|
+
geometry: u,
|
|
52
|
+
material: y
|
|
53
|
+
};
|
|
54
|
+
return b.set(n, x), x;
|
|
55
|
+
}
|
|
56
|
+
function S({ kitKey: e, fitSpan: t, matrices: n }) {
|
|
57
|
+
let r = n.length / 16, i = u(_[e]), a = c(null), l = s(() => x(i.scene, e, t), [
|
|
58
|
+
i.scene,
|
|
59
|
+
e,
|
|
60
|
+
t
|
|
61
|
+
]);
|
|
62
|
+
return o(() => {
|
|
63
|
+
a.current && r !== 0 && (a.current.instanceMatrix.array.set(n), a.current.instanceMatrix.needsUpdate = !0, a.current.computeBoundingSphere());
|
|
64
|
+
}, [n, r]), r > 0 ? /* @__PURE__ */ f("instancedMesh", {
|
|
65
|
+
ref: a,
|
|
66
|
+
args: [
|
|
67
|
+
l.geometry,
|
|
68
|
+
l.material,
|
|
69
|
+
r
|
|
70
|
+
],
|
|
71
|
+
frustumCulled: !1,
|
|
72
|
+
receiveShadow: !0
|
|
73
|
+
}) : null;
|
|
74
|
+
}
|
|
75
|
+
function C(e) {
|
|
76
|
+
return e.matrices.length === 0 || !y ? null : /* @__PURE__ */ f(i, {
|
|
77
|
+
fallback: null,
|
|
78
|
+
children: /* @__PURE__ */ f(S, { ...e })
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function w({ matrices: e, kind: n, color: r }) {
|
|
82
|
+
let i = c(null), u = e.length / 16, d = s(() => {
|
|
83
|
+
if (n === "triangle") {
|
|
84
|
+
let e = 3 * Math.sqrt(3) * .5, t = new l.Shape([
|
|
85
|
+
new l.Vector2(-1.5, 0),
|
|
86
|
+
new l.Vector2(1.5, 0),
|
|
87
|
+
new l.Vector2(0, e)
|
|
88
|
+
]), n = new l.ExtrudeGeometry(t, {
|
|
89
|
+
depth: .24,
|
|
90
|
+
bevelEnabled: !1
|
|
91
|
+
});
|
|
92
|
+
return n.rotateX(-Math.PI * .5), n;
|
|
93
|
+
}
|
|
94
|
+
return n === "wall" ? new l.BoxGeometry(3, 3, .22) : n === "roof" ? new l.BoxGeometry(3.08, .24, 3.08) : new l.BoxGeometry(3, .24, 3);
|
|
95
|
+
}, [n]), p = s(() => t(new l.MeshLambertMaterial({
|
|
96
|
+
color: r,
|
|
97
|
+
flatShading: !0
|
|
98
|
+
}), { flatShading: !0 }), [r]);
|
|
99
|
+
return a(() => () => {
|
|
100
|
+
d.dispose(), p.dispose();
|
|
101
|
+
}, [d, p]), o(() => {
|
|
102
|
+
i.current && u !== 0 && (i.current.instanceMatrix.array.set(e), i.current.instanceMatrix.needsUpdate = !0, i.current.computeBoundingSphere());
|
|
103
|
+
}, [e, u]), u > 0 ? /* @__PURE__ */ f("instancedMesh", {
|
|
104
|
+
ref: i,
|
|
105
|
+
args: [
|
|
106
|
+
d,
|
|
107
|
+
p,
|
|
108
|
+
u
|
|
109
|
+
],
|
|
110
|
+
frustumCulled: !1,
|
|
111
|
+
castShadow: !0,
|
|
112
|
+
receiveShadow: !0
|
|
113
|
+
}) : null;
|
|
114
|
+
}
|
|
115
|
+
function T({ stop: e }) {
|
|
116
|
+
let t = u(v.canopy), r = u(v.pump), i = u(v.sign), o = s(() => {
|
|
117
|
+
let e = (e, t) => {
|
|
118
|
+
let r = e.clone(!0);
|
|
119
|
+
r.traverse((e) => {
|
|
120
|
+
let t = e;
|
|
121
|
+
t.material &&= Array.isArray(t.material) ? t.material.map((e) => e.clone()) : t.material.clone();
|
|
122
|
+
}), r.updateMatrixWorld(!0);
|
|
123
|
+
let i = new l.Box3().setFromObject(r), a = i.getSize(new l.Vector3()), o = i.getCenter(new l.Vector3()), s = t / Math.max(a.y, .1);
|
|
124
|
+
return r.scale.setScalar(s), r.position.set(-o.x * s, -i.min.y * s, -o.z * s), n(r), r;
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
canopy: e(t.scene, 4.6),
|
|
128
|
+
pumpA: e(r.scene, 2.1),
|
|
129
|
+
pumpB: e(r.scene, 2.1),
|
|
130
|
+
sign: e(i.scene, 6.8)
|
|
131
|
+
};
|
|
132
|
+
}, [
|
|
133
|
+
t.scene,
|
|
134
|
+
r.scene,
|
|
135
|
+
i.scene
|
|
136
|
+
]);
|
|
137
|
+
return a(() => () => {
|
|
138
|
+
for (let e of [
|
|
139
|
+
o.canopy,
|
|
140
|
+
o.pumpA,
|
|
141
|
+
o.pumpB,
|
|
142
|
+
o.sign
|
|
143
|
+
]) e.traverse((e) => {
|
|
144
|
+
let t = e.material;
|
|
145
|
+
if (t) for (let e of Array.isArray(t) ? t : [t]) e.dispose();
|
|
146
|
+
});
|
|
147
|
+
}, [o]), /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("primitive", {
|
|
148
|
+
object: o.canopy,
|
|
149
|
+
position: [
|
|
150
|
+
0,
|
|
151
|
+
.16,
|
|
152
|
+
0
|
|
153
|
+
]
|
|
154
|
+
}), e.kind === "GAS_STATION" && /* @__PURE__ */ p(d, { children: [
|
|
155
|
+
/* @__PURE__ */ f("primitive", {
|
|
156
|
+
object: o.pumpA,
|
|
157
|
+
position: [
|
|
158
|
+
-2.4,
|
|
159
|
+
.16,
|
|
160
|
+
0
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ f("primitive", {
|
|
164
|
+
object: o.pumpB,
|
|
165
|
+
position: [
|
|
166
|
+
2.4,
|
|
167
|
+
.16,
|
|
168
|
+
0
|
|
169
|
+
]
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ f("primitive", {
|
|
172
|
+
object: o.sign,
|
|
173
|
+
position: [
|
|
174
|
+
e.widthMeters * .42,
|
|
175
|
+
.16,
|
|
176
|
+
e.depthMeters * .36
|
|
177
|
+
]
|
|
178
|
+
})
|
|
179
|
+
] })] });
|
|
180
|
+
}
|
|
181
|
+
function E({ stop: t, groundY: n, offX: a = 0, offZ: o = 0, cellTag: s }) {
|
|
182
|
+
let c = t.worldX + a, l = t.worldZ + o, u = Math.cos(t.yaw), d = Math.sin(t.yaw), h = [
|
|
183
|
+
c + 1.1 * u + 1.4 * d,
|
|
184
|
+
n + .55,
|
|
185
|
+
l - 1.1 * d + 1.4 * u
|
|
186
|
+
], g = [
|
|
187
|
+
c - 1.1 * u + 1.4 * d,
|
|
188
|
+
n + .55,
|
|
189
|
+
l + 1.1 * d + 1.4 * u
|
|
190
|
+
];
|
|
191
|
+
return /* @__PURE__ */ p("group", { children: [
|
|
192
|
+
/* @__PURE__ */ p(r, {
|
|
193
|
+
x: c,
|
|
194
|
+
y: n,
|
|
195
|
+
z: l,
|
|
196
|
+
yaw: t.yaw,
|
|
197
|
+
children: [/* @__PURE__ */ f(m, {
|
|
198
|
+
args: [
|
|
199
|
+
t.widthMeters * .5,
|
|
200
|
+
.12,
|
|
201
|
+
t.depthMeters * .5
|
|
202
|
+
],
|
|
203
|
+
position: [
|
|
204
|
+
0,
|
|
205
|
+
.12,
|
|
206
|
+
0
|
|
207
|
+
]
|
|
208
|
+
}), /* @__PURE__ */ p("mesh", {
|
|
209
|
+
position: [
|
|
210
|
+
0,
|
|
211
|
+
.08,
|
|
212
|
+
0
|
|
213
|
+
],
|
|
214
|
+
receiveShadow: !0,
|
|
215
|
+
children: [/* @__PURE__ */ f("boxGeometry", { args: [
|
|
216
|
+
t.widthMeters,
|
|
217
|
+
.16,
|
|
218
|
+
t.depthMeters
|
|
219
|
+
] }), /* @__PURE__ */ f("meshLambertMaterial", {
|
|
220
|
+
color: "#475569",
|
|
221
|
+
flatShading: !0
|
|
222
|
+
})]
|
|
223
|
+
})]
|
|
224
|
+
}),
|
|
225
|
+
y && /* @__PURE__ */ f("group", {
|
|
226
|
+
position: [
|
|
227
|
+
c,
|
|
228
|
+
n,
|
|
229
|
+
l
|
|
230
|
+
],
|
|
231
|
+
rotation: [
|
|
232
|
+
0,
|
|
233
|
+
t.yaw,
|
|
234
|
+
0
|
|
235
|
+
],
|
|
236
|
+
children: /* @__PURE__ */ f(i, {
|
|
237
|
+
fallback: null,
|
|
238
|
+
children: /* @__PURE__ */ f(T, { stop: t })
|
|
239
|
+
})
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ f(e, {
|
|
242
|
+
id: `${s}_can`,
|
|
243
|
+
kind: "tin-can",
|
|
244
|
+
labelId: "tris-soda",
|
|
245
|
+
position: h
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ f(e, {
|
|
248
|
+
id: `${s}_bot`,
|
|
249
|
+
kind: "glass-bottle",
|
|
250
|
+
position: g
|
|
251
|
+
})
|
|
252
|
+
] });
|
|
253
|
+
}
|
|
254
|
+
export { w as InstancedC12Piece, C as InstancedWorldGlb, g as KOLMO_R2_BASE, E as RoadsideStopCompound };
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { InfiniteLongDrivePlanner, type MacroCellPlan2D } from "../world/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly z: number;
|
|
7
|
-
readonly friction?: number;
|
|
8
|
-
readonly children: React.ReactNode;
|
|
9
|
-
}): React.JSX.Element;
|
|
4
|
+
import { ShiftedFixedBody, type ShiftedFixedBodyProps } from "./shiftedFixedBody.js";
|
|
5
|
+
export { ShiftedFixedBody, type ShiftedFixedBodyProps };
|
|
10
6
|
export declare function MainlandMacroCell({ mx, mz, planner, roadMat, terrainMat, offX, offZ, renderExtra, }: {
|
|
11
7
|
readonly mx: number;
|
|
12
8
|
readonly mz: number;
|
|
13
9
|
readonly planner: InfiniteLongDrivePlanner;
|
|
14
10
|
readonly roadMat: THREE.Material;
|
|
15
|
-
readonly terrainMat
|
|
11
|
+
readonly terrainMat?: THREE.Material;
|
|
16
12
|
readonly offX: number;
|
|
17
13
|
readonly offZ: number;
|
|
18
14
|
readonly renderExtra?: (mx: number, mz: number, plan: MacroCellPlan2D, offX: number, offZ: number) => React.ReactNode;
|