From 8b9d2af28f30e2666d9f14872856de3a87fe8186 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 11 May 2026 21:55:38 +0200 Subject: [PATCH] Validate NPC target anchor structure, mode, and offset --- src/document/scene-document-validation.ts | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/document/scene-document-validation.ts b/src/document/scene-document-validation.ts index c3e323b2..3fadf579 100644 --- a/src/document/scene-document-validation.ts +++ b/src/document/scene-document-validation.ts @@ -4985,6 +4985,42 @@ function validateNpcEntity( ); } + if ( + typeof entity.targetAnchor !== "object" || + entity.targetAnchor === null + ) { + diagnostics.push( + createDiagnostic( + "error", + "invalid-npc-target-anchor", + "NPC target anchor must remain an object.", + `${path}.targetAnchor` + ) + ); + } else { + if (!isNpcTargetAnchorMode(entity.targetAnchor.mode)) { + diagnostics.push( + createDiagnostic( + "error", + "invalid-npc-target-anchor-mode", + "NPC target anchor mode must be center, eyeHeight, top, origin, or custom.", + `${path}.targetAnchor.mode` + ) + ); + } + + if (!isFiniteVec3(entity.targetAnchor.offset)) { + diagnostics.push( + createDiagnostic( + "error", + "invalid-npc-target-anchor-offset", + "NPC target anchor offset must remain finite on every axis.", + `${path}.targetAnchor.offset` + ) + ); + } + } + validateNpcModelAssetId(entity, path, document, diagnostics); const seenNpcDialogueIds = new Map();