diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index 577ffc74..26cddfd6 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -5945,7 +5945,7 @@ export class RuntimeHost { return false; } - private updateActiveRuntimeTargetLockState() { + private updateActiveRuntimeTargetLockState(dt = 0) { if ( this.activeRuntimeTargetReference === null || this.currentPlayerControllerTelemetry === null || @@ -5961,6 +5961,20 @@ export class RuntimeHost { return; } + if (this.isRuntimeTargetCameraVisible(activeTarget)) { + this.activeRuntimeTargetOcclusionSeconds = 0; + } else { + this.activeRuntimeTargetOcclusionSeconds += Math.max(0, dt); + + if ( + this.activeRuntimeTargetOcclusionSeconds >= + TARGETING_ACTIVE_OCCLUSION_GRACE_SECONDS + ) { + this.setActiveRuntimeTargetReference(null); + return; + } + } + if ( distanceBetweenPoints( this.currentPlayerControllerTelemetry.eyePosition,