@pinkaphant/kolmo 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -14
  3. package/bin/kolmo.mjs +19 -54
  4. package/dist/body/HeldItem.d.ts +22 -0
  5. package/dist/body/HeldItem.js +171 -0
  6. package/dist/body/KhrBody.d.ts +26 -0
  7. package/dist/body/KhrBody.js +179 -0
  8. package/dist/body/bodySi.d.ts +59 -0
  9. package/dist/body/bodySi.js +61 -0
  10. package/dist/body/index.d.ts +3 -0
  11. package/dist/body/index.js +4 -0
  12. package/dist/engine/index.d.ts +4 -4
  13. package/dist/engine/index.js +12 -3
  14. package/dist/engine/kolmoActor.d.ts +11 -4
  15. package/dist/engine/kolmoActor.js +197 -0
  16. package/dist/engine/kolmoInput.d.ts +12 -0
  17. package/dist/engine/kolmoInput.js +80 -0
  18. package/dist/engine/kolmoIsland.d.ts +3 -1
  19. package/dist/engine/kolmoIsland.js +311 -0
  20. package/dist/engine/kolmoLongDrive.js +223 -0
  21. package/dist/engine/kolmoRigs.js +59 -0
  22. package/dist/engine/kolmoStore.d.ts +53 -27
  23. package/dist/engine/kolmoStore.js +211 -0
  24. package/dist/engine/kolmoSurface.d.ts +1 -1
  25. package/dist/engine/kolmoSurface.js +182 -0
  26. package/dist/engine/kolmoVehicle.d.ts +2 -1
  27. package/dist/engine/kolmoVehicle.js +244 -0
  28. package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
  29. package/dist/engine/kolmoVehicleDriver.js +38 -0
  30. package/dist/engine/kolmoWorld.d.ts +7 -15
  31. package/dist/engine/kolmoWorld.js +136 -0
  32. package/dist/engine/longDriveKit.d.ts +4 -2
  33. package/dist/engine/longDriveKit.js +254 -0
  34. package/dist/engine/mainlandMacroCell.d.ts +3 -7
  35. package/dist/engine/mainlandMacroCell.js +247 -0
  36. package/dist/engine/shiftedFixedBody.d.ts +13 -0
  37. package/dist/engine/shiftedFixedBody.js +64 -0
  38. package/dist/importer/ChopShopPanel.js +465 -0
  39. package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
  40. package/dist/importer/DomainWorkshopPanel.js +385 -0
  41. package/dist/importer/GateHudBar.js +312 -0
  42. package/dist/importer/GlbImportGate.js +250 -0
  43. package/dist/importer/ImperativeVehicleRig.js +336 -0
  44. package/dist/importer/ImporterPlinthUikitTags.js +112 -0
  45. package/dist/importer/Step1CalibrationPlinth.js +275 -0
  46. package/dist/importer/Step2UniversalPad.js +244 -0
  47. package/dist/importer/VfxEmitterPool.js +91 -0
  48. package/dist/importer/chopShopActions.d.ts +22 -2
  49. package/dist/importer/chopShopActions.js +232 -0
  50. package/dist/importer/gateStore.d.ts +1 -1
  51. package/dist/importer/gateStore.js +92 -0
  52. package/dist/importer/glbNormalizer.js +133 -0
  53. package/dist/importer/importerWebMcp.d.ts +17 -6
  54. package/dist/importer/importerWebMcp.js +343 -0
  55. package/dist/importer/index.js +22 -3
  56. package/dist/importer/khrCompiler.d.ts +1 -1
  57. package/dist/importer/khrCompiler.js +434 -0
  58. package/dist/importer/launcherBake.js +51 -0
  59. package/dist/importer/meshIslands.d.ts +1 -1
  60. package/dist/importer/meshIslands.js +301 -0
  61. package/dist/importer/surfaceCutter.js +254 -0
  62. package/dist/importer/surfaceTopology.js +183 -0
  63. package/dist/importer/universalGateBake.js +162 -0
  64. package/dist/importer/usdToGlb.js +294 -0
  65. package/dist/importer/useChopShopController.d.ts +11 -2
  66. package/dist/importer/useChopShopController.js +364 -0
  67. package/dist/importer/vehiclePanelAnim.js +214 -0
  68. package/dist/importer/wheelAxlePairing.d.ts +1 -2
  69. package/dist/importer/wheelAxlePairing.js +102 -0
  70. package/dist/index.d.ts +2 -3
  71. package/dist/index.js +69 -14
  72. package/dist/junk/DestructibleTarget.js +154 -0
  73. package/dist/junk/KolmoJunk.js +65 -0
  74. package/dist/junk/ShardPieces.d.ts +6 -4
  75. package/dist/junk/ShardPieces.js +74 -0
  76. package/dist/junk/TargetDecals.js +51 -0
  77. package/dist/junk/bvhShatter.js +55 -0
  78. package/dist/junk/bvhTriCollector.js +78 -0
  79. package/dist/junk/index.js +11 -1
  80. package/dist/junk/junkGeometry.js +69 -0
  81. package/dist/junk/junkImportSanitize.js +54 -0
  82. package/dist/junk/junkImporter.js +95 -0
  83. package/dist/junk/junkLabelCanvas.js +67 -0
  84. package/dist/junk/junkLabels.js +35 -0
  85. package/dist/junk/targetHelpers.js +103 -0
  86. package/dist/junk/targetHitLogic.js +128 -0
  87. package/dist/junk/useTargetAssets.js +102 -0
  88. package/dist/physics/index.d.ts +26 -0
  89. package/dist/physics/index.js +84 -0
  90. package/dist/schema/kolmoSchema.d.ts +2 -1
  91. package/dist/schema/kolmoSchema.js +184 -0
  92. package/dist/shaders/celestialBackdrop.d.ts +1 -1
  93. package/dist/shaders/celestialBackdrop.js +344 -0
  94. package/dist/shaders/index.d.ts +0 -1
  95. package/dist/shaders/index.js +9 -1
  96. package/dist/shaders/plumeAndSparkle.js +271 -0
  97. package/dist/shaders/ps2GlslShared.d.ts +1 -1
  98. package/dist/shaders/ps2GlslShared.js +3 -0
  99. package/dist/shaders/ps2MaterialsTSL.js +65 -0
  100. package/dist/shaders/ps2MaterialsWebGL.js +40 -0
  101. package/dist/shaders/ps2RoadWebGL.js +101 -0
  102. package/dist/shaders/ps2TerrainWebGL.js +54 -0
  103. package/dist/shaders/ps2Textures.js +224 -0
  104. package/dist/shaders/retroPalettes.js +188 -0
  105. package/dist/shaders/retroShader.d.ts +31 -3
  106. package/dist/shaders/retroShader.js +249 -0
  107. package/dist/shaders/tsl.d.ts +1 -0
  108. package/dist/shaders/tsl.js +1 -0
  109. package/dist/vite/index.d.ts +15 -0
  110. package/dist/vite/index.js +90 -0
  111. package/dist/world/frontage.js +32 -0
  112. package/dist/world/index.d.ts +1 -1
  113. package/dist/world/index.js +11 -3
  114. package/dist/world/infiniteWorld2D.js +244 -0
  115. package/dist/world/island.js +201 -0
  116. package/dist/world/macroCellSchema.js +27 -0
  117. package/dist/world/macroKnightAStar.js +171 -0
  118. package/dist/world/random.js +33 -0
  119. package/dist/world/road.js +136 -0
  120. package/dist/world/roadRibbon.d.ts +6 -6
  121. package/dist/world/roadRibbon.js +161 -0
  122. package/dist/world/terrain.js +87 -0
  123. package/dist/world/worldTypes.js +111 -0
  124. package/package.json +36 -19
  125. package/dist/engine-BeKvBM8d.js +0 -1745
  126. package/dist/importer-D9bdcGTh.js +0 -5113
  127. package/dist/junk-B4bC1zAl.js +0 -1049
  128. package/dist/kolmoSurface-DTnrFXH0.js +0 -558
  129. package/dist/shaders-GS71Ek1A.js +0 -1383
  130. package/dist/world-PRWPYrlx.js +0 -947
  131. package/dist/worldTypes-Z0KfdCd0.js +0 -226
