foundry-component-library 0.2.9 → 0.2.12

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.
Files changed (39) hide show
  1. package/lib/components/Capabilities/Item.tsx +4 -7
  2. package/lib/components/Capabilities/index.tsx +1 -1
  3. package/lib/components/ServiceHubsTeaserEffects/TileBalls.tsx +35 -0
  4. package/lib/components/ServiceHubsTeaserEffects/TileFluid.tsx +29 -0
  5. package/lib/components/ServiceHubsTeaserEffects/TileGlass.tsx +23 -0
  6. package/lib/components/ServiceHubsTeaserEffects/TileRays.tsx +98 -0
  7. package/lib/components/ServiceHubsTeaserEffects/bubbles/Bubble.tsx +48 -0
  8. package/lib/components/ServiceHubsTeaserEffects/bubbles/Bubbles.tsx +45 -0
  9. package/lib/components/ServiceHubsTeaserEffects/fluid/Fluid.tsx +192 -0
  10. package/lib/components/ServiceHubsTeaserEffects/fluid/constant.ts +23 -0
  11. package/lib/components/ServiceHubsTeaserEffects/fluid/effect/Fluid.tsx +22 -0
  12. package/lib/components/ServiceHubsTeaserEffects/fluid/effect/FluidEffect.tsx +61 -0
  13. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/advection.frag +16 -0
  14. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/base.vert +26 -0
  15. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/clear.frag +7 -0
  16. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/composite.frag +41 -0
  17. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/curl.frag +22 -0
  18. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/divergence.frag +41 -0
  19. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/gradientSubstract.frag +26 -0
  20. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/pressure.frag +28 -0
  21. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/splat.frag +19 -0
  22. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl/vorticity.frag +36 -0
  23. package/lib/components/ServiceHubsTeaserEffects/fluid/glsl.d.ts +14 -0
  24. package/lib/components/ServiceHubsTeaserEffects/fluid/hooks/useDoubleFBO.tsx +37 -0
  25. package/lib/components/ServiceHubsTeaserEffects/fluid/hooks/useFBOs.tsx +71 -0
  26. package/lib/components/ServiceHubsTeaserEffects/fluid/hooks/useMaterials.tsx +242 -0
  27. package/lib/components/ServiceHubsTeaserEffects/fluid/hooks/usePointer.tsx +54 -0
  28. package/lib/components/ServiceHubsTeaserEffects/fluid/index.ts +5 -0
  29. package/lib/components/ServiceHubsTeaserEffects/fluid/types.ts +27 -0
  30. package/lib/components/ServiceHubsTeaserEffects/fluid/utils.ts +12 -0
  31. package/lib/components/ServiceHubsTeaserEffects/glass/Lens.tsx +75 -0
  32. package/lib/components/ServiceHubsTeaserEffects/index.tsx +70 -0
  33. package/lib/components/ServiceHubsTeaserEffects/rays/LightSource.tsx +65 -0
  34. package/lib/components/ServiceHubsTeaserEffects/rays/noise.js +97 -0
  35. package/lib/components/ServiceHubsTeaserEffects/styles.module.scss +135 -0
  36. package/lib/index.ts +2 -0
  37. package/lib/types/glsl.d.ts +14 -0
  38. package/lib/vite-env.d.ts +5 -0
  39. package/package.json +6 -2
