@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.
- package/.biome/plugins/README.md +21 -0
- package/.biome/plugins/no-anchor-element.grit +12 -0
- package/.biome/plugins/no-relative-parent-imports.grit +10 -0
- package/.biome/plugins/no-unnecessary-forwardref.grit +9 -0
- package/.changeset/README.md +17 -0
- package/.changeset/config.json +11 -0
- package/.editorconfig +40 -0
- package/.env.example +81 -0
- package/.gitattributes +19 -0
- package/.github/workflows/canary.yml +80 -0
- package/.github/workflows/ci.yml +37 -0
- package/.github/workflows/release.yml +56 -0
- package/.tldrignore +84 -0
- package/.vscode/extensions.json +20 -0
- package/.vscode/settings.json +105 -0
- package/README.md +119 -0
- package/biome.json +249 -0
- package/bun.lock +1224 -0
- package/next.config.ts +131 -0
- package/package.json +73 -0
- package/packages/shader-lab-react/CHANGELOG.md +9 -0
- package/packages/shader-lab-react/README.md +119 -0
- package/packages/shader-lab-react/assets/patterns/bars/1.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/bars/2.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/bars/3.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/bars/4.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/bars/5.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/bars/6.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/candles/1.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/candles/2.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/candles/3.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/candles/4.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/shapes/1.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/shapes/2.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/shapes/3.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/shapes/4.svg +4 -0
- package/packages/shader-lab-react/assets/patterns/shapes/5.svg +3 -0
- package/packages/shader-lab-react/assets/patterns/shapes/6.svg +4 -0
- package/packages/shader-lab-react/assets/textures/blue-noise.png +0 -0
- package/packages/shader-lab-react/package.json +36 -0
- package/packages/shader-lab-react/scripts/fix-esm-specifiers.mjs +57 -0
- package/packages/shader-lab-react/scripts/prepare-dist.mjs +4 -0
- package/packages/shader-lab-react/src/ambient/three-tsl.d.ts +146 -0
- package/packages/shader-lab-react/src/ambient/three-webgpu.d.ts +51 -0
- package/packages/shader-lab-react/src/easings.ts +4 -0
- package/packages/shader-lab-react/src/index.ts +35 -0
- package/packages/shader-lab-react/src/lib/editor/custom-shader/shared.ts +2 -0
- package/packages/shader-lab-react/src/renderer/ascii-atlas.ts +83 -0
- package/packages/shader-lab-react/src/renderer/ascii-pass.ts +416 -0
- package/packages/shader-lab-react/src/renderer/asset-url.ts +3 -0
- package/packages/shader-lab-react/src/renderer/blend-modes.ts +229 -0
- package/packages/shader-lab-react/src/renderer/contracts.ts +54 -0
- package/packages/shader-lab-react/src/renderer/create-webgpu-renderer.ts +48 -0
- package/packages/shader-lab-react/src/renderer/crt-pass.ts +1040 -0
- package/packages/shader-lab-react/src/renderer/custom-shader-pass.ts +108 -0
- package/packages/shader-lab-react/src/renderer/custom-shader-runtime.ts +309 -0
- package/packages/shader-lab-react/src/renderer/dither-textures.ts +99 -0
- package/packages/shader-lab-react/src/renderer/dithering-pass.ts +322 -0
- package/packages/shader-lab-react/src/renderer/gradient-pass.ts +521 -0
- package/packages/shader-lab-react/src/renderer/halftone-pass.ts +932 -0
- package/packages/shader-lab-react/src/renderer/ink-pass.ts +802 -0
- package/packages/shader-lab-react/src/renderer/live-pass.ts +194 -0
- package/packages/shader-lab-react/src/renderer/media-pass.ts +187 -0
- package/packages/shader-lab-react/src/renderer/media-texture.ts +66 -0
- package/packages/shader-lab-react/src/renderer/particle-grid-pass.ts +389 -0
- package/packages/shader-lab-react/src/renderer/pass-node.ts +209 -0
- package/packages/shader-lab-react/src/renderer/pattern-atlas.ts +133 -0
- package/packages/shader-lab-react/src/renderer/pattern-pass.ts +552 -0
- package/packages/shader-lab-react/src/renderer/pipeline-manager.ts +369 -0
- package/packages/shader-lab-react/src/renderer/pixel-sorting-pass.ts +277 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/color/tonemapping.ts +87 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/cosine-palette.ts +9 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/common.ts +31 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/curl-noise-3d.ts +36 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/curl-noise-4d.ts +36 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/fbm.ts +13 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/perlin-noise-3d.ts +96 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/ridge-noise.ts +24 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/simplex-noise-3d.ts +79 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/simplex-noise-4d.ts +89 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/turbulence.ts +56 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/value-noise-3d.ts +32 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/noise/voronoi-noise-3d.ts +60 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/bloom-edge-pattern.ts +15 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/bloom.ts +11 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/canvas-weave-pattern.ts +24 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/grain-texture-pattern.ts +9 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/patterns/repeating-pattern.ts +11 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/atan2.ts +9 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-conj.ts +9 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-cos.ts +10 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-div.ts +11 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-log.ts +7 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-mobius.ts +12 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-mul.ts +9 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-pow.ts +16 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-sin.ts +10 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-sqrt.ts +18 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-tan.ts +12 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/complex-to-polar.ts +10 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/hyperbolic.ts +20 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/index.ts +48 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/rotate.ts +15 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/screen-aspect-uv.ts +15 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-box-2d.ts +6 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-diamond.ts +6 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-rhombus.ts +27 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/sd-sphere.ts +6 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/smax.ts +7 -0
- package/packages/shader-lab-react/src/renderer/shaders/tsl/utils/smin.ts +7 -0
- package/packages/shader-lab-react/src/renderer/text-pass.ts +176 -0
- package/packages/shader-lab-react/src/runtime-clock.ts +42 -0
- package/packages/shader-lab-react/src/runtime-frame.ts +29 -0
- package/packages/shader-lab-react/src/shader-lab-composition.tsx +163 -0
- package/packages/shader-lab-react/src/timeline.ts +283 -0
- package/packages/shader-lab-react/src/types/editor.ts +5 -0
- package/packages/shader-lab-react/src/types.ts +141 -0
- package/packages/shader-lab-react/tsconfig.build.json +8 -0
- package/packages/shader-lab-react/tsconfig.json +21 -0
- package/postcss.config.mjs +5 -0
- package/public/assets/fonts/msdf/geist-mono/GeistMono-Regular-msdf-atlas.png +0 -0
- package/public/assets/fonts/msdf/geist-mono/GeistMono-Regular-msdf.json +1412 -0
- package/public/assets/patterns/bars/1.svg +3 -0
- package/public/assets/patterns/bars/2.svg +3 -0
- package/public/assets/patterns/bars/3.svg +3 -0
- package/public/assets/patterns/bars/4.svg +3 -0
- package/public/assets/patterns/bars/5.svg +3 -0
- package/public/assets/patterns/bars/6.svg +3 -0
- package/public/assets/patterns/candles/1.svg +3 -0
- package/public/assets/patterns/candles/2.svg +3 -0
- package/public/assets/patterns/candles/3.svg +3 -0
- package/public/assets/patterns/candles/4.svg +3 -0
- package/public/assets/patterns/shapes/1.svg +3 -0
- package/public/assets/patterns/shapes/2.svg +3 -0
- package/public/assets/patterns/shapes/3.svg +3 -0
- package/public/assets/patterns/shapes/4.svg +4 -0
- package/public/assets/patterns/shapes/5.svg +3 -0
- package/public/assets/patterns/shapes/6.svg +4 -0
- package/public/fonts/geist/Geist-Mono.woff2 +0 -0
- package/public/textures/blue-noise.png +0 -0
- package/public/textures/crt-mask.png +0 -0
- package/src/app/design/page.tsx +398 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +280 -0
- package/src/app/layout.tsx +89 -0
- package/src/app/page.tsx +20 -0
- package/src/app/robots.ts +13 -0
- package/src/app/sitemap.ts +13 -0
- package/src/components/editor/editor-canvas-viewport.tsx +116 -0
- package/src/components/editor/editor-export-dialog.tsx +1177 -0
- package/src/components/editor/editor-timeline-overlay.tsx +983 -0
- package/src/components/editor/editor-topbar.tsx +287 -0
- package/src/components/editor/layer-sidebar.tsx +738 -0
- package/src/components/editor/properties-sidebar-content.tsx +574 -0
- package/src/components/editor/properties-sidebar-fields.tsx +389 -0
- package/src/components/editor/properties-sidebar-utils.ts +178 -0
- package/src/components/editor/properties-sidebar.tsx +421 -0
- package/src/components/ui/button/index.tsx +57 -0
- package/src/components/ui/color-picker/index.tsx +358 -0
- package/src/components/ui/glass-panel/index.tsx +45 -0
- package/src/components/ui/icon-button/index.tsx +46 -0
- package/src/components/ui/select/index.tsx +136 -0
- package/src/components/ui/slider/index.tsx +192 -0
- package/src/components/ui/toggle/index.tsx +34 -0
- package/src/components/ui/typography/index.tsx +61 -0
- package/src/components/ui/xy-pad/index.tsx +160 -0
- package/src/features/editor/components/editor-export-dialog.module.css +271 -0
- package/src/hooks/use-editor-renderer.ts +182 -0
- package/src/lib/app.ts +6 -0
- package/src/lib/cn.ts +7 -0
- package/src/lib/easings.ts +240 -0
- package/src/lib/editor/config/layer-registry.ts +2434 -0
- package/src/lib/editor/custom-shader/shared.ts +28 -0
- package/src/lib/editor/export.ts +420 -0
- package/src/lib/editor/history.ts +71 -0
- package/src/lib/editor/layers.ts +76 -0
- package/src/lib/editor/parameter-schema.ts +75 -0
- package/src/lib/editor/project-file.ts +145 -0
- package/src/lib/editor/shader-export-snippet.ts +37 -0
- package/src/lib/editor/shader-export.ts +315 -0
- package/src/lib/editor/timeline/evaluate.ts +252 -0
- package/src/lib/editor/view-transform.ts +58 -0
- package/src/lib/fonts.ts +28 -0
- package/src/renderer/ascii-atlas.ts +83 -0
- package/src/renderer/ascii-pass.ts +416 -0
- package/src/renderer/blend-modes.ts +229 -0
- package/src/renderer/contracts.ts +161 -0
- package/src/renderer/create-webgpu-renderer.ts +48 -0
- package/src/renderer/crt-pass.ts +1040 -0
- package/src/renderer/custom-shader-pass.ts +117 -0
- package/src/renderer/custom-shader-runtime.ts +309 -0
- package/src/renderer/dither-textures.ts +99 -0
- package/src/renderer/dithering-pass.ts +322 -0
- package/src/renderer/gradient-pass.ts +520 -0
- package/src/renderer/halftone-pass.ts +932 -0
- package/src/renderer/ink-pass.ts +683 -0
- package/src/renderer/live-pass.ts +194 -0
- package/src/renderer/media-pass.ts +187 -0
- package/src/renderer/media-texture.ts +66 -0
- package/src/renderer/particle-grid-pass.ts +389 -0
- package/src/renderer/pass-node-factory.ts +33 -0
- package/src/renderer/pass-node.ts +209 -0
- package/src/renderer/pattern-atlas.ts +97 -0
- package/src/renderer/pattern-pass.ts +552 -0
- package/src/renderer/pipeline-manager.ts +343 -0
- package/src/renderer/pixel-sorting-pass.ts +277 -0
- package/src/renderer/project-clock.ts +57 -0
- package/src/renderer/shaders/tsl/color/tonemapping.ts +86 -0
- package/src/renderer/shaders/tsl/cosine-palette.ts +8 -0
- package/src/renderer/shaders/tsl/noise/common.ts +30 -0
- package/src/renderer/shaders/tsl/noise/curl-noise-3d.ts +35 -0
- package/src/renderer/shaders/tsl/noise/curl-noise-4d.ts +35 -0
- package/src/renderer/shaders/tsl/noise/fbm.ts +12 -0
- package/src/renderer/shaders/tsl/noise/perlin-noise-3d.ts +97 -0
- package/src/renderer/shaders/tsl/noise/ridge-noise.ts +23 -0
- package/src/renderer/shaders/tsl/noise/simplex-noise-3d.ts +78 -0
- package/src/renderer/shaders/tsl/noise/simplex-noise-4d.ts +88 -0
- package/src/renderer/shaders/tsl/noise/turbulence.ts +55 -0
- package/src/renderer/shaders/tsl/noise/value-noise-3d.ts +31 -0
- package/src/renderer/shaders/tsl/noise/voronoi-noise-3d.ts +59 -0
- package/src/renderer/shaders/tsl/patterns/bloom-edge-pattern.ts +14 -0
- package/src/renderer/shaders/tsl/patterns/bloom.ts +10 -0
- package/src/renderer/shaders/tsl/patterns/canvas-weave-pattern.ts +23 -0
- package/src/renderer/shaders/tsl/patterns/grain-texture-pattern.ts +8 -0
- package/src/renderer/shaders/tsl/patterns/repeating-pattern.ts +10 -0
- package/src/renderer/shaders/tsl/utils/atan2.ts +8 -0
- package/src/renderer/shaders/tsl/utils/complex-conj.ts +8 -0
- package/src/renderer/shaders/tsl/utils/complex-cos.ts +9 -0
- package/src/renderer/shaders/tsl/utils/complex-div.ts +10 -0
- package/src/renderer/shaders/tsl/utils/complex-log.ts +6 -0
- package/src/renderer/shaders/tsl/utils/complex-mobius.ts +11 -0
- package/src/renderer/shaders/tsl/utils/complex-mul.ts +8 -0
- package/src/renderer/shaders/tsl/utils/complex-pow.ts +15 -0
- package/src/renderer/shaders/tsl/utils/complex-sin.ts +9 -0
- package/src/renderer/shaders/tsl/utils/complex-sqrt.ts +17 -0
- package/src/renderer/shaders/tsl/utils/complex-tan.ts +11 -0
- package/src/renderer/shaders/tsl/utils/complex-to-polar.ts +9 -0
- package/src/renderer/shaders/tsl/utils/hyperbolic.ts +19 -0
- package/src/renderer/shaders/tsl/utils/index.ts +47 -0
- package/src/renderer/shaders/tsl/utils/rotate.ts +14 -0
- package/src/renderer/shaders/tsl/utils/screen-aspect-uv.ts +14 -0
- package/src/renderer/shaders/tsl/utils/sd-box-2d.ts +5 -0
- package/src/renderer/shaders/tsl/utils/sd-diamond.ts +5 -0
- package/src/renderer/shaders/tsl/utils/sd-rhombus.ts +26 -0
- package/src/renderer/shaders/tsl/utils/sd-sphere.ts +5 -0
- package/src/renderer/shaders/tsl/utils/smax.ts +7 -0
- package/src/renderer/shaders/tsl/utils/smin.ts +6 -0
- package/src/renderer/text-pass.ts +176 -0
- package/src/store/asset-store.ts +193 -0
- package/src/store/editor-store.ts +223 -0
- package/src/store/history-store.ts +172 -0
- package/src/store/index.ts +31 -0
- package/src/store/layer-store.ts +675 -0
- package/src/store/timeline-store.ts +572 -0
- package/src/types/assets.d.ts +6 -0
- package/src/types/css.d.ts +21 -0
- package/src/types/editor.ts +357 -0
- package/src/types/react.d.ts +15 -0
- package/src/types/three-tsl.d.ts +146 -0
- package/src/types/three-webgpu.d.ts +51 -0
- 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,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)
|
|
Binary file
|
|
@@ -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,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
|
+
}
|