From 46042ef2ec2a4fc8e9a2e4e75e92c8d9739a94ec Mon Sep 17 00:00:00 2001 From: Gabby Getz Date: Wed, 10 May 2023 11:47:48 -0400 Subject: [PATCH] Spin3d should fallback to old behavior when globe is defined --- .../Source/Scene/ScreenSpaceCameraController.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/engine/Source/Scene/ScreenSpaceCameraController.js b/packages/engine/Source/Scene/ScreenSpaceCameraController.js index a17aeca252c4..5878c5492ab2 100644 --- a/packages/engine/Source/Scene/ScreenSpaceCameraController.js +++ b/packages/engine/Source/Scene/ScreenSpaceCameraController.js @@ -1926,9 +1926,9 @@ function spin3D(controller, startPosition, movement) { const globe = controller._globe; if (defined(globe) && height < controller._minimumPickingTerrainHeight) { - const mousePos = pickPosition( - controller, + const mousePos = camera.pickEllipsoid( movement.startPosition, + controller._ellipsoid, scratchMousePos ); if (defined(mousePos)) { @@ -2090,7 +2090,7 @@ function pan3D(controller, startPosition, movement, ellipsoid) { // Use the last picked world position unless we're starting a new drag if ( - !scene.globe && + !defined(controller._globe) && !Cartesian2.equalsEpsilon( startMousePosition, controller._panLastMousePosition @@ -2099,7 +2099,7 @@ function pan3D(controller, startPosition, movement, ellipsoid) { p0 = pickPosition(controller, startMousePosition, pan3DP0); } - if (!scene.globe && defined(p0)) { + if (!defined(controller._globe) && defined(p0)) { const toCenter = Cartesian3.subtract(p0, camera.positionWC, pan3DTemp1); const toCenterProj = Cartesian3.multiplyByScalar( camera.directionWC, @@ -2141,13 +2141,15 @@ function pan3D(controller, startPosition, movement, ellipsoid) { pan3DTemp2 ); const angle = Cartesian3.angleBetween(endPickProj, camera.directionWC); - const forward = Math.max(Math.tan(angle), 0.1); // Clamp so we don't make this value infinitely large when the angle is small + let forward = 1.0; + if (defined(camera.frustum.fov)) { + forward = Math.max(Math.tan(angle), 0.1); // Clamp so we don't make the magnitude infinitely large when the angle is small + } let dot = Math.abs( Cartesian3.dot(camera.directionWC, cameraPositionNormal) ); const magnitude = - ((-dragDelta.y * pixelDimensions.y) / Math.sqrt(forward)) * - 2 * + ((-dragDelta.y * pixelDimensions.y * 2.0) / Math.sqrt(forward)) * (1.0 - dot); const direction = Cartesian3.multiplyByScalar( endPickDirection,