From 727485434edfde11b7b5103dcb2d4af62792790f Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 25 Apr 2026 18:43:27 +0200 Subject: [PATCH] Implement dynamic update logic for active target indicators --- src/runtime-three/runtime-host.ts | 52 ++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index e8f38002..3f9b6003 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -6250,6 +6250,50 @@ export class RuntimeHost { this.targetingLuxFlightState = "hidden"; } + private updateRuntimeActiveTargetIndicator( + visualPlacement: ReturnType + ) { + this.targetingActiveGroup.position.set( + visualPlacement.activeMarkerPosition.x, + visualPlacement.activeMarkerPosition.y, + visualPlacement.activeMarkerPosition.z + ); + this.targetingActiveGroup.quaternion.identity(); + this.targetingActiveGroup.scale.setScalar(visualPlacement.activeMarkerScale); + this.targetingActiveCameraRight + .setFromMatrixColumn(this.camera.matrixWorld, 0) + .normalize(); + this.targetingActiveCameraUp + .setFromMatrixColumn(this.camera.matrixWorld, 1) + .normalize(); + + const orbitAngle = + this.targetingVisualTime * TARGETING_ACTIVE_ARROW_ORBIT_RATE; + const localRadius = + visualPlacement.activeMarkerRadius / visualPlacement.activeMarkerScale; + + this.targetingActiveArrows.forEach((arrow, index) => { + const angle = + orbitAngle + (index / TARGETING_ACTIVE_ARROW_COUNT) * Math.PI * 2; + arrow.position + .copy(this.targetingActiveCameraRight) + .multiplyScalar(Math.cos(angle) * localRadius) + .addScaledVector( + this.targetingActiveCameraUp, + Math.sin(angle) * localRadius + ); + this.targetingActiveArrowDirection.copy(arrow.position).multiplyScalar(-1); + + if (this.targetingActiveArrowDirection.lengthSq() > Number.EPSILON) { + this.targetingActiveArrowDirection.normalize(); + arrow.quaternion.setFromUnitVectors( + this.targetingActiveArrowLocalTipAxis, + this.targetingActiveArrowDirection + ); + } + }); + } + private updateRuntimeTargetingVisuals(dt: number) { const activeTarget = this.resolveActiveRuntimeTarget(); const visualTarget = activeTarget ?? this.proposedRuntimeTarget; @@ -6368,13 +6412,7 @@ export class RuntimeHost { this.targetingActiveGroup.visible = activeTarget !== null; if (activeTarget !== null) { - this.targetingActiveGroup.position.set( - visualPlacement.activeMarkerPosition.x, - visualPlacement.activeMarkerPosition.y, - visualPlacement.activeMarkerPosition.z - ); - this.targetingActiveGroup.scale.setScalar(visualPlacement.activeMarkerScale); - this.targetingActiveGroup.lookAt(this.camera.position); + this.updateRuntimeActiveTargetIndicator(visualPlacement); } }