123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- import defaultValue from "../../Core/defaultValue.js";
- import defined from "../../Core/defined.js";
- import destroyObject from "../../Core/destroyObject.js";
- import DeveloperError from "../../Core/DeveloperError.js";
- import EventHelper from "../../Core/EventHelper.js";
- import SceneMode from "../../Scene/SceneMode.js";
- import knockout from "../../ThirdParty/knockout.js";
- import createCommand from "../createCommand.js";
- function SceneModePickerViewModel(scene, duration) {
-
- if (!defined(scene)) {
- throw new DeveloperError("scene is required.");
- }
-
- this._scene = scene;
- var that = this;
- var morphStart = function (transitioner, oldMode, newMode, isMorphing) {
- that.sceneMode = newMode;
- that.dropDownVisible = false;
- };
- this._eventHelper = new EventHelper();
- this._eventHelper.add(scene.morphStart, morphStart);
- this._duration = defaultValue(duration, 2.0);
-
- this.sceneMode = scene.mode;
-
- this.dropDownVisible = false;
-
- this.tooltip2D = "2D";
-
- this.tooltip3D = "3D";
-
- this.tooltipColumbusView = "Columbus View";
- knockout.track(this, [
- "sceneMode",
- "dropDownVisible",
- "tooltip2D",
- "tooltip3D",
- "tooltipColumbusView",
- ]);
-
- this.selectedTooltip = undefined;
- knockout.defineProperty(this, "selectedTooltip", function () {
- var mode = that.sceneMode;
- if (mode === SceneMode.SCENE2D) {
- return that.tooltip2D;
- }
- if (mode === SceneMode.SCENE3D) {
- return that.tooltip3D;
- }
- return that.tooltipColumbusView;
- });
- this._toggleDropDown = createCommand(function () {
- that.dropDownVisible = !that.dropDownVisible;
- });
- this._morphTo2D = createCommand(function () {
- scene.morphTo2D(that._duration);
- });
- this._morphTo3D = createCommand(function () {
- scene.morphTo3D(that._duration);
- });
- this._morphToColumbusView = createCommand(function () {
- scene.morphToColumbusView(that._duration);
- });
-
- this._sceneMode = SceneMode;
- }
- Object.defineProperties(SceneModePickerViewModel.prototype, {
-
- scene: {
- get: function () {
- return this._scene;
- },
- },
-
- duration: {
- get: function () {
- return this._duration;
- },
- set: function (value) {
-
- if (value < 0.0) {
- throw new DeveloperError("duration value must be positive.");
- }
-
- this._duration = value;
- },
- },
-
- toggleDropDown: {
- get: function () {
- return this._toggleDropDown;
- },
- },
-
- morphTo2D: {
- get: function () {
- return this._morphTo2D;
- },
- },
-
- morphTo3D: {
- get: function () {
- return this._morphTo3D;
- },
- },
-
- morphToColumbusView: {
- get: function () {
- return this._morphToColumbusView;
- },
- },
- });
- SceneModePickerViewModel.prototype.isDestroyed = function () {
- return false;
- };
- SceneModePickerViewModel.prototype.destroy = function () {
- this._eventHelper.removeAll();
- destroyObject(this);
- };
- export default SceneModePickerViewModel;
|