threejs-fundamentals

Bootstrap Three.js scenes with Scene, PerspectiveCamera, and WebGLRenderer setup.

1|Updated Dec 6, 2023
One-click install
npx skills add https://github.com/tadams95/kardashev-network --skill threejs-fundamentals-tadams95
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-fundamentals
Source: https://github.com/tadams95/kardashev-network/tree/main/.claude/skills/threejs-fundamentals
Command: npx skills add https://github.com/tadams95/kardashev-network --skill threejs-fundamentals-tadams95

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides the essential setup and patterns for creating and managing basic to intermediate Three.js scenes, enabling developers to rapidly scaffold interactive 3D content without boilerplate.

Core Features & Use Cases

  • Scene, Camera, and Renderer Setup: Create a working 3D scene with a perspective camera and a WebGL renderer.
  • Object Hierarchy & Transforms: Understand Object3D hierarchy and coordinate transforms to position and orient objects in 3D space.
  • Practical Examples: Build a rotating cube, add lighting, and compose simple scenes for interactive demos.

Quick Start

Install three.js and set up a minimal HTML page that loads a module script. Then run a local dev server and open the page to see a spinning cube. Example (no fences): npm init -y npm install three Create an index.html that imports a script:

<script type="module" src="./main.js"></script>

In main.js: import * as THREE from 'three'; const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); const geometry = new THREE.BoxGeometry(1, 1, 1); const material = new THREE.MeshStandardMaterial({ color: 0x00ff00 }); const cube = new THREE.Mesh(geometry, material); scene.add(cube); const light = new THREE.AmbientLight(0xffffff, 0.5); scene.add(light); camera.position.z = 5; function animate() { requestAnimationFrame(animate); cube.rotation.x += 0.01; cube.rotation.y += 0.01; renderer.render(scene, camera); } animate();

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 a camera and renderer?

To set up a Three.js scene, instantiate a Scene object, configure a PerspectiveCamera, and initialize a WebGLRenderer to output the 3D content to your webpage.

How do I render a rotating cube using Three.js and WebGL?

You render a rotating cube by creating a BoxGeometry and MeshStandardMaterial, adding the Mesh to your scene, and updating its rotation values inside a requestAnimationFrame loop.

What is the Object3D hierarchy for managing transforms in Three.js?

The Object3D hierarchy allows you to group 3D objects and apply coordinate transforms, enabling you to position and orient child meshes relative to their parent objects in the scene.

Does this Three.js scene setup require any external dependencies?

No external dependencies are required beyond the Three.js library itself, allowing you to quickly scaffold interactive 3D content in a web app without additional boilerplate packages.

Why are my Three.js objects completely black after adding them to the scene?

Objects appear black without lighting, so you must add an AmbientLight or other light sources to your Three.js scene to illuminate the MeshStandardMaterial.