Pause/stop/Continue 车辆移动实体

Pause/stop/Continue the vehicle moving entity

如何通过调用另一个函数来pause/stop车辆移动实体(停止车辆移动)?似乎无法使用 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;

}

暂停时钟:

viewer.clock.shouldAnimate = false;

您稍后可以通过以下方式取消暂停:

viewer.clock.shouldAnimate = true;