123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import BoundingSphere from "../Core/BoundingSphere.js";
- import combine from "../Core/combine.js";
- import defined from "../Core/defined.js";
- import EasingFunction from "../Core/EasingFunction.js";
- function KmlTourFlyTo(duration, flyToMode, view) {
- this.type = "KmlTourFlyTo";
- this.blocking = true;
- this.activeCamera = null;
- this.activeCallback = null;
- this.duration = duration;
- this.view = view;
- this.flyToMode = flyToMode;
- }
- KmlTourFlyTo.prototype.play = function (done, camera, cameraOptions) {
- this.activeCamera = camera;
- if (defined(done) && done !== null) {
- var self = this;
- this.activeCallback = function (terminated) {
- delete self.activeCallback;
- delete self.activeCamera;
- done(defined(terminated) ? false : terminated);
- };
- }
- var options = this.getCameraOptions(cameraOptions);
- if (this.view.headingPitchRoll) {
- camera.flyTo(options);
- } else if (this.view.headingPitchRange) {
- var target = new BoundingSphere(this.view.position);
- camera.flyToBoundingSphere(target, options);
- }
- };
- KmlTourFlyTo.prototype.stop = function () {
- if (defined(this.activeCamera)) {
- this.activeCamera.cancelFlight();
- }
- if (defined(this.activeCallback)) {
- this.activeCallback(true);
- }
- };
- KmlTourFlyTo.prototype.getCameraOptions = function (cameraOptions) {
- var options = {
- duration: this.duration,
- };
- if (defined(this.activeCallback)) {
- options.complete = this.activeCallback;
- }
- if (this.flyToMode === "smooth") {
- options.easingFunction = EasingFunction.LINEAR_NONE;
- }
- if (this.view.headingPitchRoll) {
- options.destination = this.view.position;
- options.orientation = this.view.headingPitchRoll;
- } else if (this.view.headingPitchRange) {
- options.offset = this.view.headingPitchRange;
- }
- if (defined(cameraOptions)) {
- options = combine(options, cameraOptions);
- }
- return options;
- };
- export default KmlTourFlyTo;
|