foundry-component-library 0.2.10 → 0.2.13
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/lib/components/Capabilities/Item.tsx +4 -7
- package/lib/components/Capabilities/index.tsx +1 -1
- package/lib/components/ServiceHubsTeaserEffects/TileRays.tsx +13 -9
- package/lib/components/ServiceHubsTeaserEffects/bubbles/Bubble.tsx +15 -2
- package/lib/components/ServiceHubsTeaserEffects/bubbles/Bubbles.tsx +12 -11
- package/lib/components/ServiceHubsTeaserEffects/fluid/effect/FluidEffect.tsx +49 -46
- package/lib/components/ServiceHubsTeaserEffects/fluid/hooks/useMaterials.tsx +226 -226
- package/lib/components/ServiceHubsTeaserEffects/glass/Lens.tsx +13 -4
- package/lib/components/ServiceHubsTeaserEffects/index.tsx +5 -2
- package/lib/components/ServiceHubsTeaserEffects/rays/LightSource.tsx +29 -28
- package/lib/types/glsl.d.ts +14 -0
- package/lib/vite-env.d.ts +5 -0
- package/package.json +1 -1
- /package/lib/components/ServiceHubsTeaserEffects/rays/{noise.js → noise.ts} +0 -0
|
@@ -20,7 +20,7 @@ const Item = ({
|
|
|
20
20
|
cases: Case[];
|
|
21
21
|
active: string;
|
|
22
22
|
setActive: Dispatch<SetStateAction<string>>;
|
|
23
|
-
Link?: typeof LinkType
|
|
23
|
+
Link?: typeof LinkType;
|
|
24
24
|
Image: NextImage;
|
|
25
25
|
}) => {
|
|
26
26
|
const casesRef = useRef<HTMLDivElement>(null);
|
|
@@ -75,8 +75,7 @@ const Item = ({
|
|
|
75
75
|
} else {
|
|
76
76
|
setActive(title);
|
|
77
77
|
}
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
78
|
+
}}>
|
|
80
79
|
{isActive && <span>-</span>}
|
|
81
80
|
{!isActive && <span>+</span>}
|
|
82
81
|
</button>
|
|
@@ -100,8 +99,7 @@ const Item = ({
|
|
|
100
99
|
overflowX: "auto",
|
|
101
100
|
scrollbarWidth: "none",
|
|
102
101
|
msOverflowStyle: "none",
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
102
|
+
}}>
|
|
105
103
|
{Link &&
|
|
106
104
|
cases.map((item) => {
|
|
107
105
|
const { thumbnailImage, mainImage } = item.case;
|
|
@@ -112,8 +110,7 @@ const Item = ({
|
|
|
112
110
|
key={item.uri}
|
|
113
111
|
className={styles.case}
|
|
114
112
|
draggable={false}
|
|
115
|
-
onClick={handleClick}
|
|
116
|
-
>
|
|
113
|
+
onClick={handleClick}>
|
|
117
114
|
<div className={styles.caseImage}>
|
|
118
115
|
{Image && (
|
|
119
116
|
<Image
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useRef } from "react";
|
|
4
4
|
import { Canvas, useFrame, useThree } from "@react-three/fiber";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useGLTF } from "@react-three/drei";
|
|
6
|
+
import { MeshBasicMaterial, DoubleSide, Mesh, Group } from "three";
|
|
7
7
|
import { LightSource } from "./rays/LightSource";
|
|
8
8
|
import {
|
|
9
9
|
EffectComposer,
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
RenderPass,
|
|
13
13
|
} from "postprocessing";
|
|
14
14
|
|
|
15
|
-
function Slab({ url }) {
|
|
15
|
+
function Slab({ url }: { url: string }) {
|
|
16
16
|
const gltf = useGLTF(url);
|
|
17
|
-
const slabRef = useRef();
|
|
17
|
+
const slabRef = useRef<Group>(null);
|
|
18
18
|
const { camera, scene, gl } = useThree();
|
|
19
19
|
|
|
20
20
|
// GodRays light
|
|
21
|
-
const lightRef = useRef();
|
|
21
|
+
const lightRef = useRef<Mesh>(null);
|
|
22
22
|
useFrame(({ pointer }) => {
|
|
23
23
|
if (lightRef.current) {
|
|
24
24
|
const LIGHT_RANGE = 5;
|
|
@@ -34,7 +34,7 @@ function Slab({ url }) {
|
|
|
34
34
|
slab.rotation.x = Math.PI / 2;
|
|
35
35
|
|
|
36
36
|
slab.traverse((obj) => {
|
|
37
|
-
if (obj
|
|
37
|
+
if (obj instanceof Mesh) {
|
|
38
38
|
obj.material = new MeshBasicMaterial({
|
|
39
39
|
color: 0x491b11,
|
|
40
40
|
side: DoubleSide,
|
|
@@ -42,12 +42,16 @@ function Slab({ url }) {
|
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
slabRef.current
|
|
45
|
+
if (slabRef.current) {
|
|
46
|
+
slabRef.current.add(slab);
|
|
47
|
+
}
|
|
46
48
|
|
|
47
49
|
// Setup postprocessing
|
|
48
50
|
const composer = new EffectComposer(gl);
|
|
49
51
|
composer.addPass(new RenderPass(scene, camera));
|
|
50
52
|
|
|
53
|
+
if (!lightRef.current) return;
|
|
54
|
+
|
|
51
55
|
const gre = new GodRaysEffect(camera, lightRef.current, {
|
|
52
56
|
height: 480,
|
|
53
57
|
kernelSize: 2,
|
|
@@ -62,12 +66,12 @@ function Slab({ url }) {
|
|
|
62
66
|
composer.addPass(new EffectPass(camera, gre));
|
|
63
67
|
|
|
64
68
|
// Render loop override
|
|
65
|
-
const originalSetAnimationLoop = gl.setAnimationLoop;
|
|
69
|
+
// const originalSetAnimationLoop = gl.setAnimationLoop;
|
|
66
70
|
gl.setAnimationLoop(() => composer.render());
|
|
67
71
|
|
|
68
72
|
return () => {
|
|
69
73
|
// Cleanup
|
|
70
|
-
gl.setAnimationLoop(originalSetAnimationLoop);
|
|
74
|
+
// gl.setAnimationLoop(originalSetAnimationLoop);
|
|
71
75
|
composer.dispose();
|
|
72
76
|
};
|
|
73
77
|
}, [gltf, gl, scene, camera]);
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { useRef } from "react";
|
|
2
2
|
import { useFrame } from "@react-three/fiber";
|
|
3
3
|
import { Instance } from "@react-three/drei";
|
|
4
|
+
import type { Mesh } from "three";
|
|
4
5
|
|
|
5
|
-
const Bubble = ({
|
|
6
|
-
|
|
6
|
+
const Bubble = ({
|
|
7
|
+
factor,
|
|
8
|
+
speed,
|
|
9
|
+
xFactor,
|
|
10
|
+
yFactor,
|
|
11
|
+
zFactor,
|
|
12
|
+
}: {
|
|
13
|
+
factor: number;
|
|
14
|
+
speed: number;
|
|
15
|
+
xFactor: number;
|
|
16
|
+
yFactor: number;
|
|
17
|
+
zFactor: number;
|
|
18
|
+
}) => {
|
|
19
|
+
const ref = useRef<Mesh>(null);
|
|
7
20
|
|
|
8
21
|
useFrame((state) => {
|
|
9
22
|
const t = factor + state.clock.elapsedTime * (speed / 2);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MathUtils } from "three";
|
|
1
|
+
import { MathUtils, InstancedMesh } from "three";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { useFrame } from "@react-three/fiber";
|
|
4
4
|
import { Instances } from "@react-three/drei";
|
|
@@ -13,17 +13,18 @@ const particles = Array.from({ length: 20 }, () => ({
|
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
15
|
const Bubbles = () => {
|
|
16
|
-
const ref = useRef(null);
|
|
16
|
+
const ref = useRef<InstancedMesh>(null);
|
|
17
17
|
|
|
18
|
-
useFrame(
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
useFrame((state, delta) => {
|
|
19
|
+
if (!ref.current) return;
|
|
20
|
+
|
|
21
|
+
ref.current.rotation.y = MathUtils.damp(
|
|
22
|
+
ref.current.rotation.y,
|
|
23
|
+
(-state.pointer.x * Math.PI) / 6,
|
|
24
|
+
2.75,
|
|
25
|
+
delta
|
|
26
|
+
);
|
|
27
|
+
});
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
30
|
<Instances
|
|
@@ -1,58 +1,61 @@
|
|
|
1
|
-
import { Effect, EffectAttribute } from
|
|
2
|
-
import { Texture, Uniform, Vector3 } from
|
|
3
|
-
import compositeFrag from
|
|
4
|
-
import { type EffectProps } from
|
|
5
|
-
import { hexToRgb } from
|
|
1
|
+
import { Effect, EffectAttribute } from "postprocessing";
|
|
2
|
+
import { Texture, Uniform, Vector3 } from "three";
|
|
3
|
+
import compositeFrag from "../glsl/composite.frag?raw";
|
|
4
|
+
import { type EffectProps } from "../types";
|
|
5
|
+
import { hexToRgb } from "../utils";
|
|
6
6
|
|
|
7
7
|
type Uniforms = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
tFluid: Texture;
|
|
9
|
+
uColor: Vector3;
|
|
10
|
+
uBackgroundColor: Vector3;
|
|
11
|
+
uRainbow: boolean;
|
|
12
|
+
uShowBackground: boolean;
|
|
13
|
+
uDistort: number;
|
|
14
|
+
uBlend: number;
|
|
15
|
+
uIntensity: number;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export class FluidEffect extends Effect {
|
|
19
|
-
|
|
19
|
+
state: EffectProps;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
constructor(props: EffectProps) {
|
|
22
|
+
const uniforms: Record<keyof Uniforms, Uniform> = {
|
|
23
|
+
tFluid: new Uniform(props.tFluid),
|
|
24
|
+
uDistort: new Uniform(props.distortion),
|
|
25
|
+
uRainbow: new Uniform(props.rainbow),
|
|
26
|
+
uIntensity: new Uniform(props.intensity),
|
|
27
|
+
uBlend: new Uniform(props.blend),
|
|
28
|
+
uShowBackground: new Uniform(props.showBackground),
|
|
29
|
+
uColor: new Uniform(hexToRgb(props.fluidColor!)),
|
|
30
|
+
uBackgroundColor: new Uniform(hexToRgb(props.backgroundColor!)),
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
super("FluidEffect", compositeFrag, {
|
|
34
|
+
blendFunction: props.blendFunction,
|
|
35
|
+
attributes: EffectAttribute.CONVOLUTION,
|
|
36
|
+
uniforms: new Map(Object.entries(uniforms)),
|
|
37
|
+
});
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
this.state = props;
|
|
40
|
+
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
42
|
+
private updateUniform<K extends keyof Uniforms>(key: K, value: Uniforms[K]) {
|
|
43
|
+
const uniform = this.uniforms.get(key);
|
|
44
|
+
if (uniform) {
|
|
45
|
+
uniform.value = value;
|
|
47
46
|
}
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
update() {
|
|
50
|
+
this.updateUniform("uIntensity", this.state.intensity);
|
|
51
|
+
this.updateUniform("uDistort", this.state.distortion);
|
|
52
|
+
this.updateUniform("uRainbow", this.state.rainbow);
|
|
53
|
+
this.updateUniform("uBlend", this.state.blend);
|
|
54
|
+
this.updateUniform("uShowBackground", this.state.showBackground);
|
|
55
|
+
this.updateUniform("uColor", hexToRgb(this.state.fluidColor));
|
|
56
|
+
this.updateUniform(
|
|
57
|
+
"uBackgroundColor",
|
|
58
|
+
hexToRgb(this.state.backgroundColor)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
58
61
|
}
|
|
@@ -1,242 +1,242 @@
|
|
|
1
|
-
import { ShaderMaterial, Texture, Vector2, Vector3 } from
|
|
2
|
-
import { useEffect, useMemo } from
|
|
3
|
-
import { useThree } from
|
|
4
|
-
import { DEFAULT_CONFIG, REFRESH_RATE } from
|
|
1
|
+
import { ShaderMaterial, Texture, Vector2, Vector3 } from "three";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
import { useThree } from "@react-three/fiber";
|
|
4
|
+
import { DEFAULT_CONFIG, REFRESH_RATE } from "../constant";
|
|
5
5
|
|
|
6
|
-
import baseVertex from
|
|
7
|
-
import clearFrag from
|
|
8
|
-
import curlFrag from
|
|
9
|
-
import divergenceFrag from
|
|
10
|
-
import gradientSubstractFrag from
|
|
11
|
-
import pressureFrag from
|
|
12
|
-
import splatFrag from
|
|
13
|
-
import advectionFrag from
|
|
14
|
-
import vorticityFrag from
|
|
6
|
+
import baseVertex from "../glsl/base.vert?raw";
|
|
7
|
+
import clearFrag from "../glsl/clear.frag?raw";
|
|
8
|
+
import curlFrag from "../glsl/curl.frag?raw";
|
|
9
|
+
import divergenceFrag from "../glsl/divergence.frag?raw";
|
|
10
|
+
import gradientSubstractFrag from "../glsl/gradientSubstract.frag?raw";
|
|
11
|
+
import pressureFrag from "../glsl/pressure.frag?raw";
|
|
12
|
+
import splatFrag from "../glsl/splat.frag?raw";
|
|
13
|
+
import advectionFrag from "../glsl/advection.frag?raw";
|
|
14
|
+
import vorticityFrag from "../glsl/vorticity.frag?raw";
|
|
15
15
|
|
|
16
16
|
export const useMaterials = (): { [key: string]: ShaderMaterial } => {
|
|
17
|
-
|
|
17
|
+
const size = useThree((s) => s.size);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
const shaderMaterials = useMemo(() => {
|
|
20
|
+
const advection = new ShaderMaterial({
|
|
21
|
+
name: "Fluid/Advection",
|
|
22
|
+
uniforms: {
|
|
23
|
+
uVelocity: {
|
|
24
|
+
value: new Texture(),
|
|
25
|
+
},
|
|
26
|
+
uSource: {
|
|
27
|
+
value: new Texture(),
|
|
28
|
+
},
|
|
29
|
+
dt: {
|
|
30
|
+
value: 1 / REFRESH_RATE,
|
|
31
|
+
},
|
|
32
|
+
uDissipation: {
|
|
33
|
+
value: 1.0,
|
|
34
|
+
},
|
|
35
|
+
texelSize: { value: new Vector2() },
|
|
36
|
+
},
|
|
37
|
+
fragmentShader: advectionFrag,
|
|
38
|
+
vertexShader: baseVertex,
|
|
39
|
+
defines: {
|
|
40
|
+
USE_V_UV: "",
|
|
41
|
+
},
|
|
42
|
+
depthTest: false,
|
|
43
|
+
depthWrite: false,
|
|
44
|
+
});
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
const clear = new ShaderMaterial({
|
|
47
|
+
name: "Fluid/Clear",
|
|
48
|
+
uniforms: {
|
|
49
|
+
uTexture: {
|
|
50
|
+
value: new Texture(),
|
|
51
|
+
},
|
|
52
|
+
uClearValue: {
|
|
53
|
+
value: DEFAULT_CONFIG.pressure,
|
|
54
|
+
},
|
|
55
|
+
texelSize: {
|
|
56
|
+
value: new Vector2(),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
fragmentShader: clearFrag,
|
|
60
|
+
vertexShader: baseVertex,
|
|
61
|
+
defines: {
|
|
62
|
+
USE_V_UV: "",
|
|
63
|
+
},
|
|
64
|
+
depthTest: false,
|
|
65
|
+
depthWrite: false,
|
|
66
|
+
});
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
const curl = new ShaderMaterial({
|
|
69
|
+
name: "Fluid/Curl",
|
|
70
|
+
uniforms: {
|
|
71
|
+
uVelocity: {
|
|
72
|
+
value: new Texture(),
|
|
73
|
+
},
|
|
74
|
+
texelSize: {
|
|
75
|
+
value: new Vector2(),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
fragmentShader: curlFrag,
|
|
79
|
+
vertexShader: baseVertex,
|
|
80
|
+
defines: {
|
|
81
|
+
USE_OFFSETS: "",
|
|
82
|
+
},
|
|
83
|
+
depthTest: false,
|
|
84
|
+
depthWrite: false,
|
|
85
|
+
});
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
const divergence = new ShaderMaterial({
|
|
88
|
+
name: "Fluid/Divergence",
|
|
89
|
+
uniforms: {
|
|
90
|
+
uVelocity: {
|
|
91
|
+
value: new Texture(),
|
|
92
|
+
},
|
|
93
|
+
texelSize: {
|
|
94
|
+
value: new Vector2(),
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
fragmentShader: divergenceFrag,
|
|
98
|
+
vertexShader: baseVertex,
|
|
99
|
+
defines: {
|
|
100
|
+
USE_V_UV: "",
|
|
101
|
+
USE_OFFSETS: "",
|
|
102
|
+
},
|
|
103
|
+
depthTest: false,
|
|
104
|
+
depthWrite: false,
|
|
105
|
+
});
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
107
|
+
const gradientSubstract = new ShaderMaterial({
|
|
108
|
+
name: "Fluid/GradientSubtract",
|
|
109
|
+
uniforms: {
|
|
110
|
+
uPressure: {
|
|
111
|
+
value: new Texture(),
|
|
112
|
+
},
|
|
113
|
+
uVelocity: {
|
|
114
|
+
value: new Texture(),
|
|
115
|
+
},
|
|
116
|
+
texelSize: {
|
|
117
|
+
value: new Vector2(),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
fragmentShader: gradientSubstractFrag,
|
|
121
|
+
vertexShader: baseVertex,
|
|
122
|
+
defines: {
|
|
123
|
+
USE_V_UV: "",
|
|
124
|
+
USE_OFFSETS: "",
|
|
125
|
+
},
|
|
126
|
+
depthTest: false,
|
|
127
|
+
depthWrite: false,
|
|
128
|
+
});
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
130
|
+
const pressure = new ShaderMaterial({
|
|
131
|
+
name: "Fluid/Pressure",
|
|
132
|
+
uniforms: {
|
|
133
|
+
uPressure: {
|
|
134
|
+
value: new Texture(),
|
|
135
|
+
},
|
|
136
|
+
uDivergence: {
|
|
137
|
+
value: new Texture(),
|
|
138
|
+
},
|
|
139
|
+
texelSize: {
|
|
140
|
+
value: new Vector2(),
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
fragmentShader: pressureFrag,
|
|
144
|
+
vertexShader: baseVertex,
|
|
145
|
+
defines: {
|
|
146
|
+
USE_V_UV: "",
|
|
147
|
+
USE_OFFSETS: "",
|
|
148
|
+
},
|
|
149
|
+
depthTest: false,
|
|
150
|
+
depthWrite: false,
|
|
151
|
+
});
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
153
|
+
const splat = new ShaderMaterial({
|
|
154
|
+
name: "Fluid/Splat",
|
|
155
|
+
uniforms: {
|
|
156
|
+
uTarget: {
|
|
157
|
+
value: new Texture(),
|
|
158
|
+
},
|
|
159
|
+
aspectRatio: {
|
|
160
|
+
value: size.width / size.height,
|
|
161
|
+
},
|
|
162
|
+
uColor: {
|
|
163
|
+
value: new Vector3(),
|
|
164
|
+
},
|
|
165
|
+
uPointer: {
|
|
166
|
+
value: new Vector2(),
|
|
167
|
+
},
|
|
168
|
+
uRadius: {
|
|
169
|
+
value: DEFAULT_CONFIG.radius / 100.0,
|
|
170
|
+
},
|
|
171
|
+
texelSize: {
|
|
172
|
+
value: new Vector2(),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
fragmentShader: splatFrag,
|
|
176
|
+
vertexShader: baseVertex,
|
|
177
|
+
defines: {
|
|
178
|
+
USE_V_UV: "",
|
|
179
|
+
},
|
|
180
|
+
depthTest: false,
|
|
181
|
+
depthWrite: false,
|
|
182
|
+
});
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
184
|
+
const vorticity = new ShaderMaterial({
|
|
185
|
+
name: "Fluid/Vorticity",
|
|
186
|
+
uniforms: {
|
|
187
|
+
uVelocity: {
|
|
188
|
+
value: new Texture(),
|
|
189
|
+
},
|
|
190
|
+
uCurl: {
|
|
191
|
+
value: new Texture(),
|
|
192
|
+
},
|
|
193
|
+
uCurlValue: {
|
|
194
|
+
value: DEFAULT_CONFIG.curl,
|
|
195
|
+
},
|
|
196
|
+
dt: {
|
|
197
|
+
value: 1 / REFRESH_RATE,
|
|
198
|
+
},
|
|
199
|
+
texelSize: {
|
|
200
|
+
value: new Vector2(),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
fragmentShader: vorticityFrag,
|
|
204
|
+
vertexShader: baseVertex,
|
|
205
|
+
defines: {
|
|
206
|
+
USE_V_UV: "",
|
|
207
|
+
USE_OFFSETS: "",
|
|
208
|
+
},
|
|
209
|
+
depthTest: false,
|
|
210
|
+
depthWrite: false,
|
|
211
|
+
});
|
|
212
212
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
213
|
+
return {
|
|
214
|
+
splat,
|
|
215
|
+
curl,
|
|
216
|
+
clear,
|
|
217
|
+
divergence,
|
|
218
|
+
pressure,
|
|
219
|
+
gradientSubstract,
|
|
220
|
+
advection,
|
|
221
|
+
vorticity,
|
|
222
|
+
};
|
|
223
|
+
}, [size]);
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
for (const material of Object.values(shaderMaterials)) {
|
|
227
|
+
const aspectRatio = size.width / (size.height + 400);
|
|
228
|
+
material.uniforms.texelSize.value.set(
|
|
229
|
+
1 / (DEFAULT_CONFIG.simRes * aspectRatio),
|
|
230
|
+
1 / DEFAULT_CONFIG.simRes
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
234
|
+
return () => {
|
|
235
|
+
for (const material of Object.values(shaderMaterials)) {
|
|
236
|
+
material.dispose();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}, [shaderMaterials, size]);
|
|
240
240
|
|
|
241
|
-
|
|
241
|
+
return shaderMaterials;
|
|
242
242
|
};
|
|
@@ -4,13 +4,22 @@ import { createPortal, useFrame, useThree } from "@react-three/fiber";
|
|
|
4
4
|
import { useFBO, useGLTF, MeshTransmissionMaterial } from "@react-three/drei";
|
|
5
5
|
import { easing } from "maath";
|
|
6
6
|
|
|
7
|
-
const Lens = ({
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const Lens = ({
|
|
8
|
+
children,
|
|
9
|
+
damping = 0.2,
|
|
10
|
+
...props
|
|
11
|
+
}: {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
damping?: number;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}) => {
|
|
16
|
+
const ref = useRef<THREE.Mesh>(null);
|
|
17
|
+
const { nodes }: { nodes: any } = useGLTF("/lens-transformed.glb");
|
|
10
18
|
const buffer = useFBO();
|
|
11
19
|
const viewport = useThree((state) => state.viewport);
|
|
12
20
|
const [scene] = useState(() => new THREE.Scene());
|
|
13
21
|
useFrame((state, delta) => {
|
|
22
|
+
if (!ref.current) return;
|
|
14
23
|
// Tie lens to the pointer
|
|
15
24
|
// getCurrentViewport gives us the width & height that would fill the screen in threejs units
|
|
16
25
|
// By giving it a target coordinate we can offset these bounds, for instance width/height for a plane that
|
|
@@ -20,7 +29,7 @@ const Lens = ({ children, damping = 0.2, ...props }) => {
|
|
|
20
29
|
[0, 0, 15]
|
|
21
30
|
);
|
|
22
31
|
easing.damp3(
|
|
23
|
-
ref.current
|
|
32
|
+
ref.current.position,
|
|
24
33
|
[
|
|
25
34
|
(state.pointer.x * viewport.width) / 2,
|
|
26
35
|
(state.pointer.y * viewport.height) / 2,
|
|
@@ -47,14 +47,17 @@ const ServiceHubsTeaserEffects = ({
|
|
|
47
47
|
const background = colors[i % colors.length];
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<
|
|
50
|
+
<Link
|
|
51
|
+
href={tile.uri}
|
|
52
|
+
className={styles.tileWrapper}
|
|
53
|
+
key={tile.id}>
|
|
51
54
|
<div className={`${styles.tile} ${styles[background]}`}>
|
|
52
55
|
{i === 0 && <TileGlass />}
|
|
53
56
|
{i === 1 && <TileFluid />}
|
|
54
57
|
{i === 2 && <TileRays />}
|
|
55
58
|
{i === 3 && <TileBalls />}
|
|
56
59
|
</div>
|
|
57
|
-
</
|
|
60
|
+
</Link>
|
|
58
61
|
);
|
|
59
62
|
})}
|
|
60
63
|
</div>
|
|
@@ -5,8 +5,8 @@ import { useFrame } from "@react-three/fiber";
|
|
|
5
5
|
import * as THREE from "three";
|
|
6
6
|
import noise from "./noise";
|
|
7
7
|
|
|
8
|
-
export function LightSource(props) {
|
|
9
|
-
const meshRef = useRef();
|
|
8
|
+
export function LightSource(props: React.ComponentProps<"mesh">) {
|
|
9
|
+
const meshRef = useRef(null);
|
|
10
10
|
|
|
11
11
|
// shared time uniform
|
|
12
12
|
const time = useMemo(() => ({ value: 0 }), []);
|
|
@@ -15,38 +15,39 @@ export function LightSource(props) {
|
|
|
15
15
|
const m = new THREE.MeshBasicMaterial({
|
|
16
16
|
color: 0xf197f4,
|
|
17
17
|
transparent: true,
|
|
18
|
-
|
|
19
|
-
shader.uniforms.time = time;
|
|
18
|
+
} as any);
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
(m as any).onBeforeCompile = (shader: any) => {
|
|
21
|
+
shader.uniforms.time = time;
|
|
22
|
+
|
|
23
|
+
shader.fragmentShader = `
|
|
24
|
+
uniform float time;
|
|
25
|
+
${shader.fragmentShader}
|
|
26
|
+
`
|
|
27
|
+
.replace(
|
|
28
|
+
`void main() {`,
|
|
29
|
+
`
|
|
30
|
+
${noise}
|
|
31
|
+
void main() {
|
|
24
32
|
`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
${noise}
|
|
29
|
-
void main() {
|
|
33
|
+
)
|
|
34
|
+
.replace(
|
|
35
|
+
`vec4 diffuseColor = vec4( diffuse, opacity );`,
|
|
30
36
|
`
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
`vec4 diffuseColor = vec4( diffuse, opacity );`,
|
|
34
|
-
`
|
|
35
|
-
vec2 uv = vUv - 0.5;
|
|
36
|
-
vec3 col = vec3(0.0);
|
|
37
|
+
vec2 uv = vUv - 0.5;
|
|
38
|
+
vec3 col = vec3(0.0);
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
float f = smoothstep(0.5, 0.0, length(uv));
|
|
41
|
+
f = pow(f, 4.0);
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
float n = snoise(vec3(uv * 7.0, time)) * 0.5 + 0.5;
|
|
44
|
+
n = n * 0.5 + 0.5;
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
46
|
+
col = mix(col, diffuse, f * n);
|
|
47
|
+
vec4 diffuseColor = vec4(col, opacity);
|
|
48
|
+
`
|
|
49
|
+
);
|
|
50
|
+
};
|
|
50
51
|
|
|
51
52
|
m.defines = { USE_UV: "" };
|
|
52
53
|
return m;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module "*.frag?raw" {
|
|
2
|
+
const source: string;
|
|
3
|
+
export default source;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module "*.vert?raw" {
|
|
7
|
+
const source: string;
|
|
8
|
+
export default source;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module "*.glsl?raw" {
|
|
12
|
+
const source: string;
|
|
13
|
+
export default source;
|
|
14
|
+
}
|
package/lib/vite-env.d.ts
CHANGED
package/package.json
CHANGED
|
File without changes
|