1. A concise explanation of the problem you're experiencing.
Hello, can anyone help me?
I load 3d model and want make it fly from position 1 to position 2 in x second.
This is my code:
var viewer = this.global.map.viewer
var start = Cesium.JulianDate.fromDate(new Date(2015, 2, 25, 16));
var stop = Cesium.JulianDate.addSeconds(start, 200, new Cesium.JulianDate());
//Make sure viewer is at the desired time.
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
//viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP; //Loop at the end
viewer.clock.multiplier = 10;
let lat = 36.0994841
let lng = -112.110693
var property = new Cesium.SampledPositionProperty()
let p1 = Cesium.Cartesian3.fromDegrees(lng, lat, 0)
let time1 = Cesium.JulianDate.addSeconds(start, 0, new Cesium.JulianDate())
property.addSample(time1, p1)
let p2 = Cesium.Cartesian3.fromDegrees(lng + 0.001, lat, 0)
let time2 = Cesium.JulianDate.addSeconds(start, 50, new Cesium.JulianDate())
property.addSample(time2, p2)
var entity = viewer.entities.add({
// Set the entity availability to the same interval as the simulation time.
availability : new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start : start,
stop: stop,
})]),
//Use our computed positions
position : property,
//Automatically compute orientation based on position movement.
orientation : new Cesium.VelocityOrientationProperty(property),
//Load the Cesium plane model to represent the entity
model : {
uri : '/Cesium_Air.glb',
minimumPixelSize : 128,
maximumScale : 20000
},
//Show the path as a yellow line sampled in 1 second increments.
// path : {
// resolution : 1,
// material : new Cesium.PolylineGlowMaterialProperty({
// glowPower : 0.1,
// color : Cesium.Color.YELLOW
// }),
// width : 10
// }
});
viewer.trackedEntity = undefined;
viewer.zoomTo(viewer.entities, new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-90)));
setInterval(function(){
entity.position = p2
}, 5000);
Model will fly so smooth in to p2 and disappear but I want it pause and stay there (ex: wait to next move with listen event...)
So i use setInterval and set p2 to position. But now model fly smooth and "stop" in p2 not smooth.
Can anyone suggest me another solution without setInterval and model not disappear?
Thank you and sorry about my bad english.
OS: MacOS 10.12
Browser: Firefox 56
Cesium: 1.36