threejs-interaction
Skill1 starsChanged 8 months agoMITView on GitHub
Three.js interaction - raycasting, controls, mouse/touch input, object selection. Use when handling user input, implementing click detection, adding camera controls, or creating interactive 3D experiences.
24 other projects use a version of this, 20 of them edited.
Adopted by
Most recently taken up by
- gromov0737/skillsedited, first seen Nov 29, 2026
- mrrajrumel/claude-video-skillstheir own version, first seen Nov 29, 2026
- Badhon-00/MDCPtheir own version, first seen Nov 16, 2026
- SnoozleStudio/opencode-wp-settingsedited, first seen Nov 15, 2026
- calesthio/OpenMontageedited, first seen Nov 9, 2026
- DaraBoth/skilljmskilltheir own version, first seen Nov 8, 2026
Used with
Projects with it also use pose-library-design, threejs-asset-pipeline and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
LinHao-citySkillpose-library-design
Design reusable 2D character pose libraries, action cycles, and expression states for data-driven animation.
Also in 4 projects that use this
CloudAI-XSkillthreejs-asset-pipeline
Shrinking glTF assets for three.js with gltf-transform: inspect, validate and optimize commands, Draco, meshopt and quantization, KTX2, WebP and AVIF textures, the loader setup each output needs, and gltfjsx for React. Use when compressing, optimizing or validating 3D models before loading them.
Also in 4 projects that use this
LinHao-citySkillvideo-toolkit
Create professional videos autonomously using claude-code-video-toolkit — AI voiceovers, image generation, music, talking heads, and Remotion rendering.
Also in 4 projects that use this
CloudAI-XSkillthreejs-react-three-fiber
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 events, and adaptive performance, on WebGL or with WebGPU and TSL. Use when writing React components that render three.js.
Also in 4 projects that use this
GopyrSkillazure-speech-to-text
Also in 3 projects that use this
GopyrSkilldashscope
Also in 3 projects that use this
- +5 more from LinHao-city
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 20
- calesthio/OpenMontage★ 84k17% same
- OpenMontageInc/OpenMontage★ 84k17% same
- educlopez/thegridcn-ui★ 40117% same
- quiet-node/gesture-lab★ 18517% same
- kumaran-is/claude-code-onboarding★ 3521% same
- codetesla51/skills★ 3217% same
- ruloCode/hermes-os★ 1717% same
- LinHao-city/StoryMind★ 1017% same
- SnoozleStudio/opencode-wp-settings★ 417% same
- chadixearth/graphyloop★ 317% same
10 more not listed
Wrote their own version · 4
- CloudAI-X/threejs-skills★ 3.7ksame name
- DaraBoth/skilljmskill★ 8same name
- Badhon-00/MDCP★ 2same name
- mrrajrumel/claude-video-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- threejs-animationSkill
- threejs-fbx-mixamoSkill
- threejs-loadersSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 18 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 188
Use layers to filter raycast targets — raycaster.layers.set(N)
- Distinctive: line 189
Use simplified invisible collision meshes for raycasting complex models
“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Three.js Interaction
Quick Start
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
function onClick(event) {
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(scene.children);
if (intersects.length > 0) console.log("Clicked:", intersects[0].object);
}
window.addEventListener("click", onClick);Raycaster
const raycaster = new THREE.Raycaster();
// From camera (mouse picking)
raycaster.setFromCamera(mousePosition, camera);
// From arbitrary origin
raycaster.set(origin, direction); // direction must be normalized
// Intersections
const intersects = raycaster.intersectObjects(objects, recursive);
// intersects[0]: { distance, point, face, faceIndex, object, uv, normal }Correct Mouse Coordinates
// Normalize to [-1, 1] NDC
function updateMouse(event, canvas) {
const rect = canvas.getBoundingClientRect();
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}Raycaster Options
raycaster.near = 0;
raycaster.far = 100;
raycaster.params.Line.threshold = 0.1;
raycaster.params.Points.threshold = 0.1;
raycaster.layers.set(1); // Only intersect layer 1Hover Effects (Throttled)
let lastRaycast = 0;
let hoveredObject = null;
function onMouseMove(event) {
if (Date.now() - lastRaycast < 50) return; // 20fps max
lastRaycast = Date.now();
updateMouse(event, renderer.domElement);
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(hoverableObjects);
if (hoveredObject) {
hoveredObject.material.emissive.set(0x000000);
document.body.style.cursor = "default";
}
if (intersects.length > 0) {
hoveredObject = intersects[0].object;
hoveredObject.material.emissive.set(0x444444);
document.body.style.cursor = "pointer";
} else {
hoveredObject = null;
}
}Camera Controls
OrbitControls
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.minPolarAngle = 0;
controls.maxPolarAngle = Math.PI / 2;
controls.minDistance = 2;
controls.maxDistance = 50;
controls.target.set(0, 1, 0);
controls.autoRotate = false;
// Must call in animation loop when damping is enabled
function animate() {
controls.update();
renderer.render(scene, camera);
}PointerLockControls (FPS)
import { PointerLockControls } from "three/addons/controls/PointerLockControls.js";
const controls = new PointerLockControls(camera, document.body);
document.addEventListener("click", () => controls.lock());
controls.addEventListener("lock", () => console.log("Pointer locked"));
controls.addEventListener("unlock", () => console.log("Pointer unlocked"));TransformControls (Editor Gizmo)
import { TransformControls } from "three/addons/controls/TransformControls.js";
const transformControls = new TransformControls(camera, renderer.domElement);
scene.add(transformControls);
transformControls.attach(selectedMesh);
transformControls.setMode("translate"); // 'translate', 'rotate', 'scale'
transformControls.addEventListener("dragging-changed", (e) => {
orbitControls.enabled = !e.value; // Disable orbit while dragging
});Keyboard Input
const keys = new Set();
document.addEventListener("keydown", (e) => keys.add(e.code));
document.addEventListener("keyup", (e) => keys.delete(e.code));
function update() {
const speed = 0.1;
if (keys.has("KeyW")) player.position.z -= speed;
if (keys.has("KeyS")) player.position.z += speed;
if (keys.has("KeyA")) player.position.x -= speed;
if (keys.has("KeyD")) player.position.x += speed;
if (keys.has("Space")) player.position.y += speed;
}Coordinate Conversion
// World → Screen
function worldToScreen(position, camera) {
const v = position.clone().project(camera);
return {
x: ((v.x + 1) / 2) * window.innerWidth,
y: (-(v.y - 1) / 2) * window.innerHeight,
};
}
// Ray-Plane intersection (e.g., place object on ground)
const groundPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
const intersection = new THREE.Vector3();
raycaster.ray.intersectPlane(groundPlane, intersection);Performance Tips
- Throttle
mousemoveraycasts (50ms minimum interval) - Use layers to filter raycast targets —
raycaster.layers.set(N) - Use simplified invisible collision meshes for raycasting complex models
- Disable controls when not needed:
controls.enabled = false
See Also
threejs-fundamentals— Camera and scene setupthreejs-animation— Animating interactions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

