Skip to content

The open alternative to Salesforce, designed for AI.

Style the remaining website visuals. (#19401)

Abdullah.38802bd0b834
diff --git a/packages/twenty-website-new/src/app/(home)/_constants/testimonials.ts b/packages/twenty-website-new/src/app/(home)/_constants/testimonials.ts
index b40a29e5e8f..ad9b9c9df86 100644
--- a/packages/twenty-website-new/src/app/(home)/_constants/testimonials.ts
+++ b/packages/twenty-website-new/src/app/(home)/_constants/testimonials.ts
@@ -51,8 +51,4 @@ export const TESTIMONIALS_DATA: TestimonialsDataType = {
},
},
],
- illustration: {
- src: '/illustrations/home/testimonials/testimonials.glb',
- title: 'Testimonials illustration',
- },
};
diff --git a/packages/twenty-website-new/src/app/(home)/page.tsx b/packages/twenty-website-new/src/app/(home)/page.tsx
index 17c7f2ac2a0..8d490a11c0b 100644
--- a/packages/twenty-website-new/src/app/(home)/page.tsx
+++ b/packages/twenty-website-new/src/app/(home)/page.tsx
@@ -130,9 +130,10 @@ export default async function HomePage() {
>
<Testimonials.Carousel
eyebrow={TESTIMONIALS_DATA.eyebrow}
- illustration={TESTIMONIALS_DATA.illustration}
testimonials={TESTIMONIALS_DATA.testimonials}
- />
+ >
+ <Testimonials.HomeVisual />
+ </Testimonials.Carousel>
</Testimonials.Root>
<Faq.Root illustration={FAQ_DATA.illustration}>
diff --git a/packages/twenty-website-new/src/app/layout.tsx b/packages/twenty-website-new/src/app/layout.tsx
index 4d45a9ab4ca..4b4dba67762 100644
--- a/packages/twenty-website-new/src/app/layout.tsx
+++ b/packages/twenty-website-new/src/app/layout.tsx
@@ -1,5 +1,4 @@
import { FOOTER_DATA } from '@/app/_constants/footer';
-import { GlbWarmCache } from '@/constants/glb-warm-cache.component';
import { fetchCommunityStats } from '@/lib/community/fetch-community-stats';
import { mergeSocialLinkLabels } from '@/lib/community/merge-social-link-labels';
import { Footer } from '@/sections/Footer/components';
@@ -85,7 +84,6 @@ export default async function RootLayout({
<body
className={`${cssVariables} ${hostGrotesk.variable} ${aleo.variable} ${azeretMono.variable} ${vt323.variable}`}
>
- <GlbWarmCache />
<StyledMain>{children}</StyledMain>
<Footer.Root illustration={FOOTER_DATA.illustration}>
<Footer.Logo />
diff --git a/packages/twenty-website-new/src/app/partner/_constants/testimonials.ts b/packages/twenty-website-new/src/app/partner/_constants/testimonials.ts
index bdfdee367a2..984cbb4f113 100644
--- a/packages/twenty-website-new/src/app/partner/_constants/testimonials.ts
+++ b/packages/twenty-website-new/src/app/partner/_constants/testimonials.ts
@@ -51,8 +51,4 @@ export const TESTIMONIALS_DATA: TestimonialsDataType = {
},
},
],
- illustration: {
- src: '/illustrations/partner/testimonials/testimonials.glb',
- title: 'Partner testimonials illustration',
- },
};
diff --git a/packages/twenty-website-new/src/app/partner/page.tsx b/packages/twenty-website-new/src/app/partner/page.tsx
index 518d3e1914c..200dbbb84d3 100644
--- a/packages/twenty-website-new/src/app/partner/page.tsx
+++ b/packages/twenty-website-new/src/app/partner/page.tsx
@@ -123,9 +123,10 @@ export default async function PartnerPage() {
>
<Testimonials.Carousel
eyebrow={TESTIMONIALS_DATA.eyebrow}
- illustration={TESTIMONIALS_DATA.illustration}
testimonials={TESTIMONIALS_DATA.testimonials}
- />
+ >
+ <Testimonials.PartnerVisual />
+ </Testimonials.Carousel>
</Testimonials.Root>
<Signoff.Root
diff --git a/packages/twenty-website-new/src/constants/glb-warm-cache.component.tsx b/packages/twenty-website-new/src/constants/glb-warm-cache.component.tsx
deleted file mode 100644
index e15b27515a1..00000000000
--- a/packages/twenty-website-new/src/constants/glb-warm-cache.component.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-'use client';
-
-import { getAllWebsiteGlbUrls } from '@/constants/website-glb-urls';
-import { useEffect } from 'react';
-
-// Warms the browser cache for every marketing GLB right after hydration so LazyEmbed + useGLTF hit disk cache.
-export const GlbWarmCache = () => {
- useEffect(() => {
- const urls = getAllWebsiteGlbUrls();
-
- for (const url of urls) {
- void fetch(url, {
- priority: 'low',
- } as RequestInit & { priority?: RequestPriority });
- }
- }, []);
-
- return null;
-};
diff --git a/packages/twenty-website-new/src/constants/website-glb-urls.ts b/packages/twenty-website-new/src/constants/website-glb-urls.ts
deleted file mode 100644
index bbb16fcea45..00000000000
--- a/packages/twenty-website-new/src/constants/website-glb-urls.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { HELPED_DATA } from '@/app/(home)/_constants/helped';
-import { TESTIMONIALS_DATA as HOME_TESTIMONIALS_DATA } from '@/app/(home)/_constants/testimonials';
-import { THREE_CARDS_ILLUSTRATION_DATA as HOME_THREE_CARDS_DATA } from '@/app/(home)/_constants/three-cards-illustration';
-import { FAQ_DATA } from '@/app/_constants/faq';
-import { FOOTER_DATA } from '@/app/_constants/footer';
-import { TESTIMONIALS_DATA as PARTNER_TESTIMONIALS_DATA } from '@/app/partner/_constants/testimonials';
-import { THREE_CARDS_ILLUSTRATION_DATA as PARTNER_THREE_CARDS_DATA } from '@/app/partner/_constants/three-cards-illustration';
-import { PLANS_DATA } from '@/app/pricing/_constants/plans';
-import { HERO_DATA as PRODUCT_HERO_DATA } from '@/app/product/_constants/hero';
-import { THREE_CARDS_ILLUSTRATION_DATA as PRODUCT_THREE_CARDS_DATA } from '@/app/product/_constants/three-cards';
-import { QUOTE_DATA } from '@/app/why-twenty/_constants/quote';
-import { STEPPER_DATA } from '@/app/why-twenty/_constants/stepper';
-
-const addIfGlb = (urls: Set<string>, src: string) => {
- if (src.toLowerCase().endsWith('.glb')) {
- urls.add(src);
- }
-};
-
-// Single list of on-disk GLBs used across marketing routes; keeps HTTP cache warm after first paint.
-export const getAllWebsiteGlbUrls = (): string[] => {
- const urls = new Set<string>();
-
- addIfGlb(urls, FOOTER_DATA.illustration.src);
- addIfGlb(urls, FAQ_DATA.illustration.src);
- addIfGlb(urls, HOME_TESTIMONIALS_DATA.illustration.src);
-
- for (const card of HOME_THREE_CARDS_DATA.illustrationCards) {
- addIfGlb(urls, card.illustration.src);
- }
-
- for (const card of HELPED_DATA.cards) {
- addIfGlb(urls, card.illustration.src);
- }
-
- addIfGlb(urls, PLANS_DATA.pro.illustration.src);
- addIfGlb(urls, PLANS_DATA.organization.illustration.src);
-
- addIfGlb(urls, PRODUCT_HERO_DATA.illustration.src);
-
- for (const card of PRODUCT_THREE_CARDS_DATA.illustrationCards) {
- addIfGlb(urls, card.illustration.src);
- }
-
- for (const card of PARTNER_THREE_CARDS_DATA.illustrationCards) {
- addIfGlb(urls, card.illustration.src);
- }
-
- addIfGlb(urls, PARTNER_TESTIMONIALS_DATA.illustration.src);
-
- addIfGlb(urls, STEPPER_DATA.illustration.src);
- addIfGlb(urls, QUOTE_DATA.illustration.src);
-
- return [...urls];
-};
diff --git a/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyEmbed.tsx b/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyEmbed.tsx
deleted file mode 100644
index 14d70039b7b..00000000000
--- a/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyEmbed.tsx
+++ /dev/null
@@ -1,177 +0,0 @@
-'use client';
-
-import dynamic from 'next/dynamic';
-import {
- type ComponentPropsWithoutRef,
- useEffect,
- useMemo,
- useRef,
- useState,
-} from 'react';
-
-const DEFAULT_LOAD_ROOT_MARGIN = '1200px 0px';
-const DEFAULT_UNLOAD_ROOT_MARGIN = '1800px 0px';
-const DEFAULT_UNLOAD_DELAY_MS = 1500;
-
-const LazyGlbIllustration = dynamic(
- () =>
- import('./LazyGlbIllustration').then((mod) => ({
- default: mod.LazyGlbIllustration,
- })),
- { loading: () => null, ssr: false },
-);
-
-type LazyEmbedProps = Omit<ComponentPropsWithoutRef<'iframe'>, 'loading' | 'src'> & {
- eager?: boolean;
- rootMargin?: string;
- src: string;
- unloadDelayMs?: number;
- unloadWhenHidden?: boolean;
- unloadRootMargin?: string;
-};
-
-function isGlbSrc(src: string) {
- return src.toLowerCase().endsWith('.glb');
-}
-
-export function LazyEmbed({
- eager = false,
- rootMargin = DEFAULT_LOAD_ROOT_MARGIN,
- unloadDelayMs = DEFAULT_UNLOAD_DELAY_MS,
- unloadWhenHidden = true,
- unloadRootMargin = DEFAULT_UNLOAD_ROOT_MARGIN,
- src,
- title,
- className,
- style,
- role,
- tabIndex,
- 'aria-hidden': ariaHidden,
- ...iframeProps
-}: LazyEmbedProps) {
- const [hostNode, setHostNode] = useState<HTMLDivElement | null>(null);
- const [shouldRender, setShouldRender] = useState(eager);
- const unloadTimeoutRef = useRef<number | null>(null);
- const useGlbRenderer = isGlbSrc(src);
-
- const wrapperProps = useMemo(
- () => ({
- 'aria-hidden': ariaHidden,
- className,
- role,
- style,
- tabIndex,
- }),
- [ariaHidden, className, role, style, tabIndex],
- );
-
- useEffect(() => {
- if (!hostNode) {
- return;
- }
-
- if (!('IntersectionObserver' in window)) {
- setShouldRender(true);
- return;
- }
-
- const clearPendingUnload = () => {
- if (unloadTimeoutRef.current === null) {
- return;
- }
-
- window.clearTimeout(unloadTimeoutRef.current);
- unloadTimeoutRef.current = null;
- };
-
- const scheduleUnload = () => {
- if (!unloadWhenHidden || unloadTimeoutRef.current !== null) {
- return;
- }
-
- unloadTimeoutRef.current = window.setTimeout(() => {
- setShouldRender(false);
- unloadTimeoutRef.current = null;
- }, unloadDelayMs);
- };
-
- if (eager) {
- setShouldRender(true);
- }
-
- const loadObserver = new IntersectionObserver(
- (entries) => {
- const isNearViewport = entries.some((entry) => entry.isIntersecting);
-
- if (isNearViewport) {
- clearPendingUnload();
- setShouldRender(true);
- }
- },
- { rootMargin },
- );
-
- loadObserver.observe(hostNode);
-
- let unloadObserver: IntersectionObserver | null = null;
-
- if (unloadWhenHidden) {
- unloadObserver = new IntersectionObserver(
- (entries) => {
- const isStillClose = entries.some((entry) => entry.isIntersecting);
-
- if (isStillClose) {
- clearPendingUnload();
- return;
- }
-
- scheduleUnload();
- },
- { rootMargin: unloadRootMargin },
- );
-
- unloadObserver.observe(hostNode);
- }
-
- return () => {
- clearPendingUnload();
- loadObserver.disconnect();
- unloadObserver?.disconnect();
- };
- }, [
- eager,
- hostNode,
- rootMargin,
- unloadDelayMs,
- unloadWhenHidden,
- unloadRootMargin,
- ]);
-
- return (
- <div
- {...wrapperProps}
- ref={setHostNode}
- >
- {shouldRender ? (
- useGlbRenderer ? (
- <LazyGlbIllustration src={src} title={title} />
- ) : (
- <iframe
- {...iframeProps}
- aria-hidden={ariaHidden}
- loading={eager ? 'eager' : 'lazy'}
- src={src}
- style={{
- border: 'none',
- display: 'block',
- height: '100%',
- width: '100%',
- }}
- tabIndex={tabIndex}
- title={title}
- />
- )
- ) : null}
- </div>
- );
-}
diff --git a/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyGlbCanvasRoot.tsx b/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyGlbCanvasRoot.tsx
deleted file mode 100644
index d6ad45c03d4..00000000000
--- a/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyGlbCanvasRoot.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { styled } from '@linaria/react';
-
-export const LazyGlbCanvasRoot = styled.div`
- display: block;
- height: 100%;
- width: 100%;
-
- & canvas {
- display: block;
- height: 100%;
- width: 100%;
- }
-`;
diff --git a/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyGlbIllustration.tsx b/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyGlbIllustration.tsx
deleted file mode 100644
index f88569336ad..00000000000
--- a/packages/twenty-website-new/src/design-system/components/LazyEmbed/LazyGlbIllustration.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-'use client';
-
-import { Bounds, useGLTF, Float, PresentationControls } from '@react-three/drei';
-import { Canvas, useFrame } from '@react-three/fiber';
-import { Suspense, useMemo, useRef, useState, useCallback, useEffect } from 'react';
-import * as THREE from 'three';
-import { clone } from 'three/examples/jsm/utils/SkeletonUtils.js';
-import { LazyGlbCanvasRoot } from './LazyGlbCanvasRoot';
-
-type LazyGlbIllustrationProps = {
- src: string;
- title?: string;
-};
-
-function InteractiveGlbModel({ src }: { src: string }) {
- const gltf = useGLTF(src);
- const groupRef = useRef<THREE.Group>(null);
- const [hovered, setHovered] = useState(false);
-
- const model = useMemo(() => {
- const sceneClone = clone(gltf.scene) as THREE.Group;
-
- const bounds = new THREE.Box3().setFromObject(sceneClone);
- const center = bounds.getCenter(new THREE.Vector3());
- const size = bounds.getSize(new THREE.Vector3());
- const maxAxis = Math.max(size.x, size.y, size.z, 1);
- const scale = 2.4 / maxAxis;
-
- sceneClone.position.sub(center);
- sceneClone.scale.setScalar(scale);
-
- return sceneClone;
- }, [gltf.scene]);
-
- useEffect(() => {
- return () => {
- model.traverse((child) => {
- if (child instanceof THREE.Mesh) {
- child.geometry?.dispose();
- if (Array.isArray(child.material)) {
- child.material.forEach((mat) => mat.dispose());
- } else {
- child.material?.dispose();
- }
- }
- });
- };
- }, [model]);
-
- const handlePointerOver = useCallback(() => {
- setHovered(true);
- }, []);
-
- const handlePointerOut = useCallback(() => {
- setHovered(false);
- }, []);
-
- useFrame((state, delta) => {
- if (!groupRef.current) return;
-
- const amp = hovered ? 1.5 : 0.8;
- const targetRotationX = (-state.pointer.y * Math.PI * amp) / 10;
- const targetRotationY = (state.pointer.x * Math.PI * amp) / 10;
-
- groupRef.current.rotation.x = THREE.MathUtils.damp(
- groupRef.current.rotation.x,
- targetRotationX,
- 4,
- delta,
- );
-
- groupRef.current.rotation.y = THREE.MathUtils.damp(
- groupRef.current.rotation.y,
- targetRotationY,
- 4,
- delta,
- );
-
- groupRef.current.rotation.z = THREE.MathUtils.damp(
- groupRef.current.rotation.z,
- Math.sin(state.clock.elapsedTime * 0.5) * 0.05,
- 2,
- delta,
- );
-
- const targetScale = hovered ? 1.15 : 1;
- groupRef.current.scale.setScalar(
- THREE.MathUtils.damp(groupRef.current.scale.x, targetScale, 6, delta),
- );
- });
-
- return (
- <group
- ref={groupRef}
- onPointerOver={handlePointerOver}
- onPointerOut={handlePointerOut}
- >
- <primitive object={model} dispose={null} />
- </group>
- );
-}
-
-export function LazyGlbIllustration({ src, title }: LazyGlbIllustrationProps) {
- return (
- <LazyGlbCanvasRoot aria-label={title} role={title ? 'img' : undefined}>
- <Canvas
- dpr={[1, 1.5]}
- frameloop="demand"
- gl={{
- alpha: true,
- antialias: true,
- powerPreference: 'low-power',
- }}
- camera={{ fov: 30, far: 100, near: 0.1, position: [0, 0, 7] }}
- onCreated={({ gl, scene }) => {
- scene.background = null;
- gl.setClearColor(0x000000, 0);
- }}
- style={{ height: '100%', width: '100%', cursor: 'pointer' }}
- >
- <ambientLight intensity={0.8} />
- <directionalLight intensity={2.5} position={[5, 8, 10]} />
- <directionalLight intensity={1.0} position={[-5, -4, 5]} color="#f0f0ff" />
- <Suspense fallback={null}>
- <Float speed={2.5} rotationIntensity={0.25} floatIntensity={0.7}>
- <PresentationControls
- global
- rotation={[0.1, 0.1, 0]}
- polar={[-0.2, 0.2]}
- azimuth={[-0.5, 0.5]}
- snap={true}
- >
- <Bounds clip fit margin={1.2} observe>
- <InteractiveGlbModel src={src} />
- </Bounds>
- </PresentationControls>
- </Float>
- </Suspense>
- </Canvas>
- </LazyGlbCanvasRoot>
- );
-}
\ No newline at end of file
diff --git a/packages/twenty-website-new/src/design-system/components/index.ts b/packages/twenty-website-new/src/design-system/components/index.ts
index 8c12d7a6b1e..cea33c4d542 100644
--- a/packages/twenty-website-new/src/design-system/components/index.ts
+++ b/packages/twenty-website-new/src/design-system/components/index.ts
@@ -6,5 +6,4 @@ export { Eyebrow } from './Eyebrow/Eyebrow';
export { Heading } from './Heading/Heading';
export { IconButton } from './IconButton/IconButton';
export { Image } from './Image/Image';
-export { LazyEmbed } from './LazyEmbed/LazyEmbed';
export { StepperProgressRail } from './StepperProgressRail/StepperProgressRail';
diff --git a/packages/twenty-website-new/src/sections/Faq/components/FaqVisual/FaqVisual.tsx b/packages/twenty-website-new/src/sections/Faq/components/FaqVisual/FaqVisual.tsx
new file mode 100644
index 00000000000..505cb1ac26c
--- /dev/null
+++ b/packages/twenty-website-new/src/sections/Faq/components/FaqVisual/FaqVisual.tsx
@@ -0,0 +1,276 @@
+'use client';
+
+import { theme } from '@/theme';
+import { styled } from '@linaria/react';
+import { useEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+const FAQ_VISUAL_MODEL_FIT_SCALE = 4;
+const FAQ_VISUAL_ROTATION_RADIANS_PER_SECOND = 0.5;
+const FAQ_VISUAL_WORLD_OFFSET_Y = 0.52;
+
+// World spin axis (x, y, z). Camera on +Z: (0,0,1) = spinner in the view plane.
+// Try (0,1,0) or (1,0,0) if motion or framing looks wrong.
+const FAQ_VISUAL_SPIN_AXIS_XYZ: readonly [number, number, number] = [0, 0, 1];
+
+const scanlineVertexShader = /* glsl */ `
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ vWorldNormal = normalize(mat3(modelMatrix) * normal);
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const scanlineFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec3 uLightDir;
+ uniform float uStripeScale;
+
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec3 normal = normalize(vWorldNormal);
+ vec3 lightDir = normalize(uLightDir);
+ float ndotl = max(dot(normal, lightDir), 0.06);
+
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float shadowWeight = mix(1.0, 0.5, ndotl);
+ float lineWidth = 0.58 * shadowWeight;
+ float edge = 0.035;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ float highlight = pow(ndotl, 1.35);
+ float dash = fract(vWorldPosition.x * 20.0 + vWorldPosition.z * 6.0);
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.15, 0.45, dash) * (1.0 - smoothstep(0.55, 0.88, dash)),
+ highlight
+ );
+ band *= dashMask;
+
+ float speckle = fract(
+ sin(dot(vWorldPosition.xz, vec2(127.1, 311.7))) * 43758.5453
+ );
+ band *= mix(1.0, 0.55 + 0.45 * step(0.4, speckle), highlight * 0.85);
+
+ if (band < 0.015) {
+ discard;
+ }
+
+ vec3 lit = uColor * mix(0.72, 1.18, ndotl);
+ gl_FragColor = vec4(lit, band);
+ }
+`;
+
+function createScanlineMaterial(lightDirection: THREE.Vector3) {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#1e5bff') },
+ uLightDir: { value: lightDirection.clone() },
+ uStripeScale: { value: 16.0 },
+ },
+ vertexShader: scanlineVertexShader,
+ fragmentShader: scanlineFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.geometry?.dispose();
+
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+function applyScanlineMaterials(
+ modelRoot: THREE.Object3D,
+ lightDirection: THREE.Vector3,
+) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.material = createScanlineMaterial(lightDirection);
+ });
+}
+
+const FaqVisualShell = styled.div`
+ bottom: 0;
+ display: block;
+ left: auto;
+ opacity: 0.45;
+ overflow: hidden;
+ pointer-events: none;
+ position: absolute;
+ right: -5%;
+ top: 0;
+ transform: translateY(-11%);
+ width: min(70vw, 750px);
+
+ @media (min-width: ${theme.breakpoints.md}px) {
+ right: -10%;
+ transform: translateY(-12%);
+ width: min(60vw, 900px);
+ }
+`;
+
+const FaqVisualCanvasMount = styled.div`
+ display: block;
+ height: 100%;
+ min-width: 0;
+ width: 100%;
+`;
+
+export type FaqVisualProps = {
+ src: string;
+ title: string;
+};
+
+export function FaqVisual({ src, title }: FaqVisualProps) {
+ const mountReference = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const container = mountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ const lightDirectionWorld = new THREE.Vector3(4, 8, 6).normalize();
+
+ const scene = new THREE.Scene();
+ const width = container.clientWidth;
+ const height = container.clientHeight;
+
+ const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
+ camera.position.set(0, 0, 5.05);
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ const canvas = renderer.domElement;
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const wheel = new THREE.Group();
+ scene.add(wheel);
+
+ const spinAxisWorld = new THREE.Vector3(
+ FAQ_VISUAL_SPIN_AXIS_XYZ[0],
+ FAQ_VISUAL_SPIN_AXIS_XYZ[1],
+ FAQ_VISUAL_SPIN_AXIS_XYZ[2],
+ ).normalize();
+
+ const clock = new THREE.Clock();
+
+ const loader = new GLTFLoader();
+ loader.load(
+ src,
+ (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+ const scale = FAQ_VISUAL_MODEL_FIT_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+
+ applyScanlineMaterials(modelRoot, lightDirectionWorld);
+ wheel.add(modelRoot);
+ wheel.position.y = FAQ_VISUAL_WORLD_OFFSET_Y;
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const delta = Math.min(clock.getDelta(), 0.1);
+ wheel.rotateOnWorldAxis(
+ spinAxisWorld,
+ -delta * FAQ_VISUAL_ROTATION_RADIANS_PER_SECOND,
+ );
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ },
+ undefined,
+ undefined,
+ );
+
+ const handleResize = () => {
+ if (!mountReference.current || cancelled) {
+ return;
+ }
+
+ const nextWidth = mountReference.current.clientWidth;
+ const nextHeight = mountReference.current.clientHeight;
+ if (nextWidth < 1 || nextHeight < 1) {
+ return;
+ }
+ camera.aspect = nextWidth / nextHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(nextWidth, nextHeight);
+ };
+
+ window.addEventListener('resize', handleResize);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener('resize', handleResize);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, [src]);
+
+ return (
+ <FaqVisualShell>
+ <FaqVisualCanvasMount
+ aria-label={title}
+ ref={mountReference}
+ role="img"
+ />
+ </FaqVisualShell>
+ );
+}
diff --git a/packages/twenty-website-new/src/sections/Faq/components/Root/Root.tsx b/packages/twenty-website-new/src/sections/Faq/components/Root/Root.tsx
index 1a7a48d92f0..d5391f6a215 100644
--- a/packages/twenty-website-new/src/sections/Faq/components/Root/Root.tsx
+++ b/packages/twenty-website-new/src/sections/Faq/components/Root/Root.tsx
@@ -1,5 +1,6 @@
-import { Container, LazyEmbed } from '@/design-system/components';
+import { Container } from '@/design-system/components';
import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
+import { FaqVisual } from '../FaqVisual/FaqVisual';
import { theme } from '@/theme';
import { styled } from '@linaria/react';
import type { ReactNode } from 'react';
@@ -15,32 +16,12 @@ const StyledSection = styled.section`
const IllustrationLayer = styled.div`
inset: 0;
- opacity: 0.45;
overflow: hidden;
pointer-events: none;
position: absolute;
z-index: 0;
`;
-const FaqIllustrationEmbed = styled(LazyEmbed)`
- border: none;
- top: -15%;
- right: -5%;
- left: auto;
- transform: none;
- display: block;
- height: min(60vh, 550px);
- position: absolute;
- width: min(70vw, 750px);
-
- @media (min-width: ${theme.breakpoints.md}px) {
- top: -20%;
- right: -10%;
- height: min(70vh, 700px);
- width: min(60vw, 900px);
- }
-`;
-
const StyledContainer = styled(Container)`
display: grid;
grid-template-columns: 1fr;
@@ -67,15 +48,7 @@ export function Root({ children, illustration }: RootProps) {
return (
<StyledSection>
<IllustrationLayer aria-hidden>
- <FaqIllustrationEmbed
- allow="clipboard-write; encrypted-media; gyroscope; web-share"
- allowFullScreen
- eager
- referrerPolicy="strict-origin-when-cross-origin"
- rootMargin="400px 0px"
- src={illustration.src}
- title={illustration.title}
- />
+ <FaqVisual src={illustration.src} title={illustration.title} />
</IllustrationLayer>
<StyledContainer>{children}</StyledContainer>
</StyledSection>
diff --git a/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackground.tsx b/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackground.tsx
index df60ec8b5ec..4c88b0fbbed 100644
--- a/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackground.tsx
+++ b/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackground.tsx
@@ -12,15 +12,18 @@ const FooterBackgroundCanvas = dynamic(
{ ssr: false },
);
-type FooterBackgroundProps = ComponentPropsWithoutRef<'div'> & {
+type FooterBackgroundProps = {
illustration: IllustrationType;
-};
+} & Pick<ComponentPropsWithoutRef<'div'>, 'aria-hidden'>;
export function FooterBackground({
illustration,
- ...rest
+ 'aria-hidden': ariaHidden,
}: FooterBackgroundProps) {
return (
- <FooterBackgroundCanvas {...rest} illustration={illustration} />
+ <FooterBackgroundCanvas
+ aria-hidden={ariaHidden}
+ illustration={illustration}
+ />
);
}
diff --git a/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvas.tsx b/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvas.tsx
index 7bc42894184..6d4fde06056 100644
--- a/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvas.tsx
+++ b/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvas.tsx
@@ -1,36 +1,21 @@
'use client';
-import { LazyEmbed } from '@/design-system/components';
import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
-import { styled } from '@linaria/react';
import type { ComponentPropsWithoutRef } from 'react';
+import { FooterVisual } from '../FooterVisual/FooterVisual';
import { FooterBackgroundCanvasRoot } from './FooterBackgroundCanvasRoot';
-const FooterBackgroundEmbed = styled(LazyEmbed)`
- border: none;
- display: block;
- height: 100%;
- width: 100%;
-`;
-
-type FooterBackgroundCanvasProps = ComponentPropsWithoutRef<'div'> & {
+type FooterBackgroundCanvasProps = {
illustration: IllustrationType;
-};
+} & Pick<ComponentPropsWithoutRef<'div'>, 'aria-hidden'>;
export function FooterBackgroundCanvas({
illustration,
- ...rest
+ 'aria-hidden': ariaHidden,
}: FooterBackgroundCanvasProps) {
return (
- <FooterBackgroundCanvasRoot {...rest}>
- <FooterBackgroundEmbed
- allow="clipboard-write; encrypted-media; gyroscope; web-share"
- allowFullScreen
- referrerPolicy="strict-origin-when-cross-origin"
- rootMargin="200px 0px"
- src={illustration.src}
- title={illustration.title}
- />
+ <FooterBackgroundCanvasRoot aria-hidden={ariaHidden}>
+ <FooterVisual src={illustration.src} title={illustration.title} />
</FooterBackgroundCanvasRoot>
);
}
diff --git a/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvasRoot.tsx b/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvasRoot.tsx
index fbb44d71c74..1195ea112df 100644
--- a/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvasRoot.tsx
+++ b/packages/twenty-website-new/src/sections/Footer/components/FooterBackground/FooterBackgroundCanvasRoot.tsx
@@ -7,11 +7,10 @@ export const FooterBackgroundCanvasRoot = styled.div`
pointer-events: none;
overflow: hidden;
- & canvas,
- & iframe {
+ & canvas {
display: block;
height: 100%;
- mix-blend-mode: color-dodge;
+ pointer-events: auto;
width: 100%;
}
`;
diff --git a/packages/twenty-website-new/src/sections/Footer/components/FooterVisual/FooterVisual.tsx b/packages/twenty-website-new/src/sections/Footer/components/FooterVisual/FooterVisual.tsx
new file mode 100644
index 00000000000..e1fef9a4d4b
--- /dev/null
+++ b/packages/twenty-website-new/src/sections/Footer/components/FooterVisual/FooterVisual.tsx
@@ -0,0 +1,353 @@
+'use client';
+
+import { styled } from '@linaria/react';
+import { useEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+// Framing for the extruded “ZO” hero shot (low angle, centered, room below for links).
+const FOOTER_VISUAL_MODEL_FIT_SCALE = 5;
+const FOOTER_VISUAL_MODEL_OFFSET_Y = 0.42;
+const FOOTER_VISUAL_CAMERA_POSITION: readonly [number, number, number] = [
+ 0, -1.35, 7.4,
+];
+const FOOTER_VISUAL_CAMERA_LOOK_AT: readonly [number, number, number] = [
+ 0, 0.55, 0,
+];
+
+const scanlineVertexShader = /* glsl */ `
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ vWorldNormal = normalize(mat3(modelMatrix) * normal);
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const scanlineFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec3 uLightDir;
+ uniform float uStripeScale;
+
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec3 normal = normalize(vWorldNormal);
+ vec3 lightDir = normalize(uLightDir);
+ float ndotl = max(dot(normal, lightDir), 0.06);
+
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float shadowWeight = mix(1.0, 0.5, ndotl);
+ float lineWidth = 0.58 * shadowWeight;
+ float edge = 0.035;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ float highlight = pow(ndotl, 1.35);
+ float dash = fract(vWorldPosition.x * 20.0 + vWorldPosition.z * 6.0);
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.15, 0.45, dash) * (1.0 - smoothstep(0.55, 0.88, dash)),
+ highlight
+ );
+ band *= dashMask;
+
+ float speckle = fract(
+ sin(dot(vWorldPosition.xz, vec2(127.1, 311.7))) * 43758.5453
+ );
+ band *= mix(1.0, 0.55 + 0.45 * step(0.4, speckle), highlight * 0.85);
+
+ if (band < 0.015) {
+ discard;
+ }
+
+ vec3 lit = uColor * mix(0.72, 1.18, ndotl);
+ gl_FragColor = vec4(lit, band);
+ }
+`;
+
+function createFooterScanlineMaterial(lightDirection: THREE.Vector3) {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#b0b0b0') },
+ uLightDir: { value: lightDirection.clone() },
+ uStripeScale: { value: 16.0 },
+ },
+ vertexShader: scanlineVertexShader,
+ fragmentShader: scanlineFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.geometry?.dispose();
+
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+type MeshRestPose = {
+ position: THREE.Vector3;
+ quaternion: THREE.Quaternion;
+ wobblePhase: number;
+};
+
+function applyFooterScanlineMaterials(
+ modelRoot: THREE.Object3D,
+ lightDirection: THREE.Vector3,
+) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.material = createFooterScanlineMaterial(lightDirection);
+
+ const mesh = sceneObject;
+ const rest: MeshRestPose = {
+ position: mesh.position.clone(),
+ quaternion: mesh.quaternion.clone(),
+ wobblePhase: mesh.position.y * 4.2 + mesh.position.x * 1.7,
+ };
+ mesh.userData.footerVisualRest = rest;
+ });
+}
+
+const FooterVisualCanvasMount = styled.div`
+ display: block;
+ height: 100%;
+ min-width: 0;
+ width: 100%;
+`;
+
+export type FooterVisualProps = {
+ src: string;
+ title: string;
+};
+
+export function FooterVisual({ src, title }: FooterVisualProps) {
+ const mountReference = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const container = mountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ const pointer = { x: 0, y: 0, inside: false };
+ const targetRotation = { x: 0, y: 0 };
+ const lightDirectionWorld = new THREE.Vector3(2, 10, 5).normalize();
+
+ const scene = new THREE.Scene();
+ const width = container.clientWidth;
+ const height = container.clientHeight;
+
+ const camera = new THREE.PerspectiveCamera(42, width / height, 0.1, 100);
+ camera.position.set(
+ FOOTER_VISUAL_CAMERA_POSITION[0],
+ FOOTER_VISUAL_CAMERA_POSITION[1],
+ FOOTER_VISUAL_CAMERA_POSITION[2],
+ );
+ camera.lookAt(
+ new THREE.Vector3(
+ FOOTER_VISUAL_CAMERA_LOOK_AT[0],
+ FOOTER_VISUAL_CAMERA_LOOK_AT[1],
+ FOOTER_VISUAL_CAMERA_LOOK_AT[2],
+ ),
+ );
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ const canvas = renderer.domElement;
+ canvas.style.cursor = 'pointer';
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.touchAction = 'none';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const pivot = new THREE.Group();
+ scene.add(pivot);
+
+ const clock = new THREE.Clock();
+
+ const loader = new GLTFLoader();
+ loader.load(
+ src,
+ (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+ const scale = FOOTER_VISUAL_MODEL_FIT_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+ modelRoot.position.y += FOOTER_VISUAL_MODEL_OFFSET_Y;
+
+ applyFooterScanlineMaterials(modelRoot, lightDirectionWorld);
+ pivot.add(modelRoot);
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const delta = Math.min(clock.getDelta(), 0.1);
+
+ const rotationDamp = 6.8;
+ const influence = pointer.inside ? 1 : 0.38;
+ targetRotation.y = pointer.x * 0.78 * influence;
+ targetRotation.x = pointer.y * 0.62 * influence;
+
+ pivot.rotation.y = THREE.MathUtils.damp(
+ pivot.rotation.y,
+ targetRotation.y,
+ rotationDamp,
+ delta,
+ );
+ pivot.rotation.x = THREE.MathUtils.damp(
+ pivot.rotation.x,
+ targetRotation.x,
+ rotationDamp,
+ delta,
+ );
+
+ const hoverLift = pointer.inside ? 1 : 0;
+ pivot.scale.setScalar(
+ THREE.MathUtils.damp(pivot.scale.x, 1 + hoverLift * 0.12, 7, delta),
+ );
+
+ const mx = pointer.x * (pointer.inside ? 1 : 0.32);
+ const my = pointer.y * (pointer.inside ? 1 : 0.32);
+
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ const rest = sceneObject.userData.footerVisualRest as
+ | MeshRestPose
+ | undefined;
+ if (!rest) {
+ return;
+ }
+
+ const phase = rest.wobblePhase;
+ const wobble = pointer.inside ? 1 : 0.36;
+ sceneObject.position.x =
+ rest.position.x + mx * 0.22 * Math.sin(phase * 1.8);
+ sceneObject.position.z =
+ rest.position.z + my * 0.19 * Math.cos(phase * 1.4);
+ sceneObject.position.y =
+ rest.position.y + (mx + my) * 0.055 * Math.sin(phase * 2.5);
+
+ const twist = (mx * 0.34 + my * 0.24) * wobble * Math.sin(phase);
+ sceneObject.quaternion.copy(rest.quaternion);
+ sceneObject.rotateY(twist);
+ });
+
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ },
+ undefined,
+ undefined,
+ );
+
+ const setPointerFromEvent = (event: PointerEvent) => {
+ const rect = canvas.getBoundingClientRect();
+ const normalizedX = ((event.clientX - rect.left) / rect.width) * 2 - 1;
+ const normalizedY = -(((event.clientY - rect.top) / rect.height) * 2 - 1);
+ pointer.x = THREE.MathUtils.clamp(normalizedX, -1, 1);
+ pointer.y = THREE.MathUtils.clamp(normalizedY, -1, 1);
+ };
+
+ const handlePointerEnter = () => {
+ pointer.inside = true;
+ };
+
+ const handlePointerLeave = () => {
+ pointer.inside = false;
+ pointer.x = 0;
+ pointer.y = 0;
+ };
+
+ const handlePointerMove = (event: PointerEvent) => {
+ setPointerFromEvent(event);
+ };
+
+ canvas.addEventListener('pointerenter', handlePointerEnter);
+ canvas.addEventListener('pointerleave', handlePointerLeave);
+ canvas.addEventListener('pointermove', handlePointerMove);
+
+ const handleResize = () => {
+ if (!mountReference.current || cancelled) {
+ return;
+ }
+
+ const nextWidth = mountReference.current.clientWidth;
+ const nextHeight = mountReference.current.clientHeight;
+ camera.aspect = nextWidth / nextHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(nextWidth, nextHeight);
+ };
+
+ window.addEventListener('resize', handleResize);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener('resize', handleResize);
+ canvas.removeEventListener('pointerenter', handlePointerEnter);
+ canvas.removeEventListener('pointerleave', handlePointerLeave);
+ canvas.removeEventListener('pointermove', handlePointerMove);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, [src]);
+
+ return (
+ <FooterVisualCanvasMount
+ aria-label={title}
+ ref={mountReference}
+ role="img"
+ />
+ );
+}
diff --git a/packages/twenty-website-new/src/sections/Footer/components/Root/Root.tsx b/packages/twenty-website-new/src/sections/Footer/components/Root/Root.tsx
index 32886a9b0c3..11626f1126a 100644
--- a/packages/twenty-website-new/src/sections/Footer/components/Root/Root.tsx
+++ b/packages/twenty-website-new/src/sections/Footer/components/Root/Root.tsx
@@ -3,8 +3,8 @@ import type { IllustrationType } from '@/design-system/components/Illustration/t
import { theme } from '@/theme';
import { styled } from '@linaria/react';
import type { ReactNode } from 'react';
-import { FooterBackground } from '../FooterBackground/FooterBackground';
import { FooterShape } from '../../FooterShape';
+import { FooterBackground } from '../FooterBackground/FooterBackground';
const FooterRoot = styled.footer`
background-color: ${theme.colors.secondary.background[100]};
@@ -14,13 +14,18 @@ const FooterRoot = styled.footer`
const FooterContainer = styled(Container)`
display: flex;
flex-direction: column;
- height: 1280px;
+ height: 880px;
position: relative;
padding-bottom: ${theme.spacing(4)};
padding-left: ${theme.spacing(4)};
padding-right: ${theme.spacing(4)};
+ @media (min-width: ${theme.breakpoints.md}px) {
+ height: 920px;
+ }
+
@media (min-width: ${theme.breakpoints.lg}px) {
+ height: 1080px;
padding-bottom: ${theme.spacing(10)};
padding-left: ${theme.spacing(10)};
padding-right: ${theme.spacing(10)};
@@ -41,11 +46,6 @@ const FooterContent = styled.div`
padding-right: ${theme.spacing(20)};
padding-top: ${theme.spacing(20)};
}
-
- @media (min-width: ${theme.breakpoints.lg}px) {
- padding-left: ${theme.spacing(30)};
- padding-right: ${theme.spacing(30)};
- }
`;
type RootProps = {
diff --git a/packages/twenty-website-new/src/sections/Plans/components/Card/Card.tsx b/packages/twenty-website-new/src/sections/Plans/components/Card/Card.tsx
index 288ffabe3da..9c8e20bed48 100644
--- a/packages/twenty-website-new/src/sections/Plans/components/Card/Card.tsx
+++ b/packages/twenty-website-new/src/sections/Plans/components/Card/Card.tsx
@@ -1,13 +1,11 @@
-import {
- Body,
- Heading,
- LazyEmbed,
- LinkButton,
-} from '@/design-system/components';
+import { styled } from '@linaria/react';
+
+import { Body, Heading, LinkButton } from '@/design-system/components';
import { CheckIcon } from '@/icons/informative/Check';
import type { PlanCardType } from '@/sections/Plans/types';
import { theme } from '@/theme';
-import { styled } from '@linaria/react';
+
+import { PlanCardVisual } from './PlanCardVisual';
const FIXED_ROWS = 4;
@@ -53,17 +51,18 @@ const PriceLine = styled.div`
white-space: nowrap;
`;
-const CardIllustration = styled(LazyEmbed)`
+const CardIllustrationEmbed = styled.div`
background-color: ${theme.colors.primary.background[100]};
border: none;
- display: none;
+ border-radius: ${theme.radius(2)};
+ display: block;
flex-shrink: 0;
height: 112px;
overflow: hidden;
width: 197px;
@media (min-width: ${theme.breakpoints.md}px) {
- display: block;
+ justify-self: end;
}
`;
@@ -116,12 +115,12 @@ export function Card({ card, highlighted = false, maxBullets }: CardProps) {
<Body as="span" body={card.price.body} size="sm" />
</PriceLine>
</CardHeaderInfo>
- <CardIllustration
- allow="clipboard-write; encrypted-media; gyroscope; web-share"
- referrerPolicy="strict-origin-when-cross-origin"
- src={card.illustration.src}
- title={card.illustration.title}
- />
+ <CardIllustrationEmbed>
+ <PlanCardVisual
+ src={card.illustration.src}
+ title={card.illustration.title}
+ />
+ </CardIllustrationEmbed>
</CardHeader>
<LinkButton
diff --git a/packages/twenty-website-new/src/sections/Plans/components/Card/PlanCardVisual.tsx b/packages/twenty-website-new/src/sections/Plans/components/Card/PlanCardVisual.tsx
new file mode 100644
index 00000000000..d1a2f874e67
--- /dev/null
+++ b/packages/twenty-website-new/src/sections/Plans/components/Card/PlanCardVisual.tsx
@@ -0,0 +1,367 @@
+'use client';
+
+import { useEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+const PLAN_CARD_VISUAL_MODEL_FIT_SCALE = 2.35;
+const PLAN_CARD_IDLE_TILT_INFLUENCE = 0.22;
+const PLAN_CARD_HOVER_SCALE_LIFT = 0.06;
+const PLAN_CARD_ROTATION_DAMP = 8.2;
+const PLAN_CARD_TILT_X = 0.42;
+const PLAN_CARD_TILT_Y = 0.52;
+
+const scanlineVertexShader = /* glsl */ `
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ vWorldNormal = normalize(mat3(modelMatrix) * normal);
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const scanlineFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec3 uLightDir;
+ uniform float uStripeScale;
+
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec3 normal = normalize(vWorldNormal);
+ vec3 lightDir = normalize(uLightDir);
+ float ndotl = max(dot(normal, lightDir), 0.06);
+
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float shadowWeight = mix(1.0, 0.5, ndotl);
+ float lineWidth = 0.58 * shadowWeight;
+ float edge = 0.035;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ float highlight = pow(ndotl, 1.35);
+ float dash = fract(vWorldPosition.x * 20.0 + vWorldPosition.z * 6.0);
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.15, 0.45, dash) * (1.0 - smoothstep(0.55, 0.88, dash)),
+ highlight
+ );
+ band *= dashMask;
+
+ float speckle = fract(
+ sin(dot(vWorldPosition.xz, vec2(127.1, 311.7))) * 43758.5453
+ );
+ band *= mix(1.0, 0.55 + 0.45 * step(0.4, speckle), highlight * 0.85);
+
+ if (band < 0.015) {
+ discard;
+ }
+
+ vec3 lit = uColor * mix(0.72, 1.18, ndotl);
+ gl_FragColor = vec4(lit, band);
+ }
+`;
+
+function createScanlineMaterial(lightDirection: THREE.Vector3) {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#1e5bff') },
+ uLightDir: { value: lightDirection.clone() },
+ uStripeScale: { value: 16.0 },
+ },
+ vertexShader: scanlineVertexShader,
+ fragmentShader: scanlineFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.geometry?.dispose();
+
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+type MeshRestPose = {
+ position: THREE.Vector3;
+ quaternion: THREE.Quaternion;
+ wobblePhase: number;
+};
+
+function applyScanlineMaterials(
+ modelRoot: THREE.Object3D,
+ lightDirection: THREE.Vector3,
+) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.material = createScanlineMaterial(lightDirection);
+
+ const mesh = sceneObject;
+ const rest: MeshRestPose = {
+ position: mesh.position.clone(),
+ quaternion: mesh.quaternion.clone(),
+ wobblePhase: mesh.position.y * 4.2 + mesh.position.x * 1.7,
+ };
+ mesh.userData.planCardVisualRest = rest;
+ });
+}
+
+// Plain div + stable inline style: Linaria on this node caused SSR/client className mismatches.
+const planCardVisualMountStyle = {
+ display: 'block' as const,
+ height: '100%',
+ minWidth: 0,
+ width: '100%',
+};
+
+type PlanCardVisualProps = {
+ src: string;
+ title: string;
+};
+
+export function PlanCardVisual({ src, title }: PlanCardVisualProps) {
+ const mountReference = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const container = mountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ const pointer = { x: 0, y: 0, inside: false };
+ const targetRotation = { x: 0, y: 0 };
+ const lightDirectionWorld = new THREE.Vector3(4, 8, 6).normalize();
+
+ const scene = new THREE.Scene();
+ const readSize = () => {
+ const nextWidth = container.clientWidth;
+ const nextHeight = container.clientHeight;
+ return {
+ width: Math.max(nextWidth, 1),
+ height: Math.max(nextHeight, 1),
+ };
+ };
+
+ const { width, height } = readSize();
+
+ const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
+ camera.position.set(0, 0, 5.05);
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ const canvas = renderer.domElement;
+ canvas.style.cursor = 'default';
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.touchAction = 'none';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const pivot = new THREE.Group();
+ scene.add(pivot);
+
+ const clock = new THREE.Clock();
+
+ const loader = new GLTFLoader();
+ loader.load(
+ src,
+ (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+ const scale = PLAN_CARD_VISUAL_MODEL_FIT_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+
+ applyScanlineMaterials(modelRoot, lightDirectionWorld);
+ pivot.add(modelRoot);
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const delta = Math.min(clock.getDelta(), 0.1);
+
+ const influence = pointer.inside ? 1 : PLAN_CARD_IDLE_TILT_INFLUENCE;
+ targetRotation.y = pointer.x * PLAN_CARD_TILT_Y * influence;
+ targetRotation.x = pointer.y * PLAN_CARD_TILT_X * influence;
+
+ pivot.rotation.y = THREE.MathUtils.damp(
+ pivot.rotation.y,
+ targetRotation.y,
+ PLAN_CARD_ROTATION_DAMP,
+ delta,
+ );
+ pivot.rotation.x = THREE.MathUtils.damp(
+ pivot.rotation.x,
+ targetRotation.x,
+ PLAN_CARD_ROTATION_DAMP,
+ delta,
+ );
+
+ const hoverLift = pointer.inside ? 1 : 0;
+ pivot.scale.setScalar(
+ THREE.MathUtils.damp(
+ pivot.scale.x,
+ 1 + hoverLift * PLAN_CARD_HOVER_SCALE_LIFT,
+ 7,
+ delta,
+ ),
+ );
+
+ const mx =
+ pointer.x * (pointer.inside ? 1 : PLAN_CARD_IDLE_TILT_INFLUENCE);
+ const my =
+ pointer.y * (pointer.inside ? 1 : PLAN_CARD_IDLE_TILT_INFLUENCE);
+
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ const rest = sceneObject.userData.planCardVisualRest as
+ | MeshRestPose
+ | undefined;
+ if (!rest) {
+ return;
+ }
+
+ const phase = rest.wobblePhase;
+ const wobble = pointer.inside ? 0.55 : 0.22;
+ sceneObject.position.x =
+ rest.position.x + mx * 0.12 * Math.sin(phase * 1.8);
+ sceneObject.position.z =
+ rest.position.z + my * 0.1 * Math.cos(phase * 1.4);
+ sceneObject.position.y =
+ rest.position.y + (mx + my) * 0.03 * Math.sin(phase * 2.5);
+
+ const twist = (mx * 0.18 + my * 0.14) * wobble * Math.sin(phase);
+ sceneObject.quaternion.copy(rest.quaternion);
+ sceneObject.rotateY(twist);
+ });
+
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ },
+ undefined,
+ undefined,
+ );
+
+ const setPointerFromEvent = (event: PointerEvent) => {
+ const rect = canvas.getBoundingClientRect();
+ const normalizedX = ((event.clientX - rect.left) / rect.width) * 2 - 1;
+ const normalizedY = -(((event.clientY - rect.top) / rect.height) * 2 - 1);
+ pointer.x = THREE.MathUtils.clamp(normalizedX, -1, 1);
+ pointer.y = THREE.MathUtils.clamp(normalizedY, -1, 1);
+ };
+
+ const handlePointerEnter = () => {
+ pointer.inside = true;
+ };
+
+ const handlePointerLeave = () => {
+ pointer.inside = false;
+ pointer.x = 0;
+ pointer.y = 0;
+ };
+
+ const handlePointerMove = (event: PointerEvent) => {
+ setPointerFromEvent(event);
+ };
+
+ canvas.addEventListener('pointerenter', handlePointerEnter);
+ canvas.addEventListener('pointerleave', handlePointerLeave);
+ canvas.addEventListener('pointermove', handlePointerMove);
+
+ const syncCanvasToContainer = () => {
+ if (!mountReference.current || cancelled) {
+ return;
+ }
+
+ const nextWidth = mountReference.current.clientWidth;
+ const nextHeight = mountReference.current.clientHeight;
+ if (nextWidth < 1 || nextHeight < 1) {
+ return;
+ }
+
+ camera.aspect = nextWidth / nextHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(nextWidth, nextHeight);
+ };
+
+ const resizeObserver = new ResizeObserver(() => {
+ syncCanvasToContainer();
+ });
+ resizeObserver.observe(container);
+
+ const handleWindowResize = () => {
+ syncCanvasToContainer();
+ };
+
+ window.addEventListener('resize', handleWindowResize);
+
+ return () => {
+ cancelled = true;
+ resizeObserver.disconnect();
+ window.removeEventListener('resize', handleWindowResize);
+ canvas.removeEventListener('pointerenter', handlePointerEnter);
+ canvas.removeEventListener('pointerleave', handlePointerLeave);
+ canvas.removeEventListener('pointermove', handlePointerMove);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, [src]);
+
+ return (
+ <div
+ aria-label={title}
+ ref={mountReference}
+ role="img"
+ style={planCardVisualMountStyle}
+ />
+ );
+}
diff --git a/packages/twenty-website-new/src/sections/Quote/components/Visual/Visual.tsx b/packages/twenty-website-new/src/sections/Quote/components/Visual/Visual.tsx
index 033b0626074..f0922dbeb5a 100644
--- a/packages/twenty-website-new/src/sections/Quote/components/Visual/Visual.tsx
+++ b/packages/twenty-website-new/src/sections/Quote/components/Visual/Visual.tsx
@@ -1,10 +1,132 @@
-import { LazyEmbed } from '@/design-system/components';
+'use client';
+
import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
import { theme } from '@/theme';
import { styled } from '@linaria/react';
+import { useLayoutEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+const QUOTE_VISUAL_MODEL_FIT_SCALE = 3.05;
+
+const scanlineVertexShader = /* glsl */ `
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ vWorldNormal = normalize(mat3(modelMatrix) * normal);
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const scanlineFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec3 uLightDir;
+ uniform float uStripeScale;
+
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec3 normal = normalize(vWorldNormal);
+ vec3 lightDir = normalize(uLightDir);
+ float ndotl = max(dot(normal, lightDir), 0.06);
+
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float shadowWeight = mix(1.0, 0.5, ndotl);
+ float lineWidth = 0.58 * shadowWeight;
+ float edge = 0.035;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ float highlight = pow(ndotl, 1.35);
+ float dash = fract(vWorldPosition.x * 20.0 + vWorldPosition.z * 6.0);
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.15, 0.45, dash) * (1.0 - smoothstep(0.55, 0.88, dash)),
+ highlight
+ );
+ band *= dashMask;
+
+ float speckle = fract(
+ sin(dot(vWorldPosition.xz, vec2(127.1, 311.7))) * 43758.5453
+ );
+ band *= mix(1.0, 0.55 + 0.45 * step(0.4, speckle), highlight * 0.85);
+
+ if (band < 0.015) {
+ discard;
+ }
+
+ vec3 lit = uColor * mix(0.72, 1.18, ndotl);
+ gl_FragColor = vec4(lit, band);
+ }
+`;
+
+function createScanlineMaterial(lightDirection: THREE.Vector3) {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#1e5bff') },
+ uLightDir: { value: lightDirection.clone() },
+ uStripeScale: { value: 16.0 },
+ },
+ vertexShader: scanlineVertexShader,
+ fragmentShader: scanlineFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.geometry?.dispose();
+
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+type MeshRestPose = {
+ position: THREE.Vector3;
+ quaternion: THREE.Quaternion;
+ wobblePhase: number;
+};
+
+function applyScanlineMaterials(
+ modelRoot: THREE.Object3D,
+ lightDirection: THREE.Vector3,
+) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.material = createScanlineMaterial(lightDirection);
+
+ const mesh = sceneObject;
+ const rest: MeshRestPose = {
+ position: mesh.position.clone(),
+ quaternion: mesh.quaternion.clone(),
+ wobblePhase: mesh.position.y * 4.2 + mesh.position.x * 1.7,
+ };
+ mesh.userData.quoteVisualRest = rest;
+ });
+}
const VisualContainer = styled.div`
- background-color: ${theme.colors.secondary.background[100]};
+ background-color: transparent;
border-radius: ${theme.radius(1)};
height: min(544px, 70vw);
min-height: ${theme.spacing(80)};
@@ -18,23 +140,13 @@ const VisualContainer = styled.div`
}
`;
-const StyledIframe = styled(LazyEmbed)`
- border: none;
- height: 200%;
- left: 51.5%;
- mix-blend-mode: lighten;
- position: absolute;
- top: 50%;
- transform: translate(-50%, -50%);
- width: 200%;
-`;
-
-const HueOverlay = styled.div`
- background-color: ${theme.colors.highlight[100]};
+const CanvasMount = styled.div`
+ display: block;
+ height: 100%;
inset: 0;
- mix-blend-mode: hue;
- pointer-events: none;
+ min-width: 0;
position: absolute;
+ width: 100%;
`;
type VisualProps = {
@@ -42,16 +154,200 @@ type VisualProps = {
};
export function Visual({ illustration }: VisualProps) {
+ const mountReference = useRef<HTMLDivElement>(null);
+
+ useLayoutEffect(() => {
+ const container = mountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ const pointer = { x: 0, y: 0, inside: false };
+ const targetRotation = { x: 0, y: 0 };
+ const lightDirectionWorld = new THREE.Vector3(4, 8, 6).normalize();
+
+ const scene = new THREE.Scene();
+ const width = container.clientWidth;
+ const height = container.clientHeight;
+
+ const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
+ camera.position.set(0, 0, 5.05);
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ const canvas = renderer.domElement;
+ canvas.style.cursor = 'pointer';
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.touchAction = 'none';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const pivot = new THREE.Group();
+ scene.add(pivot);
+
+ const clock = new THREE.Clock();
+
+ const loader = new GLTFLoader();
+ loader.load(
+ illustration.src,
+ (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+ const scale = QUOTE_VISUAL_MODEL_FIT_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+
+ applyScanlineMaterials(modelRoot, lightDirectionWorld);
+ pivot.add(modelRoot);
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const delta = Math.min(clock.getDelta(), 0.1);
+
+ const rotationDamp = 6.8;
+ const influence = pointer.inside ? 1 : 0.38;
+ targetRotation.y = pointer.x * 0.78 * influence;
+ targetRotation.x = pointer.y * 0.62 * influence;
+
+ pivot.rotation.y = THREE.MathUtils.damp(
+ pivot.rotation.y,
+ targetRotation.y,
+ rotationDamp,
+ delta,
+ );
+ pivot.rotation.x = THREE.MathUtils.damp(
+ pivot.rotation.x,
+ targetRotation.x,
+ rotationDamp,
+ delta,
+ );
+
+ const hoverLift = pointer.inside ? 1 : 0;
+ pivot.scale.setScalar(
+ THREE.MathUtils.damp(pivot.scale.x, 1 + hoverLift * 0.12, 7, delta),
+ );
+
+ const mx = pointer.x * (pointer.inside ? 1 : 0.32);
+ const my = pointer.y * (pointer.inside ? 1 : 0.32);
+
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ const rest = sceneObject.userData.quoteVisualRest as
+ | MeshRestPose
+ | undefined;
+ if (!rest) {
+ return;
+ }
+
+ const phase = rest.wobblePhase;
+ const wobble = pointer.inside ? 1 : 0.36;
+ sceneObject.position.x =
+ rest.position.x + mx * 0.22 * Math.sin(phase * 1.8);
+ sceneObject.position.z =
+ rest.position.z + my * 0.19 * Math.cos(phase * 1.4);
+ sceneObject.position.y =
+ rest.position.y + (mx + my) * 0.055 * Math.sin(phase * 2.5);
+
+ const twist = (mx * 0.34 + my * 0.24) * wobble * Math.sin(phase);
+ sceneObject.quaternion.copy(rest.quaternion);
+ sceneObject.rotateY(twist);
+ });
+
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ },
+ undefined,
+ undefined,
+ );
+
+ const setPointerFromEvent = (event: PointerEvent) => {
+ const rect = canvas.getBoundingClientRect();
+ const normalizedX = ((event.clientX - rect.left) / rect.width) * 2 - 1;
+ const normalizedY = -(((event.clientY - rect.top) / rect.height) * 2 - 1);
+ pointer.x = THREE.MathUtils.clamp(normalizedX, -1, 1);
+ pointer.y = THREE.MathUtils.clamp(normalizedY, -1, 1);
+ };
+
+ const handlePointerEnter = () => {
+ pointer.inside = true;
+ };
+
+ const handlePointerLeave = () => {
+ pointer.inside = false;
+ pointer.x = 0;
+ pointer.y = 0;
+ };
+
+ const handlePointerMove = (event: PointerEvent) => {
+ setPointerFromEvent(event);
+ };
+
+ canvas.addEventListener('pointerenter', handlePointerEnter);
+ canvas.addEventListener('pointerleave', handlePointerLeave);
+ canvas.addEventListener('pointermove', handlePointerMove);
+
+ const handleResize = () => {
+ if (!mountReference.current || cancelled) {
+ return;
+ }
+
+ const nextWidth = mountReference.current.clientWidth;
+ const nextHeight = mountReference.current.clientHeight;
+ camera.aspect = nextWidth / nextHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(nextWidth, nextHeight);
+ };
+
+ window.addEventListener('resize', handleResize);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener('resize', handleResize);
+ canvas.removeEventListener('pointerenter', handlePointerEnter);
+ canvas.removeEventListener('pointerleave', handlePointerLeave);
+ canvas.removeEventListener('pointermove', handlePointerMove);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, [illustration.src]);
+
return (
<VisualContainer>
- <StyledIframe
- src={illustration.src}
- title={illustration.title}
- allow="clipboard-write; encrypted-media; gyroscope; web-share"
- referrerPolicy="strict-origin-when-cross-origin"
- allowFullScreen
+ <CanvasMount
+ aria-label={illustration.title}
+ ref={mountReference}
+ role="img"
/>
- <HueOverlay aria-hidden="true" />
</VisualContainer>
);
}
diff --git a/packages/twenty-website-new/src/sections/Salesforce/components/PricingWindow/PricingWindow.tsx b/packages/twenty-website-new/src/sections/Salesforce/components/PricingWindow/PricingWindow.tsx
index 0d5a0223839..40d8e060131 100644
--- a/packages/twenty-website-new/src/sections/Salesforce/components/PricingWindow/PricingWindow.tsx
+++ b/packages/twenty-website-new/src/sections/Salesforce/components/PricingWindow/PricingWindow.tsx
@@ -334,7 +334,9 @@ const HiddenCheckbox = styled.input`
const CheckboxFace = styled.span<{ checked: boolean }>`
aspect-ratio: 1 / 1;
background-color: ${({ checked }) =>
- checked ? theme.colors.primary.background[100] : 'rgba(255, 255, 255, 0.05)'};
+ checked
+ ? theme.colors.primary.background[100]
+ : 'rgba(255, 255, 255, 0.05)'};
border-radius: 0;
box-sizing: border-box;
box-shadow:
@@ -381,9 +383,11 @@ const AddonRightText = styled.span`
text-align: right;
`;
-const AddonRightLine = styled.span<{ muted?: boolean }>`
- color: ${({ muted }) =>
- muted ? theme.colors.primary.text[60] : theme.colors.primary.text[100]};
+const AddonRightLine = styled.span<{ 'data-muted'?: boolean }>`
+ color: ${(props) =>
+ props['data-muted']
+ ? theme.colors.primary.text[60]
+ : theme.colors.primary.text[100]};
display: block;
`;
@@ -394,7 +398,7 @@ const AddonRightPart = styled.span`
const renderRightLabelParts = (lines: SalesforceRichTextPartType[][]) =>
lines.map((line, lineIndex) => (
- <AddonRightLine key={lineIndex} muted={lineIndex > 0}>
+ <AddonRightLine key={lineIndex} data-muted={lineIndex > 0 || undefined}>
{line.map((part, partIndex) => (
<AddonRightPart
key={partIndex}
@@ -415,7 +419,10 @@ const renderRightLabelParts = (lines: SalesforceRichTextPartType[][]) =>
const renderRightLabel = (label: string) =>
label.split('\n').map((line, lineIndex) => (
- <AddonRightLine key={`${lineIndex}-${line}`} muted={lineIndex > 0}>
+ <AddonRightLine
+ key={`${lineIndex}-${line}`}
+ data-muted={lineIndex > 0 || undefined}
+ >
{line}
</AddonRightLine>
));
@@ -447,13 +454,15 @@ export function PricingWindow({
const panelRef = useRef<HTMLDivElement | null>(null);
const stickyHeaderRef = useRef<HTMLDivElement | null>(null);
const addonAnchorRefs = useRef<Record<string, HTMLLabelElement | null>>({});
- const [stickyHeaderState, setStickyHeaderState] = useState<StickyHeaderState>({
- absoluteTop: 0,
- height: 0,
- left: 0,
- mode: 'absolute',
- width: 0,
- });
+ const [stickyHeaderState, setStickyHeaderState] = useState<StickyHeaderState>(
+ {
+ absoluteTop: 0,
+ height: 0,
+ left: 0,
+ mode: 'absolute',
+ width: 0,
+ },
+ );
const { fixedPriceAmount, perSeatPriceAmount, totalPriceAmount } =
calculatePriceAmounts(pricing, checkedIds);
@@ -587,7 +596,9 @@ export function PricingWindow({
<ProductCopy>
<ProductTitle>{pricing.productTitle}</ProductTitle>
<PriceRow>
- <PriceAmount>{formatPriceAmount(perSeatPriceAmount)}</PriceAmount>
+ <PriceAmount>
+ {formatPriceAmount(perSeatPriceAmount)}
+ </PriceAmount>
<PriceSuffix>{pricing.priceSuffix}</PriceSuffix>
</PriceRow>
{fixedPriceAmount > 0 ? (
@@ -595,7 +606,9 @@ export function PricingWindow({
<TotalPriceAmount>
{formatPriceAmount(totalPriceAmount)}
</TotalPriceAmount>
- <TotalPriceLabel>{pricing.totalPriceLabel}</TotalPriceLabel>
+ <TotalPriceLabel>
+ {pricing.totalPriceLabel}
+ </TotalPriceLabel>
</TotalPriceRow>
) : null}
</ProductCopy>
@@ -628,8 +641,9 @@ export function PricingWindow({
onChange={() =>
onAddonToggle(
addon,
- addonAnchorRefs.current[addon.id]?.getBoundingClientRect() ??
- null,
+ addonAnchorRefs.current[
+ addon.id
+ ]?.getBoundingClientRect() ?? null,
)
}
type="checkbox"
diff --git a/packages/twenty-website-new/src/sections/Testimonials/components/Carousel/Carousel.tsx b/packages/twenty-website-new/src/sections/Testimonials/components/Carousel/Carousel.tsx
index 4a23732602e..bfdc9bb5b6e 100644
--- a/packages/twenty-website-new/src/sections/Testimonials/components/Carousel/Carousel.tsx
+++ b/packages/twenty-website-new/src/sections/Testimonials/components/Carousel/Carousel.tsx
@@ -2,14 +2,12 @@
import { Body, Eyebrow, Heading, IconButton } from '@/design-system/components';
import type { EyebrowType } from '@/design-system/components/Eyebrow/types/Eyebrow';
-import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
import { ArrowLeftIcon, ArrowRightIcon } from '@/icons';
import type { TestimonialCardType } from '@/sections/Testimonials/types/TestimonialCard';
import { theme } from '@/theme';
import { styled } from '@linaria/react';
import NextImage from 'next/image';
-import { useState } from 'react';
-import { Embed } from '../Embed/Embed';
+import { type ReactNode, useState } from 'react';
import { Separator } from '../Separator/Separator';
const DATE_FORMATTER = new Intl.DateTimeFormat('en-US', {
@@ -28,7 +26,7 @@ const StyledCarousel = styled.div`
@media (min-width: ${theme.breakpoints.md}px) {
align-items: stretch;
column-gap: ${theme.spacing(15)};
- grid-template-columns: auto auto 1fr;
+ grid-template-columns: auto auto minmax(0, 1fr);
row-gap: 0;
}
`;
@@ -55,7 +53,9 @@ const CounterSlot = styled.div`
}
`;
-const EmbedSlot = styled.div`
+const VisualSlot = styled.div`
+ align-self: start;
+ justify-self: start;
order: 2;
@media (min-width: ${theme.breakpoints.md}px) {
@@ -82,9 +82,11 @@ const RightColumn = styled.div`
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
+ min-width: 0;
row-gap: ${theme.spacing(6)};
@media (min-width: ${theme.breakpoints.md}px) {
+ min-width: 0;
padding-bottom: ${theme.spacing(8)};
padding-top: ${theme.spacing(8)};
row-gap: ${theme.spacing(14)};
@@ -101,7 +103,9 @@ const HeadingWrapper = styled.div`
pointer-events: none;
visibility: hidden;
transform: translateY(8px);
- transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
+ transition:
+ opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
+ transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
&[data-active='true'] {
opacity: 1;
@@ -177,16 +181,12 @@ const HandleText = styled.span`
`;
type CarouselProps = {
+ children: ReactNode;
eyebrow: EyebrowType;
- illustration: IllustrationType;
testimonials: TestimonialCardType[];
};
-export function Carousel({
- eyebrow,
- illustration,
- testimonials,
-}: CarouselProps) {
+export function Carousel({ children, eyebrow, testimonials }: CarouselProps) {
const [index, setIndex] = useState(0);
const total = testimonials.length;
@@ -216,9 +216,7 @@ export function Carousel({
{index + 1}/{total}
</CounterText>
</CounterSlot>
- <EmbedSlot>
- <Embed illustration={illustration} />
- </EmbedSlot>
+ <VisualSlot>{children}</VisualSlot>
</LeftColumn>
<Separator />
diff --git a/packages/twenty-website-new/src/sections/Testimonials/components/Embed/Embed.tsx b/packages/twenty-website-new/src/sections/Testimonials/components/Embed/Embed.tsx
deleted file mode 100644
index 418be1898e2..00000000000
--- a/packages/twenty-website-new/src/sections/Testimonials/components/Embed/Embed.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { LazyEmbed } from '@/design-system/components';
-import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
-import { theme } from '@/theme';
-import { styled } from '@linaria/react';
-
-const EmbedContainer = styled.div`
- background-color: ${theme.colors.primary.background[100]};
- border-radius: ${theme.radius(1)};
- height: 279px;
- overflow: hidden;
- position: relative;
- width: 198px;
-
- @media (min-width: ${theme.breakpoints.md}px) {
- height: 476px;
- width: 336px;
- }
-`;
-
-const StyledIframe = styled(LazyEmbed)`
- border: none;
- height: 200%;
- left: 51.5%;
- mix-blend-mode: difference;
- pointer-events: none;
- position: absolute;
- top: 50%;
- transform: translate(-50%, -50%);
- width: 200%;
-`;
-
-const PlusOverlay = styled.div`
- background-color: ${theme.colors.highlight[100]};
- inset: 0;
- mix-blend-mode: plus-lighter;
- pointer-events: none;
- position: absolute;
-`;
-
-type EmbedProps = {
- illustration: IllustrationType;
-};
-
-export function Embed({ illustration }: EmbedProps) {
- return (
- <EmbedContainer>
- <StyledIframe
- allow="clipboard-write; encrypted-media; gyroscope; web-share"
- allowFullScreen
- referrerPolicy="strict-origin-when-cross-origin"
- src={illustration.src}
- title={illustration.title}
- />
- <PlusOverlay aria-hidden="true" />
- </EmbedContainer>
- );
-}
diff --git a/packages/twenty-website-new/src/sections/Testimonials/components/HomeVisual/HomeVisual.tsx b/packages/twenty-website-new/src/sections/Testimonials/components/HomeVisual/HomeVisual.tsx
new file mode 100644
index 00000000000..034c2d9212d
--- /dev/null
+++ b/packages/twenty-website-new/src/sections/Testimonials/components/HomeVisual/HomeVisual.tsx
@@ -0,0 +1,350 @@
+'use client';
+
+import { theme } from '@/theme';
+import { styled } from '@linaria/react';
+import { useLayoutEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+const HOME_TESTIMONIALS_VISUAL_GLB_URL =
+ '/illustrations/home/testimonials/testimonials.glb';
+const HOME_TESTIMONIALS_VISUAL_TITLE = 'Testimonials illustration';
+const HOME_TESTIMONIALS_VISUAL_MODEL_FIT_SCALE = 2.85;
+
+const scanlineVertexShader = /* glsl */ `
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ vWorldNormal = normalize(mat3(modelMatrix) * normal);
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const scanlineFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec3 uLightDir;
+ uniform float uStripeScale;
+
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec3 normal = normalize(vWorldNormal);
+ vec3 lightDir = normalize(uLightDir);
+ float ndotl = max(dot(normal, lightDir), 0.06);
+
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float shadowWeight = mix(1.0, 0.5, ndotl);
+ float lineWidth = 0.58 * shadowWeight;
+ float edge = 0.035;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ float highlight = pow(ndotl, 1.35);
+ float dash = fract(vWorldPosition.x * 20.0 + vWorldPosition.z * 6.0);
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.15, 0.45, dash) * (1.0 - smoothstep(0.55, 0.88, dash)),
+ highlight
+ );
+ band *= dashMask;
+
+ float speckle = fract(
+ sin(dot(vWorldPosition.xz, vec2(127.1, 311.7))) * 43758.5453
+ );
+ band *= mix(1.0, 0.55 + 0.45 * step(0.4, speckle), highlight * 0.85);
+
+ if (band < 0.015) {
+ discard;
+ }
+
+ vec3 lit = uColor * mix(0.72, 1.18, ndotl);
+ gl_FragColor = vec4(lit, band);
+ }
+`;
+
+function createScanlineMaterial(lightDirection: THREE.Vector3) {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#1e5bff') },
+ uLightDir: { value: lightDirection.clone() },
+ uStripeScale: { value: 16.0 },
+ },
+ vertexShader: scanlineVertexShader,
+ fragmentShader: scanlineFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.geometry?.dispose();
+
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+type MeshRestPose = {
+ position: THREE.Vector3;
+ quaternion: THREE.Quaternion;
+ wobblePhase: number;
+};
+
+function applyScanlineMaterials(
+ modelRoot: THREE.Object3D,
+ lightDirection: THREE.Vector3,
+) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.material = createScanlineMaterial(lightDirection);
+
+ const mesh = sceneObject;
+ const rest: MeshRestPose = {
+ position: mesh.position.clone(),
+ quaternion: mesh.quaternion.clone(),
+ wobblePhase: mesh.position.y * 4.2 + mesh.position.x * 1.7,
+ };
+ mesh.userData.homeTestimonialsVisualRest = rest;
+ });
+}
+
+const VisualFrame = styled.div`
+ background-color: transparent;
+ border-radius: ${theme.radius(1)};
+ height: 279px;
+ overflow: hidden;
+ position: relative;
+ width: 198px;
+
+ @media (min-width: ${theme.breakpoints.md}px) {
+ height: 476px;
+ width: 336px;
+ }
+`;
+
+const CanvasMount = styled.div`
+ display: block;
+ height: 100%;
+ inset: 0;
+ min-width: 0;
+ position: absolute;
+ width: 100%;
+`;
+
+export function HomeVisual() {
+ const mountReference = useRef<HTMLDivElement>(null);
+
+ useLayoutEffect(() => {
+ const container = mountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ const pointer = { x: 0, y: 0, inside: false };
+ const targetRotation = { x: 0, y: 0 };
+ const lightDirectionWorld = new THREE.Vector3(4, 8, 6).normalize();
+
+ const scene = new THREE.Scene();
+ const width = container.clientWidth;
+ const height = container.clientHeight;
+
+ const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
+ camera.position.set(0, 0, 5.05);
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ const canvas = renderer.domElement;
+ canvas.style.cursor = 'pointer';
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.touchAction = 'none';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const pivot = new THREE.Group();
+ scene.add(pivot);
+
+ const clock = new THREE.Clock();
+
+ const loader = new GLTFLoader();
+ loader.load(
+ HOME_TESTIMONIALS_VISUAL_GLB_URL,
+ (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+ const scale = HOME_TESTIMONIALS_VISUAL_MODEL_FIT_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+
+ applyScanlineMaterials(modelRoot, lightDirectionWorld);
+ pivot.add(modelRoot);
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const delta = Math.min(clock.getDelta(), 0.1);
+
+ const rotationDamp = 6.8;
+ const influence = pointer.inside ? 1 : 0.38;
+ targetRotation.y = pointer.x * 0.78 * influence;
+ targetRotation.x = pointer.y * 0.62 * influence;
+
+ pivot.rotation.y = THREE.MathUtils.damp(
+ pivot.rotation.y,
+ targetRotation.y,
+ rotationDamp,
+ delta,
+ );
+ pivot.rotation.x = THREE.MathUtils.damp(
+ pivot.rotation.x,
+ targetRotation.x,
+ rotationDamp,
+ delta,
+ );
+
+ const hoverLift = pointer.inside ? 1 : 0;
+ pivot.scale.setScalar(
+ THREE.MathUtils.damp(pivot.scale.x, 1 + hoverLift * 0.12, 7, delta),
+ );
+
+ const mx = pointer.x * (pointer.inside ? 1 : 0.32);
+ const my = pointer.y * (pointer.inside ? 1 : 0.32);
+
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ const rest = sceneObject.userData.homeTestimonialsVisualRest as
+ | MeshRestPose
+ | undefined;
+ if (!rest) {
+ return;
+ }
+
+ const phase = rest.wobblePhase;
+ const wobble = pointer.inside ? 1 : 0.36;
+ sceneObject.position.x =
+ rest.position.x + mx * 0.22 * Math.sin(phase * 1.8);
+ sceneObject.position.z =
+ rest.position.z + my * 0.19 * Math.cos(phase * 1.4);
+ sceneObject.position.y =
+ rest.position.y + (mx + my) * 0.055 * Math.sin(phase * 2.5);
+
+ const twist = (mx * 0.34 + my * 0.24) * wobble * Math.sin(phase);
+ sceneObject.quaternion.copy(rest.quaternion);
+ sceneObject.rotateY(twist);
+ });
+
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ },
+ undefined,
+ undefined,
+ );
+
+ const setPointerFromEvent = (event: PointerEvent) => {
+ const rect = canvas.getBoundingClientRect();
+ const normalizedX = ((event.clientX - rect.left) / rect.width) * 2 - 1;
+ const normalizedY = -(((event.clientY - rect.top) / rect.height) * 2 - 1);
+ pointer.x = THREE.MathUtils.clamp(normalizedX, -1, 1);
+ pointer.y = THREE.MathUtils.clamp(normalizedY, -1, 1);
+ };
+
+ const handlePointerEnter = () => {
+ pointer.inside = true;
+ };
+
+ const handlePointerLeave = () => {
+ pointer.inside = false;
+ pointer.x = 0;
+ pointer.y = 0;
+ };
+
+ const handlePointerMove = (event: PointerEvent) => {
+ setPointerFromEvent(event);
+ };
+
+ canvas.addEventListener('pointerenter', handlePointerEnter);
+ canvas.addEventListener('pointerleave', handlePointerLeave);
+ canvas.addEventListener('pointermove', handlePointerMove);
+
+ const handleResize = () => {
+ if (!mountReference.current || cancelled) {
+ return;
+ }
+
+ const nextWidth = mountReference.current.clientWidth;
+ const nextHeight = mountReference.current.clientHeight;
+ camera.aspect = nextWidth / nextHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(nextWidth, nextHeight);
+ };
+
+ window.addEventListener('resize', handleResize);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener('resize', handleResize);
+ canvas.removeEventListener('pointerenter', handlePointerEnter);
+ canvas.removeEventListener('pointerleave', handlePointerLeave);
+ canvas.removeEventListener('pointermove', handlePointerMove);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, []);
+
+ return (
+ <VisualFrame>
+ <CanvasMount
+ aria-label={HOME_TESTIMONIALS_VISUAL_TITLE}
+ ref={mountReference}
+ role="img"
+ />
+ </VisualFrame>
+ );
+}
diff --git a/packages/twenty-website-new/src/sections/Testimonials/components/PartnerVisual/PartnerVisual.tsx b/packages/twenty-website-new/src/sections/Testimonials/components/PartnerVisual/PartnerVisual.tsx
new file mode 100644
index 00000000000..7540dc5460b
--- /dev/null
+++ b/packages/twenty-website-new/src/sections/Testimonials/components/PartnerVisual/PartnerVisual.tsx
@@ -0,0 +1,350 @@
+'use client';
+
+import { theme } from '@/theme';
+import { styled } from '@linaria/react';
+import { useLayoutEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+const PARTNER_TESTIMONIALS_VISUAL_GLB_URL =
+ '/illustrations/partner/testimonials/testimonials.glb';
+const PARTNER_TESTIMONIALS_VISUAL_TITLE = 'Partner testimonials illustration';
+const PARTNER_TESTIMONIALS_VISUAL_MODEL_FIT_SCALE = 2.85;
+
+const scanlineVertexShader = /* glsl */ `
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ vWorldNormal = normalize(mat3(modelMatrix) * normal);
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const scanlineFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec3 uLightDir;
+ uniform float uStripeScale;
+
+ varying vec3 vWorldPosition;
+ varying vec3 vWorldNormal;
+
+ void main() {
+ vec3 normal = normalize(vWorldNormal);
+ vec3 lightDir = normalize(uLightDir);
+ float ndotl = max(dot(normal, lightDir), 0.06);
+
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float shadowWeight = mix(1.0, 0.5, ndotl);
+ float lineWidth = 0.58 * shadowWeight;
+ float edge = 0.035;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ float highlight = pow(ndotl, 1.35);
+ float dash = fract(vWorldPosition.x * 20.0 + vWorldPosition.z * 6.0);
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.15, 0.45, dash) * (1.0 - smoothstep(0.55, 0.88, dash)),
+ highlight
+ );
+ band *= dashMask;
+
+ float speckle = fract(
+ sin(dot(vWorldPosition.xz, vec2(127.1, 311.7))) * 43758.5453
+ );
+ band *= mix(1.0, 0.55 + 0.45 * step(0.4, speckle), highlight * 0.85);
+
+ if (band < 0.015) {
+ discard;
+ }
+
+ vec3 lit = uColor * mix(0.72, 1.18, ndotl);
+ gl_FragColor = vec4(lit, band);
+ }
+`;
+
+function createScanlineMaterial(lightDirection: THREE.Vector3) {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#1e5bff') },
+ uLightDir: { value: lightDirection.clone() },
+ uStripeScale: { value: 16.0 },
+ },
+ vertexShader: scanlineVertexShader,
+ fragmentShader: scanlineFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.geometry?.dispose();
+
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+type MeshRestPose = {
+ position: THREE.Vector3;
+ quaternion: THREE.Quaternion;
+ wobblePhase: number;
+};
+
+function applyScanlineMaterials(
+ modelRoot: THREE.Object3D,
+ lightDirection: THREE.Vector3,
+) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ sceneObject.material = createScanlineMaterial(lightDirection);
+
+ const mesh = sceneObject;
+ const rest: MeshRestPose = {
+ position: mesh.position.clone(),
+ quaternion: mesh.quaternion.clone(),
+ wobblePhase: mesh.position.y * 4.2 + mesh.position.x * 1.7,
+ };
+ mesh.userData.partnerTestimonialsVisualRest = rest;
+ });
+}
+
+const VisualFrame = styled.div`
+ background-color: transparent;
+ border-radius: ${theme.radius(1)};
+ height: 279px;
+ overflow: hidden;
+ position: relative;
+ width: 198px;
+
+ @media (min-width: ${theme.breakpoints.md}px) {
+ height: 476px;
+ width: 336px;
+ }
+`;
+
+const CanvasMount = styled.div`
+ display: block;
+ height: 100%;
+ inset: 0;
+ min-width: 0;
+ position: absolute;
+ width: 100%;
+`;
+
+export function PartnerVisual() {
+ const mountReference = useRef<HTMLDivElement>(null);
+
+ useLayoutEffect(() => {
+ const container = mountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ const pointer = { x: 0, y: 0, inside: false };
+ const targetRotation = { x: 0, y: 0 };
+ const lightDirectionWorld = new THREE.Vector3(4, 8, 6).normalize();
+
+ const scene = new THREE.Scene();
+ const width = container.clientWidth;
+ const height = container.clientHeight;
+
+ const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
+ camera.position.set(0, 0, 5.05);
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ const canvas = renderer.domElement;
+ canvas.style.cursor = 'pointer';
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.touchAction = 'none';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const pivot = new THREE.Group();
+ scene.add(pivot);
+
+ const clock = new THREE.Clock();
+
+ const loader = new GLTFLoader();
+ loader.load(
+ PARTNER_TESTIMONIALS_VISUAL_GLB_URL,
+ (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+ const scale = PARTNER_TESTIMONIALS_VISUAL_MODEL_FIT_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+
+ applyScanlineMaterials(modelRoot, lightDirectionWorld);
+ pivot.add(modelRoot);
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const delta = Math.min(clock.getDelta(), 0.1);
+
+ const rotationDamp = 6.8;
+ const influence = pointer.inside ? 1 : 0.38;
+ targetRotation.y = pointer.x * 0.78 * influence;
+ targetRotation.x = pointer.y * 0.62 * influence;
+
+ pivot.rotation.y = THREE.MathUtils.damp(
+ pivot.rotation.y,
+ targetRotation.y,
+ rotationDamp,
+ delta,
+ );
+ pivot.rotation.x = THREE.MathUtils.damp(
+ pivot.rotation.x,
+ targetRotation.x,
+ rotationDamp,
+ delta,
+ );
+
+ const hoverLift = pointer.inside ? 1 : 0;
+ pivot.scale.setScalar(
+ THREE.MathUtils.damp(pivot.scale.x, 1 + hoverLift * 0.12, 7, delta),
+ );
+
+ const mx = pointer.x * (pointer.inside ? 1 : 0.32);
+ const my = pointer.y * (pointer.inside ? 1 : 0.32);
+
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ const rest = sceneObject.userData.partnerTestimonialsVisualRest as
+ | MeshRestPose
+ | undefined;
+ if (!rest) {
+ return;
+ }
+
+ const phase = rest.wobblePhase;
+ const wobble = pointer.inside ? 1 : 0.36;
+ sceneObject.position.x =
+ rest.position.x + mx * 0.22 * Math.sin(phase * 1.8);
+ sceneObject.position.z =
+ rest.position.z + my * 0.19 * Math.cos(phase * 1.4);
+ sceneObject.position.y =
+ rest.position.y + (mx + my) * 0.055 * Math.sin(phase * 2.5);
+
+ const twist = (mx * 0.34 + my * 0.24) * wobble * Math.sin(phase);
+ sceneObject.quaternion.copy(rest.quaternion);
+ sceneObject.rotateY(twist);
+ });
+
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ },
+ undefined,
+ undefined,
+ );
+
+ const setPointerFromEvent = (event: PointerEvent) => {
+ const rect = canvas.getBoundingClientRect();
+ const normalizedX = ((event.clientX - rect.left) / rect.width) * 2 - 1;
+ const normalizedY = -(((event.clientY - rect.top) / rect.height) * 2 - 1);
+ pointer.x = THREE.MathUtils.clamp(normalizedX, -1, 1);
+ pointer.y = THREE.MathUtils.clamp(normalizedY, -1, 1);
+ };
+
+ const handlePointerEnter = () => {
+ pointer.inside = true;
+ };
+
+ const handlePointerLeave = () => {
+ pointer.inside = false;
+ pointer.x = 0;
+ pointer.y = 0;
+ };
+
+ const handlePointerMove = (event: PointerEvent) => {
+ setPointerFromEvent(event);
+ };
+
+ canvas.addEventListener('pointerenter', handlePointerEnter);
+ canvas.addEventListener('pointerleave', handlePointerLeave);
+ canvas.addEventListener('pointermove', handlePointerMove);
+
+ const handleResize = () => {
+ if (!mountReference.current || cancelled) {
+ return;
+ }
+
+ const nextWidth = mountReference.current.clientWidth;
+ const nextHeight = mountReference.current.clientHeight;
+ camera.aspect = nextWidth / nextHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(nextWidth, nextHeight);
+ };
+
+ window.addEventListener('resize', handleResize);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener('resize', handleResize);
+ canvas.removeEventListener('pointerenter', handlePointerEnter);
+ canvas.removeEventListener('pointerleave', handlePointerLeave);
+ canvas.removeEventListener('pointermove', handlePointerMove);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, []);
+
+ return (
+ <VisualFrame>
+ <CanvasMount
+ aria-label={PARTNER_TESTIMONIALS_VISUAL_TITLE}
+ ref={mountReference}
+ role="img"
+ />
+ </VisualFrame>
+ );
+}
diff --git a/packages/twenty-website-new/src/sections/Testimonials/components/index.ts b/packages/twenty-website-new/src/sections/Testimonials/components/index.ts
index c6acebc08d5..c0686cb1bc1 100644
--- a/packages/twenty-website-new/src/sections/Testimonials/components/index.ts
+++ b/packages/twenty-website-new/src/sections/Testimonials/components/index.ts
@@ -1,11 +1,13 @@
import { Carousel } from './Carousel/Carousel';
-import { Embed } from './Embed/Embed';
+import { HomeVisual } from './HomeVisual/HomeVisual';
+import { PartnerVisual } from './PartnerVisual/PartnerVisual';
import { Root } from './Root/Root';
import { Separator } from './Separator/Separator';
export const Testimonials = {
Carousel,
- Embed,
+ HomeVisual,
+ PartnerVisual,
Root,
Separator,
};
diff --git a/packages/twenty-website-new/src/sections/Testimonials/types/TestimonialsData.ts b/packages/twenty-website-new/src/sections/Testimonials/types/TestimonialsData.ts
index e3f814692a7..b4b85513cc0 100644
--- a/packages/twenty-website-new/src/sections/Testimonials/types/TestimonialsData.ts
+++ b/packages/twenty-website-new/src/sections/Testimonials/types/TestimonialsData.ts
@@ -1,9 +1,7 @@
import type { EyebrowType } from '@/design-system/components/Eyebrow/types/Eyebrow';
-import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
import type { TestimonialCardType } from '@/sections/Testimonials/types/TestimonialCard';
export type TestimonialsDataType = {
eyebrow: EyebrowType;
testimonials: TestimonialCardType[];
- illustration: IllustrationType;
};
diff --git a/packages/twenty-website-new/src/sections/WhyTwentyStepper/components/Visual/Visual.tsx b/packages/twenty-website-new/src/sections/WhyTwentyStepper/components/Visual/Visual.tsx
index dab02f66237..4d76c676745 100644
--- a/packages/twenty-website-new/src/sections/WhyTwentyStepper/components/Visual/Visual.tsx
+++ b/packages/twenty-website-new/src/sections/WhyTwentyStepper/components/Visual/Visual.tsx
@@ -1,7 +1,14 @@
-import { LazyEmbed } from '@/design-system/components';
+'use client';
+
import type { IllustrationType } from '@/design-system/components/Illustration/types/Illustration';
import { theme } from '@/theme';
import { styled } from '@linaria/react';
+import { useLayoutEffect, useRef } from 'react';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
+
+const STEP_VISUAL_MODEL_SCALE = 2.72;
+const STEP_VISUAL_STRIPE_SCALE = 22.0;
const VisualColumn = styled.div`
min-width: 0;
@@ -15,7 +22,7 @@ const VisualColumn = styled.div`
`;
const VisualContainer = styled.div`
- background-color: ${theme.colors.secondary.background[100]};
+ background-color: transparent;
border-radius: ${theme.radius(1)};
height: min(705px, 70vw);
min-height: ${theme.spacing(80)};
@@ -29,41 +36,344 @@ const VisualContainer = styled.div`
}
`;
-const StyledIframe = styled(LazyEmbed)`
- border: none;
- height: 200%;
- left: 51.5%;
- mix-blend-mode: lighten;
+const GlbMount = styled.div`
+ display: block;
+ height: 100%;
+ inset: 0;
+ min-width: 0;
position: absolute;
- top: 50%;
- transform: translate(-50%, -50%);
- width: 200%;
+ width: 100%;
`;
-const HueOverlay = styled.div`
- background-color: ${theme.colors.highlight[100]};
- inset: 0;
- mix-blend-mode: hue;
- pointer-events: none;
- position: absolute;
+const retroVertexShader = /* glsl */ `
+ varying vec3 vLocalPosition;
+ varying vec3 vWorldPosition;
+
+ void main() {
+ vLocalPosition = position;
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPosition.xyz;
+ gl_Position = projectionMatrix * viewMatrix * worldPosition;
+ }
+`;
+
+const retroFragmentShader = /* glsl */ `
+ uniform vec3 uColor;
+ uniform vec2 uDigitCenterXY;
+ uniform vec2 uDigitRadiusXY;
+ uniform float uDigitZMin;
+ uniform float uStripeScale;
+
+ varying vec3 vLocalPosition;
+ varying vec3 vWorldPosition;
+
+ void main() {
+ vec2 delta =
+ (vLocalPosition.xy - uDigitCenterXY) / max(uDigitRadiusXY, vec2(0.0001));
+ float inDigitXY = 1.0 - smoothstep(0.88, 1.42, length(delta));
+ float inDigitZ = smoothstep(uDigitZMin - 2.5, uDigitZMin + 1.2, vLocalPosition.z);
+
+ float digitMask = clamp(inDigitXY * mix(0.55, 1.0, inDigitZ), 0.0, 1.0);
+
+ if (digitMask > 0.62) {
+ discard;
+ }
+
+ // Left-to-right gradient based on world X
+ float xGrad = smoothstep(-1.2, 1.2, vWorldPosition.x);
+
+ // Horizontal stripes based on world Y
+ float y = vWorldPosition.y * uStripeScale;
+ float cell = fract(y);
+
+ float lineWidth = mix(0.85, 0.0, xGrad);
+ float edge = 0.04;
+ float band = 1.0 - smoothstep(lineWidth, lineWidth + edge, cell);
+
+ // Dash effect increases from left to right
+ float dashPhase = vWorldPosition.x * 25.0 + vWorldPosition.y * 12.0;
+ float dash = fract(dashPhase);
+
+ float dashStrength = smoothstep(0.1, 0.9, xGrad);
+
+ float dashMask = mix(
+ 1.0,
+ smoothstep(0.1, 0.3, dash) * (1.0 - smoothstep(0.4, 0.9, dash)),
+ dashStrength
+ );
+
+ // Add speckle noise for the retro feel
+ float speckle = fract(sin(dot(vWorldPosition.xy, vec2(12.9898, 78.233))) * 43758.5453);
+ float speckleMask = mix(1.0, step(0.3, speckle), dashStrength * 0.8);
+
+ band *= dashMask * speckleMask;
+
+ if (band < 0.05) {
+ discard;
+ }
+
+ gl_FragColor = vec4(uColor, 1.0);
+ }
`;
+function disposeObjectSubtree(root: THREE.Object3D) {
+ root.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+ sceneObject.geometry?.dispose();
+ const material = sceneObject.material;
+ if (Array.isArray(material)) {
+ material.forEach((item) => item.dispose());
+ } else {
+ material?.dispose();
+ }
+ });
+}
+
+function createRetroScreenStripeMaterial() {
+ return new THREE.ShaderMaterial({
+ uniforms: {
+ uColor: { value: new THREE.Color('#000000') },
+ uDigitCenterXY: { value: new THREE.Vector2(0, 0) },
+ uDigitRadiusXY: { value: new THREE.Vector2(1, 1) },
+ uDigitZMin: { value: 0 },
+ uStripeScale: { value: STEP_VISUAL_STRIPE_SCALE },
+ },
+ vertexShader: retroVertexShader,
+ fragmentShader: retroFragmentShader,
+ transparent: true,
+ depthWrite: true,
+ depthTest: true,
+ side: THREE.DoubleSide,
+ });
+}
+
+function applyRetroScreenStripeMaterials(modelRoot: THREE.Object3D) {
+ modelRoot.traverse((sceneObject) => {
+ if (!(sceneObject instanceof THREE.Mesh)) {
+ return;
+ }
+
+ const geometry = sceneObject.geometry;
+ if (!geometry.getAttribute('position')) {
+ return;
+ }
+
+ geometry.computeBoundingBox();
+ const box = geometry.boundingBox;
+ if (!box) {
+ return;
+ }
+
+ const centerX = (box.min.x + box.max.x) / 2;
+ const centerY = (box.min.y + box.max.y) / 2;
+ const sizeX = box.max.x - box.min.x;
+ const sizeY = box.max.y - box.min.y;
+ const sizeZ = box.max.z - box.min.z;
+
+ const material = createRetroScreenStripeMaterial();
+ material.uniforms.uDigitCenterXY.value.set(centerX, centerY);
+ material.uniforms.uDigitRadiusXY.value.set(
+ Math.max(sizeX * 0.135, 0.01),
+ Math.max(sizeY * 0.105, 0.01),
+ );
+ material.uniforms.uDigitZMin.value = box.max.z - sizeZ * 0.14;
+
+ sceneObject.material = material;
+ });
+}
+
type VisualProps = {
illustration: IllustrationType;
};
export function Visual({ illustration }: VisualProps) {
+ const glbMountReference = useRef<HTMLDivElement>(null);
+
+ useLayoutEffect(() => {
+ const container = glbMountReference.current;
+ if (!container) {
+ return;
+ }
+
+ let cancelled = false;
+ let animationFrameId = 0;
+
+ let modelHalfX = 0.55;
+ let modelHalfY = 0.55;
+
+ const scene = new THREE.Scene();
+ const width = container.clientWidth;
+ const height = container.clientHeight;
+ const aspect = width / Math.max(height, 1);
+
+ const camera = new THREE.OrthographicCamera(
+ -aspect,
+ aspect,
+ 1,
+ -1,
+ 0.1,
+ 100,
+ );
+ camera.position.set(0, 0, 10);
+ camera.lookAt(0, 0, 0);
+
+ const updateOrthoFrustum = () => {
+ const w = container.clientWidth;
+ const h = Math.max(container.clientHeight, 1);
+ const asp = w / h;
+ const halfH = Math.max(modelHalfY, modelHalfX / asp);
+ const halfW = halfH * asp;
+ camera.left = -halfW;
+ camera.right = halfW;
+ camera.top = halfH;
+ camera.bottom = -halfH;
+ camera.updateProjectionMatrix();
+ };
+
+ updateOrthoFrustum();
+
+ const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ renderer.setSize(width, height);
+ renderer.setClearColor(0x000000, 0);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+
+ const canvas = renderer.domElement;
+ canvas.style.cursor = 'crosshair';
+ canvas.style.display = 'block';
+ canvas.style.height = '100%';
+ canvas.style.width = '100%';
+ container.appendChild(canvas);
+
+ const clock = new THREE.Clock();
+
+ const pivot = new THREE.Group();
+ scene.add(pivot);
+
+ let targetRotationX = 0;
+ let targetRotationY = 0;
+
+ const syncResolutionUniforms = () => {
+ const rw = canvas.width;
+ const rh = canvas.height;
+ pivot.traverse((sceneObject) => {
+ if (
+ sceneObject instanceof THREE.Mesh &&
+ sceneObject.material instanceof THREE.ShaderMaterial &&
+ sceneObject.material.uniforms.uResolution
+ ) {
+ sceneObject.material.uniforms.uResolution.value.set(rw, rh);
+ }
+ });
+ };
+
+ syncResolutionUniforms();
+
+ const loader = new GLTFLoader();
+ loader.load(illustration.src, (gltf) => {
+ if (cancelled) {
+ disposeObjectSubtree(gltf.scene);
+ return;
+ }
+
+ const modelRoot = gltf.scene;
+ const bounds = new THREE.Box3().setFromObject(modelRoot);
+ const center = bounds.getCenter(new THREE.Vector3());
+ const size = bounds.getSize(new THREE.Vector3());
+ const maxAxis = Math.max(size.x, size.y, size.z, 0.001);
+
+ const scale = STEP_VISUAL_MODEL_SCALE / maxAxis;
+
+ modelRoot.position.sub(center);
+ modelRoot.scale.setScalar(scale);
+ modelRoot.rotation.set(0, -0.2, -0.2);
+
+ applyRetroScreenStripeMaterials(modelRoot);
+
+ pivot.add(modelRoot);
+
+ const fitBox = new THREE.Box3().setFromObject(pivot);
+ const fitSize = new THREE.Vector3();
+ fitBox.getSize(fitSize);
+ const fitPad = 1.1;
+ modelHalfX = (fitSize.x * fitPad) / 2;
+ modelHalfY = (fitSize.y * fitPad) / 2;
+
+ updateOrthoFrustum();
+ syncResolutionUniforms();
+
+ const renderFrame = () => {
+ if (cancelled) {
+ return;
+ }
+
+ animationFrameId = window.requestAnimationFrame(renderFrame);
+ const time = clock.getElapsedTime();
+
+ pivot.position.y = Math.sin(time * 1.2) * 0.025;
+
+ pivot.rotation.x += (targetRotationX - pivot.rotation.x) * 0.06;
+ pivot.rotation.y += (targetRotationY - pivot.rotation.y) * 0.06;
+
+ renderer.render(scene, camera);
+ };
+
+ renderFrame();
+ });
+
+ const handlePointerMove = (event: PointerEvent) => {
+ const rect = canvas.getBoundingClientRect();
+ const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
+ const y = -(((event.clientY - rect.top) / rect.height) * 2 - 1);
+
+ targetRotationY = x * 0.1;
+ targetRotationX = y * 0.08;
+ };
+
+ const handlePointerLeave = () => {
+ targetRotationX = 0;
+ targetRotationY = 0;
+ };
+
+ const handleResize = () => {
+ if (!container || cancelled) {
+ return;
+ }
+ const nextWidth = container.clientWidth;
+ const nextHeight = container.clientHeight;
+ renderer.setSize(nextWidth, nextHeight);
+ updateOrthoFrustum();
+ syncResolutionUniforms();
+ };
+
+ canvas.addEventListener('pointermove', handlePointerMove);
+ canvas.addEventListener('pointerleave', handlePointerLeave);
+ window.addEventListener('resize', handleResize);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener('resize', handleResize);
+ canvas.removeEventListener('pointermove', handlePointerMove);
+ canvas.removeEventListener('pointerleave', handlePointerLeave);
+ window.cancelAnimationFrame(animationFrameId);
+ disposeObjectSubtree(scene);
+ renderer.dispose();
+ if (canvas.parentNode === container) {
+ container.removeChild(canvas);
+ }
+ };
+ }, [illustration.src]);
+
return (
<VisualColumn>
<VisualContainer>
- <StyledIframe
- allow="clipboard-write; encrypted-media; gyroscope; web-share"
- allowFullScreen
- referrerPolicy="strict-origin-when-cross-origin"
- src={illustration.src}
- title={illustration.title}
+ <GlbMount
+ aria-label={illustration.title}
+ ref={glbMountReference}
+ role="img"
/>
- <HueOverlay aria-hidden="true" />
</VisualContainer>
</VisualColumn>
);