Cesiun 之 CallbackProperty

CallbackProperty

Cesium号称是集显示时空数据于一体的三维引擎。空间数据的展示我们已经见到,对于时间上的数据,我觉得CallbackProperty是最大功臣。因为使用CallbackProperty,cesium中一切可视化的要素都可以与时间联系起来。

new Cesium.CallbackProperty(getEndPoint, isConstant)
function getEndPoint (time, result) {
    endLongitude = startLongitude - 0.001 * Cesium.JulianDate.secondsDifference(time, startTime);
    return Cesium.Cartesian3.fromDegreesArray(
        [startLongitude, startLatitude, endLongitude, startLatitude],
        Cesium.Ellipsoid.WGS84,
        result
    );
}

官方示例

// CallbackProperty 中 回调函数 不一定要和时间挂钩 也可以是通过事件去控制 

let positions = []
viewer.entities.add({
    polyline: {
        positions: new Cesium.CallbackProperty(() => positions, false),
        width: 5,
        arcType: Cesium.ArcType.RHUMB,
        material: Cesium.Color.GREEN,
    }
});
// 通过add 事件去改变positions 这样也可以改变entities
function add() {
    positions.push(...)
}

posted @ 2022-08-31 14:52  有点油  阅读(1112)  评论(0编辑  收藏  举报