原版本涉及到坐标系变化和矩阵变换,在对原版的思路掌握后,特写一个精简版,帮助大家理解。
function zoom(movement, feature) {
const longitude = Cesium.Math.toRadians(feature.getProperty("Longitude"));
const latitude = Cesium.Math.toRadians(feature.getProperty("Latitude"));
const height = feature.getProperty("Height");
const positionCartographic = new Cesium.Cartographic(
longitude,
latitude,
height * 0.5
);
const position =
viewer.scene.globe.ellipsoid.cartographicToCartesian(positionCartographic);
const camera = viewer.camera;
const heading = camera.heading;
const pitch = camera.pitch;
const direction = viewer.camera.direction;
const ScaleDirection = Cesium.Cartesian3.multiplyByScalar(
Cesium.Cartesian3.negate(direction, new Cesium.Cartesian3()),
height * 2,
new Cesium.Cartesian3()
);
const cameraPos = Cesium.Cartesian3.add(
position,
ScaleDirection,
new Cesium.Cartesian3()
);
camera.flyTo({
destination: cameraPos,
orientation: {
heading: heading,
pitch: pitch,
},
easingFunction: Cesium.EasingFunction.QUADRATIC_OUT,
});
}
标签:Interactivity,const,Cartesian3,pitch,zoom,feature,camera,3dtiles,Cesium From: https://www.cnblogs.com/HRDK-CADeveloper/p/17603587.html