@@ -0,0 +1,84 @@
1
+ import { Suspense as e, createContext as t, useContext as n, useLayoutEffect as r, useMemo as i } from "react";
2
+ import * as a from "three";
3
+ import { WorldProvider as o, useWorld as s } from "koota/react";
4
+ import { PhysicsWorld as c } from "@khr3/core";
5
+ import { useCustomGravity as l } from "@pinkaphant/ecctrl/gravity";
6
+ import { jsx as u } from "react/jsx-runtime";
7
+ // src/physics/index.tsx
8
+ var d = t(!1), f = new a.Vector3();
9
+ function p() {
10
+ try {
11
+ return s();
12
+ } catch {
13
+ return null;
14
+ }
15
+ }
16
+ function m(e) {
17
+ return Array.isArray(e);
18
+ }
19
+ function h(e) {
20
+ return typeof e == "object" && !Array.isArray(e) && "kind" in e && e.kind === "point";
21
+ }
22
+ function g({ gravity: t = "planar", paused: n = !1, timeScale: a = 1, maxDelta: s, physicsDebug: g = !1, world: _ = null, children: v, ...y }) {
23
+ let b = p(), x = typeof t == "function", S = m(t), C = t === "custom", w = h(t), T = x || w || C, E = S ? t[0] : 0, D = S ? t[1] : -9.81, O = S ? t[2] : 0, k = w ? t.center[0] : 0, A = w ? t.center[1] : 0, j = w ? t.center[2] : 0, M = w ? t.surfaceG : t === "zero" ? 0 : 9.81, N = x ? t : null, P = i(() => S ? [
24
+ E,
25
+ D,
26
+ O
27
+ ] : T || t === "zero" ? [
28
+ 0,
29
+ 0,
30
+ 0
31
+ ] : [
32
+ 0,
33
+ -9.81,
34
+ 0
35
+ ], [
36
+ S,
37
+ E,
38
+ D,
39
+ O,
40
+ T,
41
+ t === "zero"
42
+ ]);
43
+ r(() => {
44
+ if (C || !x && !w) return;
45
+ let e = l.getState().setGravityField;
46
+ N ? e((e) => N(e, f)) : w && e((e) => {
47
+ f.set(e.x - k, e.y - A, e.z - j);
48
+ let t = f.lengthSq();
49
+ return t < 1e-8 ? f.set(0, -M, 0) : f.multiplyScalar(-M / Math.sqrt(t));
50
+ });
51
+ }, [
52
+ C,
53
+ x,
54
+ w,
55
+ N,
56
+ k,
57
+ A,
58
+ j,
59
+ M
60
+ ]);
61
+ let F = /* @__PURE__ */ u(d.Provider, {
62
+ value: T,
63
+ children: /* @__PURE__ */ u(c, {
64
+ ...y,
65
+ paused: n,
66
+ timeScale: a,
67
+ ...s === void 0 ? {} : { maxDelta: s },
68
+ gravity: P,
69
+ debug: g,
70
+ children: /* @__PURE__ */ u(e, {
71
+ fallback: null,
72
+ children: v
73
+ })
74
+ })
75
+ });
76
+ return _ && _ !== b ? /* @__PURE__ */ u(o, {
77
+ world: _,
78
+ children: F
79
+ }) : F;
80
+ }
81
+ function _() {
82
+ return n(d);
83
+ }
84
+ export { d as KolmoGravityContext, g as KolmoPhysics, _ as useIsKolmoCustomGravity, p as useOptionalKootaWorld };
@@ -2,7 +2,7 @@ import * as THREE from "three";
2
2
  export declare const KOLMO_EXTENSION_NAME: "KOLMO_emitter";
