@fjandin/react-shader 0.0.18 → 0.0.20
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/README.md +248 -22
- package/dist/ReactGpuShader.d.ts +3 -4
- package/dist/ReactGpuShader.d.ts.map +1 -1
- package/dist/hooks/useWebGPU.d.ts +2 -2
- package/dist/hooks/useWebGPU.d.ts.map +1 -1
- package/dist/index.cjs +193 -145
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +193 -145
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @fjandin/react-shader
|
|
2
2
|
|
|
3
|
-
A React component for rendering WebGL
|
|
3
|
+
A React component library for rendering WebGL and WebGPU shaders. Provides `<ReactShader>` for GLSL (Shadertoy-style) and `<ReactGpuShader>` for WGSL (WebGPU) with automatic uniform handling, texture support, storage buffers, and audio reactivity.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -12,7 +12,11 @@ yarn add @fjandin/react-shader
|
|
|
12
12
|
bun add @fjandin/react-shader
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Components
|
|
16
|
+
|
|
17
|
+
### `<ReactShader>` (WebGL)
|
|
18
|
+
|
|
19
|
+
Renders GLSL fragment shaders. Uses WebGL2 with WebGL1 fallback.
|
|
16
20
|
|
|
17
21
|
```tsx
|
|
18
22
|
import { ReactShader } from "@fjandin/react-shader"
|
|
@@ -41,8 +45,35 @@ function App() {
|
|
|
41
45
|
}
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
### `<ReactGpuShader>` (WebGPU)
|
|
49
|
+
|
|
50
|
+
Renders WGSL fragment shaders using WebGPU. Supports storage buffers for large array data.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { ReactGpuShader } from "@fjandin/react-shader"
|
|
54
|
+
|
|
55
|
+
const fragment = /*wgsl*/ `
|
|
56
|
+
fn mainImage(uv: vec2f) -> vec4f {
|
|
57
|
+
let color = 0.5 + 0.5 * cos(uniforms.iTime + vec3f(uv, 0.0) + vec3f(0.0, 2.0, 4.0));
|
|
58
|
+
return vec4f(color, 1.0);
|
|
59
|
+
}
|
|
60
|
+
`
|
|
61
|
+
|
|
62
|
+
function App() {
|
|
63
|
+
return (
|
|
64
|
+
<div style={{ width: "800px", height: "600px" }}>
|
|
65
|
+
<ReactGpuShader fragment={fragment} />
|
|
66
|
+
</div>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
WebGPU shaders define a `mainImage(uv: vec2f) -> vec4f` function. Built-in uniforms are accessed via `uniforms.iTime`, `uniforms.iResolution`, etc. The component automatically generates the uniform struct and wrapping `@fragment` entry point.
|
|
72
|
+
|
|
44
73
|
## Props
|
|
45
74
|
|
|
75
|
+
### ReactShader
|
|
76
|
+
|
|
46
77
|
| Prop | Type | Required | Default | Description |
|
|
47
78
|
|------|------|----------|---------|-------------|
|
|
48
79
|
| `fragment` | `string` | Yes | - | GLSL fragment shader source code |
|
|
@@ -54,22 +85,44 @@ function App() {
|
|
|
54
85
|
| `onFrame` | `(info: FrameInfo) => void` | No | - | Callback invoked on each frame |
|
|
55
86
|
| `onClick` | `(info: FrameInfo) => void` | No | - | Callback invoked on canvas click |
|
|
56
87
|
| `onMouseMove` | `(info: FrameInfo) => void` | No | - | Callback invoked on mouse move |
|
|
88
|
+
| `onMouseDown` | `(info: FrameInfo) => void` | No | - | Callback invoked on mouse button press |
|
|
89
|
+
| `onMouseUp` | `(info: FrameInfo) => void` | No | - | Callback invoked on mouse button release |
|
|
90
|
+
| `onMouseWheel` | `(info: FrameInfo, wheelDelta: number) => void` | No | - | Callback invoked on mouse wheel scroll |
|
|
91
|
+
|
|
92
|
+
### ReactGpuShader
|
|
93
|
+
|
|
94
|
+
| Prop | Type | Required | Default | Description |
|
|
95
|
+
|------|------|----------|---------|-------------|
|
|
96
|
+
| `fragment` | `string` | Yes | - | WGSL fragment shader source code |
|
|
97
|
+
| `uniforms` | `Record<string, GpuUniformValue>` | No | `{}` | Custom uniform values (`number`, `Vec2`, `Vec3`, `Vec4`) |
|
|
98
|
+
| `storageBuffers` | `Record<string, Vec4Array>` | No | - | Named storage buffers of `Vec4` arrays |
|
|
99
|
+
| `className` | `string` | No | - | CSS class name for the canvas |
|
|
100
|
+
| `fullscreen` | `boolean` | No | `false` | Render as fixed fullscreen overlay |
|
|
101
|
+
| `timeScale` | `number` | No | `1` | Scale factor for elapsed time |
|
|
102
|
+
| `onFrame` | `(info: FrameInfo) => void` | No | - | Callback invoked on each frame |
|
|
103
|
+
| `onClick` | `(info: FrameInfo) => void` | No | - | Callback invoked on canvas click |
|
|
104
|
+
| `onMouseMove` | `(info: FrameInfo) => void` | No | - | Callback invoked on mouse move |
|
|
105
|
+
| `onMouseDown` | `(info: FrameInfo) => void` | No | - | Callback invoked on mouse button press |
|
|
106
|
+
| `onMouseUp` | `(info: FrameInfo) => void` | No | - | Callback invoked on mouse button release |
|
|
107
|
+
| `onMouseWheel` | `(info: FrameInfo, wheelDelta: number) => void` | No | - | Callback invoked on mouse wheel scroll |
|
|
57
108
|
|
|
58
109
|
## Built-in Uniforms
|
|
59
110
|
|
|
60
111
|
These uniforms are automatically provided to your shader every frame:
|
|
61
112
|
|
|
62
|
-
| Uniform | GLSL Type | Description |
|
|
63
|
-
|
|
64
|
-
| `iTime` | `float` | Elapsed time in seconds (scaled by `timeScale`
|
|
65
|
-
| `iMouse` | `vec2` | Mouse position in pixels (Y=0 at bottom) |
|
|
66
|
-
| `iMouseNormalized` | `vec2` | Mouse position normalized with aspect correction (shorter axis -0.5 to 0.5, center is 0,0) |
|
|
67
|
-
| `iMouseLeftDown` | `float` | `1.0` when left mouse button is pressed, `0.0` otherwise |
|
|
68
|
-
| `iResolution` | `vec2` | Canvas resolution in pixels (includes high-DPI scaling) |
|
|
113
|
+
| Uniform | GLSL Type | WGSL Type | Description |
|
|
114
|
+
|---------|-----------|-----------|-------------|
|
|
115
|
+
| `iTime` | `float` | `f32` | Elapsed time in seconds (scaled by `timeScale`) |
|
|
116
|
+
| `iMouse` | `vec2` | `vec2f` | Mouse position in pixels (Y=0 at bottom) |
|
|
117
|
+
| `iMouseNormalized` | `vec2` | `vec2f` | Mouse position normalized with aspect correction (shorter axis -0.5 to 0.5, center is 0,0) |
|
|
118
|
+
| `iMouseLeftDown` | `float` | `f32` | `1.0` when left mouse button is pressed, `0.0` otherwise |
|
|
119
|
+
| `iResolution` | `vec2` | `vec2f` | Canvas resolution in pixels (includes high-DPI scaling) |
|
|
69
120
|
|
|
70
121
|
## Custom Uniforms
|
|
71
122
|
|
|
72
|
-
|
|
123
|
+
### WebGL (ReactShader)
|
|
124
|
+
|
|
125
|
+
Pass custom uniform values via the `uniforms` prop. Supports scalars, vectors, arrays, and textures:
|
|
73
126
|
|
|
74
127
|
```tsx
|
|
75
128
|
<ReactShader
|
|
@@ -96,8 +149,28 @@ Supported types:
|
|
|
96
149
|
- `[number, number][]` → `vec2[N]`
|
|
97
150
|
- `[number, number, number][]` → `vec3[N]`
|
|
98
151
|
- `[number, number, number, number][]` → `vec4[N]`
|
|
152
|
+
- `HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap | ImageData | OffscreenCanvas` → `sampler2D` (texture)
|
|
153
|
+
- `TextureOptions` object → `sampler2D` with wrap/filter configuration
|
|
99
154
|
|
|
100
|
-
###
|
|
155
|
+
### WebGPU (ReactGpuShader)
|
|
156
|
+
|
|
157
|
+
Custom uniforms support scalar and vector types:
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<ReactGpuShader
|
|
161
|
+
fragment={fragment}
|
|
162
|
+
uniforms={{
|
|
163
|
+
scale: 2.0, // f32
|
|
164
|
+
offset: [0.5, 0.5], // vec2f
|
|
165
|
+
color: [1.0, 0.5, 0.2], // vec3f
|
|
166
|
+
transform: [1, 0, 0, 1], // vec4f
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Custom uniforms are accessed via `uniforms.scale`, `uniforms.color`, etc. in your WGSL code.
|
|
172
|
+
|
|
173
|
+
## Array Count Uniforms (WebGL)
|
|
101
174
|
|
|
102
175
|
For array uniforms, an additional `_count` uniform is automatically created and set:
|
|
103
176
|
|
|
@@ -113,7 +186,59 @@ for (int i = 0; i < points_count; i++) {
|
|
|
113
186
|
}
|
|
114
187
|
```
|
|
115
188
|
|
|
116
|
-
##
|
|
189
|
+
## Storage Buffers (WebGPU)
|
|
190
|
+
|
|
191
|
+
For large dynamic array data, `ReactGpuShader` supports storage buffers. These are more efficient than uniforms for large datasets and support dynamic resizing:
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
const [particles, setParticles] = useState<Vec4Array>([
|
|
195
|
+
[0, 0, 0.5, 1],
|
|
196
|
+
[1, 1, 0.3, 0.8],
|
|
197
|
+
])
|
|
198
|
+
|
|
199
|
+
<ReactGpuShader
|
|
200
|
+
fragment={fragment}
|
|
201
|
+
storageBuffers={{ particles }}
|
|
202
|
+
/>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
In WGSL, storage buffers are declared as `array<vec4f>` and accessed by name:
|
|
206
|
+
|
|
207
|
+
```wgsl
|
|
208
|
+
fn mainImage(uv: vec2f) -> vec4f {
|
|
209
|
+
for (var i: u32 = 0; i < arrayLength(&particles); i++) {
|
|
210
|
+
let p = particles[i];
|
|
211
|
+
// Use p.xy as position, p.z as radius, p.w as intensity...
|
|
212
|
+
}
|
|
213
|
+
return vec4f(0.0);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Storage buffers use over-allocation (1.5x growth) to minimize GPU buffer rebuilds when array sizes change frequently.
|
|
218
|
+
|
|
219
|
+
## Texture Uniforms (WebGL)
|
|
220
|
+
|
|
221
|
+
Pass images, canvases, or video elements as texture uniforms:
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
<ReactShader
|
|
225
|
+
fragment={fragment}
|
|
226
|
+
uniforms={{
|
|
227
|
+
myTexture: imageElement,
|
|
228
|
+
// or with options:
|
|
229
|
+
myTexture: {
|
|
230
|
+
source: imageElement,
|
|
231
|
+
wrapS: "repeat", // "repeat" | "clamp" | "mirror"
|
|
232
|
+
wrapT: "repeat",
|
|
233
|
+
minFilter: "linear", // "nearest" | "linear" | "mipmap"
|
|
234
|
+
magFilter: "linear", // "nearest" | "linear"
|
|
235
|
+
flipY: true,
|
|
236
|
+
},
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Automatic Uniform Injection (WebGL)
|
|
117
242
|
|
|
118
243
|
Instead of manually declaring uniforms in your shader, you can use the `// @UNIFORM_VALUES` marker to automatically inject all uniform declarations:
|
|
119
244
|
|
|
@@ -138,15 +263,99 @@ void main() {
|
|
|
138
263
|
/>
|
|
139
264
|
```
|
|
140
265
|
|
|
141
|
-
The marker gets replaced with declarations for both built-in uniforms (`iTime`, `iMouse`, `iMouseNormalized`, `iMouseLeftDown`, `iResolution`) and your custom uniforms
|
|
266
|
+
The marker gets replaced with declarations for both built-in uniforms (`iTime`, `iMouse`, `iMouseNormalized`, `iMouseLeftDown`, `iResolution`) and your custom uniforms.
|
|
142
267
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
268
|
+
## Audio Reactivity
|
|
269
|
+
|
|
270
|
+
The `useAudio` hook provides real-time audio analysis for audio-reactive shaders:
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
import { ReactShader, useAudio } from "@fjandin/react-shader"
|
|
274
|
+
|
|
275
|
+
function AudioVisualizer() {
|
|
276
|
+
const audio = useAudio({
|
|
277
|
+
source: "microphone", // "microphone" | "element" | "display"
|
|
278
|
+
smoothing: 0.9, // 0-1, lerp factor between frames
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<>
|
|
283
|
+
<button onClick={() => audio.isRunning ? audio.stop() : audio.start()}>
|
|
284
|
+
{audio.isRunning ? "Stop" : "Start"}
|
|
285
|
+
</button>
|
|
286
|
+
<ReactShader
|
|
287
|
+
fragment={fragment}
|
|
288
|
+
uniforms={{
|
|
289
|
+
audioLow: audio.levels.low,
|
|
290
|
+
audioMid: audio.levels.mid,
|
|
291
|
+
audioHigh: audio.levels.high,
|
|
292
|
+
}}
|
|
293
|
+
/>
|
|
294
|
+
</>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
`useAudio` options:
|
|
300
|
+
|
|
301
|
+
| Option | Type | Default | Description |
|
|
302
|
+
|--------|------|---------|-------------|
|
|
303
|
+
| `source` | `"microphone" \| "element" \| "display"` | `"microphone"` | Audio input source |
|
|
304
|
+
| `mediaElement` | `HTMLAudioElement \| HTMLVideoElement` | - | Media element (when `source` is `"element"`) |
|
|
305
|
+
| `fftSize` | `number` | `2048` | FFT size for frequency analysis |
|
|
306
|
+
| `smoothingTimeConstant` | `number` | `0.8` | AnalyserNode smoothing |
|
|
307
|
+
| `smoothing` | `number` | `0.9` | Frame-to-frame lerp factor (0 = instant, 0.9 = very smooth) |
|
|
308
|
+
|
|
309
|
+
`useAudio` return value:
|
|
310
|
+
|
|
311
|
+
| Field | Type | Description |
|
|
312
|
+
|-------|------|-------------|
|
|
313
|
+
| `levels` | `AudioLevels` | `{ low, mid, high, bands }` - normalized 0-1 frequency levels |
|
|
314
|
+
| `frequencyData` | `Uint8Array \| null` | Raw frequency data |
|
|
315
|
+
| `state` | `AudioConnectionState` | `"disconnected" \| "connecting" \| "connected" \| "error"` |
|
|
316
|
+
| `error` | `Error \| null` | Connection error if any |
|
|
317
|
+
| `start` | `() => Promise<void>` | Start audio capture |
|
|
318
|
+
| `stop` | `() => void` | Stop audio capture |
|
|
319
|
+
| `isRunning` | `boolean` | Whether audio is currently capturing |
|
|
320
|
+
|
|
321
|
+
## Shader Helper Functions
|
|
322
|
+
|
|
323
|
+
Pre-built shader functions are available for both GLSL and WGSL:
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
import {
|
|
327
|
+
// GLSL (WebGL)
|
|
328
|
+
generateSimplexNoiseFunction,
|
|
329
|
+
generateColorPaletteFunction,
|
|
330
|
+
generateDistortionRippleFunction,
|
|
331
|
+
generateSceneCirclesFunction,
|
|
332
|
+
generateUtilsFunction,
|
|
333
|
+
// WGSL (WebGPU)
|
|
334
|
+
generateSimplexNoiseFunctionGpu,
|
|
335
|
+
generateColorPaletteFunctionGpu,
|
|
336
|
+
generateDistortionRippleFunctionGpu,
|
|
337
|
+
generateSceneCirclesFunctionGpu,
|
|
338
|
+
} from "@fjandin/react-shader"
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Inject them into your shader source:
|
|
342
|
+
|
|
343
|
+
```tsx
|
|
344
|
+
// GLSL
|
|
345
|
+
const fragment = `#version 300 es
|
|
346
|
+
precision highp float;
|
|
347
|
+
${generateSimplexNoiseFunction()}
|
|
348
|
+
// Use SimplexNoise3D(vec3 v) in your shader...
|
|
349
|
+
`
|
|
350
|
+
|
|
351
|
+
// WGSL
|
|
352
|
+
const fragment = /*wgsl*/ `
|
|
353
|
+
${generateSimplexNoiseFunctionGpu()}
|
|
354
|
+
fn mainImage(uv: vec2f) -> vec4f {
|
|
355
|
+
let n = SimplexNoise3D(vec3f(uv, uniforms.iTime));
|
|
356
|
+
return vec4f(vec3f(n), 1.0);
|
|
357
|
+
}
|
|
358
|
+
`
|
|
150
359
|
```
|
|
151
360
|
|
|
152
361
|
## Frame Callback
|
|
@@ -191,9 +400,21 @@ import type {
|
|
|
191
400
|
Vec3Array,
|
|
192
401
|
Vec4Array,
|
|
193
402
|
UniformValue,
|
|
403
|
+
GpuStorageBuffers,
|
|
194
404
|
DefaultUniforms,
|
|
195
405
|
FrameInfo,
|
|
196
406
|
ReactShaderProps,
|
|
407
|
+
ReactGpuShaderProps,
|
|
408
|
+
TextureSource,
|
|
409
|
+
TextureOptions,
|
|
410
|
+
TextureWrap,
|
|
411
|
+
TextureMinFilter,
|
|
412
|
+
TextureMagFilter,
|
|
413
|
+
AudioLevels,
|
|
414
|
+
AudioConnectionState,
|
|
415
|
+
AudioSourceType,
|
|
416
|
+
UseAudioOptions,
|
|
417
|
+
UseAudioReturn,
|
|
197
418
|
} from "@fjandin/react-shader"
|
|
198
419
|
```
|
|
199
420
|
|
|
@@ -214,12 +435,17 @@ const declarations = generateUniformDeclarations({
|
|
|
214
435
|
|
|
215
436
|
## Features
|
|
216
437
|
|
|
217
|
-
- WebGL2 with WebGL1 fallback
|
|
438
|
+
- WebGL2 with WebGL1 fallback (`ReactShader`)
|
|
439
|
+
- WebGPU support with WGSL shaders (`ReactGpuShader`)
|
|
440
|
+
- Storage buffers for large dynamic arrays (WebGPU)
|
|
441
|
+
- Texture uniforms with configurable wrap/filter modes (WebGL)
|
|
442
|
+
- Audio reactivity via `useAudio` hook
|
|
443
|
+
- Pre-built shader functions (simplex noise, color palettes, distortion ripples, circles)
|
|
218
444
|
- High-DPI display support with automatic DPR change detection
|
|
219
445
|
- Automatic canvas resizing
|
|
220
446
|
- Shader compilation error display
|
|
221
447
|
- Context loss/restoration handling
|
|
222
|
-
- Mouse tracking with WebGL coordinate convention
|
|
448
|
+
- Mouse tracking with WebGL/WebGPU coordinate convention
|
|
223
449
|
- Optimized render loop with minimal per-frame allocations
|
|
224
450
|
|
|
225
451
|
## Requirements
|
package/dist/ReactGpuShader.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { FrameInfo,
|
|
2
|
-
type GpuUniformValue = number | Vec2 | Vec3 | Vec4 | Vec4Array;
|
|
1
|
+
import type { FrameInfo, GpuUniformValue, Vec4Array } from "./types";
|
|
3
2
|
export interface ReactGpuShaderProps {
|
|
4
3
|
className?: string;
|
|
5
4
|
fragment: string;
|
|
6
5
|
uniforms?: Record<string, GpuUniformValue>;
|
|
6
|
+
storageBuffers?: Record<string, Vec4Array>;
|
|
7
7
|
fullscreen?: boolean;
|
|
8
8
|
timeScale?: number;
|
|
9
9
|
onFrame?: (info: FrameInfo) => void;
|
|
@@ -13,6 +13,5 @@ export interface ReactGpuShaderProps {
|
|
|
13
13
|
onMouseUp?: (info: FrameInfo) => void;
|
|
14
14
|
onMouseWheel?: (info: FrameInfo, wheelDelta: number) => void;
|
|
15
15
|
}
|
|
16
|
-
export declare function ReactGpuShader({ className, fragment, uniforms, fullscreen, timeScale, onFrame, onClick, onMouseMove, onMouseDown, onMouseUp, onMouseWheel, }: ReactGpuShaderProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
|
16
|
+
export declare function ReactGpuShader({ className, fragment, uniforms, storageBuffers, fullscreen, timeScale, onFrame, onClick, onMouseMove, onMouseDown, onMouseUp, onMouseWheel, }: ReactGpuShaderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
17
|
//# sourceMappingURL=ReactGpuShader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactGpuShader.d.ts","sourceRoot":"","sources":["../src/ReactGpuShader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"ReactGpuShader.d.ts","sourceRoot":"","sources":["../src/ReactGpuShader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEpE,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACnC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACvC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACvC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACrC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7D;AAuBD,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,UAAkB,EAClB,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,GACb,EAAE,mBAAmB,2CA0DrB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FrameInfo,
|
|
2
|
-
type GpuUniformValue = number | Vec2 | Vec3 | Vec4 | Vec4Array;
|
|
1
|
+
import type { FrameInfo, GpuUniformValue, Vec4Array } from "../types";
|
|
3
2
|
interface UseWebGPUOptions {
|
|
4
3
|
fragment: string;
|
|
5
4
|
uniforms?: Record<string, GpuUniformValue>;
|
|
5
|
+
storageBuffers?: Record<string, Vec4Array>;
|
|
6
6
|
onError?: (error: Error) => void;
|
|
7
7
|
timeScale?: number;
|
|
8
8
|
onFrame?: (info: FrameInfo) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebGPU.d.ts","sourceRoot":"","sources":["../../src/hooks/useWebGPU.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"useWebGPU.d.ts","sourceRoot":"","sources":["../../src/hooks/useWebGPU.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAoB,SAAS,EAAE,MAAM,UAAU,CAAA;AAEvF,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACnC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACvC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACvC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACrC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7D;AAgYD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB;;;EA8SlD"}
|