暂停/停止/继续车辆移动实体

avwztpqn  于 2021-09-23  发布在  Java
关注(0)|答案(1)|浏览(370)

如何通过调用另一个函数暂停/停止车辆移动实体(停止车辆移动)?似乎无法使用 viewModel.pauseViewModel.command(); . 如果有人能演示如何为移动实体提供暂停和继续,请不胜感激。

function togglesimulation() {

    Cesium.Math.setRandomNumberSeed(3);

    var start = Cesium.JulianDate.fromDate(new Date(2021, 6, 29, 16));
    var stop = Cesium.JulianDate.addSeconds(start, 300, new Cesium.JulianDate);

    //Make sure viewer is at the desired time.
    var clock = new Cesium.Clock();
    viewer.clock.startTime = start.clone();
    viewer.clock.stopTime = stop.clone();
    viewer.clock.currentTime = start.clone();
    viewer.clock.clockRange = Cesium.ClockRange.CLAMPED; // stop at the end
    viewer.clock.multiplier = clockmultiplier;
    viewer.clock.shouldAnimate = true;

    var position = new Cesium.SampledPositionProperty();
    var time = Cesium.JulianDate.addSeconds(start, 120, new Cesium.JulianDate());

    var timeStepInSeconds = 5;
    var newPositions = mergedgeom1;

    for (var i = 0; i < newPositions.length; i++) {
        var poss = Cesium.Cartesian3.fromDegrees(parseFloat(newPositions[i][0]), parseFloat(newPositions[i][1])); //height
        var time = Cesium.JulianDate.addSeconds(start, i * timeStepInSeconds, new Cesium.JulianDate());

        position.addSample(time, poss);
    }

    var entity = viewer.entities.add({
        availability: new Cesium.TimeIntervalCollection([
            new Cesium.TimeInterval({
                start: start,
                stop: stop,
            }),
        ]),
        model: {
            uri: "../asset/vehicle/CesiumMilkTruck/CesiumMilkTruck.glb",
            minimumPixelSize: 64,
        },
        viewFrom: new Cesium.Cartesian3(-100.0, 0.0, 100.0),
        position: position,
        orientation: new Cesium.VelocityOrientationProperty(position),
    });
    viewer.trackedEntity = entity;

    var scene = viewer.scene;

}
3yhwsihp

3yhwsihp1#

使用以下命令暂停时钟:

viewer.clock.shouldAnimate = false;

您可以稍后使用以下命令取消暂停:

viewer.clock.shouldAnimate = true;

相关问题