threejs-fundamentals

Configure Three.js scenes, cameras, renderers, and Object3D hierarchies for 3D web applications.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill threejs-fundamentals-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-fundamentals
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/threejs-fundamentals
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill threejs-fundamentals-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires three.

What problem does it solve? Setting up a Three.js scene involves many interdependent pieces—cameras, renderers, lights, object hierarchies, and math utilities—and getting any of them wrong leads to blank screens, distorted views, or memory leaks. This Skill provides working code patterns and API references so you can build correct 3D scenes without digging through documentation. ## Core Features & Use Cases - Scene and Renderer Setup: Ready-to-use patterns for WebGLRenderer configuration including tone mapping, color spaces, shadow maps, and responsive canvas resizing. - Camera and Object3D Reference: Covers PerspectiveCamera, OrthographicCamera, CubeCamera, and the full Object3D transform and hierarchy API. - Math Utilities and Performance: Vector3, Matrix4, Quaternion, and Color operations plus cleanup, clock-based animation, LOD, and geometry merging patterns. - Use Case: You are building an interactive 3D product viewer in a Next.js app and need a correctly configured scene with lighting, shadows, and resize handling—this Skill gives you the complete working setup. ## Quick Start Set up a Three.js scene with a perspective camera, lighting, an animated rotating cube, and window resize handling.

Frequently Asked Questions about threejs-fundamentals

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

FAQPage Schema
How do I set up a basic Three.js scene with camera and renderer?

Create a THREE.Scene, a PerspectiveCamera with fov, aspect ratio, and near/far planes, and a WebGLRenderer with antialias enabled. Set the renderer size and pixel ratio, append its DOM element to the page, then call renderer.render(scene, camera) inside a requestAnimationFrame loop.

What is the difference between PerspectiveCamera and OrthographicCamera in Three.js?

PerspectiveCamera simulates human vision with depth-based foreshortening and is the most common choice. OrthographicCamera has no perspective distortion, making it suitable for 2D interfaces, isometric views, and technical diagrams.

How do I handle window resize in Three.js?

Add a resize event listener that updates camera.aspect with the new width-to-height ratio, calls camera.updateProjectionMatrix(), and resizes the renderer with renderer.setSize. Also reapply the pixel ratio clamped with Math.min(window.devicePixelRatio, 2).

Why does my Three.js app leak memory when removing objects?

Removing a mesh from the scene does not free its GPU resources. You must explicitly call dispose() on geometries, materials, and textures, then remove the object from the scene and dispose the renderer when finished.

How do I make Three.js animation speed consistent across framerates?

Use THREE.Clock and multiply movement by clock.getDelta(), which returns seconds elapsed since the last frame. This makes rotation and movement speed independent of the display refresh rate.

How do I reduce draw calls in a Three.js scene?

Merge static geometries using mergeGeometries from BufferGeometryUtils, use instancing for repeated objects, and apply texture atlases. You can also use THREE.LOD to swap in lower-detail meshes at greater distances.