@designbasekorea/ui-wc 0.5.5 → 0.5.6

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 (155) hide show
  1. package/dist/chunks/lottie-e273b936.js +17032 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +121 -1
  3. package/dist/esm/components/animation-background/controls.js +180 -1
  4. package/dist/esm/components/animation-background/graphite-controller.js +196 -1
  5. package/dist/esm/components/animation-background/graphite-presets.js +42 -1
  6. package/dist/esm/components/animation-background/graphite-shader.js +111 -1
  7. package/dist/esm/components/animation-background/layers.js +369 -1
  8. package/dist/esm/components/animation-background/lumina-presets.js +53 -1
  9. package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
  10. package/dist/esm/components/animation-background/lumina-utils.js +60 -1
  11. package/dist/esm/components/animation-background/particle-defaults.js +36 -1
  12. package/dist/esm/components/animation-background/renderers.js +167 -1
  13. package/dist/esm/components/animation-background/shader-controller.js +154 -1
  14. package/dist/esm/components/color-picker-utils.js +134 -1
  15. package/dist/esm/components/date-picker-utils.js +140 -1
  16. package/dist/esm/components/db-accordion.js +304 -1
  17. package/dist/esm/components/db-ad-banner.js +455 -1
  18. package/dist/esm/components/db-alert.js +149 -1
  19. package/dist/esm/components/db-animation-background.js +486 -1
  20. package/dist/esm/components/db-animation-text.js +601 -1
  21. package/dist/esm/components/db-app-badge.js +88 -1
  22. package/dist/esm/components/db-audio-player.js +752 -1
  23. package/dist/esm/components/db-avatar.js +188 -1
  24. package/dist/esm/components/db-backdrop.js +139 -1
  25. package/dist/esm/components/db-badge.js +91 -1
  26. package/dist/esm/components/db-banner.js +188 -1
  27. package/dist/esm/components/db-bottom-navigation.js +146 -1
  28. package/dist/esm/components/db-bottom-sheet.js +481 -1
  29. package/dist/esm/components/db-breadcrumbs.js +329 -1
  30. package/dist/esm/components/db-button.js +316 -1
  31. package/dist/esm/components/db-calendar.js +675 -1
  32. package/dist/esm/components/db-card.js +265 -1
  33. package/dist/esm/components/db-carousel.js +264 -1
  34. package/dist/esm/components/db-checkbox.js +202 -1
  35. package/dist/esm/components/db-chip.js +104 -1
  36. package/dist/esm/components/db-code-block.js +304 -1
  37. package/dist/esm/components/db-color-picker.js +746 -1
  38. package/dist/esm/components/db-confirm.js +191 -1
  39. package/dist/esm/components/db-container.js +39 -1
  40. package/dist/esm/components/db-context-menu.js +265 -1
  41. package/dist/esm/components/db-countdown.js +146 -1
  42. package/dist/esm/components/db-cursor-follower.js +173 -1
  43. package/dist/esm/components/db-date-picker.js +837 -1
  44. package/dist/esm/components/db-divider.js +66 -1
  45. package/dist/esm/components/db-drawer.js +245 -1
  46. package/dist/esm/components/db-dropdown.js +493 -1
  47. package/dist/esm/components/db-dropzone.js +266 -1
  48. package/dist/esm/components/db-empty-state.js +97 -1
  49. package/dist/esm/components/db-file-uploader.js +256 -1
  50. package/dist/esm/components/db-floating-action-button.js +139 -1
  51. package/dist/esm/components/db-footer.js +385 -1
  52. package/dist/esm/components/db-form.js +566 -1
  53. package/dist/esm/components/db-gantt.js +882 -1
  54. package/dist/esm/components/db-gradient.js +133 -1
  55. package/dist/esm/components/db-grid-background.js +909 -1
  56. package/dist/esm/components/db-grid.js +73 -1
  57. package/dist/esm/components/db-icons.js +82 -1
  58. package/dist/esm/components/db-image-list.js +214 -1
  59. package/dist/esm/components/db-image-placeholder.js +96 -1
  60. package/dist/esm/components/db-image.js +289 -1
  61. package/dist/esm/components/db-indicator.js +517 -1
  62. package/dist/esm/components/db-input.js +420 -1
  63. package/dist/esm/components/db-kanban.js +538 -1
  64. package/dist/esm/components/db-label.js +66 -1
  65. package/dist/esm/components/db-lightbox.js +372 -1
  66. package/dist/esm/components/db-list.js +340 -1
  67. package/dist/esm/components/db-logo-svg.js +72 -1
  68. package/dist/esm/components/db-logo.js +106 -1
  69. package/dist/esm/components/db-lottie.js +109 -1
  70. package/dist/esm/components/db-markdown-editor.js +458 -1
  71. package/dist/esm/components/db-marquee.js +402 -1
  72. package/dist/esm/components/db-masonry.js +94 -1
  73. package/dist/esm/components/db-menu-item.js +211 -1
  74. package/dist/esm/components/db-modal.js +522 -1
  75. package/dist/esm/components/db-navbar.js +680 -1
  76. package/dist/esm/components/db-onboarding-modal.js +322 -1
  77. package/dist/esm/components/db-page-header.js +312 -1
  78. package/dist/esm/components/db-pagination.js +271 -1
  79. package/dist/esm/components/db-popover.js +580 -1
  80. package/dist/esm/components/db-progress-step.js +166 -1
  81. package/dist/esm/components/db-progress.js +171 -1
  82. package/dist/esm/components/db-progressbar.js +72 -1
  83. package/dist/esm/components/db-radio.js +172 -1
  84. package/dist/esm/components/db-random-gradient.js +121 -1
  85. package/dist/esm/components/db-range-slider.js +811 -1
  86. package/dist/esm/components/db-rating.js +325 -1
  87. package/dist/esm/components/db-reorder.js +286 -1
  88. package/dist/esm/components/db-resizable-panels.js +282 -1
  89. package/dist/esm/components/db-scroll-area.js +126 -1
  90. package/dist/esm/components/db-search-bar.js +668 -1
  91. package/dist/esm/components/db-section-app-download.js +101 -1
  92. package/dist/esm/components/db-section-contact.js +102 -1
  93. package/dist/esm/components/db-section-cta.js +150 -1
  94. package/dist/esm/components/db-section-faq.js +120 -1
  95. package/dist/esm/components/db-section-feature-grid.js +137 -1
  96. package/dist/esm/components/db-section-feature.js +179 -1
  97. package/dist/esm/components/db-section-hero.js +243 -1
  98. package/dist/esm/components/db-section-logo-cloud.js +138 -1
  99. package/dist/esm/components/db-section-pricing.js +166 -1
  100. package/dist/esm/components/db-section-stats.js +129 -1
  101. package/dist/esm/components/db-section-testimonials.js +252 -1
  102. package/dist/esm/components/db-section.js +385 -1
  103. package/dist/esm/components/db-segment-control.js +231 -1
  104. package/dist/esm/components/db-select.js +571 -1
  105. package/dist/esm/components/db-share-icons.js +40 -1
  106. package/dist/esm/components/db-share.js +489 -1
  107. package/dist/esm/components/db-sidebar.js +1068 -1
  108. package/dist/esm/components/db-skeleton.js +94 -1
  109. package/dist/esm/components/db-spinner.js +102 -1
  110. package/dist/esm/components/db-split-view.js +297 -1
  111. package/dist/esm/components/db-stack.js +46 -1
  112. package/dist/esm/components/db-stat.js +218 -1
  113. package/dist/esm/components/db-stepper.js +398 -1
  114. package/dist/esm/components/db-table.js +412 -1
  115. package/dist/esm/components/db-tabs.js +335 -1
  116. package/dist/esm/components/db-testimonial.js +162 -1
  117. package/dist/esm/components/db-textarea.js +233 -1
  118. package/dist/esm/components/db-time-picker.js +523 -1
  119. package/dist/esm/components/db-timeline.js +174 -1
  120. package/dist/esm/components/db-toast.js +158 -1
  121. package/dist/esm/components/db-toggle.js +162 -1
  122. package/dist/esm/components/db-toolbar.js +94 -1
  123. package/dist/esm/components/db-tooltip.js +440 -1
  124. package/dist/esm/components/db-top-banner.js +121 -1
  125. package/dist/esm/components/db-tutorial.js +324 -1
  126. package/dist/esm/components/db-video-player.js +503 -1
  127. package/dist/esm/components/db-youtube-player.js +194 -1
  128. package/dist/esm/components/highlight-code.js +65 -1
  129. package/dist/esm/components/input-validation.js +50 -1
  130. package/dist/esm/components/marketing-block-host-utils.js +9 -1
  131. package/dist/esm/components/number-scrub.js +117 -1
  132. package/dist/esm/components/random-gradient-palettes.js +67 -1
  133. package/dist/esm/components/section-block-header-utils.js +48 -1
  134. package/dist/esm/helpers/confirm.js +52 -1
  135. package/dist/esm/helpers/toast.js +73 -1
  136. package/dist/esm/index.js +111 -1
  137. package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
  138. package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
  139. package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
  140. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
  141. package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
  142. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
  143. package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
  144. package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
  145. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
  146. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
  147. package/dist/index.cjs +55414 -1
  148. package/dist/index.css +1 -1
  149. package/dist/index.esm.js +38284 -1
  150. package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
  151. package/dist/react/index.cjs +56503 -1
  152. package/dist/react/index.esm.js +39373 -1
  153. package/package.json +1 -1
  154. package/dist/chunks/lottie-2637aa0f.js +0 -1
  155. package/dist/react/chunks/lottie-14e7addb.js +0 -1
