Three Js Gsap Guide
Three Js Gsap Guide
Three Js Gsap Guide
Three JS and
GSAP Guide
Created by JS Mastery
The Ultimate
Next 14 Course
than jQuery!
1. NPM
2. CDN
<script
src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12....
integrity="sha512-EZI2cBcGPnmR89wTgVnN3602Yyi7muWo8say...
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
Make sure to place this script tag before the script tag
containing your local JS file. This ensures that your
local file has access to the GSAP library and its
functionality.
notice that in the new version, GSAP 3.0, they have all
everything in GSAP.
It's like a toolbox filled with all the tools you need to
method
target
vars
The method(s)
There are four types of tweens:
gsap.to()
his is the most common type of tween. A to() tween
starts at the element's current state and animates "to"
the values defined in the tween.
gsap.from()
This is similar to a backwards to() tween. It animates
"from" the values defined in the tween and ends at the
element's current state.
gsap.set()
This method immediately sets properties without any
animation. It's essentially a zero-duration to() tween.
// Using a class or ID
// Using a variable
The variables
x: 200,
rotation: 360,
duration: 2,
});
default).
synchronized.
method:
gsap.timeline()
anything on-the-fly.
var tl = gsap.timeline();
gsap object.
specific Timeline.
// Sequenced one-after-the-other
npm start
gsap.registerPlugin(useGSAP);
useGSAP(
() => {
},
{ scope: container }
);
return (
<div className="box">Hello</div>
</div>
);
gsap.registerPlugin(useGSAP);
useGSAP(
() => {
},
{ scope: container }
and efficiently.
behavior.
differently:
gsap.registerPlugin(MotionPathPlugin, ScrollTrigger);
animate a box:
gsap.to(".box", {
scrollTrigger: ".box",
x: 500,
});
Filer
https://www.filer.dev/3d-models/1
MorphSVG Showcase
https://codepen.io/collection/naMaNQ
DrawSVG Showcase
https://codepen.io/collection/DYmKKD
Cassie Evans
https://codepen.io/cassie-codes
Blake Bowen
https://codepen.io/osublake
Craig Roblewsky
https://codepen.io/PointC/
Darin Senneff
https://codepen.io/dsenneff
Chris Gannon
https://codepen.io/chrisgannon
Carl Schooff
https://codepen.io/snorkltv
Pete Barr
https://codepen.io/petebarr
Steve Gardner
https://codepen.io/ste-vg
Ryan Mulligan
https://codepen.io/hexagoncircle
Cameron Knight
https://codepen.io/cameronknight
Tom Miller
https://codepen.io/creativeocean
Explore plugins
GSAP has extra tools you can add to make your
animations even cooler. For example, SplitText lets you
animate text in unique ways, and ScrollTrigger lets you
create animations that happen when you scroll down
a webpage. These plugins can add extra flair to your
animations without much extra work.
animations if needed.
smoothly everywhere.
Geometry
Geometry defines the shape and structure of an
object in Three.js.
Camera
A camera determines the perspective and position of
the viewer in the scene. The PerspectiveCamera and
OrthographicCamera classes are used to create
cameras. The PerspectiveCamera simulates a
perspective view, while the OrthographicCamera
simulates an isometric view.
Scene
A scene is the container that holds all of the objects,
lights, and cameras in Three.js. In order to render
anything in Three.js, you must create a scene and add
objects, lights, and cameras to it.
Animation
Animation is the process of creating movement or
change in a 3D scene over time. In Three.js, animation
is achieved using the requestAnimationFrame method
to update the position, rotation, or scale of objects in
the scene.
applications or 2D games.
3D scenes.
Basic Geometries
Three.js provides a set of built-in basic geometries
that you can use to create common shapes such as
cubes, spheres, cylinders, planes, and toruses.
SphereGeometry
Generates a spherical geometry with a specified
radius and number of segments for smoothness.
PlaneGeometry
Represents a flat, rectangular plane with specified
width and height.
Custom Geometries
In addition to basic geometries, you can create
custom geometries by defining the vertices and faces
manually. This allows you to create more complex
shapes and structures that are not provided by the
built-in geometries.
model of a product.
The model may have multiple parts, each with its own
pure Three.js:
Familiar syntax:
Component-based architecture:
Debugging tools:
TypeScript support:
code in React.
Drei library:
applications in React.
<mesh>
A component that wraps a 3D object and its material.
<primitive>
A component that creates a Three.js primitive
geometry, like a box or sphere.
<group>
A component that allows you to group objects
together for easier manipulation.
useFrame()
A hook that runs on every frame of the animation loop,
allowing you to update Three.js objects over time.
useGraph()
Convenience hook which creates a memoized, named
object/material collection from any Object 3D.
<perspectiveCamera>
A component that defines a perspective camera for
your scene.
intuitive interface.
common 3D tasks.
OrbitControls component:
useTexture hook:
material.
Html component:
Component-based architecture:
Drei uses React's component-based architecture,
which makes it easier to organize and manage the
state and lifecycle of 3D objects in a scene.
Performance optimizations:
React Three Drei includes performance optimizations
such as automatic batching of meshes and pre-
loading of assets, which can help improve the overall
performance of a 3D application.
Code reusability:
React Three Drei over pure Three.js is that it can help
reduce code complexity & increase code reusability.
<OrbitControls>
A pre-built camera controller that allows users to pan,
zoom, and orbit around the 3D scene
<Html>
A component that allows you to render HTML elements
in a Three.js scene.
<Text>
A component that allows you to render 3D text in a
Three.js scene.
<Line>
A component that creates a 3D line mesh.
<Sphere>
A component that creates a 3D sphere mesh.
<Plane>
A component that creates a 3D plane mesh.
useTexture
A hook that loads a texture and returns a Three.js
texture object.
useGLTF
A hook that loads a GLTF model and returns a Three.js
object.
RTD Cheat Sheet
3D Text:
Create 3D text using Three.js and experiment with
different fonts, sizes, and colors to make it visually
interesting.
Particle Effects:
Create particle effects using Three.js and experiment
with different settings to make visually appealing
effects, such as explosions, fire, or rain.
3D Terrain:
Create a 3D terrain using Three.js and experiment with
different textures, heights, and shapes to create a
dynamic landscape.
3D Card Flip:
Create a simple card-flipping animation using
Three.js to showcase your understanding of basic 3D
transformations and animations.
3D Interactive Dice:
Build a 3D dice that users can roll and interact with
using Three.js, using basic geometry and materials to
create a realistic effect.
Animation
over time.
Physics
Textures
Optimization
devices.
3D Data Visualization
Create immersive visualizations of complex data sets
using Three.js. This could include anything from
financial data to scientific data, presented in a visually
appealing and interactive 3D format.
Particle Effects
Experiment with particle systems in Three.js to create
mesmerizing effects like fire, smoke, water, or dynamic
particle-based animations.
Educational Simulations
Develop interactive educational simulations for
subjects like physics, chemistry, or biology. For eg, you
could create a simulation demonstrating gravitational
forces or molecular structures.
Interactive Storytelling
Combine 3D graphics with storytelling elements to
create immersive interactive narratives. Users can
navigate through the story world, interact with
characters, & make choices that affect the outcome.
Educational Simulations
Develop interactive educational simulations for
subjects like physics, chemistry, or biology. For eg, you
could create a simulation demonstrating gravitational
forces or molecular structures.
Weather Visualization
Create a dynamic 3D visualization of weather patterns
and phenomena such as clouds, rainfall, and storms.
Users can interact with the simulation to understand
weather dynamics.
3D Fractal Explorer
Implement a fractal explorer that allows users to
navigate and interact with 3D fractal structures in
real-time. Fractals are visually stunning and provide
endless exploration possibilities.
Sketchfab
https://sketchfab.com/
Poly Pizza
https://poly.pizza/
PMNDRS Market
https://market.pmnd.rs/
Filer
https://www.filer.dev/3d-models/1
Clara
https://clara.io/library
Pikbest
pikbest.com/decors-models/3d-models
CG Trader
https://www.cgtrader.com/3d-models/
Grabcad
https://grabcad.com/library
Autodesk Community
https://autodesk.com/community/gallery
Freepik
https://www.freepik.com/3d-models
RenderCrate
https://rendercrate.com/
Free 3D
https://free3d.com/
3dsky
https://3dsky.org/3dmodels
Thingiverse
https://www.thingiverse.com/
Cults
https://cults3d.com/
Turbosquid
https://www.turbosquid.com/
Design Connected
https://designconnected.com/Freebies/
Archive 3d
https://archive3d.net/
3d Export
https://3dexport.com/free-3d-models
Cadnav
https://www.cadnav.com/3d-models/
All 3d Free
https://www.all3dfree.net/
3DXO
https://www.3dxo.com/textures
Sketchup Texture
https://sketchuptextureclub.com/