Hi everyone!
By loading czml, I want a vehicle to dynamically move along the polyline as time changes.
polyline is loaded out,but vehicle did not load. Here are the results
I want the vehicle to move dynamically along the polyline. Is there an easy way to do this, I feel like I’m doing it the wrong way
Here is my code.
var viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: Cesium.createWorldTerrain(),
});
var scene = viewer.scene;
var clock = viewer.clock;
var position1 = Cesium.Cartesian3.fromDegrees(103.667886, 32.051531);
var position2 = Cesium.Cartesian3.fromDegrees(103.664483, 32.054231);
var position3 = Cesium.Cartesian3.fromDegrees(103.662779, 32.057314);
//get positions terrainHeight
var terrainProvider = Cesium.createWorldTerrain();
var positions = [
Cesium.Cartographic.fromDegrees(103.667886, 32.051531),
Cesium.Cartographic.fromDegrees(103.664483, 32.054231),
Cesium.Cartographic.fromDegrees(103.662779, 32.057314)
];
var promise = Cesium.sampleTerrainMostDetailed(terrainProvider, positions);
Cesium.when(promise, function (updatedPositions) {
var terrainHeight1 = updatedPositions[0].height;
var terrainHeight2 = updatedPositions[1].height;
var terrainHeight3 = updatedPositions[2].height;
console.log(terrainHeight1);
console.log(terrainHeight2);
console.log(terrainHeight3);
});
var czml = [{
“id”: “document”,
“version”: “1.0”,
“clock”: {
“interval”: “2018-07-19T15:18:00Z/2018-07-19T15:18:30Z”,
“currentTime”: “2018-07-19T15:18:00Z”,
“multiplier”: 5,
“range”: “LOOP_STOP”,
“step”: “SYSTEM_CLOCK_MULTIPLIER”
}
},
{
"id": "CesiumMilkTruck",
"model": {
"gltf": "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb",
"scale": 500
},
"position": {
"interpolationAlgorithm": "LINEAR",
"forwardExtrapolationType": "HOLD",
"cartesian": [
"2018-07-19T15:18:00Z",
position1.x, position1.y, 2115.5071695027223,
"2018-07-19T15:18:15Z",
position2.x, position2.y, 2143.748176028439,
"2018-07-19T15:18:30Z",
position3.x, position3.y, 2167.1735560478137
]
}
},
{
"id": "polyline",
"polyline": {
"positions": {
"cartographicDegrees": [
103.667886, 32.051531, 0,
103.664483, 32.054231, 0,
103.662779, 32.057314, 0,
103.658926, 32.063334, 0,
103.646179, 32.067430, 0
]
},
"material": {
"polylineOutline": {
"color": {
"rgba": [255, 0, 255, 255]
},
"outlineColor": {
"rgba": [0, 255, 255, 255]
},
"outlineWidth": 5
}
},
"width": 8,
"clampToGround": true
}
}
]
dataSource = new Cesium.CzmlDataSource();
dataSource.load(czml);
viewer.dataSources.add(dataSource);
