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

Function look3D

packages/engine/Source/Scene/ScreenSpaceCameraController.js:2750–2872  ·  view source on GitHub ↗
(controller, startPosition, movement, rotationAxis)

Source from the content-addressed store, hash-verified

2748const look3DTan = new Cartesian3();
2749
2750function look3D(controller, startPosition, movement, rotationAxis) {
2751 const scene = controller._scene;
2752 const camera = scene.camera;
2753
2754 const startPos = look3DStartPos;
2755 startPos.x = movement.startPosition.x;
2756 startPos.y = 0.0;
2757 const endPos = look3DEndPos;
2758 endPos.x = movement.endPosition.x;
2759 endPos.y = 0.0;
2760
2761 let startRay = camera.getPickRay(startPos, look3DStartRay);
2762 let endRay = camera.getPickRay(endPos, look3DEndRay);
2763 let angle = 0.0;
2764 let start;
2765 let end;
2766
2767 if (camera.frustum instanceof OrthographicFrustum) {
2768 start = startRay.origin;
2769 end = endRay.origin;
2770
2771 Cartesian3.add(camera.direction, start, start);
2772 Cartesian3.add(camera.direction, end, end);
2773
2774 Cartesian3.subtract(start, camera.position, start);
2775 Cartesian3.subtract(end, camera.position, end);
2776
2777 Cartesian3.normalize(start, start);
2778 Cartesian3.normalize(end, end);
2779 } else {
2780 start = startRay.direction;
2781 end = endRay.direction;
2782 }
2783
2784 let dot = Cartesian3.dot(start, end);
2785 if (dot < 1.0) {
2786 // dot is in [0, 1]
2787 angle = Math.acos(dot);
2788 }
2789
2790 angle = movement.startPosition.x > movement.endPosition.x ? -angle : angle;
2791
2792 const horizontalRotationAxis = controller._horizontalRotationAxis;
2793 if (defined(rotationAxis)) {
2794 camera.look(rotationAxis, -angle);
2795 } else if (defined(horizontalRotationAxis)) {
2796 camera.look(horizontalRotationAxis, -angle);
2797 } else {
2798 camera.lookLeft(angle);
2799 }
2800
2801 startPos.x = 0.0;
2802 startPos.y = movement.startPosition.y;
2803 endPos.x = 0.0;
2804 endPos.y = movement.endPosition.y;
2805
2806 startRay = camera.getPickRay(startPos, look3DStartRay);
2807 endRay = camera.getPickRay(endPos, look3DEndRay);

Callers 8

translateCVFunction · 0.85
rotateCVFunction · 0.85
rotateCVOnPlaneFunction · 0.85
rotateCVOnTerrainFunction · 0.85
spin3DFunction · 0.85
tilt3DFunction · 0.85
tilt3DOnEllipsoidFunction · 0.85
tilt3DOnTerrainFunction · 0.85

Calls 8

definedFunction · 0.50
addMethod · 0.45
subtractMethod · 0.45
normalizeMethod · 0.45
dotMethod · 0.45
negateMethod · 0.45
equalsEpsilonMethod · 0.45
crossMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…