@basementstudio/shader-lab 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/.biome/plugins/README.md +21 -0
  2. package/.biome/plugins/no-anchor-element.grit +12 -0
  3. package/.biome/plugins/no-relative-parent-imports.grit +10 -0
  4. package/.biome/plugins/no-unnecessary-forwardref.grit +9 -0
  5. package/.changeset/README.md +17 -0
  6. package/.changeset/config.json +11 -0
  7. package/.editorconfig +40 -0
  8. package/.env.example +81 -0
  9. package/.gitattributes +19 -0
  10. package/.github/workflows/canary.yml +80 -0
  11. package/.github/workflows/ci.yml +37 -0
  12. package/.github/workflows/release.yml +56 -0
  13. package/.tldrignore +84 -0
  14. package/.vscode/extensions.json +20 -0
  15. package/.vscode/settings.json +105 -0
  16. package/README.md +119 -0
  17. package/biome.json +249 -0
  18. package/bun.lock +1224 -0
  19. package/next.config.ts +131 -0
  20. package/package.json +73 -0
  21. package/packages/shader-lab-react/CHANGELOG.md +9 -0
  22. package/packages/shader-lab-react/README.md +119 -0
  23. package/packages/shader-lab-react/assets/patterns/bars/1.svg +3 -0
  24. package/packages/shader-lab-react/assets/patterns/bars/2.svg +3 -0
  25. package/packages/shader-lab-react/assets/patterns/bars/3.svg +3 -0
  26. package/packages/shader-lab-react/assets/patterns/bars/4.svg +3 -0
  27. package/packages/shader-lab-react/assets/patterns/bars/5.svg +3 -0
  28. package/packages/shader-lab-react/assets/patterns/bars/6.svg +3 -0
  29. package/packages/shader-lab-react/assets/patterns/candles/1.svg +3 -0
  30. package/packages/shader-lab-react/assets/patterns/candles/2.svg +3 -0
  31. package/packages/shader-lab-react/assets/patterns/candles/3.svg +3 -0
  32. package/packages/shader-lab-react/assets/patterns/candles/4.svg +3 -0
  33. package/packages/shader-lab-react/assets/patterns/shapes/1.svg +3 -0
  34. package/packages/shader-lab-react/assets/patterns/shapes/2.svg +3 -0
  35. package/packages/shader-lab-react/assets/patterns/shapes/3.svg +3 -0
  36. package/packages/shader-lab-react/assets/patterns/shapes/4.svg +4 -0
  37. package/packages/shader-lab-react/assets/patterns/shapes/5.svg +3 -0
  38. package/packages/shader-lab-react/assets/patterns/shapes/6.svg +4 -0
  39. package/packages/shader-lab-react/assets/textures/blue-noise.png +0 -0
  40. package/packages/shader-lab-react/package.json +36 -0
  41. package/packages/shader-lab-react/scripts/fix-esm-specifiers.mjs +57 -0
  42. package/packages/shader-lab-react/scripts/prepare-dist.mjs +4 -0
  43. package/packages/shader-lab-react/src/ambient/three-tsl.d.ts +146 -0
  44. package/packages/shader-lab-react/src/ambient/three-webgpu.d.ts +51 -0
  45. package/packages/shader-lab-react/src/easings.ts +4 -0
  46. package/packages/shader-lab-react/src/index.ts +35 -0
  47. package/packages/shader-lab-react/src/lib/editor/custom-shader/shared.ts +2 -0
  48. package/packages/shader-lab-react/src/renderer/ascii-atlas.ts +83 -0
  49. package/packages/shader-lab-react/src/renderer/ascii-pass.ts +416 -0
  50. package/packages/shader-lab-react/src/renderer/asset-url.ts +3 -0
  51. package/packages/shader-lab-react/src/renderer/blend-modes.ts +229 -0
  52. package/packages/shader-lab-react/src/renderer/contracts.ts +54 -0
  53. package/packages/shader-lab-react/src/renderer/create-webgpu-renderer.ts +48 -0
  54. package/packages/shader-lab-react/src/renderer/crt-pass.ts +1040 -0
  55. package/packages/shader-lab-react/src/renderer/custom-shader-pass.ts +108 -0
  56. package/packages/shader-lab-react/src/renderer/custom-shader-runtime.ts +309 -0
  57. package/packages/shader-lab-react/src/renderer/dither-textures.ts +99 -0
  58. package/packages/shader-lab-react/src/renderer/dithering-pass.ts +322 -0
  59. package/packages/shader-lab-react/src/renderer/gradient-pass.ts +521 -0
  60. package/packages/shader-lab-react/src/renderer/halftone-pass.ts +932 -0
  61. package/packages/shader-lab-react/src/renderer/ink-pass.ts +802 -0
  62. package/packages/shader-lab-react/src/renderer/live-pass.ts +194 -0
  63. package/packages/shader-lab-react/src/renderer/media-pass.ts +187 -0
  64. package/packages/shader-lab-react/src/renderer/media-texture.ts +66 -0
  65. package/packages/shader-lab-react/src/renderer/particle-grid-pass.ts +389 -0
  66. package/packages/shader-lab-react/src/renderer/pass-node.ts +209 -0
  67. package/packages/shader-lab-react/src/renderer/pattern-atlas.ts +133 -0
  68. package/packages/shader-lab-react/src/renderer/pattern-pass.ts +552 -0
  69. package/packages/shader-lab-react/src/renderer/pipeline-manager.ts +369 -0
  70. package/packages/shader-lab-react/src/renderer/pixel-sorting-pass.ts +277 -0
  71. package/packages/shader-lab-react/src/renderer/shaders/tsl/color/tonemapping.ts +87 -0
  72. package/packages/shader-lab-react/src/renderer/shaders/tsl/cosine-palette.ts +9 -0
  73. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/common.ts +31 -0
  74. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/curl-noise-3d.ts +36 -0
  75. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/curl-noise-4d.ts +36 -0
  76. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/fbm.ts +13 -0
  77. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/perlin-noise-3d.ts +96 -0
  78. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/ridge-noise.ts +24 -0
  79. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/simplex-noise-3d.ts +79 -0
  80. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/simplex-noise-4d.ts +89 -0
  81. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/turbulence.ts +56 -0
  82. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/value-noise-3d.ts +32 -0
  83. package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/voronoi-noise-3d.ts +60 -0
  84. package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/bloom-edge-pattern.ts +15 -0
  85. package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/bloom.ts +11 -0
  86. package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/canvas-weave-pattern.ts +24 -0
  87. package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/grain-texture-pattern.ts +9 -0
  88. package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/repeating-pattern.ts +11 -0
  89. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/atan2.ts +9 -0
  90. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-conj.ts +9 -0
  91. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-cos.ts +10 -0
  92. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-div.ts +11 -0
  93. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-log.ts +7 -0
  94. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-mobius.ts +12 -0
  95. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-mul.ts +9 -0
  96. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-pow.ts +16 -0
  97. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-sin.ts +10 -0
  98. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-sqrt.ts +18 -0
  99. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-tan.ts +12 -0
  100. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-to-polar.ts +10 -0
  101. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/hyperbolic.ts +20 -0
  102. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/index.ts +48 -0
  103. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/rotate.ts +15 -0
  104. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/screen-aspect-uv.ts +15 -0
  105. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-box-2d.ts +6 -0
  106. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-diamond.ts +6 -0
  107. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-rhombus.ts +27 -0
  108. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-sphere.ts +6 -0
  109. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/smax.ts +7 -0
  110. package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/smin.ts +7 -0
  111. package/packages/shader-lab-react/src/renderer/text-pass.ts +176 -0
  112. package/packages/shader-lab-react/src/runtime-clock.ts +42 -0
  113. package/packages/shader-lab-react/src/runtime-frame.ts +29 -0
  114. package/packages/shader-lab-react/src/shader-lab-composition.tsx +163 -0
  115. package/packages/shader-lab-react/src/timeline.ts +283 -0
  116. package/packages/shader-lab-react/src/types/editor.ts +5 -0
  117. package/packages/shader-lab-react/src/types.ts +141 -0
  118. package/packages/shader-lab-react/tsconfig.build.json +8 -0
  119. package/packages/shader-lab-react/tsconfig.json +21 -0
  120. package/postcss.config.mjs +5 -0
  121. package/public/assets/fonts/msdf/geist-mono/GeistMono-Regular-msdf-atlas.png +0 -0
  122. package/public/assets/fonts/msdf/geist-mono/GeistMono-Regular-msdf.json +1412 -0
  123. package/public/assets/patterns/bars/1.svg +3 -0
  124. package/public/assets/patterns/bars/2.svg +3 -0
  125. package/public/assets/patterns/bars/3.svg +3 -0
  126. package/public/assets/patterns/bars/4.svg +3 -0
  127. package/public/assets/patterns/bars/5.svg +3 -0
  128. package/public/assets/patterns/bars/6.svg +3 -0
  129. package/public/assets/patterns/candles/1.svg +3 -0
  130. package/public/assets/patterns/candles/2.svg +3 -0
  131. package/public/assets/patterns/candles/3.svg +3 -0
  132. package/public/assets/patterns/candles/4.svg +3 -0
  133. package/public/assets/patterns/shapes/1.svg +3 -0
  134. package/public/assets/patterns/shapes/2.svg +3 -0
  135. package/public/assets/patterns/shapes/3.svg +3 -0
  136. package/public/assets/patterns/shapes/4.svg +4 -0
  137. package/public/assets/patterns/shapes/5.svg +3 -0
  138. package/public/assets/patterns/shapes/6.svg +4 -0
  139. package/public/fonts/geist/Geist-Mono.woff2 +0 -0
  140. package/public/textures/blue-noise.png +0 -0
  141. package/public/textures/crt-mask.png +0 -0
  142. package/src/app/design/page.tsx +398 -0
  143. package/src/app/favicon.ico +0 -0
  144. package/src/app/globals.css +280 -0
  145. package/src/app/layout.tsx +89 -0
  146. package/src/app/page.tsx +20 -0
  147. package/src/app/robots.ts +13 -0
  148. package/src/app/sitemap.ts +13 -0
  149. package/src/components/editor/editor-canvas-viewport.tsx +116 -0
  150. package/src/components/editor/editor-export-dialog.tsx +1177 -0
  151. package/src/components/editor/editor-timeline-overlay.tsx +983 -0
  152. package/src/components/editor/editor-topbar.tsx +287 -0
  153. package/src/components/editor/layer-sidebar.tsx +738 -0
  154. package/src/components/editor/properties-sidebar-content.tsx +574 -0
  155. package/src/components/editor/properties-sidebar-fields.tsx +389 -0
  156. package/src/components/editor/properties-sidebar-utils.ts +178 -0
  157. package/src/components/editor/properties-sidebar.tsx +421 -0
  158. package/src/components/ui/button/index.tsx +57 -0
  159. package/src/components/ui/color-picker/index.tsx +358 -0
  160. package/src/components/ui/glass-panel/index.tsx +45 -0
  161. package/src/components/ui/icon-button/index.tsx +46 -0
  162. package/src/components/ui/select/index.tsx +136 -0
  163. package/src/components/ui/slider/index.tsx +192 -0
  164. package/src/components/ui/toggle/index.tsx +34 -0
  165. package/src/components/ui/typography/index.tsx +61 -0
  166. package/src/components/ui/xy-pad/index.tsx +160 -0
  167. package/src/features/editor/components/editor-export-dialog.module.css +271 -0
  168. package/src/hooks/use-editor-renderer.ts +182 -0
  169. package/src/lib/app.ts +6 -0
  170. package/src/lib/cn.ts +7 -0
  171. package/src/lib/easings.ts +240 -0
  172. package/src/lib/editor/config/layer-registry.ts +2434 -0
  173. package/src/lib/editor/custom-shader/shared.ts +28 -0
  174. package/src/lib/editor/export.ts +420 -0
  175. package/src/lib/editor/history.ts +71 -0
  176. package/src/lib/editor/layers.ts +76 -0
  177. package/src/lib/editor/parameter-schema.ts +75 -0
  178. package/src/lib/editor/project-file.ts +145 -0
  179. package/src/lib/editor/shader-export-snippet.ts +37 -0
  180. package/src/lib/editor/shader-export.ts +315 -0
  181. package/src/lib/editor/timeline/evaluate.ts +252 -0
  182. package/src/lib/editor/view-transform.ts +58 -0
  183. package/src/lib/fonts.ts +28 -0
  184. package/src/renderer/ascii-atlas.ts +83 -0
  185. package/src/renderer/ascii-pass.ts +416 -0
  186. package/src/renderer/blend-modes.ts +229 -0
  187. package/src/renderer/contracts.ts +161 -0
  188. package/src/renderer/create-webgpu-renderer.ts +48 -0
  189. package/src/renderer/crt-pass.ts +1040 -0
  190. package/src/renderer/custom-shader-pass.ts +117 -0
  191. package/src/renderer/custom-shader-runtime.ts +309 -0
  192. package/src/renderer/dither-textures.ts +99 -0
  193. package/src/renderer/dithering-pass.ts +322 -0
  194. package/src/renderer/gradient-pass.ts +520 -0
  195. package/src/renderer/halftone-pass.ts +932 -0
  196. package/src/renderer/ink-pass.ts +683 -0
  197. package/src/renderer/live-pass.ts +194 -0
  198. package/src/renderer/media-pass.ts +187 -0
  199. package/src/renderer/media-texture.ts +66 -0
  200. package/src/renderer/particle-grid-pass.ts +389 -0
  201. package/src/renderer/pass-node-factory.ts +33 -0
  202. package/src/renderer/pass-node.ts +209 -0
  203. package/src/renderer/pattern-atlas.ts +97 -0
  204. package/src/renderer/pattern-pass.ts +552 -0
  205. package/src/renderer/pipeline-manager.ts +343 -0
  206. package/src/renderer/pixel-sorting-pass.ts +277 -0
  207. package/src/renderer/project-clock.ts +57 -0
  208. package/src/renderer/shaders/tsl/color/tonemapping.ts +86 -0
  209. package/src/renderer/shaders/tsl/cosine-palette.ts +8 -0
  210. package/src/renderer/shaders/tsl/noise/common.ts +30 -0
  211. package/src/renderer/shaders/tsl/noise/curl-noise-3d.ts +35 -0
  212. package/src/renderer/shaders/tsl/noise/curl-noise-4d.ts +35 -0
  213. package/src/renderer/shaders/tsl/noise/fbm.ts +12 -0
  214. package/src/renderer/shaders/tsl/noise/perlin-noise-3d.ts +97 -0
  215. package/src/renderer/shaders/tsl/noise/ridge-noise.ts +23 -0
  216. package/src/renderer/shaders/tsl/noise/simplex-noise-3d.ts +78 -0
  217. package/src/renderer/shaders/tsl/noise/simplex-noise-4d.ts +88 -0
  218. package/src/renderer/shaders/tsl/noise/turbulence.ts +55 -0
  219. package/src/renderer/shaders/tsl/noise/value-noise-3d.ts +31 -0
  220. package/src/renderer/shaders/tsl/noise/voronoi-noise-3d.ts +59 -0
  221. package/src/renderer/shaders/tsl/patterns/bloom-edge-pattern.ts +14 -0
  222. package/src/renderer/shaders/tsl/patterns/bloom.ts +10 -0
  223. package/src/renderer/shaders/tsl/patterns/canvas-weave-pattern.ts +23 -0
  224. package/src/renderer/shaders/tsl/patterns/grain-texture-pattern.ts +8 -0
  225. package/src/renderer/shaders/tsl/patterns/repeating-pattern.ts +10 -0
  226. package/src/renderer/shaders/tsl/utils/atan2.ts +8 -0
  227. package/src/renderer/shaders/tsl/utils/complex-conj.ts +8 -0
  228. package/src/renderer/shaders/tsl/utils/complex-cos.ts +9 -0
  229. package/src/renderer/shaders/tsl/utils/complex-div.ts +10 -0
  230. package/src/renderer/shaders/tsl/utils/complex-log.ts +6 -0
  231. package/src/renderer/shaders/tsl/utils/complex-mobius.ts +11 -0
  232. package/src/renderer/shaders/tsl/utils/complex-mul.ts +8 -0
  233. package/src/renderer/shaders/tsl/utils/complex-pow.ts +15 -0
  234. package/src/renderer/shaders/tsl/utils/complex-sin.ts +9 -0
  235. package/src/renderer/shaders/tsl/utils/complex-sqrt.ts +17 -0
  236. package/src/renderer/shaders/tsl/utils/complex-tan.ts +11 -0
  237. package/src/renderer/shaders/tsl/utils/complex-to-polar.ts +9 -0
  238. package/src/renderer/shaders/tsl/utils/hyperbolic.ts +19 -0
  239. package/src/renderer/shaders/tsl/utils/index.ts +47 -0
  240. package/src/renderer/shaders/tsl/utils/rotate.ts +14 -0
  241. package/src/renderer/shaders/tsl/utils/screen-aspect-uv.ts +14 -0
  242. package/src/renderer/shaders/tsl/utils/sd-box-2d.ts +5 -0
  243. package/src/renderer/shaders/tsl/utils/sd-diamond.ts +5 -0
  244. package/src/renderer/shaders/tsl/utils/sd-rhombus.ts +26 -0
  245. package/src/renderer/shaders/tsl/utils/sd-sphere.ts +5 -0
  246. package/src/renderer/shaders/tsl/utils/smax.ts +7 -0
  247. package/src/renderer/shaders/tsl/utils/smin.ts +6 -0
  248. package/src/renderer/text-pass.ts +176 -0
  249. package/src/store/asset-store.ts +193 -0
  250. package/src/store/editor-store.ts +223 -0
  251. package/src/store/history-store.ts +172 -0
  252. package/src/store/index.ts +31 -0
  253. package/src/store/layer-store.ts +675 -0
  254. package/src/store/timeline-store.ts +572 -0
  255. package/src/types/assets.d.ts +6 -0
  256. package/src/types/css.d.ts +21 -0
  257. package/src/types/editor.ts +357 -0
  258. package/src/types/react.d.ts +15 -0
  259. package/src/types/three-tsl.d.ts +146 -0
  260. package/src/types/three-webgpu.d.ts +51 -0
  261. package/tsconfig.json +49 -0