@@ -0,0 +1,75 @@
1
+ import * as THREE from "three";
2
+ import { useRef, useState } from "react";
3
+ import { createPortal, useFrame, useThree } from "@react-three/fiber";
4
+ import { useFBO, useGLTF, MeshTransmissionMaterial } from "@react-three/drei";
5
+ import { easing } from "maath";
6
+
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");
18
+ const buffer = useFBO();
19
+ const viewport = useThree((state) => state.viewport);
20
+ const [scene] = useState(() => new THREE.Scene());
21
+ useFrame((state, delta) => {
22
+ if (!ref.current) return;
23
+ // Tie lens to the pointer
24
+ // getCurrentViewport gives us the width & height that would fill the screen in threejs units
25
+ // By giving it a target coordinate we can offset these bounds, for instance width/height for a plane that
26
+ // sits 15 units from 0/0/0 towards the camera (which is where the lens is)
27
+ const viewport = state.viewport.getCurrentViewport(
28
+ state.camera,
29
+ [0, 0, 15]
30
+ );
31
+ easing.damp3(
32
+ ref.current.position,
33
+ [
34
+ (state.pointer.x * viewport.width) / 2,
35
+ (state.pointer.y * viewport.height) / 2,
36
+ 15,
37
+ ],
38
+ damping,
39
+ delta
40
+ );
41
+ // This is entirely optional but spares us one extra render of the scene
42
+ // The createPortal below will mount the children of <Lens> into the new THREE.Scene above
43
+ // The following code will render that scene into a buffer, whose texture will then be fed into
44
+ // a plane spanning the full screen and the lens transmission material
45
+ state.gl.setRenderTarget(buffer);
46
+ state.gl.setClearColor("#f197f4");
47
+ state.gl.render(scene, state.camera);
48
+ state.gl.setRenderTarget(null);
49
+ });
50
+ return (
51
+ <>
52
+ {createPortal(children, scene)}
53
+ <mesh scale={[viewport.width, viewport.height, 1]}>
54
+ <planeGeometry />
55
+ <meshBasicMaterial map={buffer.texture} />
56
+ </mesh>
57
+ <mesh
58
+ scale={0.25}
59
+ ref={ref}
60
+ rotation-x={Math.PI / 2}
61
+ geometry={nodes.Cylinder.geometry}
62
+ {...props}>
63
+ <MeshTransmissionMaterial
64
+ buffer={buffer.texture}
65
+ ior={1.2}
66
+ thickness={1.5}
67
+ anisotropy={0.1}
68
+ chromaticAberration={0.02}
69
+ />
70
+ </mesh>
71
+ </>
72
+ );
73
+ };
74
+
75
+ export default Lens;
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { useRef } from "react";
3
+ import Container from "../Container";
4
+ import styles from "./styles.module.scss";
5
+ import TextSection from "../TextSection";
6
+ import TileGlass from "./TileGlass";
7
+ import TileBalls from "./TileBalls";
8
+ import TileRays from "./TileRays";
9
+ import TileFluid from "./TileFluid";
10
+ import { NextLink } from "../../types";
11
+
12
+ const ServiceHubsTeaserEffects = ({
13
+ caption,
14
+ heading,
15
+ text,
16
+ tiles,
17
+ Link,
18
+ }: {
19
+ caption: string;
20
+ heading: string;
21
+ text: string;
22
+ tiles: {
23
+ id: string;
24
+ uri: string;
25
+ title: string;
26
+ customFieldsHub: {
27
+ heading: string;
28
+ };
29
+ }[];
30
+ Link: NextLink;
31
+ }) => {
32
+ const wrapperRef = useRef<HTMLDivElement>(null);
33
+
34
+ return (
35
+ <div className={styles.benefits}>
36
+ <TextSection caption={caption} heading={heading} text={text} isSmall />
37
+ <Container noMobilePadding>
38
+ <div className={styles.wrapper} ref={wrapperRef}>
39
+ <div className={styles.tiles}>
40
+ {tiles.map((tile, i) => {
41
+ const colors: Array<"pink" | "yellow" | "brown" | "blue"> = [
42
+ "pink",
43
+ "yellow",
44
+ "brown",
45
+ "blue",
46
+ ];
47
+ const background = colors[i % colors.length];
48
+
49
+ return (
50
+ <Link
51
+ href={tile.uri}
52
+ className={styles.tileWrapper}
53
+ key={tile.id}>
54
+ <div className={`${styles.tile} ${styles[background]}`}>
55
+ {i === 0 && <TileGlass />}
56
+ {i === 1 && <TileFluid />}
57
+ {i === 2 && <TileRays />}
58
+ {i === 3 && <TileBalls />}
59
+ </div>
60
+ </Link>
61
+ );
62
+ })}
63
+ </div>
64
+ </div>
65
+ </Container>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export default ServiceHubsTeaserEffects;
@@ -0,0 +1,65 @@
1
+ "use client";
2
+
3
+ import { useRef, useMemo } from "react";
4
+ import { useFrame } from "@react-three/fiber";
5
+ import * as THREE from "three";
6
+ import noise from "./noise";
7
+
8
+ export function LightSource(props: React.ComponentProps<"mesh">) {
9
+ const meshRef = useRef(null);
10
+
11
+ // shared time uniform
12
+ const time = useMemo(() => ({ value: 0 }), []);
13
+
14
+ const material = useMemo(() => {
15
+ const m = new THREE.MeshBasicMaterial({
16
+ color: 0xf197f4,
17
+ transparent: true,
18
+ } as any);
19
+
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() {
32
+ `
33
+ )
34
+ .replace(
35
+ `vec4 diffuseColor = vec4( diffuse, opacity );`,
36
+ `
37
+ vec2 uv = vUv - 0.5;
38
+ vec3 col = vec3(0.0);
39
+
40
+ float f = smoothstep(0.5, 0.0, length(uv));
41
+ f = pow(f, 4.0);
42
+
43
+ float n = snoise(vec3(uv * 7.0, time)) * 0.5 + 0.5;
44
+ n = n * 0.5 + 0.5;
45
+
46
+ col = mix(col, diffuse, f * n);
47
+ vec4 diffuseColor = vec4(col, opacity);
48
+ `
49
+ );
50
+ };
51
+
52
+ m.defines = { USE_UV: "" };
53
+ return m;
54
+ }, [time]);
55
+
56
+ useFrame((_, delta) => {
57
+ time.value += delta;
58
+ });
59
+
60
+ return (
61
+ <mesh ref={meshRef} material={material} {...props}>
62
+ <circleGeometry args={[50, 64]} />
63
+ </mesh>
64
+ );
65
+ }
@@ -0,0 +1,97 @@
1
+ const noise = `
2
+ vec4 permute(vec4 x) {
3
+ return mod(((x * 34.0) + 1.0) * x, 289.0);
4
+ }
5
+
6
+ vec4 taylorInvSqrt(vec4 r) {
7
+ return 1.79284291400159 - 0.85373472095314 * r;
8
+ }
9
+
10
+ vec3 fade(vec3 t) {
11
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
12
+ }
13
+
14
+ float snoise(vec3 v) {
15
+ const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);
16
+ const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
17
+
18
+ vec3 i = floor(v + dot(v, C.yyy));
19
+ vec3 x0 = v - i + dot(i, C.xxx);
20
+
21
+ vec3 g = step(x0.yzx, x0.xyz);
22
+ vec3 l = 1.0 - g;
23
+ vec3 i1 = min(g.xyz, l.zxy);
24
+ vec3 i2 = max(g.xyz, l.zxy);
25
+
26
+ vec3 x1 = x0 - i1 + C.xxx;
27
+ vec3 x2 = x0 - i2 + C.yyy;
28
+ vec3 x3 = x0 - D.yyy;
29
+
30
+ i = mod(i, 289.0);
31
+ vec4 p = permute(
32
+ permute(
33
+ permute(
34
+ i.z + vec4(0.0, i1.z, i2.z, 1.0)
35
+ ) + i.y + vec4(0.0, i1.y, i2.y, 1.0)
36
+ ) + i.x + vec4(0.0, i1.x, i2.x, 1.0)
37
+ );
38
+
39
+ float n_ = 1.0 / 7.0;
40
+ vec3 ns = n_ * D.wyz - D.xzx;
41
+
42
+ vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
43
+ vec4 x_ = floor(j * ns.z);
44
+ vec4 y_ = floor(j - 7.0 * x_);
45
+
46
+ vec4 x = x_ * ns.x + ns.yyyy;
47
+ vec4 y = y_ * ns.x + ns.yyyy;
48
+ vec4 h = 1.0 - abs(x) - abs(y);
49
+
50
+ vec4 b0 = vec4(x.xy, y.xy);
51
+ vec4 b1 = vec4(x.zw, y.zw);
52
+
53
+ vec4 s0 = floor(b0) * 2.0 + 1.0;
54
+ vec4 s1 = floor(b1) * 2.0 + 1.0;
55
+ vec4 sh = -step(h, vec4(0.0));
56
+
57
+ vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
58
+ vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
59
+
60
+ vec3 p0 = vec3(a0.xy, h.x);
61
+ vec3 p1 = vec3(a0.zw, h.y);
62
+ vec3 p2 = vec3(a1.xy, h.z);
63
+ vec3 p3 = vec3(a1.zw, h.w);
64
+
65
+ vec4 norm = taylorInvSqrt(
66
+ vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))
67
+ );
68
+ p0 *= norm.x;
69
+ p1 *= norm.y;
70
+ p2 *= norm.z;
71
+ p3 *= norm.w;
72
+
73
+ vec4 m = max(
74
+ 0.6 - vec4(
75
+ dot(x0, x0),
76
+ dot(x1, x1),
77
+ dot(x2, x2),
78
+ dot(x3, x3)
79
+ ),
80
+ 0.0
81
+ );
82
+ m = m * m;
83
+
84
+ return 42.0 *
85
+ dot(
86
+ m * m,
87
+ vec4(
88
+ dot(p0, x0),
89
+ dot(p1, x1),
90
+ dot(p2, x2),
91
+ dot(p3, x3)
92
+ )
93
+ );
94
+ }
95
+ `;
96
+
97
+ export default noise;
@@ -0,0 +1,135 @@
1
+ @use "../variables" as *;
2
+
3
+ .benefits {
4
+ overflow: hidden;
5
+ }
6
+
7
+ .wrapper {
8
+ width: 100%;
9
+ // overflow-x: scroll;
10
+ user-select: none;
11
+ }
12
+
13
+ .tiles {
14
+ display: flex;
15
+ flex-wrap: wrap;
16
+ gap: 16px;
17
+ padding-bottom: 64px;
18
+
19
+ @media #{$QUERY-sm} {
20
+ padding-bottom: 32px;
21
+ }
22
+ }
23
+
24
+ .tileWrapper {
25
+ z-index: 0;
26
+ position: relative;
27
+ width: calc(25% - 12px);
28
+ max-width: 100%;
29
+ height: 351px;
30
+
31
+ &:hover {
32
+ z-index: 1;
33
+ }
34
+
35
+ @media screen and (max-width: $screen-sm) {
36
+ max-width: 80%;
37
+ height: 300px;
38
+ }
39
+
40
+ &:first-child {
41
+ @media #{$QUERY-sm} {
42
+ margin-left: 20px;
43
+ }
44
+ }
45
+
46
+ &:last-child {
47
+ @media #{$QUERY-sm} {
48
+ margin-right: 20px;
49
+ }
50
+ }
51
+ }
52
+
53
+ .tile {
54
+ flex-shrink: 0;
55
+ white-space: pre-wrap;
56
+ padding: 0;
57
+ display: flex;
58
+ flex-direction: column;
59
+ align-items: center;
60
+ justify-content: center;
61
+ text-align: center;
62
+ box-sizing: border-box;
63
+ background-color: $color-pink;
64
+ color: $color-brown;
65
+ font-size: 25px;
66
+ width: 100%;
67
+ height: 100%;
68
+ font-family: $font-secondary;
69
+
70
+ path {
71
+ stroke: $color-brown;
72
+ }
73
+
74
+ &.yellow {
75
+ background-color: $color-yellow;
76
+ color: $color-blue;
77
+
78
+ path {
79
+ stroke: $color-blue;
80
+ }
81
+ }
82
+
83
+ &.brown {
84
+ background-color: $color-brown;
85
+ color: $color-pink;
86
+
87
+ path {
88
+ stroke: $color-pink;
89
+ }
90
+ }
91
+
92
+ &.blue {
93
+ background-color: $color-blue;
94
+ color: $color-white;
95
+
96
+ path {
97
+ stroke: $color-white;
98
+ }
99
+ }
100
+
101
+ // &:hover {
102
+ // .face {
103
+ // display: none;
104
+ // }
105
+
106
+ // .tails {
107
+ // display: block;
108
+ // }
109
+ // }
110
+ }
111
+
112
+ .text {
113
+ margin-bottom: 42px;
114
+
115
+ &:last-child {
116
+ margin-bottom: 0;
117
+ }
118
+ }
119
+
120
+ .face {
121
+ display: block;
122
+ font-size: 35px;
123
+ }
124
+
125
+ // .tails {
126
+ // text-align: left;
127
+ // padding-left: 30px;
128
+ // display: none;
129
+ // font-size: 21px;
130
+ // font-family: $font-secondary;
131
+ // }
132
+
133
+ // .tailsText {
134
+ // margin-bottom: 30px;
135
+ // }
package/lib/index.ts CHANGED
@@ -31,6 +31,7 @@ import OfficesTeaser from "./components/OfficesTeaser";
31
31
  import PartnerNetwork from "./components/PartnerNetwork";
32
32
  import QuoteSection from "./components/QuoteSection";
33
33
  import ServiceHubsTeaser from "./components/ServiceHubsTeaser";
34
+ import ServiceHubsTeaserEffects from "./components/ServiceHubsTeaserEffects";
34
35
  import PostContent from "./components/single/Content";
35
36
  import PostTop from "./components/single/Top";
36
37
  import TeamBenefits from "./components/TeamBenefits";
@@ -74,6 +75,7 @@ export {
74
75
  PartnerNetwork,
75
76
  QuoteSection,
76
77
  ServiceHubsTeaser,
78
+ ServiceHubsTeaserEffects,
77
79
  PostContent,
78
80
  PostTop,
79
81
  TeamBenefits,
@@ -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
@@ -1,2 +1,7 @@
1
1
  /// <reference types="vite/client" />
2
2
  /// <reference types="vite-plugin-svgr/client" />
3
+
4
+ declare module "*.frag" {
5
+ const source: string;
6
+ export default source;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foundry-component-library",
3
- "version": "0.2.9",
3
+ "version": "0.2.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,6 +63,10 @@
63
63
  "**/*.css"
64
64
  ],
65
65
  "dependencies": {
66
- "graphql-request": "^7.1.2"
66
+ "@react-three/drei": "^10.7.7",
67
+ "@react-three/fiber": "^9.4.2",
68
+ "@react-three/postprocessing": "^3.0.4",
69
+ "graphql-request": "^7.1.2",
70
+ "three": "^0.182.0"
67
71
  }
68
72
  }