Skip to content

Instantly share code, notes, and snippets.

@FREEZX
Created March 21, 2015 21:49
Show Gist options
  • Select an option

  • Save FREEZX/12d4b2144c4471b8b5da to your computer and use it in GitHub Desktop.

Select an option

Save FREEZX/12d4b2144c4471b8b5da to your computer and use it in GitHub Desktop.
var viewer = new Cesium.Viewer('cesiumContainer');
var Nuke = function(){
var self = this;
this.degrees = [0, 0, 5000];
this.heading = 0;
this.pitch = Cesium.Math.toRadians(270);
this.roll = 0;
this.position = Cesium.Cartesian3.fromDegrees.apply(null, this.degrees);
this.startPosition = new Cesium.Cartesian3();
this.position.clone(this.startPosition);
this.position = new Cesium.Cartesian3(-3476505.5760482615, 5353349.133063745, 0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(this.position, this.heading, this.pitch, this.roll);
var trail = viewer.entities.add({
polyline : {
positions : [this.startPosition, this.position],
width : 10.0,
material : new Cesium.PolylineGlowMaterialProperty({
color : Cesium.Color.DEEPSKYBLUE,
glowPower : 0.25
})
}
});
this.trailEntity = trail;
// Create a draw loop using requestAnimationFrame. The
// tick callback function is called for every animation frame.
function tick() {
self.update();
self.updateFrame = Cesium.requestAnimationFrame(tick);
}
tick();
};
Nuke.prototype.update = function(){
this.degrees[0] += 0.05;
this.position = Cesium.Cartesian3.fromDegrees.apply(null, this.degrees);
// this.trailEntity.polyline.positions = [this.startPosition, new Cesium.Cartesian3(-3476505.5760482615, 5353349.133063745, 0)];
};
Nuke.prototype.destroy = function(){
viewer.entities.remove(this.entity);
Cesium.cancelAnimationFrame(this.updateFrame);
};
new Nuke();
viewer.zoomTo(viewer.entities);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment