Atlaslog
Atlaslog / three.js / Tutorial / Scene graph and coordinates
three.js · Tutorial

Scene graph and coordinates

Quick answer

This tutorial explains that every Object3D hangs in one tree and that children store local transforms. It walks through Group, Mesh and Scene inheritance, parent and children relations, world matrix composition, getWorldPosition, localToWorld and the difference between add and attach. It also defines a single toScene function that offsets projected eastings and northings around a local origin. Readers can debug why objects move unexpectedly and keep GIS coordinates precise.

Last verified 2026-11-03 · three.js 0.160.0 · Cite this page
Key points
Example
const cityBlock = new THREE.Group();
cityBlock.position.set(120, 0, -80);

const building = new THREE.Mesh(boxGeometry, wallMaterial);
building.position.set(10, 15, 6);        // 相对 cityBlock
cityBlock.add(building);
scene.add(cityBlock);

console.log(building.parent === cityBlock);       // true
console.log(building.getWorldPosition(new THREE.Vector3()).x);  // 130

cityBlock.traverse(function (obj) {
  if (obj.isMesh) obj.castShadow = true;
});
const pivot = new THREE.Group();
pivot.position.set(200, 0, 0);

const arm = new THREE.Mesh(new THREE.BoxGeometry(60, 2, 2), metalMaterial);
arm.position.set(30, 0, 0);      // 伸出 30 米
pivot.add(arm);
pivot.rotation.y = THREE.MathUtils.degToRad(35);
pivot.updateMatrixWorld(true);
const endPoint = new THREE.Vector3(60, 0, 0);
arm.localToWorld(endPoint);
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Scene graph and coordinates. https://www.jingweizhi.com/en/three/tutorials/scene-graph.html (accessed 2026-11-03).