월드 앵커

World anchor

카메라(사용자)가 움직여도 실제 공간의 한 지점에 고정된 채 그대로 있는 가상 객체 — 화면에 붙는 것과 정반대.

다른 이름: Spatial anchorFixed-in-place object
···
js
import * as THREE from 'three';
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b0c16);
const camera = new THREE.PerspectiveCamera(52, 1, 0.1, 30);
scene.add(new THREE.HemisphereLight(0xaebfff, 0x0c0c14, 1.6));
const key = new THREE.DirectionalLight(0xffffff, 1.2); key.position.set(3, 5, 2); scene.add(key);
const grid = new THREE.GridHelper(8, 16, 0x4a5bd8, 0x22243a);
scene.add(grid);
const anchor = new THREE.Mesh(new THREE.OctahedronGeometry(0.6, 0), new THREE.MeshStandardMaterial({ color: 0xff7a59, roughness: 0.4 }));
anchor.position.y = 0.6;
scene.add(anchor);
function resize() { renderer.setSize(innerWidth, innerHeight); camera.aspect = innerWidth / innerHeight; camera.updateProjectionMatrix(); }
addEventListener('resize', resize); resize();
renderer.setAnimationLoop((t) => {
  const a = t * 0.00025;
  camera.position.set(Math.sin(a) * 5, 2.2, Math.cos(a) * 5);
  camera.lookAt(0, 0.4, 0);
  anchor.rotation.y = t * 0.0006;
  renderer.render(scene, camera);
});

헤드셋 화면에는 두 종류의 가상 요소가 공존한다. 하나는 머리를 따라다니는 것(헤드 락, 배터리 상태 표시처럼), 다른 하나는 실제 공간의 한 좌표에 그대로 "박혀" 있는 것 — 월드 앵커다. 책상 위에 둔 가상 메모, 벽에 붙인 가상 그림처럼 사용자가 그 주위를 돌아다녀도 제자리에 남는다.

이게 중요한 이유는 몰입감이다. 실제 물체가 그렇듯, 가상 객체도 사용자가 움직일 때 위치·각도가 시점에 맞게 자연스럽게 바뀌어야("이 물체는 진짜 저기 있다"는 느낌) 한다. 반대로 계속 사용자를 따라다니면 "화면에 붙은 스티커"처럼 보여 몰입이 깨진다.

데모는 카메라가 방 안을 천천히 돌며(궤도 운동) 바라보는 동안, 바닥의 격자와 그 위에 놓인 오브젝트는 전혀 움직이지 않는 걸 보여준다 — 실제 헤드셋에서 고개를 돌릴 때 세상이 고정돼 보이는 것과 같은 원리다.

언제 쓰나

실제 사물처럼 느껴져야 하는 콘텐츠(방 안에 둔 오브젝트, 위치 기반 알림)에 씁니다. 항상 눈앞에 있어야 하는 상태 표시는 반대로 헤드 락으로 둡니다.