@@ -10,6 +10,7 @@ import {
1010 Size ,
1111} from "@react-three/fiber" ;
1212import {
13+ useMorphParticles ,
1314 useCreateMorphParticles ,
1415 MORPHPARTICLES_PARAMS ,
1516 MorphParticlesParams ,
@@ -29,10 +30,10 @@ const setGUI = (gui: GUI) => {
2930 gui . add ( CONFIG , "blurAlpha" , 0 , 1 , 0.01 ) ;
3031 gui . add ( CONFIG , "blurRadius" , 0 , 2 , 0.01 ) ;
3132 gui . add ( CONFIG , "pointSize" , 0.01 , 2 , 0.01 ) ;
32- gui . addColor ( CONFIG , "color0" ) ;
33- gui . addColor ( CONFIG , "color1" ) ;
34- gui . addColor ( CONFIG , "color2" ) ;
35- gui . addColor ( CONFIG , "color3" ) ;
33+ // gui.addColor(CONFIG, "color0");
34+ // gui.addColor(CONFIG, "color1");
35+ // gui.addColor(CONFIG, "color2");
36+ // gui.addColor(CONFIG, "color3");
3637 gui . add ( CONFIG , "wobbleStrength" , 0 , 10 , 0.01 ) ;
3738 gui . add ( CONFIG , "wobblePositionFrequency" , 0 , 10 , 0.01 ) ;
3839 gui . add ( CONFIG , "wobbleTimeFrequency" , 0 , 10 , 0.01 ) ;
@@ -85,7 +86,7 @@ export const Playground = () => {
8586 scene : false ,
8687 size,
8788 dpr : viewport . dpr ,
88- geometry : new THREE . IcosahedronGeometry ( 2.5 , 50 ) ,
89+ geometry : useMemo ( ( ) => new THREE . IcosahedronGeometry ( 2.5 , 50 ) , [ ] ) ,
8990 positions : morphList ,
9091 uvs : uvList ,
9192 // geometry: new THREE.PlaneGeometry(5, 5, 100, 100),
@@ -106,7 +107,6 @@ export const Playground = () => {
106107 updateFluid ( props , {
107108 pointerValues : updatePointer ( refPointer . current ) ,
108109 } ) ;
109- // updateFluid(props);
110110 updatePoints ( props , {
111111 ...setConfig ( ) ,
112112 displacement : fluid ,
@@ -115,7 +115,7 @@ export const Playground = () => {
115115 // map: funkun,
116116 // alphaMap: funkunAlpha,
117117 beat : b . beat ,
118- // morphProgress: Math.max(Math.sin(props.clock.getElapsedTime() / 2), 0),
118+ morphProgress : Math . max ( Math . sin ( props . clock . getElapsedTime ( ) / 2 ) , 0 ) ,
119119 // morphProgress: 0.5,
120120 } ) ;
121121 updateGUI ( ) ;
@@ -132,3 +132,49 @@ export const Playground = () => {
132132 </ mesh >
133133 ) ;
134134} ;
135+
136+ /*===============================================
137+ you can also use useMorphParticles (FBO)
138+ ===============================================*/
139+ // export const Playground = () => {
140+ // const { size, viewport, scene, camera } = useThree();
141+
142+ // const [updatePoints, setPoints, { output }] = useMorphParticles({
143+ // camera,
144+ // size,
145+ // dpr: viewport.dpr,
146+ // geometry: new THREE.IcosahedronGeometry(2.5, 50),
147+ // positions: morphList,
148+ // uvs: uvList,
149+ // // geometry: new THREE.PlaneGeometry(5, 5, 100, 100),
150+ // });
151+
152+ // const beat = useBeat(140, "easeOutCubic");
153+ // const updatePointer = usePointer();
154+ // const refPointer = useRef(new THREE.Vector2(0, 0));
155+ // const handlePointerMove = (e: any) => {
156+ // if (!e?.pointer) {
157+ // return;
158+ // }
159+ // refPointer.current = e.pointer;
160+ // };
161+
162+ // useFrame((props) => {
163+ // const b = beat(props.clock);
164+ // updatePoints(props, {
165+ // ...setConfig(),
166+ // // map: funkun,
167+ // // alphaMap: funkunAlpha,
168+ // beat: b.beat,
169+ // morphProgress: Math.max(Math.sin(props.clock.getElapsedTime() / 2), 0),
170+ // // morphProgress: 0.5,
171+ // });
172+ // });
173+
174+ // return (
175+ // <mesh>
176+ // <planeGeometry args={[2, 2]} />
177+ // <fxMaterial key={FxMaterial.key} u_fx={output} />
178+ // </mesh>
179+ // );
180+ // };
0 commit comments