threejs-interaction
Picking with raycasting, camera controls, transform gizmos, drag, hover and box selection for three.js, identical under WebGL and WebGPU.
Skill by CloudAI-X
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/cloudai-x-threejs-interaction
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend-development
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/threejs-interaction
What's inside
- Skill name
threejs-interaction- Description
- 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.
- License
- MIT
- Instructions
- 497 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Three.js Interaction
Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.
## Quick Start
```javascript
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x111318);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 1.5, 5);
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
new THREE.MeshStandardMaterial({ color: 0x3a86ff }),
);
scene.add(mesh);
const light = new THREE.DirectionalLight(0xffffff, 2);
light.position.set(3, 5, 4);
scene.add(light, new THREE.AmbientLight(0xffffff, 0.4));
const controls = new OrbitControls(camera, renderer.domElement); // connects itself
controls.enableDamping = true; // requires controls.update() every frame
const timer = new THREE.Timer();
timer.connect(document); // freezes the delta while the tab is hidden
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function setPointer(event) {
// NDC coordinates relative to the canvas, so the page can scroll or embed it
const rect = renderer.domElement.getBoundingClientRect();
pointer.set(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1,
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObject(mesh); // also tests children (recursive by default), as a loaded model needs
if (hits.length > 0) console.log("clicked", hits[0].object);
});
function animate() {
timer.update();
controls.update(timer.getDelta());
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
```
Pointer events (`pointerdown`, `pointermove`, `pointerup`) cover mouse, touch and pen in one listener set, so no separate touch handlers are needed.
## Raycasting
Faces pointing away from the ray origin are not hit; set `material.side = THREE.DoubleSide` to catch both sides. A ray that grazes an edge shared by two faces can produce two coincident hits. Invisible meshes are still raycast — the Raycaster tests layers, not visibility — so an invisible simple proxy can stand in for a complex model.
### What an intersection contains
```javascript
const raycaster = new THREE.Raycaster();
const clickables = [mesh]; // the smallest list you can: the meshes, not scene.children
const hits = raycaster.intersectObjects(clickables, false); // sorted, closest first
// Each hit:
// {
// distance: number, // from the ray origin, world units
// point: THREE.Vector3, // hit point in world space
// face: { a, b, c, normal, materialIndex }, // plain object; a, b, c are vertex indices; normal in object space
// faceIndex: number,
// object: THREE.Object3D,
// uv: THREE.Vector2, // undefined when the geometry has no uv
// uv1: THREE.Vector2, // second UV set, when the geometry has one
// normal: THREE.Vector3, // interpolated vertex normal in object space, flipped to face the ray
// barycoord: THREE.Vector3, // barycentric coordinates of the hit point
// instanceId: number, // set on InstancedMesh hits
// batchId: number, // set on BatchedMesh hits
// distanceToRay: number // set on Points hits
// }
```
### Raycaster configuration
```javascript
const raycaster = new THREE.Raycaster();
// From any origin and direction (normalize the direction first)
raycaster.set(new THREE.Vector3(0, 2, 0), new THREE.Vector3(1, 0, 0).normalize());
// Range: hits closer than near or farther than far are discarded
raycaster.near = 0.1;
raycaster.far = 10;
// Precision for Points and Line, in world units (both default to 1)
raycaster.params.Points.threshold = 0.2;
raycaster.params.Line.threshold = 0.2;
// Restrict picking to layer 1. Objects join with enable; set would also remove
// them from layer 0, where the default camera looks, so use set only on a pick-only proxy.
mesh.layers.enable(1); // stays on layer 0 too, so the camera still renders the mesh
raycaster.layers.set(1); // tests layer 1 only; raycaster.layers.enable(1) would test layers 0 and 1
```
### Dragging on a plane
```javascript
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();From CloudAI-X/threejs-skills, MIT.
More from CloudAI-X/threejs-skills
- 0.840score
threejs-react-three-fiber
CloudAI-X
Building three.js scenes from React with React Three Fiber and drei: renderer setup, the scene graph as JSX, frame-loop, state and loading hooks, pointer…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-textures
CloudAI-X
Three.js textures: image loading, color spaces, UV channels and transforms, texture types from canvas to HDR and KTX2, render targets, texture memory.
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-shaders
CloudAI-X
Custom GLSL vertex and fragment shaders: uniforms, varyings, shader chunks, extending built-in materials, instanced attributes, plus the same effects as node…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-postprocessing
CloudAI-X
Three.js post-processing: composer pass chains, built-in renderer effects, and the WebGPU/TSL node pipeline — bloom, depth of field, ambient occlusion, custom…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-performance
CloudAI-X
Measuring and optimizing three.js speed: render statistics, memory counters, fewer draw calls via merging, instancing, batching and LOD, fill rate, shadows…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-materials
CloudAI-X
Choosing and configuring three.js materials - unlit, diffuse, specular, PBR, toon, point and line materials - shared properties like blending and stencil…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-loaders
CloudAI-X
Loading three.js assets: glTF with Draco, meshopt and KTX2 compression, other model formats, textures, HDR and EXR environments, progress, caching, cloning…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-lighting
CloudAI-X
Light types and physical units, shadow maps, HDR environment lighting, light probes, and lighting performance, on WebGL or with WebGPU and TSL.
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-geometry
CloudAI-X
Creating and shaping three.js geometry: built-in shapes, 3D text, vertex buffers and attributes, merging, instancing, batching, point clouds and lines, on…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-fundamentals
CloudAI-X
Three.js scene setup: scenes and fog, cameras, the renderer and tone mapping, the animation loop, object hierarchies, transforms, core math and cleanup, on…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-asset-pipeline
CloudAI-X
Shrinking glTF assets for three.js with gltf-transform: inspect, validate and optimize commands, Draco, meshopt and quantization, KTX2, WebP and AVIF…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-animation
CloudAI-X
Keyframe, skeletal and morph-target animation, procedural motion and clip blending, on WebGL or with WebGPU and TSL.
SkillAFreshness: A★ 3.7KClaude Code +9
Signals
- Stars
- 3,708
- Forks
- 428
- Open issues
- 0
- Last commit (this folder)
- Oct 19, 2026 (9 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/CloudAI-X/threejs-skills
- Website
- x.com/cloudxdev
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from CloudAI-X
- 0.840score
threejs-react-three-fiber
CloudAI-X
Building three.js scenes from React with React Three Fiber and drei: renderer setup, the scene graph as JSX, frame-loop, state and loading hooks, pointer…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-textures
CloudAI-X
Three.js textures: image loading, color spaces, UV channels and transforms, texture types from canvas to HDR and KTX2, render targets, texture memory.
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-shaders
CloudAI-X
Custom GLSL vertex and fragment shaders: uniforms, varyings, shader chunks, extending built-in materials, instanced attributes, plus the same effects as node…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-postprocessing
CloudAI-X
Three.js post-processing: composer pass chains, built-in renderer effects, and the WebGPU/TSL node pipeline — bloom, depth of field, ambient occlusion, custom…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-performance
CloudAI-X
Measuring and optimizing three.js speed: render statistics, memory counters, fewer draw calls via merging, instancing, batching and LOD, fill rate, shadows…
SkillAFreshness: A★ 3.7KClaude Code +9 - 0.840score
threejs-materials
CloudAI-X
Choosing and configuring three.js materials - unlit, diffuse, specular, PBR, toon, point and line materials - shared properties like blending and stencil…
SkillAFreshness: A★ 3.7KClaude Code +9
Cite this page
threejs-interaction skill. Agent Mart. https://agentmart.dev/skills/cloudai-x-threejs-interaction (last updated 2026-10-24)