threejs-fundamentals
Agent skill fromCloudAI-X/threejs-skills
Three.js scene setup: scenes and fog, cameras, the renderer and tone mapping, the animation loop, object hierarchies, transforms, core math and cleanup, on WebGL or with WebGPU and TSL. Use when creating a scene from scratch, configuring a camera or renderer, handling resize, or arranging objects.
How to install threejs-fundamentals
install threejs-fundamentals
# install the threejs-skills pack with the skills CLI
npx skills add CloudAI-X/threejs-skills# or add only this skill to Claude Code: copy the folder
skills/threejs-fundamentals/
# into
~/.claude/skills/threejs-fundamentals/ (all projects)
.claude/skills/threejs-fundamentals/ (one project)
1# Three.js Fundamentals23Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.45## Quick Start67```javascript8import * as THREE from "three";910const renderer = new THREE.WebGLRenderer({ antialias: true });11renderer.setPixelRatio(window.devicePixelRatio);12renderer.setSize(window.innerWidth, window.innerHeight);13document.body.appendChild(renderer.domElement);1415const scene = new THREE.Scene();16scene.background = new THREE.Color(0x111318);1718const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);19camera.position.set(0, 1.5, 5);2021const cube = new THREE.Mesh(22 new THREE.BoxGeometry(1, 1, 1),23 new THREE.MeshStandardMaterial({ color: 0x3a86ff }),24);25scene.add(cube);26const light = new THREE.DirectionalLight(0xffffff, 2);27light.position.set(3, 4, 5); // shines from its position toward the origin28scene.add(light);29scene.add(new THREE.AmbientLight(0xffffff, 0.4));3031const timer = new THREE.Timer();32timer.connect(document); // freezes the delta while the tab is hidden3334function animate() {35 timer.update(); // advance the timer first thing each frame36 cube.rotation.y += timer.getDelta(); // seconds since the previous frame37 renderer.render(scene, camera);38}39renderer.setAnimationLoop(animate);4041window.addEventListener("resize", () => {42 camera.aspect = window.innerWidth / window.innerHeight;43 camera.updateProjectionMatrix();44 renderer.setSize(window.innerWidth, window.innerHeight);45});46```47…
Excerpt shown under the repository's MIT license.
