An animated loading screen overlays the entire viewport with a solid black plane. Clicking the “click to start” prompt triggers a GPU-accelerated dissolve: a Three.jsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/hetari/creative-coding/llms.txt
Use this file to discover all available pages before exploring further.
ShaderMaterial applied to a full-screen PlaneGeometry erases the overlay outward from the center, driven by a uTransition uniform that GSAP advances from 0 to 1 over roughly 2.2 seconds. A retro Perlin-noise pixelation effect and a volumetric blue glow pulse around the dissolving edge as it expands. Once the transition completes, the loader element is hidden and the underlying page content appears.
Registry Entry
This sketch is registered insrc/config/sketches.ts as:
Tech Stack
| Layer | Tool |
|---|---|
| Composable | useGsap — provides gsap instance and useGsapContext helper |
| Renderer | Three.js WebGLRenderer with alpha: true |
| Shader | THREE.ShaderMaterial with inline vertex + fragment GLSL |
| Noise | Classic 3D Perlin noise (cnoise) — self-contained GLSL implementation |
| Animation | GSAP gsap.to() on the uTransition uniform object |
| Lifecycle | Vue onMounted / onUnmounted for renderer setup and cleanup |
Concept
Loading animations are one of the most common creative coding patterns on the web. This sketch demonstrates how to drive a WebGL shader transition entirely from GSAP, treating auniforms object as the animation target. The approach keeps animation logic in JavaScript while the GPU handles per-pixel rendering:
- State lives in
uniforms— theuTransitionvalue is a plain JavaScript number that Three.js reads each frame. - GSAP animates the number —
gsap.to(uniforms.uTransition, { value: 1.0, ... })advances the uniform smoothly without any manualrequestAnimationFramecounter. - The shader interprets the value — the fragment shader uses
uTransitionto compute a radial dissolve with noise-displaced edges and a glowing border.
Shader Uniforms
| Uniform | Type | Description |
|---|---|---|
uTransition | float | Transition progress from 0.0 (fully opaque black) to 1.0 (fully transparent). Animated by GSAP |
uResolution | vec2 | Viewport dimensions. Updated on resize via handleResize() |
uTime | float | Elapsed seconds from a THREE.Clock. Drives the pulsing glow color and noise animation |
uBorderColor | vec3 | Base glow color. Default: #3b82f6 (blue). Controls both the deep midnight tone and the rich glowing highlight |
Key Shader Patterns
Pixelation Grid
The fragment shader snaps continuous UV coordinates onto a10 × 10 pixel block grid to create a retro digital-glitch look:
Perlin Noise Displacement
The pixelated UVs are displaced by a 3D Perlin noise field before computing the dissolve, giving the edge an organic, non-circular shape:Radial Dissolve
A radial gradient from the center drives the transition boundary. The formula ensures the screen starts fully opaque and dissolves outward asuTransition rises:
Volumetric Glow Edge
Asmoothstep band around the dissolve boundary produces a wide, soft glow ring that pulses with uTime:
GSAP Animation
When the user clicks,handleStart() runs a two-part GSAP animation: the “click to start” text fades out immediately, then the transition uniform advances over 2.2 seconds:
Lifecycle & Cleanup
The Three.js renderer, geometry, and material are created ononMounted and fully disposed on onUnmounted to prevent memory leaks:
useGsap Composable
The
useGsap() composable provides a scoped gsap instance. For sketches that use ScrollTrigger or many tweens, pair it with useGsapContext() to automatically call ctx.revert() on unmount.Three.js Shader Material
THREE.ShaderMaterial with transparent: true, depthTest: false, and depthWrite: false renders an overlay plane in front of all scene geometry without interfering with depth sorting.