shaders 2.2.23 → 2.2.25

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 (213) hide show
  1. package/dist/core/AngularBlur-Dl2gwk68.js +64 -0
  2. package/dist/core/Ascii-Dha_QpT3.js +286 -0
  3. package/dist/core/Beam-CTN9Ni43.js +139 -0
  4. package/dist/core/Blob-CxFDZovO.js +218 -0
  5. package/dist/core/Blur-Y2FsmFk_.js +77 -0
  6. package/dist/core/Bulge-Cb-t0xqI.js +132 -0
  7. package/dist/core/CRTScreen-CtERsenz.js +112 -0
  8. package/dist/core/ChannelBlur-CvM6GJgZ.js +118 -0
  9. package/dist/core/Checkerboard-CgB-egNY.js +83 -0
  10. package/dist/core/ChromaFlow-vRCwhQpN.js +222 -0
  11. package/dist/core/ChromaticAberration-FTquTQIL.js +88 -0
  12. package/dist/core/Circle-Daziv5d7.js +67 -0
  13. package/dist/core/CursorTrail-Bsz9e6Fn.js +145 -0
  14. package/dist/core/DiffuseBlur-Cj2PtRNd.js +83 -0
  15. package/dist/core/Dither-D2Nf4p3w.js +66 -0
  16. package/dist/core/DotGrid-CzOwquo4.js +75 -0
  17. package/dist/core/Duotone-XuTN9tI7.js +65 -0
  18. package/dist/core/FilmGrain-D3-nbi12.js +28 -0
  19. package/dist/core/FloatingParticles-D9Nnu1qg.js +217 -0
  20. package/dist/core/GlassTiles-CnjCvajI.js +69 -0
  21. package/dist/core/Glow-BluFc9be.js +75 -0
  22. package/dist/core/Godrays-ChLh_vGl.js +144 -0
  23. package/dist/core/Grayscale-DRny75A9.js +20 -0
  24. package/dist/core/Grid-DgyDa4H1.js +58 -0
  25. package/dist/core/GridDistortion-BAspCYvp.js +188 -0
  26. package/dist/core/Group-Dul7PUBl.js +14 -0
  27. package/dist/core/Halftone-Ifv5F_FT.js +65 -0
  28. package/dist/core/HueShift-De8ukMWs.js +31 -0
  29. package/dist/core/ImageTexture-DvYcQgJB.js +143 -0
  30. package/dist/core/Invert-Fz0NtIJc.js +21 -0
  31. package/dist/core/LinearBlur-LmhnQoA4.js +62 -0
  32. package/dist/core/LinearGradient-xbloQjzt.js +133 -0
  33. package/dist/core/Liquify-DMe1V5-O.js +175 -0
  34. package/dist/core/Pixelate-Cv8537Pj.js +37 -0
  35. package/dist/core/PolarCoordinates-DDvDhBE-.js +112 -0
  36. package/dist/core/Posterize-3m3xkWOz.js +29 -0
  37. package/dist/core/ProgressiveBlur-EGkevObV.js +121 -0
  38. package/dist/core/RadialGradient-B7ZZB_VJ.js +71 -0
  39. package/dist/core/RectangularCoordinates-muWR8mZS.js +101 -0
  40. package/dist/core/Ripples-8XaZaXQF.js +117 -0
  41. package/dist/core/Saturation-CYFI1jzN.js +30 -0
  42. package/dist/core/SimplexNoise-DJUe0wz_.js +99 -0
  43. package/dist/core/SineWave-Dl3nFO1W.js +120 -0
  44. package/dist/core/SolidColor-CWGq_Bjq.js +21 -0
  45. package/dist/core/Spherize-C-jZEUsN.js +128 -0
  46. package/dist/core/Spiral-BSB_R39p.js +132 -0
  47. package/dist/core/Strands-0stO5BMy.js +161 -0
  48. package/dist/core/Stretch-B645paha.js +133 -0
  49. package/dist/core/Swirl-CVnbawit.js +173 -0
  50. package/dist/core/TiltShift-0CxNRI6L.js +134 -0
  51. package/dist/core/Tritone-Daa-I5UD.js +76 -0
  52. package/dist/core/Twirl-2CJVZEtk.js +96 -0
  53. package/dist/core/Vibrance-DRtecEvb.js +30 -0
  54. package/dist/core/WaveDistortion-BscXN2rs.js +173 -0
  55. package/dist/core/ZoomBlur-CAqK0Kju.js +62 -0
  56. package/dist/core/colorMixing-BXiTAqJU.js +69 -0
  57. package/dist/core/edges-Bn_OIa_h.js +26 -0
  58. package/dist/core/index.js +2257 -1604
  59. package/dist/core/shaderRegistry.d.ts.map +1 -1
  60. package/dist/core/shaders/AngularBlur/index.js +3 -7
  61. package/dist/core/shaders/Ascii/index.js +2 -6
  62. package/dist/core/shaders/Beam/index.d.ts +71 -0
  63. package/dist/core/shaders/Beam/index.d.ts.map +1 -0
  64. package/dist/core/shaders/Beam/index.js +4 -0
  65. package/dist/core/shaders/Blob/index.js +5 -9
  66. package/dist/core/shaders/Blur/index.js +2 -6
  67. package/dist/core/shaders/Bulge/index.js +4 -8
  68. package/dist/core/shaders/CRTScreen/index.js +2 -6
  69. package/dist/core/shaders/ChannelBlur/index.js +2 -6
  70. package/dist/core/shaders/Checkerboard/index.js +4 -8
  71. package/dist/core/shaders/ChromaFlow/index.js +3 -7
  72. package/dist/core/shaders/ChromaticAberration/index.js +3 -7
  73. package/dist/core/shaders/Circle/index.js +3 -7
  74. package/dist/core/shaders/CursorTrail/index.js +4 -8
  75. package/dist/core/shaders/DiffuseBlur/index.js +4 -8
  76. package/dist/core/shaders/Dither/index.js +3 -7
  77. package/dist/core/shaders/DotGrid/index.js +3 -7
  78. package/dist/core/shaders/Duotone/index.js +4 -8
  79. package/dist/core/shaders/FilmGrain/index.js +2 -6
  80. package/dist/core/shaders/FloatingParticles/index.js +3 -7
  81. package/dist/core/shaders/GlassTiles/index.js +2 -6
  82. package/dist/core/shaders/Glow/index.js +2 -6
  83. package/dist/core/shaders/Godrays/index.js +3 -7
  84. package/dist/core/shaders/Grayscale/index.js +2 -8
  85. package/dist/core/shaders/Grid/index.js +3 -7
  86. package/dist/core/shaders/GridDistortion/index.js +4 -8
  87. package/dist/core/shaders/Group/index.js +2 -6
  88. package/dist/core/shaders/Halftone/index.js +3 -7
  89. package/dist/core/shaders/HueShift/index.js +2 -8
  90. package/dist/core/shaders/ImageTexture/index.js +2 -6
  91. package/dist/core/shaders/Invert/index.js +2 -6
  92. package/dist/core/shaders/LinearBlur/index.js +3 -7
  93. package/dist/core/shaders/LinearGradient/index.js +4 -8
  94. package/dist/core/shaders/Liquify/index.js +4 -8
  95. package/dist/core/shaders/Pixelate/index.js +2 -6
  96. package/dist/core/shaders/PolarCoordinates/index.js +4 -8
  97. package/dist/core/shaders/Posterize/index.js +2 -7
  98. package/dist/core/shaders/ProgressiveBlur/index.js +3 -7
  99. package/dist/core/shaders/RadialGradient/index.js +4 -8
  100. package/dist/core/shaders/RectangularCoordinates/index.js +4 -8
  101. package/dist/core/shaders/Ripples/index.js +5 -9
  102. package/dist/core/shaders/Saturation/index.js +2 -8
  103. package/dist/core/shaders/SimplexNoise/index.js +5 -9
  104. package/dist/core/shaders/SineWave/index.js +3 -7
  105. package/dist/core/shaders/SolidColor/index.js +3 -7
  106. package/dist/core/shaders/Spherize/index.js +3 -7
  107. package/dist/core/shaders/Spiral/index.js +4 -8
  108. package/dist/core/shaders/Strands/index.js +4 -8
  109. package/dist/core/shaders/Stretch/index.js +4 -8
  110. package/dist/core/shaders/Swirl/index.js +5 -9
  111. package/dist/core/shaders/TiltShift/index.js +3 -7
  112. package/dist/core/shaders/Tritone/index.js +4 -8
  113. package/dist/core/shaders/Twirl/index.js +4 -8
  114. package/dist/core/shaders/Vibrance/index.js +2 -8
  115. package/dist/core/shaders/WaveDistortion/index.js +4 -8
  116. package/dist/core/shaders/ZoomBlur/index.js +3 -7
  117. package/dist/core/telemetry/index.js +189 -157
  118. package/dist/core/time-CTJvRUZ4.js +10 -0
  119. package/dist/core/transformations-DxfQXZWi.js +4715 -0
  120. package/dist/react/components/Beam.d.ts +31 -0
  121. package/dist/react/components/Beam.d.ts.map +1 -0
  122. package/dist/react/generatePresetCode-CCibXbtZ.js +645 -0
  123. package/dist/react/index.d.ts +1 -0
  124. package/dist/react/index.d.ts.map +1 -1
  125. package/dist/react/index.js +7649 -104600
  126. package/dist/react/utils/generatePresetCode.d.ts.map +1 -1
  127. package/dist/react/utils/generatePresetCode.js +2 -5
  128. package/dist/registry.js +224 -0
  129. package/dist/solid/components/Beam.d.ts +28 -0
  130. package/dist/solid/components/Beam.d.ts.map +1 -0
  131. package/dist/solid/index.d.ts +1 -0
  132. package/dist/solid/index.d.ts.map +1 -1
  133. package/dist/solid/index.js +6691 -102524
  134. package/dist/solid/utils/generatePresetCode.d.ts.map +1 -1
  135. package/dist/solid/utils/generatePresetCode.js +586 -537
  136. package/dist/svelte/components/Beam.svelte.d.ts +19 -0
  137. package/dist/svelte/generatePresetCode-CymgoDq_.js +645 -0
  138. package/dist/svelte/index.d.ts +1 -0
  139. package/dist/svelte/index.js +6175 -102455
  140. package/dist/svelte/utils/generatePresetCode.js +2 -5
  141. package/dist/vue/components/Beam.vue.d.ts +57 -0
  142. package/dist/vue/components/Beam.vue.d.ts.map +1 -0
  143. package/dist/vue/generatePresetCode-CRJmU8iF.js +649 -0
  144. package/dist/vue/index.d.ts +1 -0
  145. package/dist/vue/index.d.ts.map +1 -1
  146. package/dist/vue/index.js +6929 -103492
  147. package/dist/vue/utils/generatePresetCode.d.ts.map +1 -1
  148. package/dist/vue/utils/generatePresetCode.js +2 -5
  149. package/package.json +12 -1
  150. package/dist/core/AngularBlur-ClvtyURQ.js +0 -56
  151. package/dist/core/Ascii-BT0-K_vw.js +0 -196
  152. package/dist/core/Blob-BlQ_1T_8.js +0 -169
  153. package/dist/core/Blur-421AjWLH.js +0 -64
  154. package/dist/core/Bulge-CZRVoR6C.js +0 -103
  155. package/dist/core/CRTScreen-C_U9g_IR.js +0 -91
  156. package/dist/core/ChannelBlur-5pzcB6Zv.js +0 -89
  157. package/dist/core/Checkerboard-CrQkqXhD.js +0 -75
  158. package/dist/core/ChromaFlow-CNrQdL8f.js +0 -134
  159. package/dist/core/ChromaticAberration-D9H7O17Y.js +0 -82
  160. package/dist/core/Circle-DnLaDn8V.js +0 -62
  161. package/dist/core/ColorAdjustment-CKwpE_4M.js +0 -14
  162. package/dist/core/CursorTrail-NY6n97VG.js +0 -105
  163. package/dist/core/DiffuseBlur-C_n01ABk.js +0 -69
  164. package/dist/core/Dither-4s-c4zh4.js +0 -61
  165. package/dist/core/DotGrid-BYl8XdMi.js +0 -61
  166. package/dist/core/Duotone-DbewOoB4.js +0 -66
  167. package/dist/core/FilmGrain-zA_-knOw.js +0 -28
  168. package/dist/core/FloatingParticles-BhVnqMsE.js +0 -160
  169. package/dist/core/GlassTiles-CFI57glh.js +0 -52
  170. package/dist/core/Glow-CQgl3IoS.js +0 -66
  171. package/dist/core/Godrays-BHMix_Bh.js +0 -105
  172. package/dist/core/Grayscale-CAEFLteL.js +0 -21
  173. package/dist/core/Grid-DlM-rVbZ.js +0 -50
  174. package/dist/core/GridDistortion-ZOZphSAT.js +0 -147
  175. package/dist/core/Group-BQAs3RiH.js +0 -17
  176. package/dist/core/Halftone-ci4ga-_J.js +0 -55
  177. package/dist/core/HueShift-CyxzPcJV.js +0 -32
  178. package/dist/core/ImageTexture-CdAGsPuH.js +0 -105
  179. package/dist/core/Invert-iPsiIqNZ.js +0 -20
  180. package/dist/core/LinearBlur-BEaaoIk-.js +0 -56
  181. package/dist/core/LinearGradient-DR_7RxLX.js +0 -111
  182. package/dist/core/Liquify-Bi02_ugh.js +0 -139
  183. package/dist/core/Pixelate-CSsdT1rr.js +0 -38
  184. package/dist/core/PolarCoordinates-D626ml58.js +0 -103
  185. package/dist/core/Posterize-DhZkMaC7.js +0 -46
  186. package/dist/core/ProgressiveBlur-CGtCfLF8.js +0 -102
  187. package/dist/core/RadialGradient-C0_WzmbH.js +0 -71
  188. package/dist/core/RectangularCoordinates-DfXw7fhI.js +0 -92
  189. package/dist/core/Ripples-DkemN3eh.js +0 -106
  190. package/dist/core/Saturation-Dup81Pnq.js +0 -31
  191. package/dist/core/SimplexNoise-BYEiCjDj.js +0 -94
  192. package/dist/core/SineWave-C6MRPtsy.js +0 -107
  193. package/dist/core/SolidColor-BZHRczgb.js +0 -22
  194. package/dist/core/Spherize-DOAnDx2l.js +0 -103
  195. package/dist/core/Spiral-BMjnWXh1.js +0 -115
  196. package/dist/core/Strands-BOVsuJLe.js +0 -125
  197. package/dist/core/Stretch-D6bHc6yp.js +0 -103
  198. package/dist/core/Swirl-BFoc0ImG.js +0 -148
  199. package/dist/core/TSLBase-BFMvTOak.js +0 -8053
  200. package/dist/core/TiltShift-BiNvvhzj.js +0 -114
  201. package/dist/core/Tritone-gdx2AA0m.js +0 -75
  202. package/dist/core/Twirl-BsV8YbqC.js +0 -82
  203. package/dist/core/Vibrance-C182fbSw.js +0 -31
  204. package/dist/core/WaveDistortion-CmaS2zDB.js +0 -132
  205. package/dist/core/ZoomBlur-DLf5xQ16.js +0 -56
  206. package/dist/core/colorMixing--dhzx0ch.js +0 -21
  207. package/dist/core/edges-CDzKsauJ.js +0 -15
  208. package/dist/core/three.tsl-Btj1hLsf.js +0 -43845
  209. package/dist/core/time-DbRMw6Jm.js +0 -10
  210. package/dist/core/transformations-CsrIJXh-.js +0 -3992
  211. package/dist/react/generatePresetCode-DaS7jkcT.js +0 -626
  212. package/dist/svelte/generatePresetCode-DaS7jkcT.js +0 -626
  213. package/dist/vue/generatePresetCode-Cd1B-Y9j.js +0 -632
