@react-three/tsl 10.0.0-canary.04087d8

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/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@react-three/tsl",
3
+ "version": "10.0.0-canary.04087d8",
4
+ "description": "TSL resource hooks for react-three-fiber: uniforms, nodes, buffers, GPU storage and render pipelines on WebGPU",
5
+ "keywords": [
6
+ "react",
7
+ "three",
8
+ "threejs",
9
+ "react-three-fiber",
10
+ "webgpu",
11
+ "tsl"
12
+ ],
13
+ "author": "Dennis Smolek (https://github.com/dennissmolek)",
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": "https://github.com/pmndrs/react-three-fiber/issues"
17
+ },
18
+ "homepage": "https://github.com/pmndrs/react-three-fiber/tree/v10/packages/tsl#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/pmndrs/react-three-fiber.git",
22
+ "directory": "packages/tsl"
23
+ },
24
+ "main": "./dist/index.cjs",
25
+ "module": "./dist/index.mjs",
26
+ "types": "./dist/index.d.ts",
27
+ "sideEffects": [
28
+ "./dist/index.mjs",
29
+ "./dist/index.cjs"
30
+ ],
31
+ "files": [
32
+ "dist",
33
+ "readme.md"
34
+ ],
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.mjs",
39
+ "require": "./dist/index.cjs"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "dequal": "^2.0.3",
48
+ "zustand": "^5.0.10"
49
+ },
50
+ "peerDependencies": {
51
+ "@react-three/fiber": "^10.0.0-alpha.6",
52
+ "react": ">=19.0 <19.4",
53
+ "three": ">=0.185.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/three": "^0.185.0",
57
+ "@webgpu/types": "^0.1.64",
58
+ "three": ">=0.185.0",
59
+ "@react-three/fiber": "10.0.0-canary.04087d8"
60
+ },
61
+ "scripts": {
62
+ "build": "unbuild",
63
+ "stub": "unbuild --stub"
64
+ }
65
+ }
package/readme.md ADDED
@@ -0,0 +1,53 @@
1
+ # @react-three/tsl
2
+
3
+ TSL resource hooks for [react-three-fiber](https://github.com/pmndrs/react-three-fiber) on WebGPU: shared uniforms, nodes, buffers, GPU storage and render pipelines.
4
+
5
+ ```bash
6
+ npm install @react-three/tsl
7
+ ```
8
+
9
+ ```tsx
10
+ import { Canvas, useFrame } from '@react-three/fiber'
11
+ import { useUniforms, useNodes } from '@react-three/tsl'
12
+ import { positionLocal, normalLocal, sin, time } from 'three/tsl'
13
+
14
+ function Wobble() {
15
+ const { uAmount } = useUniforms({ uAmount: 0.2 })
16
+ const { offset } = useNodes(() => ({ offset: normalLocal.mul(sin(time).mul(uAmount)) }))
17
+
18
+ return (
19
+ <mesh>
20
+ <sphereGeometry />
21
+ <meshStandardNodeMaterial positionNode={positionLocal.add(offset)} />
22
+ </mesh>
23
+ )
24
+ }
25
+
26
+ function Driver() {
27
+ // The resources are on RootState: frame state, useThree and creators all read them.
28
+ useFrame(({ uniforms, elapsed }) => {
29
+ uniforms.uAmount.value = Math.abs(Math.sin(elapsed))
30
+ })
31
+ return null
32
+ }
33
+
34
+ export const App = () => (
35
+ <Canvas renderer>
36
+ <Wobble />
37
+ <Driver />
38
+ </Canvas>
39
+ )
40
+ ```
41
+
42
+ | Export | What it does |
43
+ | ----------------------------- | ---------------------------------------------------------------------------- |
44
+ | `useUniforms`, `useUniform` | Create or read uniforms, shared across components, optionally scoped |
45
+ | `useNodes`, `useLocalNodes` | Share TSL nodes across components, or compose them locally |
46
+ | `useBuffers`, `useGPUStorage` | Buffers and storage textures for compute |
47
+ | `useRenderPipeline` | Post-processing with three's `RenderPipeline` (scene pass, MRT, output node) |
48
+
49
+ Resources belong to the renderer: a `<Canvas primary>`, the canvases sharing its renderer (every other WebGPU canvas, or `share="id"`) and every portal inside them share one set. They live on the primary canvas's `RootState` (`state.uniforms`, `state.nodes`, `state.buffers`, `state.gpuStorage`); secondaries hold the same objects and portals inherit them from their parent (a portal's scene and camera stay its own), so `state.uniforms` reads the same everywhere.
50
+
51
+ Works under any Canvas that runs the WebGPU renderer: `@react-three/fiber` with the `renderer` prop, or `@react-three/fiber/webgpu`. It reaches fiber only through the three-free `@react-three/fiber/extension` entry, so it adds no renderer and no second copy of fiber to your bundle.
52
+
53
+ Full documentation: [WebGPU & TSL](https://github.com/pmndrs/react-three-fiber/tree/v10/docs/webgpu).