Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding the processing of the model after the conclusion of the clock animation #12347

Open
zyyyyyy456 opened this issue Nov 29, 2024 · 0 comments

Comments

@zyyyyyy456
Copy link

Feature

The animation is over, and the model will disappear or loop, but I want to achieve real-time vehicle trajectory playback. The animation playback is not continuous, and there may be delays. Therefore, during the waiting time for data, I want the model to still be displayed on the map. I don't understand why the model needs to disappear when the animation ends.

const timeStepInSeconds = 30;
const totalSeconds = timeStepInSeconds * (flightData.length - 1);
const start = Cesium.JulianDate.fromIso8601("2020-03-09T23:10:00Z");
const stop = Cesium.JulianDate.fromIso8601("2020-03-09T24:10:10Z");
// Cesium.JulianDate.addSeconds(
// start,
// totalSeconds,
// new Cesium.JulianDate()
// );
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
viewer.timeline.zoomTo(start, stop);
// Speed up the playback speed 50x.
viewer.clock.multiplier = 1;
// Start playing the scene.
viewer.clock.shouldAnimate = true;
viewer.clock.clockRange = Cesium.ClockRange.CLAMPED;
// The SampledPositionedProperty stores the position and timestamp for each sample along the radar sample series.
const positionProperty = new Cesium.SampledPositionProperty();
for (let i = 0; i < flightData.length; i++) {
const dataPoint = flightData[i];
const time = Cesium.JulianDate.fromIso8601(dataPoint.time);
const position = Cesium.Cartesian3.fromDegrees(
dataPoint.longitude,
dataPoint.latitude,
dataPoint.height
);

      positionProperty.addSample(time, position);
      viewer.entities.add({
        description: `Location: (${dataPoint.longitude}, ${dataPoint.latitude}, ${dataPoint.height})`,
        position: position,
        point: { pixelSize: 10, color: Cesium.Color.BLUE },
      });
    }

  async function loadModel() {
    console.log("loadModel");
    console.log(Cesium.TimeInterval);
    // Load the glTF model from Cesium ion.
    const airplaneUri = await Cesium.IonResource.fromAssetId("2867724");
    const airplaneEntity = viewer.entities.add({
      availability: new Cesium.TimeIntervalCollection([
        {
          start: start.clone(),
          stop: stop.clone(),
        },
      ]),
      position: positionProperty,
      // Attach the 3D model instead of the green point.
      model: { uri: airplaneUri },
      // Automatically compute the orientation from the position.
      orientation: new Cesium.VelocityOrientationProperty(positionProperty),
      path: new Cesium.PathGraphics({ width: 3 }),
    });

    viewer.trackedEntity = airplaneEntity;
    viewer.camera.setView({
      destination: Cesium.Cartesian3.fromDegrees(-122.39053, 37.61779, 500),
    });
  }
  loadModel();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant