Top Related Projects
GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
JavaScript animation engine
🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.
JavaScript/TypeScript animation engine
The motion graphics toolbelt for the web
Javascript library to create physics-based animations
Quick Overview
Frame.js is a lightweight JavaScript library for creating and managing 3D scenes and animations in web browsers. It provides a simple API for working with 3D objects, cameras, and rendering, making it easier for developers to create interactive 3D experiences without dealing with complex WebGL code directly.
Pros
- Easy to use and learn, with a straightforward API
- Lightweight and performant, suitable for web-based 3D applications
- Integrates well with other JavaScript libraries and frameworks
- Supports both canvas and WebGL rendering
Cons
- Limited documentation and examples compared to more established 3D libraries
- Smaller community and ecosystem compared to alternatives like Three.js
- May lack some advanced features found in more comprehensive 3D engines
- Not actively maintained (last commit was in 2016)
Code Examples
Creating a basic 3D scene:
var scene = new FRAME.Scene();
var camera = new FRAME.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new FRAME.Renderer();
var cube = new FRAME.Mesh(
new FRAME.BoxGeometry(1, 1, 1),
new FRAME.MeshBasicMaterial({ color: 0x00ff00 })
);
scene.add(cube);
camera.position.z = 5;
function animate() {
requestAnimationFrame(animate);
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render(scene, camera);
}
animate();
Adding lighting to the scene:
var light = new FRAME.PointLight(0xffffff, 1, 100);
light.position.set(0, 0, 10);
scene.add(light);
Handling user input:
document.addEventListener('mousemove', onMouseMove, false);
function onMouseMove(event) {
var mouseX = (event.clientX / window.innerWidth) * 2 - 1;
var mouseY = -(event.clientY / window.innerHeight) * 2 + 1;
cube.rotation.x = mouseY;
cube.rotation.y = mouseX;
}
Getting Started
-
Include the Frame.js library in your HTML file:
<script src="https://raw.githubusercontent.com/mrdoob/frame.js/master/build/frame.js"></script>
-
Create a container for your 3D scene:
<div id="container"></div>
-
Initialize the scene, camera, and renderer:
var scene = new FRAME.Scene(); var camera = new FRAME.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); var renderer = new FRAME.Renderer(); document.getElementById('container').appendChild(renderer.domElement);
-
Add objects to the scene and start rendering:
var cube = new FRAME.Mesh( new FRAME.BoxGeometry(1, 1, 1), new FRAME.MeshBasicMaterial({ color: 0x00ff00 }) ); scene.add(cube); camera.position.z = 5; function animate() { requestAnimationFrame(animate); renderer.render(scene, camera); } animate();
Competitor Comparisons
GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
Pros of GSAP
- More comprehensive animation toolkit with a wider range of features
- Extensive documentation and community support
- Cross-browser compatibility and performance optimization
Cons of GSAP
- Larger file size and potential overhead for simpler projects
- Steeper learning curve due to its extensive API
Code Comparison
Frame.js:
frame.on('update', function(time) {
cube.rotation.x += 0.01;
cube.rotation.y += 0.02;
});
GSAP:
gsap.to(cube.rotation, {
duration: 1,
x: "+=0.01",
y: "+=0.02",
repeat: -1,
ease: "linear"
});
Summary
Frame.js is a lightweight animation framework focused on simplicity and ease of use. It's ideal for basic animations and smaller projects. GSAP, on the other hand, is a more powerful and feature-rich animation library suitable for complex animations and larger-scale projects. While Frame.js offers a straightforward API, GSAP provides more advanced features and better cross-browser support at the cost of a larger file size and steeper learning curve.
JavaScript animation engine
Pros of anime
- Lightweight and flexible animation library with a simple API
- Supports a wide range of animation types (CSS properties, SVG, DOM attributes, etc.)
- Extensive documentation and examples available
Cons of anime
- Focused solely on animations, lacking broader application framework features
- May require additional libraries for complex interactive applications
- Less suitable for real-time, game-like animations compared to frame.js
Code Comparison
anime:
anime({
targets: '.element',
translateX: 250,
rotate: '1turn',
duration: 800,
easing: 'easeInOutQuad'
});
frame.js:
var element = new THREE.CSS3DObject(document.querySelector('.element'));
scene.add(element);
function animate() {
requestAnimationFrame(animate);
element.position.x += 1;
renderer.render(scene, camera);
}
animate();
Key Differences
- anime is designed for general-purpose web animations, while frame.js is more focused on 3D and WebGL-based animations
- frame.js provides a lower-level API, giving developers more control over the animation loop
- anime offers a more declarative approach to defining animations, while frame.js requires more manual management of the animation process
Use Cases
- Choose anime for simple to moderately complex web animations and transitions
- Opt for frame.js when building complex 3D scenes or game-like applications requiring fine-grained control over the rendering process
🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.
Pros of animate.css
- Easier to use with pre-defined CSS classes for animations
- Lightweight and doesn't require JavaScript
- Widely adopted and well-documented
Cons of animate.css
- Limited customization options compared to frame.js
- Animations are fixed and not easily modifiable
- Lacks advanced features like timeline control
Code Comparison
animate.css:
.animate__animated {
animation-duration: 1s;
animation-fill-mode: both;
}
.animate__bounce {
animation-name: bounce;
}
frame.js:
var animation = new FRAME.Animation()
.add( 0, function () { mesh.position.set( 0, 0, 0 ); } )
.add( 1, function () { mesh.position.set( 100, 0, 0 ); } )
.add( 2, function () { mesh.position.set( 100, 100, 0 ); } );
animate.css provides ready-to-use CSS classes for animations, making it simple to implement basic animations without JavaScript. frame.js, on the other hand, offers more granular control over animations through JavaScript, allowing for complex, programmatic animations.
While animate.css is easier to get started with and requires less code for basic animations, frame.js provides greater flexibility and control for advanced animation scenarios. The choice between the two depends on the specific requirements of the project and the desired level of animation complexity.
JavaScript/TypeScript animation engine
Pros of Tween.js
- More comprehensive and feature-rich animation library
- Supports a wider range of easing functions
- Better documentation and community support
Cons of Tween.js
- Larger file size and potentially higher overhead
- May be overkill for simple animation needs
- Less integrated with other Three.js-related projects
Code Comparison
Frame.js:
frame.add( function () {
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
} );
Tween.js:
new TWEEN.Tween(mesh.rotation)
.to({ x: Math.PI * 2, y: Math.PI * 2 }, 2000)
.easing(TWEEN.Easing.Quadratic.Out)
.start();
Summary
Frame.js is a lightweight animation framework designed for simplicity and integration with Three.js projects. It's ideal for basic animations and is closely tied to the Three.js ecosystem.
Tween.js offers a more robust animation solution with advanced features and easing functions. It's suitable for complex animations across various JavaScript projects but may be excessive for simpler needs.
Choose Frame.js for lightweight, Three.js-focused animations, and Tween.js for more complex, versatile animation requirements in broader JavaScript applications.
The motion graphics toolbelt for the web
Pros of mojs
- More comprehensive animation library with a wider range of features
- Active development and community support
- Extensive documentation and examples
Cons of mojs
- Steeper learning curve due to more complex API
- Larger file size, which may impact page load times
Code Comparison
frame.js:
var animation = new FRAME.Animation()
.add( 0, function () { console.log( 'start' ) } )
.add( 1, function () { console.log( 'end' ) } );
animation.start();
mojs:
const burst = new mojs.Burst({
radius: { 0: 100 },
count: 5,
children: {
shape: 'circle',
fill: { 'cyan' : 'yellow' },
duration: 2000
}
});
burst.play();
Key Differences
- frame.js focuses on simple, timeline-based animations
- mojs offers more complex, object-oriented animations with extensive customization
- frame.js has a smaller footprint and simpler API, making it easier to learn and integrate
- mojs provides more advanced features like shape morphing and custom easing functions
Use Cases
- frame.js: Ideal for basic, lightweight animations and simple timelines
- mojs: Better suited for complex, interactive animations and rich visual effects
Javascript library to create physics-based animations
Pros of dynamics.js
- More focused on creating dynamic animations with spring and gravity effects
- Provides a simpler API for common animation scenarios
- Smaller file size, making it more lightweight for web projects
Cons of dynamics.js
- Less flexible for complex custom animations compared to frame.js
- Limited to specific animation types (spring, gravity, etc.)
- Lacks some advanced features found in frame.js, such as timeline management
Code Comparison
dynamics.js:
dynamics.animate(element, {
translateX: 100,
scale: 2
}, {
type: dynamics.spring,
duration: 1000
});
frame.js:
var animation = new FRAME.Animation();
animation.add( new FRAME.Translation( element, 100, 0, 0 ) );
animation.add( new FRAME.Scale( element, 2, 2, 1 ) );
animation.start();
Summary
dynamics.js is better suited for quick, physics-based animations with a simple API, while frame.js offers more flexibility and control for complex animations. The choice between the two depends on the specific project requirements and the level of animation complexity needed.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
frame.js
Work in progress.
Editor
Examples
- https://framejs.org/player.html?file=examples/html_colors.json
- https://framejs.org/player.html?file=examples/threejs_cube.json
- https://framejs.org/player.html?file=examples/threejs_shaders.json
Projects
Top Related Projects
GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
JavaScript animation engine
🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.
JavaScript/TypeScript animation engine
The motion graphics toolbelt for the web
Javascript library to create physics-based animations
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot