threejs-core-scene-graph

Explain Three.js Object3D hierarchy best practices for reparenting with attach().

4|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/Bailipa/EZTor_FULLBLOOD --skill threejs-core-scene-graph-bailipa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-core-scene-graph
Source: https://github.com/Bailipa/EZTor_FULLBLOOD/tree/main/.opencode/skills/threejs/threejs-core/threejs-core-scene-graph
Command: npx skills add https://github.com/Bailipa/EZTor_FULLBLOOD --skill threejs-core-scene-graph-bailipa

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides best practices for managing a Three.js scene graph, focusing on how Object3D hierarchies should be structured and how to avoid common reparenting mistakes that disrupt world transforms.

Core Features & Use Cases

  • Understand and manage Object3D hierarchies, including Scene, Group, and Mesh.
  • Use attach() to preserve world transforms when moving objects between parents, and understand when add() changes local space.
  • Perform safe traversal, prevent mid-iteration mutations, and implement clean disposal patterns for GPU resources.
  • Build reusable scene compositions with nested groups and coordinate conversions for world/local space transitions.

Quick Start

Create a small three.js scene with a parent group and a child mesh, then compare attach() and add() to observe how world positions are preserved.

Frequently Asked Questions about threejs-core-scene-graph

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

FAQPage Schema
What is the difference between add() and attach() for reparenting in a Three.js scene graph?

In a Three.js scene graph, add() moves an Object3D to a new parent but alters its local transform to match the new hierarchy, whereas attach() reparents the object while preserving its exact world position and orientation.

How do I preserve world position when moving objects between parent groups in Three.js?

To preserve world position when moving objects between parent groups in Three.js, use the attach() method instead of add(), ensuring the Object3D maintains its global transform during reparenting.

Why does traversing a Three.js scene graph cause errors when removing child objects?

Traversing a Three.js scene graph causes errors when removing child objects because mutating the children array mid-iteration breaks the traversal loop, requiring safe traversal patterns that defer structural modifications.

How do I manage matrix updates and matrixAutoUpdate for predictable rendering in Three.js?

To manage matrix updates in Three.js, toggle matrixAutoUpdate to false and manually call updateMatrix() when you need predictable rendering, preventing automatic matrix recalculations during scene graph traversal.

What is the best way to dispose of GPU resources when removing Object3D meshes from a scene?

The best way to dispose of GPU resources when removing Object3D meshes from a scene is to implement clean disposal patterns that explicitly call dispose() on geometries and materials to prevent memory leaks.

How do I build nested groups with correct local and world coordinate conversions in Three.js?

To build nested groups with correct coordinate conversions in Three.js, structure Object3D hierarchies using Scene and Group containers, and apply local-to-world space transitions to ensure reusable scene compositions.