Created
March 21, 2015 21:50
-
-
Save FREEZX/9bd667aba73bbdf55d02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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