A procedural product model
The Fresh Can model is generated in code rather than loaded from a file. The can’s body is a lathe profile based on a standard 330 ml can (66 × 122 mm), and other formats scale that body. The liquid is a separate mesh whose level is a single parameter, which is what lets scroll “drain” the can. Building it procedurally kept the 3D payload to code instead of a multi-megabyte model file.
Sharing one WebGL canvas
The format cards (250, 330 and 500 ml) share one WebGL canvas with multiple render slots instead of creating three renderers. WebGL contexts are a limited resource on mobile browsers, and one context means one set of GPU resources to manage and dispose.
Loading 3D without slowing the page
- The 3D module is lazy-loaded; the page renders its content and imagery first.
- A static image stands in until the scene is ready, and permanently if WebGL is unavailable.
- Under
prefers-reduced-motion, the can stays still. - Resources are explicitly disposed when a section unmounts.
// Illustrative: level-driven liquid, the core of a scroll-linked "drain"
export function setLevel(level: number) {
const h = THREE.MathUtils.clamp(level, 0, 1) * LIQUID_MAX;
liquid.scale.y = Math.max(h, 0.001) / LIQUID_MAX;
liquid.position.y = h / 2;
}