Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix camera go througth building in zoom #11108

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/engine/Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,8 @@ function pan3D(controller, startPosition, movement, ellipsoid) {
const zoom3DUnitPosition = new Cartesian3();
const zoom3DCartographic = new Cartographic();

let preIntersectionDistance = 0;

function zoom3D(controller, startPosition, movement) {
if (defined(movement.distance)) {
movement = movement.distance;
Expand Down Expand Up @@ -2189,10 +2191,10 @@ function zoom3D(controller, startPosition, movement) {
zoom3DCartographic
).height;

const inertiaMovementApproachingGround = Math.abs(height) < 50;
const approachingCollision = Math.abs(preIntersectionDistance) < 4000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an arbitrary value it's probably best to expose this value as a property, like what is done for controller.minimumPickingTerrainHeight. I would call it something like minimumPickingTerrainHeightWithInertia.


const needPickGlobe = inertiaMovement
? inertiaMovementApproachingGround
? approachingCollision
: height < controller._minimumPickingTerrainHeight;
if (needPickGlobe) {
intersection = pickGlobe(controller, windowPosition, zoomCVIntersection);
Expand All @@ -2201,6 +2203,7 @@ function zoom3D(controller, startPosition, movement) {
let distance;
if (defined(intersection)) {
distance = Cartesian3.distance(ray.origin, intersection);
preIntersectionDistance = distance;
}

if (cameraUnderground) {
Expand Down