+ vertices.push(verticesRow);
+ }
+ for (var y = 0; y < heightSegments; ++y) {
+ for (var x = 0; x < widthSegments; ++x) {
+ var v1 = vertices[y][x + 1];
+ var v2 = vertices[y][x];
+ var v3 = vertices[y + 1][x];
+ var v4 = vertices[y + 1][x + 1];
+ var n1 = geometry.vertices[v1].clone().normalize();
+ var n2 = geometry.vertices[v2].clone().normalize();
+ var n3 = geometry.vertices[v3].clone().normalize();
+ var n4 = geometry.vertices[v4].clone().normalize();
+ geometry.faces.push(new THREE.Face3(v1, v2, v4, [n1, n2, n4]));
+ geometry.faces.push(new THREE.Face3(v2, v3, v4, [n2.clone(), n3, n4.clone()]));
+ }
+ }
+ geometry.computeFaceNormals();
+ geometry.boundingSphere = new THREE.Sphere(new THREE.Vector3(), radius + height);
+ return geometry;
+ };
+ return SimpleMarker;
+}(Component_1.Marker));
+exports.SimpleMarker = SimpleMarker;
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = SimpleMarker;
+
+},{"../../../Component":224,"three":174}],267:[function(require,module,exports){
+"use strict";
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var Observable_1 = require("rxjs/Observable");
+var Component_1 = require("../../Component");
+/**
+ * The `DoubleClickZoomHandler` allows the user to zoom the viewer photo at a point by double clicking.
+ */
+var DoubleClickZoomHandler = (function (_super) {
+ __extends(DoubleClickZoomHandler, _super);
+ function DoubleClickZoomHandler() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ DoubleClickZoomHandler.prototype._enable = function () {
+ var _this = this;
+ this._zoomSubscription = Observable_1.Observable
+ .merge(this._container.mouseService
+ .filtered$(this._component.name, this._container.mouseService.dblClick$), this._container.touchService.doubleTap$
+ .map(function (e) {
+ var touch = e.touches[0];
+ return { clientX: touch.clientX, clientY: touch.clientY, shiftKey: e.shiftKey };
+ }))
+ .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$)
+ .subscribe(function (_a) {
+ var event = _a[0], render = _a[1], transform = _a[2];
+ var element = _this._container.element;
+ var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
+ var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
+ var reference = transform.projectBasic(unprojected.toArray());
+ var delta = !!event.shiftKey ? -1 : 1;
+ _this._navigator.stateService.zoomIn(delta, reference);
+ });
+ };
+ DoubleClickZoomHandler.prototype._disable = function () {
+ this._zoomSubscription.unsubscribe();
+ };
+ DoubleClickZoomHandler.prototype._getConfiguration = function (enable) {
+ return { doubleClickZoom: enable };
+ };
+ return DoubleClickZoomHandler;
+}(Component_1.MouseHandlerBase));
+exports.DoubleClickZoomHandler = DoubleClickZoomHandler;
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = DoubleClickZoomHandler;
+
+},{"../../Component":224,"rxjs/Observable":28}],268:[function(require,module,exports){
+/// <reference path="../../../typings/index.d.ts" />
+"use strict";
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var THREE = require("three");
+var Observable_1 = require("rxjs/Observable");
+var Component_1 = require("../../Component");
+/**
+ * The `DragPanHandler` allows the user to pan the viewer photo by clicking and dragging the cursor.
+ */
+var DragPanHandler = (function (_super) {
+ __extends(DragPanHandler, _super);
+ function DragPanHandler(component, container, navigator, viewportCoords, spatial) {
+ var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
+ _this._spatial = spatial;
+ _this._basicRotationThreshold = 5e-2;
+ _this._forceCoeff = 2e-1;
+ return _this;
+ }
+ DragPanHandler.prototype._enable = function () {
+ var _this = this;
+ this._preventDefaultSubscription = Observable_1.Observable.merge(this._container.mouseService.mouseDragStart$, this._container.mouseService.mouseDrag$, this._container.touchService.touchMove$)
+ .subscribe(function (event) {
+ event.preventDefault(); // prevent selection of content outside the viewer
+ });
+ var draggingStarted$ = this._container.mouseService
+ .filtered$(this._component.name, this._container.mouseService.mouseDragStart$)
+ .map(function (event) {
+ return true;
+ });
+ var draggingStopped$ = this._container.mouseService
+ .filtered$(this._component.name, this._container.mouseService.mouseDragEnd$)
+ .map(function (event) {
+ return false;
+ });
+ this._activeMouseSubscription = Observable_1.Observable
+ .merge(draggingStarted$, draggingStopped$)
+ .subscribe(this._container.mouseService.activate$);
+ var touchMovingStarted$ = this._container.touchService.singleTouchDragStart$
+ .map(function (event) {
+ return true;
+ });
+ var touchMovingStopped$ = this._container.touchService.singleTouchDragEnd$
+ .map(function (event) {
+ return false;
+ });
+ this._activeTouchSubscription = Observable_1.Observable
+ .merge(touchMovingStarted$, touchMovingStopped$)
+ .subscribe(this._container.touchService.activate$);
+ this._rotateBasicSubscription = this._navigator.stateService.currentState$
+ .map(function (frame) {
+ return frame.state.currentNode.fullPano || frame.state.nodesAhead < 1;
+ })
+ .distinctUntilChanged()
+ .switchMap(function (enable) {
+ if (!enable) {
+ return Observable_1.Observable.empty();
+ }
+ var mouseDrag$ = Observable_1.Observable
+ .merge(_this._container.mouseService.filtered$(_this._component.name, _this._container.mouseService.mouseDragStart$), _this._container.mouseService.filtered$(_this._component.name, _this._container.mouseService.mouseDrag$), _this._container.mouseService.filtered$(_this._component.name, _this._container.mouseService.mouseDragEnd$)
+ .map(function (e) { return null; }))
+ .pairwise()
+ .filter(function (pair) {
+ return pair[0] != null && pair[1] != null;
+ });
+ var singleTouchDrag$ = Observable_1.Observable
+ .merge(_this._container.touchService.singleTouchDragStart$, _this._container.touchService.singleTouchDrag$, _this._container.touchService.singleTouchDragEnd$.map(function (t) { return null; }))
+ .map(function (event) {
+ return event != null && event.touches.length > 0 ?
+ event.touches[0] : null;
+ })
+ .pairwise()
+ .filter(function (pair) {
+ return pair[0] != null && pair[1] != null;
+ });
+ return Observable_1.Observable
+ .merge(mouseDrag$, singleTouchDrag$);
+ })
+ .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, this._navigator.stateService.currentCamera$)
+ .map(function (_a) {
+ var events = _a[0], render = _a[1], transform = _a[2], c = _a[3];
+ var camera = c.clone();
+ var previousEvent = events[0];
+ var event = events[1];
+ var movementX = event.clientX - previousEvent.clientX;
+ var movementY = event.clientY - previousEvent.clientY;
+ var element = _this._container.element;
+ var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
+ var currentDirection = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective)
+ .sub(render.perspective.position);
+ var directionX = _this._viewportCoords.unprojectFromCanvas(canvasX - movementX, canvasY, element, render.perspective)
+ .sub(render.perspective.position);
+ var directionY = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY - movementY, element, render.perspective)
+ .sub(render.perspective.position);
+ var deltaPhi = (movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection);
+ var deltaTheta = (movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection);
+ var upQuaternion = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
+ var upQuaternionInverse = upQuaternion.clone().inverse();
+ var offset = new THREE.Vector3();
+ offset.copy(camera.lookat).sub(camera.position);
+ offset.applyQuaternion(upQuaternion);
+ var length = offset.length();
+ var phi = Math.atan2(offset.y, offset.x);
+ phi += deltaPhi;
+ var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
+ theta += deltaTheta;
+ theta = Math.max(0.01, Math.min(Math.PI - 0.01, theta));
+ offset.x = Math.sin(theta) * Math.cos(phi);
+ offset.y = Math.sin(theta) * Math.sin(phi);
+ offset.z = Math.cos(theta);
+ offset.applyQuaternion(upQuaternionInverse);
+ var lookat = new THREE.Vector3().copy(camera.position).add(offset.multiplyScalar(length));
+ var basic = transform.projectBasic(lookat.toArray());
+ var original = transform.projectBasic(camera.lookat.toArray());
+ var x = basic[0] - original[0];
+ var y = basic[1] - original[1];
+ if (Math.abs(x) > 1) {
+ x = 0;
+ }
+ else if (x > 0.5) {
+ x = x - 1;
+ }
+ else if (x < -0.5) {
+ x = x + 1;
+ }
+ var rotationThreshold = _this._basicRotationThreshold;
+ x = _this._spatial.clamp(x, -rotationThreshold, rotationThreshold);
+ y = _this._spatial.clamp(y, -rotationThreshold, rotationThreshold);
+ if (transform.fullPano) {
+ return [x, y];
+ }
+ var pixelDistances = _this._viewportCoords.getPixelDistances(_this._container.element, transform, render.perspective);
+ var coeff = _this._forceCoeff;
+ if (pixelDistances[0] > 0 && y < 0 && basic[1] < 0.5) {
+ y /= Math.max(1, coeff * pixelDistances[0]);
+ }
+ if (pixelDistances[1] > 0 && x > 0 && basic[0] > 0.5) {
+ x /= Math.max(1, coeff * pixelDistances[1]);
+ }
+ if (pixelDistances[2] > 0 && y > 0 && basic[1] > 0.5) {
+ y /= Math.max(1, coeff * pixelDistances[2]);
+ }
+ if (pixelDistances[3] > 0 && x < 0 && basic[0] < 0.5) {
+ x /= Math.max(1, coeff * pixelDistances[3]);
+ }
+ return [x, y];
+ })
+ .subscribe(function (basicRotation) {
+ _this._navigator.stateService.rotateBasic(basicRotation);
+ });
+ };
+ DragPanHandler.prototype._disable = function () {
+ this._activeMouseSubscription.unsubscribe();
+ this._activeTouchSubscription.unsubscribe();
+ this._preventDefaultSubscription.unsubscribe();
+ this._rotateBasicSubscription.unsubscribe();
+ this._activeMouseSubscription = null;
+ this._activeTouchSubscription = null;
+ this._rotateBasicSubscription = null;
+ };
+ DragPanHandler.prototype._getConfiguration = function (enable) {
+ return { dragPan: enable };
+ };
+ return DragPanHandler;
+}(Component_1.MouseHandlerBase));
+exports.DragPanHandler = DragPanHandler;
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = DragPanHandler;
+
+},{"../../Component":224,"rxjs/Observable":28,"three":174}],269:[function(require,module,exports){
+/// <reference path="../../../typings/index.d.ts" />
+"use strict";
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var Observable_1 = require("rxjs/Observable");
+require("rxjs/add/observable/merge");
+require("rxjs/add/operator/filter");
+require("rxjs/add/operator/map");
+require("rxjs/add/operator/withLatestFrom");
+var Component_1 = require("../../Component");
+var Geo_1 = require("../../Geo");
+/**
+ * @class MouseComponent
+ *
+ * @classdesc Component handling mouse and touch events for camera movement.
+ */
+var MouseComponent = (function (_super) {
+ __extends(MouseComponent, _super);
+ function MouseComponent(name, container, navigator) {
+ var _this = _super.call(this, name, container, navigator) || this;
+ _this._basicDistanceThreshold = 1e-3;
+ _this._basicRotationThreshold = 5e-2;
+ _this._bounceCoeff = 1e-1;
+ var spatial = new Geo_1.Spatial();
+ var viewportCoords = new Geo_1.ViewportCoords();
+ _this._spatial = spatial;
+ _this._viewportCoords = viewportCoords;
+ _this._doubleClickZoomHandler = new Component_1.DoubleClickZoomHandler(_this, container, navigator, viewportCoords);
+ _this._dragPanHandler = new Component_1.DragPanHandler(_this, container, navigator, viewportCoords, spatial);
+ _this._scrollZoomHandler = new Component_1.ScrollZoomHandler(_this, container, navigator, viewportCoords);
+ _this._touchZoomHandler = new Component_1.TouchZoomHandler(_this, container, navigator, viewportCoords);
+ return _this;
+ }
+ Object.defineProperty(MouseComponent.prototype, "doubleClickZoom", {
+ /**
+ * Get double click zoom.
+ *
+ * @returns {DoubleClickZoomHandler} The double click zoom handler.
+ */
+ get: function () {
+ return this._doubleClickZoomHandler;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(MouseComponent.prototype, "dragPan", {
+ /**
+ * Get drag pan.
+ *
+ * @returns {DragPanHandler} The drag pan handler.
+ */
+ get: function () {
+ return this._dragPanHandler;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(MouseComponent.prototype, "scrollZoom", {
+ /**
+ * Get scroll zoom.
+ *
+ * @returns {ScrollZoomHandler} The scroll zoom handler.
+ */
+ get: function () {
+ return this._scrollZoomHandler;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(MouseComponent.prototype, "touchZoom", {
+ /**
+ * Get touch zoom.
+ *
+ * @returns {TouchZoomHandler} The touch zoom handler.
+ */
+ get: function () {
+ return this._touchZoomHandler;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ MouseComponent.prototype._activate = function () {
+ var _this = this;
+ this._configurationSubscription = this._configuration$
+ .subscribe(function (configuration) {
+ if (configuration.doubleClickZoom) {
+ _this._doubleClickZoomHandler.enable();
+ }
+ else {
+ _this._doubleClickZoomHandler.disable();
+ }
+ if (configuration.dragPan) {
+ _this._dragPanHandler.enable();
+ }
+ else {
+ _this._dragPanHandler.disable();
+ }
+ if (configuration.scrollZoom) {
+ _this._scrollZoomHandler.enable();
+ }
+ else {
+ _this._scrollZoomHandler.disable();
+ }
+ if (configuration.touchZoom) {
+ _this._touchZoomHandler.enable();
+ }
+ else {
+ _this._touchZoomHandler.disable();
+ }
+ });
+ var inTransition$ = this._navigator.stateService.currentState$
+ .map(function (frame) {
+ return frame.state.alpha < 1;
+ });
+ this._bounceSubscription = Observable_1.Observable
+ .combineLatest(inTransition$, this._navigator.stateService.inTranslation$, this._container.mouseService.active$, this._container.touchService.active$)
+ .map(function (noForce) {
+ return noForce[0] || noForce[1] || noForce[2] || noForce[3];
+ })
+ .distinctUntilChanged()
+ .switchMap(function (noForce) {
+ return noForce ?
+ Observable_1.Observable.empty() :
+ Observable_1.Observable.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$.first());
+ })
+ .subscribe(function (args) {
+ var renderCamera = args[0];
+ var perspectiveCamera = renderCamera.perspective;
+ var transform = args[1];
+ var distanceThreshold = _this._basicDistanceThreshold / Math.pow(2, renderCamera.zoom);
+ var basicCenter = _this._viewportCoords.viewportToBasic(0, 0, transform, perspectiveCamera);
+ if (Math.abs(basicCenter[0] - 0.5) < distanceThreshold && Math.abs(basicCenter[1] - 0.5) < distanceThreshold) {
+ return;
+ }
+ var basicDistances = _this._viewportCoords.getBasicDistances(transform, perspectiveCamera);
+ var basicX = 0;
+ var basicY = 0;
+ if (basicDistances[0] < distanceThreshold && basicDistances[1] < distanceThreshold &&
+ basicDistances[2] < distanceThreshold && basicDistances[3] < distanceThreshold) {
+ return;
+ }
+ if (Math.abs(basicDistances[0] - basicDistances[2]) < distanceThreshold &&
+ Math.abs(basicDistances[1] - basicDistances[3]) < distanceThreshold) {
+ return;
+ }
+ var coeff = _this._bounceCoeff;
+ if (basicDistances[1] > 0 && basicDistances[3] === 0) {
+ basicX = -coeff * basicDistances[1];
+ }
+ else if (basicDistances[1] === 0 && basicDistances[3] > 0) {
+ basicX = coeff * basicDistances[3];
+ }
+ else if (basicDistances[1] > 0 && basicDistances[3] > 0) {
+ basicX = coeff * (basicDistances[3] - basicDistances[1]) / 2;
+ }
+ if (basicDistances[0] > 0 && basicDistances[2] === 0) {
+ basicY = coeff * basicDistances[0];
+ }
+ else if (basicDistances[0] === 0 && basicDistances[2] > 0) {
+ basicY = -coeff * basicDistances[2];
+ }
+ else if (basicDistances[0] > 0 && basicDistances[2] > 0) {
+ basicY = coeff * (basicDistances[0] - basicDistances[2]) / 2;
+ }
+ var rotationThreshold = _this._basicRotationThreshold;
+ basicX = _this._spatial.clamp(basicX, -rotationThreshold, rotationThreshold);
+ basicY = _this._spatial.clamp(basicY, -rotationThreshold, rotationThreshold);
+ _this._navigator.stateService.rotateBasicUnbounded([basicX, basicY]);
+ });
+ this._container.mouseService.claimMouse(this._name, 0);
+ };
+ MouseComponent.prototype._deactivate = function () {
+ this._container.mouseService.unclaimMouse(this._name);
+ this._bounceSubscription.unsubscribe();
+ this._configurationSubscription.unsubscribe();
+ this._doubleClickZoomHandler.disable();
+ this._dragPanHandler.disable();
+ this._scrollZoomHandler.disable();
+ this._touchZoomHandler.disable();
+ };
+ MouseComponent.prototype._getDefaultConfiguration = function () {
+ return { doubleClickZoom: true, dragPan: true, scrollZoom: true, touchZoom: true };
+ };
+ return MouseComponent;
+}(Component_1.Component));
+/** @inheritdoc */
+MouseComponent.componentName = "mouse";
+exports.MouseComponent = MouseComponent;
+Component_1.ComponentService.register(MouseComponent);
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = MouseComponent;
+
+},{"../../Component":224,"../../Geo":227,"rxjs/Observable":28,"rxjs/add/observable/merge":43,"rxjs/add/operator/filter":60,"rxjs/add/operator/map":64,"rxjs/add/operator/withLatestFrom":82}],270:[function(require,module,exports){
+"use strict";
+var MouseHandlerBase = (function () {
+ function MouseHandlerBase(component, container, navigator, viewportCoords) {
+ this._component = component;
+ this._container = container;
+ this._navigator = navigator;
+ this._viewportCoords = viewportCoords;
+ this._enabled = false;
+ }
+ Object.defineProperty(MouseHandlerBase.prototype, "isEnabled", {
+ /**
+ * Returns a Boolean indicating whether the interaction is enabled.
+ *
+ * @returns {boolean} `true` if the interaction is enabled.
+ */
+ get: function () {
+ return this._enabled;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ /**
+ * Enables the interaction.
+ *
+ * @example ```mouseComponent.<handler-name>.enable();```
+ */
+ MouseHandlerBase.prototype.enable = function () {
+ if (this._enabled || !this._component.activated) {
+ return;
+ }
+ this._enable();
+ this._enabled = true;
+ this._component.configure(this._getConfiguration(true));
+ };
+ /**
+ * Disables the interaction.
+ *
+ * @example ```mouseComponent.<handler-name>.disable();```
+ */
+ MouseHandlerBase.prototype.disable = function () {
+ if (!this._enabled) {
+ return;
+ }
+ this._disable();
+ this._enabled = false;
+ if (this._component.activated) {
+ this._component.configure(this._getConfiguration(false));
+ }
+ };
+ return MouseHandlerBase;
+}());
+exports.MouseHandlerBase = MouseHandlerBase;
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = MouseHandlerBase;
+
+},{}],271:[function(require,module,exports){
+"use strict";
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var Component_1 = require("../../Component");
+/**
+ * The `ScrollZoomHandler` allows the user to zoom the viewer photo by scrolling.
+ */
+var ScrollZoomHandler = (function (_super) {
+ __extends(ScrollZoomHandler, _super);
+ function ScrollZoomHandler() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ ScrollZoomHandler.prototype._enable = function () {
+ var _this = this;
+ this._preventDefaultSubscription = this._container.mouseService.mouseWheel$
+ .subscribe(function (event) {
+ event.preventDefault();
+ });
+ this._zoomSubscription = this._container.mouseService
+ .filtered$(this._component.name, this._container.mouseService.mouseWheel$)
+ .withLatestFrom(this._navigator.stateService.currentState$, function (w, f) {
+ return [w, f];
+ })
+ .filter(function (args) {
+ var state = args[1].state;
+ return state.currentNode.fullPano || state.nodesAhead < 1;
+ })
+ .map(function (args) {
+ return args[0];
+ })
+ .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (w, r, t) {
+ return [w, r, t];
+ })
+ .subscribe(function (args) {
+ var event = args[0];
+ var render = args[1];
+ var transform = args[2];
+ var element = _this._container.element;
+ var _a = _this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
+ var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
+ var reference = transform.projectBasic(unprojected.toArray());
+ var deltaY = event.deltaY;
+ if (event.deltaMode === 1) {
+ deltaY = 40 * deltaY;
+ }
+ else if (event.deltaMode === 2) {
+ deltaY = 800 * deltaY;