Skip to main content

5 JavaScript & Three.js Projects for Beginners: Globe, Particles, Animation & Physics

freeCodeCamp.orgAugust 27, 20251h 25min38,528 views
32 connections·40 entities in this video→

Getting Started with Three.js

  • πŸ’‘ Three.js is a JavaScript library that simplifies creating 3D graphics for the web.
  • 🧠 The core components are the Scene (where everything exists), the Camera (your viewpoint), and the Renderer (which draws it all).
  • 🧩 Geometries define shapes, Materials define appearance, and Meshes combine both.
  • πŸš€ Lighting is crucial for realistic scenes, and Animations bring them to life.
  • πŸ—ΊοΈ A roadmap for beginners includes starting simple, learning model loading, textures, environment maps, and advanced topics like shaders and physics engines.

Applying Textures and Materials

  • 🧱 Textures are images applied to 3D models to add detail and realism.
  • 🎨 Materials have various properties like map (base color), normal map (surface detail), and roughness map (shininess).
  • πŸͺž Metalness and roughness properties significantly alter how a material interacts with light, creating effects from matte to highly reflective.
  • πŸ”„ Texture wrapping and repeating options control how textures tile on surfaces.

Building a 3D Globe

  • 🌍 This project involves creating a 3D globe with country outlines floating in space.
  • ✨ Starfields are added to the background for depth.
  • πŸ—ΊοΈ A library like three-geo is used to draw country outlines based on GeoJSON data.
  • 🌫️ Fog is applied to the scene to enhance the sense of depth, affecting the globe's lines but not the stars by default.
  • 🎨 Random colors can be applied to individual countries for a vibrant look.

Creating Particle Effects

  • ✨ A simple particle system is used to create various visual effects.
  • πŸ’¨ Smoke effects are achieved by adjusting particle velocity, size, and growth over time.
  • πŸ”₯ Fire effects can be simulated by modifying particle lifespan, size, and adding blending to the material.
  • 🌟 Sparkly dot effects involve using a circular texture, adjusting velocity, color transitions (e.g., yellow to green to black), and shrinking particle size over their life.

Scroll-Triggered Animations

  • 🎬 This project focuses on creating animations that respond to user scrolling.
  • πŸ–ΌοΈ A 3D scene is set up behind HTML content, allowing for dynamic background animations.
  • πŸ–±οΈ The scroll progress is tracked, and this value is used to control elements like the rotation of a loaded 3D model (e.g., an astronaut).
  • 🌌 Starfield positions can also be animated based on scroll progress, creating a sense of depth or movement.
  • πŸ’« Interpolation is used to smooth out animations, preventing abrupt stops when the user finishes scrolling.

Interactive Physics with Rapier

  • πŸ’₯ Rapier physics engine is integrated with Three.js for interactive simulations.
  • 🧊 Colliders are created for meshes to define their physical boundaries.
  • 🧸 Various primitive geometries (icosahedrons, spheres, boxes, etc.) and loaded GLTF models (like a duck) can be incorporated.
  • πŸ’‘ Custom colliders, such as convexHull, can be generated to precisely match complex mesh shapes, improving collision accuracy.
  • πŸ–±οΈ Mouse interactivity is enhanced using raycasting to interact with objects in the 3D scene, even when the camera is orbiting.
  • 🌈 Color palettes can be applied to objects to create visually appealing physics simulations.
Knowledge graph40 entities Β· 32 connections

How they connect

An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.

Hover Β· drag to explore
40 entities
Chapters20 moments

Key Moments

Transcript306 segments

Full Transcript

Topics13 themes

What’s Discussed

Three.jsJavaScript3D GraphicsWeb DevelopmentParticle EffectsScroll AnimationPhysics EngineRapier Physics3D GlobeTexturesMaterialsGLTF ModelsWebGL
Smart Objects40 Β· 32 links
ProductsΒ· 11
PeopleΒ· 2
ConceptsΒ· 21
MediasΒ· 3
CompaniesΒ· 3