threejs-interaction
Agent skill fromCloudAI-X/threejs-skills
Picking with raycasting, camera controls, transform gizmos, drag, hover and box selection for three.js, identical under WebGL and WebGPU. Use when handling mouse, touch or keyboard input, detecting clicks on 3D objects, adding camera controls, or making scene objects interactive.
How to install threejs-interaction
install threejs-interaction
# 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-interaction/
# into
~/.claude/skills/threejs-interaction/ (all projects)
.claude/skills/threejs-interaction/ (one project)
1# Three.js Interaction23Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.45## Quick Start67```javascript8import * as THREE from "three";9import { OrbitControls } from "three/addons/controls/OrbitControls.js";1011const renderer = new THREE.WebGLRenderer({ antialias: true });12renderer.setPixelRatio(window.devicePixelRatio);13renderer.setSize(window.innerWidth, window.innerHeight);14document.body.appendChild(renderer.domElement);1516const scene = new THREE.Scene();17scene.background = new THREE.Color(0x111318);1819const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100);20camera.position.set(0, 1.5, 5);2122const mesh = new THREE.Mesh(23 new THREE.BoxGeometry(1, 1, 1),24 new THREE.MeshStandardMaterial({ color: 0x3a86ff }),25);26scene.add(mesh);27const light = new THREE.DirectionalLight(0xffffff, 2);28light.position.set(3, 5, 4);29scene.add(light, new THREE.AmbientLight(0xffffff, 0.4));3031const controls = new OrbitControls(camera, renderer.domElement); // connects itself32controls.enableDamping = true; // requires controls.update() every frame3334const timer = new THREE.Timer();35timer.connect(document); // freezes the delta while the tab is hidden3637const raycaster = new THREE.Raycaster();38const pointer = new THREE.Vector2();3940function setPointer(event) {41 // NDC coordinates relative to the canvas, so the page can scroll or embed it42 const rect = renderer.domElement.getBoundingClientRect();43 pointer.set(44…
Excerpt shown under the repository's MIT license.