@@ -1 +1,181 @@
1
- const o="\n attribute vec4 aVertexPosition;\n void main() {\n gl_Position = aVertexPosition;\n }\n";function getLuminaFragmentShader(o){switch(o){case"mesh-flow":return"\n precision highp float;\n uniform vec2 uResolution;\n uniform float uTime;\n uniform vec3 uColors[5];\n uniform float uSpeed;\n uniform float uSoftness;\n uniform float uZoom;\n void main() {\n vec2 uv = gl_FragCoord.xy / uResolution.xy;\n float aspect = uResolution.x / uResolution.y;\n vec2 p = (uv - 0.5) / max(0.25, uZoom) + 0.5;\n p.x *= aspect;\n float t = uTime * uSpeed * 0.1;\n vec3 col = mix(uColors[0], uColors[4], uv.y * 0.6 + 0.2);\n for(int i = 1; i < 4; i++) {\n float fi = float(i);\n float offset = fi * 4.0;\n vec2 q = p;\n q.x += sin(q.y * 1.5 + t + offset) * 0.2;\n q.y += cos(q.x * 0.8 - t + offset) * 0.1;\n float waveCenterY = 0.5 + 0.3 * sin(q.x * 1.0 + t * 0.8 + offset);\n float thickness = 0.15 + 0.15 * sin(q.x * 2.5 + t * 1.2 + offset);\n float w = thickness * (1.0 + uSoftness * 3.0);\n float dist = abs(q.y - waveCenterY);\n float blurAmount = 0.1 + uSoftness * 0.4;\n float intensity = smoothstep(w + blurAmount, w - blurAmount, dist);\n intensity *= 0.7;\n vec3 bandColor = uColors[i];\n bandColor = mix(bandColor, uColors[i+1], sin(p.x + t)*0.2 + 0.2);\n col = mix(col, bandColor, intensity);\n }\n float noise = fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453);\n col += (noise - 0.5) * 0.03;\n gl_FragColor = vec4(col, 1.0);\n }\n";case"radiant":return"\n precision highp float;\n uniform vec2 uResolution;\n uniform float uTime;\n uniform vec3 uColors[5];\n uniform float uNoiseStrength;\n uniform float uSoftness;\n uniform float uZoom;\n float random(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);\n }\n void main() {\n vec2 uv = gl_FragCoord.xy / uResolution.xy;\n float aspect = uResolution.x / uResolution.y;\n uv = (uv - 0.5) / max(0.25, uZoom) + 0.5;\n uv.x *= aspect;\n float t = uTime * 0.15;\n vec3 col = uColors[0];\n for(int i = 1; i < 5; i++) {\n float fi = float(i);\n vec2 pos = vec2(\n 0.5 * aspect + 0.4 * sin(t * (0.5 + fi * 0.2) + fi * 1.5),\n 0.5 + 0.4 * cos(t * (0.4 + fi * 0.15) + fi)\n );\n float d = length(uv - pos);\n float radius = 0.6 + uSoftness * 1.0;\n float intensity = smoothstep(radius, 0.0, d);\n col = mix(col, uColors[i], intensity * 0.7);\n }\n float grain = random(gl_FragCoord.xy + uTime);\n col += (grain - 0.5) * uNoiseStrength;\n gl_FragColor = vec4(col, 1.0);\n }\n";case"ethereal":return"\n precision highp float;\n uniform vec2 uResolution;\n uniform float uTime;\n uniform vec3 uColors[5];\n uniform float uNoiseStrength;\n uniform float uSoftness;\n uniform float uZoom;\n float random (in vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233)))*43758.5453123);\n }\n float noise (in vec2 st) {\n vec2 i = floor(st);\n vec2 f = fract(st);\n vec2 u = f*f*(3.0-2.0*f);\n return mix( mix( random( i + vec2(0.0,0.0) ),\n random( i + vec2(1.0,0.0) ), u.x),\n mix( random( i + vec2(0.0,1.0) ),\n random( i + vec2(1.0,1.0) ), u.x), u.y);\n }\n #define OCTAVES 5\n float fbm (in vec2 st) {\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitude * noise(st);\n st *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n }\n void main() {\n vec2 uv = gl_FragCoord.xy/uResolution.xy;\n float aspect = uResolution.x/uResolution.y;\n uv = (uv - 0.5) / max(0.25, uZoom) + 0.5;\n uv.x *= aspect;\n float t = uTime * 0.8;\n float scale = 5.0 - uSoftness * 3.0;\n vec2 st = uv * scale;\n vec2 q = vec2(0.);\n q.x = fbm( st + 0.12*t );\n q.y = fbm( st + vec2(1.0) + 0.10*t );\n vec2 r = vec2(0.);\n r.x = fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.30*t );\n r.y = fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.26*t );\n float f = fbm(st + r);\n vec3 color = mix(uColors[0], uColors[1], clamp((f*f)*4.0,0.0,1.0));\n color = mix(color, uColors[2], clamp(length(q),0.0,1.0));\n color = mix(color, uColors[3], clamp(length(r.x),0.0,1.0));\n color = mix(color, uColors[4], clamp(r.y*r.y, 0.0, 1.0));\n float grain = random(gl_FragCoord.xy + uTime);\n color += (grain - 0.5) * uNoiseStrength;\n gl_FragColor = vec4(color,1.0);\n }\n";default:return"\n precision highp float;\n uniform vec2 uResolution;\n uniform float uTime;\n uniform vec3 uColors[5];\n uniform float uNoiseStrength;\n uniform float uSoftness;\n uniform float uZoom;\n float random(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);\n }\n void main() {\n vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / min(uResolution.y, uResolution.x);\n float t = uTime * 0.2;\n float scale = mix(1.8, 0.45, uSoftness) / max(0.25, uZoom);\n vec2 p = uv * scale;\n for(float i = 1.0; i <= 4.0; i++){\n p.x += 0.6 / i * sin(i * 3.0 * p.y + t);\n p.y += 0.6 / i * cos(i * 3.0 * p.x + t);\n }\n float w1 = 0.5 + 0.5 * sin(p.x + t);\n float w2 = 0.5 + 0.5 * sin(p.y + t * 0.8);\n float w3 = 0.5 + 0.5 * sin(p.x + p.y);\n vec3 col = uColors[0];\n col = mix(col, uColors[1], smoothstep(0.1, 0.9, w1));\n col = mix(col, uColors[2], smoothstep(0.1, 0.9, w2));\n col = mix(col, uColors[3], smoothstep(0.1, 0.9, w3));\n float w4 = w1 * w2 * w3;\n col = mix(col, uColors[4], w4);\n float grain = random(gl_FragCoord.xy + uTime);\n col += (grain - 0.5) * uNoiseStrength;\n gl_FragColor = vec4(col, 1.0);\n }\n"}}export{o as VS_SOURCE,getLuminaFragmentShader};
1
+ const VS_SOURCE = `
2
+ attribute vec4 aVertexPosition;
3
+ void main() {
4
+ gl_Position = aVertexPosition;
5
+ }
6
+ `;
7
+ const FS_MESH_FLOW = `
8
+ precision highp float;
9
+ uniform vec2 uResolution;
10
+ uniform float uTime;
11
+ uniform vec3 uColors[5];
12
+ uniform float uSpeed;
13
+ uniform float uSoftness;
14
+ uniform float uZoom;
15
+ void main() {
16
+ vec2 uv = gl_FragCoord.xy / uResolution.xy;
17
+ float aspect = uResolution.x / uResolution.y;
18
+ vec2 p = (uv - 0.5) / max(0.25, uZoom) + 0.5;
19
+ p.x *= aspect;
20
+ float t = uTime * uSpeed * 0.1;
21
+ vec3 col = mix(uColors[0], uColors[4], uv.y * 0.6 + 0.2);
22
+ for(int i = 1; i < 4; i++) {
23
+ float fi = float(i);
24
+ float offset = fi * 4.0;
25
+ vec2 q = p;
26
+ q.x += sin(q.y * 1.5 + t + offset) * 0.2;
27
+ q.y += cos(q.x * 0.8 - t + offset) * 0.1;
28
+ float waveCenterY = 0.5 + 0.3 * sin(q.x * 1.0 + t * 0.8 + offset);
29
+ float thickness = 0.15 + 0.15 * sin(q.x * 2.5 + t * 1.2 + offset);
30
+ float w = thickness * (1.0 + uSoftness * 3.0);
31
+ float dist = abs(q.y - waveCenterY);
32
+ float blurAmount = 0.1 + uSoftness * 0.4;
33
+ float intensity = smoothstep(w + blurAmount, w - blurAmount, dist);
34
+ intensity *= 0.7;
35
+ vec3 bandColor = uColors[i];
36
+ bandColor = mix(bandColor, uColors[i+1], sin(p.x + t)*0.2 + 0.2);
37
+ col = mix(col, bandColor, intensity);
38
+ }
39
+ float noise = fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453);
40
+ col += (noise - 0.5) * 0.03;
41
+ gl_FragColor = vec4(col, 1.0);
42
+ }
43
+ `;
44
+ const FS_FLUID = `
45
+ precision highp float;
46
+ uniform vec2 uResolution;
47
+ uniform float uTime;
48
+ uniform vec3 uColors[5];
49
+ uniform float uNoiseStrength;
50
+ uniform float uSoftness;
51
+ uniform float uZoom;
52
+ float random(vec2 st) {
53
+ return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
54
+ }
55
+ void main() {
56
+ vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / min(uResolution.y, uResolution.x);
57
+ float t = uTime * 0.2;
58
+ float scale = mix(1.8, 0.45, uSoftness) / max(0.25, uZoom);
59
+ vec2 p = uv * scale;
60
+ for(float i = 1.0; i <= 4.0; i++){
61
+ p.x += 0.6 / i * sin(i * 3.0 * p.y + t);
62
+ p.y += 0.6 / i * cos(i * 3.0 * p.x + t);
63
+ }
64
+ float w1 = 0.5 + 0.5 * sin(p.x + t);
65
+ float w2 = 0.5 + 0.5 * sin(p.y + t * 0.8);
66
+ float w3 = 0.5 + 0.5 * sin(p.x + p.y);
67
+ vec3 col = uColors[0];
68
+ col = mix(col, uColors[1], smoothstep(0.1, 0.9, w1));
69
+ col = mix(col, uColors[2], smoothstep(0.1, 0.9, w2));
70
+ col = mix(col, uColors[3], smoothstep(0.1, 0.9, w3));
71
+ float w4 = w1 * w2 * w3;
72
+ col = mix(col, uColors[4], w4);
73
+ float grain = random(gl_FragCoord.xy + uTime);
74
+ col += (grain - 0.5) * uNoiseStrength;
75
+ gl_FragColor = vec4(col, 1.0);
76
+ }
77
+ `;
78
+ const FS_RADIANT = `
79
+ precision highp float;
80
+ uniform vec2 uResolution;
81
+ uniform float uTime;
82
+ uniform vec3 uColors[5];
83
+ uniform float uNoiseStrength;
84
+ uniform float uSoftness;
85
+ uniform float uZoom;
86
+ float random(vec2 st) {
87
+ return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
88
+ }
89
+ void main() {
90
+ vec2 uv = gl_FragCoord.xy / uResolution.xy;
91
+ float aspect = uResolution.x / uResolution.y;
92
+ uv = (uv - 0.5) / max(0.25, uZoom) + 0.5;
93
+ uv.x *= aspect;
94
+ float t = uTime * 0.15;
95
+ vec3 col = uColors[0];
96
+ for(int i = 1; i < 5; i++) {
97
+ float fi = float(i);
98
+ vec2 pos = vec2(
99
+ 0.5 * aspect + 0.4 * sin(t * (0.5 + fi * 0.2) + fi * 1.5),
100
+ 0.5 + 0.4 * cos(t * (0.4 + fi * 0.15) + fi)
101
+ );
102
+ float d = length(uv - pos);
103
+ float radius = 0.6 + uSoftness * 1.0;
104
+ float intensity = smoothstep(radius, 0.0, d);
105
+ col = mix(col, uColors[i], intensity * 0.7);
106
+ }
107
+ float grain = random(gl_FragCoord.xy + uTime);
108
+ col += (grain - 0.5) * uNoiseStrength;
109
+ gl_FragColor = vec4(col, 1.0);
110
+ }
111
+ `;
112
+ const FS_ETHEREAL = `
113
+ precision highp float;
114
+ uniform vec2 uResolution;
115
+ uniform float uTime;
116
+ uniform vec3 uColors[5];
117
+ uniform float uNoiseStrength;
118
+ uniform float uSoftness;
119
+ uniform float uZoom;
120
+ float random (in vec2 st) {
121
+ return fract(sin(dot(st.xy, vec2(12.9898,78.233)))*43758.5453123);
122
+ }
123
+ float noise (in vec2 st) {
124
+ vec2 i = floor(st);
125
+ vec2 f = fract(st);
126
+ vec2 u = f*f*(3.0-2.0*f);
127
+ return mix( mix( random( i + vec2(0.0,0.0) ),
128
+ random( i + vec2(1.0,0.0) ), u.x),
129
+ mix( random( i + vec2(0.0,1.0) ),
130
+ random( i + vec2(1.0,1.0) ), u.x), u.y);
131
+ }
132
+ #define OCTAVES 5
133
+ float fbm (in vec2 st) {
134
+ float value = 0.0;
135
+ float amplitude = 0.5;
136
+ for (int i = 0; i < OCTAVES; i++) {
137
+ value += amplitude * noise(st);
138
+ st *= 2.0;
139
+ amplitude *= 0.5;
140
+ }
141
+ return value;
142
+ }
143
+ void main() {
144
+ vec2 uv = gl_FragCoord.xy/uResolution.xy;
145
+ float aspect = uResolution.x/uResolution.y;
146
+ uv = (uv - 0.5) / max(0.25, uZoom) + 0.5;
147
+ uv.x *= aspect;
148
+ float t = uTime * 0.8;
149
+ float scale = 5.0 - uSoftness * 3.0;
150
+ vec2 st = uv * scale;
151
+ vec2 q = vec2(0.);
152
+ q.x = fbm( st + 0.12*t );
153
+ q.y = fbm( st + vec2(1.0) + 0.10*t );
154
+ vec2 r = vec2(0.);
155
+ r.x = fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.30*t );
156
+ r.y = fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.26*t );
157
+ float f = fbm(st + r);
158
+ vec3 color = mix(uColors[0], uColors[1], clamp((f*f)*4.0,0.0,1.0));
159
+ color = mix(color, uColors[2], clamp(length(q),0.0,1.0));
160
+ color = mix(color, uColors[3], clamp(length(r.x),0.0,1.0));
161
+ color = mix(color, uColors[4], clamp(r.y*r.y, 0.0, 1.0));
162
+ float grain = random(gl_FragCoord.xy + uTime);
163
+ color += (grain - 0.5) * uNoiseStrength;
164
+ gl_FragColor = vec4(color,1.0);
165
+ }
166
+ `;
167
+ function getLuminaFragmentShader(variant) {
168
+ switch (variant) {
169
+ case 'mesh-flow':
170
+ return FS_MESH_FLOW;
171
+ case 'radiant':
172
+ return FS_RADIANT;
173
+ case 'ethereal':
174
+ return FS_ETHEREAL;
175
+ case 'fluid':
176
+ default:
177
+ return FS_FLUID;
178
+ }
179
+ }
180
+
181
+ export { VS_SOURCE, getLuminaFragmentShader };
@@ -1 +1,60 @@
1
- const t=60,e=["plasma","mesh-flow","fluid","radiant","ethereal"];function isLuminaType(t){return e.includes(t)}function toLuminaSpeed(t){return Math.max(.1,t/3e3)}function toSpeedRate(t){return Math.max(.1,t/3e3)}function toAnimationDurationSec(t,e=3,n=.75){const a=3e3*e/Math.max(500,t);return Math.max(n,a)}function toLuminaSoftness(t){return Math.min(1,t/200)}function clampZoom(t){return Math.min(4,Math.max(.25,t))}function hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?[parseInt(e[1],16)/255,parseInt(e[2],16)/255,parseInt(e[3],16)/255]:[0,0,0]}function padColors(t,e=5){return 0===t.length?["#7000FF","#FF00AA","#3300FF","#FFCC00","#00FFFF"]:Array.from({length:e},(e,n)=>t[n%t.length])}const n=["#0d0221","#5b21b6","#db2777","#38bdf8","#e9d5ff"],a="data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='1'/%3E%3C/svg%3E";export{n as FLUID_DEFAULT_COLORS,t as LUMINA_ANIMATION_DURATION_SEC,e as LUMINA_ANIMATION_TYPES,a as LUMINA_NOISE_SVG,clampZoom,hexToRgb,isLuminaType,padColors,toAnimationDurationSec,toLuminaSoftness,toLuminaSpeed,toSpeedRate};
1
+ /** Lumina Loop 기본 루프 주기 () */
2
+ const LUMINA_ANIMATION_DURATION_SEC = 60;
3
+ const LUMINA_ANIMATION_TYPES = [
4
+ 'plasma',
5
+ 'mesh-flow',
6
+ 'fluid',
7
+ 'radiant',
8
+ 'ethereal',
9
+ ];
10
+ function isLuminaType(type) {
11
+ return LUMINA_ANIMATION_TYPES.includes(type);
12
+ }
13
+ /** speed(ms) → Lumina speed 배율 (기본 3000ms = 1.0). 슬라이더 오른쪽일수록 빠름 */
14
+ function toLuminaSpeed(speedMs) {
15
+ return Math.max(0.1, speedMs / 3000);
16
+ }
17
+ /** 슬라이더 속도(ms) → 애니메이션 배율. 왼쪽=느림, 오른쪽=빠름 (3000ms = 1.0) */
18
+ function toSpeedRate(speedMs) {
19
+ return Math.max(0.1, speedMs / 3000);
20
+ }
21
+ /** CSS keyframe duration(초). speedMs가 클수록 짧은 duration = 빠른 애니메이션 */
22
+ function toAnimationDurationSec(speedMs, baseSec = 3, minSec = 0.75) {
23
+ const duration = (baseSec * 3000) / Math.max(500, speedMs);
24
+ return Math.max(minSec, duration);
25
+ }
26
+ /** blur(px) → Lumina softness (0–1) */
27
+ function toLuminaSoftness(blur) {
28
+ return Math.min(1, blur / 200);
29
+ }
30
+ /** zoom 배율 클램프 (0.25–4, 1 = 기본) */
31
+ function clampZoom(zoom) {
32
+ return Math.min(4, Math.max(0.25, zoom));
33
+ }
34
+ function hexToRgb(hex) {
35
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
36
+ return result
37
+ ? [
38
+ parseInt(result[1], 16) / 255,
39
+ parseInt(result[2], 16) / 255,
40
+ parseInt(result[3], 16) / 255,
41
+ ]
42
+ : [0, 0, 0];
43
+ }
44
+ function padColors(colors, count = 5) {
45
+ if (colors.length === 0) {
46
+ return ['#7000FF', '#FF00AA', '#3300FF', '#FFCC00', '#00FFFF'];
47
+ }
48
+ return Array.from({ length: count }, (_, i) => colors[i % colors.length]);
49
+ }
50
+ /** fluid 타입 기본 팔레트 (딥 바이올렛 → 로즈 → 스카이) */
51
+ const FLUID_DEFAULT_COLORS = [
52
+ '#0d0221',
53
+ '#5b21b6',
54
+ '#db2777',
55
+ '#38bdf8',
56
+ '#e9d5ff',
57
+ ];
58
+ const LUMINA_NOISE_SVG = "data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='1'/%3E%3C/svg%3E";
59
+
60
+ export { FLUID_DEFAULT_COLORS, LUMINA_ANIMATION_DURATION_SEC, LUMINA_ANIMATION_TYPES, LUMINA_NOISE_SVG, clampZoom, hexToRgb, isLuminaType, padColors, toAnimationDurationSec, toLuminaSoftness, toLuminaSpeed, toSpeedRate };
@@ -1 +1,36 @@
1
- const f=["#ffffff","#f0f9ff","#e0f2fe"],e=["#ffb7c5","#ff91a4","#f8c8dc","#ffc0cb","#fda4af"],c=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#4caf50","#ffeb3b","#ffc107","#ff9800"];function getFallingParticleDefaults(a){switch(a){case"snow":default:return f;case"flowers":return e;case"confetti":return c}}export{c as CONFETTI_DEFAULT_COLORS,e as FLOWERS_DEFAULT_COLORS,f as SNOW_DEFAULT_COLORS,getFallingParticleDefaults};
1
+ const SNOW_DEFAULT_COLORS = ['#ffffff', '#f0f9ff', '#e0f2fe'];
2
+ const FLOWERS_DEFAULT_COLORS = [
3
+ '#ffb7c5',
4
+ '#ff91a4',
5
+ '#f8c8dc',
6
+ '#ffc0cb',
7
+ '#fda4af',
8
+ ];
9
+ const CONFETTI_DEFAULT_COLORS = [
10
+ '#f44336',
11
+ '#e91e63',
12
+ '#9c27b0',
13
+ '#673ab7',
14
+ '#3f51b5',
15
+ '#2196f3',
16
+ '#03a9f4',
17
+ '#00bcd4',
18
+ '#4caf50',
19
+ '#ffeb3b',
20
+ '#ffc107',
21
+ '#ff9800',
22
+ ];
23
+ function getFallingParticleDefaults(type) {
24
+ switch (type) {
25
+ case 'snow':
26
+ return SNOW_DEFAULT_COLORS;
27
+ case 'flowers':
28
+ return FLOWERS_DEFAULT_COLORS;
29
+ case 'confetti':
30
+ return CONFETTI_DEFAULT_COLORS;
31
+ default:
32
+ return SNOW_DEFAULT_COLORS;
33
+ }
34
+ }
35
+
36
+ export { CONFETTI_DEFAULT_COLORS, FLOWERS_DEFAULT_COLORS, SNOW_DEFAULT_COLORS, getFallingParticleDefaults };
@@ -1 +1,167 @@
1
- import{toSpeedRate as a}from"./lumina-utils.js";function createFallingParticle(a,e,t,o=!1){return{x:Math.random()*a,y:o?Math.random()*e:-20,size:Math.random()*(t.maxSize-t.minSize)+t.minSize,speedX:(Math.random()-.5)*t.wind,speedY:Math.random()*(t.maxSpeedY-t.minSpeedY)+t.minSpeedY,opacity:.5*Math.random()+.3,rotation:Math.random()*Math.PI*2,rotationSpeed:.05*(Math.random()-.5),color:t.colors[Math.floor(Math.random()*t.colors.length)]}}const drawFallingParticles=(e,t,o,r,n,l)=>{const i=a(l.speed),c=Math.max(1,.5*l.size),s={minSize:c,maxSize:Math.max(c+.5,1.5*l.size),minSpeedY:.4*i,maxSpeedY:1.2*i,wind:l.wind*i,colors:l.colors},h=`${l.count}:${l.size}:${l.speed}:${l.wind}`;r.current.length===l.count&&r.spawnKey===h||(r.current=Array.from({length:l.count},()=>createFallingParticle(t,o,s,!0)),r.spawnKey=h),r.current.forEach(a=>{a.y+=a.speedY,a.x+=a.speedX+.5*Math.sin(a.y/50)*i,a.rotation+=a.rotationSpeed,a.y>o+20&&Object.assign(a,createFallingParticle(t,o,s)),a.x>t+20&&(a.x=-20),a.x<-20&&(a.x=t+20),e.save(),e.translate(a.x,a.y),e.rotate(a.rotation),e.fillStyle=a.color,e.globalAlpha=a.opacity*l.layerOpacity,function drawFallingParticleShape(a,e,t){return"snow"===e?(a.beginPath(),a.arc(0,0,t,0,2*Math.PI),void a.fill()):"flowers"===e?(a.beginPath(),a.moveTo(0,0),a.bezierCurveTo(t,-t,2*t,t,0,2*t),a.bezierCurveTo(2*-t,t,-t,-t,0,0),void a.fill()):void a.fillRect(-t/2,-t/2,t,t)}(e,n,a.size),e.restore()}),e.globalAlpha=1},drawParticles=(e,t,o,r,n)=>{const l=`${n.count}:${n.size}`;r.current.length===n.count&&r.spawnKey===l||(r.current=Array.from({length:n.count}).map(()=>({x:Math.random()*t,y:Math.random()*o,vx:1.5*(Math.random()-.5),vy:1.5*(Math.random()-.5),size:Math.random()*n.size+1,color:n.colors[Math.floor(Math.random()*n.colors.length)]})),r.spawnKey=l);const i=r.current,c=a(n.speed);i.forEach((a,r)=>{if(a.x+=a.vx*c,a.y+=a.vy*c,(a.x<0||a.x>t)&&(a.vx*=-1),(a.y<0||a.y>o)&&(a.vy*=-1),n.clickable){const e=n.mouse.x-a.x,t=n.mouse.y-a.y,o=Math.sqrt(e*e+t*t);if(o<150){const r=(150-o)/150;a.vx+=e/o*r*.5,a.vy+=t/o*r*.5}const r=3,l=Math.sqrt(a.vx*a.vx+a.vy*a.vy);l>r&&(a.vx=a.vx/l*r,a.vy=a.vy/l*r)}e.save(),e.globalAlpha=n.layerOpacity,e.beginPath(),e.arc(a.x,a.y,a.size,0,2*Math.PI),e.fillStyle=a.color,e.fill(),e.restore();for(let t=r+1;t<i.length;t++){const o=i[t],r=a.x-o.x,l=a.y-o.y,c=Math.sqrt(r*r+l*l);c<100&&(e.beginPath(),e.strokeStyle=a.color,e.globalAlpha=(1-c/100)*n.layerOpacity,e.lineWidth=.5,e.moveTo(a.x,a.y),e.lineTo(o.x,o.y),e.stroke(),e.globalAlpha=1)}})},drawStars=(a,e,t,o,r)=>{const n=`${r.count}:${r.size}`;o.current.length===r.count&&o.spawnKey===n||(o.current=Array.from({length:r.count}).map(()=>({x:Math.random()*e,y:Math.random()*t,size:Math.random()*r.size,blinkSpeed:.05*Math.random()+.01,color:r.colors[Math.floor(Math.random()*r.colors.length)]})),o.spawnKey=n),o.current.forEach(e=>{e.y-=.05*r.speedRate,e.y<0&&(e.y=t);const o=(.5+.5*Math.sin(r.time*e.blinkSpeed))*r.layerOpacity;a.beginPath(),a.arc(e.x,e.y,e.size,0,2*Math.PI),a.fillStyle=e.color,a.globalAlpha=o,a.fill(),a.globalAlpha=1})};export{drawFallingParticles,drawParticles,drawStars};
1
+ import { toSpeedRate } from './lumina-utils.js';
2
+
3
+ /**
4
+ * Canvas 렌더러: particles, stars, snow, flowers, confetti
5
+ */
6
+ function createFallingParticle(width, height, options, isInitial = false) {
7
+ return {
8
+ x: Math.random() * width,
9
+ y: isInitial ? Math.random() * height : -20,
10
+ size: Math.random() * (options.maxSize - options.minSize) + options.minSize,
11
+ speedX: (Math.random() - 0.5) * options.wind,
12
+ speedY: Math.random() * (options.maxSpeedY - options.minSpeedY) + options.minSpeedY,
13
+ opacity: Math.random() * 0.5 + 0.3,
14
+ rotation: Math.random() * Math.PI * 2,
15
+ rotationSpeed: (Math.random() - 0.5) * 0.05,
16
+ color: options.colors[Math.floor(Math.random() * options.colors.length)],
17
+ };
18
+ }
19
+ function drawFallingParticleShape(ctx, variant, size) {
20
+ if (variant === 'snow') {
21
+ ctx.beginPath();
22
+ ctx.arc(0, 0, size, 0, Math.PI * 2);
23
+ ctx.fill();
24
+ return;
25
+ }
26
+ if (variant === 'flowers') {
27
+ ctx.beginPath();
28
+ ctx.moveTo(0, 0);
29
+ ctx.bezierCurveTo(size, -size, size * 2, size, 0, size * 2);
30
+ ctx.bezierCurveTo(-size * 2, size, -size, -size, 0, 0);
31
+ ctx.fill();
32
+ return;
33
+ }
34
+ ctx.fillRect(-size / 2, -size / 2, size, size);
35
+ }
36
+ const drawFallingParticles = (ctx, width, height, particlesRef, variant, options) => {
37
+ const speedFactor = toSpeedRate(options.speed);
38
+ const minSize = Math.max(1, options.size * 0.5);
39
+ const maxSize = Math.max(minSize + 0.5, options.size * 1.5);
40
+ const minSpeedY = 0.4 * speedFactor;
41
+ const maxSpeedY = 1.2 * speedFactor;
42
+ const wind = options.wind * speedFactor;
43
+ const spawnOptions = {
44
+ minSize,
45
+ maxSize,
46
+ minSpeedY,
47
+ maxSpeedY,
48
+ wind,
49
+ colors: options.colors,
50
+ };
51
+ const spawnKey = `${options.count}:${options.size}:${options.speed}:${options.wind}`;
52
+ if (particlesRef.current.length !== options.count || particlesRef.spawnKey !== spawnKey) {
53
+ particlesRef.current = Array.from({ length: options.count }, () => createFallingParticle(width, height, spawnOptions, true));
54
+ particlesRef.spawnKey = spawnKey;
55
+ }
56
+ particlesRef.current.forEach((p) => {
57
+ p.y += p.speedY;
58
+ p.x += p.speedX + Math.sin(p.y / 50) * 0.5 * speedFactor;
59
+ p.rotation += p.rotationSpeed;
60
+ if (p.y > height + 20) {
61
+ Object.assign(p, createFallingParticle(width, height, spawnOptions));
62
+ }
63
+ if (p.x > width + 20)
64
+ p.x = -20;
65
+ if (p.x < -20)
66
+ p.x = width + 20;
67
+ ctx.save();
68
+ ctx.translate(p.x, p.y);
69
+ ctx.rotate(p.rotation);
70
+ ctx.fillStyle = p.color;
71
+ ctx.globalAlpha = p.opacity * options.layerOpacity;
72
+ drawFallingParticleShape(ctx, variant, p.size);
73
+ ctx.restore();
74
+ });
75
+ ctx.globalAlpha = 1;
76
+ };
77
+ const drawParticles = (ctx, width, height, particlesRef, options) => {
78
+ const spawnKey = `${options.count}:${options.size}`;
79
+ if (particlesRef.current.length !== options.count || particlesRef.spawnKey !== spawnKey) {
80
+ particlesRef.current = Array.from({ length: options.count }).map(() => ({
81
+ x: Math.random() * width,
82
+ y: Math.random() * height,
83
+ vx: (Math.random() - 0.5) * 1.5,
84
+ vy: (Math.random() - 0.5) * 1.5,
85
+ size: Math.random() * options.size + 1,
86
+ color: options.colors[Math.floor(Math.random() * options.colors.length)],
87
+ }));
88
+ particlesRef.spawnKey = spawnKey;
89
+ }
90
+ const particles = particlesRef.current;
91
+ const interactionRadius = 150;
92
+ const speedFactor = toSpeedRate(options.speed);
93
+ particles.forEach((p, i) => {
94
+ p.x += p.vx * speedFactor;
95
+ p.y += p.vy * speedFactor;
96
+ if (p.x < 0 || p.x > width)
97
+ p.vx *= -1;
98
+ if (p.y < 0 || p.y > height)
99
+ p.vy *= -1;
100
+ if (options.clickable) {
101
+ const dx = options.mouse.x - p.x;
102
+ const dy = options.mouse.y - p.y;
103
+ const distance = Math.sqrt(dx * dx + dy * dy);
104
+ if (distance < interactionRadius) {
105
+ const force = (interactionRadius - distance) / interactionRadius;
106
+ p.vx += (dx / distance) * force * 0.5;
107
+ p.vy += (dy / distance) * force * 0.5;
108
+ }
109
+ const maxSpeed = 3;
110
+ const particleSpeed = Math.sqrt(p.vx * p.vx + p.vy * p.vy);
111
+ if (particleSpeed > maxSpeed) {
112
+ p.vx = (p.vx / particleSpeed) * maxSpeed;
113
+ p.vy = (p.vy / particleSpeed) * maxSpeed;
114
+ }
115
+ }
116
+ ctx.save();
117
+ ctx.globalAlpha = options.layerOpacity;
118
+ ctx.beginPath();
119
+ ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
120
+ ctx.fillStyle = p.color;
121
+ ctx.fill();
122
+ ctx.restore();
123
+ for (let j = i + 1; j < particles.length; j++) {
124
+ const p2 = particles[j];
125
+ const dx = p.x - p2.x;
126
+ const dy = p.y - p2.y;
127
+ const dist = Math.sqrt(dx * dx + dy * dy);
128
+ if (dist < 100) {
129
+ ctx.beginPath();
130
+ ctx.strokeStyle = p.color;
131
+ ctx.globalAlpha = (1 - dist / 100) * options.layerOpacity;
132
+ ctx.lineWidth = 0.5;
133
+ ctx.moveTo(p.x, p.y);
134
+ ctx.lineTo(p2.x, p2.y);
135
+ ctx.stroke();
136
+ ctx.globalAlpha = 1;
137
+ }
138
+ }
139
+ });
140
+ };
141
+ const drawStars = (ctx, width, height, starsRef, options) => {
142
+ const spawnKey = `${options.count}:${options.size}`;
143
+ if (starsRef.current.length !== options.count || starsRef.spawnKey !== spawnKey) {
144
+ starsRef.current = Array.from({ length: options.count }).map(() => ({
145
+ x: Math.random() * width,
146
+ y: Math.random() * height,
147
+ size: Math.random() * options.size,
148
+ blinkSpeed: Math.random() * 0.05 + 0.01,
149
+ color: options.colors[Math.floor(Math.random() * options.colors.length)],
150
+ }));
151
+ starsRef.spawnKey = spawnKey;
152
+ }
153
+ starsRef.current.forEach(star => {
154
+ star.y -= 0.05 * options.speedRate;
155
+ if (star.y < 0)
156
+ star.y = height;
157
+ const opacity = (0.5 + Math.sin(options.time * star.blinkSpeed) * 0.5) * options.layerOpacity;
158
+ ctx.beginPath();
159
+ ctx.arc(star.x, star.y, star.size, 0, Math.PI * 2);
160
+ ctx.fillStyle = star.color;
161
+ ctx.globalAlpha = opacity;
162
+ ctx.fill();
163
+ ctx.globalAlpha = 1;
164
+ });
165
+ };
166
+
167
+ export { drawFallingParticles, drawParticles, drawStars };
@@ -1 +1,154 @@
1
- import{padColors as t,hexToRgb as e,toLuminaSpeed as r,toLuminaSoftness as i,clampZoom as a}from"./lumina-utils.js";import{VS_SOURCE as n,getLuminaFragmentShader as o}from"./lumina-shaders.js";function loadShader(t,e,r){const i=t.createShader(e);return i?(t.shaderSource(i,r),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS)?i:(t.deleteShader(i),null)):null}class ShaderAnimationController{constructor(n,o){this.raf=0,this.startTime=performance.now(),this.render=()=>{const n=this.gl,o=this.program,s=this.positionBuffer;if(!n||!o||!s)return;const{colors:h,speed:f,blur:c,noise:m,zoom:d,variant:u}=this.options,{width:l,height:g}=this.resizeCanvas();if(0===l||0===g)return void(this.raf=requestAnimationFrame(this.render));n.viewport(0,0,l,g),n.useProgram(o);const v=n.getAttribLocation(o,"aVertexPosition"),S=n.getUniformLocation(o,"uResolution"),p=n.getUniformLocation(o,"uTime"),A=n.getUniformLocation(o,"uColors"),w=n.getUniformLocation(o,"uSpeed"),R=n.getUniformLocation(o,"uSoftness"),b=n.getUniformLocation(o,"uNoiseStrength"),T=n.getUniformLocation(o,"uZoom");n.enableVertexAttribArray(v),n.bindBuffer(n.ARRAY_BUFFER,s),n.vertexAttribPointer(v,2,n.FLOAT,!1,0,0),n.uniform2f(S,l,g);const x=t(h),F=r(f),B=i(c),L=.6*F,P=a(d),U=(performance.now()-this.startTime)/1e3;"mesh-flow"===u?(p&&n.uniform1f(p,U),w&&n.uniform1f(w,L),R&&n.uniform1f(R,B),T&&n.uniform1f(T,P)):(p&&n.uniform1f(p,U*F),R&&n.uniform1f(R,B),b&&n.uniform1f(b,m),T&&n.uniform1f(T,P));const C=new Float32Array(15);for(let t=0;t<5;t++){const r=e(x[t]);C[3*t]=r[0],C[3*t+1]=r[1],C[3*t+2]=r[2]}A&&n.uniform3fv(A,C),n.drawArrays(n.TRIANGLE_STRIP,0,4),this.raf=requestAnimationFrame(this.render)},this.container=n,this.options=o,this.canvas=document.createElement("canvas"),this.canvas.className="designbase-wc-animation-background__shader-canvas",n.appendChild(this.canvas),this.init()}updateOptions(t){this.options={...this.options,...t}}resizeCanvas(){const t=this.container.getBoundingClientRect(),e=window.devicePixelRatio||1;return this.canvas.width=Math.max(1,t.width*e),this.canvas.height=Math.max(1,t.height*e),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`,{width:this.canvas.width,height:this.canvas.height}}init(){const t=this.canvas.getContext("webgl");if(!t)return;this.gl=t;const{variant:e}=this.options,r=o(e),i=t.createProgram();if(!i)return;const a=loadShader(t,t.VERTEX_SHADER,n),s=loadShader(t,t.FRAGMENT_SHADER,r);if(!a||!s)return;if(t.attachShader(i,a),t.attachShader(i,s),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS))return;this.program=i,this.vertexShader=a,this.fragmentShader=s;const h=t.createBuffer();h&&(this.positionBuffer=h,t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),t.STATIC_DRAW),this.observer=new ResizeObserver(()=>this.resizeCanvas()),this.observer.observe(this.container),this.startTime=performance.now(),this.render())}destroy(){cancelAnimationFrame(this.raf),this.observer?.disconnect();const t=this.gl;t&&this.program&&(this.vertexShader&&t.deleteShader(this.vertexShader),this.fragmentShader&&t.deleteShader(this.fragmentShader),this.positionBuffer&&t.deleteBuffer(this.positionBuffer),t.deleteProgram(this.program)),this.canvas.remove()}}export{ShaderAnimationController};
1
+ import { padColors, hexToRgb, toLuminaSpeed, toLuminaSoftness, clampZoom } from './lumina-utils.js';
2
+ import { VS_SOURCE, getLuminaFragmentShader } from './lumina-shaders.js';
3
+
4
+ const CLASS = 'designbase-wc-animation-background';
5
+ function loadShader(gl, type, source) {
6
+ const shader = gl.createShader(type);
7
+ if (!shader)
8
+ return null;
9
+ gl.shaderSource(shader, source);
10
+ gl.compileShader(shader);
11
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
12
+ gl.deleteShader(shader);
13
+ return null;
14
+ }
15
+ return shader;
16
+ }
17
+ class ShaderAnimationController {
18
+ constructor(container, options) {
19
+ this.raf = 0;
20
+ this.startTime = performance.now();
21
+ this.render = () => {
22
+ const gl = this.gl;
23
+ const program = this.program;
24
+ const positionBuffer = this.positionBuffer;
25
+ if (!gl || !program || !positionBuffer)
26
+ return;
27
+ const { colors, speed, blur, noise, zoom, variant } = this.options;
28
+ const { width, height } = this.resizeCanvas();
29
+ if (width === 0 || height === 0) {
30
+ this.raf = requestAnimationFrame(this.render);
31
+ return;
32
+ }
33
+ gl.viewport(0, 0, width, height);
34
+ gl.useProgram(program);
35
+ const aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
36
+ const uResolution = gl.getUniformLocation(program, 'uResolution');
37
+ const uTime = gl.getUniformLocation(program, 'uTime');
38
+ const uColors = gl.getUniformLocation(program, 'uColors');
39
+ const uSpeed = gl.getUniformLocation(program, 'uSpeed');
40
+ const uSoftness = gl.getUniformLocation(program, 'uSoftness');
41
+ const uNoiseStrength = gl.getUniformLocation(program, 'uNoiseStrength');
42
+ const uZoom = gl.getUniformLocation(program, 'uZoom');
43
+ gl.enableVertexAttribArray(aVertexPosition);
44
+ gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
45
+ gl.vertexAttribPointer(aVertexPosition, 2, gl.FLOAT, false, 0, 0);
46
+ gl.uniform2f(uResolution, width, height);
47
+ const palette = padColors(colors);
48
+ const luminaSpeed = toLuminaSpeed(speed);
49
+ const softness = toLuminaSoftness(blur);
50
+ const meshFlowSpeed = luminaSpeed * 0.6;
51
+ const zoomValue = clampZoom(zoom);
52
+ const elapsed = (performance.now() - this.startTime) / 1000;
53
+ if (variant === 'mesh-flow') {
54
+ if (uTime)
55
+ gl.uniform1f(uTime, elapsed);
56
+ if (uSpeed)
57
+ gl.uniform1f(uSpeed, meshFlowSpeed);
58
+ if (uSoftness)
59
+ gl.uniform1f(uSoftness, softness);
60
+ if (uZoom)
61
+ gl.uniform1f(uZoom, zoomValue);
62
+ }
63
+ else {
64
+ if (uTime)
65
+ gl.uniform1f(uTime, elapsed * luminaSpeed);
66
+ if (uSoftness)
67
+ gl.uniform1f(uSoftness, softness);
68
+ if (uNoiseStrength)
69
+ gl.uniform1f(uNoiseStrength, noise);
70
+ if (uZoom)
71
+ gl.uniform1f(uZoom, zoomValue);
72
+ }
73
+ const flatColors = new Float32Array(5 * 3);
74
+ for (let i = 0; i < 5; i++) {
75
+ const rgb = hexToRgb(palette[i]);
76
+ flatColors[i * 3] = rgb[0];
77
+ flatColors[i * 3 + 1] = rgb[1];
78
+ flatColors[i * 3 + 2] = rgb[2];
79
+ }
80
+ if (uColors)
81
+ gl.uniform3fv(uColors, flatColors);
82
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
83
+ this.raf = requestAnimationFrame(this.render);
84
+ };
85
+ this.container = container;
86
+ this.options = options;
87
+ this.canvas = document.createElement('canvas');
88
+ this.canvas.className = `${CLASS}__shader-canvas`;
89
+ container.appendChild(this.canvas);
90
+ this.init();
91
+ }
92
+ updateOptions(options) {
93
+ this.options = { ...this.options, ...options };
94
+ }
95
+ resizeCanvas() {
96
+ const rect = this.container.getBoundingClientRect();
97
+ const dpr = window.devicePixelRatio || 1;
98
+ this.canvas.width = Math.max(1, rect.width * dpr);
99
+ this.canvas.height = Math.max(1, rect.height * dpr);
100
+ this.canvas.style.width = `${rect.width}px`;
101
+ this.canvas.style.height = `${rect.height}px`;
102
+ return { width: this.canvas.width, height: this.canvas.height };
103
+ }
104
+ init() {
105
+ const gl = this.canvas.getContext('webgl');
106
+ if (!gl)
107
+ return;
108
+ this.gl = gl;
109
+ const { variant } = this.options;
110
+ const fsSource = getLuminaFragmentShader(variant);
111
+ const shaderProgram = gl.createProgram();
112
+ if (!shaderProgram)
113
+ return;
114
+ const vertexShader = loadShader(gl, gl.VERTEX_SHADER, VS_SOURCE);
115
+ const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource);
116
+ if (!vertexShader || !fragmentShader)
117
+ return;
118
+ gl.attachShader(shaderProgram, vertexShader);
119
+ gl.attachShader(shaderProgram, fragmentShader);
120
+ gl.linkProgram(shaderProgram);
121
+ if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS))
122
+ return;
123
+ this.program = shaderProgram;
124
+ this.vertexShader = vertexShader;
125
+ this.fragmentShader = fragmentShader;
126
+ const positionBuffer = gl.createBuffer();
127
+ if (!positionBuffer)
128
+ return;
129
+ this.positionBuffer = positionBuffer;
130
+ gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
131
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
132
+ this.observer = new ResizeObserver(() => this.resizeCanvas());
133
+ this.observer.observe(this.container);
134
+ this.startTime = performance.now();
135
+ this.render();
136
+ }
137
+ destroy() {
138
+ cancelAnimationFrame(this.raf);
139
+ this.observer?.disconnect();
140
+ const gl = this.gl;
141
+ if (gl && this.program) {
142
+ if (this.vertexShader)
143
+ gl.deleteShader(this.vertexShader);
144
+ if (this.fragmentShader)
145
+ gl.deleteShader(this.fragmentShader);
146
+ if (this.positionBuffer)
147
+ gl.deleteBuffer(this.positionBuffer);
148
+ gl.deleteProgram(this.program);
149
+ }
150
+ this.canvas.remove();
151
+ }
152
+ }
153
+
154
+ export { ShaderAnimationController };