Fix camera zoom issue when tracked entity set or after execute lookAt function #12999
      
        
          +9
        
        
          −0
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Description
This PR addresses the issue where the zoom beyond the target point by ignoring
pickPositionresults (intersection) that are farther than the target point whencontroller._globeis set toundefined(when thetrackedEntityset or the camera'slookAtfunction is executed).Before fix
tracked-before.mp4
lookat-before.mp4
After fix
tracked-after.mp4
lookat-after.mp4
Issue number and link
Fixes #12812
Fixes #12645
Issue scenario
The primary scenarios where this issue occurs are as follows:
For easy reproduction, I've attached a sandcastle visualizing the ray toward the point the camera is looking at.
Aircraft model example
Box model example - This case more clear to test issue.
lookAt example - This is default CesiumJS example showing cloud.
Main problem
In the
Zoom3Dfunction, the issue occurs because the surface of the target in the camera's direction does not exist, so, theintersectionpoint obtained viapickPositionto point to another target beyond the intended target.Changes
In this code, it appeared that controller._globe was used to determine whether the state was tracked or in look-at mode.
So, after calculating the intersection, Check the state of controller._globe and, if a location farther than the target's distance was picked, ignore the intersection.
The initial approach involved early escape during the intersection calculation phase, but this was discarded because it caused several unintended behaviors.
For example, in the case of a balloon Hot Air Balloon zooming normally stops at the balloon's outer surface. However, if the intersection is ignored without distance conditions, zooming will proceed toward the center of the bounding sphere inside the balloon.
So, I implemented it to perform an additional check based on distance conditions after calculating the intersection.
Testing plan
I apologize for not familiar with creating file-based tests.
I tested using the sandcastle in the Issue scenario at the top and several built-in sandcastles.
Author checklist
CONTRIBUTORS.mdCHANGES.mdwith a short summary of my change