From 25d363dc7bcdac22aaf3d7d8900515abd020c9b9 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 25 Apr 2026 04:13:44 +0200 Subject: [PATCH] auto-git: [change] src/runtime-three/runtime-interaction-system.ts --- .../runtime-interaction-system.ts | 90 +++++-------------- 1 file changed, 23 insertions(+), 67 deletions(-) diff --git a/src/runtime-three/runtime-interaction-system.ts b/src/runtime-three/runtime-interaction-system.ts index fce6cf70..00f49983 100644 --- a/src/runtime-three/runtime-interaction-system.ts +++ b/src/runtime-three/runtime-interaction-system.ts @@ -731,69 +731,25 @@ export class RuntimeInteractionSystem { let bestPrompt: RuntimeInteractionPrompt | null = null; let bestHitDistance = Number.POSITIVE_INFINITY; - for (const interactable of runtimeScene.entities.interactables) { - if ( - !interactable.interactionEnabled || - !hasTriggerLinks(runtimeScene, interactable.entityId, "click") - ) { - continue; - } - - const distance = distanceBetweenVec3( - interactionOrigin, - interactable.position - ); - - if (distance > interactable.radius) { - continue; - } - - const hitDistance = raySphereHitDistance( - rayOrigin, - normalizedViewDirection, - interactable.position, - getInteractableTargetRadius(interactable) - ); - - if (hitDistance === null) { - continue; - } - const next = updateBestPrompt( - bestPrompt, - bestHitDistance, - interactable.entityId, - interactable.prompt, - distance, - interactable.radius, - hitDistance - ); - bestPrompt = next.prompt; - bestHitDistance = next.hitDistance; - } - - for (const npc of runtimeScene.entities.npcs) { - if (!npc.visible) { - continue; - } - - const hasClickLinks = hasTriggerLinks(runtimeScene, npc.entityId, "click"); - - if (!hasClickLinks) { - continue; - } - - const bounds = getNpcDialogueTargetBounds(npc); - const distance = distanceToAxisAlignedBox(interactionOrigin, bounds); - - if (distance > bounds.range) { - continue; - } - - const hitDistance = rayAxisAlignedBoxHitDistance( - rayOrigin, - normalizedViewDirection, - bounds - ); + for (const candidate of collectRuntimeInteractionTargetSources( + interactionOrigin, + runtimeScene + )) { + const hitDistance = + candidate.kind === "interactable" + ? raySphereHitDistance( + rayOrigin, + normalizedViewDirection, + candidate.center, + candidate.targetRadius ?? DEFAULT_INTERACTABLE_TARGET_RADIUS + ) + : candidate.bounds + ? rayAxisAlignedBoxHitDistance( + rayOrigin, + normalizedViewDirection, + candidate.bounds + ) + : null; if (hitDistance === null) { continue; @@ -802,10 +758,10 @@ export class RuntimeInteractionSystem { const next = updateBestPrompt( bestPrompt, bestHitDistance, - npc.entityId, - getNpcDialoguePrompt(npc, hasClickLinks), - distance, - bounds.range, + candidate.entityId, + candidate.prompt, + candidate.distance, + candidate.range, hitDistance ); bestPrompt = next.prompt;