package/next.config.ts ADDED
@@ -0,0 +1,131 @@
1
+ import withBundleAnalyzer from "@next/bundle-analyzer"
2
+ import type { NextConfig } from "next"
3
+
4
+ const nextConfig: NextConfig = {
5
+ reactStrictMode: true,
6
+ reactCompiler: true,
7
+ typedRoutes: true,
8
+ turbopack: {
9
+ rules: {
10
+ "*.svg": {
11
+ loaders: [
12
+ {
13
+ loader: "@svgr/webpack",
14
+ options: {
15
+ memo: true,
16
+ dimensions: false,
17
+ svgoConfig: {
18
+ multipass: true,
19
+ plugins: [
20
+ "removeDimensions",
21
+ "removeOffCanvasPaths",
22
+ "reusePaths",
23
+ "removeElementsByAttr",
24
+ "removeStyleElement",
25
+ "removeScriptElement",
26
+ "prefixIds",
27
+ "cleanupIds",
28
+ {
29
+ name: "cleanupNumericValues",
30
+ params: {
31
+ floatPrecision: 1,
32
+ },
33
+ },
34
+ {
35
+ name: "convertPathData",
36
+ params: {
37
+ floatPrecision: 1,
38
+ },
39
+ },
40
+ {
41
+ name: "convertTransform",
42
+ params: {
43
+ floatPrecision: 1,
44
+ },
45
+ },
46
+ {
47
+ name: "cleanupListOfValues",
48
+ params: {
49
+ floatPrecision: 1,
50
+ },
51
+ },
52
+ ],
53
+ },
54
+ },
55
+ },
56
+ ],
57
+ as: "*.js",
58
+ },
59
+ },
60
+ },
61
+ cacheComponents: true,
62
+ experimental: {
63
+ browserDebugInfoInTerminal: true,
64
+ optimizePackageImports: [
65
+ "@react-three/drei",
66
+ "@react-three/fiber",
67
+ "gsap",
68
+ "three",
69
+ "postprocessing",
70
+ "lenis",
71
+ "zustand",
72
+ ],
73
+ },
74
+ images: {
75
+ dangerouslyAllowSVG: true,
76
+ remotePatterns: [],
77
+ minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days
78
+ qualities: [90],
79
+ formats: ["image/avif", "image/webp"],
80
+ deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
81
+ imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
82
+ },
83
+ headers: async () => [
84
+ {
85
+ source: "/(.*)",
86
+ headers: [
87
+ {
88
+ key: "X-Content-Type-Options",
89
+ value: "nosniff",
90
+ },
91
+ {
92
+ key: "Content-Security-Policy",
93
+ value: "frame-ancestors 'self';",
94
+ },
95
+ {
96
+ key: "X-Frame-Options",
97
+ value: "SAMEORIGIN",
98
+ },
99
+ {
100
+ key: "X-XSS-Protection",
101
+ value: "1; mode=block",
102
+ },
103
+ {
104
+ key: "X-DNS-Prefetch-Control",
105
+ value: "on",
106
+ },
107
+ {
108
+ key: "Strict-Transport-Security",
109
+ value: "max-age=63072000; includeSubDomains; preload",
110
+ },
111
+ {
112
+ key: "Permissions-Policy",
113
+ value: "camera=(self), microphone=(), geolocation=()",
114
+ },
115
+ ],
116
+ },
117
+ ],
118
+ redirects: async () => [],
119
+ rewrites: async () => [],
120
+ }
121
+
122
+ const bundleAnalyzerPlugin = withBundleAnalyzer({
123
+ enabled: process.env.ANALYZE === "true",
124
+ })
125
+
126
+ const NextApp = () => {
127
+ const plugins = [bundleAnalyzerPlugin]
128
+ return plugins.reduce((config, plugin) => plugin(config), nextConfig)
129
+ }
130
+
131
+ export default NextApp
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@basementstudio/shader-lab",
3
+ "description": "Shader Lab starter template",
4
+ "version": "0.1.0",
5
+ "packageManager": "bun@1.3.5",
6
+ "workspaces": [
7
+ "packages/*"
8
+ ],
9
+ "scripts": {
10
+ "analyze": "cross-env ANALYZE=true bun run build",
11
+ "analyze:experimental": "next experimental-analyze",
12
+ "build": "bun run build:runtime && next build",
13
+ "build:runtime": "bun run --cwd packages/shader-lab-react build",
14
+ "changeset": "changeset",
15
+ "check": "bun run build:runtime && bun run lint && bun run typecheck:compare",
16
+ "dev": "next dev",
17
+ "dev:https": "next dev --experimental-https",
18
+ "format": "biome format --write .",
19
+ "lighthouse": "bunx @unlighthouse/cli --site http://localhost:3000",
20
+ "lint": "biome lint --max-diagnostics=200",
21
+ "lint:fix": "biome lint --write --unsafe --max-diagnostics=200",
22
+ "release": "changeset publish",
23
+ "release-canary": "changeset publish --tag canary --no-git-tag",
24
+ "version-canary": "changeset version --snapshot canary",
25
+ "version-packages": "changeset version",
26
+ "start": "next start",
27
+ "test": "bun test",
28
+ "typecheck": "tsgo --noEmit",
29
+ "typecheck:runtime": "bun run --cwd packages/shader-lab-react typecheck",
30
+ "typecheck:compare": "bun run typecheck:tsc && bun run typecheck",
31
+ "typecheck:tsc": "tsc --noEmit --incremental false"
32
+ },
33
+ "dependencies": {
34
+ "@basementstudio/shader-lab": "workspace:*",
35
+ "@base-ui/react": "^1.3.0",
36
+ "@phosphor-icons/react": "^2.1.10",
37
+ "class-variance-authority": "^0.7.1",
38
+ "motion": "^12.38.0",
39
+ "next": "16.1.4",
40
+ "react": "19.2.4",
41
+ "react-dom": "19.2.4",
42
+ "react-use": "^17.6.0",
43
+ "tailwind-merge": "^3.4.0",
44
+ "three": "^0.183.2",
45
+ "zod": "^4.3.6",
46
+ "zustand": "^5.0.10"
47
+ },
48
+ "devDependencies": {
49
+ "@biomejs/biome": "2.3.11",
50
+ "@changesets/changelog-github": "^0.6.0",
51
+ "@changesets/cli": "^2.30.0",
52
+ "@next/bundle-analyzer": "16.1.1",
53
+ "@svgr/webpack": "^8.1.0",
54
+ "@tailwindcss/postcss": "^4.1.18",
55
+ "@types/bun": "^1.3.6",
56
+ "@types/node": "^20.19.30",
57
+ "@types/react": "^19.2.9",
58
+ "@types/react-dom": "^19.2.3",
59
+ "@types/three": "^0.183.1",
60
+ "@typescript/native-preview": "^7.0.0-dev.20260122.3",
61
+ "babel-plugin-react-compiler": "1.0.0",
62
+ "cross-env": "^10.1.0",
63
+ "postcss-preset-env": "^10.6.1",
64
+ "tailwindcss": "^4.1.18",
65
+ "typescript": "^5.9.3"
66
+ },
67
+ "trustedDependencies": [
68
+ "@biomejs/biome",
69
+ "@tailwindcss/oxide",
70
+ "esbuild",
71
+ "sharp"
72
+ ]
73
+ }
@@ -0,0 +1,9 @@
1
+ # @basementstudio/shader-lab
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - b878ba0: Publish the first release of `@basementstudio/shader-lab`.
8
+
9
+ This package provides the Shader Lab runtime for rendering exported Shader Lab compositions in React apps.
@@ -0,0 +1,119 @@
1
+ # @basementstudio/shader-lab
2
+
3
+ <a href="https://basement.studio"><img alt="basement.studio logo" src="https://img.shields.io/badge/MADE%20BY%20basement.studio-000000.svg?style=for-the-badge&labelColor=000"></a>
4
+ <a href="https://www.npmjs.com/package/@basementstudio/shader-lab"><img alt="NPM version" src="https://img.shields.io/npm/v/%40basementstudio%2Fshader-lab.svg?style=for-the-badge&labelColor=000000"></a>
5
+ <a href="https://basement.studio"><img alt="Website" src="https://img.shields.io/badge/WEBSITE-basement.studio-a6d600.svg?style=for-the-badge&labelColor=000000"></a>
6
+
7
+ `@basementstudio/shader-lab` is a portable React runtime for rendering Shader Lab compositions exported from the editor.
8
+
9
+ ## Overview
10
+
11
+ - Render exported Shader Lab configs inside React apps
12
+ - Play Shader Lab timelines at runtime
13
+ - Support Shader Lab source and effect layers in a standalone runtime
14
+ - Use exported compositions without shipping the full editor
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @basementstudio/shader-lab three
20
+ ```
21
+
22
+ ```bash
23
+ bun add @basementstudio/shader-lab three
24
+ ```
25
+
26
+ ## Peer Dependencies
27
+
28
+ - `react`
29
+ - `react-dom`
30
+ - `three`
31
+
32
+ ## Usage
33
+
34
+ ```tsx
35
+ "use client"
36
+
37
+ import { ShaderLabComposition, type ShaderLabConfig } from "@basementstudio/shader-lab"
38
+
39
+ const config: ShaderLabConfig = {
40
+ composition: {
41
+ width: 1512,
42
+ height: 909,
43
+ },
44
+ layers: [],
45
+ timeline: {
46
+ duration: 6,
47
+ loop: true,
48
+ tracks: [],
49
+ },
50
+ }
51
+
52
+ export default function Example() {
53
+ return (
54
+ <div style={{ width: "100%", maxWidth: 1200 }}>
55
+ <ShaderLabComposition config={config} />
56
+ </div>
57
+ )
58
+ }
59
+ ```
60
+
61
+ Listen for runtime errors:
62
+
63
+ ```tsx
64
+ <ShaderLabComposition
65
+ config={config}
66
+ onRuntimeError={(message) => {
67
+ console.error(message)
68
+ }}
69
+ />
70
+ ```
71
+
72
+ ## Component API
73
+
74
+ ### `ShaderLabComposition`
75
+
76
+ | Prop | Description |
77
+ | --- | --- |
78
+ | `config` | Exported `ShaderLabConfig` object |
79
+ | `className` | Optional wrapper class name |
80
+ | `style` | Optional wrapper styles |
81
+ | `onRuntimeError` | Optional callback for initialization or asset-loading errors |
82
+
83
+ ## Exports
84
+
85
+ - `ShaderLabComposition`
86
+ - `createRuntimeClock`
87
+ - `advanceRuntimeClock`
88
+ - `buildRuntimeFrame`
89
+ - `evaluateTimelineForLayers`
90
+ - `resolveEvaluatedLayers`
91
+ - runtime config and timeline types
92
+
93
+ ## Notes
94
+
95
+ - `ShaderLabComposition` is a client component and should be used from a `"use client"` module
96
+ - The component fills the width of its container and preserves the exported composition aspect ratio
97
+ - WebGPU support is required in the browser
98
+ - Media source layers expect accessible asset URLs in `layer.asset.src`
99
+
100
+ ## Included Runtime Support
101
+
102
+ - Gradient
103
+ - Text
104
+ - Custom shader
105
+ - Image and video sources
106
+ - Live camera input
107
+ - ASCII
108
+ - Pattern
109
+ - Ink
110
+ - Halftone
111
+ - Dithering
112
+ - CRT
113
+ - Particle grid
114
+ - Pixel sorting
115
+
116
+ ## Links
117
+
118
+ - Website: [basement.studio](https://basement.studio/)
119
+ - npm: [@basementstudio/shader-lab](https://www.npmjs.com/package/@basementstudio/shader-lab)
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="64" y="28" width="8" height="64" transform="rotate(90 64 28)" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="64" y="20" width="24" height="64" transform="rotate(90 64 20)" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="64" y="12" width="40" height="64" transform="rotate(90 64 12)" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="64" y="4" width="56" height="64" transform="rotate(90 64 4)" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="64" y="12" width="40" height="64" transform="rotate(90 64 12)" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="64" y="20" width="24" height="64" transform="rotate(90 64 20)" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="7" width="2" height="16" fill="#696969"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="5" width="6" height="16" fill="#696969"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="3" width="10" height="16" fill="#696969"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="1" width="14" height="16" fill="#696969"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="31.5" y="31.5" width="1" height="1" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="28" y="28" width="8" height="8" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="28" y="16" width="8" height="32" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="28" y="16" width="8" height="32" fill="#D9D9D9"/>
3
+ <rect x="48" y="28" width="8" height="32" transform="rotate(90 48 28)" fill="#D9D9D9"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="16" y="16" width="32" height="32" fill="#D9D9D9"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="32" height="32" fill="#D9D9D9"/>
3
+ <rect x="32.373" y="32.3726" width="32" height="32" fill="#D9D9D9"/>
4
+ </svg>
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@basementstudio/shader-lab",
3
+ "version": "1.0.0",
4
+ "description": "Portable React runtime for Shader Lab exports.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/src/index.js",
8
+ "types": "./dist/src/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "assets"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/src/index.d.ts",
16
+ "default": "./dist/src/index.js"
17
+ }
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "typescript": "^5.9.3"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^19.0.0",
27
+ "react-dom": "^19.0.0",
28
+ "three": "^0.183.0"
29
+ },
30
+ "scripts": {
31
+ "build": "node ./scripts/prepare-dist.mjs && bun x tsc -p tsconfig.build.json && node ./scripts/fix-esm-specifiers.mjs",
32
+ "lint": "biome lint src --max-diagnostics=200",
33
+ "prepack": "bun run build",
34
+ "typecheck": "bun x tsc -p tsconfig.json --noEmit"
35
+ }
36
+ }
@@ -0,0 +1,57 @@
1
+ import { readdir, readFile, writeFile } from "node:fs/promises"
2
+
3
+ const DIST_DIR = new URL("../dist/", import.meta.url)
4
+
5
+ const JS_IMPORT_PATTERN =
6
+ /(from\s+["'])(\.\.?\/[^"']+)(["'])|(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g
7
+
8
+ async function collectJsFiles(directoryUrl) {
9
+ const entries = await readdir(directoryUrl, { withFileTypes: true })
10
+ const files = await Promise.all(
11
+ entries.map(async (entry) => {
12
+ const nextUrl = new URL(`${entry.name}${entry.isDirectory() ? "/" : ""}`, directoryUrl)
13
+
14
+ if (entry.isDirectory()) {
15
+ return collectJsFiles(nextUrl)
16
+ }
17
+
18
+ return entry.name.endsWith(".js") ? [nextUrl] : []
19
+ }),
20
+ )
21
+
22
+ return files.flat()
23
+ }
24
+
25
+ function withJsExtension(specifier) {
26
+ return /\.[cm]?js$|\.json$|\.node$/.test(specifier) ? specifier : `${specifier}.js`
27
+ }
28
+
29
+ function rewriteSpecifiers(source) {
30
+ return source.replace(
31
+ JS_IMPORT_PATTERN,
32
+ (match, fromPrefix, fromSpecifier, fromSuffix, importPrefix, importSpecifier, importSuffix) => {
33
+ if (fromSpecifier) {
34
+ return `${fromPrefix}${withJsExtension(fromSpecifier)}${fromSuffix}`
35
+ }
36
+
37
+ if (importSpecifier) {
38
+ return `${importPrefix}${withJsExtension(importSpecifier)}${importSuffix}`
39
+ }
40
+
41
+ return match
42
+ },
43
+ )
44
+ }
45
+
46
+ const files = await collectJsFiles(DIST_DIR)
47
+
48
+ await Promise.all(
49
+ files.map(async (fileUrl) => {
50
+ const source = await readFile(fileUrl, "utf8")
51
+ const rewritten = rewriteSpecifiers(source)
52
+
53
+ if (rewritten !== source) {
54
+ await writeFile(fileUrl, rewritten)
55
+ }
56
+ }),
57
+ )
@@ -0,0 +1,4 @@
1
+ import { rm } from "node:fs/promises"
2
+
3
+ await rm(new URL("../dist", import.meta.url), { force: true, recursive: true })
4
+ await rm(new URL("../tsconfig.build.tsbuildinfo", import.meta.url), { force: true })
@@ -0,0 +1,146 @@
1
+ declare module "three/tsl" {
2
+ export interface LoopConfig {
3
+ condition?: string
4
+ end: number
5
+ start: number
6
+ type: "float" | "int"
7
+ }
8
+
9
+ export type ShaderNodeParams = readonly [
10
+ TSLNode,
11
+ TSLNode,
12
+ TSLNode,
13
+ TSLNode,
14
+ TSLNode,
15
+ TSLNode?,
16
+ ...TSLNode[],
17
+ ]
18
+
19
+ export type ShaderNodeFn = (
20
+ params: ShaderNodeParams,
21
+ ...rest: unknown[]
22
+ ) => unknown
23
+
24
+ export interface TSLNode {
25
+ a: TSLNode
26
+ b: TSLNode
27
+ dot(value: unknown): TSLNode
28
+ g: TSLNode
29
+ r: TSLNode
30
+ rgb: TSLNode
31
+ value: unknown
32
+ w: TSLNode
33
+ x: TSLNode
34
+ xx: TSLNode
35
+ xy: TSLNode
36
+ xyz: TSLNode
37
+ xxxx: TSLNode
38
+ xxyy: TSLNode
39
+ xxx: TSLNode
40
+ xzx: TSLNode
41
+ xzyw: TSLNode
42
+ y: TSLNode
43
+ yyy: TSLNode
44
+ yyyy: TSLNode
45
+ yyz: TSLNode
46
+ yzx: TSLNode
47
+ yzw: TSLNode
48
+ z: TSLNode
49
+ zw: TSLNode
50
+ zww: TSLNode
51
+ zxy: TSLNode
52
+ zzww: TSLNode
53
+ www: TSLNode
54
+ wyz: TSLNode
55
+
56
+ add(value: unknown): TSLNode
57
+ addAssign(value: unknown): TSLNode
58
+ and(value: unknown): TSLNode
59
+ or(value: unknown): TSLNode
60
+ assign(value: unknown): TSLNode
61
+ clamp(min?: unknown, max?: unknown): TSLNode
62
+ div(value: unknown): TSLNode
63
+ equal(value: unknown): TSLNode
64
+ fract(): TSLNode
65
+ length(): TSLNode
66
+ greaterThan(value: unknown): TSLNode
67
+ greaterThanEqual(value: unknown): TSLNode
68
+ lessThan(value: unknown): TSLNode
69
+ lessThanEqual(value: unknown): TSLNode
70
+ mul(value: unknown): TSLNode
71
+ mulAssign(value: unknown): TSLNode
72
+ negate(): TSLNode
73
+ normalize(): TSLNode
74
+ sqrt(): TSLNode
75
+ sub(value: unknown): TSLNode
76
+ toVar(): TSLNode
77
+ }
78
+
79
+ export function attribute(name: string, type: string): TSLNode
80
+ export const pointUV: TSLNode
81
+ export const positionLocal: TSLNode
82
+
83
+ export const EPSILON: TSLNode
84
+ export const PI: TSLNode
85
+ export function abs(value: unknown): TSLNode
86
+ export function add(left: unknown, right: unknown): TSLNode
87
+ export function atan(value: unknown): TSLNode
88
+ export function clamp(value: unknown, min?: unknown, max?: unknown): TSLNode
89
+ export function cos(value: unknown): TSLNode
90
+ export function cross(left: unknown, right: unknown): TSLNode
91
+ export function div(left: unknown, right: unknown): TSLNode
92
+ export function dot(left: unknown, right: unknown): TSLNode
93
+ export function Fn(
94
+ fn: ShaderNodeFn,
95
+ layout?: unknown
96
+ ): (...args: unknown[]) => TSLNode
97
+ export function Loop(
98
+ config: LoopConfig,
99
+ callback: (...args: unknown[]) => unknown
100
+ ): TSLNode
101
+ export function exp(value: unknown): TSLNode
102
+ export function fract(value: unknown): TSLNode
103
+ export function float(value?: unknown): TSLNode
104
+ export function floor(value: unknown): TSLNode
105
+ export function mat2(
106
+ a?: unknown,
107
+ b?: unknown,
108
+ c?: unknown,
109
+ d?: unknown
110
+ ): TSLNode
111
+ export function length(value: unknown): TSLNode
112
+ export function log(value: unknown): TSLNode
113
+ export function max(left: unknown, right: unknown): TSLNode
114
+ export function min(left: unknown, right: unknown): TSLNode
115
+ export function mix(left: unknown, right: unknown, factor: unknown): TSLNode
116
+ export function mod(left: unknown, right: unknown): TSLNode
117
+ export function mul(left: unknown, right: unknown): TSLNode
118
+ export const screenSize: TSLNode
119
+ export function select(
120
+ condition: unknown,
121
+ whenTrue: unknown,
122
+ whenFalse: unknown
123
+ ): TSLNode
124
+ export function sin(value: unknown): TSLNode
125
+ export function sign(value: unknown): TSLNode
126
+ export function smoothstep(
127
+ edge0: unknown,
128
+ edge1: unknown,
129
+ x: unknown
130
+ ): TSLNode
131
+ export function sqrt(value: unknown): TSLNode
132
+ export function pow(base: unknown, exponent: unknown): TSLNode
133
+ export function step(edge: unknown, value: unknown): TSLNode
134
+ export function sub(left: unknown, right: unknown): TSLNode
135
+ export function texture(value: unknown, uv?: unknown): TSLNode
136
+ export function uniform(value?: unknown): TSLNode
137
+ export function uv(): TSLNode
138
+ export function vec2(x?: unknown, y?: unknown): TSLNode
139
+ export function vec3(x?: unknown, y?: unknown, z?: unknown): TSLNode
140
+ export function vec4(
141
+ x?: unknown,
142
+ y?: unknown,
143
+ z?: unknown,
144
+ w?: unknown
145
+ ): TSLNode
146
+ }