@@ -0,0 +1,64 @@
1
+ import { o as transformPosition } from "./transformations-DxfQXZWi.js";
2
+ import * as TSL from "three/tsl";
3
+ const componentDefinition = {
4
+ name: "AngularBlur",
5
+ category: "Blurs",
6
+ description: "Radial motion blur rotating around a center point",
7
+ requiresRTT: true,
8
+ requiresChild: true,
9
+ props: {
10
+ intensity: {
11
+ default: 20,
12
+ description: "Intensity of the angular blur effect",
13
+ ui: {
14
+ type: "range",
15
+ min: 0,
16
+ max: 100,
17
+ step: 1,
18
+ label: "Blur Intensity"
19
+ }
20
+ },
21
+ center: {
22
+ default: {
23
+ x: .5,
24
+ y: .5
25
+ },
26
+ transform: transformPosition,
27
+ description: "The center point of the rotation",
28
+ ui: {
29
+ type: "position",
30
+ label: "Center Position"
31
+ }
32
+ }
33
+ },
34
+ fragmentNode: ({ uniforms, childNode, onCleanup }) => {
35
+ const { vec2: vec2$1, vec4: vec4$1, float: float$1, screenUV: screenUV$1, sin: sin$1, cos: cos$1, Fn, convertToTexture: convertToTexture$1 } = TSL;
36
+ if (!childNode) return vec4$1(0, 0, 0, 0);
37
+ const childTexture = convertToTexture$1(childNode);
38
+ onCleanup(() => {
39
+ if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
40
+ });
41
+ const center = vec2$1(uniforms.center.uniform.x, uniforms.center.uniform.y.oneMinus());
42
+ const angle = uniforms.intensity.uniform.mul(.005);
43
+ return Fn(() => {
44
+ const initialCoord = screenUV$1.sub(center);
45
+ const total = vec4$1(0).toVar();
46
+ const totalWeight = float$1(0).toVar();
47
+ const angleStep = angle.div(float$1(31));
48
+ for (let i = 0; i < 32; i++) {
49
+ const t = float$1(i).div(float$1(31)).sub(.5).mul(2);
50
+ const weight = float$1(1).div(float$1(2.506628)).mul(float$1(-.5).mul(t).mul(t).div(float$1(.64)).exp());
51
+ const currentAngle = angleStep.mul(float$1(i));
52
+ const cosAngle = cos$1(currentAngle);
53
+ const sinAngle = sin$1(currentAngle);
54
+ const sampleCoord = vec2$1(initialCoord.x.mul(cosAngle).sub(initialCoord.y.mul(sinAngle)), initialCoord.x.mul(sinAngle).add(initialCoord.y.mul(cosAngle))).add(center);
55
+ const sample = childTexture.sample(sampleCoord).mul(weight);
56
+ total.assign(total.add(sample));
57
+ totalWeight.assign(totalWeight.add(weight));
58
+ }
59
+ return total.div(totalWeight);
60
+ })();
61
+ }
62
+ };
63
+ var AngularBlur_default = componentDefinition;
64
+ export { componentDefinition as n, AngularBlur_default as t };
@@ -0,0 +1,286 @@
1
+ import { DataTexture, NearestFilter, RGBAFormat, UnsignedByteType } from "three";
2
+ import * as TSL from "three/tsl";
3
+ const componentDefinition = {
4
+ name: "Ascii",
5
+ category: "Stylize",
6
+ description: "Convert imagery to ASCII character art",
7
+ requiresRTT: true,
8
+ requiresChild: true,
9
+ props: {
10
+ characters: {
11
+ default: "@%#*+=-:.",
12
+ description: "Characters to use for ASCII effect (light to dark)",
13
+ ui: {
14
+ type: "text",
15
+ label: "Characters"
16
+ }
17
+ },
18
+ cellSize: {
19
+ default: 30,
20
+ description: "Size of each ASCII character cell in pixels",
21
+ ui: {
22
+ type: "range",
23
+ min: 8,
24
+ max: 100,
25
+ step: 1,
26
+ label: "Cell Size"
27
+ }
28
+ },
29
+ fontFamily: {
30
+ default: "JetBrains Mono",
31
+ description: "Font family for characters",
32
+ ui: {
33
+ type: "select",
34
+ options: [
35
+ {
36
+ label: "JetBrains Mono",
37
+ value: "JetBrains Mono"
38
+ },
39
+ {
40
+ label: "Fira Code",
41
+ value: "Fira Code"
42
+ },
43
+ {
44
+ label: "Source Code Pro",
45
+ value: "Source Code Pro"
46
+ },
47
+ {
48
+ label: "IBM Plex Mono",
49
+ value: "IBM Plex Mono"
50
+ },
51
+ {
52
+ label: "Space Mono",
53
+ value: "Space Mono"
54
+ },
55
+ {
56
+ label: "Roboto Mono",
57
+ value: "Roboto Mono"
58
+ },
59
+ {
60
+ label: "Courier Prime",
61
+ value: "Courier Prime"
62
+ }
63
+ ],
64
+ label: "Font Family"
65
+ }
66
+ },
67
+ spacing: {
68
+ default: 1,
69
+ description: "Character size within each cell (1.0 = optimal size, 0.0 = smallest)",
70
+ ui: {
71
+ type: "range",
72
+ min: 0,
73
+ max: 1,
74
+ step: .05,
75
+ label: "Character Size"
76
+ },
77
+ transform: (value) => .1 + value * 1.4
78
+ }
79
+ },
80
+ fragmentNode: ({ uniforms, childNode, onCleanup, onBeforeRender }) => {
81
+ const { vec2: vec2$1, vec3: vec3$1, vec4: vec4$1, floor, fract, dot: dot$1, ceil, sqrt: sqrt$1, screenUV: screenUV$1, texture, viewportSize: viewportSize$1, convertToTexture: convertToTexture$1 } = TSL;
82
+ if (!childNode) return vec4$1(0, 0, 0, 0);
83
+ const childTexture = convertToTexture$1(childNode);
84
+ onCleanup(() => {
85
+ if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
86
+ });
87
+ const ATLAS_TEXTURE_SIZE = 2048;
88
+ const GOOGLE_FONTS_MAP = {
89
+ "JetBrains Mono": "JetBrains+Mono",
90
+ "Fira Code": "Fira+Code",
91
+ "Source Code Pro": "Source+Code+Pro",
92
+ "IBM Plex Mono": "IBM+Plex+Mono",
93
+ "Space Mono": "Space+Mono",
94
+ "Roboto Mono": "Roboto+Mono",
95
+ "Courier Prime": "Courier+Prime"
96
+ };
97
+ const loadedFonts = /* @__PURE__ */ new Set();
98
+ async function loadGoogleFont(fontFamily) {
99
+ if (loadedFonts.has(fontFamily)) return;
100
+ if (!GOOGLE_FONTS_MAP[fontFamily]) return;
101
+ const googleFontName = GOOGLE_FONTS_MAP[fontFamily];
102
+ if (!document.querySelector(`link[href*="${googleFontName}"]`)) {
103
+ const link = document.createElement("link");
104
+ link.rel = "stylesheet";
105
+ link.href = `https://fonts.googleapis.com/css2?family=${googleFontName}:wght@400&display=swap`;
106
+ document.head.appendChild(link);
107
+ }
108
+ try {
109
+ if (document.fonts && document.fonts.load) {
110
+ const specs = [
111
+ `400 12px "${fontFamily}"`,
112
+ `12px "${fontFamily}"`,
113
+ `400 12px ${fontFamily}`,
114
+ `12px ${fontFamily}`
115
+ ];
116
+ for (const spec of specs) try {
117
+ await document.fonts.load(spec);
118
+ break;
119
+ } catch (e) {}
120
+ await new Promise((resolve) => setTimeout(resolve, 500));
121
+ loadedFonts.add(fontFamily);
122
+ } else {
123
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
124
+ loadedFonts.add(fontFamily);
125
+ }
126
+ } catch (error) {}
127
+ }
128
+ const createCharacterAtlas = async (characters, cellSize, fontFamily, spacing) => {
129
+ if (!characters || characters.length === 0) throw new Error("Characters string cannot be empty");
130
+ const charCount$1 = characters.length;
131
+ const atlasSize$1 = Math.max(2, Math.ceil(Math.sqrt(charCount$1)));
132
+ const baseAtlasCellSize = 128;
133
+ const spacingMultiplier = Math.max(1, 2 / spacing);
134
+ const actualCellSize = Math.min(baseAtlasCellSize * spacingMultiplier, ATLAS_TEXTURE_SIZE / atlasSize$1);
135
+ const fontSize = actualCellSize * .75;
136
+ const atlasCanvas = document.createElement("canvas");
137
+ atlasCanvas.width = ATLAS_TEXTURE_SIZE;
138
+ atlasCanvas.height = ATLAS_TEXTURE_SIZE;
139
+ const ctx = atlasCanvas.getContext("2d");
140
+ ctx.clearRect(0, 0, atlasCanvas.width, atlasCanvas.height);
141
+ ctx.fillStyle = "#ffffff";
142
+ ctx.font = `${fontSize}px "${fontFamily}", ${fontFamily}, monospace`;
143
+ if (!ctx.font.includes(fontFamily) && !ctx.font.includes("IBM") && !ctx.font.includes("Plex")) ctx.font = `${fontSize}px ${fontFamily}, monospace`;
144
+ ctx.textAlign = "center";
145
+ ctx.textBaseline = "middle";
146
+ for (let i = 0; i < charCount$1; i++) {
147
+ const char = characters[i];
148
+ const row = Math.floor(i / atlasSize$1);
149
+ const x = i % atlasSize$1 * actualCellSize + actualCellSize / 2;
150
+ const y = row * actualCellSize + actualCellSize / 2;
151
+ ctx.fillText(char, x, y);
152
+ }
153
+ const imageData = ctx.getImageData(0, 0, atlasCanvas.width, atlasCanvas.height);
154
+ return {
155
+ data: new Uint8Array(imageData.data),
156
+ width: ATLAS_TEXTURE_SIZE,
157
+ height: ATLAS_TEXTURE_SIZE,
158
+ atlasSize: atlasSize$1,
159
+ cellSize,
160
+ charCount: charCount$1,
161
+ characters,
162
+ fontFamily,
163
+ uvScale: atlasSize$1 * actualCellSize / ATLAS_TEXTURE_SIZE
164
+ };
165
+ };
166
+ const defaultCharacters = componentDefinition.props.characters.default;
167
+ const defaultCellSize = componentDefinition.props.cellSize.default;
168
+ const defaultFontFamily = componentDefinition.props.fontFamily.default;
169
+ const defaultSpacing = componentDefinition.props.spacing.transform ? componentDefinition.props.spacing.transform(componentDefinition.props.spacing.default) : componentDefinition.props.spacing.default;
170
+ const initialCharacters = uniforms?.characters?.uniform?.value ?? defaultCharacters;
171
+ const initialCellSize = uniforms?.cellSize?.uniform?.value ?? defaultCellSize;
172
+ const initialFontFamily = uniforms?.fontFamily?.uniform?.value ?? defaultFontFamily;
173
+ const initialSpacing = uniforms?.spacing?.uniform?.value ?? defaultSpacing;
174
+ let atlasData = {
175
+ data: new Uint8Array(ATLAS_TEXTURE_SIZE * ATLAS_TEXTURE_SIZE * 4),
176
+ width: ATLAS_TEXTURE_SIZE,
177
+ height: ATLAS_TEXTURE_SIZE,
178
+ atlasSize: 3,
179
+ cellSize: initialCellSize,
180
+ charCount: initialCharacters.length,
181
+ characters: initialCharacters,
182
+ fontFamily: initialFontFamily,
183
+ uvScale: 1
184
+ };
185
+ const atlasTexture = new DataTexture(atlasData.data, ATLAS_TEXTURE_SIZE, ATLAS_TEXTURE_SIZE, RGBAFormat, UnsignedByteType);
186
+ atlasTexture.minFilter = NearestFilter;
187
+ atlasTexture.magFilter = NearestFilter;
188
+ atlasTexture.generateMipmaps = false;
189
+ atlasTexture.needsUpdate = true;
190
+ const atlasField = texture(atlasTexture);
191
+ const charCountUniform = TSL.uniform(atlasData.charCount);
192
+ const cellSizeUniform = TSL.uniform(atlasData.cellSize);
193
+ const atlasScaleUniform = TSL.uniform(atlasData.uvScale);
194
+ let lastCharacters = initialCharacters;
195
+ let lastCellSize = initialCellSize;
196
+ let lastFontFamily = initialFontFamily;
197
+ let lastSpacing = initialSpacing;
198
+ const initializeAtlas = async () => {
199
+ const currentCharacters = uniforms?.characters?.uniform?.value ?? lastCharacters;
200
+ const currentCellSize = uniforms?.cellSize?.uniform?.value ?? lastCellSize;
201
+ const currentFontFamily = uniforms?.fontFamily?.uniform?.value ?? lastFontFamily;
202
+ const currentSpacing = uniforms?.spacing?.uniform?.value ?? lastSpacing;
203
+ atlasData = await createCharacterAtlas(currentCharacters, currentCellSize, currentFontFamily, currentSpacing);
204
+ atlasTexture.image.data = atlasData.data;
205
+ atlasTexture.needsUpdate = true;
206
+ charCountUniform.value = atlasData.charCount;
207
+ cellSizeUniform.value = atlasData.cellSize;
208
+ atlasScaleUniform.value = atlasData.uvScale;
209
+ lastCharacters = currentCharacters;
210
+ lastCellSize = currentCellSize;
211
+ lastFontFamily = currentFontFamily;
212
+ lastSpacing = currentSpacing;
213
+ };
214
+ setTimeout(() => {
215
+ initializeAtlas().catch((error) => {
216
+ console.error("Failed to initialize atlas:", error);
217
+ });
218
+ loadGoogleFont(uniforms?.fontFamily?.uniform?.value ?? initialFontFamily).then(() => {
219
+ initializeAtlas().catch((error) => {
220
+ console.error("Failed to update atlas with custom font:", error);
221
+ });
222
+ }).catch((error) => {
223
+ console.error("Failed to load font:", error);
224
+ });
225
+ }, 0);
226
+ let lastUpdateTime = 0;
227
+ let isUpdating = false;
228
+ onBeforeRender(() => {
229
+ const now = Date.now();
230
+ if (now - lastUpdateTime < 16 || isUpdating) return;
231
+ const currentCharacters = uniforms.characters?.uniform?.value ?? lastCharacters;
232
+ const currentCellSize = uniforms.cellSize?.uniform?.value ?? lastCellSize;
233
+ const currentFontFamily = uniforms.fontFamily?.uniform?.value ?? lastFontFamily;
234
+ const currentSpacing = uniforms.spacing?.uniform?.value ?? lastSpacing;
235
+ if (!currentCharacters || currentCharacters.length === 0) return;
236
+ if (currentCharacters !== lastCharacters || currentCellSize !== lastCellSize || currentFontFamily !== lastFontFamily || currentSpacing !== lastSpacing) {
237
+ lastUpdateTime = now;
238
+ isUpdating = true;
239
+ createCharacterAtlas(currentCharacters, currentCellSize, currentFontFamily, currentSpacing).then((newAtlasData) => {
240
+ atlasData = newAtlasData;
241
+ atlasTexture.image.data = atlasData.data;
242
+ atlasTexture.needsUpdate = true;
243
+ charCountUniform.value = atlasData.charCount;
244
+ cellSizeUniform.value = atlasData.cellSize;
245
+ atlasScaleUniform.value = atlasData.uvScale;
246
+ lastCharacters = currentCharacters;
247
+ lastCellSize = currentCellSize;
248
+ lastFontFamily = currentFontFamily;
249
+ lastSpacing = currentSpacing;
250
+ isUpdating = false;
251
+ }).catch((error) => {
252
+ console.error("Failed to update atlas:", error);
253
+ isUpdating = false;
254
+ });
255
+ }
256
+ });
257
+ onCleanup(() => {
258
+ atlasTexture.dispose();
259
+ });
260
+ const effectiveCellSize = cellSizeUniform.mul(1.5);
261
+ const mainGridSize = viewportSize$1.div(effectiveCellSize);
262
+ const gridCoords = screenUV$1.mul(mainGridSize);
263
+ const cellCoords = floor(gridCoords);
264
+ const rawCellUV = fract(gridCoords);
265
+ const characterSize = uniforms.spacing?.uniform ?? TSL.uniform(initialSpacing);
266
+ const center = vec2$1(.5);
267
+ const centeredUV = rawCellUV.sub(center);
268
+ const cellUV = centeredUV.div(characterSize).add(center);
269
+ const isOutsideBounds = TSL.any(TSL.greaterThan(TSL.abs(centeredUV), vec2$1(characterSize.mul(.5))));
270
+ const cellCenter = cellCoords.add(vec2$1(.5)).div(mainGridSize);
271
+ const cellColor = childTexture.sample(cellCenter);
272
+ const rawBrightness = dot$1(cellColor.rgb, vec3$1(.299, .587, .114));
273
+ const charCount = charCountUniform;
274
+ const charIndex = floor(rawBrightness.mul(.8).add(.1).mul(charCount).min(charCount.sub(1e-4)));
275
+ const atlasSize = ceil(sqrt$1(charCount));
276
+ const atlasCol = charIndex.mod(atlasSize);
277
+ const atlasRow = floor(charIndex.div(atlasSize));
278
+ const atlasCellSize = TSL.float(1).div(atlasSize).mul(atlasScaleUniform);
279
+ const atlasSampleUV = vec2$1(atlasCol, atlasRow).mul(atlasCellSize).add(cellUV.mul(atlasCellSize));
280
+ const asciiChar = atlasField.sample(atlasSampleUV);
281
+ const isBackground = dot$1(asciiChar.rgb, vec3$1(.299, .587, .114)).lessThan(.1);
282
+ return vec4$1(asciiChar.rgb.mul(cellColor.rgb), TSL.select(TSL.or(isBackground, isOutsideBounds), TSL.float(0), cellColor.a));
283
+ }
284
+ };
285
+ var Ascii_default = componentDefinition;
286
+ export { componentDefinition as n, Ascii_default as t };
@@ -0,0 +1,139 @@
1
+ import { i as transformColorSpace, o as transformPosition, r as transformColor, t as colorSpaceOptions } from "./transformations-DxfQXZWi.js";
2
+ import { t as mixColors } from "./colorMixing-BXiTAqJU.js";
3
+ import * as TSL from "three/tsl";
4
+ const componentDefinition = {
5
+ name: "Beam",
6
+ category: "Base Layers",
7
+ description: "A beam of light from one point to another.",
8
+ acceptsUVContext: true,
9
+ props: {
10
+ startPosition: {
11
+ default: {
12
+ x: .2,
13
+ y: .5
14
+ },
15
+ transform: transformPosition,
16
+ description: "Starting point of the beam",
17
+ ui: {
18
+ type: "position",
19
+ label: "Start Position"
20
+ }
21
+ },
22
+ endPosition: {
23
+ default: {
24
+ x: .8,
25
+ y: .5
26
+ },
27
+ transform: transformPosition,
28
+ description: "Ending point of the beam",
29
+ ui: {
30
+ type: "position",
31
+ label: "End Position"
32
+ }
33
+ },
34
+ startThickness: {
35
+ default: .2,
36
+ description: "Thickness at the start of the beam",
37
+ ui: {
38
+ type: "range",
39
+ min: 0,
40
+ max: 2,
41
+ step: .01,
42
+ label: "Start Thickness"
43
+ }
44
+ },
45
+ endThickness: {
46
+ default: .2,
47
+ description: "Thickness at the end of the beam",
48
+ ui: {
49
+ type: "range",
50
+ min: 0,
51
+ max: 2,
52
+ step: .01,
53
+ label: "End Thickness"
54
+ }
55
+ },
56
+ startSoftness: {
57
+ default: .5,
58
+ description: "Edge softness at the start of the beam",
59
+ ui: {
60
+ type: "range",
61
+ min: 0,
62
+ max: 50,
63
+ step: .01,
64
+ label: "Start Softness"
65
+ }
66
+ },
67
+ endSoftness: {
68
+ default: .5,
69
+ description: "Edge softness at the end of the beam",
70
+ ui: {
71
+ type: "range",
72
+ min: 0,
73
+ max: 20,
74
+ step: .01,
75
+ label: "End Softness"
76
+ }
77
+ },
78
+ insideColor: {
79
+ default: "#FF0000",
80
+ transform: transformColor,
81
+ description: "Color at the center of the beam",
82
+ ui: {
83
+ type: "color",
84
+ label: "Inside Color"
85
+ }
86
+ },
87
+ outsideColor: {
88
+ default: "#0000FF",
89
+ transform: transformColor,
90
+ description: "Color at the edges of the beam",
91
+ ui: {
92
+ type: "color",
93
+ label: "Outside Color"
94
+ }
95
+ },
96
+ colorSpace: {
97
+ default: "linear",
98
+ transform: transformColorSpace,
99
+ description: "Color space for color interpolation",
100
+ ui: {
101
+ type: "select",
102
+ options: colorSpaceOptions,
103
+ label: "Color Space"
104
+ }
105
+ }
106
+ },
107
+ fragmentNode: ({ uniforms, uvContext }) => {
108
+ const { vec2: vec2$1, vec4: vec4$1, float: float$1, screenUV: screenUV$1, viewportSize: viewportSize$1, sqrt: sqrt$1, max: max$1, smoothstep, mix: mix$1, clamp: clamp$1, pow: pow$1 } = TSL;
109
+ const baseUV = uvContext ?? screenUV$1;
110
+ const aspect = viewportSize$1.x.div(viewportSize$1.y);
111
+ const startPos = vec2$1(uniforms.startPosition.uniform.x, uniforms.startPosition.uniform.y.oneMinus());
112
+ const endPos = vec2$1(uniforms.endPosition.uniform.x, uniforms.endPosition.uniform.y.oneMinus());
113
+ const aspectCorrectedStart = vec2$1(startPos.x.mul(aspect), startPos.y);
114
+ const aspectCorrectedEnd = vec2$1(endPos.x.mul(aspect), endPos.y);
115
+ const aspectCorrectedUV = vec2$1(baseUV.x.mul(aspect), baseUV.y);
116
+ const lineVec = vec2$1(aspectCorrectedEnd.x.sub(aspectCorrectedStart.x), aspectCorrectedEnd.y.sub(aspectCorrectedStart.y));
117
+ const toPoint = vec2$1(aspectCorrectedUV.x.sub(aspectCorrectedStart.x), aspectCorrectedUV.y.sub(aspectCorrectedStart.y));
118
+ const dotProduct = toPoint.x.mul(lineVec.x).add(toPoint.y.mul(lineVec.y));
119
+ const lineLengthSq = lineVec.x.mul(lineVec.x).add(lineVec.y.mul(lineVec.y));
120
+ const t = clamp$1(dotProduct.div(max$1(lineLengthSq, float$1(1e-4))), float$1(0), float$1(1));
121
+ const closestPoint = vec2$1(aspectCorrectedStart.x.add(lineVec.x.mul(t)), aspectCorrectedStart.y.add(lineVec.y.mul(t)));
122
+ const distVec = vec2$1(aspectCorrectedUV.x.sub(closestPoint.x), aspectCorrectedUV.y.sub(closestPoint.y));
123
+ const distance = sqrt$1(distVec.x.mul(distVec.x).add(distVec.y.mul(distVec.y)));
124
+ const thickness = mix$1(uniforms.startThickness.uniform.mul(.25), uniforms.endThickness.uniform.mul(.25), t);
125
+ const startSoft = uniforms.startSoftness.uniform;
126
+ const endSoft = uniforms.endSoftness.uniform;
127
+ const softness = mix$1(startSoft, endSoft, t);
128
+ const normalizedDist = distance.div(max$1(thickness, float$1(1e-4)));
129
+ const edgeEnd = float$1(1).add(softness);
130
+ const alpha = pow$1(float$1(1).sub(smoothstep(float$1(1), edgeEnd, normalizedDist)), float$1(1).add(softness.mul(1.5)));
131
+ const colorT = smoothstep(float$1(1).sub(softness), float$1(1).add(softness), normalizedDist);
132
+ const insideCol = uniforms.insideColor.uniform;
133
+ const outsideCol = uniforms.outsideColor.uniform;
134
+ const beamColorRGB = mixColors(insideCol, outsideCol, colorT, uniforms.colorSpace.uniform).rgb;
135
+ return vec4$1(beamColorRGB, insideCol.a.add(outsideCol.a).div(float$1(2)).mul(alpha));
136
+ }
137
+ };
138
+ var Beam_default = componentDefinition;
139
+ export { componentDefinition as n, Beam_default as t };