Loading...
We can record the current position and viewpoint of the camera and save it as a Landmark, and then when the camera parameters change, you can switch to any of the previously saved Landmark at any time, with a smooth switching animation, similar to the camera pan arm on a real set, also called flyTo
in some applications (e.g. Mapbox in application), example.
Create a Landmark with the following parameters.
position
The position of the camera in the world coordinate system, taking the type reference setPositionfocalPoint
Viewpoint in the world coordinate system, reference to the value type setFocalPointroll
Rotation angle, take the value type reference setRollzoom
Zoom scaling, take the value type reference setZoomcamera.createLandmark('mark1', {position: [300, 250, 400],focalPoint: [300, 250, 0],});camera.createLandmark('mark2', {position: [300, 600, 500],focalPoint: [300, 250, 0],});camera.createLandmark('mark3', {position: [0, 250, 800],focalPoint: [300, 250, 0],roll: 30,});
Switching to a previously saved Landmark works in both 2D and 3D scenes, example.
camera.gotoLandmark('mark1', { duration: 300, easing: 'ease-in' });// orcamera.gotoLandmark(landmark, { duration: 300, easing: 'ease-in' });
The list of parameters is as follows.
duration
Duration of the animation in ms
, default value is 100
.easing
Easing function, default value is linear
. Consistent with the animation system built-in effectseasingFunction
Custom easing function, when the built-in easing function can not meet the requirements, you can customonfinish
Callback function at the end of the animationAs with the options parameter in the animation system, passing number
is equivalent to setting duration
.
camera.gotoLandmark('mark1', { duration: 300 });camera.gotoLandmark('mark1', 300);
It is important to note that if another camera animation is called before the end of one, the animation in progress will be cancelled immediately.