From d00404ece35780dc2987b4d0361218e9939b6fdf Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 11 May 2026 22:00:29 +0200 Subject: [PATCH] Use default target anchor when resolving NPC target center --- src/runtime-three/runtime-interaction-system.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/runtime-three/runtime-interaction-system.ts b/src/runtime-three/runtime-interaction-system.ts index 87dce694..c01983db 100644 --- a/src/runtime-three/runtime-interaction-system.ts +++ b/src/runtime-three/runtime-interaction-system.ts @@ -22,6 +22,10 @@ const DEFAULT_NPC_DIALOGUE_TARGET_RADIUS = 1.5; const DEFAULT_INTERACTION_PROMPT_NEAR_FIELD_RADIUS = 0.2; const TARGETING_ACQUISITION_REACH = 15; const TARGETING_MIN_VIEW_DOT = 0.1; +const DEFAULT_RUNTIME_NPC_TARGET_ANCHOR = { + mode: "center", + offset: { x: 0, y: 0, z: 0 } +} as const; export interface RuntimeDialogueStartSource { kind: "interactionLink" | "npc" | "direct"; @@ -463,7 +467,9 @@ function resolveNpcTargetAnchorCenter( npc: RuntimeNpc, bounds: { min: Vec3; max: Vec3 } ): Vec3 { - switch (npc.targetAnchor.mode) { + const targetAnchor = npc.targetAnchor ?? DEFAULT_RUNTIME_NPC_TARGET_ANCHOR; + + switch (targetAnchor.mode) { case "origin": return npc.position; case "top": @@ -485,7 +491,7 @@ function resolveNpcTargetAnchorCenter( z: npc.position.z }; case "custom": - return transformNpcLocalAnchorOffset(npc, npc.targetAnchor.offset); + return transformNpcLocalAnchorOffset(npc, targetAnchor.offset); case "center": return { x: (bounds.min.x + bounds.max.x) * 0.5,