@pinkaphant/kolmo 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/kolmo.mjs +1 -1
- package/dist/engine/kolmoActor.js +125 -83
- package/dist/engine/kolmoLongDrive.js +136 -91
- package/dist/engine/kolmoStore.d.ts +6 -5
- package/dist/engine/kolmoStore.js +115 -79
- package/dist/engine/kolmoVehicle.d.ts +1 -1
- package/dist/engine/kolmoVehicle.js +160 -147
- package/dist/engine/kolmoVehicleDriver.d.ts +12 -4
- package/dist/engine/kolmoVehicleDriver.js +40 -20
- package/dist/engine/kolmoWorld.js +55 -35
- package/dist/importer/CabinPreviewRig.d.ts +13 -0
- package/dist/importer/CabinPreviewRig.js +138 -0
- package/dist/importer/CabinStepSection.d.ts +17 -0
- package/dist/importer/CabinStepSection.js +222 -0
- package/dist/importer/ChopShopPanel.d.ts +31 -1
- package/dist/importer/ChopShopPanel.js +474 -380
- package/dist/importer/GateHudBar.d.ts +3 -0
- package/dist/importer/GateHudBar.js +8 -2
- package/dist/importer/GlbImportGate.js +183 -147
- package/dist/importer/ImporterPlinthUikitTags.d.ts +2 -1
- package/dist/importer/ImporterPlinthUikitTags.js +23 -16
- package/dist/importer/Step1CalibrationPlinth.d.ts +10 -0
- package/dist/importer/Step1CalibrationPlinth.js +203 -141
- package/dist/importer/Step2UniversalPad.d.ts +8 -1
- package/dist/importer/Step2UniversalPad.js +112 -90
- package/dist/importer/cabinMeshBuilders.d.ts +13 -0
- package/dist/importer/cabinMeshBuilders.js +104 -0
- package/dist/importer/cabinMixamoRig.d.ts +53 -0
- package/dist/importer/cabinMixamoRig.js +150 -0
- package/dist/importer/chopShopActions.d.ts +6 -0
- package/dist/importer/chopShopActions.js +86 -61
- package/dist/importer/chopShopUiComponents.d.ts +22 -0
- package/dist/importer/chopShopUiComponents.js +91 -0
- package/dist/importer/gateStore.d.ts +5 -2
- package/dist/importer/gateStore.js +13 -10
- package/dist/importer/glbNormalizer.d.ts +10 -1
- package/dist/importer/glbNormalizer.js +114 -49
- package/dist/importer/importerWebMcp.js +4 -1
- package/dist/importer/index.d.ts +4 -2
- package/dist/importer/index.js +24 -21
- package/dist/importer/khrCompiler.d.ts +20 -1
- package/dist/importer/khrCompiler.js +539 -290
- package/dist/importer/launcherBake.js +12 -8
- package/dist/importer/meshIslands.d.ts +4 -0
- package/dist/importer/meshIslands.js +104 -99
- package/dist/importer/surfaceCutter.d.ts +12 -3
- package/dist/importer/surfaceCutter.js +220 -127
- package/dist/importer/surfaceTopology.d.ts +13 -2
- package/dist/importer/surfaceTopology.js +57 -29
- package/dist/importer/universalGateBake.d.ts +7 -1
- package/dist/importer/universalGateBake.js +63 -60
- package/dist/importer/usdToGlb.js +19 -7
- package/dist/importer/useChopShopController.d.ts +27 -1
- package/dist/importer/useChopShopController.js +369 -255
- package/dist/importer/wheelAxlePairing.d.ts +3 -1
- package/dist/importer/wheelAxlePairing.js +82 -33
- package/dist/index.js +31 -28
- package/dist/junk/ShardPieces.js +3 -3
- package/dist/physics/index.d.ts +7 -0
- package/dist/physics/index.js +66 -40
- package/package.json +1 -1
|
@@ -1,106 +1,115 @@
|
|
|
1
1
|
import { togglePropJoint as e } from "../engine/kolmoSurface.js";
|
|
2
2
|
import { createDefaultSignals as t } from "../schema/kolmoSchema.js";
|
|
3
3
|
import { KolmoEmitterRig as n } from "../shaders/plumeAndSparkle.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
4
|
+
import { CabinPreviewRig as r } from "./CabinPreviewRig.js";
|
|
5
|
+
import { ImperativeVehicleRig as i } from "./ImperativeVehicleRig.js";
|
|
6
|
+
import { gateTelemetry as a, useGateStore as o } from "./gateStore.js";
|
|
7
|
+
import { buildPatchPreviewEmitters as s, createVehiclePanelAnimator as c } from "./vehiclePanelAnim.js";
|
|
8
|
+
import { useEffect as l, useMemo as u, useRef as d } from "react";
|
|
9
|
+
import * as f from "three";
|
|
10
|
+
import { useFrame as p } from "@react-three/fiber";
|
|
11
|
+
import { KhrAssembly as m, PhysicsWorld as h, cloneKhrBundle as g } from "@khr3/core";
|
|
12
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
13
|
+
import { CuboidCollider as y, CylinderCollider as b, RigidBody as x } from "@react-three/rapier";
|
|
14
|
+
import { KhrVehicle as S } from "@khr3/core/vehicle";
|
|
15
|
+
import { easing as C } from "maath";
|
|
15
16
|
// src/importer/Step2UniversalPad.tsx
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
let
|
|
17
|
+
var w = new f.Vector3(), T = new f.Vector3(0, 1, 0), E = new f.Vector3(), D = new f.Vector3();
|
|
18
|
+
function O({ bundle: e, subArchetype: i, patches: m, stampActive: h, panelAnimRef: y, cabin: b, carBounds: x, showDriver: O, onStampSurface: k }) {
|
|
19
|
+
let A = d(null), j = o((e) => e.chaseCam), M = d(o.getState().dropTrigger), N = d({
|
|
19
20
|
w: !1,
|
|
20
21
|
s: !1,
|
|
21
22
|
a: !1,
|
|
22
23
|
d: !1,
|
|
23
24
|
space: !1,
|
|
24
25
|
shift: !1
|
|
25
|
-
}),
|
|
26
|
+
}), P = d(new f.Vector3(0, 1, 4)), F = d({
|
|
26
27
|
...t(),
|
|
27
28
|
throttle: 0,
|
|
28
29
|
boost: 0,
|
|
29
30
|
brake: 0,
|
|
30
31
|
headlight: 1,
|
|
31
32
|
always: 1
|
|
32
|
-
}),
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
}), [
|
|
36
|
-
|
|
33
|
+
}), I = u(() => g(e), [e]), L = u(() => s(m), [m]), R = u(() => c(I), [I]);
|
|
34
|
+
return l(() => (y.current = R, () => {
|
|
35
|
+
y.current === R && (y.current = null);
|
|
36
|
+
}), [R, y]), l(() => {
|
|
37
|
+
a.massKg = I.totalDynamicMass, a.com = [...I.centerOfMass];
|
|
37
38
|
let e = (e) => (t) => {
|
|
38
|
-
(t.code === "KeyW" || t.code === "ArrowUp") && (
|
|
39
|
+
(t.code === "KeyW" || t.code === "ArrowUp") && (N.current.w = e), (t.code === "KeyS" || t.code === "ArrowDown") && (N.current.s = e), (t.code === "KeyA" || t.code === "ArrowLeft") && (N.current.a = e), (t.code === "KeyD" || t.code === "ArrowRight") && (N.current.d = e), t.code === "Space" && (N.current.space = e), (t.code === "ShiftLeft" || t.code === "ShiftRight") && (N.current.shift = e);
|
|
39
40
|
}, t = e(!0), n = e(!1);
|
|
40
41
|
return window.addEventListener("keydown", t), window.addEventListener("keyup", n), () => {
|
|
41
42
|
window.removeEventListener("keydown", t), window.removeEventListener("keyup", n);
|
|
42
43
|
};
|
|
43
|
-
}, [
|
|
44
|
+
}, [I]), p((e, t) => {
|
|
44
45
|
let n = Math.min(Math.max(t, 1e-4), .05);
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
if (!
|
|
48
|
-
let s =
|
|
49
|
-
s !==
|
|
46
|
+
R.step(n);
|
|
47
|
+
let r = A.current;
|
|
48
|
+
if (!r?.body) return;
|
|
49
|
+
let s = o.getState().dropTrigger;
|
|
50
|
+
s !== M.current && (M.current = s, r.body.setTranslation({
|
|
50
51
|
x: 0,
|
|
51
52
|
y: 1.35,
|
|
52
53
|
z: 0
|
|
53
|
-
}, !0),
|
|
54
|
+
}, !0), r.body.setRotation({
|
|
54
55
|
x: 0,
|
|
55
56
|
y: 0,
|
|
56
57
|
z: 0,
|
|
57
58
|
w: 1
|
|
58
|
-
}, !0),
|
|
59
|
+
}, !0), r.body.setLinvel({
|
|
59
60
|
x: 0,
|
|
60
61
|
y: 0,
|
|
61
62
|
z: 0
|
|
62
|
-
}, !0),
|
|
63
|
+
}, !0), r.body.setAngvel({
|
|
63
64
|
x: 0,
|
|
64
65
|
y: 0,
|
|
65
66
|
z: 0
|
|
66
67
|
}, !0));
|
|
67
|
-
let c =
|
|
68
|
-
|
|
68
|
+
let c = N.current;
|
|
69
|
+
i === "starcraft" || I.propellers.length > 0 && I.wheels.length === 0 ? r.setMovement({
|
|
69
70
|
pitchForward: c.w,
|
|
70
71
|
pitchBackward: c.s,
|
|
71
72
|
yawLeft: c.a,
|
|
72
73
|
yawRight: c.d,
|
|
73
|
-
throttleUp: c.space
|
|
74
|
-
|
|
74
|
+
throttleUp: c.space,
|
|
75
|
+
throttleDown: c.shift
|
|
76
|
+
}) : r.setMovement({
|
|
75
77
|
forward: c.w,
|
|
76
78
|
backward: c.s,
|
|
77
79
|
steerLeft: c.a,
|
|
78
80
|
steerRight: c.d,
|
|
79
|
-
brake: c.space
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
brake: c.space,
|
|
82
|
+
...I.propellers.length > 0 ? { throttleUp: c.shift } : {}
|
|
83
|
+
});
|
|
84
|
+
let l = F.current;
|
|
85
|
+
l.throttle = +!!c.w, l.boost = c.w && c.shift ? 1 : 0, l.brake = c.space || c.s ? 1 : 0, a.speedKmh = r.currLinVel.length() * 3.6, a.rpm = Math.max(850, r.engineRPM), j && !h && (w.copy(r.bodyZAxis).projectOnPlane(T), w.lengthSq() < 1e-6 ? w.set(0, 0, 1) : w.normalize(), E.copy(r.currPos).addScaledVector(w, -6.8).addScaledVector(T, 2.25), D.copy(r.currPos).addScaledVector(w, 3.5).addScaledVector(T, .65), C.damp3(e.camera.position, E, .14, n), C.damp3(P.current, D, .08, n), e.camera.lookAt(P.current));
|
|
86
|
+
}), /* @__PURE__ */ _("group", {
|
|
84
87
|
onClick: (e) => {
|
|
85
|
-
|
|
88
|
+
h ? k(e) : e.delta <= 5 && R.toggleHitObject(e.object) && e.stopPropagation();
|
|
86
89
|
},
|
|
87
|
-
children: /* @__PURE__ */
|
|
88
|
-
ref:
|
|
89
|
-
bundle:
|
|
90
|
+
children: /* @__PURE__ */ v(S, {
|
|
91
|
+
ref: A,
|
|
92
|
+
bundle: I,
|
|
90
93
|
position: [
|
|
91
94
|
0,
|
|
92
|
-
|
|
95
|
+
i === "starcraft" ? 1.4 : .35,
|
|
93
96
|
0
|
|
94
97
|
],
|
|
95
|
-
children: /* @__PURE__ */
|
|
96
|
-
emitters:
|
|
97
|
-
signalsRef:
|
|
98
|
-
})
|
|
98
|
+
children: [/* @__PURE__ */ _(n, {
|
|
99
|
+
emitters: L,
|
|
100
|
+
signalsRef: F
|
|
101
|
+
}), O && b?.enabled && x && /* @__PURE__ */ _(r, {
|
|
102
|
+
cabin: b,
|
|
103
|
+
carBounds: x,
|
|
104
|
+
showTub: !1,
|
|
105
|
+
showDummy: !0,
|
|
106
|
+
showSockets: !1
|
|
107
|
+
})]
|
|
99
108
|
})
|
|
100
109
|
});
|
|
101
110
|
}
|
|
102
|
-
function
|
|
103
|
-
let
|
|
111
|
+
function k({ bundle: r, domain: i, staticProp: c, patches: f, onStampSurface: p }) {
|
|
112
|
+
let h = d(null), y = d(!1), b = o((e) => e.dropTrigger), x = d({
|
|
104
113
|
...t(),
|
|
105
114
|
throttle: .9,
|
|
106
115
|
boost: 1,
|
|
@@ -108,15 +117,15 @@ function O({ bundle: r, domain: s, staticProp: d, patches: f, onStampSurface: m
|
|
|
108
117
|
headlight: 1,
|
|
109
118
|
fire: 1,
|
|
110
119
|
always: 1
|
|
111
|
-
}), S =
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
}, [S]), /* @__PURE__ */
|
|
120
|
+
}), S = u(() => g(r), [r, b]), C = u(() => s(f), [f]), w = i === "c12" || i === "prop" && c;
|
|
121
|
+
return l(() => {
|
|
122
|
+
a.massKg = S.totalDynamicMass, a.com = [...S.centerOfMass], a.speedKmh = 0;
|
|
123
|
+
}, [S]), /* @__PURE__ */ v("group", {
|
|
115
124
|
onClick: (t) => {
|
|
116
|
-
|
|
125
|
+
p(t), y.current = e(h.current, S, y.current);
|
|
117
126
|
},
|
|
118
|
-
children: [/* @__PURE__ */
|
|
119
|
-
ref:
|
|
127
|
+
children: [/* @__PURE__ */ _(m, {
|
|
128
|
+
ref: h,
|
|
120
129
|
bundle: S,
|
|
121
130
|
position: [
|
|
122
131
|
0,
|
|
@@ -124,22 +133,22 @@ function O({ bundle: r, domain: s, staticProp: d, patches: f, onStampSurface: m
|
|
|
124
133
|
0
|
|
125
134
|
],
|
|
126
135
|
fixedRoot: w
|
|
127
|
-
}, `asm_${b}`), /* @__PURE__ */
|
|
136
|
+
}, `asm_${b}`), /* @__PURE__ */ _(n, {
|
|
128
137
|
emitters: C,
|
|
129
138
|
signalsRef: x
|
|
130
139
|
})]
|
|
131
140
|
});
|
|
132
141
|
}
|
|
133
|
-
function
|
|
134
|
-
let
|
|
135
|
-
return /* @__PURE__ */
|
|
142
|
+
function A({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: r, patches: a, stampActive: s, panelAnimRef: c, cabin: l, carBounds: u, showDriver: d, onStampSurface: f }) {
|
|
143
|
+
let p = o((e) => e.domain), m = o((e) => e.vehicleArchetype), g = o((e) => e.usePaperShellProxy), S = o((e) => e.staticProp);
|
|
144
|
+
return /* @__PURE__ */ v(h, {
|
|
136
145
|
gravity: [
|
|
137
146
|
0,
|
|
138
147
|
-9.81,
|
|
139
148
|
0
|
|
140
149
|
],
|
|
141
150
|
children: [
|
|
142
|
-
/* @__PURE__ */
|
|
151
|
+
/* @__PURE__ */ _(x, {
|
|
143
152
|
type: "fixed",
|
|
144
153
|
position: [
|
|
145
154
|
0,
|
|
@@ -147,7 +156,7 @@ function k({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: i, patches
|
|
|
147
156
|
0
|
|
148
157
|
],
|
|
149
158
|
colliders: !1,
|
|
150
|
-
children: /* @__PURE__ */
|
|
159
|
+
children: /* @__PURE__ */ _(y, {
|
|
151
160
|
args: [
|
|
152
161
|
180,
|
|
153
162
|
.25,
|
|
@@ -156,7 +165,7 @@ function k({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: i, patches
|
|
|
156
165
|
friction: .92
|
|
157
166
|
})
|
|
158
167
|
}),
|
|
159
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ v("mesh", {
|
|
160
169
|
rotation: [
|
|
161
170
|
-Math.PI * .5,
|
|
162
171
|
0,
|
|
@@ -168,12 +177,12 @@ function k({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: i, patches
|
|
|
168
177
|
0
|
|
169
178
|
],
|
|
170
179
|
receiveShadow: !0,
|
|
171
|
-
children: [/* @__PURE__ */
|
|
180
|
+
children: [/* @__PURE__ */ _("planeGeometry", { args: [360, 360] }), /* @__PURE__ */ _("meshStandardMaterial", {
|
|
172
181
|
color: "#11161d",
|
|
173
182
|
roughness: .95
|
|
174
183
|
})]
|
|
175
184
|
}),
|
|
176
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ _(x, {
|
|
177
186
|
type: "fixed",
|
|
178
187
|
position: [
|
|
179
188
|
0,
|
|
@@ -186,11 +195,11 @@ function k({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: i, patches
|
|
|
186
195
|
0
|
|
187
196
|
],
|
|
188
197
|
colliders: "cuboid",
|
|
189
|
-
children: /* @__PURE__ */
|
|
198
|
+
children: /* @__PURE__ */ v("mesh", { children: [/* @__PURE__ */ _("boxGeometry", { args: [
|
|
190
199
|
4.4,
|
|
191
200
|
.22,
|
|
192
201
|
6.2
|
|
193
|
-
] }), /* @__PURE__ */
|
|
202
|
+
] }), /* @__PURE__ */ _("meshStandardMaterial", {
|
|
194
203
|
color: "#f59e0b",
|
|
195
204
|
roughness: .75,
|
|
196
205
|
flatShading: !0
|
|
@@ -204,41 +213,54 @@ function k({ assembly: e, importedRoot: t, rootObjRef: n, liveBundle: i, patches
|
|
|
204
213
|
24,
|
|
205
214
|
36,
|
|
206
215
|
48
|
|
207
|
-
].map((t) => /* @__PURE__ */
|
|
216
|
+
].map((t) => /* @__PURE__ */ v(x, {
|
|
217
|
+
type: "dynamic",
|
|
218
|
+
mass: 2.2,
|
|
208
219
|
position: [
|
|
209
220
|
e,
|
|
210
221
|
.35,
|
|
211
222
|
t
|
|
212
223
|
],
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
colliders: !1,
|
|
225
|
+
children: [/* @__PURE__ */ _(b, {
|
|
226
|
+
args: [.35, .24],
|
|
227
|
+
friction: .65,
|
|
228
|
+
restitution: .15
|
|
229
|
+
}), /* @__PURE__ */ v("mesh", {
|
|
230
|
+
castShadow: !0,
|
|
231
|
+
children: [/* @__PURE__ */ _("coneGeometry", { args: [
|
|
232
|
+
.28,
|
|
233
|
+
.7,
|
|
234
|
+
8
|
|
235
|
+
] }), /* @__PURE__ */ _("meshStandardMaterial", {
|
|
236
|
+
color: "#ff5a1f",
|
|
237
|
+
roughness: .6,
|
|
238
|
+
flatShading: !0
|
|
239
|
+
})]
|
|
221
240
|
})]
|
|
222
241
|
}, `cone_${e}_${t}`))),
|
|
223
|
-
|
|
242
|
+
p === "vehicle" && g ? /* @__PURE__ */ _(i, {
|
|
224
243
|
assembly: e,
|
|
225
244
|
importedRoot: t,
|
|
226
245
|
chassisGroupRef: n
|
|
227
|
-
}) :
|
|
228
|
-
bundle:
|
|
229
|
-
subArchetype:
|
|
230
|
-
patches:
|
|
246
|
+
}) : r ? p === "vehicle" ? /* @__PURE__ */ _(O, {
|
|
247
|
+
bundle: r,
|
|
248
|
+
subArchetype: m,
|
|
249
|
+
patches: a,
|
|
231
250
|
stampActive: s,
|
|
232
251
|
panelAnimRef: c,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
252
|
+
cabin: l,
|
|
253
|
+
carBounds: u,
|
|
254
|
+
showDriver: d,
|
|
255
|
+
onStampSurface: f
|
|
256
|
+
}) : /* @__PURE__ */ _(k, {
|
|
257
|
+
bundle: r,
|
|
258
|
+
domain: p,
|
|
259
|
+
staticProp: S,
|
|
260
|
+
patches: a,
|
|
261
|
+
onStampSurface: f
|
|
240
262
|
}) : null
|
|
241
263
|
]
|
|
242
264
|
});
|
|
243
265
|
}
|
|
244
|
-
export {
|
|
266
|
+
export { A as Step2UniversalPad };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { type CarCabinConfig } from "./cabinMixamoRig.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a Mixamo-named 1.75m seated driver rig with analytic 2-bone IK arms (to wheel) and legs (to pedals).
|
|
5
|
+
* Used as a visual fit mannequin in Step 1 and live driver preview in Step 2 (not exported into final GLB).
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildMixamoSeatedDummyGroup(cfg: CarCabinConfig, carMin: readonly [number, number, number], carMax: readonly [number, number, number], steerAngleRad?: number): THREE.Group;
|
|
8
|
+
/**
|
|
9
|
+
* Builds a clean, low-poly interior cabin tub (floor pan, dash, steering wheel, bucket seat(s), rear bulkhead)
|
|
10
|
+
* strictly inset inside the car AABB so solid exterior-only GLBs have a real interior where a character sits.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildCabinTubGroup(cfg: CarCabinConfig, carMin: readonly [number, number, number], carMax: readonly [number, number, number]): THREE.Group;
|
|
13
|
+
export declare function disposeObjectTree(obj: THREE.Object3D): void;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { MIXAMO_SEATED as e, computeMixamoCabinPoints as t } from "./cabinMixamoRig.js";
|
|
2
|
+
import * as n from "three";
|
|
3
|
+
// src/importer/cabinMeshBuilders.ts
|
|
4
|
+
var r = (e, t, n) => Math.max(t, Math.min(n, e));
|
|
5
|
+
function i(e, t, i, a, o) {
|
|
6
|
+
let s = t.clone().sub(e), c = r(s.length(), Math.abs(i - a) + 1e-4, i + a - 1e-4), l = s.lengthSq() > 1e-10 ? s.normalize() : new n.Vector3(0, 0, 1), u = (i * i - a * a + c * c) / (2 * c), d = Math.sqrt(Math.max(0, i * i - u * u)), f = o.clone().addScaledVector(l, -o.dot(l));
|
|
7
|
+
return f.lengthSq() < 1e-8 ? f.set(0, 1, 0) : f.normalize(), e.clone().addScaledVector(l, u).addScaledVector(f, d);
|
|
8
|
+
}
|
|
9
|
+
function a(e, t, r, i, a, o) {
|
|
10
|
+
let s = new n.Group();
|
|
11
|
+
s.name = t, s.position.copy(r);
|
|
12
|
+
let c = i.clone().sub(r), l = Math.max(.02, c.length()), u = new n.Quaternion().setFromUnitVectors(new n.Vector3(0, 1, 0), c.clone().normalize()), d = new n.Mesh(new n.CapsuleGeometry(a, Math.max(.01, l - a * 2), 4, 8), o);
|
|
13
|
+
return d.position.copy(c).multiplyScalar(.5), d.quaternion.copy(u), s.add(d), e.add(s), s;
|
|
14
|
+
}
|
|
15
|
+
function o(r, o, s, c = 0) {
|
|
16
|
+
let l = t(r, o, s), u = new n.Group();
|
|
17
|
+
u.name = "MixamoSeatedPreview";
|
|
18
|
+
let d = new n.MeshStandardMaterial({
|
|
19
|
+
color: "#38bdf8",
|
|
20
|
+
roughness: .45,
|
|
21
|
+
metalness: .1,
|
|
22
|
+
flatShading: !0
|
|
23
|
+
}), f = new n.MeshStandardMaterial({
|
|
24
|
+
color: "#ffb000",
|
|
25
|
+
roughness: .35,
|
|
26
|
+
emissive: "#ffb000",
|
|
27
|
+
emissiveIntensity: .22,
|
|
28
|
+
flatShading: !0
|
|
29
|
+
}), p = new n.MeshStandardMaterial({
|
|
30
|
+
color: "#0f172a",
|
|
31
|
+
roughness: .2,
|
|
32
|
+
metalness: .4,
|
|
33
|
+
flatShading: !0
|
|
34
|
+
}), m = new n.Vector3(...l.hips), h = new n.Vector3(...l.shoulderL), g = new n.Vector3(...l.shoulderR), _ = h.clone().add(g).multiplyScalar(.5), v = new n.Vector3(...l.eye), y = new n.Vector3(...l.wheelCenter), b = new n.Vector3(0, Math.sin(e.wheelTiltRad), Math.cos(e.wheelTiltRad)).normalize(), x = new n.Quaternion().setFromAxisAngle(b, c), S = new n.Vector3(...l.handL).sub(y).applyQuaternion(x).add(y), C = new n.Vector3(...l.handR).sub(y).applyQuaternion(x).add(y), w = new n.Vector3(...l.footL), T = new n.Vector3(...l.footR), E = new n.Group();
|
|
35
|
+
E.name = "mixamorigHips", E.position.copy(m), E.add(new n.Mesh(new n.BoxGeometry(.28, .14, .2), f)), u.add(E), a(u, "mixamorigSpine", m, _, .125, d), a(u, "mixamorigNeck", _, v.clone().add(new n.Vector3(0, -.05, 0)), .052, f);
|
|
36
|
+
let D = new n.Group();
|
|
37
|
+
D.name = "mixamorigHead", D.position.copy(v);
|
|
38
|
+
let O = new n.Mesh(new n.BoxGeometry(.16, .055, .08), p);
|
|
39
|
+
O.position.set(0, .01, .085), D.add(new n.Mesh(new n.SphereGeometry(.105, 10, 8), d), O), u.add(D);
|
|
40
|
+
let k = i(h, S, e.upperArmLen, e.forearmLen, new n.Vector3(.45, -.8, -.25)), A = i(g, C, e.upperArmLen, e.forearmLen, new n.Vector3(-.45, -.8, -.25));
|
|
41
|
+
a(u, "mixamorigLeftArm", h, k, .046, d), a(u, "mixamorigLeftForeArm", k, S, .038, d), a(u, "mixamorigRightArm", g, A, .046, d), a(u, "mixamorigRightForeArm", A, C, .038, d);
|
|
42
|
+
for (let [e, t] of [["mixamorigLeftHand", S], ["mixamorigRightHand", C]]) {
|
|
43
|
+
let r = new n.Mesh(new n.SphereGeometry(.042, 8, 6), f);
|
|
44
|
+
r.name = e, r.position.copy(t), u.add(r);
|
|
45
|
+
}
|
|
46
|
+
let j = m.clone().add(new n.Vector3(e.hipHalfWidth, -.02, .03)), M = m.clone().add(new n.Vector3(-e.hipHalfWidth, -.02, .03)), N = i(j, w, e.thighLen, e.shinLen, new n.Vector3(.12, .85, .55)), P = i(M, T, e.thighLen, e.shinLen, new n.Vector3(-.12, .85, .55));
|
|
47
|
+
a(u, "mixamorigLeftUpLeg", j, N, .068, d), a(u, "mixamorigLeftLeg", N, w, .052, d), a(u, "mixamorigRightUpLeg", M, P, .068, d), a(u, "mixamorigRightLeg", P, T, .052, d);
|
|
48
|
+
for (let [e, t] of [["mixamorigLeftFoot", w], ["mixamorigRightFoot", T]]) {
|
|
49
|
+
let r = new n.Mesh(new n.BoxGeometry(.09, .05, .2), f);
|
|
50
|
+
r.name = e, r.position.copy(t).add(new n.Vector3(0, 0, .04)), u.add(r);
|
|
51
|
+
}
|
|
52
|
+
return u;
|
|
53
|
+
}
|
|
54
|
+
function s(i, a, o) {
|
|
55
|
+
let s = new n.Group();
|
|
56
|
+
s.name = "CabinTub";
|
|
57
|
+
let c = t(i, a, o), [l, u, d] = i.seatPos, f = new n.MeshStandardMaterial({
|
|
58
|
+
color: "#151922",
|
|
59
|
+
roughness: .92,
|
|
60
|
+
metalness: .06,
|
|
61
|
+
flatShading: !0
|
|
62
|
+
}), p = new n.MeshStandardMaterial({
|
|
63
|
+
color: "#27303f",
|
|
64
|
+
roughness: .85,
|
|
65
|
+
metalness: .05,
|
|
66
|
+
flatShading: !0
|
|
67
|
+
}), m = new n.MeshStandardMaterial({
|
|
68
|
+
color: "#0b0f17",
|
|
69
|
+
roughness: .72,
|
|
70
|
+
metalness: .18,
|
|
71
|
+
flatShading: !0
|
|
72
|
+
}), h = Math.max(.7, o[0] - a[0]), g = r(h - .16, .56, h * .88), _ = r(u - .24, a[1] + .08, u - .08), v = r(d - .36, a[2] + .14, d - .18), y = r(c.wheelCenter[2] + .34, d + .48, o[2] - .16), b = Math.max(.65, y - v), x = (a[0] + o[0]) * .5, S = new n.Mesh(new n.BoxGeometry(g, .04, b), f);
|
|
73
|
+
S.name = "Cabin_Floor", S.position.set(x, _, (v + y) * .5), s.add(S);
|
|
74
|
+
let C = r(c.wheelCenter[1] - _ + .08, .24, Math.max(.26, o[1] - _ - .32)), w = new n.Mesh(new n.BoxGeometry(g, C, .22), f);
|
|
75
|
+
w.name = "Cabin_Dash", w.position.set(x, _ + C * .5, y - .11), s.add(w);
|
|
76
|
+
let T = r(Math.min(o[1] - _ - .12, .65), .28, .72), E = new n.Mesh(new n.BoxGeometry(g, T, .05), f);
|
|
77
|
+
E.name = "Cabin_Bulkhead", E.position.set(x, _ + T * .5, v), s.add(E);
|
|
78
|
+
let D = (e, t) => {
|
|
79
|
+
let a = new n.Group();
|
|
80
|
+
a.name = `Cabin_Seat_${t}`, a.position.set(e, u, d);
|
|
81
|
+
let o = new n.Mesh(new n.BoxGeometry(.44, .08, .44), p);
|
|
82
|
+
o.position.set(0, -.04, .05);
|
|
83
|
+
let c = Math.max(.05, u - _ - .08), l = new n.Mesh(new n.BoxGeometry(.32, c, .34), f);
|
|
84
|
+
l.position.set(0, -.08 - c * .5, .02);
|
|
85
|
+
let m = r(i.reclineDeg, 0, 35) * Math.PI / 180, h = new n.Mesh(new n.BoxGeometry(.44, .56, .09), p);
|
|
86
|
+
h.position.set(0, .26, -.17), h.rotation.x = -m;
|
|
87
|
+
let g = new n.Mesh(new n.BoxGeometry(.24, .16, .08), p);
|
|
88
|
+
g.position.set(0, .61, -.17 - Math.sin(m) * .34), g.rotation.x = -m, a.add(o, l, h, g), s.add(a);
|
|
89
|
+
};
|
|
90
|
+
D(l, "Driver"), i.passengerSeat && i.layout !== "center" && Math.abs(l) * 2 + .46 <= g + .04 && D(-l, "Passenger");
|
|
91
|
+
let O = new n.Group();
|
|
92
|
+
O.name = "Cabin_SteeringWheel", O.position.set(...c.wheelCenter), O.rotation.x = -e.wheelTiltRad;
|
|
93
|
+
let k = new n.Mesh(new n.CylinderGeometry(.042, .042, .04, 8), m);
|
|
94
|
+
k.rotation.x = Math.PI * .5;
|
|
95
|
+
let A = Math.max(.14, Math.min(.45, y - c.wheelCenter[2])), j = new n.Mesh(new n.CylinderGeometry(.024, .028, A, 8), f);
|
|
96
|
+
return j.rotation.x = Math.PI * .5, j.position.set(0, 0, A * .5), O.add(new n.Mesh(new n.TorusGeometry(e.wheelRadius, .018, 6, 12), m), k, new n.Mesh(new n.BoxGeometry(e.wheelRadius * 1.9, .022, .018), m), j), s.add(O), s;
|
|
97
|
+
}
|
|
98
|
+
function c(e) {
|
|
99
|
+
e.traverse((e) => {
|
|
100
|
+
let t = e;
|
|
101
|
+
if (t.geometry && t.geometry.dispose(), t.material) for (let e of Array.isArray(t.material) ? t.material : [t.material]) e.dispose();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export { s as buildCabinTubGroup, o as buildMixamoSeatedDummyGroup, c as disposeObjectTree };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { KolmoAuthoredNodePatch } from "../schema/kolmoSchema.js";
|
|
2
|
+
export { buildCabinTubGroup, buildMixamoSeatedDummyGroup, disposeObjectTree } from "./cabinMeshBuilders.js";
|
|
3
|
+
export type DriverSeatLayout = "lhd" | "rhd" | "center";
|
|
4
|
+
export type ShellViewMode = "solid" | "xray" | "cutaway";
|
|
5
|
+
export interface CarCabinConfig {
|
|
6
|
+
readonly enabled: boolean;
|
|
7
|
+
readonly includeInteriorTub: boolean;
|
|
8
|
+
readonly layout: DriverSeatLayout;
|
|
9
|
+
readonly seatPos: readonly [number, number, number];
|
|
10
|
+
readonly steerOffsetZ: number;
|
|
11
|
+
readonly steerOffsetY: number;
|
|
12
|
+
readonly reclineDeg: number;
|
|
13
|
+
readonly passengerSeat: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CabinFitReport {
|
|
16
|
+
readonly headroomM: number;
|
|
17
|
+
readonly shoulderClearanceM: number;
|
|
18
|
+
readonly headroomOk: boolean;
|
|
19
|
+
readonly shoulderOk: boolean;
|
|
20
|
+
readonly headTopY: number;
|
|
21
|
+
}
|
|
22
|
+
/** Exact 1.75m Mixamo seated anthropometry (meters, relative to seat pan / cushion top). */
|
|
23
|
+
export declare const MIXAMO_SEATED: Readonly<{
|
|
24
|
+
hipsAbovePan: 0.11;
|
|
25
|
+
torsoLen: 0.48;
|
|
26
|
+
neckToEye: 0.17;
|
|
27
|
+
eyeToCrown: 0.11;
|
|
28
|
+
shoulderHalfWidth: 0.21;
|
|
29
|
+
hipHalfWidth: 0.11;
|
|
30
|
+
upperArmLen: 0.3;
|
|
31
|
+
forearmLen: 0.28;
|
|
32
|
+
thighLen: 0.43;
|
|
33
|
+
shinLen: 0.42;
|
|
34
|
+
wheelRadius: 0.165;
|
|
35
|
+
wheelTiltRad: 0.38;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function seatXForLayout(layout: DriverSeatLayout, carWidth: number): number;
|
|
38
|
+
export declare function autoFitCabinConfig(carMin: readonly [number, number, number], carMax: readonly [number, number, number], wheelRadius?: number, layout?: DriverSeatLayout): CarCabinConfig;
|
|
39
|
+
export declare function computeMixamoCabinPoints(cfg: CarCabinConfig, carMin: readonly [number, number, number], carMax: readonly [number, number, number]): {
|
|
40
|
+
hips: [number, number, number];
|
|
41
|
+
eye: [number, number, number];
|
|
42
|
+
crown: [number, number, number];
|
|
43
|
+
shoulderL: [number, number, number];
|
|
44
|
+
shoulderR: [number, number, number];
|
|
45
|
+
wheelCenter: [number, number, number];
|
|
46
|
+
handL: [number, number, number];
|
|
47
|
+
handR: [number, number, number];
|
|
48
|
+
footL: [number, number, number];
|
|
49
|
+
footR: [number, number, number];
|
|
50
|
+
exit: [number, number, number];
|
|
51
|
+
};
|
|
52
|
+
export declare function evaluateCabinFit(cfg: CarCabinConfig, carMin: readonly [number, number, number], carMax: readonly [number, number, number]): CabinFitReport;
|
|
53
|
+
export declare function computeMixamoCabinSockets(cfg: CarCabinConfig, carMin: readonly [number, number, number], carMax: readonly [number, number, number]): KolmoAuthoredNodePatch[];
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { buildCabinTubGroup as e, buildMixamoSeatedDummyGroup as t, disposeObjectTree as n } from "./cabinMeshBuilders.js";
|
|
2
|
+
// src/importer/cabinMixamoRig.ts
|
|
3
|
+
var r = (e) => Number(e.toFixed(4)), i = (e, t, n) => Math.max(t, Math.min(n, e)), a = Object.freeze({
|
|
4
|
+
hipsAbovePan: .11,
|
|
5
|
+
torsoLen: .48,
|
|
6
|
+
neckToEye: .17,
|
|
7
|
+
eyeToCrown: .11,
|
|
8
|
+
shoulderHalfWidth: .21,
|
|
9
|
+
hipHalfWidth: .11,
|
|
10
|
+
upperArmLen: .3,
|
|
11
|
+
forearmLen: .28,
|
|
12
|
+
thighLen: .43,
|
|
13
|
+
shinLen: .42,
|
|
14
|
+
wheelRadius: .165,
|
|
15
|
+
wheelTiltRad: .38
|
|
16
|
+
});
|
|
17
|
+
function o(e, t) {
|
|
18
|
+
if (e === "center") return 0;
|
|
19
|
+
let n = i(t * .22, .24, .46);
|
|
20
|
+
return r(e === "lhd" ? n : -n);
|
|
21
|
+
}
|
|
22
|
+
function s(e, t, n = .32, s = "lhd") {
|
|
23
|
+
let c = Math.max(.9, t[0] - e[0]), l = Math.max(.85, t[1] - e[1]), u = Math.max(1.8, t[2] - e[2]), d = a.hipsAbovePan + a.torsoLen + a.neckToEye + a.eyeToCrown, f = t[1] - d - .06, p = Math.max(e[1] + .18, n * .82), m = r(i(e[1] + l * .3, p, Math.max(p, f))), h = r((e[2] + t[2]) * .5 - u * .05), g = c < 1.15 ? "center" : s;
|
|
24
|
+
return {
|
|
25
|
+
enabled: !0,
|
|
26
|
+
includeInteriorTub: !0,
|
|
27
|
+
layout: g,
|
|
28
|
+
seatPos: [
|
|
29
|
+
o(g, c),
|
|
30
|
+
m,
|
|
31
|
+
h
|
|
32
|
+
],
|
|
33
|
+
steerOffsetZ: r(i(u * .11, .38, .54)),
|
|
34
|
+
steerOffsetY: .4,
|
|
35
|
+
reclineDeg: 14,
|
|
36
|
+
passengerSeat: g !== "center" && c >= 1.35
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function c(e, t, n) {
|
|
40
|
+
let [o, s, c] = e.seatPos, l = i(e.reclineDeg, 0, 35) * Math.PI / 180, u = Math.sin(l), d = Math.cos(l), f = [
|
|
41
|
+
r(o),
|
|
42
|
+
r(s + a.hipsAbovePan),
|
|
43
|
+
r(c)
|
|
44
|
+
], p = f[1] + a.torsoLen * d, m = f[2] - a.torsoLen * u, h = [
|
|
45
|
+
r(o),
|
|
46
|
+
r(p + a.neckToEye),
|
|
47
|
+
r(m + .04)
|
|
48
|
+
], g = [
|
|
49
|
+
r(o),
|
|
50
|
+
r(h[1] + a.eyeToCrown),
|
|
51
|
+
r(m)
|
|
52
|
+
], _ = [
|
|
53
|
+
r(o + a.shoulderHalfWidth),
|
|
54
|
+
r(p),
|
|
55
|
+
r(m)
|
|
56
|
+
], v = [
|
|
57
|
+
r(o - a.shoulderHalfWidth),
|
|
58
|
+
r(p),
|
|
59
|
+
r(m)
|
|
60
|
+
], y = [
|
|
61
|
+
r(o),
|
|
62
|
+
r(s + e.steerOffsetY),
|
|
63
|
+
r(c + e.steerOffsetZ)
|
|
64
|
+
], b = a.wheelRadius, x = .42, S = Math.cos(x) * b, C = Math.sin(x) * b * Math.cos(a.wheelTiltRad), w = -Math.sin(x) * b * Math.sin(a.wheelTiltRad), T = [
|
|
65
|
+
r(y[0] + S),
|
|
66
|
+
r(y[1] + C),
|
|
67
|
+
r(y[2] + w)
|
|
68
|
+
], E = [
|
|
69
|
+
r(y[0] - S),
|
|
70
|
+
r(y[1] + C),
|
|
71
|
+
r(y[2] + w)
|
|
72
|
+
], D = Math.max(t[1] + .08, s - .24), O = Math.min(n[2] - .22, c + e.steerOffsetZ + .22);
|
|
73
|
+
return {
|
|
74
|
+
hips: f,
|
|
75
|
+
eye: h,
|
|
76
|
+
crown: g,
|
|
77
|
+
shoulderL: _,
|
|
78
|
+
shoulderR: v,
|
|
79
|
+
wheelCenter: y,
|
|
80
|
+
handL: T,
|
|
81
|
+
handR: E,
|
|
82
|
+
footL: [
|
|
83
|
+
r(o + .11),
|
|
84
|
+
r(D + .05),
|
|
85
|
+
r(O)
|
|
86
|
+
],
|
|
87
|
+
footR: [
|
|
88
|
+
r(o - .11),
|
|
89
|
+
r(D + .05),
|
|
90
|
+
r(O)
|
|
91
|
+
],
|
|
92
|
+
exit: [
|
|
93
|
+
r(e.layout === "rhd" ? t[0] - .58 : n[0] + .58),
|
|
94
|
+
r(Math.max(.55, s)),
|
|
95
|
+
r(c)
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function l(e, t, n) {
|
|
100
|
+
let i = c(e, t, n), o = r(n[1] - i.crown[1]), s = n[0] - (e.seatPos[0] + a.shoulderHalfWidth), l = e.seatPos[0] - a.shoulderHalfWidth - t[0], u = r(Math.min(s, l));
|
|
101
|
+
return {
|
|
102
|
+
headroomM: o,
|
|
103
|
+
shoulderClearanceM: u,
|
|
104
|
+
headroomOk: o >= .03,
|
|
105
|
+
shoulderOk: u >= .03,
|
|
106
|
+
headTopY: i.crown[1]
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function u(e, t, n) {
|
|
110
|
+
if (!e.enabled) return [];
|
|
111
|
+
let r = c(e, t, n);
|
|
112
|
+
return [
|
|
113
|
+
{
|
|
114
|
+
nodeName: "Socket_seat",
|
|
115
|
+
translation: r.hips,
|
|
116
|
+
extension: { socket: "seat" }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
nodeName: "Socket_optic",
|
|
120
|
+
translation: r.eye,
|
|
121
|
+
extension: { socket: "optic" }
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
nodeName: "Socket_exit",
|
|
125
|
+
translation: r.exit,
|
|
126
|
+
extension: { socket: "exit" }
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
nodeName: "Socket_steer_L",
|
|
130
|
+
translation: r.handL,
|
|
131
|
+
extension: { socket: "grip_primary" }
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
nodeName: "Socket_steer_R",
|
|
135
|
+
translation: r.handR,
|
|
136
|
+
extension: { socket: "grip_secondary" }
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
nodeName: "Socket_pedal_L",
|
|
140
|
+
translation: r.footL,
|
|
141
|
+
extension: { socket: "contact" }
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
nodeName: "Socket_pedal_R",
|
|
145
|
+
translation: r.footR,
|
|
146
|
+
extension: { socket: "contact" }
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
export { a as MIXAMO_SEATED, s as autoFitCabinConfig, e as buildCabinTubGroup, t as buildMixamoSeatedDummyGroup, c as computeMixamoCabinPoints, u as computeMixamoCabinSockets, n as disposeObjectTree, l as evaluateCabinFit, o as seatXForLayout };
|