Skip to content

Commit efa819c

Browse files
authored
Merge pull request #90 from FunTechInc/v1.1.10
demo update
2 parents c701f33 + 1a9d589 commit efa819c

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

app/ShaderFx.tsx

+41-21
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@
22

33
import { Suspense, useState } from "react";
44
import { Canvas } from "@react-three/fiber";
5-
import { Perf } from "r3f-perf";
5+
// import { Perf } from "r3f-perf";
66
import { PerformanceMonitor } from "@react-three/drei";
77

8+
const Loading = () => {
9+
return (
10+
<div
11+
style={{
12+
fontSize: "16px",
13+
color: "white",
14+
width: "100%",
15+
height: "100%",
16+
display: "flex",
17+
alignItems: "center",
18+
justifyContent: "center",
19+
}}>
20+
Loading...
21+
</div>
22+
);
23+
};
24+
825
export const ShaderFx = ({
926
children,
1027
preserveDrawingBuffer = false,
@@ -18,25 +35,28 @@ export const ShaderFx = ({
1835
}) => {
1936
const [dpr, setDpr] = useState(1.5);
2037
return (
21-
<Canvas
22-
dpr={dpr}
23-
gl={{ preserveDrawingBuffer: preserveDrawingBuffer }}
24-
shadows={shadows}>
25-
<PerformanceMonitor
26-
factor={1}
27-
onChange={({ factor }) => {
28-
if (preserveDrawingBuffer) {
29-
return;
30-
}
31-
if (!isDprUpdate) {
32-
return;
33-
}
34-
console.log(`dpr:${dpr}`);
35-
setDpr(Math.round((1.0 + 1.0 * factor) * 10) / 10);
36-
}}>
37-
<Suspense fallback={null}>{children}</Suspense>
38-
{/* <Perf position={"bottom-left"} minimal={false} /> */}
39-
</PerformanceMonitor>
40-
</Canvas>
38+
<Suspense fallback={<Loading />}>
39+
<Canvas
40+
dpr={dpr}
41+
gl={{ preserveDrawingBuffer: preserveDrawingBuffer }}
42+
shadows={shadows}>
43+
<PerformanceMonitor
44+
factor={1}
45+
onChange={({ factor }) => {
46+
if (preserveDrawingBuffer) {
47+
return;
48+
}
49+
if (!isDprUpdate) {
50+
return;
51+
}
52+
console.log(`dpr:${dpr}`);
53+
setDpr(Math.round((1.0 + 1.0 * factor) * 10) / 10);
54+
}}>
55+
{children}
56+
{/* <Suspense fallback={null}>{children}</Suspense> */}
57+
{/* <Perf position={"bottom-left"} minimal={false} /> */}
58+
</PerformanceMonitor>
59+
</Canvas>
60+
</Suspense>
4161
);
4262
};

app/obscurus/Playground.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const PARTICLE_CONFIG: MorphParticlesParams = {
5757
color1: new THREE.Color(0x000000),
5858
color2: new THREE.Color(0x000000),
5959
color3: new THREE.Color(0x000000),
60-
wobbleStrength: 0.4,
61-
warpStrength: 2.6,
60+
wobbleStrength: 0.6,
61+
warpStrength: 3,
6262
wobblePositionFrequency: 0.4,
6363
wobbleTimeFrequency: 0.4,
6464
warpTimeFrequency: 0.2,
@@ -129,7 +129,7 @@ const setWobbleConfig = () => {
129129
export const Playground = () => {
130130
useGUI(setGUI);
131131
const [noise] = useLoader(THREE.TextureLoader, ["/noise.jpg"]);
132-
const { size, viewport } = useThree();
132+
const { size, viewport, camera } = useThree();
133133
const [updateWobble, wobble] = useCreateWobble3D({
134134
baseMaterial: THREE.MeshPhysicalMaterial,
135135
geometry: useMemo(() => new THREE.IcosahedronGeometry(2.4, 10), []),
@@ -143,7 +143,8 @@ export const Playground = () => {
143143
useEffect(() => {
144144
const particleMat = particles.points.material as THREE.ShaderMaterial;
145145
particleMat.blending = THREE.NormalBlending;
146-
}, [noise, updateParticle, particles.points.material]);
146+
camera.position.z = 8;
147+
}, [noise, updateParticle, particles.points.material, camera]);
147148

148149
useFrame((props) => {
149150
updateWobble(props, {

0 commit comments

Comments
 (0)