threejs-core-raycaster

Implement mouse picking in Three.js scenes using Raycaster intersection tests.

11|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/OpenAEC-Foundation/Three.js-Claude-Skill-Package --skill threejs-core-raycaster
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-core-raycaster
Source: https://github.com/OpenAEC-Foundation/Three.js-Claude-Skill-Package/tree/main/skills/source/threejs-core/threejs-core-raycaster
Command: npx skills add https://github.com/OpenAEC-Foundation/Three.js-Claude-Skill-Package --skill threejs-core-raycaster

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Efficient, accurate mouse picking in Three.js scenes using Raycaster to test intersections against a target object set, while avoiding unnecessary traversal and ensuring reliable results for hover and click interactions.

Core Features & Use Cases

  • Raycaster-based mouse picking with setFromCamera and set origin/direction
  • intersectObject and intersectObjects with optional recursive traversal
  • InstancedMesh picking support via instanceId and per-instance data
  • Layer filtering using raycaster.layers to restrict tests to interactive objects
  • Performance guidance including throttling, array reuse, and selective testing

Quick Start

Initialize a Raycaster, convert your mouse coordinates to normalized device coordinates, and call intersectObjects or intersectObject on your target objects.

Frequently Asked Questions about threejs-core-raycaster

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement mouse picking in a Three.js scene?

Mouse picking in Three.js uses Raycaster to test intersections against a target object set. Configure the Raycaster with origin, direction, near, and far values, then use setFromCamera to cast rays and intersectObjects to detect clickable items.

How does Three.js raycasting handle InstancedMesh intersections?

Three.js raycasting handles InstancedMesh by returning an instanceId in the intersection result. This allows you to identify and select specific instances within the InstancedMesh, enabling accurate per-instance picking without testing individual meshes.

What's the best way to improve Three.js raycaster performance across frames?

To improve raycaster performance, reuse optionalTarget arrays for intersection results, throttle raycasting calls, restrict tests using layer filtering, and selectively test only interactive objects instead of traversing the entire scene graph.

Can I use layer filtering with Three.js raycaster to restrict intersections?

Yes, you can use raycaster.layers to restrict intersection tests to specific layers. By configuring layers on your Raycaster and objects, you limit tests to interactive objects, avoiding unnecessary traversal and ensuring deterministic hover and click results.

Why does my Three.js raycaster return no intersections on mouse click?

Three.js raycaster returns no intersections when mouse coordinates are not converted to normalized device coordinates, or when the target object set is incorrectly configured. Ensure setFromCamera is called with correct coordinates and intersectObjects receives valid targets.

Do I need to set recursive traversal when using intersectObjects in Three.js?

Recursive traversal in intersectObjects is optional. When enabled, it tests all descendants of the target objects; when disabled, it only tests the objects themselves. Choose based on whether your interactive objects are nested within parent groups.