threejs-objects
$
npx mdskill add partme-ai/full-stack-skills/threejs-objectsManages three.js scene graph objects, transforms, and picking for building interactive 3D hierarchies.
- Helps with constructing scene hierarchies, selecting mesh types, and implementing object picking via Raycaster.
- Integrates with three.js APIs like Object3D, Group, Mesh, Raycaster, Layers, and EventDispatcher patterns.
- Decides recommendations based on user mentions of transforms, mesh types, picking, or layer visibility.
- Presents results through structured guidance on scene composition, instancing, and interaction techniques.
SKILL.md
.github/skills/threejs-objectsView on GitHub ↗
---
name: threejs-objects
description: "three.js scene graph objects: Object3D transforms and hierarchy, Group, Mesh, InstancedMesh, SkinnedMesh, BatchedMesh, LOD, Line/LineLoop/LineSegments, Points, Sprite, Bone, Skeleton, ClippingGroup; interaction via Raycaster, Layers masks, and EventDispatcher patterns. Use when building scene hierarchies, picking objects with Raycaster, or configuring instanced/skinned meshes; for pure vector math use threejs-math; for skeletal clips use threejs-animation."
---
## When to use this skill
**ALWAYS use this skill when the user mentions:**
- Parent/child relationships, `position/rotation/scale`, `matrixAutoUpdate`, `updateMatrixWorld`
- Choosing mesh types: static vs instanced vs skinned vs batched LOD
- **Picking**: `Raycaster.setFromCamera`, `intersectObjects`, recursive flag, face/uv results
- **Layers**: selective visibility for cameras/lights/objects
**IMPORTANT: objects vs math**
| Need | Skill |
|------|--------|
| Scene graph + picking | **threejs-objects** |
| Box/ray math only | **threejs-math** |
**Trigger phrases include:**
- "Object3D", "InstancedMesh", "SkinnedMesh", "Raycaster", "layers"
- "父子节点", "射线拾取", "图层"
## How to use this skill
1. **Compose** scenes with `Group` and transforms; minimize deep hierarchies where possible.
2. **Instancing** — set per-instance matrices; understand `count` and frustum culling behavior.
3. **SkinnedMesh** — bind skeleton; clips in **threejs-animation**; skinning material flags in **threejs-materials**.
4. **Picking** — normalize device coords, set ray from camera, filter by layers, validate intersections are sorted by distance before processing.
5. **Events** — `EventDispatcher` on custom objects; patterns only, not DOM frameworks.
6. **Clipping** — `ClippingGroup` usage per docs when user needs sectional cuts.
7. **Dispose** — call `dispose()` on geometries/materials/textures when removing objects permanently.
### Example: Raycaster picking with validation
```javascript
import * as THREE from 'three';
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function onPointerMove(event) {
// Normalize device coordinates (-1 to +1)
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
}
function pick(camera, scene) {
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(scene.children, true);
// Validate: intersections are sorted by distance (nearest first)
if (intersections.length > 0) {
console.log('Nearest hit:', intersections[0].object.name,
'at distance:', intersections[0].distance);
}
return intersections;
}
```
See [examples/workflow-raycaster-pick.md](examples/workflow-raycaster-pick.md).
## Doc map (official)
| Docs section | Representative links |
|--------------|----------------------|
| Core | https://threejs.org/docs/Object3D.html |
| Objects | https://threejs.org/docs/Mesh.html |
| Objects | https://threejs.org/docs/InstancedMesh.html |
| Core | https://threejs.org/docs/Raycaster.html |
## Scope
- **In scope:** Object3D graph, renderable object types, raycasting, layers, dispatcher basics.
- **Out of scope:** Physics engines; XR input mapping (**threejs-webxr**).
## Common pitfalls and best practices
- Forgetting `updateMatrixWorld` before world-space ray tests on moved objects.
- Raycaster without `layers` set picks unintended objects—set masks consistently on camera and objects.
- InstancedMesh raycast hits need per-instance handling—check docs for your version.
## Documentation and version
`Object3D`, mesh types, `Raycaster`, and `Layers` are documented under [Objects](https://threejs.org/docs/#Objects) and [Core](https://threejs.org/docs/Raycaster.html) in [three.js docs](https://threejs.org/docs/). Behavior of picking and layers can shift slightly—link the exact page for the user’s three.js line.
## Agent response checklist
When answering under this skill, prefer responses that:
1. Link `Object3D`, `Mesh`, `InstancedMesh`, `Raycaster`, or `Layers` as needed.
2. Pair skeletal animation with **threejs-animation** and skinned mesh setup.
3. Route pure linear-algebra questions without a scene graph to **threejs-math**.
4. Route XR input to **threejs-webxr** when sessions/controllers are involved.
5. Mention `dispose()` for geometries/materials when removing objects permanently.
## References
- https://threejs.org/docs/Object3D.html
- https://threejs.org/docs/Raycaster.html
- https://threejs.org/docs/Layers.html
- https://threejs.org/docs/InstancedMesh.html
## Keywords
**English:** object3d, mesh, instancedmesh, skinnedmesh, raycaster, layers, scene graph, three.js
**中文:** 场景图、Object3D、Mesh、实例化、骨骼网格、射线拾取、图层、three.js
More from partme-ai/full-stack-skills
- adobe-xd"Guides creation of UI/UX designs, interactive prototypes, reusable components, and design specs in Adobe XD. Use when the user asks about Adobe XD artboards, prototype links, repeat grids, component states, design tokens export, or developer handoff."
- angular"Provides comprehensive guidance for Angular framework including components, modules, services, dependency injection, routing, forms, and TypeScript integration. Use when the user asks about Angular, needs to create Angular applications, implement Angular components, or work with Angular features."
- ansible"Provides comprehensive guidance for Ansible automation including playbooks, roles, inventory, and module usage. Use when the user asks about Ansible, needs to automate IT tasks, create Ansible playbooks, or manage infrastructure with Ansible."
- ant-design-mini"Builds mini-program UIs with Ant Design Mini components for Alipay and WeChat mini-programs. Covers Button, Form, List, Modal, Tabs, NavBar, and 60+ components with theme customization and CSS variable theming. Use when the user needs to create mini-program interfaces with Ant Design Mini, configure themes, or implement mini-program-specific UI patterns."
- ant-design-mobile"Builds React mobile UIs with Ant Design Mobile (antd-mobile) components including Button, Form, List, Modal, Picker, Tabs, PullToRefresh, InfiniteScroll, and 50+ mobile-optimized components. Use when the user needs to create mobile-first React interfaces, implement mobile navigation, forms, or data display with Ant Design Mobile."
- ant-design-react"Builds enterprise React UIs with Ant Design (antd) including 60+ components (Button, Form, Table, Select, Modal, Message), design tokens, TypeScript support, and ConfigProvider theming. Use when the user needs to create React applications with Ant Design, build forms with validation, display data tables, or customize the Ant Design theme."
- ant-design-vueProvides comprehensive guidance for Ant Design Vue (AntDV) component library for Vue 3. Covers installation, usage, API reference, templates, and all component categories. Use when building enterprise-class UI with Vue 3 and Ant Design.
- api-doc-generator"Generate API documentation by scanning Controller classes, extracting endpoint URLs, HTTP methods, parameters, and response structures, then producing standardized docs from templates. Use when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting REST APIs. Do not trigger for generic documentation requests without explicit API mention."
- appium"Provides comprehensive guidance for Appium mobile testing including mobile app automation, element location, gestures, and cross-platform testing. Use when the user asks about Appium, needs to test mobile applications, automate mobile apps, or write Appium test scripts."
- ascii-ansi-colorizer"Add an ANSI color layer to existing ASCII/plain-text output (gradient/rainbow/highlights) with alignment-safe rules and a required no-color fallback. Use when the user wants to colorize terminal output, add rainbow effects to CLI text, or style ASCII art with ANSI colors."