kmcom-nuxt-layers 2.2.6 → 2.2.8

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 (201) hide show
  1. package/docs/FEEDS.md +197 -0
  2. package/docs/LAYERS-FIXES.md +101 -0
  3. package/docs/MIGRATION.md +627 -0
  4. package/docs/feed-layer.md +374 -0
  5. package/docs/patch-picture-provider-type.md +52 -0
  6. package/docs/shaderGuide.md +2071 -0
  7. package/docs/types-architecture.md +234 -0
  8. package/layers/animations/app/components/Motion/CountUp.vue +1 -2
  9. package/layers/animations/app/components/Motion/Magnetic.vue +1 -2
  10. package/layers/animations/app/components/Motion/Marquee.vue +2 -5
  11. package/layers/animations/app/components/Motion/MarqueeText.vue +1 -2
  12. package/layers/animations/app/components/Motion/Tilt.vue +1 -2
  13. package/layers/animations/app/composables/useCountUp.ts +4 -1
  14. package/layers/animations/app/composables/useMagneticElement.ts +1 -3
  15. package/layers/animations/app/composables/useMarqueeCopies.ts +3 -3
  16. package/layers/animations/app/types/animations.ts +8 -0
  17. package/layers/animations/app/types/index.ts +1 -0
  18. package/layers/animations/package.json +4 -1
  19. package/layers/canvas/app/components/ShaderCanvas.vue +4 -4
  20. package/layers/canvas/app/composables/useRendererCapabilities.ts +19 -15
  21. package/layers/canvas/app/types/index.ts +1 -0
  22. package/layers/canvas/package.json +2 -1
  23. package/layers/canvas/tsconfig.json +2 -1
  24. package/layers/content/app/components/Blog/Card.vue +5 -5
  25. package/layers/content/app/components/Gallery/AmbientImage.vue +3 -3
  26. package/layers/content/app/components/Gallery/Card.vue +3 -3
  27. package/layers/content/app/components/NuxtContent/Detail.vue +5 -1
  28. package/layers/content/app/components/NuxtContent/Surround.vue +5 -3
  29. package/layers/content/app/components/NuxtContent/Toc.vue +1 -1
  30. package/layers/content/app/components/Portfolio/Card.vue +5 -5
  31. package/layers/content/app/components/content/Figure.vue +3 -3
  32. package/layers/content/app/types/index.ts +1 -0
  33. package/layers/content/package.json +2 -1
  34. package/layers/core/app/composables/useErrorLog.ts +9 -11
  35. package/layers/core/app/utils/helpers.ts +14 -12
  36. package/layers/core/nuxt.config.ts +1 -0
  37. package/layers/feeds/app/plugins/feed-head.ts +1 -2
  38. package/layers/feeds/package.json +2 -1
  39. package/layers/feeds/server/routes/feed/discovery.get.ts +1 -2
  40. package/layers/feeds/server/utils/content-adapter.ts +3 -2
  41. package/layers/forms/app/components/Form/Field.vue +4 -4
  42. package/layers/forms/app/types/index.ts +1 -0
  43. package/layers/forms/package.json +2 -1
  44. package/layers/layout/app/components/Layout/Grid/Item.vue +33 -19
  45. package/layers/layout/app/components/Layout/Page/Container.vue +11 -11
  46. package/layers/layout/app/components/Layout/Page/Header.vue +1 -1
  47. package/layers/layout/app/components/Layout/Page/index.vue +1 -1
  48. package/layers/layout/app/components/Layout/Section/Gallery.vue +6 -1
  49. package/layers/layout/app/components/Layout/Section/Title.vue +1 -1
  50. package/layers/layout/app/types/index.ts +1 -0
  51. package/layers/layout/package.json +2 -1
  52. package/layers/mailer/app/types/index.ts +1 -0
  53. package/layers/mailer/app/types/mailer.ts +25 -0
  54. package/layers/mailer/package.json +2 -1
  55. package/layers/motion/package.json +2 -1
  56. package/layers/navigation/app/components/Links/Group.vue +1 -0
  57. package/layers/navigation/app/components/Links/Named.vue +2 -0
  58. package/layers/navigation/app/types/index.ts +1 -0
  59. package/layers/navigation/package.json +4 -1
  60. package/layers/page-transitions/package.json +4 -1
  61. package/layers/routing/app/types/app-config.d.ts +3 -1
  62. package/layers/routing/app/types/index.ts +1 -0
  63. package/layers/routing/package.json +2 -1
  64. package/layers/scripts/app/composables/useGtm.ts +1 -1
  65. package/layers/scripts/app/types/index.ts +1 -0
  66. package/layers/scripts/app/types/scripts.ts +14 -0
  67. package/layers/scripts/package.json +2 -1
  68. package/layers/scroll/app/components/Motion/ScrollScene.vue +3 -1
  69. package/layers/scroll/app/composables/useScrollSteps.ts +2 -9
  70. package/layers/scroll/app/composables/useSectionProgress.ts +2 -1
  71. package/layers/scroll/app/plugins/locomotive-scroll.client.ts +1 -8
  72. package/layers/scroll/app/types/index.ts +1 -0
  73. package/layers/scroll/app/types/scroll.ts +32 -0
  74. package/layers/scroll/package.json +3 -0
  75. package/layers/seo/package.json +2 -1
  76. package/layers/shader/app/components/Material/Fresnel.client.vue +1 -1
  77. package/layers/shader/app/components/Material/Image.client.vue +1 -1
  78. package/layers/shader/app/components/Material/Node.client.vue +7 -7
  79. package/layers/shader/app/components/Material/Noise.client.vue +1 -1
  80. package/layers/shader/app/components/Node/Color.client.vue +17 -20
  81. package/layers/shader/app/components/Node/Noise.client.vue +31 -34
  82. package/layers/shader/app/components/Pipeline/Aurora.client.vue +4 -8
  83. package/layers/shader/app/components/Pipeline/BilinearGradient.client.vue +8 -11
  84. package/layers/shader/app/components/Pipeline/BillowNoise.client.vue +4 -8
  85. package/layers/shader/app/components/Pipeline/BrightnessContrast.client.vue +6 -2
  86. package/layers/shader/app/components/Pipeline/CellularNoise.client.vue +4 -8
  87. package/layers/shader/app/components/Pipeline/Checkerboard.client.vue +4 -8
  88. package/layers/shader/app/components/Pipeline/Circle.client.vue +5 -8
  89. package/layers/shader/app/components/Pipeline/Clouds.client.vue +4 -8
  90. package/layers/shader/app/components/Pipeline/ColorBurnBlend.client.vue +2 -19
  91. package/layers/shader/app/components/Pipeline/ColorDodgeBlend.client.vue +2 -19
  92. package/layers/shader/app/components/Pipeline/ColourRamp.client.vue +5 -9
  93. package/layers/shader/app/components/Pipeline/ConicGradient.client.vue +5 -8
  94. package/layers/shader/app/components/Pipeline/Cross.client.vue +4 -8
  95. package/layers/shader/app/components/Pipeline/CurlNoise.client.vue +3 -7
  96. package/layers/shader/app/components/Pipeline/DarkenBlend.client.vue +2 -19
  97. package/layers/shader/app/components/Pipeline/DayNightCycle.client.vue +5 -8
  98. package/layers/shader/app/components/Pipeline/DiagonalGradient.client.vue +5 -8
  99. package/layers/shader/app/components/Pipeline/DiamondGradient.client.vue +5 -8
  100. package/layers/shader/app/components/Pipeline/DifferenceBlend.client.vue +2 -19
  101. package/layers/shader/app/components/Pipeline/DomainWarpedNoise.client.vue +4 -8
  102. package/layers/shader/app/components/Pipeline/Dots.client.vue +4 -8
  103. package/layers/shader/app/components/Pipeline/DuoTone.client.vue +5 -9
  104. package/layers/shader/app/components/Pipeline/ExclusionBlend.client.vue +3 -23
  105. package/layers/shader/app/components/Pipeline/ExponentialFog.client.vue +4 -7
  106. package/layers/shader/app/components/Pipeline/FilmBurn.client.vue +4 -7
  107. package/layers/shader/app/components/Pipeline/Flame.client.vue +4 -8
  108. package/layers/shader/app/components/Pipeline/FocalGradient.client.vue +5 -8
  109. package/layers/shader/app/components/Pipeline/GodRays.client.vue +4 -7
  110. package/layers/shader/app/components/Pipeline/GradientNoise.client.vue +4 -8
  111. package/layers/shader/app/components/Pipeline/Grid.client.vue +4 -8
  112. package/layers/shader/app/components/Pipeline/Halation.client.vue +3 -7
  113. package/layers/shader/app/components/Pipeline/HardLightBlend.client.vue +2 -19
  114. package/layers/shader/app/components/Pipeline/Haze.client.vue +4 -7
  115. package/layers/shader/app/components/Pipeline/Hexagon.client.vue +4 -8
  116. package/layers/shader/app/components/Pipeline/LensFlare.client.vue +4 -7
  117. package/layers/shader/app/components/Pipeline/LightenBlend.client.vue +2 -19
  118. package/layers/shader/app/components/Pipeline/LinearGradient4.client.vue +2 -2
  119. package/layers/shader/app/components/Pipeline/Marble.client.vue +4 -8
  120. package/layers/shader/app/components/Pipeline/MonochromeTint.client.vue +3 -7
  121. package/layers/shader/app/components/Pipeline/MultiplyBlend.client.vue +2 -19
  122. package/layers/shader/app/components/Pipeline/NoisyGradient.client.vue +4 -8
  123. package/layers/shader/app/components/Pipeline/NoisyGradientBlend.client.vue +4 -8
  124. package/layers/shader/app/components/Pipeline/OverlayBlend.client.vue +2 -19
  125. package/layers/shader/app/components/Pipeline/Polygon.client.vue +4 -8
  126. package/layers/shader/app/components/Pipeline/RaymarchTunnel.client.vue +4 -7
  127. package/layers/shader/app/components/Pipeline/Rectangle.client.vue +4 -8
  128. package/layers/shader/app/components/Pipeline/RidgedNoise.client.vue +4 -8
  129. package/layers/shader/app/components/Pipeline/Ring.client.vue +4 -8
  130. package/layers/shader/app/components/Pipeline/ScreenBlend.client.vue +2 -19
  131. package/layers/shader/app/components/Pipeline/SkyAtmosphere.client.vue +6 -9
  132. package/layers/shader/app/components/Pipeline/SoftLightBlend.client.vue +2 -19
  133. package/layers/shader/app/components/Pipeline/SplitTone.client.vue +4 -8
  134. package/layers/shader/app/components/Pipeline/Star.client.vue +4 -8
  135. package/layers/shader/app/components/Pipeline/Stripes.client.vue +4 -8
  136. package/layers/shader/app/components/Pipeline/Tint.client.vue +4 -7
  137. package/layers/shader/app/components/Pipeline/Triangle.client.vue +4 -8
  138. package/layers/shader/app/components/Pipeline/ValueNoise.client.vue +4 -8
  139. package/layers/shader/app/components/Pipeline/VoronoiEdges.client.vue +4 -8
  140. package/layers/shader/app/components/Pipeline/Water.client.vue +5 -8
  141. package/layers/shader/app/components/Pipeline/WaveBendLayer.client.vue +4 -7
  142. package/layers/shader/app/components/Pipeline/WaveColourLayer.client.vue +3 -7
  143. package/layers/shader/app/components/Pipeline/Wood.client.vue +4 -8
  144. package/layers/shader/app/components/Preset/Aurora.client.vue +15 -21
  145. package/layers/shader/app/components/Preset/Flow.client.vue +2 -1
  146. package/layers/shader/app/components/Preset/GradientMesh.client.vue +2 -1
  147. package/layers/shader/app/components/Preset/Nebula.client.vue +2 -1
  148. package/layers/shader/app/components/Preset/Ocean.client.vue +2 -1
  149. package/layers/shader/app/components/Preset/ThemeAurora.client.vue +30 -90
  150. package/layers/shader/app/components/Preset/ThemeBubble.client.vue +30 -91
  151. package/layers/shader/app/components/Preset/ThemeFlow.client.vue +30 -90
  152. package/layers/shader/app/components/Preset/ThemeGradient.client.vue +30 -91
  153. package/layers/shader/app/components/Preset/ThemeLavaLamp.client.vue +30 -90
  154. package/layers/shader/app/components/Preset/ThemePlasma.client.vue +30 -90
  155. package/layers/shader/app/components/Preset/ThemeWave.client.vue +30 -90
  156. package/layers/shader/app/components/Shader/Background.client.vue +4 -4
  157. package/layers/shader/app/components/Shader/Host.client.vue +31 -33
  158. package/layers/shader/app/components/Shader/Runtime.client.vue +15 -23
  159. package/layers/shader/app/composables/useAmbientMaterials.ts +53 -51
  160. package/layers/shader/app/composables/useShaderMixBlend.ts +26 -0
  161. package/layers/shader/app/composables/useThemePreset.ts +75 -0
  162. package/layers/shader/app/shaders/common/noise.ts +2 -7
  163. package/layers/shader/app/shaders/types.ts +6 -6
  164. package/layers/shader/app/types/tsl.ts +7 -25
  165. package/layers/shader/app/types/uniforms.ts +2 -1
  166. package/layers/shader/app/utils/tsl/color.ts +7 -1
  167. package/layers/shader/package.json +2 -1
  168. package/layers/theme/app/components/ThemePicker/Colors.vue +1 -3
  169. package/layers/theme/app/types/app-config.d.ts +4 -2
  170. package/layers/theme/app/types/index.ts +1 -0
  171. package/layers/theme/app/types/theme.ts +3 -18
  172. package/layers/theme/package.json +2 -1
  173. package/layers/theme/server/plugins/theme-fouc.ts +1 -1
  174. package/layers/transitions/package.json +4 -1
  175. package/layers/typography/app/components/Typography/CodeBlock.vue +2 -2
  176. package/layers/typography/app/components/Typography/Headline.vue +2 -2
  177. package/layers/typography/app/components/Typography/HeadlineScreen.vue +1 -1
  178. package/layers/typography/app/components/Typography/QuoteBlock.vue +4 -1
  179. package/layers/typography/app/components/Typography/TextStroke.vue +2 -0
  180. package/layers/typography/app/components/Typography/index.vue +36 -27
  181. package/layers/typography/app/composables/typography.ts +27 -21
  182. package/layers/typography/app/types/colors.ts +9 -29
  183. package/layers/typography/app/types/index.ts +2 -0
  184. package/layers/typography/package.json +4 -1
  185. package/layers/ui/package.json +2 -1
  186. package/layers/visual/app/app.config.ts +5 -2
  187. package/layers/visual/app/components/Accent/Blob.vue +20 -20
  188. package/layers/visual/app/components/Accent/Scene.vue +2 -2
  189. package/layers/visual/app/components/Base/Modal.vue +2 -2
  190. package/layers/visual/app/components/Gradient/Background.vue +2 -2
  191. package/layers/visual/app/components/Gradient/Text.vue +2 -2
  192. package/layers/visual/app/components/Media/Picture.vue +3 -1
  193. package/layers/visual/app/components/Progress/Bar.vue +6 -6
  194. package/layers/visual/app/components/Tint/Overlay.vue +14 -14
  195. package/layers/visual/app/composables/accent.ts +10 -8
  196. package/layers/visual/app/composables/tint.ts +7 -7
  197. package/layers/visual/app/types/index.ts +6 -0
  198. package/layers/visual/app/types/media.ts +4 -2
  199. package/layers/visual/app/types/tint.ts +2 -1
  200. package/layers/visual/package.json +4 -1
  201. package/package.json +5 -2
