视角向下
侧面视角
第一视角
//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 = bmgl.ClockRange.LOOP_STOP; //Loop at the end
viewer.clock.multiplier = 10;
//Set timeline to simulation bounds
viewer.timeline.zoomTo(start, stop);
//Generate a random circular pattern with varying heights.
function computeCirclularFlight(lon, lat, radius) {
var property = new bmgl.SampledPositionProperty();
for (var i = 0; i <= 360; i += 45) {
var radians = bmgl.Math.toRadians(i);
var time = bmgl.JulianDate.addSeconds(start, i, new bmgl.JulianDate());
var position = bmgl.Cartesian3.fromDegrees(lon + (radius * 1.5 * Math.cos(radians)), lat + (radius * Math.sin(radians)), bmgl.Math.nextRandomNumber() * 500 + 8750);
property.addSample(time, position);
//Also create a point for each sample we generate.
viewer.entities.add({
position: position,
point: {
pixelSize: 8,
color: bmgl.Color.TRANSPARENT,
outlineColor: bmgl.Color.YELLOW,
outlineWidth: 3
}
});
}
return property;
}
//Compute the entity position property.
var position = computeCirclularFlight(86.93047, 27.986914, 0.03);
viewer.camera.flyTo({
destination: bmgl.Cartesian3.fromDegrees(86.93047, 27.986914, 20000)
});
//Actually create the entity
entity = viewer.entities.add({
//Set the entity availability to the same interval as the simulation time.
availability: new bmgl.TimeIntervalCollection([new bmgl.TimeInterval({
start: start,
stop: stop
})]),
//Use our computed positions
position: position,
//Automatically compute orientation based on position movement.
orientation: new bmgl.VelocityOrientationProperty(position),
//Load the Cesium plane model to represent the entity
model: {
uri: '/bmgl/obj/plane.glb',
minimumPixelSize: 64,
scale:50,
},
//Show the path as a pink line sampled in 1 second increments.
path: {
resolution: 1,
material: new bmgl.PolylineGlowMaterialProperty({
glowPower: 0.1,
color: bmgl.Color.YELLOW
}),
width: 10
}
});
var viewModel = {
selection: ["折线", "光滑线", "Hermite光滑线"],
selectValue: 0
};
bmgl.knockout.track(viewModel);
/*给viewModel中的所有属性进行监测*/
var toolbar = document.getElementById('toolbar');
bmgl.knockout.applyBindings(viewModel, toolbar);
bmgl.knockout.getObservable(viewModel, 'selectValue').subscribe(
function (newValue) {
var that = this;
if (newValue == '折线') {
entity.position.setInterpolationOptions({
interpolationDegree: 1,
interpolationAlgorithm: bmgl.LinearApproximation
});
} else if (newValue == '光滑线') {
entity.position.setInterpolationOptions({
interpolationDegree: 5,
interpolationAlgorithm: bmgl.LagrangePolynomialApproximation
});
} else if (newValue == 'Hermite光滑线') {
entity.position.setInterpolationOptions({
interpolationDegree: 2,
interpolationAlgorithm: bmgl.HermitePolynomialApproximation
});
}
}
);
function ViewToDown() {
viewer.trackedEntity = undefined;
viewer.zoomTo(viewer.entities, new bmgl.HeadingPitchRange(0, bmgl.Math.toRadians(-90)));
}
function ViewToSide() {
viewer.trackedEntity = undefined;
viewer.zoomTo(viewer.entities, new bmgl.HeadingPitchRange(bmgl.Math.toRadians(-90), bmgl.Math.toRadians(-15), 7500));
}
function ViewToAircraft() {
viewer.trackedEntity = entity;
}
viewer.clock.shouldAnimate=true;