auto-git:

[change] src/runtime-three/runtime-interaction-system.ts
This commit is contained in:
2026-04-25 04:13:44 +02:00
parent 9a0228e9b2
commit 25d363dc7b

View File

@@ -731,69 +731,25 @@ export class RuntimeInteractionSystem {
let bestPrompt: RuntimeInteractionPrompt | null = null; let bestPrompt: RuntimeInteractionPrompt | null = null;
let bestHitDistance = Number.POSITIVE_INFINITY; let bestHitDistance = Number.POSITIVE_INFINITY;
for (const interactable of runtimeScene.entities.interactables) { for (const candidate of collectRuntimeInteractionTargetSources(
if ( interactionOrigin,
!interactable.interactionEnabled || runtimeScene
!hasTriggerLinks(runtimeScene, interactable.entityId, "click") )) {
) { const hitDistance =
continue; candidate.kind === "interactable"
} ? raySphereHitDistance(
rayOrigin,
const distance = distanceBetweenVec3( normalizedViewDirection,
interactionOrigin, candidate.center,
interactable.position candidate.targetRadius ?? DEFAULT_INTERACTABLE_TARGET_RADIUS
); )
: candidate.bounds
if (distance > interactable.radius) { ? rayAxisAlignedBoxHitDistance(
continue; rayOrigin,
} normalizedViewDirection,
candidate.bounds
const hitDistance = raySphereHitDistance( )
rayOrigin, : null;
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
);
if (hitDistance === null) { if (hitDistance === null) {
continue; continue;
@@ -802,10 +758,10 @@ export class RuntimeInteractionSystem {
const next = updateBestPrompt( const next = updateBestPrompt(
bestPrompt, bestPrompt,
bestHitDistance, bestHitDistance,
npc.entityId, candidate.entityId,
getNpcDialoguePrompt(npc, hasClickLinks), candidate.prompt,
distance, candidate.distance,
bounds.range, candidate.range,
hitDistance hitDistance
); );
bestPrompt = next.prompt; bestPrompt = next.prompt;