From 34dba2d4c8afa0c861b2882a1856f9e788268f72 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 11 May 2026 21:55:11 +0200 Subject: [PATCH] Implement readNpcTargetAnchor function --- src/document/migrate-scene-document.ts | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/document/migrate-scene-document.ts b/src/document/migrate-scene-document.ts index 90e81b7e..b72dd659 100644 --- a/src/document/migrate-scene-document.ts +++ b/src/document/migrate-scene-document.ts @@ -4376,6 +4376,36 @@ function readNpcPresence(value: unknown, label: string): NpcPresence { } } +function readNpcTargetAnchor(value: unknown, label: string): NpcTargetAnchor { + if (value === undefined) { + return createNpcTargetAnchor(); + } + + if (!isRecord(value)) { + throw new Error(`${label} must be an object.`); + } + + const mode = + value.mode === undefined + ? DEFAULT_NPC_TARGET_ANCHOR_MODE + : expectString(value.mode, `${label}.mode`); + + if (!isNpcTargetAnchorMode(mode)) { + throw new Error( + `${label}.mode must be center, eyeHeight, top, origin, or custom.` + ); + } + + return createNpcTargetAnchor({ + mode, + offset: readOptionalVec3( + value.offset, + `${label}.offset`, + DEFAULT_NPC_TARGET_ANCHOR_OFFSET + ) + }); +} + function readEntityInstance( value: unknown, label: string,