Skip to content

Commit dd3cf03

Browse files
author
takuma-hmng8
committed
fix README , v1.0.13
1 parent fa8190c commit dd3cf03

File tree

11 files changed

+120
-30
lines changed

11 files changed

+120
-30
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,56 @@ useFrame((props) => {
3333
});
3434
```
3535

36+
## The simplest example
37+
38+
This is the simplest example!
39+
40+
```tsx
41+
import * as THREE from "three";
42+
import { useRef } from "react";
43+
import { useFrame, useThree } from "@react-three/fiber";
44+
import { useFruid } from "@hmng8/use-shader-fx";
45+
46+
export const Demo = () => {
47+
const ref = useRef<THREE.ShaderMaterial>(null);
48+
const size = useThree((state) => state.size);
49+
const dpr = useThree((state) => state.viewport.dpr);
50+
const [updateFruid] = useFruid({ size, dpr });
51+
useFrame((props) => {
52+
ref.current!.uniforms.u_fx.value = updateFruid(props);
53+
});
54+
55+
return (
56+
<mesh>
57+
<planeGeometry args={[2, 2]} />
58+
<shaderMaterial
59+
ref={ref}
60+
vertexShader={`
61+
varying vec2 vUv;
62+
void main() {
63+
vUv = uv;
64+
gl_Position = vec4(position, 1.0);
65+
}
66+
`}
67+
fragmentShader={`
68+
precision highp float;
69+
varying vec2 vUv;
70+
uniform sampler2D u_fx;
71+
72+
void main() {
73+
vec2 uv = vUv;
74+
gl_FragColor = texture2D(u_fx, uv);
75+
}
76+
`}
77+
uniforms={{
78+
u_fx: { value: null },
79+
}}
80+
/>
81+
</mesh>
82+
);
83+
};
84+
```
85+
3686
# Performance
3787

3888
You can control the `dpr` using the `PerformanceMonitor` from [drei](https://github.com/pmndrs/drei). For more details, please refer to the [scaling-performance](https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance) of r3f.

app/_demo/index.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,51 @@ export const Demo = () => {
9999
</mesh>
100100
);
101101
};
102+
103+
/*===============================================
104+
the simplest demo
105+
===============================================*/
106+
107+
// import * as THREE from "three";
108+
// import { useRef } from "react";
109+
// import { useFrame, useThree } from "@react-three/fiber";
110+
// import { useFruid } from "@hmng8/use-shader-fx";
111+
112+
// export const Demo = () => {
113+
// const ref = useRef<THREE.ShaderMaterial>(null);
114+
// const size = useThree((state) => state.size);
115+
// const dpr = useThree((state) => state.viewport.dpr);
116+
// const [updateFruid] = useFruid({ size, dpr });
117+
// useFrame((props) => {
118+
// ref.current!.uniforms.u_fx.value = updateFruid(props);
119+
// });
120+
121+
// return (
122+
// <mesh>
123+
// <planeGeometry args={[2, 2]} />
124+
// <shaderMaterial
125+
// ref={ref}
126+
// vertexShader={`
127+
// varying vec2 vUv;
128+
// void main() {
129+
// vUv = uv;
130+
// gl_Position = vec4(position, 1.0);
131+
// }
132+
// `}
133+
// fragmentShader={`
134+
// precision highp float;
135+
// varying vec2 vUv;
136+
// uniform sampler2D u_fx;
137+
138+
// void main() {
139+
// vec2 uv = vUv;
140+
// gl_FragColor = texture2D(u_fx, uv);
141+
// }
142+
// `}
143+
// uniforms={{
144+
// u_fx: { value: null },
145+
// }}
146+
// />
147+
// </mesh>
148+
// );
149+
// };

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"zustand": "^4.4.1"
3737
},
3838
"devDependencies": {
39-
"@hmng8/use-shader-fx": "^1.0.12",
39+
"@hmng8/use-shader-fx": "^1.0.13",
4040
"@storybook/addon-essentials": "^7.5.3",
4141
"@storybook/addon-interactions": "^7.5.3",
4242
"@storybook/addon-links": "^7.5.3",

packages/use-shader-fx/build/use-shader-fx.js

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/use-shader-fx/build/use-shader-fx.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)