( object, startPosition, movement, zoomFactor, distanceMeasure, unitPositionDotDirection, )
| 557 | }; |
| 558 | |
| 559 | function handleZoom( |
| 560 | object, |
| 561 | startPosition, |
| 562 | movement, |
| 563 | zoomFactor, |
| 564 | distanceMeasure, |
| 565 | unitPositionDotDirection, |
| 566 | ) { |
| 567 | let percentage = 1.0; |
| 568 | if (defined(unitPositionDotDirection)) { |
| 569 | percentage = CesiumMath.clamp( |
| 570 | Math.abs(unitPositionDotDirection), |
| 571 | 0.25, |
| 572 | 1.0, |
| 573 | ); |
| 574 | } |
| 575 | |
| 576 | const diff = movement.endPosition.y - movement.startPosition.y; |
| 577 | |
| 578 | // distanceMeasure should be the height above the ellipsoid. |
| 579 | // When approaching the surface, the zoomRate slows and stops minimumZoomDistance above it. |
| 580 | const approachingSurface = diff > 0; |
| 581 | const minHeight = approachingSurface |
| 582 | ? object.minimumZoomDistance * percentage |
| 583 | : 0; |
| 584 | const maxHeight = object.maximumZoomDistance; |
| 585 | |
| 586 | const minDistance = distanceMeasure - minHeight; |
| 587 | let zoomRate = zoomFactor * minDistance; |
| 588 | zoomRate = CesiumMath.clamp( |
| 589 | zoomRate, |
| 590 | object._minimumZoomRate, |
| 591 | object._maximumZoomRate, |
| 592 | ); |
| 593 | |
| 594 | let rangeWindowRatio = diff / object._scene.canvas.clientHeight; |
| 595 | rangeWindowRatio = Math.min(rangeWindowRatio, object.maximumMovementRatio); |
| 596 | let distance = zoomRate * rangeWindowRatio; |
| 597 | |
| 598 | if ( |
| 599 | object.enableCollisionDetection || |
| 600 | object.minimumZoomDistance === 0.0 || |
| 601 | !defined(object._globe) // look-at mode |
| 602 | ) { |
| 603 | if (distance > 0.0 && Math.abs(distanceMeasure - minHeight) < 1.0) { |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | if (distance < 0.0 && Math.abs(distanceMeasure - maxHeight) < 1.0) { |
| 608 | return; |
| 609 | } |
| 610 | |
| 611 | if (distanceMeasure - distance < minHeight) { |
| 612 | distance = distanceMeasure - minHeight - 1.0; |
| 613 | } else if (distanceMeasure - distance > maxHeight) { |
| 614 | distance = distanceMeasure - maxHeight; |
| 615 | } |
| 616 | } |
no test coverage detected
searching dependent graphs…