@pinkaphant/kolmo 0.0.0-stage → 0.1.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/README.md +44 -2
- package/bin/kolmo.mjs +112 -0
- package/dist/engine/index.d.ts +8 -0
- package/dist/engine/index.js +3 -0
- package/dist/engine/kolmoActor.d.ts +6 -0
- package/dist/engine/kolmoIsland.d.ts +17 -0
- package/dist/engine/kolmoLongDrive.d.ts +13 -0
- package/dist/engine/kolmoRigs.d.ts +13 -0
- package/dist/engine/kolmoStore.d.ts +68 -0
- package/dist/engine/kolmoSurface.d.ts +18 -0
- package/dist/engine/kolmoVehicle.d.ts +32 -0
- package/dist/engine/kolmoWorld.d.ts +51 -0
- package/dist/engine/longDriveKit.d.ts +19 -0
- package/dist/engine/mainlandMacroCell.d.ts +19 -0
- package/dist/engine-BiMeAPAi.js +1717 -0
- package/dist/importer/ChopShopPanel.d.ts +44 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +17 -0
- package/dist/importer/GateHudBar.d.ts +29 -0
- package/dist/importer/GlbImportGate.d.ts +7 -0
- package/dist/importer/ImperativeVehicleRig.d.ts +9 -0
- package/dist/importer/Step1CalibrationPlinth.d.ts +38 -0
- package/dist/importer/Step2UniversalPad.d.ts +18 -0
- package/dist/importer/VfxEmitterPool.d.ts +8 -0
- package/dist/importer/chopShopActions.d.ts +44 -0
- package/dist/importer/gateStore.d.ts +73 -0
- package/dist/importer/glbNormalizer.d.ts +22 -0
- package/dist/importer/importerWebMcp.d.ts +37 -0
- package/dist/importer/index.d.ts +17 -0
- package/dist/importer/index.js +3 -0
- package/dist/importer/khrCompiler.d.ts +23 -0
- package/dist/importer/launcherBake.d.ts +15 -0
- package/dist/importer/meshIslands.d.ts +59 -0
- package/dist/importer/surfaceCutter.d.ts +27 -0
- package/dist/importer/surfaceTopology.d.ts +40 -0
- package/dist/importer/universalGateBake.d.ts +41 -0
- package/dist/importer/usdToGlb.d.ts +11 -0
- package/dist/importer/useChopShopController.d.ts +94 -0
- package/dist/importer/vehiclePanelAnim.d.ts +25 -0
- package/dist/importer/wheelAxlePairing.d.ts +19 -0
- package/dist/importer-Cz5w0mnC.js +5005 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +14 -0
- package/dist/junk/DestructibleTarget.d.ts +18 -0
- package/dist/junk/KolmoJunk.d.ts +14 -0
- package/dist/junk/ShardPieces.d.ts +10 -0
- package/dist/junk/TargetDecals.d.ts +18 -0
- package/dist/junk/bvhShatter.d.ts +7 -0
- package/dist/junk/bvhTriCollector.d.ts +20 -0
- package/dist/junk/index.d.ts +12 -0
- package/dist/junk/index.js +1 -0
- package/dist/junk/junkGeometry.d.ts +34 -0
- package/dist/junk/junkImportSanitize.d.ts +6 -0
- package/dist/junk/junkImporter.d.ts +25 -0
- package/dist/junk/junkLabelCanvas.d.ts +7 -0
- package/dist/junk/junkLabels.d.ts +31 -0
- package/dist/junk/junkTypes.d.ts +48 -0
- package/dist/junk/targetHelpers.d.ts +56 -0
- package/dist/junk/targetHitLogic.d.ts +30 -0
- package/dist/junk/useTargetAssets.d.ts +24 -0
- package/dist/junk-B4bC1zAl.js +1049 -0
- package/dist/kolmoSurface-DTnrFXH0.js +558 -0
- package/dist/schema/kolmoSchema.d.ts +69 -0
- package/dist/shaders/celestialBackdrop.d.ts +22 -0
- package/dist/shaders/index.d.ts +6 -0
- package/dist/shaders/index.js +1 -0
- package/dist/shaders/plumeAndSparkle.d.ts +14 -0
- package/dist/shaders/ps2GlslShared.d.ts +20 -0
- package/dist/shaders/ps2MaterialsTSL.d.ts +23 -0
- package/dist/shaders/ps2MaterialsWebGL.d.ts +15 -0
- package/dist/shaders/ps2RoadWebGL.d.ts +7 -0
- package/dist/shaders/ps2TerrainWebGL.d.ts +8 -0
- package/dist/shaders/ps2Textures.d.ts +22 -0
- package/dist/shaders/retroPalettes.d.ts +24 -0
- package/dist/shaders/retroShader.d.ts +69 -0
- package/dist/shaders-GS71Ek1A.js +1383 -0
- package/dist/world/frontage.d.ts +26 -0
- package/dist/world/index.d.ts +9 -0
- package/dist/world/index.js +3 -0
- package/dist/world/infiniteWorld2D.d.ts +24 -0
- package/dist/world/island.d.ts +29 -0
- package/dist/world/macroCellSchema.d.ts +72 -0
- package/dist/world/macroKnightAStar.d.ts +11 -0
- package/dist/world/random.d.ts +23 -0
- package/dist/world/road.d.ts +37 -0
- package/dist/world/roadRibbon.d.ts +44 -0
- package/dist/world/terrain.d.ts +62 -0
- package/dist/world/worldTypes.d.ts +39 -0
- package/dist/world-PRWPYrlx.js +947 -0
- package/dist/worldTypes-Z0KfdCd0.js +226 -0
- package/package.json +100 -4
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import { O as e } from "./shaders-GS71Ek1A.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
3
|
+
import * as s from "three";
|
|
4
|
+
import { KhrAssembly as c, cloneKhrBundle as l, exportKhrGlb as u, loadKhrGlb as d, patchGlbJsonChunk as f, useKhrGlb as p } from "@khr3/core";
|
|
5
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
6
|
+
// src/schema/kolmoSchema.ts
|
|
7
|
+
var h = "KOLMO_emitter";
|
|
8
|
+
function g() {
|
|
9
|
+
return {
|
|
10
|
+
throttle: 0,
|
|
11
|
+
boost: 0,
|
|
12
|
+
brake: 0,
|
|
13
|
+
slip: 0,
|
|
14
|
+
reverse: 0,
|
|
15
|
+
turn_l: 0,
|
|
16
|
+
turn_r: 0,
|
|
17
|
+
headlight: 1,
|
|
18
|
+
fire: 0,
|
|
19
|
+
damage: 0,
|
|
20
|
+
always: 1
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var _ = /* @__PURE__ */ new Set([
|
|
24
|
+
"plume",
|
|
25
|
+
"sparkle",
|
|
26
|
+
"fume",
|
|
27
|
+
"trail",
|
|
28
|
+
"flare"
|
|
29
|
+
]), v = /* @__PURE__ */ new Set([
|
|
30
|
+
"throttle",
|
|
31
|
+
"boost",
|
|
32
|
+
"brake",
|
|
33
|
+
"slip",
|
|
34
|
+
"reverse",
|
|
35
|
+
"turn_l",
|
|
36
|
+
"turn_r",
|
|
37
|
+
"headlight",
|
|
38
|
+
"fire",
|
|
39
|
+
"damage",
|
|
40
|
+
"always"
|
|
41
|
+
]), y = /* @__PURE__ */ new Set([
|
|
42
|
+
"seat",
|
|
43
|
+
"exit",
|
|
44
|
+
"grip_primary",
|
|
45
|
+
"grip_secondary",
|
|
46
|
+
"optic",
|
|
47
|
+
"muzzle",
|
|
48
|
+
"mount"
|
|
49
|
+
]), b = {
|
|
50
|
+
plume: [
|
|
51
|
+
.22,
|
|
52
|
+
.91,
|
|
53
|
+
1
|
|
54
|
+
],
|
|
55
|
+
sparkle: [
|
|
56
|
+
1,
|
|
57
|
+
.72,
|
|
58
|
+
.24
|
|
59
|
+
],
|
|
60
|
+
fume: [
|
|
61
|
+
.68,
|
|
62
|
+
.74,
|
|
63
|
+
.82
|
|
64
|
+
],
|
|
65
|
+
trail: [
|
|
66
|
+
.32,
|
|
67
|
+
.88,
|
|
68
|
+
1
|
|
69
|
+
],
|
|
70
|
+
flare: [
|
|
71
|
+
1,
|
|
72
|
+
.18,
|
|
73
|
+
.08
|
|
74
|
+
]
|
|
75
|
+
}, x = new s.Matrix4(), S = new s.Matrix4(), C = new s.Vector3(), w = new s.Quaternion(), T = new s.Vector3();
|
|
76
|
+
function E(e, t) {
|
|
77
|
+
e.updateMatrixWorld(!0), x.copy(e.matrixWorld).invert();
|
|
78
|
+
let n = /* @__PURE__ */ new Map();
|
|
79
|
+
if (t) {
|
|
80
|
+
let e = t instanceof Uint8Array ? t : new Uint8Array(t), r = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
81
|
+
if (e.byteLength >= 20 && r.getUint32(0, !0) === 1179937895) {
|
|
82
|
+
let t = r.getUint32(12, !0), i = JSON.parse(new TextDecoder().decode(e.subarray(20, 20 + t)));
|
|
83
|
+
for (let e of i.nodes ?? []) {
|
|
84
|
+
let t = e.extensions?.[h];
|
|
85
|
+
e.name && t && typeof t == "object" && n.set(e.name, t);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
let r = [], i = [];
|
|
90
|
+
return e.traverse((t) => {
|
|
91
|
+
if (t === e) return;
|
|
92
|
+
let a = n.get(t.name) ?? t.userData?.KOLMO_emitter;
|
|
93
|
+
if (!a || typeof a != "object") return;
|
|
94
|
+
t.userData[h] = a, S.multiplyMatrices(x, t.matrixWorld), S.decompose(C, w, T);
|
|
95
|
+
let o = [
|
|
96
|
+
C.x,
|
|
97
|
+
C.y,
|
|
98
|
+
C.z
|
|
99
|
+
], s = [
|
|
100
|
+
w.x,
|
|
101
|
+
w.y,
|
|
102
|
+
w.z,
|
|
103
|
+
w.w
|
|
104
|
+
];
|
|
105
|
+
if (typeof a.kind == "string" && _.has(a.kind)) {
|
|
106
|
+
let e = a.kind, n = typeof a.drive == "string" && v.has(a.drive) ? a.drive : "always", i = Array.isArray(a.color) && a.color.length === 3 ? a.color : b[e], c = [
|
|
107
|
+
Number(i[0]),
|
|
108
|
+
Number(i[1]),
|
|
109
|
+
Number(i[2])
|
|
110
|
+
], l = typeof a.size == "number" && a.size > 0 ? a.size : 1;
|
|
111
|
+
r.push({
|
|
112
|
+
nodeName: t.name,
|
|
113
|
+
object: t,
|
|
114
|
+
localPosition: o,
|
|
115
|
+
localQuaternion: s,
|
|
116
|
+
kind: e,
|
|
117
|
+
drive: n,
|
|
118
|
+
color: c,
|
|
119
|
+
size: l
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
typeof a.socket == "string" && y.has(a.socket) && i.push({
|
|
123
|
+
nodeName: t.name,
|
|
124
|
+
role: a.socket,
|
|
125
|
+
localPosition: o,
|
|
126
|
+
localQuaternion: s
|
|
127
|
+
});
|
|
128
|
+
}), {
|
|
129
|
+
emitters: r,
|
|
130
|
+
sockets: i
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function D(e, t, n) {
|
|
134
|
+
return t.length === 0 && !n ? e : new Uint8Array(f(e, (e) => {
|
|
135
|
+
let r = e;
|
|
136
|
+
r.extensionsUsed = Array.from(/* @__PURE__ */ new Set([...r.extensionsUsed ?? [], h])), r.nodes = r.nodes ?? [];
|
|
137
|
+
let i = r.scene ?? 0, a = r.scenes?.[i];
|
|
138
|
+
a && n && (a.extras = {
|
|
139
|
+
...a.extras ?? {},
|
|
140
|
+
...n
|
|
141
|
+
});
|
|
142
|
+
for (let e of t) {
|
|
143
|
+
let t;
|
|
144
|
+
if (e.spotLight) {
|
|
145
|
+
r.extensionsUsed = Array.from(/* @__PURE__ */ new Set([...r.extensionsUsed, "KHR_lights_punctual"])), r.extensions = r.extensions ?? {};
|
|
146
|
+
let n = r.extensions.KHR_lights_punctual ?? { lights: [] };
|
|
147
|
+
n.lights = n.lights ?? [], t = n.lights.length, n.lights.push({
|
|
148
|
+
name: `${e.nodeName}_spot`,
|
|
149
|
+
type: "spot",
|
|
150
|
+
color: e.spotLight.color,
|
|
151
|
+
intensity: e.spotLight.intensity,
|
|
152
|
+
...e.spotLight.range ? { range: e.spotLight.range } : {},
|
|
153
|
+
spot: {
|
|
154
|
+
innerConeAngle: e.spotLight.innerConeAngle ?? .22,
|
|
155
|
+
outerConeAngle: e.spotLight.outerConeAngle ?? .58
|
|
156
|
+
}
|
|
157
|
+
}), r.extensions.KHR_lights_punctual = n;
|
|
158
|
+
}
|
|
159
|
+
let n = r.nodes.findIndex((t) => t.name === e.nodeName), i = { [h]: e.extension };
|
|
160
|
+
if (t !== void 0 && (i.KHR_lights_punctual = { light: t }), n >= 0) {
|
|
161
|
+
let t = r.nodes[n];
|
|
162
|
+
t.translation = e.translation, e.rotation && (t.rotation = e.rotation), t.extensions = {
|
|
163
|
+
...t.extensions ?? {},
|
|
164
|
+
...i
|
|
165
|
+
};
|
|
166
|
+
} else {
|
|
167
|
+
let t = r.nodes.length;
|
|
168
|
+
r.nodes.push({
|
|
169
|
+
name: e.nodeName,
|
|
170
|
+
translation: e.translation,
|
|
171
|
+
...e.rotation ? { rotation: e.rotation } : {},
|
|
172
|
+
extensions: i
|
|
173
|
+
}), a && (a.nodes = a.nodes ?? [], a.nodes.push(t));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
// src/importer/vehiclePanelAnim.ts
|
|
179
|
+
var O = {
|
|
180
|
+
plume: [
|
|
181
|
+
.22,
|
|
182
|
+
.91,
|
|
183
|
+
1
|
|
184
|
+
],
|
|
185
|
+
sparkle: [
|
|
186
|
+
1,
|
|
187
|
+
.72,
|
|
188
|
+
.24
|
|
189
|
+
],
|
|
190
|
+
fume: [
|
|
191
|
+
.68,
|
|
192
|
+
.74,
|
|
193
|
+
.82
|
|
194
|
+
],
|
|
195
|
+
trail: [
|
|
196
|
+
.32,
|
|
197
|
+
.88,
|
|
198
|
+
1
|
|
199
|
+
],
|
|
200
|
+
flare: [
|
|
201
|
+
1,
|
|
202
|
+
.18,
|
|
203
|
+
.08
|
|
204
|
+
]
|
|
205
|
+
}, k = new s.Vector3(0, 0, 0), A = new s.Vector3(0, 1, 0), j = new s.Vector3(0, 0, 1), M = new s.Matrix4(), N = new s.Quaternion(), P = new s.Vector3(), F = (e) => Number(e.toFixed(4));
|
|
206
|
+
function I(e) {
|
|
207
|
+
let t = e.clone();
|
|
208
|
+
return t.lengthSq() < 1e-10 ? t.set(0, 0, -1) : t.normalize(), M.lookAt(k, t, Math.abs(t.y) > .98 ? j : A), N.setFromRotationMatrix(M).normalize(), [
|
|
209
|
+
Number(N.x.toFixed(5)),
|
|
210
|
+
Number(N.y.toFixed(5)),
|
|
211
|
+
Number(N.z.toFixed(5)),
|
|
212
|
+
Number(N.w.toFixed(5))
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
function L(e) {
|
|
216
|
+
let t = [];
|
|
217
|
+
for (let n of e) {
|
|
218
|
+
let e = n.extension.kind;
|
|
219
|
+
if (!e) continue;
|
|
220
|
+
let r = n.rotation ?? [
|
|
221
|
+
0,
|
|
222
|
+
0,
|
|
223
|
+
0,
|
|
224
|
+
1
|
|
225
|
+
], i = new s.Object3D();
|
|
226
|
+
i.name = n.nodeName, i.position.set(n.translation[0], n.translation[1], n.translation[2]), i.quaternion.set(r[0], r[1], r[2], r[3]);
|
|
227
|
+
let a = n.extension.drive ?? "always", o = n.extension.color ?? O[e];
|
|
228
|
+
t.push({
|
|
229
|
+
nodeName: n.nodeName,
|
|
230
|
+
object: i,
|
|
231
|
+
localPosition: n.translation,
|
|
232
|
+
localQuaternion: r,
|
|
233
|
+
kind: e,
|
|
234
|
+
drive: a,
|
|
235
|
+
color: o,
|
|
236
|
+
size: n.extension.size ?? 1
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return t;
|
|
240
|
+
}
|
|
241
|
+
function R(e, t) {
|
|
242
|
+
let [n, r, i] = e.min, [a, o, s] = e.max, [c, l, u] = e.center;
|
|
243
|
+
if (t === "door") {
|
|
244
|
+
let e = c >= 0;
|
|
245
|
+
return {
|
|
246
|
+
anchor: [
|
|
247
|
+
F(e ? a - .02 : n + .02),
|
|
248
|
+
F(l),
|
|
249
|
+
F(s)
|
|
250
|
+
],
|
|
251
|
+
axis: [
|
|
252
|
+
0,
|
|
253
|
+
1,
|
|
254
|
+
0
|
|
255
|
+
],
|
|
256
|
+
limits: e ? [-1.15, 0] : [0, 1.15],
|
|
257
|
+
openAngle: e ? -1.15 : 1.15,
|
|
258
|
+
explodeDir: [
|
|
259
|
+
e ? 1 : -1,
|
|
260
|
+
.1,
|
|
261
|
+
0
|
|
262
|
+
]
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
if (t === "hood") return {
|
|
266
|
+
anchor: [
|
|
267
|
+
F(c),
|
|
268
|
+
F(o),
|
|
269
|
+
F(i)
|
|
270
|
+
],
|
|
271
|
+
axis: [
|
|
272
|
+
1,
|
|
273
|
+
0,
|
|
274
|
+
0
|
|
275
|
+
],
|
|
276
|
+
limits: [-1.05, 0],
|
|
277
|
+
openAngle: -1.05,
|
|
278
|
+
explodeDir: [
|
|
279
|
+
0,
|
|
280
|
+
.55,
|
|
281
|
+
.75
|
|
282
|
+
]
|
|
283
|
+
};
|
|
284
|
+
if (t === "trunk") return {
|
|
285
|
+
anchor: [
|
|
286
|
+
F(c),
|
|
287
|
+
F(o),
|
|
288
|
+
F(s)
|
|
289
|
+
],
|
|
290
|
+
axis: [
|
|
291
|
+
1,
|
|
292
|
+
0,
|
|
293
|
+
0
|
|
294
|
+
],
|
|
295
|
+
limits: [0, 1.15],
|
|
296
|
+
openAngle: 1.15,
|
|
297
|
+
explodeDir: [
|
|
298
|
+
0,
|
|
299
|
+
.55,
|
|
300
|
+
-.75
|
|
301
|
+
]
|
|
302
|
+
};
|
|
303
|
+
if (t === "fender") {
|
|
304
|
+
let e = c >= 0;
|
|
305
|
+
return {
|
|
306
|
+
anchor: [
|
|
307
|
+
F(e ? n : a),
|
|
308
|
+
F(o),
|
|
309
|
+
F(u)
|
|
310
|
+
],
|
|
311
|
+
axis: [
|
|
312
|
+
0,
|
|
313
|
+
0,
|
|
314
|
+
1
|
|
315
|
+
],
|
|
316
|
+
limits: e ? [-.55, 0] : [0, .55],
|
|
317
|
+
openAngle: e ? -.55 : .55,
|
|
318
|
+
explodeDir: [
|
|
319
|
+
e ? 1 : -1,
|
|
320
|
+
.25,
|
|
321
|
+
0
|
|
322
|
+
]
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
let d = u >= 0;
|
|
326
|
+
return {
|
|
327
|
+
anchor: [
|
|
328
|
+
F(c),
|
|
329
|
+
F(o),
|
|
330
|
+
F(d ? i : s)
|
|
331
|
+
],
|
|
332
|
+
axis: [
|
|
333
|
+
1,
|
|
334
|
+
0,
|
|
335
|
+
0
|
|
336
|
+
],
|
|
337
|
+
limits: d ? [-.55, 0] : [0, .55],
|
|
338
|
+
openAngle: d ? -.55 : .55,
|
|
339
|
+
explodeDir: [
|
|
340
|
+
0,
|
|
341
|
+
.15,
|
|
342
|
+
d ? 1 : -1
|
|
343
|
+
]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function z(e) {
|
|
347
|
+
let t = e.bodies.filter((e) => e.joint !== null && e.joint.kind === "revolute" && e.joint.limits !== null).map((e) => {
|
|
348
|
+
let t = e.joint.limits, n = Math.abs(t[0]) > Math.abs(t[1]) ? t[0] : t[1];
|
|
349
|
+
return {
|
|
350
|
+
nodeName: e.nodeName,
|
|
351
|
+
role: (e.role ?? e.nodeName).toLowerCase(),
|
|
352
|
+
object: e.object,
|
|
353
|
+
restQuat: e.object.quaternion.clone(),
|
|
354
|
+
axis: e.joint.axis,
|
|
355
|
+
openAngle: n,
|
|
356
|
+
open: !1,
|
|
357
|
+
angle: 0
|
|
358
|
+
};
|
|
359
|
+
}), n = new Map(t.map((e) => [e.object, e])), r = new s.Quaternion();
|
|
360
|
+
return {
|
|
361
|
+
hasPanels: t.length > 0,
|
|
362
|
+
panelNames: t.map((e) => e.nodeName),
|
|
363
|
+
toggleHitObject(e) {
|
|
364
|
+
for (let t = e; t; t = t.parent) {
|
|
365
|
+
let e = n.get(t);
|
|
366
|
+
if (e) return e.open = !e.open, !0;
|
|
367
|
+
}
|
|
368
|
+
return !1;
|
|
369
|
+
},
|
|
370
|
+
toggleRolePrefix(e) {
|
|
371
|
+
let n = e.toLowerCase(), r = t.filter((e) => e.role.startsWith(n) || e.nodeName.toLowerCase().startsWith(n));
|
|
372
|
+
if (r.length === 0) return;
|
|
373
|
+
let i = !r[0].open;
|
|
374
|
+
for (let e of r) e.open = i;
|
|
375
|
+
},
|
|
376
|
+
toggleAll() {
|
|
377
|
+
if (t.length === 0) return;
|
|
378
|
+
let e = !t.some((e) => e.open);
|
|
379
|
+
for (let n of t) n.open = e;
|
|
380
|
+
},
|
|
381
|
+
step(e) {
|
|
382
|
+
let n = 1 - Math.exp(-11 * Math.min(e, .05));
|
|
383
|
+
for (let e of t) {
|
|
384
|
+
let t = e.open ? e.openAngle : 0;
|
|
385
|
+
Math.abs(t - e.angle) < 1e-4 || (e.angle += (t - e.angle) * n, P.set(e.axis[0], e.axis[1], e.axis[2]).normalize(), r.setFromAxisAngle(P, e.angle), e.object.quaternion.copy(e.restQuat).multiply(r));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
// src/engine/kolmoSurface.tsx
|
|
391
|
+
var B = /* @__PURE__ */ new Map();
|
|
392
|
+
function V(e) {
|
|
393
|
+
let t = /* @__PURE__ */ new Uint8Array(16384);
|
|
394
|
+
for (let e = 0; e < 64; e++) for (let n = 0; n < 64; n++) {
|
|
395
|
+
let r = (e * 64 + n) * 4;
|
|
396
|
+
if (n === 0 || e === 0) t[r] = 56, t[r + 1] = 178, t[r + 2] = 216;
|
|
397
|
+
else if (n === 32 || e === 32) t[r] = 44, t[r + 1] = 58, t[r + 2] = 78;
|
|
398
|
+
else {
|
|
399
|
+
let i = (n >> 4) + (e >> 4) & 1 ? 30 : 35;
|
|
400
|
+
t[r] = i, t[r + 1] = i + 3, t[r + 2] = i + 9;
|
|
401
|
+
}
|
|
402
|
+
t[r + 3] = 255;
|
|
403
|
+
}
|
|
404
|
+
let n = new s.DataTexture(t, 64, 64, s.RGBAFormat);
|
|
405
|
+
return n.colorSpace = s.SRGBColorSpace, n.wrapS = s.RepeatWrapping, n.wrapT = s.RepeatWrapping, n.magFilter = s.NearestFilter, n.minFilter = s.NearestFilter, n.repeat.set(e, e), n.needsUpdate = !0, n;
|
|
406
|
+
}
|
|
407
|
+
function H(e) {
|
|
408
|
+
let t = B.get(e);
|
|
409
|
+
return t || (t = (async () => {
|
|
410
|
+
let t = new s.Group();
|
|
411
|
+
t.name = "KolmoProceduralSurface";
|
|
412
|
+
let n = new s.Mesh(new s.BoxGeometry(e, 1, e), new s.MeshStandardMaterial({
|
|
413
|
+
map: V(Math.max(4, Math.round(e / 8))),
|
|
414
|
+
roughness: .92,
|
|
415
|
+
metalness: .06
|
|
416
|
+
}));
|
|
417
|
+
n.name = "KolmoArenaSlab", n.position.set(0, -.5, 0), n.receiveShadow = !0, t.add(n);
|
|
418
|
+
let r = await u(t, [{
|
|
419
|
+
nodeName: "KolmoArenaSlab",
|
|
420
|
+
motion: { isKinematic: !0 },
|
|
421
|
+
collider: {
|
|
422
|
+
shape: {
|
|
423
|
+
type: "box",
|
|
424
|
+
size: [
|
|
425
|
+
e,
|
|
426
|
+
1,
|
|
427
|
+
e
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
friction: .95,
|
|
431
|
+
restitution: .04
|
|
432
|
+
}
|
|
433
|
+
}]);
|
|
434
|
+
return d(r);
|
|
435
|
+
})(), B.set(e, t)), t;
|
|
436
|
+
}
|
|
437
|
+
function U({ bundle: t, position: n }) {
|
|
438
|
+
let a = i(() => l(t), [t]);
|
|
439
|
+
return r(() => {
|
|
440
|
+
e(a.scene, { flatShading: !1 });
|
|
441
|
+
}, [a]), /* @__PURE__ */ m(c, {
|
|
442
|
+
bundle: a,
|
|
443
|
+
position: n,
|
|
444
|
+
fixedRoot: !0
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function W({ src: t, position: n }) {
|
|
448
|
+
let i = p(t);
|
|
449
|
+
return r(() => {
|
|
450
|
+
e(i.scene, { flatShading: !1 });
|
|
451
|
+
}, [i]), /* @__PURE__ */ m(c, {
|
|
452
|
+
bundle: i,
|
|
453
|
+
position: n,
|
|
454
|
+
fixedRoot: !0
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
function G({ src: e, bundle: t, size: r = 200, position: i = [
|
|
458
|
+
0,
|
|
459
|
+
0,
|
|
460
|
+
0
|
|
461
|
+
] }) {
|
|
462
|
+
let [a, s] = o(null);
|
|
463
|
+
return n(() => {
|
|
464
|
+
if (t || e) return;
|
|
465
|
+
let n = !0;
|
|
466
|
+
return H(r).then((e) => {
|
|
467
|
+
n && s(e);
|
|
468
|
+
}), () => {
|
|
469
|
+
n = !1;
|
|
470
|
+
};
|
|
471
|
+
}, [
|
|
472
|
+
t,
|
|
473
|
+
e,
|
|
474
|
+
r
|
|
475
|
+
]), t ? /* @__PURE__ */ m(U, {
|
|
476
|
+
bundle: t,
|
|
477
|
+
position: i
|
|
478
|
+
}) : e ? /* @__PURE__ */ m(W, {
|
|
479
|
+
src: e,
|
|
480
|
+
position: i
|
|
481
|
+
}) : a ? /* @__PURE__ */ m(U, {
|
|
482
|
+
bundle: a,
|
|
483
|
+
position: i
|
|
484
|
+
}) : null;
|
|
485
|
+
}
|
|
486
|
+
function K(e) {
|
|
487
|
+
if (!e) return {
|
|
488
|
+
open: 1.35,
|
|
489
|
+
closed: 0
|
|
490
|
+
};
|
|
491
|
+
let [t, n] = e;
|
|
492
|
+
return {
|
|
493
|
+
open: Math.abs(n) >= Math.abs(t) ? n : t,
|
|
494
|
+
closed: Math.min(n, Math.max(t, 0))
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function q(e, t, n, r, i) {
|
|
498
|
+
if (!e) return n;
|
|
499
|
+
if (r && i) {
|
|
500
|
+
let n = r;
|
|
501
|
+
for (; n;) {
|
|
502
|
+
let r = t.bodies.find((e) => e.object === n && e.joint?.drive?.stiffness !== void 0);
|
|
503
|
+
if (r) {
|
|
504
|
+
let t = !(i.get(r.nodeName) ?? !1);
|
|
505
|
+
i.set(r.nodeName, t);
|
|
506
|
+
let { open: n, closed: a } = K(r.joint?.limits);
|
|
507
|
+
return e.setJointTarget(r.nodeName, t ? n : a), t;
|
|
508
|
+
}
|
|
509
|
+
n = n.parent;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
let a = !n;
|
|
513
|
+
for (let n of t.bodies) {
|
|
514
|
+
if (!n.joint?.drive || n.joint.drive.stiffness === void 0) continue;
|
|
515
|
+
let { open: t, closed: r } = K(n.joint.limits);
|
|
516
|
+
i?.set(n.nodeName, a), e.setJointTarget(n.nodeName, a ? t : r);
|
|
517
|
+
}
|
|
518
|
+
return a;
|
|
519
|
+
}
|
|
520
|
+
function J({ bundle: n, position: o, fixed: s }) {
|
|
521
|
+
let u = a(null), d = a(!1), f = a(/* @__PURE__ */ new Map()), p = i(() => l(n), [n]);
|
|
522
|
+
r(() => {
|
|
523
|
+
e(p.scene);
|
|
524
|
+
}, [p]);
|
|
525
|
+
let h = t((e) => {
|
|
526
|
+
e?.stopPropagation?.(), d.current = q(u.current, p, d.current, e?.object ?? null, f.current);
|
|
527
|
+
}, [p]);
|
|
528
|
+
return /* @__PURE__ */ m(c, {
|
|
529
|
+
ref: u,
|
|
530
|
+
bundle: p,
|
|
531
|
+
position: o,
|
|
532
|
+
fixedRoot: s,
|
|
533
|
+
onClick: h
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
function Y({ src: e, position: t, fixed: n }) {
|
|
537
|
+
return /* @__PURE__ */ m(J, {
|
|
538
|
+
bundle: p(e),
|
|
539
|
+
position: t,
|
|
540
|
+
fixed: n
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function X({ src: e, bundle: t, position: n = [
|
|
544
|
+
0,
|
|
545
|
+
0,
|
|
546
|
+
0
|
|
547
|
+
], fixed: r = !1 }) {
|
|
548
|
+
return t ? /* @__PURE__ */ m(J, {
|
|
549
|
+
bundle: t,
|
|
550
|
+
position: n,
|
|
551
|
+
fixed: r
|
|
552
|
+
}) : e ? /* @__PURE__ */ m(Y, {
|
|
553
|
+
src: e,
|
|
554
|
+
position: n,
|
|
555
|
+
fixed: r
|
|
556
|
+
}) : null;
|
|
557
|
+
}
|
|
558
|
+
export { R as a, h as c, D as d, L as i, g as l, G as n, z as o, q as r, I as s, X as t, E as u };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
export declare const KOLMO_EXTENSION_NAME: "KOLMO_emitter";
|
|
3
|
+
export type KolmoEmitterKind = "plume" | "sparkle" | "fume" | "trail" | "flare";
|
|
4
|
+
export type KolmoDriveChannel = "throttle" | "boost" | "brake" | "slip" | "reverse" | "turn_l" | "turn_r" | "headlight" | "fire" | "damage" | "always";
|
|
5
|
+
export type KolmoSocketRole = "seat" | "exit" | "grip_primary" | "grip_secondary" | "optic" | "muzzle" | "mount";
|
|
6
|
+
export interface KolmoNodeExtension {
|
|
7
|
+
kind?: KolmoEmitterKind;
|
|
8
|
+
drive?: KolmoDriveChannel;
|
|
9
|
+
color?: [number, number, number];
|
|
10
|
+
size?: number;
|
|
11
|
+
socket?: KolmoSocketRole;
|
|
12
|
+
}
|
|
13
|
+
export interface DecodedKolmoEmitter {
|
|
14
|
+
nodeName: string;
|
|
15
|
+
object: THREE.Object3D;
|
|
16
|
+
localPosition: [number, number, number];
|
|
17
|
+
localQuaternion: [number, number, number, number];
|
|
18
|
+
kind: KolmoEmitterKind;
|
|
19
|
+
drive: KolmoDriveChannel;
|
|
20
|
+
color: [number, number, number];
|
|
21
|
+
size: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DecodedKolmoSocket {
|
|
24
|
+
nodeName: string;
|
|
25
|
+
role: KolmoSocketRole;
|
|
26
|
+
localPosition: [number, number, number];
|
|
27
|
+
localQuaternion: [number, number, number, number];
|
|
28
|
+
}
|
|
29
|
+
export interface KolmoRigMetadata {
|
|
30
|
+
emitters: DecodedKolmoEmitter[];
|
|
31
|
+
sockets: DecodedKolmoSocket[];
|
|
32
|
+
}
|
|
33
|
+
export interface KolmoSignalState {
|
|
34
|
+
throttle: number;
|
|
35
|
+
boost: number;
|
|
36
|
+
brake: number;
|
|
37
|
+
slip: number;
|
|
38
|
+
reverse: number;
|
|
39
|
+
turn_l: number;
|
|
40
|
+
turn_r: number;
|
|
41
|
+
headlight: number;
|
|
42
|
+
fire: number;
|
|
43
|
+
damage: number;
|
|
44
|
+
always: number;
|
|
45
|
+
}
|
|
46
|
+
export declare function createDefaultSignals(): KolmoSignalState;
|
|
47
|
+
/**
|
|
48
|
+
* Extracts `KOLMO_emitter` directional VFX emitters (-Z nozzle convention) and sockets
|
|
49
|
+
* from raw `.glb` JSON + live `THREE.Group` scene graph (or cloned `userData.kolmoExtension`).
|
|
50
|
+
*/
|
|
51
|
+
export declare function decodeKolmoRig(scene: THREE.Group, glbBytes?: ArrayBuffer | Uint8Array): KolmoRigMetadata;
|
|
52
|
+
export interface KolmoAuthoredNodePatch {
|
|
53
|
+
nodeName: string;
|
|
54
|
+
translation: [number, number, number];
|
|
55
|
+
rotation?: [number, number, number, number];
|
|
56
|
+
extension: KolmoNodeExtension;
|
|
57
|
+
spotLight?: {
|
|
58
|
+
color: [number, number, number];
|
|
59
|
+
intensity: number;
|
|
60
|
+
range?: number;
|
|
61
|
+
innerConeAngle?: number;
|
|
62
|
+
outerConeAngle?: number;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Stamps `KOLMO_emitter` nodes and optional official `KHR_lights_punctual` spotlights
|
|
67
|
+
* directly into a `.glb` binary's JSON chunk (`extensionsUsed`, never `extensionsRequired`).
|
|
68
|
+
*/
|
|
69
|
+
export declare function stampKolmoNodesIntoGlb(glbBytes: Uint8Array, patches: readonly KolmoAuthoredNodePatch[], extraSceneTune?: Record<string, unknown>): Uint8Array;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
export declare const KEY_SUN_DIRECTION: THREE.Vector3;
|
|
4
|
+
export declare const RING_MOONLET_COUNT = 72;
|
|
5
|
+
export declare const ATMO_VERT = "\n uniform vec2 uPs1Grid; uniform float uSnapStrength; varying vec3 vNormalWorld, vWorldPos;\n void main() {\n vec4 wp = modelMatrix * vec4(position, 1.0); vWorldPos = wp.xyz; vNormalWorld = normalize(mat3(modelMatrix) * normal);\n vec4 clip = projectionMatrix * viewMatrix * wp;\n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w; vec2 safeGrid = max(uPs1Grid, vec2(1.0));\n snapped.xy = mix(snapped.xy, floor(safeGrid * snapped.xy + 0.5) / safeGrid, uSnapStrength); snapped.xyz *= clip.w; clip = snapped;\n }\n gl_Position = clip;\n }\n";
|
|
6
|
+
export declare const ATMO_FRAG = "\n uniform vec3 uSunDir, uColor; uniform float uDitherMix; varying vec3 vNormalWorld, vWorldPos;\n \nuniform float uDitherScale; uniform vec4 uColorQuant; uniform sampler2D uPaletteLut;\n\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\nfloat ps1BayerDither(vec2 fragCoord) { return ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)); }\nvec3 ps1SamplePaletteLut(vec3 srgb) {\n vec3 c = clamp(srgb, 0.0, 1.0);\n return texture2D(uPaletteLut, vec2((floor(c.b * 31.0 + 0.5) * 32.0 + floor(c.r * 31.0 + 0.5) + 0.5) / 1024.0, (floor(c.g * 31.0 + 0.5) + 0.5) / 32.0)).rgb;\n}\nvec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {\n if (uColorQuant.w < 0.5) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer8x8(fragCoord / max(uDitherScale, 0.5)), spread = clamp(ditherSpread, 0.0, 1.0);\n if (uColorQuant.w > 1.5) return ps1SamplePaletteLut(ps1LinearToSrgb(clamp(ps1SrgbToLinear(srgb) + (bayer - 0.5) * (uColorQuant.y * spread), 0.0, 1.0)));\n vec3 levels = max(uColorQuant.rgb, vec3(1.0)), c0 = floor(srgb * levels) / levels, c1 = min(c0 + 1.0 / levels, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, spread)), t));\n}\n\n void main() {\n vec3 viewDir = normalize(cameraPosition - vWorldPos);\n float rim = pow(1.0 - max(0.0, dot(viewDir, vNormalWorld)), 2.6), nl = dot(vNormalWorld, normalize(uSunDir));\n float sunLit = mix(smoothstep(-0.3, 0.7, nl), step(-0.25, nl), uDitherMix) * 0.72 + 0.28, alpha = rim * sunLit;\n if (alpha < (ps1BayerDither(gl_FragCoord.xy) * 0.65 + 0.14) * uDitherMix) discard;\n vec3 col = ps1QuantizeRetro(ps1LinearToSrgb(uColor * (0.8 + sunLit * 0.55)), gl_FragCoord.xy, uDitherMix);\n gl_FragColor = vec4(col, mix(alpha * 0.85, 0.75, uDitherMix));\n }\n";
|
|
7
|
+
export interface KolmoSkyboxProps {
|
|
8
|
+
sunDirection?: [number, number, number];
|
|
9
|
+
}
|
|
10
|
+
export declare function KolmoSkybox({ sunDirection }: KolmoSkyboxProps): React.JSX.Element;
|
|
11
|
+
export declare function populateMoonletMatrices(inst: THREE.InstancedMesh, innerR: number, outerR: number): void;
|
|
12
|
+
export interface KolmoExoplanetProps {
|
|
13
|
+
position?: [number, number, number];
|
|
14
|
+
radius?: number;
|
|
15
|
+
ringInner?: number;
|
|
16
|
+
ringOuter?: number;
|
|
17
|
+
color?: string;
|
|
18
|
+
collider?: boolean;
|
|
19
|
+
moonlets?: boolean;
|
|
20
|
+
gravityWellActive?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function KolmoExoplanet({ position, radius, ringInner, ringOuter, color, collider, moonlets, gravityWellActive, }: KolmoExoplanetProps): React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { PS1_SNAP_RESOLUTION, RETRO_UNIFORMS, RETRO_PRESETS, RETRO_COLOR_MODES, PALETTE_CRUNCHY_16, PALETTE_CRUNCHY_64, GLSL_BAYER_RGB555, GLSL_RETRO_QUANTIZE, getRetroPreset, getRetroShaderUniforms, getColorQuantVector, getPaletteLutTexture, buildPaletteLutData, syncRetroUniforms, syncRetroViewport, computeRetroDpr, applyRetroTextureFiltering, applyRetroFilteringToMaterial, applyRetroMaterial, applyPs1Material, applySceneRetroMaterials, type RetroPresetId, type RetroPreset, type RetroColorMode, type RetroColorModeSpec, type RetroTextureOptions, type RetroMaterialOptions, } from "./retroShader.js";
|
|
2
|
+
export { PLUME_VERT, PLUME_FRAG, PARTICLE_VERT, PARTICLE_FRAG, KolmoEmitterRig, type KolmoEmitterRigProps, } from "./plumeAndSparkle.js";
|
|
3
|
+
export { KEY_SUN_DIRECTION, RING_MOONLET_COUNT, ATMO_VERT, ATMO_FRAG, populateMoonletMatrices, KolmoSkybox, KolmoExoplanet, type KolmoSkyboxProps, type KolmoExoplanetProps, } from "./celestialBackdrop.js";
|
|
4
|
+
export { SPLAT_LAYER, createPS2WorldTextures, generatePS2DetailSlices, type PS2TextureBundle, } from "./ps2Textures.js";
|
|
5
|
+
export { createPS2RoadMaterialWebGL, createPS2TerrainMaterialWebGL, mountPS2WorldMeshes, type MountedPS2WorldScene, type PS2RoadMaterialOptions, type PS2TerrainMaterialOptions, } from "./ps2MaterialsWebGL.js";
|
|
6
|
+
export { createPS2RoadMaterialTSL, createPS2TerrainMaterialTSL, } from "./ps2MaterialsTSL.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { l as ATMO_FRAG, u as ATMO_VERT, x as GLSL_BAYER_RGB555, S as GLSL_RETRO_QUANTIZE, d as KEY_SUN_DIRECTION, g as KolmoEmitterRig, f as KolmoExoplanet, p as KolmoSkybox, N as PALETTE_CRUNCHY_16, P as PALETTE_CRUNCHY_64, _ as PARTICLE_FRAG, v as PARTICLE_VERT, y as PLUME_FRAG, b as PLUME_VERT, C as PS1_SNAP_RESOLUTION, F as RETRO_COLOR_MODES, w as RETRO_PRESETS, T as RETRO_UNIFORMS, m as RING_MOONLET_COUNT, o as SPLAT_LAYER, E as applyPs1Material, I as applyRetroFilteringToMaterial, D as applyRetroMaterial, L as applyRetroTextureFiltering, O as applySceneRetroMaterials, R as buildPaletteLutData, z as computeRetroDpr, t as createPS2RoadMaterialTSL, a as createPS2RoadMaterialWebGL, n as createPS2TerrainMaterialTSL, i as createPS2TerrainMaterialWebGL, s as createPS2WorldTextures, c as generatePS2DetailSlices, B as getColorQuantVector, V as getPaletteLutTexture, k as getRetroPreset, A as getRetroShaderUniforms, r as mountPS2WorldMeshes, h as populateMoonletMatrices, j as syncRetroUniforms, M as syncRetroViewport } from "../shaders-GS71Ek1A.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DecodedKolmoEmitter, KolmoSignalState } from "../schema/kolmoSchema.js";
|
|
3
|
+
export declare const PLUME_VERT = "\n uniform vec2 uPs1Grid; uniform float uSnapStrength, uTime, uThrottle, uBoost;\n varying vec2 vUv;\n void main() {\n vUv = uv; vec3 p = position; float along = clamp(uv.y, 0.0, 1.0);\n float shock = sin(along * 22.0 - uTime * (16.0 + uBoost * 24.0)) * (0.045 + uBoost * 0.085) * along;\n p.xz *= 1.0 + shock + along * (uThrottle * 0.25 + uBoost * 0.52);\n vec4 clip = projectionMatrix * modelViewMatrix * vec4(p, 1.0);\n \n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n snapped.xy = mix(snapped.xy, floor(uPs1Grid * snapped.xy + 0.5) / uPs1Grid, uSnapStrength);\n snapped.xyz *= clip.w; clip = snapped;\n }\n\n gl_Position = clip;\n }\n";
|
|
4
|
+
export declare const PLUME_FRAG = "\n uniform float uTime, uThrottle, uBoost, uIntensity, uDitherMix;\n uniform vec3 uColorCore, uColorMid, uColorOuter;\n varying vec2 vUv;\n \nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\n void main() {\n float along = clamp(vUv.y, 0.0, 1.0);\n float tailFade = pow(1.0 - along, 1.15 - uBoost * 0.28), nozzleFade = smoothstep(0.0, 0.09, along);\n float throatHot = exp(-along * 5.2) * (0.65 + uThrottle * 0.55 + uBoost * 0.9);\n float machWave = sin(along * 28.0 - uTime * (16.0 + uThrottle * 10.0 + uBoost * 22.0)) * 0.5 + 0.5;\n float machCells = mix(machWave, step(0.42, machWave), uDitherMix * 0.85);\n float spiral = sin(vUv.x * 37.699 + along * 10.0 - uTime * 14.0) * 0.16 + 0.84;\n float density = (tailFade * (0.62 + machCells * 0.38) * spiral + throatHot * 0.45) * nozzleFade * uIntensity;\n if (density < mix(0.04, ps1Bayer4x4(gl_FragCoord.xy * 0.5) * 0.56 + 0.05, uDitherMix)) discard;\n vec3 cruise = mix(mix(uColorCore, uColorMid, smoothstep(0.05, 0.36, along)), uColorOuter, smoothstep(0.36, 0.88, along));\n vec3 boostC = mix(mix(vec3(1.0, 0.97, 0.90), vec3(0.18, 0.88, 1.0), smoothstep(0.04, 0.28, along)), vec3(1.0, 0.46, 0.08), smoothstep(0.28, 0.72, along));\n boostC += vec3(0.22, 0.52, 0.65) * machCells * (1.0 - along) * 0.45;\n vec3 col = mix(cruise, boostC, uBoost * 0.85) * (0.82 + uThrottle * 0.22 + uBoost * 0.28 + throatHot * 0.22);\n gl_FragColor = vec4(ps1QuantizeRGB555Mix(clamp(col, 0.0, 1.0), gl_FragCoord.xy, uDitherMix), clamp(mix(density * 0.88, 0.88, uDitherMix * 0.55), 0.16, 0.92));\n }\n";
|
|
5
|
+
export declare const PARTICLE_VERT = "\n attribute float aPhase, aAngle, aRadius, aSpeed, aSize;\n uniform float uTime, uDrive, uBoost, uScale, uMode, uSnapStrength;\n uniform vec2 uPs1Grid;\n varying float vLife, vBoost;\n void main() {\n float life = fract(aPhase + uTime * (0.7 + uDrive * 0.9 + uBoost * 1.4) * aSpeed);\n vLife = life; vBoost = uBoost;\n float coneLen = (1.35 + uDrive * 2.5 + uBoost * 4.4) * (uMode > 1.5 ? 1.55 : 1.0) * uScale;\n float z = -(0.04 * uScale + life * coneLen);\n float spread = uMode > 0.5 && uMode < 1.5 ? 1.6 : (uMode > 1.5 ? 0.42 : 0.88);\n float flare = aRadius * uScale * spread * (0.22 + life * (0.85 + uBoost * 0.95));\n float ang = aAngle + life * (3.2 + uBoost * 4.2) - uTime * 2.9;\n float rise = (uMode > 0.5 && uMode < 1.5) ? life * life * 0.52 * uScale : 0.0;\n vec4 mvPos = modelViewMatrix * vec4(cos(ang) * flare, sin(ang) * flare + rise, z, 1.0);\n vec4 clip = projectionMatrix * mvPos;\n \n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n snapped.xy = mix(snapped.xy, floor(uPs1Grid * snapped.xy + 0.5) / uPs1Grid, uSnapStrength);\n snapped.xyz *= clip.w; clip = snapped;\n }\n\n gl_Position = clip;\n float szMul = uMode > 0.5 && uMode < 1.5 ? (0.75 + life * 0.95) : (1.0 - life * 0.65);\n gl_PointSize = clamp(aSize * uScale * szMul * (0.65 + uDrive * 0.5 + uBoost * 0.9) * (155.0 / max(1.5, -mvPos.z)), 2.0, 26.0);\n }\n";
|
|
6
|
+
export declare const PARTICLE_FRAG = "\n uniform float uDitherMix, uMode;\n uniform vec3 uColor;\n varying float vLife, vBoost;\n \nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\n void main() {\n vec2 p = abs(gl_PointCoord - 0.5) * 2.0;\n float manhattan = p.x + p.y;\n if (manhattan > 1.05) discard;\n float fade = (1.0 - vLife) * (1.0 - vLife * 0.35);\n if (uMode > 0.5 && uMode < 1.5) {\n if (fade < ps1Bayer4x4(gl_FragCoord.xy * 0.5) * 0.75 * uDitherMix) discard;\n gl_FragColor = vec4(ps1QuantizeRGB555Mix(mix(uColor * 1.1, uColor * 0.45, vLife), gl_FragCoord.xy, uDitherMix), clamp(fade * 0.68, 0.0, 0.8));\n return;\n }\n float core = 1.0 - smoothstep(0.0, 1.05, manhattan);\n vec3 cEnd = uMode > 1.5 ? uColor * 0.55 : mix(uColor * 0.7, vec3(1.0, 0.48, 0.1), 0.55 + vBoost * 0.45);\n vec3 col = mix(mix(vec3(0.96, 0.99, 1.0), uColor, smoothstep(0.0, 0.32, vLife)), cEnd, smoothstep(0.32, 0.95, vLife));\n col *= 1.05 + vBoost * 0.85 + core * 0.5;\n gl_FragColor = vec4(ps1QuantizeRGB555Mix(clamp(col, 0.0, 1.0), gl_FragCoord.xy, uDitherMix), clamp(fade * 0.9, 0.0, 0.95));\n }\n";
|
|
7
|
+
export interface KolmoEmitterRigProps {
|
|
8
|
+
emitters: readonly DecodedKolmoEmitter[];
|
|
9
|
+
signalsRef: {
|
|
10
|
+
readonly current: KolmoSignalState | null;
|
|
11
|
+
};
|
|
12
|
+
comOffset?: readonly [number, number, number];
|
|
13
|
+
}
|
|
14
|
+
export declare function KolmoEmitterRig({ emitters, signalsRef, comOffset }: KolmoEmitterRigProps): React.JSX.Element | null;
|