3
3
  export type KolmoEmitterKind = "plume" | "sparkle" | "fume" | "trail" | "flare";
4
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";
5
+ export type KolmoSocketRole = "seat" | "exit" | "grip_primary" | "grip_secondary" | "optic" | "muzzle" | "eject" | "hinge" | "mount" | "contact";
6
6
  export interface KolmoNodeExtension {
7
7
  kind?: KolmoEmitterKind;
8
8
  drive?: KolmoDriveChannel;
@@ -44,6 +44,7 @@ export interface KolmoSignalState {
44
44
  always: number;
45
45
  }
46
46
  export declare function createDefaultSignals(): KolmoSignalState;
47
+ export declare function inferKolmoSocketRole(nodeName: string, explicitRole?: KolmoSocketRole): KolmoSocketRole;
47
48
  /**
48
49
  * Extracts `KOLMO_emitter` directional VFX emitters (-Z nozzle convention) and sockets
49
50
  * from raw `.glb` JSON + live `THREE.Group` scene graph (or cloned `userData.kolmoExtension`).
@@ -0,0 +1,184 @@
1
+ import * as e from "three";
2
+ import { patchGlbJsonChunk as t } from "@khr3/core";
3
+ // src/schema/kolmoSchema.ts
4
+ var n = "KOLMO_emitter";
5
+ function r() {
6
+ return {
7
+ throttle: 0,
8
+ boost: 0,
9
+ brake: 0,
10
+ slip: 0,
11
+ reverse: 0,
12
+ turn_l: 0,
13
+ turn_r: 0,
14
+ headlight: 1,
15
+ fire: 0,
16
+ damage: 0,
17
+ always: 1
18
+ };
19
+ }
20
+ var i = /* @__PURE__ */ new Set([
21
+ "plume",
22
+ "sparkle",
23
+ "fume",
24
+ "trail",
25
+ "flare"
26
+ ]), a = /* @__PURE__ */ new Set([
27
+ "throttle",
28
+ "boost",
29
+ "brake",
30
+ "slip",
31
+ "reverse",
32
+ "turn_l",
33
+ "turn_r",
34
+ "headlight",
35
+ "fire",
36
+ "damage",
37
+ "always"
38
+ ]), o = /* @__PURE__ */ new Set([
39
+ "seat",
40
+ "exit",
41
+ "grip_primary",
42
+ "grip_secondary",
43
+ "optic",
44
+ "muzzle",
45
+ "eject",
46
+ "hinge",
47
+ "mount",
48
+ "contact"
49
+ ]);
50
+ function s(e, t) {
51
+ if (t && o.has(t)) return t;
52
+ let n = e.toLowerCase();
53
+ return n.includes("muzzle") ? "muzzle" : n.includes("eject") ? "eject" : n.includes("palm_primary") || n.includes("grip_primary") ? "grip_primary" : n.includes("forend") || n.includes("grip_secondary") || n.includes("trigger") || n.includes("safety") ? "grip_secondary" : n.includes("seat") || n === "butt" || n.endsWith("_butt") ? "seat" : n.includes("exit") ? "exit" : n.includes("hinge") ? "hinge" : n.includes("foot_") || n.includes("contact") ? "contact" : n.includes("optic") || n.includes("screen_rect") || n.includes("head") ? "optic" : "mount";
54
+ }
55
+ var c = {
56
+ plume: [
57
+ .22,
58
+ .91,
59
+ 1
60
+ ],
61
+ sparkle: [
62
+ 1,
63
+ .72,
64
+ .24
65
+ ],
66
+ fume: [
67
+ .68,
68
+ .74,
69
+ .82
70
+ ],
71
+ trail: [
72
+ .32,
73
+ .88,
74
+ 1
75
+ ],
76
+ flare: [
77
+ 1,
78
+ .18,
79
+ .08
80
+ ]
81
+ }, l = new e.Matrix4(), u = new e.Matrix4(), d = new e.Vector3(), f = new e.Quaternion(), p = new e.Vector3();
82
+ function m(e, t) {
83
+ e.updateMatrixWorld(!0), l.copy(e.matrixWorld).invert();
84
+ let r = /* @__PURE__ */ new Map();
85
+ if (t) {
86
+ let e = t instanceof Uint8Array ? t : new Uint8Array(t), i = new DataView(e.buffer, e.byteOffset, e.byteLength);
87
+ if (e.byteLength >= 20 && i.getUint32(0, !0) === 1179937895) {
88
+ let t = i.getUint32(12, !0), a = JSON.parse(new TextDecoder().decode(e.subarray(20, 20 + t)));
89
+ for (let e of a.nodes ?? []) {
90
+ let t = e.extensions?.[n];
91
+ e.name && t && typeof t == "object" && r.set(e.name, t);
92
+ }
93
+ }
94
+ }
95
+ let s = [], m = [];
96
+ return e.traverse((t) => {
97
+ if (t === e) return;
98
+ let h = r.get(t.name) ?? t.userData?.KOLMO_emitter;
99
+ if (!h || typeof h != "object") return;
100
+ t.userData[n] = h, u.multiplyMatrices(l, t.matrixWorld), u.decompose(d, f, p);
101
+ let g = [
102
+ d.x,
103
+ d.y,
104
+ d.z
105
+ ], _ = [
106
+ f.x,
107
+ f.y,
108
+ f.z,
109
+ f.w
110
+ ];
111
+ if (typeof h.kind == "string" && i.has(h.kind)) {
112
+ let e = h.kind, n = typeof h.drive == "string" && a.has(h.drive) ? h.drive : "always", r = Array.isArray(h.color) && h.color.length === 3 ? h.color : c[e], i = [
113
+ Number(r[0]),
114
+ Number(r[1]),
115
+ Number(r[2])
116
+ ], o = typeof h.size == "number" && h.size > 0 ? h.size : 1;
117
+ s.push({
118
+ nodeName: t.name,
119
+ object: t,
120
+ localPosition: g,
121
+ localQuaternion: _,
122
+ kind: e,
123
+ drive: n,
124
+ color: i,
125
+ size: o
126
+ });
127
+ }
128
+ typeof h.socket == "string" && o.has(h.socket) && m.push({
129
+ nodeName: t.name,
130
+ role: h.socket,
131
+ localPosition: g,
132
+ localQuaternion: _
133
+ });
134
+ }), {
135
+ emitters: s,
136
+ sockets: m
137
+ };
138
+ }
139
+ function h(e, r, i) {
140
+ return r.length === 0 && !i ? e : new Uint8Array(t(e, (e) => {
141
+ let t = e;
142
+ t.extensionsUsed = Array.from(/* @__PURE__ */ new Set([...t.extensionsUsed ?? [], n])), t.nodes = t.nodes ?? [];
143
+ let a = t.scene ?? 0, o = t.scenes?.[a];
144
+ o && i && (o.extras = {
145
+ ...o.extras ?? {},
146
+ ...i
147
+ });
148
+ for (let e of r) {
149
+ let r;
150
+ if (e.spotLight) {
151
+ t.extensionsUsed = Array.from(/* @__PURE__ */ new Set([...t.extensionsUsed, "KHR_lights_punctual"])), t.extensions = t.extensions ?? {};
152
+ let n = t.extensions.KHR_lights_punctual ?? { lights: [] };
153
+ n.lights = n.lights ?? [], r = n.lights.length, n.lights.push({
154
+ name: `${e.nodeName}_spot`,
155
+ type: "spot",
156
+ color: e.spotLight.color,
157
+ intensity: e.spotLight.intensity,
158
+ ...e.spotLight.range ? { range: e.spotLight.range } : {},
159
+ spot: {
160
+ innerConeAngle: e.spotLight.innerConeAngle ?? .22,
161
+ outerConeAngle: e.spotLight.outerConeAngle ?? .58
162
+ }
163
+ }), t.extensions.KHR_lights_punctual = n;
164
+ }
165
+ let i = t.nodes.findIndex((t) => t.name === e.nodeName), a = { [n]: e.extension };
166
+ if (r !== void 0 && (a.KHR_lights_punctual = { light: r }), i >= 0) {
167
+ let n = t.nodes[i];
168
+ n.translation = e.translation, e.rotation && (n.rotation = e.rotation), n.extensions = {
169
+ ...n.extensions ?? {},
170
+ ...a
171
+ };
172
+ } else {
173
+ let n = t.nodes.length;
174
+ t.nodes.push({
175
+ name: e.nodeName,
176
+ translation: e.translation,
177
+ ...e.rotation ? { rotation: e.rotation } : {},
178
+ extensions: a
179
+ }), o && (o.nodes = o.nodes ?? [], o.nodes.push(n));
180
+ }
181
+ }
182
+ }));
183
+ }
184
+ export { n as KOLMO_EXTENSION_NAME, r as createDefaultSignals, m as decodeKolmoRig, s as inferKolmoSocketRole, h as stampKolmoNodesIntoGlb };
@@ -3,7 +3,7 @@ import * as THREE from "three";
3
3
  export declare const KEY_SUN_DIRECTION: THREE.Vector3;
4
4
  export declare const RING_MOONLET_COUNT = 72;
5
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";
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 = ps1Bayer4x4(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}\nvec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStrength) {\n vec4 nearestSample = texture2D(tex, uv);\n if (mixStrength <= 0.001) return nearestSample;\n float ts = max(16.0, texSize);\n vec2 p = uv * ts - 0.5;\n vec2 i = floor(p);\n vec2 f = p - i;\n vec2 inv = 1.0 / vec2(ts);\n vec2 uv00 = (i + vec2(0.5, 0.5)) * inv;\n vec2 uv10 = (i + vec2(1.5, 0.5)) * inv;\n vec2 uv01 = (i + vec2(0.5, 1.5)) * inv;\n vec2 uv11 = (i + vec2(1.5, 1.5)) * inv;\n vec4 c10 = texture2D(tex, uv10);\n vec4 c01 = texture2D(tex, uv01);\n vec4 n64Col;\n if (f.x + f.y < 1.0) {\n vec4 c00 = texture2D(tex, uv00);\n n64Col = c00 + f.x * (c10 - c00) + f.y * (c01 - c00);\n } else {\n vec4 c11 = texture2D(tex, uv11);\n n64Col = c11 + (1.0 - f.y) * (c10 - c11) + (1.0 - f.x) * (c01 - c11);\n }\n return mix(nearestSample, n64Col, clamp(mixStrength, 0.0, 1.0));\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
7
  export interface KolmoSkyboxProps {
8
8
  sunDirection?: [number, number, number];
9
9
  }
@@ -0,0 +1,344 @@
1
+ import { GLSL_BAYER_RGB555 as e, GLSL_RETRO_QUANTIZE as t, RETRO_UNIFORMS as n, applyRetroMaterial as r, getRetroShaderUniforms as i } from "./retroShader.js";
2
+ import { useEffect as a, useMemo as o, useRef as s } from "react";
3
+ import * as c from "three";
4
+ import { useFrame as l } from "@react-three/fiber";
5
+ import { Stars as u } from "@react-three/drei";
6
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
7
+ import { BallCollider as p, RigidBody as m } from "@react-three/rapier";
8
+ // src/shaders/celestialBackdrop.tsx
9
+ var h = new c.Vector3(-.62, .42, -.66).normalize(), g = 72, _ = "varying vec3 vDir; void main() { vDir = normalize(position); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }", v = `
10
+ uniform float uTime, uDitherMix; uniform vec3 uSunDir; varying vec3 vDir;
11
+ ${e}
12
+ float hash(vec3 p) { p = fract(p * 0.3183099 + 0.1) * 17.0; return fract(p.x * p.y * p.z * (p.x + p.y + p.z)); }
13
+ float noise(vec3 x) {
14
+ vec3 i = floor(x), f = fract(x);
15
+ return mix(
16
+ mix(mix(hash(i + vec3(0,0,0)), hash(i + vec3(1,0,0)), f.x), mix(hash(i + vec3(0,1,0)), hash(i + vec3(1,1,0)), f.x), f.y),
17
+ mix(mix(hash(i + vec3(0,0,1)), hash(i + vec3(1,0,1)), f.x), mix(hash(i + vec3(0,1,1)), hash(i + vec3(1,1,1)), f.x), f.y), f.z
18
+ );
19
+ }
20
+ float fbm(vec3 p) { float v = 0.0, a = 0.55; for (int i = 0; i < 3; i++) { v += a * noise(p); p = p * 2.05 + vec3(13.1, 7.7, 5.3); a *= 0.48; } return v; }
21
+ void main() {
22
+ vec3 dir = normalize(vDir);
23
+ float horizon = exp(-abs(dir.y + dir.x * 0.18) * 3.0);
24
+ vec3 col = mix(mix(vec3(0.015, 0.02, 0.055), vec3(0.02, 0.03, 0.08), dir.y * 0.5 + 0.5), vec3(0.08, 0.16, 0.27), horizon * 0.9);
25
+ float n1 = fbm(dir * 2.8 + vec3(0.0, uTime * 0.003, 0.0)), n2 = fbm(dir * 5.0 - vec3(uTime * 0.002, 0.0, 1.4));
26
+ float rawMask = clamp((n1 * 0.72 + n2 * 0.34 - 0.44) * 2.4, 0.0, 1.0) * (0.35 + horizon * 0.85);
27
+ float cloudMask = mix(rawMask, floor(rawMask * 5.0) / 5.0, uDitherMix);
28
+ float sunDot = max(0.0, dot(dir, normalize(uSunDir)));
29
+ vec3 tint = mix(vec3(0.06, 0.38, 0.50), vec3(0.28, 0.12, 0.40), mix(n2, step(0.52, n2), uDitherMix));
30
+ col += mix(tint, vec3(0.62, 0.26, 0.14), pow(sunDot, 2.0) * 0.9) * cloudMask * 0.85;
31
+ float corona = mix(pow(sunDot, 12.0), floor(pow(sunDot, 12.0) * 6.0) / 6.0, uDitherMix);
32
+ col += vec3(0.95, 0.55, 0.22) * corona * 0.65 + vec3(1.0, 0.90, 0.68) * step(0.9965, sunDot) * 1.1;
33
+ float s = hash(floor(dir * 165.0));
34
+ if (s > 0.995) col += mix(vec3(0.74, 0.90, 1.0), vec3(1.0, 0.86, 0.68), step(0.5, fract(s * 91.3))) * 0.95;
35
+ gl_FragColor = vec4(ps1QuantizeRGB555Mix(col, gl_FragCoord.xy, uDitherMix), 1.0);
36
+ }
37
+ `, y = "\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", b = `
38
+ uniform vec3 uSunDir, uColor; uniform float uDitherMix; varying vec3 vNormalWorld, vWorldPos;
39
+ ${t}
40
+ void main() {
41
+ vec3 viewDir = normalize(cameraPosition - vWorldPos);
42
+ float rim = pow(1.0 - max(0.0, dot(viewDir, vNormalWorld)), 2.6), nl = dot(vNormalWorld, normalize(uSunDir));
43
+ float sunLit = mix(smoothstep(-0.3, 0.7, nl), step(-0.25, nl), uDitherMix) * 0.72 + 0.28, alpha = rim * sunLit;
44
+ if (alpha < (ps1BayerDither(gl_FragCoord.xy) * 0.65 + 0.14) * uDitherMix) discard;
45
+ vec3 col = ps1QuantizeRetro(ps1LinearToSrgb(uColor * (0.8 + sunLit * 0.55)), gl_FragCoord.xy, uDitherMix);
46
+ gl_FragColor = vec4(col, mix(alpha * 0.85, 0.75, uDitherMix));
47
+ }
48
+ `;
49
+ function x({ sunDirection: e }) {
50
+ let t = s(null), r = s(null), i = o(() => ({
51
+ uTime: { value: 0 },
52
+ uSunDir: { value: h.clone() },
53
+ uDitherMix: n.uDitherMix
54
+ }), []);
55
+ return a(() => {
56
+ e ? i.uSunDir.value.set(e[0], e[1], e[2]).normalize() : i.uSunDir.value.copy(h);
57
+ }, [
58
+ e?.[0],
59
+ e?.[1],
60
+ e?.[2],
61
+ i
62
+ ]), l((e, n) => {
63
+ t.current && (t.current.uniforms.uTime.value += Math.min(n, .05)), r.current && r.current.position.copy(e.camera.position);
64
+ }), /* @__PURE__ */ f("group", {
65
+ ref: r,
66
+ children: [/* @__PURE__ */ f("mesh", {
67
+ renderOrder: -10,
68
+ frustumCulled: !1,
69
+ children: [/* @__PURE__ */ d("icosahedronGeometry", { args: [3800, 2] }), /* @__PURE__ */ d("shaderMaterial", {
70
+ ref: t,
71
+ uniforms: i,
72
+ vertexShader: _,
73
+ fragmentShader: v,
74
+ side: c.BackSide,
75
+ depthWrite: !1
76
+ })]
77
+ }), /* @__PURE__ */ d(u, {
78
+ radius: 190,
79
+ depth: 130,
80
+ count: 2600,
81
+ factor: 4.5,
82
+ saturation: .35,
83
+ fade: !1,
84
+ speed: .18
85
+ })]
86
+ });
87
+ }
88
+ var S = [
89
+ [
90
+ 0,
91
+ 8,
92
+ 2,
93
+ 10
94
+ ],
95
+ [
96
+ 12,
97
+ 4,
98
+ 14,
99
+ 6
100
+ ],
101
+ [
102
+ 3,
103
+ 11,
104
+ 1,
105
+ 9
106
+ ],
107
+ [
108
+ 15,
109
+ 7,
110
+ 13,
111
+ 5
112
+ ]
113
+ ], C = [
114
+ [
115
+ 14,
116
+ 30,
117
+ 56
118
+ ],
119
+ [
120
+ 24,
121
+ 58,
122
+ 92
123
+ ],
124
+ [
125
+ 42,
126
+ 98,
127
+ 126
128
+ ],
129
+ [
130
+ 76,
131
+ 134,
132
+ 152
133
+ ],
134
+ [
135
+ 186,
136
+ 128,
137
+ 86
138
+ ],
139
+ [
140
+ 232,
141
+ 160,
142
+ 94
143
+ ],
144
+ [
145
+ 172,
146
+ 108,
147
+ 74
148
+ ],
149
+ [
150
+ 68,
151
+ 108,
152
+ 136
153
+ ],
154
+ [
155
+ 34,
156
+ 62,
157
+ 96
158
+ ],
159
+ [
160
+ 16,
161
+ 28,
162
+ 50
163
+ ]
164
+ ], w = (e) => Math.min(255, Math.round(Math.max(0, Math.min(255, e)) / 8.225) * 8);
165
+ function T() {
166
+ let e = /* @__PURE__ */ new Uint8Array(131072);
167
+ for (let t = 0; t < 128; t++) for (let n = 0; n < 256; n++) {
168
+ let r = Math.sin(n / 256 * Math.PI * 8 + t * .16) * 2.8 + Math.cos(n / 256 * Math.PI * 16 - t * .24) * 1.4, i = c.MathUtils.clamp((t + r) / 128 * (C.length - 1), 0, C.length - 1.001), a = Math.floor(i), [o, s, l] = i - a > S[t & 3][n & 3] / 16 ? C[a + 1] : C[a], u = (n - 92.16) / 24, d = (t - 71.68) / 11, f = Math.hypot(u, d);
169
+ if (f < 1) {
170
+ let e = (1 - f) * (.65 + (Math.sin(f * 10 - Math.atan2(d, u) * 2) * .5 + .5) * .35);
171
+ o = o * (1 - e) + 244 * e, s = s * (1 - e) + 148 * e, l = l * (1 - e) + 74 * e;
172
+ }
173
+ let p = ((n * 19 + t * 29 & 15) - 8) * 1.1, m = (t * 256 + n) * 4;
174
+ e[m] = w(o + p), e[m + 1] = w(s + p), e[m + 2] = w(l + p), e[m + 3] = 255;
175
+ }
176
+ let t = new c.DataTexture(e, 256, 128, c.RGBAFormat);
177
+ t.colorSpace = c.SRGBColorSpace, t.wrapS = c.RepeatWrapping, t.minFilter = c.NearestFilter, t.magFilter = c.NearestFilter, t.needsUpdate = !0;
178
+ let n = /* @__PURE__ */ new Uint8Array(1024);
179
+ for (let e = 0; e < 256; e++) {
180
+ let t = e / 255, r = Math.abs(t - .44) < .048 || Math.abs(t - .78) < .024 ? 0 : 1, i = (.62 + .38 * Math.sin(t * 78)) * Math.sin(t * Math.PI) * r, a = e * 4;
181
+ n[a] = w(168 + 68 * Math.sin(t * 11 + .4)), n[a + 1] = w(186 + 44 * Math.cos(t * 16)), n[a + 2] = w(204 + 42 * Math.sin(t * 13 + 1.8)), n[a + 3] = i > .14 ? Math.round(Math.min(.92, Math.round(i * 8) / 8) * 255) : 0;
182
+ }
183
+ let r = new c.DataTexture(n, 256, 1, c.RGBAFormat);
184
+ return r.colorSpace = c.SRGBColorSpace, r.minFilter = c.NearestFilter, r.magFilter = c.NearestFilter, r.needsUpdate = !0, {
185
+ planetMap: t,
186
+ ringMap: r
187
+ };
188
+ }
189
+ function E() {
190
+ let e = new c.DodecahedronGeometry(1, 0), t = e.index ? e.toNonIndexed() : e.clone();
191
+ e.dispose();
192
+ let n = t.attributes.position, r = new Float32Array(n.count * 3);
193
+ for (let e = 0; e < n.count; e++) {
194
+ let t = .48 + e * 17 % 10 * .032;
195
+ r[e * 3] = t * .92, r[e * 3 + 1] = t * .96, r[e * 3 + 2] = t;
196
+ }
197
+ return t.setAttribute("color", new c.BufferAttribute(r, 3)), t.computeVertexNormals(), t;
198
+ }
199
+ function D(e, t, n) {
200
+ let r = new c.Object3D();
201
+ for (let i = 0; i < 72; i++) {
202
+ let a = i / 72 * Math.PI * 2 + i % 5 * .08, o = c.MathUtils.lerp(t + 18, n - 18, i * 37 % 100 / 100), s = (i * 19 % 100 / 100 - .5) * 18, l = 4.5 + i * 13 % 100 / 100 * 14.5;
203
+ r.position.set(Math.cos(a) * o, Math.sin(a) * o, s), r.rotation.set(i * .7, i * 1.1, i * .4), r.scale.set(l * 1.2, l * .8, l), r.updateMatrix(), e.setMatrixAt(i, r.matrix);
204
+ }
205
+ e.instanceMatrix.needsUpdate = !0;
206
+ }
207
+ function O({ position: e = [
208
+ -420,
209
+ 140,
210
+ -980
211
+ ], radius: t = 180, ringInner: n, ringOuter: u, color: g = "#47d7ff", collider: _ = !1, moonlets: v = !0, gravityWellActive: x = !1 }) {
212
+ let S = n ?? t * 1.45, C = u ?? t * 2.35, w = s(null), O = s(null), k = s(null), A = s(null), j = o(() => {
213
+ let { planetMap: e, ringMap: n } = T(), a = new c.SphereGeometry(t, 48, 28), o = a.index ? a.toNonIndexed() : a.clone();
214
+ a.dispose(), o.computeVertexNormals();
215
+ let s = new c.RingGeometry(S, C, 96, 4), l = s.attributes.position, u = s.attributes.uv, d = new c.Vector3();
216
+ for (let e = 0; e < l.count; e++) d.fromBufferAttribute(l, e), u.setXY(e, c.MathUtils.clamp((d.length() - S) / Math.max(.001, C - S), 0, 1), .5);
217
+ u.needsUpdate = !0;
218
+ let f = s.index ? s.toNonIndexed() : s.clone();
219
+ return s.dispose(), f.computeVertexNormals(), {
220
+ planetMap: e,
221
+ ringMap: n,
222
+ planetGeo: o,
223
+ ringGeo: f,
224
+ moonletGeo: E(),
225
+ moonletMat: r(new c.MeshStandardMaterial({
226
+ vertexColors: !0,
227
+ flatShading: !0,
228
+ roughness: .82,
229
+ metalness: .14
230
+ })),
231
+ planetMat: r(new c.MeshStandardMaterial({
232
+ map: e,
233
+ flatShading: !0,
234
+ roughness: .9,
235
+ metalness: .05
236
+ })),
237
+ ringMat: r(new c.MeshStandardMaterial({
238
+ map: n,
239
+ flatShading: !0,
240
+ transparent: !0,
241
+ alphaTest: .12,
242
+ opacity: .94,
243
+ roughness: .84,
244
+ metalness: .1,
245
+ side: c.DoubleSide
246
+ })),
247
+ gravWellMat: r(new c.MeshBasicMaterial({
248
+ color: "#38f2ff",
249
+ transparent: !0,
250
+ opacity: 0,
251
+ side: c.DoubleSide,
252
+ depthWrite: !1,
253
+ toneMapped: !1
254
+ })),
255
+ atmoUniforms: {
256
+ ...i(),
257
+ uSunDir: { value: h.clone() },
258
+ uColor: { value: new c.Color(g) }
259
+ }
260
+ };
261
+ }, [
262
+ t,
263
+ S,
264
+ C,
265
+ g
266
+ ]);
267
+ return a(() => {
268
+ A.current && D(A.current, S, C);
269
+ }, [
270
+ S,
271
+ C,
272
+ v
273
+ ]), a(() => () => {
274
+ j.planetMap.dispose(), j.ringMap.dispose(), j.planetGeo.dispose(), j.ringGeo.dispose(), j.moonletGeo.dispose(), j.moonletMat.dispose(), j.planetMat.dispose(), j.ringMat.dispose(), j.gravWellMat.dispose();
275
+ }, [j]), l((e, t) => {
276
+ let n = Math.min(t, .05);
277
+ w.current && (w.current.rotation.y += n * .018), O.current && (O.current.rotation.z += n * .008), k.current && (k.current.rotation.z -= n * .1, j.gravWellMat.opacity = c.MathUtils.lerp(j.gravWellMat.opacity, x ? .55 : 0, 1 - Math.exp(-5 * n)), k.current.visible = j.gravWellMat.opacity > .02);
278
+ }), /* @__PURE__ */ f("group", {
279
+ position: e,
280
+ children: [
281
+ _ && /* @__PURE__ */ d(m, {
282
+ type: "fixed",
283
+ colliders: !1,
284
+ userData: {
285
+ kind: "planet",
286
+ radius: t
287
+ },
288
+ children: /* @__PURE__ */ d(p, { args: [t * .97] })
289
+ }),
290
+ /* @__PURE__ */ d("mesh", {
291
+ ref: w,
292
+ geometry: j.planetGeo,
293
+ material: j.planetMat,
294
+ receiveShadow: !1
295
+ }),
296
+ /* @__PURE__ */ d("mesh", {
297
+ geometry: j.planetGeo,
298
+ scale: 1.04,
299
+ children: /* @__PURE__ */ d("shaderMaterial", {
300
+ uniforms: j.atmoUniforms,
301
+ vertexShader: y,
302
+ fragmentShader: b,
303
+ transparent: !0,
304
+ depthWrite: !1,
305
+ blending: c.AdditiveBlending
306
+ })
307
+ }),
308
+ /* @__PURE__ */ f("group", {
309
+ ref: O,
310
+ rotation: [
311
+ Math.PI * .39,
312
+ .24,
313
+ -.32
314
+ ],
315
+ children: [
316
+ /* @__PURE__ */ d("mesh", {
317
+ geometry: j.ringGeo,
318
+ material: j.ringMat
319
+ }),
320
+ v && /* @__PURE__ */ d("instancedMesh", {
321
+ ref: A,
322
+ args: [
323
+ j.moonletGeo,
324
+ j.moonletMat,
325
+ 72
326
+ ],
327
+ frustumCulled: !1
328
+ }),
329
+ /* @__PURE__ */ d("mesh", {
330
+ ref: k,
331
+ visible: !1,
332
+ material: j.gravWellMat,
333
+ children: /* @__PURE__ */ d("ringGeometry", { args: [
334
+ C + 14,
335
+ C + 30,
336
+ 64
337
+ ] })
338
+ })
339
+ ]
340
+ })
341
+ ]
342
+ });
343
+ }
344
+ export { b as ATMO_FRAG, y as ATMO_VERT, h as KEY_SUN_DIRECTION, O as KolmoExoplanet, x as KolmoSkybox, g as RING_MOONLET_COUNT, D as populateMoonletMatrices };
@@ -3,4 +3,3 @@ export { PLUME_VERT, PLUME_FRAG, PARTICLE_VERT, PARTICLE_FRAG, KolmoEmitterRig,
3
3
  export { KEY_SUN_DIRECTION, RING_MOONLET_COUNT, ATMO_VERT, ATMO_FRAG, populateMoonletMatrices, KolmoSkybox, KolmoExoplanet, type KolmoSkyboxProps, type KolmoExoplanetProps, } from "./celestialBackdrop.js";
4
4
  export { SPLAT_LAYER, createPS2WorldTextures, generatePS2DetailSlices, type PS2TextureBundle, } from "./ps2Textures.js";
5
5
  export { createPS2RoadMaterialWebGL, createPS2TerrainMaterialWebGL, mountPS2WorldMeshes, type MountedPS2WorldScene, type PS2RoadMaterialOptions, type PS2TerrainMaterialOptions, } from "./ps2MaterialsWebGL.js";
6
- export { createPS2RoadMaterialTSL, createPS2TerrainMaterialTSL, } from "./ps2MaterialsTSL.js";
@@ -1 +1,9 @@
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";
1
+ import { PALETTE_CRUNCHY_16 as e, PALETTE_CRUNCHY_64 as t, RETRO_COLOR_MODES as n, applyRetroFilteringToMaterial as r, applyRetroTextureFiltering as i, buildPaletteLutData as a, computeRetroDpr as o, getColorQuantVector as s, getPaletteLutTexture as c } from "./retroPalettes.js";
2
+ import { GLSL_BAYER_RGB555 as l, GLSL_RETRO_QUANTIZE as u, PS1_SNAP_RESOLUTION as d, RETRO_PRESETS as f, RETRO_UNIFORMS as p, applyPs1Material as m, applyRetroMaterial as h, applySceneRetroMaterials as g, getRetroPreset as _, getRetroShaderUniforms as v, syncRetroUniforms as y, syncRetroViewport as b } from "./retroShader.js";
3
+ import { KolmoEmitterRig as x, PARTICLE_FRAG as S, PARTICLE_VERT as C, PLUME_FRAG as w, PLUME_VERT as T } from "./plumeAndSparkle.js";
4
+ import { ATMO_FRAG as E, ATMO_VERT as D, KEY_SUN_DIRECTION as O, KolmoExoplanet as k, KolmoSkybox as A, RING_MOONLET_COUNT as j, populateMoonletMatrices as M } from "./celestialBackdrop.js";
5
+ import { SPLAT_LAYER as N, createPS2WorldTextures as P, generatePS2DetailSlices as F } from "./ps2Textures.js";
6
+ import { createPS2RoadMaterialWebGL as I } from "./ps2RoadWebGL.js";
7
+ import { createPS2TerrainMaterialWebGL as L } from "./ps2TerrainWebGL.js";
8
+ import { mountPS2WorldMeshes as R } from "./ps2MaterialsWebGL.js";
9
+ export { E as ATMO_FRAG, D as ATMO_VERT, l as GLSL_BAYER_RGB555, u as GLSL_RETRO_QUANTIZE, O as KEY_SUN_DIRECTION, x as KolmoEmitterRig, k as KolmoExoplanet, A as KolmoSkybox, e as PALETTE_CRUNCHY_16, t as PALETTE_CRUNCHY_64, S as PARTICLE_FRAG, C as PARTICLE_VERT, w as PLUME_FRAG, T as PLUME_VERT, d as PS1_SNAP_RESOLUTION, n as RETRO_COLOR_MODES, f as RETRO_PRESETS, p as RETRO_UNIFORMS, j as RING_MOONLET_COUNT, N as SPLAT_LAYER, m as applyPs1Material, r as applyRetroFilteringToMaterial, h as applyRetroMaterial, i as applyRetroTextureFiltering, g as applySceneRetroMaterials, a as buildPaletteLutData, o as computeRetroDpr, I as createPS2RoadMaterialWebGL, L as createPS2TerrainMaterialWebGL, P as createPS2WorldTextures, F as generatePS2DetailSlices, s as getColorQuantVector, c as getPaletteLutTexture, _ as getRetroPreset, v as getRetroShaderUniforms, R as mountPS2WorldMeshes, M as populateMoonletMatrices, y as syncRetroUniforms, b as syncRetroViewport };