MCPcopy
hub / github.com/CesiumGS/cesium / handleZoom

Function handleZoom

packages/engine/Source/Scene/ScreenSpaceCameraController.js:559–983  ·  view source on GitHub ↗
(
  object,
  startPosition,
  movement,
  zoomFactor,
  distanceMeasure,
  unitPositionDotDirection,
)

Source from the content-addressed store, hash-verified

557};
558
559function 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 }

Callers 3

zoom2DFunction · 0.85
zoomCVFunction · 0.85
zoom3DFunction · 0.85

Calls 15

pickPositionFunction · 0.85
definedFunction · 0.50
clampMethod · 0.45
absMethod · 0.45
equalsMethod · 0.45
cloneMethod · 0.45
fromElementsMethod · 0.45
subtractMethod · 0.45
normalizeMethod · 0.45
distanceMethod · 0.45
dotMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…