(controller, startPosition, movement, rotationAxis)
| 2748 | const look3DTan = new Cartesian3(); |
| 2749 | |
| 2750 | function 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); |
no test coverage detected
searching dependent graphs…