数组按点顺序执行
2021-12-06 本文已影响0人
宿州刘德华
const ddddffff = [
{
lng: 119.89537542677047,
lat: 32.437863934227366,
height: 23.993530252481897,
heading: 315.3629340699483,
pitch: -38.755310859117905,
roll: 359.8429874844901
},
{
lng: 119.8954021718191,
lat: 32.438087280546384,
height: 29.475413510980506,
heading: 315.3629344352534,
pitch: -38.75531039824164,
roll: 359.8429869009309
},
{
lng: 119.89561457847132,
lat: 32.438250889315604,
height: 55.26582147804471,
heading: 315.36293491930945,
pitch: -38.755309787547404,
roll: 359.8429861276736
},
{
lng: 119.8928361237956,
lat: 32.43844145648772,
height: 153.20149224440027,
heading: 95.4788982780769,
pitch: -32.17973804367229,
roll: 0.2045712752189138
}
]
function f(p) {
if (p && p.length > 0) {
let d = p[0]
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(d.lng, d.lat, d.height),
orientation: {
heading: Cesium.Math.toRadians(d.heading),
pitch: Cesium.Math.toRadians(d.pitch),
roll: Cesium.Math.toRadians(d.roll)
},
complete: () => {
p.shift() //删除数组下标为0的
s(f, p)
// f(p)
}
})
}
}
function s(f, ds) {
setTimeout(() => {
if (typeof f === 'function') {
f(ds)
}
}, 3000)
}
export const testFlyCamera = () => {
f(ddddffff)
}