var viewer = new Cesium.Viewer('cesiumContainer', {
sceneMode: 2,
infoBox: false, //Disable InfoBox widget
selectionIndicator: false, //Disable selection indicator
shouldAnimate: true, // Enable animations
terrainProvider: Cesium.createWorldTerrain()
});
//Enable lighting based on the sun position
viewer.scene.globe.enableLighting = true;
//Enable depth testing so things behind the terrain disappear.
viewer.scene.globe.depthTestAgainstTerrain = true;
//Set the random number seed for consistent results.
Cesium.Math.setRandomNumberSeed(3);
//Set bounds of our simulation time
var start = Cesium.JulianDate.fromDate(new Date(2015, 2, 25, 16));
var stop = Cesium.JulianDate.addSeconds(start, 360, 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;
//Set timeline to simulation bounds
viewer.timeline.zoomTo(start, stop);
function computeCirclularFlight(start) {
var polyLinePositions=[
[70, 20, 150000,],
[-80, 44, 150000,],
[-90, 18, 150000,],
[-98, 52, 150000,]
]
var property = new Cesium.SampledPositionProperty();
for (var i = 0; i < polyLinePositions.length; i++) {
var time = Cesium.JulianDate.addSeconds(start, i * 10, new Cesium.JulianDate());
// 将经纬度坐标转换为三维空间坐标
var position = Cesium.Cartesian3.fromDegrees(polyLinePositions[i][0], polyLinePositions[i][1], polyLinePositions[i][2]);
// Property最大的特点是和时间相互关联,在不同的时间可以动态地返回不同的属性值;
// Entity则可以感知这些Property的变化,在不同的时间驱动物体进行动态展示;
property.addSample(time, position);
}
return property;
}
//Compute the entity position property.
var position = computeCirclularFlight(start);
//Actually create the entity
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 : position,//Automatically compute orientation based on position movement.
orientation : new Cesium.VelocityOrientationProperty(position),
//Load the Cesium plane model to represent the entity
"billboard" : {
"image" :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jMgMTM5Ljc0NTg4MnpNNTQ0LjUyNzA1OSA4OTAuMjc3NjQ3bDkuNjM3NjQ3LTI2MC4yMTY0NzEtMTguMDcwNTg4IDMuNjE0MTE4IDguNDMyOTQxIDI1Ni42MDIzNTN6IiBwLWlkPSIzNjA0IiBmaWxsPSIjZDgxZTA2Ij48L3BhdGg+PC9zdmc+",
"scale" : 0.5,
"alignedAxis" : new Cesium.VelocityVectorProperty(position, true)
},
//将路径显示为以0.1秒为增量采样的路径线。
path : {
resolution : 0.1,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.1,
color : Cesium.Color.YELLOW
}),
width :3
},
// 贴底线
// polyline : {
// positions : Cesium.Cartesian3.fromDegreesArray([70, 20,-80, 44,-90, 18,-98, 52,]),
// width : 3,
// material : Cesium.Color.YELLOW,
// clampToGround : true
// }
});
//~~~~~~~~~~~~~~~~~~~~平滑插值~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// entity.position.setInterpolationOptions({
// interpolationDegree:5, //1 2 5
// interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
// })
Cesium:entity实体二维贴地运动+模型转向
最新推荐文章于 2024-07-26 16:42:09 发布