@pinkaphant/kolmo 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/kolmo.mjs +1 -2
- package/dist/body/HeldItem.d.ts +22 -0
- package/dist/body/KhrBody.d.ts +26 -0
- package/dist/body/bodySi.d.ts +59 -0
- package/dist/body/index.d.ts +3 -0
- package/dist/body/index.js +1 -0
- package/dist/body-B7FTf67o.js +362 -0
- package/dist/importer/index.js +1 -1
- package/dist/{importer-D9bdcGTh.js → importer-B2-S-N_e.js} +894 -894
- package/dist/index.d.ts +1 -2
- package/dist/index.js +7 -8
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
# Install into an existing R3F / Vite app:
|
|
9
|
-
npm install @pinkaphant/kolmo @pinkaphant/ecctrl@^2.0.4-beta.3 @khr3/core @khr3/assets @khr3/c12 @khr3/vehicles @khr3/launchers
|
|
9
|
+
npm install @pinkaphant/kolmo @pinkaphant/ecctrl@^2.0.4-beta.3 @khr3/core @khr3/assets @khr3/c12 @khr3/vehicles @khr3/launchers
|
|
10
10
|
|
|
11
11
|
# Or scaffold your own standalone game (configured for your own Cloudflare Workers/R2 account):
|
|
12
12
|
npx @pinkaphant/kolmo create my-road-game --template longline
|
|
@@ -26,7 +26,7 @@ All `@khr3/*` packages are **zero-`koota`** reusable libraries. **`@pinkaphant/k
|
|
|
26
26
|
| `@pinkaphant/kolmo/shaders` | [src/shaders/index.ts](./src/shaders/index.ts) | 6-mode retro quantizer (`rgb555`, `rgb444`, `rgb332`, `crunchy16`/`crunchy64` 3D LUTs, linear-light Bayer 8×8, [retroShader.ts](./src/shaders/retroShader.ts)), PS2 world-locked splat shaders ([ps2TerrainWebGL.ts](./src/shaders/ps2TerrainWebGL.ts), [ps2RoadWebGL.ts](./src/shaders/ps2RoadWebGL.ts)), `<KolmoSkybox>`, `<KolmoExoplanet>` |
|
|
27
27
|
| `@pinkaphant/kolmo/importer` | [src/importer/index.ts](./src/importer/index.ts) | `<GlbImportGate>` ([GlbImportGate.tsx](./src/importer/GlbImportGate.tsx)), `<ChopShopPanel>`, `<DomainWorkshopPanel>` (`c12`, `launcher`, `person`, live R2 vault), zero-WASM USD intake ([usdToGlb.ts](./src/importer/usdToGlb.ts)), and W3C WebMCP (`importer_*` tools in [importerWebMcp.ts](./src/importer/importerWebMcp.ts)) |
|
|
28
28
|
| `@pinkaphant/kolmo/junk` | [src/junk/index.ts](./src/junk/index.ts) | `<KolmoJunk>` ([KolmoJunk.tsx](./src/junk/KolmoJunk.tsx)), `<DestructibleTarget>`, multi-LOD cans & bottles, decals, and BVH shattering (`<ShardPieces>`) |
|
|
29
|
-
| `@
|
|
29
|
+
| `@pinkaphant/kolmo/body` | [src/body/index.ts](./src/body/index.ts) | `1.75 m` SI standing capsule (`BODY_SI`, `bodySpawnPosition`, `withExcludeCharacterRay`), `<KhrBody>`, and `<HeldItem>` |
|
|
30
30
|
|
|
31
31
|
## Flagship Games Inside `Kolmo/games/` (Excluded from npm Tarball)
|
|
32
32
|
|
package/bin/kolmo.mjs
CHANGED
|
@@ -44,13 +44,12 @@ fs.writeFileSync(path.join(targetDir, "package.json"), JSON.stringify({
|
|
|
44
44
|
dependencies: {
|
|
45
45
|
"@dimforge/rapier3d-compat": "^0.19.2",
|
|
46
46
|
"@khr3/assets": "^0.2.1",
|
|
47
|
-
"@khr3/body": "^0.1.0",
|
|
48
47
|
"@khr3/c12": "^0.3.0",
|
|
49
48
|
"@khr3/core": "^0.1.1",
|
|
50
49
|
"@khr3/launchers": "^0.2.1",
|
|
51
50
|
"@khr3/vehicles": "^0.1.2",
|
|
52
51
|
"@pinkaphant/ecctrl": "^2.0.4-beta.3",
|
|
53
|
-
"@pinkaphant/kolmo": "^0.1.
|
|
52
|
+
"@pinkaphant/kolmo": "^0.1.2",
|
|
54
53
|
"@pmndrs/uikit": "^1.0.78",
|
|
55
54
|
"@preact/signals-core": "^1.5.1",
|
|
56
55
|
"@react-three/drei": "^10.7.7",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type KhrAssetBundle } from "@khr3/core";
|
|
2
|
+
import { type RapierRigidBody } from "@react-three/rapier";
|
|
3
|
+
import { type Ref, type RefObject } from "react";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
import { type BodySocketId } from "./bodySi.js";
|
|
6
|
+
import type { KhrBodyHandle } from "./KhrBody.js";
|
|
7
|
+
export interface HeldItemHandle {
|
|
8
|
+
readonly socket: BodySocketId;
|
|
9
|
+
readonly rigidBody: RapierRigidBody | null;
|
|
10
|
+
setRoleTarget(role: string, target: number): number;
|
|
11
|
+
setJointTarget(nodeName: string, target: number): number;
|
|
12
|
+
getRoleValue(role: string): number;
|
|
13
|
+
}
|
|
14
|
+
export interface HeldItemProps {
|
|
15
|
+
readonly ref?: Ref<HeldItemHandle>;
|
|
16
|
+
readonly bundle: KhrAssetBundle;
|
|
17
|
+
readonly socket: BodySocketId;
|
|
18
|
+
readonly bodyRef?: RefObject<KhrBodyHandle | null>;
|
|
19
|
+
readonly parentSocketObject?: THREE.Object3D | null;
|
|
20
|
+
readonly userData?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export declare function HeldItem({ ref, bundle, socket, bodyRef, parentSocketObject, userData }: HeldItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type EcctrlHandle, type EcctrlProps } from "@pinkaphant/ecctrl";
|
|
2
|
+
import { type EcctrlCameraControlsHandle } from "@pinkaphant/ecctrl/camera";
|
|
3
|
+
import { type ReactNode, type Ref } from "react";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
import { stepCameraSync, type BodySiConstants, type BodySocketId } from "./bodySi.js";
|
|
6
|
+
export { stepCameraSync };
|
|
7
|
+
export interface KhrBodyHandle {
|
|
8
|
+
readonly ecctrl: EcctrlHandle | null;
|
|
9
|
+
readonly cameraControls: EcctrlCameraControlsHandle | null;
|
|
10
|
+
socket(id: BodySocketId): THREE.Object3D | null;
|
|
11
|
+
syncCameraStep(pos: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
}): void;
|
|
16
|
+
}
|
|
17
|
+
export interface KhrBodyProps extends Omit<EcctrlProps, "ref"> {
|
|
18
|
+
readonly ref?: Ref<KhrBodyHandle>;
|
|
19
|
+
readonly si?: BodySiConstants;
|
|
20
|
+
readonly smoothCamera?: boolean;
|
|
21
|
+
readonly makeDefaultCamera?: boolean;
|
|
22
|
+
readonly enableInput?: boolean;
|
|
23
|
+
readonly viewModelChildren?: ReactNode;
|
|
24
|
+
readonly socketOffsets?: Partial<Record<BodySocketId, readonly [number, number, number]>>;
|
|
25
|
+
}
|
|
26
|
+
export declare function KhrBody({ ref, si, smoothCamera, makeDefaultCamera, enableInput, enable, viewModelChildren, socketOffsets, children, userData: callerUserData, position, ...ecctrlProps }: KhrBodyProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SI first-person and third-person body dimensions and zero-allocation camera helpers
|
|
3
|
+
* for `@pinkaphant/ecctrl` `<Ecctrl>` and `<EcctrlCameraControls>`.
|
|
4
|
+
*/
|
|
5
|
+
export interface BodySiConstants {
|
|
6
|
+
/** `<Ecctrl capsuleHalfHeight>` in metres. */
|
|
7
|
+
readonly capsuleHalfHeight: number;
|
|
8
|
+
/** `<Ecctrl capsuleRadius>` in metres. */
|
|
9
|
+
readonly capsuleRadius: number;
|
|
10
|
+
/** `<Ecctrl floatHeight>` in metres. */
|
|
11
|
+
readonly floatHeight: number;
|
|
12
|
+
/** Eye height above the floor in metres. */
|
|
13
|
+
readonly eyeHeight: number;
|
|
14
|
+
/** Camera dolly distance in first person (metres). */
|
|
15
|
+
readonly firstPersonDistance: number;
|
|
16
|
+
/** Camera dolly distance in third person (metres). */
|
|
17
|
+
readonly thirdPersonDistance: number;
|
|
18
|
+
}
|
|
19
|
+
/** 1.75 m standing adult: 2 * 0.50 + 2 * 0.30 + 0.15. */
|
|
20
|
+
export declare const BODY_SI: BodySiConstants;
|
|
21
|
+
/** Ecctrl movement tuning for the standing SI body. */
|
|
22
|
+
export declare const BODY_MOVE_TUNE: Readonly<{
|
|
23
|
+
readonly maxWalkVel: 2.5;
|
|
24
|
+
readonly maxRunVel: 9;
|
|
25
|
+
readonly accDeltaTime: 0.96;
|
|
26
|
+
readonly decDeltaTime: 0.9;
|
|
27
|
+
readonly slideGripFactor: 1;
|
|
28
|
+
readonly moveImpulsePointOffset: 0;
|
|
29
|
+
readonly airDragFactor: 0.85;
|
|
30
|
+
readonly enableToggleRun: false;
|
|
31
|
+
}>;
|
|
32
|
+
export type BodySocketId = "Socket_Hand_R" | "Socket_Hand_L" | "Socket_Head" | "Socket_Back";
|
|
33
|
+
export declare const BODY_SOCKET_IDS: readonly BodySocketId[];
|
|
34
|
+
/** Rigid-body centre height when standing at rest on flat ground. */
|
|
35
|
+
export declare function bodyRestCenterY(b?: BodySiConstants): number;
|
|
36
|
+
/** Total standing height from floor to the top of the capsule. */
|
|
37
|
+
export declare function bodyStandingHeight(b?: BodySiConstants): number;
|
|
38
|
+
/** Camera target offset above the rigid-body centre. */
|
|
39
|
+
export declare function bodyEyeOffsetY(b?: BodySiConstants): number;
|
|
40
|
+
/** Spawn position whose feet rest on `floorY`. */
|
|
41
|
+
export declare function bodySpawnPosition(x: number, floorY: number, z: number, b?: BodySiConstants): [number, number, number];
|
|
42
|
+
/**
|
|
43
|
+
* Merges `ecctrl.excludeCharacterRay: true` into a RigidBody `userData` object for held-item colliders
|
|
44
|
+
* so `@pinkaphant/ecctrl` ground casts ignore held items (`collider.parent()?.userData`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function withExcludeCharacterRay(userData?: Record<string, unknown>): Record<string, unknown>;
|
|
47
|
+
/** Zero-allocation camera step sync from live handle position (and optional local Y axis) to camera controls at eye height. */
|
|
48
|
+
export declare function stepCameraSync(controls: {
|
|
49
|
+
moveTo?: (x: number, y: number, z: number, smooth: boolean) => unknown;
|
|
50
|
+
update?: (dt: number) => unknown;
|
|
51
|
+
} | null, pos: {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
z: number;
|
|
55
|
+
}, eyeOffsetY: number, smooth: boolean, bodyYAxis?: {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
z: number;
|
|
59
|
+
}): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { BODY_MOVE_TUNE, BODY_SI, BODY_SOCKET_IDS, bodyEyeOffsetY, bodyRestCenterY, bodySpawnPosition, bodyStandingHeight, stepCameraSync, withExcludeCharacterRay, type BodySiConstants, type BodySocketId, } from "./bodySi.js";
|
|
2
|
+
export { KhrBody, type KhrBodyHandle, type KhrBodyProps } from "./KhrBody.js";
|
|
3
|
+
export { HeldItem, type HeldItemHandle, type HeldItemProps } from "./HeldItem.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { r as BODY_MOVE_TUNE, i as BODY_SI, a as BODY_SOCKET_IDS, t as HeldItem, n as KhrBody, o as bodyEyeOffsetY, s as bodyRestCenterY, c as bodySpawnPosition, l as bodyStandingHeight, u as stepCameraSync, d as withExcludeCharacterRay } from "../body-B7FTf67o.js";
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { useContext as e, useEffect as t, useImperativeHandle as n, useLayoutEffect as r, useMemo as i, useRef as a } from "react";
|
|
2
|
+
import * as o from "three";
|
|
3
|
+
import { useFrame as s, useThree as c } from "@react-three/fiber";
|
|
4
|
+
import { JointRegistryContext as l, KhrCollider as u, KhrValidationError as d, claimBundleMount as f, releaseBundleMount as p } from "@khr3/core";
|
|
5
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
6
|
+
import { RigidBody as _ } from "@react-three/rapier";
|
|
7
|
+
import { Ecctrl as v } from "@pinkaphant/ecctrl";
|
|
8
|
+
import { EcctrlCameraControls as y } from "@pinkaphant/ecctrl/camera";
|
|
9
|
+
// src/body/bodySi.ts
|
|
10
|
+
var b = Object.freeze({
|
|
11
|
+
capsuleHalfHeight: .5,
|
|
12
|
+
capsuleRadius: .3,
|
|
13
|
+
floatHeight: .15,
|
|
14
|
+
eyeHeight: 1.62,
|
|
15
|
+
firstPersonDistance: .02,
|
|
16
|
+
thirdPersonDistance: 3.2
|
|
17
|
+
}), x = Object.freeze({
|
|
18
|
+
maxWalkVel: 2.5,
|
|
19
|
+
maxRunVel: 9,
|
|
20
|
+
accDeltaTime: .96,
|
|
21
|
+
decDeltaTime: .9,
|
|
22
|
+
slideGripFactor: 1,
|
|
23
|
+
moveImpulsePointOffset: 0,
|
|
24
|
+
airDragFactor: .85,
|
|
25
|
+
enableToggleRun: !1
|
|
26
|
+
}), S = Object.freeze([
|
|
27
|
+
"Socket_Hand_R",
|
|
28
|
+
"Socket_Hand_L",
|
|
29
|
+
"Socket_Head",
|
|
30
|
+
"Socket_Back"
|
|
31
|
+
]);
|
|
32
|
+
function C(e) {
|
|
33
|
+
for (let [t, n] of Object.entries(e)) if (!(typeof n == "number" && Number.isFinite(n) && n >= 0)) throw RangeError(`kolmo/body: ${t} must be a finite non-negative number, got ${String(n)}`);
|
|
34
|
+
if (!(e.capsuleRadius > 0)) throw RangeError("kolmo/body: capsuleRadius must be > 0");
|
|
35
|
+
}
|
|
36
|
+
function w(e = b) {
|
|
37
|
+
return C(e), e.floatHeight + e.capsuleRadius + e.capsuleHalfHeight;
|
|
38
|
+
}
|
|
39
|
+
function T(e = b) {
|
|
40
|
+
return w(e) + e.capsuleHalfHeight + e.capsuleRadius;
|
|
41
|
+
}
|
|
42
|
+
function E(e = b) {
|
|
43
|
+
let t = e.eyeHeight - w(e);
|
|
44
|
+
if (!(t > 0)) throw RangeError("kolmo/body: eyeHeight must sit above the body centre");
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
function D(e, t, n, r = b) {
|
|
48
|
+
return [
|
|
49
|
+
e,
|
|
50
|
+
t + w(r),
|
|
51
|
+
n
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
function O(e) {
|
|
55
|
+
let t = e?.ecctrl ?? {};
|
|
56
|
+
return {
|
|
57
|
+
...e ?? {},
|
|
58
|
+
ecctrl: {
|
|
59
|
+
...t,
|
|
60
|
+
excludeCharacterRay: !0
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function k(e, t, n, r, i) {
|
|
65
|
+
if (!e) return;
|
|
66
|
+
let a = i ? t.x + i.x * n : t.x, o = i ? t.y + i.y * n : t.y + n, s = i ? t.z + i.z * n : t.z;
|
|
67
|
+
e.moveTo?.(a, o, s, r), e.update?.(0);
|
|
68
|
+
}
|
|
69
|
+
// src/body/KhrBody.tsx
|
|
70
|
+
var A = Object.freeze({
|
|
71
|
+
Socket_Hand_R: [
|
|
72
|
+
.22,
|
|
73
|
+
-.18,
|
|
74
|
+
-.38
|
|
75
|
+
],
|
|
76
|
+
Socket_Hand_L: [
|
|
77
|
+
-.22,
|
|
78
|
+
-.18,
|
|
79
|
+
-.38
|
|
80
|
+
],
|
|
81
|
+
Socket_Head: [
|
|
82
|
+
0,
|
|
83
|
+
0,
|
|
84
|
+
-.12
|
|
85
|
+
],
|
|
86
|
+
Socket_Back: [
|
|
87
|
+
0,
|
|
88
|
+
-.25,
|
|
89
|
+
.28
|
|
90
|
+
]
|
|
91
|
+
}), j = {
|
|
92
|
+
forward: !1,
|
|
93
|
+
backward: !1,
|
|
94
|
+
leftward: !1,
|
|
95
|
+
rightward: !1,
|
|
96
|
+
run: !1,
|
|
97
|
+
jump: !1
|
|
98
|
+
};
|
|
99
|
+
function M({ active: e, ecctrlRef: n }) {
|
|
100
|
+
let r = a({
|
|
101
|
+
w: !1,
|
|
102
|
+
s: !1,
|
|
103
|
+
a: !1,
|
|
104
|
+
d: !1,
|
|
105
|
+
shift: !1,
|
|
106
|
+
space: !1,
|
|
107
|
+
dirty: !1
|
|
108
|
+
}), i = a(e);
|
|
109
|
+
return t(() => {
|
|
110
|
+
if (!e || typeof window > "u" || typeof window.addEventListener != "function") return;
|
|
111
|
+
let t = (e) => (t) => {
|
|
112
|
+
let n = r.current;
|
|
113
|
+
t.code === "KeyW" || t.code === "ArrowUp" ? n.w !== e && (n.w = e, n.dirty = !0) : t.code === "KeyS" || t.code === "ArrowDown" ? n.s !== e && (n.s = e, n.dirty = !0) : t.code === "KeyA" || t.code === "ArrowLeft" ? n.a !== e && (n.a = e, n.dirty = !0) : t.code === "KeyD" || t.code === "ArrowRight" ? n.d !== e && (n.d = e, n.dirty = !0) : t.code === "ShiftLeft" || t.code === "ShiftRight" ? n.shift !== e && (n.shift = e, n.dirty = !0) : t.code === "Space" && n.space !== e && (n.space = e, n.dirty = !0);
|
|
114
|
+
}, n = () => {
|
|
115
|
+
let e = r.current;
|
|
116
|
+
(e.w || e.s || e.a || e.d || e.shift || e.space) && (e.w = !1, e.s = !1, e.a = !1, e.d = !1, e.shift = !1, e.space = !1, e.dirty = !0);
|
|
117
|
+
}, i = t(!0), a = t(!1);
|
|
118
|
+
return window.addEventListener("keydown", i), window.addEventListener("keyup", a), window.addEventListener("blur", n), () => {
|
|
119
|
+
window.removeEventListener("keydown", i), window.removeEventListener("keyup", a), window.removeEventListener("blur", n);
|
|
120
|
+
};
|
|
121
|
+
}, [e]), s(() => {
|
|
122
|
+
let t = n.current;
|
|
123
|
+
if (!t) return;
|
|
124
|
+
if (!e) {
|
|
125
|
+
if (i.current) {
|
|
126
|
+
let e = r.current;
|
|
127
|
+
e.w = !1, e.s = !1, e.a = !1, e.d = !1, e.shift = !1, e.space = !1, e.dirty = !1, j.forward = !1, j.backward = !1, j.leftward = !1, j.rightward = !1, j.run = !1, j.jump = !1, t.setMovement(j), i.current = !1;
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
i.current = !0;
|
|
132
|
+
let a = r.current;
|
|
133
|
+
a.dirty && (a.dirty = !1, j.forward = a.w, j.backward = a.s, j.leftward = a.a, j.rightward = a.d, j.run = a.shift, j.jump = a.space, t.setMovement(j));
|
|
134
|
+
}), null;
|
|
135
|
+
}
|
|
136
|
+
function N({ ref: e, si: t = b, smoothCamera: r = !1, makeDefaultCamera: o = !0, enableInput: s = !0, enable: l = !0, viewModelChildren: u, socketOffsets: d, children: f, userData: p, position: _, ...C }) {
|
|
137
|
+
let T = a(null), D = a(null), O = a(null), j = a({
|
|
138
|
+
Socket_Hand_R: null,
|
|
139
|
+
Socket_Hand_L: null,
|
|
140
|
+
Socket_Head: null,
|
|
141
|
+
Socket_Back: null
|
|
142
|
+
}), N = i(() => E(t), [t]), F = i(() => [
|
|
143
|
+
0,
|
|
144
|
+
w(t),
|
|
145
|
+
0
|
|
146
|
+
], [t]), I = c((e) => typeof e.gl?.domElement?.setAttribute == "function"), L = i(() => {
|
|
147
|
+
let e = p ?? {}, t = e.ecctrl ?? {};
|
|
148
|
+
return {
|
|
149
|
+
...e,
|
|
150
|
+
ecctrl: {
|
|
151
|
+
excludeVehicleRay: !0,
|
|
152
|
+
...t
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}, [p]);
|
|
156
|
+
return n(e, () => ({
|
|
157
|
+
get ecctrl() {
|
|
158
|
+
return T.current;
|
|
159
|
+
},
|
|
160
|
+
get cameraControls() {
|
|
161
|
+
return D.current;
|
|
162
|
+
},
|
|
163
|
+
socket(e) {
|
|
164
|
+
return j.current[e] ?? null;
|
|
165
|
+
},
|
|
166
|
+
syncCameraStep(e) {
|
|
167
|
+
k(D.current, e, N, r, T.current?.bodyYAxis);
|
|
168
|
+
}
|
|
169
|
+
}), [N, r]), /* @__PURE__ */ g(m, { children: [
|
|
170
|
+
/* @__PURE__ */ h(M, {
|
|
171
|
+
active: !!(l && s),
|
|
172
|
+
ecctrlRef: T
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ h(v, {
|
|
175
|
+
ref: T,
|
|
176
|
+
enable: l,
|
|
177
|
+
position: _ ?? F,
|
|
178
|
+
capsuleHalfHeight: t.capsuleHalfHeight,
|
|
179
|
+
capsuleRadius: t.capsuleRadius,
|
|
180
|
+
floatHeight: t.floatHeight,
|
|
181
|
+
maxWalkVel: x.maxWalkVel,
|
|
182
|
+
maxRunVel: x.maxRunVel,
|
|
183
|
+
accDeltaTime: x.accDeltaTime,
|
|
184
|
+
decDeltaTime: x.decDeltaTime,
|
|
185
|
+
slideGripFactor: x.slideGripFactor,
|
|
186
|
+
moveImpulsePointOffset: x.moveImpulsePointOffset,
|
|
187
|
+
airDragFactor: x.airDragFactor,
|
|
188
|
+
enableToggleRun: x.enableToggleRun,
|
|
189
|
+
...C,
|
|
190
|
+
userData: L,
|
|
191
|
+
children: f
|
|
192
|
+
}),
|
|
193
|
+
I ? /* @__PURE__ */ h(y, {
|
|
194
|
+
ref: D,
|
|
195
|
+
makeDefault: o
|
|
196
|
+
}) : null,
|
|
197
|
+
/* @__PURE__ */ h(P, {
|
|
198
|
+
enable: l,
|
|
199
|
+
ecctrlRef: T,
|
|
200
|
+
camControlsRef: D,
|
|
201
|
+
viewModelGroupRef: O,
|
|
202
|
+
eyeOffsetY: N,
|
|
203
|
+
smoothCamera: r
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ g("group", {
|
|
206
|
+
ref: O,
|
|
207
|
+
name: "KhrBody_ViewModel",
|
|
208
|
+
children: [S.map((e) => {
|
|
209
|
+
let t = d?.[e] ?? A[e];
|
|
210
|
+
return /* @__PURE__ */ h("group", {
|
|
211
|
+
name: e,
|
|
212
|
+
position: [
|
|
213
|
+
t[0],
|
|
214
|
+
t[1],
|
|
215
|
+
t[2]
|
|
216
|
+
],
|
|
217
|
+
ref: (t) => {
|
|
218
|
+
j.current[e] = t;
|
|
219
|
+
}
|
|
220
|
+
}, e);
|
|
221
|
+
}), u]
|
|
222
|
+
})
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
225
|
+
function P({ enable: e, ecctrlRef: t, camControlsRef: n, viewModelGroupRef: r, eyeOffsetY: i, smoothCamera: a }) {
|
|
226
|
+
return s((o) => {
|
|
227
|
+
if (!e) return;
|
|
228
|
+
let s = t.current;
|
|
229
|
+
s && k(n.current, s.currPos, i, a, s.bodyYAxis);
|
|
230
|
+
let c = r.current;
|
|
231
|
+
c && (c.position.copy(o.camera.position), c.quaternion.copy(o.camera.quaternion));
|
|
232
|
+
}), null;
|
|
233
|
+
}
|
|
234
|
+
// src/body/HeldItem.tsx
|
|
235
|
+
var F = new o.Vector3(), I = new o.Vector3(), L = new o.Quaternion(), R = new o.Vector3(), z = new o.Quaternion(), B = 1e5;
|
|
236
|
+
function V(e, t) {
|
|
237
|
+
if (t.kind === "fixed") return 0;
|
|
238
|
+
if (t.kind === "prismatic") return e.mass > 0 ? e.mass : 1;
|
|
239
|
+
F.fromArray(t.axis).normalize(), L.fromArray(e.inertiaOrientation).invert();
|
|
240
|
+
let n = F.clone().applyQuaternion(L), [r, i, a] = e.inertiaDiagonal, o = r * n.x * n.x + i * n.y * n.y + a * n.z * n.z;
|
|
241
|
+
I.fromArray(e.centerOfMass);
|
|
242
|
+
let s = I.dot(F), c = o + e.mass * (I.lengthSq() - s * s);
|
|
243
|
+
return c > 0 ? c : 1;
|
|
244
|
+
}
|
|
245
|
+
var H = (e) => new o.Matrix4().compose(new o.Vector3().fromArray(e.localPosition), new o.Quaternion().fromArray(e.localQuaternion), new o.Vector3(1, 1, 1));
|
|
246
|
+
function U({ ref: t, bundle: c, socket: v, bodyRef: y, parentSocketObject: b, userData: x }) {
|
|
247
|
+
let S = e(l), C = i(() => B++, []), w = a(null), T = a(null), E = a(/* @__PURE__ */ new Map()), D = i(() => O(x), [x]), k = i(() => {
|
|
248
|
+
let e = [];
|
|
249
|
+
for (let t of c.bodies) for (let n = 0; n < t.colliders.length; n++) {
|
|
250
|
+
let r = t.colliders[n], i = new o.Matrix4().compose(new o.Vector3().fromArray(r.localPosition), new o.Quaternion().fromArray(r.localQuaternion), new o.Vector3(1, 1, 1));
|
|
251
|
+
e.push({
|
|
252
|
+
key: `${t.nodeName}:${n}`,
|
|
253
|
+
nodeName: t.nodeName,
|
|
254
|
+
spec: r,
|
|
255
|
+
local: i,
|
|
256
|
+
ref: { current: null }
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return e;
|
|
260
|
+
}, [c]);
|
|
261
|
+
return r(() => {
|
|
262
|
+
f(c, "HeldItem");
|
|
263
|
+
let e = c.scene.position.clone(), t = c.scene.quaternion.clone(), n = c.scene.parent, r = c.sockets.grip_primary ?? c.sockets.IK_Palm_Primary;
|
|
264
|
+
r ? c.scene.position.set(-r[0], -r[1], -r[2]) : c.scene.position.set(0, 0, 0);
|
|
265
|
+
let i = b ?? y?.current?.socket(v) ?? T.current;
|
|
266
|
+
i && c.scene.parent !== i && i.add(c.scene);
|
|
267
|
+
let a = new Map(c.bodies.map((e) => [e.nodeName, e])), s = c.bodies.find((e) => !e.joint) ?? c.bodies[0], l = s ? H(s).invert() : new o.Matrix4(), u = /* @__PURE__ */ new Map();
|
|
268
|
+
for (let e of c.bodies) {
|
|
269
|
+
let t = e.joint;
|
|
270
|
+
if (!t) continue;
|
|
271
|
+
let n = a.get(t.connectedNodeName), r = l.clone().multiply(H(e)), i = n && n.joint ? H(n).invert().multiply(H(e)) : r, s = k.filter((t) => t.nodeName === e.nodeName).map((e) => ({
|
|
272
|
+
ref: e.ref,
|
|
273
|
+
local: e.local
|
|
274
|
+
})), c = t.drive, d = {
|
|
275
|
+
assemblyId: C,
|
|
276
|
+
nodeName: e.nodeName,
|
|
277
|
+
role: t.role ?? e.role,
|
|
278
|
+
kind: t.kind,
|
|
279
|
+
object: e.object,
|
|
280
|
+
axis: new o.Vector3().fromArray(t.axis).normalize(),
|
|
281
|
+
restPosition: e.object.position.clone(),
|
|
282
|
+
restQuaternion: e.object.quaternion.clone(),
|
|
283
|
+
q: 0,
|
|
284
|
+
v: 0,
|
|
285
|
+
positionTarget: c?.positionTarget ?? null,
|
|
286
|
+
velocityTarget: c?.velocityTarget ?? 0,
|
|
287
|
+
drive: c,
|
|
288
|
+
limits: t.limits ? [t.limits[0], t.limits[1]] : null,
|
|
289
|
+
limitStiffness: t.limitStiffness ?? null,
|
|
290
|
+
limitDamping: t.limitDamping ?? 0,
|
|
291
|
+
inertia: V(e, t),
|
|
292
|
+
parent: null,
|
|
293
|
+
restRelParent: i,
|
|
294
|
+
current: i.clone(),
|
|
295
|
+
stamp: -1,
|
|
296
|
+
colliders: s
|
|
297
|
+
};
|
|
298
|
+
u.set(d.nodeName, d);
|
|
299
|
+
}
|
|
300
|
+
for (let e of c.bodies) {
|
|
301
|
+
if (!e.joint) continue;
|
|
302
|
+
let t = u.get(e.nodeName);
|
|
303
|
+
t.parent = u.get(e.joint.connectedNodeName) ?? null, S?.add(t);
|
|
304
|
+
}
|
|
305
|
+
return E.current = u, () => {
|
|
306
|
+
for (let e of u.values()) S?.delete(e), e.object.position.copy(e.restPosition), e.object.quaternion.copy(e.restQuaternion);
|
|
307
|
+
E.current = /* @__PURE__ */ new Map(), c.scene.parent && c.scene.parent.remove(c.scene), n && n.add(c.scene), c.scene.position.copy(e), c.scene.quaternion.copy(t), p(c);
|
|
308
|
+
};
|
|
309
|
+
}, [
|
|
310
|
+
c,
|
|
311
|
+
v,
|
|
312
|
+
y,
|
|
313
|
+
b,
|
|
314
|
+
S,
|
|
315
|
+
C,
|
|
316
|
+
k
|
|
317
|
+
]), s(() => {
|
|
318
|
+
let e = w.current, t = b ?? y?.current?.socket(v) ?? T.current;
|
|
319
|
+
e && t && (c.scene.parent !== t && t.add(c.scene), c.scene.getWorldPosition(R), c.scene.getWorldQuaternion(z), e.setNextKinematicTranslation(R), e.setNextKinematicRotation(z));
|
|
320
|
+
}), n(t, () => {
|
|
321
|
+
let e = (e, t) => {
|
|
322
|
+
if (!e.drive || e.drive.stiffness === void 0) throw new d(`Joint "${e.nodeName}" has no authored drive stiffness; cannot set a position target`);
|
|
323
|
+
let n = e.limits ? Math.max(e.limits[0], Math.min(e.limits[1], t)) : t;
|
|
324
|
+
return e.positionTarget = n, n;
|
|
325
|
+
};
|
|
326
|
+
return {
|
|
327
|
+
socket: v,
|
|
328
|
+
get rigidBody() {
|
|
329
|
+
return w.current;
|
|
330
|
+
},
|
|
331
|
+
setJointTarget(t, n) {
|
|
332
|
+
let r = E.current.get(t);
|
|
333
|
+
if (!r) throw new d(`kolmo/body: HeldItem has no joint named "${t}"`);
|
|
334
|
+
return e(r, n);
|
|
335
|
+
},
|
|
336
|
+
setRoleTarget(t, n) {
|
|
337
|
+
let r = !1, i = n;
|
|
338
|
+
for (let a of E.current.values()) a.role === t && (i = e(a, n), r = !0);
|
|
339
|
+
if (!r) throw new d(`kolmo/body: HeldItem has no joint with role "${t}"`);
|
|
340
|
+
return i;
|
|
341
|
+
},
|
|
342
|
+
getRoleValue(e) {
|
|
343
|
+
for (let t of E.current.values()) if (t.role === e) return t.q;
|
|
344
|
+
throw new d(`kolmo/body: HeldItem has no joint with role "${e}"`);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}, [v]), /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("group", {
|
|
348
|
+
ref: T,
|
|
349
|
+
name: `HeldItem_Fallback_${v}`
|
|
350
|
+
}), /* @__PURE__ */ h(_, {
|
|
351
|
+
ref: w,
|
|
352
|
+
type: "kinematicPosition",
|
|
353
|
+
colliders: !1,
|
|
354
|
+
sensor: !0,
|
|
355
|
+
userData: D,
|
|
356
|
+
children: k.map((e) => /* @__PURE__ */ h(u, {
|
|
357
|
+
ref: e.ref,
|
|
358
|
+
c: e.spec
|
|
359
|
+
}, e.key))
|
|
360
|
+
})] });
|
|
361
|
+
}
|
|
362
|
+
export { S as a, D as c, O as d, b as i, T as l, N as n, E as o, x as r, w as s, U as t, k as u };
|
package/dist/importer/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as e, i as t, o as n, s as r } from "../kolmoSurface-DTnrFXH0.js";
|
|
2
|
-
import { $ as i, A as a, B as o, C as s, D as c, E as l, F as u, G as d, H as f, I as p, J as m, K as h, L as g, M as _, N as v, O as y, P as b, Q as x, R as S, S as C, T as w, U as T, V as E, W as D, X as O, Y as k, Z as ee, _ as A, a as j, b as M, c as N, d as P, et as F, f as I, g as L, h as R, i as z, j as B, k as V, l as H, m as U, n as W, nt as G, o as K, p as q, q as J, r as Y, s as X, t as Z, tt as Q, u as $, v as te, w as ne, x as re, y as ie, z as ae } from "../importer-
|
|
2
|
+
import { $ as i, A as a, B as o, C as s, D as c, E as l, F as u, G as d, H as f, I as p, J as m, K as h, L as g, M as _, N as v, O as y, P as b, Q as x, R as S, S as C, T as w, U as T, V as E, W as D, X as O, Y as k, Z as ee, _ as A, a as j, b as M, c as N, d as P, et as F, f as I, g as L, h as R, i as z, j as B, k as V, l as H, m as U, n as W, nt as G, o as K, p as q, q as J, r as Y, s as X, t as Z, tt as Q, u as $, v as te, w as ne, x as re, y as ie, z as ae } from "../importer-B2-S-N_e.js";
|
|
3
3
|
export { N as C12_TICK_M, D as CHOP_ROLES, v as ChopShopPanel, ne as DAMP_ZETA, V as DomainWorkshopPanel, w as FREQ_HZ, s as GateHudBar, Z as GlbImportGate, Z as ImporterWorkbench, X as ImperativeVehicleRig, te as Step1CalibrationPlinth, K as Step2UniversalPad, H as UNIFIED_ANCHOR_NAMES, j as VfxEmitterPool, B as bakeArticulatedLauncherGlb, W as bakeUniversalGateGlb, M as buildImporterWebMcpTools, _ as buildLauncherSceneFromPlan, t as buildPatchPreviewEmitters, u as buildSelectionOverlayGeometry, d as buildSurfaceTopology, b as compileKhrAssetGlb, $ as computeC12Metrics, e as computeChopPartHinge, Y as convertUsdToGlb, p as createFleet12GonWheelGroup, n as createVehiclePanelAnimator, P as defaultTargetMeters, I as detectSceneAnchors, a as enforceRetroPersonMaterials, k as extractMeshIslands, g as findMirrorIslandId, h as floodFillByCrease, l as gateTelemetry, J as getIslandTopology, re as getNavigatorModelContext, c as isGateStep1Unlocked, z as isUsdFileName, q as khrBoxToRapierHalfExtents, ie as makeStarterDomainScene, U as measureAssemblyCalibration, R as measureNormalizedSceneCalibration, i as measureSelection, m as mirrorTriangles, r as normalToMinusZQuaternion, O as normalizeSceneToSi, S as peelIslandSelection, ae as previewLoopPolyline, o as refineMeshAlongLoop, E as remapIslandIds, f as selectFacesByClick, T as selectFacesByLoop, ee as separateVehicleMeshes, x as sliceMeshTriangles, L as snapMetersToC12, F as suggestCarAxles, Q as suggestMotorcycleWheels, G as toggleIslandSelection, y as useGateStore, C as useImporterWebMcp, A as wrapSingleMeshWithPaperShellProxy };
|