@@ -1,8 +1,7 @@
1
1
  <script setup lang="ts">
2
- import {
3
- createAmbientUniforms,
4
- createThemeGradientColorNode,
5
- } from '#layers/shader/app/composables/useAmbientMaterials'
2
+ import { createThemeGradientColorNode } from '#layers/shader/app/composables/useAmbientMaterials'
3
+ import { type ThemePresetProps } from '#layers/shader/app/composables/useThemePreset'
4
+ import type { TSLNode } from '#layers/shader/app/types/tsl'
6
5
 
7
6
  const {
8
7
  speed = 1.0,
@@ -13,99 +12,39 @@
13
12
  color2 = '#6366f1',
14
13
  color3 = '#a78bfa',
15
14
  color4 = '#38bdf8',
16
- } = defineProps<{
17
- speed?: number
18
- intensity?: number
19
- mouseInteraction?: boolean
20
- mouseStrength?: number
21
- color1?: string
22
- color2?: string
23
- color3?: string
24
- color4?: string
25
- }>()
15
+ } = defineProps<ThemePresetProps>()
26
16
 
27
17
  const emit = defineEmits<{
28
- node: [colorNode: any]
18
+ node: [colorNode: TSLNode]
29
19
  }>()
30
20
 
31
- const uniforms = createAmbientUniforms({
32
- speed: speed,
33
- intensity: intensity,
34
- mouseInteraction: mouseInteraction,
35
- })
36
- // createAmbientUniforms hardcodes 0.5 — override with our prop value
37
- if (mouseInteraction) {
38
- uniforms.mouseStrength.value = mouseStrength
39
- }
40
-
41
- const c1 = useShaderColor(color1)
42
- const c2 = useShaderColor(color2)
43
- const c3 = useShaderColor(color3)
44
- const c4 = useShaderColor(color4)
45
-
46
- const colorNode = createThemeGradientColorNode(uniforms, {
47
- color1: c1.node,
48
- color2: c2.node,
49
- color3: c3.node,
50
- color4: c4.node,
21
+ const { uniforms, colorNode } = useThemePreset(createThemeGradientColorNode, {
22
+ get speed() {
23
+ return speed
24
+ },
25
+ get intensity() {
26
+ return intensity
27
+ },
28
+ get mouseInteraction() {
29
+ return mouseInteraction
30
+ },
31
+ get mouseStrength() {
32
+ return mouseStrength
33
+ },
34
+ get color1() {
35
+ return color1
36
+ },
37
+ get color2() {
38
+ return color2
39
+ },
40
+ get color3() {
41
+ return color3
42
+ },
43
+ get color4() {
44
+ return color4
45
+ },
51
46
  })
52
47
 
53
- watch(
54
- () => color1,
55
- (hex) => c1.tweenTo(hex, 0.8)
56
- )
57
- watch(
58
- () => color2,
59
- (hex) => c2.tweenTo(hex, 0.8)
60
- )
61
- watch(
62
- () => color3,
63
- (hex) => c3.tweenTo(hex, 0.8)
64
- )
65
- watch(
66
- () => color4,
67
- (hex) => c4.tweenTo(hex, 0.8)
68
- )
69
-
70
- try {
71
- const runtime = useShaderRuntimeContext()
72
- watch(
73
- () => [runtime.mouse.mouseX.value, runtime.mouse.mouseY.value],
74
- ([mx, my]) => {
75
- uniforms.mouseX.value = mx
76
- uniforms.mouseY.value = my
77
- },
78
- { immediate: true }
79
- )
80
- } catch {
81
- // No runtime context
82
- }
83
-
84
- watch(
85
- () => speed,
86
- (v) => {
87
- uniforms.speed.value = v
88
- }
89
- )
90
- watch(
91
- () => intensity,
92
- (v) => {
93
- uniforms.intensity.value = v
94
- }
95
- )
96
- watch(
97
- () => mouseInteraction,
98
- (v) => {
99
- uniforms.mouseStrength.value = v ? mouseStrength : 0
100
- }
101
- )
102
- watch(
103
- () => mouseStrength,
104
- (v) => {
105
- if (mouseInteraction) uniforms.mouseStrength.value = v
106
- }
107
- )
108
-
109
48
  emit('node', colorNode)
110
49
  defineExpose({ uniforms, colorNode })
111
50
  </script>
@@ -1,8 +1,7 @@
1
1
  <script setup lang="ts">
2
- import {
3
- createAmbientUniforms,
4
- createThemeLavaLampColorNode,
5
- } from '#layers/shader/app/composables/useAmbientMaterials'
2
+ import { createThemeLavaLampColorNode } from '#layers/shader/app/composables/useAmbientMaterials'
3
+ import { type ThemePresetProps } from '#layers/shader/app/composables/useThemePreset'
4
+ import type { TSLNode } from '#layers/shader/app/types/tsl'
6
5
 
7
6
  const {
8
7
  speed = 1.0,
@@ -13,98 +12,39 @@
13
12
  color2 = '#6366f1',
14
13
  color3 = '#a78bfa',
15
14
  color4 = '#38bdf8',
16
- } = defineProps<{
17
- speed?: number
18
- intensity?: number
19
- mouseInteraction?: boolean
20
- mouseStrength?: number
21
- color1?: string
22
- color2?: string
23
- color3?: string
24
- color4?: string
25
- }>()
15
+ } = defineProps<ThemePresetProps>()
26
16
 
27
17
  const emit = defineEmits<{
28
- node: [colorNode: any]
18
+ node: [colorNode: TSLNode]
29
19
  }>()
30
20
 
31
- const uniforms = createAmbientUniforms({
32
- speed: speed,
33
- intensity: intensity,
34
- mouseInteraction: mouseInteraction,
35
- })
36
- if (mouseInteraction) {
37
- uniforms.mouseStrength.value = mouseStrength
38
- }
39
-
40
- const c1 = useShaderColor(color1)
41
- const c2 = useShaderColor(color2)
42
- const c3 = useShaderColor(color3)
43
- const c4 = useShaderColor(color4)
44
-
45
- const colorNode = createThemeLavaLampColorNode(uniforms, {
46
- color1: c1.node,
47
- color2: c2.node,
48
- color3: c3.node,
49
- color4: c4.node,
21
+ const { uniforms, colorNode } = useThemePreset(createThemeLavaLampColorNode, {
22
+ get speed() {
23
+ return speed
24
+ },
25
+ get intensity() {
26
+ return intensity
27
+ },
28
+ get mouseInteraction() {
29
+ return mouseInteraction
30
+ },
31
+ get mouseStrength() {
32
+ return mouseStrength
33
+ },
34
+ get color1() {
35
+ return color1
36
+ },
37
+ get color2() {
38
+ return color2
39
+ },
40
+ get color3() {
41
+ return color3
42
+ },
43
+ get color4() {
44
+ return color4
45
+ },
50
46
  })
51
47
 
52
- watch(
53
- () => color1,
54
- (hex) => c1.tweenTo(hex, 0.8)
55
- )
56
- watch(
57
- () => color2,
58
- (hex) => c2.tweenTo(hex, 0.8)
59
- )
60
- watch(
61
- () => color3,
62
- (hex) => c3.tweenTo(hex, 0.8)
63
- )
64
- watch(
65
- () => color4,
66
- (hex) => c4.tweenTo(hex, 0.8)
67
- )
68
-
69
- try {
70
- const runtime = useShaderRuntimeContext()
71
- watch(
72
- () => [runtime.mouse.mouseX.value, runtime.mouse.mouseY.value],
73
- ([mx, my]) => {
74
- uniforms.mouseX.value = mx
75
- uniforms.mouseY.value = my
76
- },
77
- { immediate: true }
78
- )
79
- } catch {
80
- // No runtime context
81
- }
82
-
83
- watch(
84
- () => speed,
85
- (v) => {
86
- uniforms.speed.value = v
87
- }
88
- )
89
- watch(
90
- () => intensity,
91
- (v) => {
92
- uniforms.intensity.value = v
93
- }
94
- )
95
- watch(
96
- () => mouseInteraction,
97
- (v) => {
98
- uniforms.mouseStrength.value = v ? mouseStrength : 0
99
- }
100
- )
101
- watch(
102
- () => mouseStrength,
103
- (v) => {
104
- if (mouseInteraction) uniforms.mouseStrength.value = v
105
- }
106
- )
107
-
108
48
  emit('node', colorNode)
109
49
  defineExpose({ uniforms, colorNode })
110
50
  </script>
@@ -1,8 +1,7 @@
1
1
  <script setup lang="ts">
2
- import {
3
- createAmbientUniforms,
4
- createThemePlasmaColorNode,
5
- } from '#layers/shader/app/composables/useAmbientMaterials'
2
+ import { createThemePlasmaColorNode } from '#layers/shader/app/composables/useAmbientMaterials'
3
+ import { type ThemePresetProps } from '#layers/shader/app/composables/useThemePreset'
4
+ import type { TSLNode } from '#layers/shader/app/types/tsl'
6
5
 
7
6
  const {
8
7
  speed = 1.0,
@@ -13,98 +12,39 @@
13
12
  color2 = '#6366f1',
14
13
  color3 = '#a78bfa',
15
14
  color4 = '#38bdf8',
16
- } = defineProps<{
17
- speed?: number
18
- intensity?: number
19
- mouseInteraction?: boolean
20
- mouseStrength?: number
21
- color1?: string
22
- color2?: string
23
- color3?: string
24
- color4?: string
25
- }>()
15
+ } = defineProps<ThemePresetProps>()
26
16
 
27
17
  const emit = defineEmits<{
28
- node: [colorNode: any]
18
+ node: [colorNode: TSLNode]
29
19
  }>()
30
20
 
31
- const uniforms = createAmbientUniforms({
32
- speed: speed,
33
- intensity: intensity,
34
- mouseInteraction: mouseInteraction,
35
- })
36
- if (mouseInteraction) {
37
- uniforms.mouseStrength.value = mouseStrength
38
- }
39
-
40
- const c1 = useShaderColor(color1)
41
- const c2 = useShaderColor(color2)
42
- const c3 = useShaderColor(color3)
43
- const c4 = useShaderColor(color4)
44
-
45
- const colorNode = createThemePlasmaColorNode(uniforms, {
46
- color1: c1.node,
47
- color2: c2.node,
48
- color3: c3.node,
49
- color4: c4.node,
21
+ const { uniforms, colorNode } = useThemePreset(createThemePlasmaColorNode, {
22
+ get speed() {
23
+ return speed
24
+ },
25
+ get intensity() {
26
+ return intensity
27
+ },
28
+ get mouseInteraction() {
29
+ return mouseInteraction
30
+ },
31
+ get mouseStrength() {
32
+ return mouseStrength
33
+ },
34
+ get color1() {
35
+ return color1
36
+ },
37
+ get color2() {
38
+ return color2
39
+ },
40
+ get color3() {
41
+ return color3
42
+ },
43
+ get color4() {
44
+ return color4
45
+ },
50
46
  })
51
47
 
52
- watch(
53
- () => color1,
54
- (hex) => c1.tweenTo(hex, 0.8)
55
- )
56
- watch(
57
- () => color2,
58
- (hex) => c2.tweenTo(hex, 0.8)
59
- )
60
- watch(
61
- () => color3,
62
- (hex) => c3.tweenTo(hex, 0.8)
63
- )
64
- watch(
65
- () => color4,
66
- (hex) => c4.tweenTo(hex, 0.8)
67
- )
68
-
69
- try {
70
- const runtime = useShaderRuntimeContext()
71
- watch(
72
- () => [runtime.mouse.mouseX.value, runtime.mouse.mouseY.value],
73
- ([mx, my]) => {
74
- uniforms.mouseX.value = mx
75
- uniforms.mouseY.value = my
76
- },
77
- { immediate: true }
78
- )
79
- } catch {
80
- // No runtime context
81
- }
82
-
83
- watch(
84
- () => speed,
85
- (v) => {
86
- uniforms.speed.value = v
87
- }
88
- )
89
- watch(
90
- () => intensity,
91
- (v) => {
92
- uniforms.intensity.value = v
93
- }
94
- )
95
- watch(
96
- () => mouseInteraction,
97
- (v) => {
98
- uniforms.mouseStrength.value = v ? mouseStrength : 0
99
- }
100
- )
101
- watch(
102
- () => mouseStrength,
103
- (v) => {
104
- if (mouseInteraction) uniforms.mouseStrength.value = v
105
- }
106
- )
107
-
108
48
  emit('node', colorNode)
109
49
  defineExpose({ uniforms, colorNode })
110
50
  </script>
@@ -1,8 +1,7 @@
1
1
  <script setup lang="ts">
2
- import {
3
- createAmbientUniforms,
4
- createThemeWaveColorNode,
5
- } from '#layers/shader/app/composables/useAmbientMaterials'
2
+ import { createThemeWaveColorNode } from '#layers/shader/app/composables/useAmbientMaterials'
3
+ import { type ThemePresetProps } from '#layers/shader/app/composables/useThemePreset'
4
+ import type { TSLNode } from '#layers/shader/app/types/tsl'
6
5
 
7
6
  const {
8
7
  speed = 1.0,
@@ -13,98 +12,39 @@
13
12
  color2 = '#6366f1',
14
13
  color3 = '#a78bfa',
15
14
  color4 = '#38bdf8',
16
- } = defineProps<{
17
- speed?: number
18
- intensity?: number
19
- mouseInteraction?: boolean
20
- mouseStrength?: number
21
- color1?: string
22
- color2?: string
23
- color3?: string
24
- color4?: string
25
- }>()
15
+ } = defineProps<ThemePresetProps>()
26
16
 
27
17
  const emit = defineEmits<{
28
- node: [colorNode: any]
18
+ node: [colorNode: TSLNode]
29
19
  }>()
30
20
 
31
- const uniforms = createAmbientUniforms({
32
- speed: speed,
33
- intensity: intensity,
34
- mouseInteraction: mouseInteraction,
35
- })
36
- if (mouseInteraction) {
37
- uniforms.mouseStrength.value = mouseStrength
38
- }
39
-
40
- const c1 = useShaderColor(color1)
41
- const c2 = useShaderColor(color2)
42
- const c3 = useShaderColor(color3)
43
- const c4 = useShaderColor(color4)
44
-
45
- const colorNode = createThemeWaveColorNode(uniforms, {
46
- color1: c1.node,
47
- color2: c2.node,
48
- color3: c3.node,
49
- color4: c4.node,
21
+ const { uniforms, colorNode } = useThemePreset(createThemeWaveColorNode, {
22
+ get speed() {
23
+ return speed
24
+ },
25
+ get intensity() {
26
+ return intensity
27
+ },
28
+ get mouseInteraction() {
29
+ return mouseInteraction
30
+ },
31
+ get mouseStrength() {
32
+ return mouseStrength
33
+ },
34
+ get color1() {
35
+ return color1
36
+ },
37
+ get color2() {
38
+ return color2
39
+ },
40
+ get color3() {
41
+ return color3
42
+ },
43
+ get color4() {
44
+ return color4
45
+ },
50
46
  })
51
47
 
52
- watch(
53
- () => color1,
54
- (hex) => c1.tweenTo(hex, 0.8)
55
- )
56
- watch(
57
- () => color2,
58
- (hex) => c2.tweenTo(hex, 0.8)
59
- )
60
- watch(
61
- () => color3,
62
- (hex) => c3.tweenTo(hex, 0.8)
63
- )
64
- watch(
65
- () => color4,
66
- (hex) => c4.tweenTo(hex, 0.8)
67
- )
68
-
69
- try {
70
- const runtime = useShaderRuntimeContext()
71
- watch(
72
- () => [runtime.mouse.mouseX.value, runtime.mouse.mouseY.value],
73
- ([mx, my]) => {
74
- uniforms.mouseX.value = mx
75
- uniforms.mouseY.value = my
76
- },
77
- { immediate: true }
78
- )
79
- } catch {
80
- // No runtime context
81
- }
82
-
83
- watch(
84
- () => speed,
85
- (v) => {
86
- uniforms.speed.value = v
87
- }
88
- )
89
- watch(
90
- () => intensity,
91
- (v) => {
92
- uniforms.intensity.value = v
93
- }
94
- )
95
- watch(
96
- () => mouseInteraction,
97
- (v) => {
98
- uniforms.mouseStrength.value = v ? mouseStrength : 0
99
- }
100
- )
101
- watch(
102
- () => mouseStrength,
103
- (v) => {
104
- if (mouseInteraction) uniforms.mouseStrength.value = v
105
- }
106
- )
107
-
108
48
  emit('node', colorNode)
109
49
  defineExpose({ uniforms, colorNode })
110
50
  </script>
@@ -13,7 +13,7 @@
13
13
  Scene,
14
14
  SRGBColorSpace,
15
15
  } from 'three'
16
- import { WebGPURenderer } from 'three/webgpu'
16
+ import { MeshBasicNodeMaterial, WebGPURenderer } from 'three/webgpu'
17
17
 
18
18
  const {
19
19
  material = null,
@@ -25,7 +25,7 @@
25
25
  pointerEvents = 'none',
26
26
  } = defineProps<{
27
27
  /** The TSL node material to render */
28
- material?: any
28
+ material?: MeshBasicNodeMaterial | null
29
29
  /** Background clear color */
30
30
  clearColor?: string
31
31
  /** Tone mapping algorithm */
@@ -41,13 +41,13 @@
41
41
  }>()
42
42
 
43
43
  const emit = defineEmits<{
44
- ready: [renderer: any]
44
+ ready: [renderer: WebGPURenderer]
45
45
  }>()
46
46
 
47
47
  const canvasRef = useTemplateRef<HTMLCanvasElement>('canvasRef')
48
48
  const { width, height } = useWindowSize()
49
49
 
50
- let renderer: any
50
+ let renderer: WebGPURenderer | undefined
51
51
  let scene: Scene
52
52
  let camera: PerspectiveCamera
53
53
  let planeMesh: Mesh
@@ -1,36 +1,34 @@
1
1
  <script setup lang="ts">
2
2
  import type { Component } from 'vue'
3
+ import type { TSLNode } from '#layers/shader/app/types/tsl'
3
4
  import { tweenUniform } from '#layers/shader/app/utils/tsl/tween'
4
5
  import { DoubleSide } from 'three'
5
6
  import { mix as tslMix, uniform } from 'three/tsl'
6
7
  import { MeshBasicNodeMaterial } from 'three/webgpu'
7
8
 
8
- const props = withDefaults(
9
- defineProps<{
10
- /** The active preset component */
11
- preset?: Component | null
12
- /** Crossfade duration in seconds */
13
- transitionDuration?: number
14
- /** Props forwarded to the active preset component */
15
- presetProps?: Record<string, any>
16
- /** ShaderBackground props */
17
- clearColor?: string
18
- toneMapping?: 'aces' | 'reinhard' | 'cineon' | 'linear'
19
- fixed?: boolean
20
- zIndex?: number
21
- pointerEvents?: 'none' | 'auto'
22
- }>(),
23
- {
24
- preset: null,
25
- transitionDuration: 1.0,
26
- presetProps: () => ({}),
27
- clearColor: '#000000',
28
- toneMapping: 'aces',
29
- fixed: true,
30
- zIndex: -1,
31
- pointerEvents: 'none',
32
- }
33
- )
9
+ const {
10
+ preset = null,
11
+ transitionDuration = 1.0,
12
+ presetProps = {} as Record<string, unknown>,
13
+ clearColor = '#000000',
14
+ toneMapping = 'aces',
15
+ fixed = true,
16
+ zIndex = -1,
17
+ pointerEvents = 'none',
18
+ } = defineProps<{
19
+ /** The active preset component */
20
+ preset?: Component | null
21
+ /** Crossfade duration in seconds */
22
+ transitionDuration?: number
23
+ /** Props forwarded to the active preset component */
24
+ presetProps?: Record<string, unknown>
25
+ /** ShaderBackground props */
26
+ clearColor?: string
27
+ toneMapping?: 'aces' | 'reinhard' | 'cineon' | 'linear'
28
+ fixed?: boolean
29
+ zIndex?: number
30
+ pointerEvents?: 'none' | 'auto'
31
+ }>()
34
32
 
35
33
  const emit = defineEmits<{
36
34
  transitionStart: []
@@ -42,7 +40,7 @@
42
40
  const isTransitioning = ref(false)
43
41
 
44
42
  // Current and next preset tracking
45
- const currentPreset = shallowRef<Component | null>(props.preset)
43
+ const currentPreset = shallowRef<Component | null>(preset)
46
44
  const nextPreset = shallowRef<Component | null>(null)
47
45
 
48
46
  function setCurrentPreset(preset: Component | null) {
@@ -54,15 +52,15 @@
54
52
  material.side = DoubleSide
55
53
 
56
54
  // Current and next graph nodes (set by preset via @node event)
57
- let currentNode: any = null
58
- let nextNode: any = null
55
+ let currentNode: TSLNode | null = null
56
+ let nextNode: TSLNode | null = null
59
57
 
60
- function setCurrentNode(node: any) {
58
+ function setCurrentNode(node: TSLNode) {
61
59
  currentNode = node
62
60
  updateMaterialNode()
63
61
  }
64
62
 
65
- function setNextNode(node: any) {
63
+ function setNextNode(node: TSLNode) {
66
64
  nextNode = node
67
65
  updateMaterialNode()
68
66
  }
@@ -79,7 +77,7 @@
79
77
 
80
78
  // Watch preset changes for crossfade
81
79
  watch(
82
- () => props.preset,
80
+ () => preset,
83
81
  async (newPreset, oldPreset) => {
84
82
  if (!newPreset || newPreset === oldPreset) return
85
83
 
@@ -100,7 +98,7 @@
100
98
  transitionProgress,
101
99
  0,
102
100
  1,
103
- props.transitionDuration,
101
+ transitionDuration,
104
102
  (t) => t * t * (3 - 2 * t) // smoothstep
105
103
  )
106
104