web3d-integration-patterns

Provides architecture patterns for integrating Three.js, GSAP, React Three Fiber, Motion, and React Spring.

1|Updated Aug 20, 2023
One-click install
npx skills add https://github.com/imanlangaran/mini-projects --skill web3d-integration-patterns-imanlangaran
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: web3d-integration-patterns
Source: https://github.com/imanlangaran/mini-projects/tree/main/react/three-gsap/.claude/skills/web3d-integration-patterns
Command: npx skills add https://github.com/imanlangaran/mini-projects --skill web3d-integration-patterns-imanlangaran

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building complex 3D web experiences often requires combining multiple rendering and animation libraries, which leads to architecture confusion, animation conflicts, state synchronization bugs, and performance issues. This Skill provides proven integration patterns, decision frameworks, and working code examples for combining Three.js, GSAP ScrollTrigger, React Three Fiber, Motion, and React Spring. ## Core Features & Use Cases - Architecture Patterns: Four core patterns including layered separation (Three.js + GSAP + React UI), unified React components (R3F + Motion), hybrid GSAP timelines in R3F, and physics-based interactions with React Spring. - State Management Strategies: Zustand-based patterns for synchronizing state between 3D scenes and React UI layers. - Performance Optimization: Techniques for coordinating render loops, on-demand rendering with frameloop="demand", and avoiding animation conflicts between libraries. - Use Case: When building a scroll-driven product landing page, use the Three.js + GSAP pattern to animate camera paths with ScrollTrigger while React handles the UI overlay with Motion transitions. ## Quick Start Ask the AI to help you architect a scroll-driven 3D landing page that combines Three.js rendering with GSAP ScrollTrigger animations and a React UI overlay.

Frequently Asked Questions about web3d-integration-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I combine Three.js with GSAP ScrollTrigger for scroll-driven animations?

Register ScrollTrigger with GSAP, then animate Three.js object properties like camera.position or mesh.rotation inside gsap.to() calls with a scrollTrigger config using scrub. Initialize the Three.js scene separately and pass its references to the animation setup function.

React Three Fiber vs plain Three.js: which should I use for my project?

Use React Three Fiber for React-first applications needing declarative components, unified state management, and reusability. Use plain Three.js with GSAP for marketing pages with heavy scroll orchestration or high-performance particle systems requiring imperative control.

Can I use GSAP and React Spring together in the same 3D scene?

Yes, but avoid animating the same property with both libraries simultaneously, as this causes conflicts. Assign each library distinct properties, for example GSAP handles position while React Spring handles scale, or coordinate their timing explicitly.

How do I synchronize React state with Three.js scene objects?

Use Zustand for global state shared between the 3D scene and UI, storing selections, camera modes, and object references. Update both the Three.js object and the store together, and subscribe components to store slices to trigger GSAP animations on state changes.

Why do my GSAP animations cause memory leaks in React Three Fiber?

Memory leaks occur when GSAP tweens or timelines are not killed on component unmount. Always store the tween reference and call tween.kill() or tl.kill() inside the useEffect cleanup function to dispose of running animations.

How do I improve performance when combining multiple animation libraries?

Use on-demand rendering with frameloop="demand" in React Three Fiber and call invalidate() only when state changes. For imperative setups, coordinate a single render loop with a needsRender flag triggered by ScrollTrigger updates instead of rendering every frame.