photo-sphere-viewer
Advanced tools
Comparing version 4.4.2 to 4.4.3
@@ -1,2 +0,2 @@ | ||
import { AbstractAdapter } from 'photo-sphere-viewer'; | ||
import { AbstractAdapter, Viewer } from 'photo-sphere-viewer'; | ||
@@ -21,2 +21,6 @@ /** | ||
type CubemapAdapterOptions = { | ||
flipTopBottom?: boolean; | ||
}; | ||
/** | ||
@@ -27,4 +31,6 @@ * @summary Adapter for cubemaps | ||
constructor(psv: Viewer, options: CubemapAdapterOptions); | ||
} | ||
export { Cubemap, CubemapAdapter, CubemapArray }; | ||
export { Cubemap, CubemapAdapter, CubemapAdapterOptions, CubemapArray }; |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -13,2 +13,20 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
@@ -41,5 +59,11 @@ subClass.prototype = Object.create(superClass.prototype); | ||
/** | ||
* @typedef {Object} PSV.adapters.CubemapAdapter.Options | ||
* @property {boolean} [flipTopBottom=false] - set to true if the top and bottom faces are not correctly oriented | ||
*/ | ||
var CUBE_VERTICES = 8; | ||
var CUBE_MAP = [0, 2, 4, 5, 3, 1]; | ||
var CUBE_HASHMAP = ['left', 'right', 'top', 'bottom', 'back', 'front']; | ||
var VECTOR2D_CENTER = new THREE.Vector2(0.5, 0.5); | ||
/** | ||
@@ -53,8 +77,20 @@ * @summary Adapter for cubemaps | ||
function CubemapAdapter() { | ||
return _AbstractAdapter.apply(this, arguments) || this; | ||
} | ||
/** | ||
* @param {PSV.Viewer} psv | ||
* @param {PSV.adapters.CubemapAdapter.Options} options | ||
*/ | ||
function CubemapAdapter(psv, options) { | ||
var _this; | ||
var _proto = CubemapAdapter.prototype; | ||
_this = _AbstractAdapter.call(this, psv) || this; | ||
/** | ||
* @member {PSV.adapters.CubemapAdapter.Options} | ||
* @private | ||
*/ | ||
_this.config = _extends({ | ||
flipTopBottom: false | ||
}, options); | ||
return _this; | ||
} | ||
/** | ||
@@ -65,4 +101,8 @@ * @override | ||
*/ | ||
var _proto = CubemapAdapter.prototype; | ||
_proto.loadTexture = function loadTexture(panorama) { | ||
var _this = this; | ||
var _this2 = this; | ||
@@ -103,8 +143,8 @@ var cleanPanorama = []; | ||
var _loop = function _loop(_i) { | ||
promises.push(_this.psv.textureLoader.loadImage(cleanPanorama[_i], function (p) { | ||
promises.push(_this2.psv.textureLoader.loadImage(cleanPanorama[_i], function (p) { | ||
progress[_i] = p; | ||
_this.psv.loader.setProgress(photoSphereViewer.utils.sum(progress) / 6); | ||
_this2.psv.loader.setProgress(photoSphereViewer.utils.sum(progress) / 6); | ||
}).then(function (img) { | ||
return _this.__createCubemapTexture(img); | ||
return _this2.__createCubemapTexture(img); | ||
})); | ||
@@ -186,2 +226,7 @@ }; | ||
if (this.config.flipTopBottom && (i === 2 || i === 3)) { | ||
texture[i].center = VECTOR2D_CENTER; | ||
texture[i].rotation = Math.PI; | ||
} | ||
mesh.material[i].map = texture[i]; | ||
@@ -188,0 +233,0 @@ } |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -4,0 +4,0 @@ * @copyright 2015-2022 Damien "Mistic" Sorel |
@@ -854,2 +854,7 @@ import { Texture, Mesh, Vector3, Intersection } from 'three'; | ||
/** | ||
* @summary Initializes the plugin | ||
*/ | ||
init(); | ||
/** | ||
* @summary Destroys the plugin | ||
@@ -856,0 +861,0 @@ */ |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -47,10 +47,2 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
/** | ||
@@ -116,5 +108,3 @@ * @typedef {PSV.ExtendedPosition|string|Object} PSV.plugins.AutorotateKeypointsPlugin.Keypoints | ||
startFromClosest: true | ||
}, options, { | ||
keypoints: null | ||
}); | ||
}, options); | ||
/** | ||
@@ -130,13 +120,24 @@ * @type {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints | ||
_this.markers = _this.psv.getPlugin('markers'); | ||
_this.markers = null; | ||
return _this; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
if (options != null && options.keypoints) { | ||
_this.setKeypoints(options.keypoints); | ||
} | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.AUTOROTATE, _assertThisInitialized(_this)); | ||
var _proto = AutorotateKeypointsPlugin.prototype; | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, _assertThisInitialized(_this)); | ||
_proto.init = function init() { | ||
_AbstractPlugin.prototype.init.call(this); | ||
return _this; | ||
this.markers = this.psv.getPlugin('markers'); | ||
if (this.config.keypoints) { | ||
this.setKeypoints(this.config.keypoints); | ||
delete this.config.keypoints; | ||
} | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.AUTOROTATE, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this); | ||
} | ||
@@ -146,6 +147,4 @@ /** | ||
*/ | ||
; | ||
var _proto = AutorotateKeypointsPlugin.prototype; | ||
_proto.destroy = function destroy() { | ||
@@ -156,3 +155,2 @@ this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.AUTOROTATE, this); | ||
delete this.keypoints; | ||
delete this.state; | ||
@@ -159,0 +157,0 @@ _AbstractPlugin.prototype.destroy.call(this); |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -121,3 +121,3 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
_this.markers = _this.psv.getPlugin('markers'); | ||
_this.markers = null; | ||
/** | ||
@@ -142,3 +142,13 @@ * @member {HTMLElement} | ||
} | ||
/** | ||
* @member {HTMLCanvasElement} | ||
* @readonly | ||
* @private | ||
*/ | ||
_this.canvas = document.createElement('canvas'); | ||
_this.container.appendChild(_this.canvas); | ||
if (_this.config.navigation) { | ||
@@ -154,22 +164,8 @@ _this.container.addEventListener('mouseenter', _assertThisInitialized(_this)); | ||
_this.container.addEventListener('mouseup', _assertThisInitialized(_this)); | ||
} | ||
_this.psv.container.appendChild(_this.container); | ||
/** | ||
* @member {HTMLCanvasElement} | ||
* @readonly | ||
* @private | ||
*/ | ||
_this.container.addEventListener('touchstart', _assertThisInitialized(_this)); | ||
_this.container.addEventListener('touchmove', _assertThisInitialized(_this)); | ||
_this.canvas = document.createElement('canvas'); | ||
_this.canvas.width = _this.container.clientWidth * photoSphereViewer.SYSTEM.pixelRatio; | ||
_this.canvas.height = _this.container.clientWidth * photoSphereViewer.SYSTEM.pixelRatio; | ||
_this.container.appendChild(_this.canvas); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.RENDER, _assertThisInitialized(_this)); | ||
if (_this.markers) { | ||
_this.markers.on('set-markers', _assertThisInitialized(_this)); | ||
_this.container.addEventListener('touchend', _assertThisInitialized(_this)); | ||
} | ||
@@ -186,2 +182,20 @@ | ||
_proto.init = function init() { | ||
_AbstractPlugin.prototype.init.call(this); | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.psv.container.appendChild(this.container); | ||
this.canvas.width = this.container.clientWidth * photoSphereViewer.SYSTEM.pixelRatio; | ||
this.canvas.height = this.container.clientWidth * photoSphereViewer.SYSTEM.pixelRatio; | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.RENDER, this); | ||
if (this.markers) { | ||
this.markers.on('set-markers', this); | ||
} | ||
} | ||
/** | ||
* @package | ||
*/ | ||
; | ||
_proto.destroy = function destroy() { | ||
@@ -206,2 +220,4 @@ this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.RENDER, this); | ||
_proto.handleEvent = function handleEvent(e) { | ||
var _e$changedTouches, _e$changedTouches2; | ||
switch (e.type) { | ||
@@ -226,3 +242,4 @@ case photoSphereViewer.CONSTANTS.EVENTS.RENDER: | ||
case 'mousemove': | ||
this.prop.mouse = e; | ||
case 'touchmove': | ||
this.prop.mouse = ((_e$changedTouches = e.changedTouches) == null ? void 0 : _e$changedTouches[0]) || e; | ||
@@ -236,10 +253,15 @@ if (this.prop.mouseDown) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
break; | ||
case 'mousedown': | ||
case 'touchstart': | ||
this.prop.mouseDown = true; | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
break; | ||
case 'mouseup': | ||
this.prop.mouse = e; | ||
case 'touchend': | ||
this.prop.mouse = ((_e$changedTouches2 = e.changedTouches) == null ? void 0 : _e$changedTouches2[0]) || e; | ||
this.prop.mouseDown = false; | ||
@@ -249,3 +271,10 @@ | ||
if (e.changedTouches) { | ||
this.prop.mouse = null; | ||
this.__update(); | ||
} | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
break; | ||
@@ -252,0 +281,0 @@ |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -323,10 +323,17 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
_this.controls = null; | ||
return _this; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, _assertThisInitialized(_this)); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_ROTATE, _assertThisInitialized(_this)); | ||
var _proto = GyroscopePlugin.prototype; | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, _assertThisInitialized(_this)); | ||
_proto.init = function init() { | ||
_AbstractPlugin.prototype.init.call(this); | ||
return _this; | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_ROTATE, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this); | ||
} | ||
@@ -336,6 +343,4 @@ /** | ||
*/ | ||
; | ||
var _proto = GyroscopePlugin.prototype; | ||
_proto.destroy = function destroy() { | ||
@@ -347,3 +352,2 @@ this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, this); | ||
delete this.controls; | ||
delete this.prop; | ||
@@ -350,0 +354,0 @@ _AbstractPlugin.prototype.destroy.call(this); |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -13,2 +13,20 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
@@ -30,10 +48,2 @@ subClass.prototype = Object.create(superClass.prototype); | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
/** | ||
@@ -129,22 +139,3 @@ * @summary Available events | ||
_this.settings = psv.getPlugin('settings'); | ||
if (!_this.settings) { | ||
throw new photoSphereViewer.PSVError('Resolution plugin requires the Settings plugin'); | ||
} | ||
_this.settings.addSetting({ | ||
id: ResolutionPlugin.id, | ||
type: 'options', | ||
label: _this.psv.config.lang.resolution, | ||
current: function current() { | ||
return _this.prop.resolution; | ||
}, | ||
options: function options() { | ||
return _this.__getSettingsOptions(); | ||
}, | ||
apply: function apply(resolution) { | ||
return _this.setResolution(resolution); | ||
} | ||
}); | ||
_this.settings = null; | ||
/** | ||
@@ -155,3 +146,2 @@ * @summary Available resolutions | ||
_this.resolutions = []; | ||
@@ -174,9 +164,7 @@ /** | ||
}; | ||
/** | ||
* @type {PSV.plugins.ResolutionPlugin.Options} | ||
*/ | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, _assertThisInitialized(_this)); | ||
if (options != null && options.resolutions) { | ||
_this.setResolutions(options.resolutions); | ||
} | ||
_this.config = _extends({}, options); | ||
return _this; | ||
@@ -191,2 +179,39 @@ } | ||
_proto.init = function init() { | ||
var _this2 = this; | ||
_AbstractPlugin.prototype.init.call(this); | ||
this.settings = this.psv.getPlugin('settings'); | ||
if (!this.settings) { | ||
throw new photoSphereViewer.PSVError('Resolution plugin requires the Settings plugin'); | ||
} | ||
this.settings.addSetting({ | ||
id: ResolutionPlugin.id, | ||
type: 'options', | ||
label: this.psv.config.lang.resolution, | ||
current: function current() { | ||
return _this2.prop.resolution; | ||
}, | ||
options: function options() { | ||
return _this2.__getSettingsOptions(); | ||
}, | ||
apply: function apply(resolution) { | ||
return _this2.setResolution(resolution); | ||
} | ||
}); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
if (this.config.resolutions) { | ||
this.setResolutions(this.config.resolutions); | ||
delete this.config.resolutions; | ||
} | ||
} | ||
/** | ||
* @package | ||
*/ | ||
; | ||
_proto.destroy = function destroy() { | ||
@@ -217,3 +242,3 @@ this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
_proto.setResolutions = function setResolutions(resolutions) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -227,3 +252,3 @@ this.resolutions = resolutions; | ||
_this2.resolutionsById[resolution.id] = resolution; | ||
_this3.resolutionsById[resolution.id] = resolution; | ||
}); | ||
@@ -265,6 +290,6 @@ | ||
_proto.__refreshResolution = function __refreshResolution() { | ||
var _this3 = this; | ||
var _this4 = this; | ||
var resolution = this.resolutions.find(function (r) { | ||
return deepEqual(_this3.psv.config.panorama, r.panorama); | ||
return deepEqual(_this4.psv.config.panorama, r.panorama); | ||
}); | ||
@@ -271,0 +296,0 @@ |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -268,3 +268,13 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
_proto.init = function init() { | ||
_AbstractPlugin.prototype.init.call(this); | ||
} | ||
/** | ||
* @package | ||
*/ | ||
; | ||
_proto.destroy = function destroy() { | ||
delete this.settings; | ||
_AbstractPlugin.prototype.destroy.call(this); | ||
@@ -271,0 +281,0 @@ } |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -221,7 +221,10 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
_this.gyroscope = psv.getPlugin('gyroscope'); | ||
_this.gyroscope = null; | ||
/** | ||
* @type {PSV.plugins.MarkersPlugin} | ||
* @readonly | ||
* @private | ||
*/ | ||
if (!_this.gyroscope) { | ||
throw new photoSphereViewer.PSVError('Stereo plugin requires the Gyroscope plugin'); | ||
} | ||
_this.markers = null; | ||
/** | ||
@@ -236,5 +239,4 @@ * @member {Object} | ||
_this.prop = { | ||
isSupported: _this.gyroscope.prop.isSupported, | ||
isSupported: false, | ||
renderer: null, | ||
@@ -244,14 +246,24 @@ noSleep: null, | ||
}; | ||
/** | ||
* @type {PSV.plugins.MarkersPlugin} | ||
* @private | ||
*/ | ||
return _this; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
_this.markers = _this.psv.getPlugin('markers'); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, _assertThisInitialized(_this)); | ||
var _proto = StereoPlugin.prototype; | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.CLICK, _assertThisInitialized(_this)); | ||
_proto.init = function init() { | ||
_AbstractPlugin.prototype.init.call(this); | ||
return _this; | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.gyroscope = this.psv.getPlugin('gyroscope'); | ||
if (!this.gyroscope) { | ||
throw new photoSphereViewer.PSVError('Stereo plugin requires the Gyroscope plugin'); | ||
} | ||
this.prop.isSupported = this.gyroscope.prop.isSupported; | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.CLICK, this); | ||
} | ||
@@ -261,6 +273,4 @@ /** | ||
*/ | ||
; | ||
var _proto = StereoPlugin.prototype; | ||
_proto.destroy = function destroy() { | ||
@@ -271,6 +281,2 @@ this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, this); | ||
if (this.prop.noSleep) { | ||
delete this.prop.noSleep; | ||
} | ||
_AbstractPlugin.prototype.destroy.call(this); | ||
@@ -325,2 +331,4 @@ } | ||
return this.gyroscope.start().then(function () { | ||
var _this2$markers; | ||
// switch renderer | ||
@@ -332,5 +340,3 @@ _this2.prop.renderer = _this2.psv.renderer.renderer; | ||
if (_this2.markers) { | ||
_this2.markers.hide(); | ||
} | ||
(_this2$markers = _this2.markers) == null ? void 0 : _this2$markers.hide(); | ||
@@ -363,10 +369,8 @@ _this2.psv.navbar.hide(); | ||
if (this.isEnabled()) { | ||
var _this$markers; | ||
this.psv.renderer.renderer = this.prop.renderer; | ||
this.prop.renderer = null; | ||
this.psv.needsUpdate(); | ||
if (this.markers) { | ||
this.markers.show(); | ||
} | ||
(_this$markers = this.markers) == null ? void 0 : _this$markers.show(); | ||
this.psv.navbar.show(); | ||
@@ -373,0 +377,0 @@ |
import { Event } from 'uevent'; | ||
import { ViewerOptions, AbstractPlugin, Viewer } from 'photo-sphere-viewer'; | ||
import { ViewerOptions, Position, AbstractPlugin, Viewer } from 'photo-sphere-viewer'; | ||
import { Marker, MarkerProperties } from 'photo-sphere-viewer/dist/plugins/markers'; | ||
@@ -41,2 +41,11 @@ | ||
/** | ||
* @summary Data associated to the "node-changed" event | ||
*/ | ||
type VirtualTourNodeChangedData = { | ||
fromNode?: VirtualTourNode, | ||
fromLink?: VirtualTourNodeLink, | ||
fromLinkPosition?: Position, | ||
}; | ||
type VirtualTourPluginPluginOptions = { | ||
@@ -51,2 +60,3 @@ dataMode?: 'client' | 'server'; | ||
preload?: boolean | ((node: VirtualTourNode, link: VirtualTourNodeLink) => boolean); | ||
rotateSpeed?: boolean | string | number; | ||
markerStyle?: MarkerProperties; | ||
@@ -56,7 +66,7 @@ arrowStyle?: VirtualTourArrowStyle; | ||
arrowPosition?: 'top' | 'bottom'; | ||
} | ||
}; | ||
declare const EVENTS: { | ||
NODE_CHANGED: 'node-changed', | ||
RENDER_NODES_LIST: 'render-nodes-list, | ||
RENDER_NODES_LIST: 'render-nodes-list', | ||
}; | ||
@@ -100,3 +110,3 @@ | ||
*/ | ||
on(e: 'node-changed', cb: (e: Event, node: Node) => void): this; | ||
on(e: 'node-changed', cb: (e: Event, nodeId: VirtualTourNode['id'], data: VirtualTourNodeChangedData) => void): this; | ||
@@ -106,6 +116,6 @@ /** | ||
*/ | ||
on(e: 'render-nodes-list', cb: (e: Event, nodes: Node[]) => Node[]): this; | ||
on(e: 'render-nodes-list', cb: (e: Event, nodes: VirtualTourNode[]) => VirtualTourNode[]): this; | ||
} | ||
export { EVENTS, VirtualTourArrowStyle, VirtualTourNode, VirtualTourNodeLink, VirtualTourPlugin, VirtualTourPluginPluginOptions }; | ||
export { EVENTS, VirtualTourArrowStyle, VirtualTourNode, VirtualTourNodeChangedData, VirtualTourNodeLink, VirtualTourPlugin, VirtualTourPluginPluginOptions }; |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -8,6 +8,6 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('photo-sphere-viewer'), require('three')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'photo-sphere-viewer', 'three'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.PhotoSphereViewer = global.PhotoSphereViewer || {}, global.PhotoSphereViewer.VirtualTourPlugin = {}), global.PhotoSphereViewer, global.THREE)); | ||
})(this, (function (exports, photoSphereViewer, THREE) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('photo-sphere-viewer')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'three', 'photo-sphere-viewer'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.PhotoSphereViewer = global.PhotoSphereViewer || {}, global.PhotoSphereViewer.VirtualTourPlugin = {}), global.THREE, global.PhotoSphereViewer)); | ||
})(this, (function (exports, THREE, photoSphereViewer) { 'use strict'; | ||
@@ -652,2 +652,3 @@ function _extends() { | ||
* @property {boolean|PSV.plugins.VirtualTourPlugin.Preload} [preload=false] - preload linked panoramas | ||
* @property {boolean|string|number} [rotateSpeed='20rpm'] - speed of rotation when clicking on a link, if 'false' the viewer won't rotate at all | ||
* @property {boolean} [listButton] - adds a button to show the list of nodes, defaults to `true` only in client data mode | ||
@@ -660,2 +661,10 @@ * @property {boolean} [linksOnCompass] - if the Compass plugin is enabled, displays the links on the compass, defaults to `true` on in markers render mode | ||
*/ | ||
/** | ||
* @typedef {Object} PSV.plugins.VirtualTourPlugin.NodeChangedData | ||
* @summary Data associated to the "node-changed" event | ||
* @type {PSV.plugins.VirtualTourPlugin.Node} [fromNode] - The previous node | ||
* @type {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink] - The link that was clicked in the previous node | ||
* @type {PSV.Position} [fromLinkPosition] - The position of the link on the previous node | ||
*/ | ||
// add markers buttons | ||
@@ -714,2 +723,3 @@ | ||
preload: false, | ||
rotateSpeed: '20rpm', | ||
markerLatOffset: -0.1, | ||
@@ -721,4 +731,3 @@ arrowPosition: 'bottom', | ||
markerStyle: _extends({}, DEFAULT_MARKER, options == null ? void 0 : options.markerStyle), | ||
arrowStyle: _extends({}, DEFAULT_ARROW, options == null ? void 0 : options.arrowStyle), | ||
nodes: null | ||
arrowStyle: _extends({}, DEFAULT_ARROW, options == null ? void 0 : options.arrowStyle) | ||
}); | ||
@@ -730,3 +739,3 @@ /** | ||
_this.markers = _this.psv.getPlugin('markers'); | ||
_this.markers = null; | ||
/** | ||
@@ -737,7 +746,3 @@ * @type {PSV.plugins.CompassPlugin} | ||
_this.compass = _this.psv.getPlugin('compass'); | ||
if (!_this.is3D() && !_this.markers) { | ||
throw new photoSphereViewer.PSVError('Tour plugin requires the Markers plugin in markers mode'); | ||
} | ||
_this.compass = null; | ||
/** | ||
@@ -747,4 +752,3 @@ * @type {PSV.plugins.VirtualTourPlugin.AbstractDatasource} | ||
_this.datasource = _this.isServerSide() ? new ServerSideDatasource(_assertThisInitialized(_this)) : new ClientSideDatasource(_assertThisInitialized(_this)); | ||
_this.datasource = null; | ||
/** | ||
@@ -763,39 +767,62 @@ * @type {external:THREE.Group} | ||
_this.arrowsGroup.add(localLight); | ||
} | ||
_this.psv.once(photoSphereViewer.CONSTANTS.EVENTS.READY, function () { | ||
_this.__positionArrows(); | ||
return _this; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
_this.psv.renderer.scene.add(_this.arrowsGroup); | ||
var ambientLight = new THREE.AmbientLight(0xffffff, 1); | ||
var _proto = VirtualTourPlugin.prototype; | ||
_this.psv.renderer.scene.add(ambientLight); | ||
_proto.init = function init() { | ||
var _this2 = this; | ||
_this.psv.needsUpdate(); | ||
_AbstractPlugin.prototype.init.call(this); | ||
_this.psv.container.addEventListener('mousemove', _assertThisInitialized(_this)); | ||
}); | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.compass = this.psv.getPlugin('compass'); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.POSITION_UPDATED, _assertThisInitialized(_this)); | ||
if (!this.is3D() && !this.markers) { | ||
throw new photoSphereViewer.PSVError('Tour plugin requires the Markers plugin in markers mode'); | ||
} | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED, _assertThisInitialized(_this)); | ||
this.datasource = this.isServerSide() ? new ServerSideDatasource(this) : new ClientSideDatasource(this); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.CLICK, _assertThisInitialized(_this)); | ||
if (this.is3D()) { | ||
this.psv.once(photoSphereViewer.CONSTANTS.EVENTS.READY, function () { | ||
_this2.__positionArrows(); | ||
_this2.psv.renderer.scene.add(_this2.arrowsGroup); | ||
var ambientLight = new THREE.AmbientLight(0xffffff, 1); | ||
_this2.psv.renderer.scene.add(ambientLight); | ||
_this2.psv.needsUpdate(); | ||
_this2.psv.container.addEventListener('mousemove', _this2); | ||
}); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.POSITION_UPDATED, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.CLICK, this); | ||
} else { | ||
_this.markers.on('select-marker', _assertThisInitialized(_this)); | ||
this.markers.on('select-marker', this); | ||
} | ||
if (_this.isServerSide()) { | ||
if (_this.config.startNodeId) { | ||
_this.setCurrentNode(_this.config.startNodeId); | ||
if (this.isServerSide()) { | ||
if (this.config.startNodeId) { | ||
this.setCurrentNode(this.config.startNodeId); | ||
} | ||
} else if (options != null && options.nodes) { | ||
_this.setNodes(options.nodes, _this.config.startNodeId); | ||
} else if (this.config.nodes) { | ||
this.setNodes(this.config.nodes, this.config.startNodeId); | ||
delete this.config.nodes; | ||
} | ||
return _this; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
; | ||
var _proto = VirtualTourPlugin.prototype; | ||
_proto.destroy = function destroy() { | ||
@@ -818,3 +845,3 @@ if (this.markers) { | ||
delete this.markers; | ||
delete this.prop; | ||
delete this.compass; | ||
delete this.arrowsGroup; | ||
@@ -826,12 +853,12 @@ | ||
_proto.handleEvent = function handleEvent(e) { | ||
var _e$args$0$data, _e$args$0$data$LINK_D, _this$prop$currentArr, _this$prop$currentArr2, _this$prop$currentArr3; | ||
var _e$args$0$data, _this$prop$currentArr, _this$prop$currentArr2; | ||
var nodeId; | ||
var link; | ||
switch (e.type) { | ||
case 'select-marker': | ||
nodeId = (_e$args$0$data = e.args[0].data) == null ? void 0 : (_e$args$0$data$LINK_D = _e$args$0$data[LINK_DATA]) == null ? void 0 : _e$args$0$data$LINK_D.nodeId; | ||
link = (_e$args$0$data = e.args[0].data) == null ? void 0 : _e$args$0$data[LINK_DATA]; | ||
if (nodeId) { | ||
this.setCurrentNode(nodeId); | ||
if (link) { | ||
this.setCurrentNode(link.nodeId, link); | ||
} | ||
@@ -850,6 +877,6 @@ | ||
case photoSphereViewer.CONSTANTS.EVENTS.CLICK: | ||
nodeId = (_this$prop$currentArr = this.prop.currentArrow) == null ? void 0 : (_this$prop$currentArr2 = _this$prop$currentArr.userData) == null ? void 0 : (_this$prop$currentArr3 = _this$prop$currentArr2[LINK_DATA]) == null ? void 0 : _this$prop$currentArr3.nodeId; | ||
link = (_this$prop$currentArr = this.prop.currentArrow) == null ? void 0 : (_this$prop$currentArr2 = _this$prop$currentArr.userData) == null ? void 0 : _this$prop$currentArr2[LINK_DATA]; | ||
if (!nodeId) { | ||
var _this$psv$dataHelper$, _arrow$userData, _arrow$userData$LINK_; | ||
if (!link) { | ||
var _this$psv$dataHelper$, _arrow$userData; | ||
@@ -861,7 +888,7 @@ // on touch screens "currentArrow" may be null (no hover state) | ||
}, LINK_DATA)) == null ? void 0 : _this$psv$dataHelper$.object; | ||
nodeId = arrow == null ? void 0 : (_arrow$userData = arrow.userData) == null ? void 0 : (_arrow$userData$LINK_ = _arrow$userData[LINK_DATA]) == null ? void 0 : _arrow$userData$LINK_.nodeId; | ||
link = arrow == null ? void 0 : (_arrow$userData = arrow.userData) == null ? void 0 : _arrow$userData[LINK_DATA]; | ||
} | ||
if (nodeId) { | ||
this.setCurrentNode(nodeId); | ||
if (link) { | ||
this.setCurrentNode(link.nodeId, link); | ||
} | ||
@@ -931,2 +958,3 @@ | ||
* @param {string} nodeId | ||
* @param {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink] | ||
* @returns {Promise<boolean>} resolves false if the loading was aborted by another call | ||
@@ -936,6 +964,10 @@ */ | ||
_proto.setCurrentNode = function setCurrentNode(nodeId) { | ||
_proto.setCurrentNode = function setCurrentNode(nodeId, fromLink) { | ||
var _this$prop$currentNod, | ||
_this2 = this; | ||
_this3 = this; | ||
if (fromLink === void 0) { | ||
fromLink = null; | ||
} | ||
if (nodeId === ((_this$prop$currentNod = this.prop.currentNode) == null ? void 0 : _this$prop$currentNod.id)) { | ||
@@ -945,44 +977,57 @@ return Promise.resolve(true); | ||
this.psv.loader.show(); | ||
this.psv.hideError(); | ||
this.prop.loadingNode = nodeId; // if this node is already preloading, wait for it | ||
return Promise.resolve(this.preload[nodeId]).then(function () { | ||
if (_this2.prop.loadingNode !== nodeId) { | ||
this.prop.loadingNode = nodeId; | ||
var fromNode = this.prop.currentNode; | ||
var fromLinkPosition = fromNode && fromLink ? this.__getLinkPosition(fromNode, fromLink) : null; | ||
return Promise.all([// if this node is already preloading, wait for it | ||
Promise.resolve(this.preload[nodeId]).then(function () { | ||
if (_this3.prop.loadingNode !== nodeId) { | ||
return Promise.reject(photoSphereViewer.utils.getAbortError()); | ||
} | ||
_this2.psv.textureLoader.abortLoading(); | ||
_this3.psv.textureLoader.abortLoading(); | ||
return _this2.datasource.loadNode(nodeId); | ||
}).then(function (node) { | ||
var _this2$markers, _this2$compass; | ||
return _this3.datasource.loadNode(nodeId); | ||
}), Promise.resolve(fromLinkPosition ? this.config.rotateSpeed : false).then(function (speed) { | ||
if (!speed) { | ||
return Promise.resolve(); | ||
} else { | ||
return _this3.psv.animate(_extends({}, fromLinkPosition, { | ||
speed: speed | ||
})); | ||
} | ||
}).then(function () { | ||
_this3.psv.loader.show(); | ||
})]).then(function (_ref) { | ||
var _this3$markers, _this3$compass; | ||
if (_this2.prop.loadingNode !== nodeId) { | ||
var node = _ref[0]; | ||
if (_this3.prop.loadingNode !== nodeId) { | ||
return Promise.reject(photoSphereViewer.utils.getAbortError()); | ||
} | ||
_this2.psv.navbar.setCaption("<em>" + _this2.psv.config.lang.loading + "</em>"); | ||
_this3.psv.navbar.setCaption("<em>" + _this3.psv.config.lang.loading + "</em>"); | ||
_this2.prop.currentNode = node; | ||
_this3.prop.currentNode = node; | ||
if (_this2.prop.currentTooltip) { | ||
_this2.prop.currentTooltip.hide(); | ||
if (_this3.prop.currentTooltip) { | ||
_this3.prop.currentTooltip.hide(); | ||
_this2.prop.currentTooltip = null; | ||
_this3.prop.currentTooltip = null; | ||
} | ||
if (_this2.is3D()) { | ||
var _this2$arrowsGroup; | ||
if (_this3.is3D()) { | ||
var _this3$arrowsGroup; | ||
(_this2$arrowsGroup = _this2.arrowsGroup).remove.apply(_this2$arrowsGroup, _this2.arrowsGroup.children.filter(function (o) { | ||
(_this3$arrowsGroup = _this3.arrowsGroup).remove.apply(_this3$arrowsGroup, _this3.arrowsGroup.children.filter(function (o) { | ||
return o.type === 'Mesh'; | ||
})); | ||
_this2.prop.currentArrow = null; | ||
_this3.prop.currentArrow = null; | ||
} | ||
(_this2$markers = _this2.markers) == null ? void 0 : _this2$markers.clearMarkers(); | ||
(_this2$compass = _this2.compass) == null ? void 0 : _this2$compass.clearHotspots(); | ||
return Promise.all([_this2.psv.setPanorama(node.panorama, { | ||
(_this3$markers = _this3.markers) == null ? void 0 : _this3$markers.clearMarkers(); | ||
(_this3$compass = _this3.compass) == null ? void 0 : _this3$compass.clearHotspots(); | ||
return Promise.all([_this3.psv.setPanorama(node.panorama, { | ||
panoData: node.panoData, | ||
@@ -993,13 +1038,13 @@ sphereCorrection: node.sphereCorrection | ||
return Promise.reject(photoSphereViewer.utils.isAbortError(err) ? err : null); | ||
}), _this2.datasource.loadLinkedNodes(nodeId)]); | ||
}), _this3.datasource.loadLinkedNodes(nodeId)]); | ||
}).then(function () { | ||
if (_this2.prop.loadingNode !== nodeId) { | ||
if (_this3.prop.loadingNode !== nodeId) { | ||
return Promise.reject(photoSphereViewer.utils.getAbortError()); | ||
} | ||
var node = _this2.prop.currentNode; | ||
var node = _this3.prop.currentNode; | ||
if (node.markers) { | ||
if (_this2.markers) { | ||
_this2.markers.setMarkers(node.markers); | ||
if (_this3.markers) { | ||
_this3.markers.setMarkers(node.markers); | ||
} else { | ||
@@ -1010,7 +1055,7 @@ photoSphereViewer.utils.logWarn("Node " + node.id + " markers ignored because the plugin is not loaded."); | ||
_this2.__renderLinks(node); | ||
_this3.__renderLinks(node); | ||
_this2.__preload(node); | ||
_this3.__preload(node); | ||
_this2.psv.navbar.setCaption(node.caption || _this2.psv.config.caption); | ||
_this3.psv.navbar.setCaption(node.caption || _this3.psv.config.caption); | ||
/** | ||
@@ -1021,8 +1066,13 @@ * @event node-changed | ||
* @param {string} nodeId | ||
* @param {PSV.plugins.VirtualTourPlugin.NodeChangedData} data | ||
*/ | ||
_this2.trigger(EVENTS.NODE_CHANGED, nodeId); | ||
_this3.trigger(EVENTS.NODE_CHANGED, nodeId, { | ||
fromNode: fromNode, | ||
fromLink: fromLink, | ||
fromLinkPosition: fromLinkPosition | ||
}); | ||
_this2.prop.loadingNode = null; | ||
_this3.prop.loadingNode = null; | ||
return true; | ||
@@ -1033,10 +1083,10 @@ }).catch(function (err) { | ||
} else if (err) { | ||
_this2.psv.showError(_this2.psv.config.lang.loadError); | ||
_this3.psv.showError(_this3.psv.config.lang.loadError); | ||
} | ||
_this2.psv.loader.hide(); | ||
_this3.psv.loader.hide(); | ||
_this2.psv.navbar.setCaption(''); | ||
_this3.psv.navbar.setCaption(''); | ||
_this2.prop.loadingNode = null; | ||
_this3.prop.loadingNode = null; | ||
return Promise.reject(err); | ||
@@ -1053,11 +1103,11 @@ }); | ||
_proto.__renderLinks = function __renderLinks(node) { | ||
var _this3 = this; | ||
var _this4 = this; | ||
var positions = []; | ||
node.links.forEach(function (link) { | ||
var position = _this3.__getLinkPosition(node, link); | ||
var position = _this4.__getLinkPosition(node, link); | ||
positions.push(position); | ||
if (_this3.is3D()) { | ||
if (_this4.is3D()) { | ||
var _link$arrowStyle, _link$arrowStyle2, _mesh$userData; | ||
@@ -1068,6 +1118,6 @@ | ||
transparent: true, | ||
opacity: ((_link$arrowStyle = link.arrowStyle) == null ? void 0 : _link$arrowStyle.opacity) || _this3.config.arrowStyle.opacity | ||
opacity: ((_link$arrowStyle = link.arrowStyle) == null ? void 0 : _link$arrowStyle.opacity) || _this4.config.arrowStyle.opacity | ||
}); | ||
var mesh = new THREE.Mesh(arrow, mat); | ||
setMeshColor(mesh, ((_link$arrowStyle2 = link.arrowStyle) == null ? void 0 : _link$arrowStyle2.color) || _this3.config.arrowStyle.color); | ||
setMeshColor(mesh, ((_link$arrowStyle2 = link.arrowStyle) == null ? void 0 : _link$arrowStyle2.color) || _this4.config.arrowStyle.color); | ||
mesh.userData = (_mesh$userData = {}, _mesh$userData[LINK_DATA] = link, _mesh$userData.longitude = position.longitude, _mesh$userData); | ||
@@ -1077,3 +1127,3 @@ mesh.rotation.order = 'YXZ'; | ||
_this3.psv.dataHelper.sphericalCoordsToVector3({ | ||
_this4.psv.dataHelper.sphericalCoordsToVector3({ | ||
longitude: position.longitude, | ||
@@ -1083,11 +1133,11 @@ latitude: 0 | ||
_this3.arrowsGroup.add(mesh); | ||
_this4.arrowsGroup.add(mesh); | ||
} else { | ||
var _data; | ||
if (_this3.isGps()) { | ||
position.latitude += _this3.config.markerLatOffset; | ||
if (_this4.isGps()) { | ||
position.latitude += _this4.config.markerLatOffset; | ||
} | ||
_this3.markers.addMarker(_extends({}, _this3.config.markerStyle, link.markerStyle, { | ||
_this4.markers.addMarker(_extends({}, _this4.config.markerStyle, link.markerStyle, { | ||
id: "tour-link-" + link.nodeId, | ||
@@ -1238,3 +1288,3 @@ tooltip: link.name, | ||
_proto.__preload = function __preload(node) { | ||
var _this4 = this; | ||
var _this5 = this; | ||
@@ -1247,6 +1297,6 @@ if (!this.config.preload || !this.isServerSide()) { | ||
this.prop.currentNode.links.filter(function (link) { | ||
return !_this4.preload[link.nodeId]; | ||
return !_this5.preload[link.nodeId]; | ||
}).filter(function (link) { | ||
if (typeof _this4.config.preload === 'function') { | ||
return _this4.config.preload(_this4.prop.currentNode, link); | ||
if (typeof _this5.config.preload === 'function') { | ||
return _this5.config.preload(_this5.prop.currentNode, link); | ||
} else { | ||
@@ -1256,8 +1306,8 @@ return true; | ||
}).forEach(function (link) { | ||
_this4.preload[link.nodeId] = _this4.datasource.loadNode(link.nodeId).then(function (linkNode) { | ||
return _this4.psv.textureLoader.preloadPanorama(linkNode.panorama); | ||
_this5.preload[link.nodeId] = _this5.datasource.loadNode(link.nodeId).then(function (linkNode) { | ||
return _this5.psv.textureLoader.preloadPanorama(linkNode.panorama); | ||
}).then(function () { | ||
_this4.preload[link.nodeId] = true; | ||
_this5.preload[link.nodeId] = true; | ||
}).catch(function () { | ||
delete _this4.preload[link.nodeId]; | ||
delete _this5.preload[link.nodeId]; | ||
}); | ||
@@ -1285,3 +1335,3 @@ }); | ||
var _this$prop$currentNod2, | ||
_this5 = this; | ||
_this6 = this; | ||
@@ -1298,5 +1348,5 @@ var nodes = this.change(EVENTS.RENDER_NODES_LIST, Object.values(this.datasource.nodes)); | ||
if (nodeId) { | ||
_this5.setCurrentNode(nodeId); | ||
_this6.setCurrentNode(nodeId); | ||
_this5.hideNodesList(); | ||
_this6.hideNodesList(); | ||
} | ||
@@ -1303,0 +1353,0 @@ } |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -13,2 +13,20 @@ * @copyright 2015-2022 Damien "Mistic" Sorel | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
@@ -30,10 +48,2 @@ subClass.prototype = Object.create(superClass.prototype); | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
/** | ||
@@ -68,25 +78,26 @@ * @typedef {Object} PSV.plugins.VisibleRangePlugin.Options | ||
_this.config = { | ||
_this.config = _extends({ | ||
latitudeRange: null, | ||
longitudeRange: null, | ||
usePanoData: false | ||
}; | ||
}, options); | ||
return _this; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
if (options) { | ||
_this.config.usePanoData = !!options.usePanoData; | ||
_this.setLatitudeRange(options.latitudeRange); | ||
var _proto = VisibleRangePlugin.prototype; | ||
_this.setLongitudeRange(options.longitudeRange); | ||
} | ||
_proto.init = function init() { | ||
_AbstractPlugin.prototype.init.call(this); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, _assertThisInitialized(_this)); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED, _assertThisInitialized(_this)); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION, _assertThisInitialized(_this)); | ||
_this.psv.on(photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION, _assertThisInitialized(_this)); | ||
return _this; | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.POSITION_UPDATED, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION, this); | ||
this.psv.on(photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION, this); | ||
this.setLatitudeRange(this.config.latitudeRange); | ||
this.setLongitudeRange(this.config.longitudeRange); | ||
} | ||
@@ -96,8 +107,7 @@ /** | ||
*/ | ||
; | ||
var _proto = VisibleRangePlugin.prototype; | ||
_proto.destroy = function destroy() { | ||
this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.POSITION_UPDATED, this); | ||
this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED, this); | ||
@@ -116,32 +126,35 @@ this.psv.off(photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION, this); | ||
_proto.handleEvent = function handleEvent(e) { | ||
if (e.type === photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION) { | ||
var _this$applyRanges = this.applyRanges(e.value), | ||
rangedPosition = _this$applyRanges.rangedPosition; | ||
switch (e.type) { | ||
case photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION: | ||
case photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION: | ||
return this.applyRanges(e.value).rangedPosition; | ||
return rangedPosition; | ||
} else if (e.type === photoSphereViewer.CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION) { | ||
var _this$applyRanges2 = this.applyRanges(e.value), | ||
_rangedPosition = _this$applyRanges2.rangedPosition, | ||
sidesReached = _this$applyRanges2.sidesReached; | ||
case photoSphereViewer.CONSTANTS.EVENTS.POSITION_UPDATED: | ||
var _this$applyRanges = this.applyRanges(e.args[0]), | ||
sidesReached = _this$applyRanges.sidesReached; | ||
if (photoSphereViewer.utils.intersect(['left', 'right'], sidesReached).length > 0 && this.psv.isAutorotateEnabled()) { | ||
this.__reverseAutorotate(); | ||
if ((sidesReached.left || sidesReached.right) && this.psv.isAutorotateEnabled()) { | ||
this.__reverseAutorotate(sidesReached.left, sidesReached.right); | ||
} | ||
return e.value; | ||
} | ||
break; | ||
return _rangedPosition; | ||
} else if (e.type === photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED) { | ||
if (this.config.usePanoData) { | ||
this.setRangesFromPanoData(); | ||
} | ||
} else if (e.type === photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED) { | ||
var currentPosition = this.psv.getPosition(); | ||
case photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED: | ||
if (this.config.usePanoData) { | ||
this.setRangesFromPanoData(); | ||
} | ||
var _this$applyRanges3 = this.applyRanges(currentPosition), | ||
_rangedPosition2 = _this$applyRanges3.rangedPosition; | ||
break; | ||
if (currentPosition.longitude !== _rangedPosition2.longitude || currentPosition.latitude !== _rangedPosition2.latitude) { | ||
this.psv.rotate(_rangedPosition2); | ||
} | ||
case photoSphereViewer.CONSTANTS.EVENTS.ZOOM_UPDATED: | ||
var currentPosition = this.psv.getPosition(); | ||
var _this$applyRanges2 = this.applyRanges(currentPosition), | ||
rangedPosition = _this$applyRanges2.rangedPosition; | ||
if (currentPosition.longitude !== rangedPosition.longitude || currentPosition.latitude !== rangedPosition.latitude) { | ||
this.psv.rotate(rangedPosition); | ||
} | ||
break; | ||
} | ||
@@ -267,3 +280,3 @@ } | ||
}; | ||
var sidesReached = []; | ||
var sidesReached = {}; | ||
var range; | ||
@@ -284,6 +297,6 @@ var offset; | ||
rangedPosition.longitude = range[0]; | ||
sidesReached.push('left'); | ||
sidesReached.left = true; | ||
} else { | ||
rangedPosition.longitude = range[1]; | ||
sidesReached.push('right'); | ||
sidesReached.right = true; | ||
} | ||
@@ -293,6 +306,6 @@ } | ||
rangedPosition.longitude = range[0]; | ||
sidesReached.push('left'); | ||
sidesReached.left = true; | ||
} else if (position.longitude > range[1]) { | ||
rangedPosition.longitude = range[1]; | ||
sidesReached.push('right'); | ||
sidesReached.right = true; | ||
} | ||
@@ -309,6 +322,6 @@ } | ||
rangedPosition.latitude = range[0]; | ||
sidesReached.push('bottom'); | ||
sidesReached.bottom = true; | ||
} else if (position.latitude > range[1]) { | ||
rangedPosition.latitude = range[1]; | ||
sidesReached.push('top'); | ||
sidesReached.top = true; | ||
} | ||
@@ -328,37 +341,10 @@ } | ||
_proto.__reverseAutorotate = function __reverseAutorotate() { | ||
var _this2 = this; | ||
_proto.__reverseAutorotate = function __reverseAutorotate(left, right) { | ||
// reverse already ongoing | ||
if (left && this.psv.config.autorotateSpeed > 0 || right && this.psv.config.autorotateSpeed < 0) { | ||
return; | ||
} | ||
var newSpeed = -this.psv.config.autorotateSpeed; | ||
var range = this.config.longitudeRange; | ||
this.config.longitudeRange = null; | ||
new photoSphereViewer.Animation({ | ||
properties: { | ||
speed: { | ||
start: this.psv.config.autorotateSpeed, | ||
end: 0 | ||
} | ||
}, | ||
duration: 300, | ||
easing: 'inSine', | ||
onTick: function onTick(properties) { | ||
_this2.psv.config.autorotateSpeed = properties.speed; | ||
} | ||
}).then(function () { | ||
return new photoSphereViewer.Animation({ | ||
properties: { | ||
speed: { | ||
start: 0, | ||
end: newSpeed | ||
} | ||
}, | ||
duration: 300, | ||
easing: 'outSine', | ||
onTick: function onTick(properties) { | ||
_this2.psv.config.autorotateSpeed = properties.speed; | ||
} | ||
}); | ||
}).then(function () { | ||
_this2.config.longitudeRange = range; | ||
}); | ||
this.psv.config.autorotateSpeed = -this.psv.config.autorotateSpeed; | ||
this.psv.startAutorotate(true); | ||
}; | ||
@@ -365,0 +351,0 @@ |
/*! | ||
* Photo Sphere Viewer 4.4.2 | ||
* Photo Sphere Viewer 4.4.3 | ||
* @copyright 2014-2015 Jérémy Heleine | ||
@@ -4,0 +4,0 @@ * @copyright 2015-2022 Damien "Mistic" Sorel |
{ | ||
"name": "photo-sphere-viewer", | ||
"version": "4.4.2", | ||
"version": "4.4.3", | ||
"description": "A JavaScript library to display Photo Sphere panoramas", | ||
@@ -46,2 +46,3 @@ "homepage": "https://photo-sphere-viewer.js.org", | ||
"@babel/register": "^7.15.3", | ||
"@compodoc/live-server": "^1.2.3", | ||
"@pixi/jsdoc-template": "^2.5.1", | ||
@@ -55,4 +56,4 @@ "@rollup/plugin-babel": "^5.3.0", | ||
"autoprefixer": "^10.3.3", | ||
"axios": "^0.24.0", | ||
"cpx": "^1.5.0", | ||
"axios": "^0.25.0", | ||
"cpx2": "^4.1.2", | ||
"date-fns": "^2.23.0", | ||
@@ -63,3 +64,2 @@ "eslint": "^8.2.0", | ||
"jsdoc": "^3.6.7", | ||
"live-server": "^1.2.0", | ||
"marked": "^4.0.0", | ||
@@ -66,0 +66,0 @@ "mocha": "^9.1.1", |
@@ -16,6 +16,12 @@ import * as THREE from 'three'; | ||
/** | ||
* @typedef {Object} PSV.adapters.CubemapAdapter.Options | ||
* @property {boolean} [flipTopBottom=false] - set to true if the top and bottom faces are not correctly oriented | ||
*/ | ||
const CUBE_VERTICES = 8; | ||
const CUBE_MAP = [0, 2, 4, 5, 3, 1]; | ||
const CUBE_HASHMAP = ['left', 'right', 'top', 'bottom', 'back', 'front']; | ||
const VECTOR2D_CENTER = new THREE.Vector2(0.5, 0.5); | ||
@@ -33,2 +39,19 @@ | ||
/** | ||
* @param {PSV.Viewer} psv | ||
* @param {PSV.adapters.CubemapAdapter.Options} options | ||
*/ | ||
constructor(psv, options) { | ||
super(psv); | ||
/** | ||
* @member {PSV.adapters.CubemapAdapter.Options} | ||
* @private | ||
*/ | ||
this.config = { | ||
flipTopBottom: false, | ||
...options, | ||
}; | ||
} | ||
/** | ||
* @override | ||
@@ -146,2 +169,7 @@ * @param {string[] | PSV.adapters.CubemapAdapter.Cubemap} panorama | ||
if (this.config.flipTopBottom && (i === 2 || i === 3)) { | ||
texture[i].center = VECTOR2D_CENTER; | ||
texture[i].rotation = Math.PI; | ||
} | ||
mesh.material[i].map = texture[i]; | ||
@@ -148,0 +176,0 @@ } |
@@ -37,2 +37,9 @@ import { EventEmitter } from 'uevent'; | ||
/** | ||
* @summary Initializes the plugin | ||
* @package | ||
*/ | ||
init() { | ||
} | ||
/** | ||
* @summary Destroys the plugin | ||
@@ -39,0 +46,0 @@ * @package |
@@ -65,3 +65,2 @@ import { AbstractPlugin, CONSTANTS, PSVError, utils } from '../..'; | ||
...options, | ||
keypoints : null, | ||
}; | ||
@@ -78,6 +77,16 @@ | ||
*/ | ||
this.markers = null; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.markers = this.psv.getPlugin('markers'); | ||
if (options?.keypoints) { | ||
this.setKeypoints(options.keypoints); | ||
if (this.config.keypoints) { | ||
this.setKeypoints(this.config.keypoints); | ||
delete this.config.keypoints; | ||
} | ||
@@ -98,3 +107,2 @@ | ||
delete this.keypoints; | ||
delete this.state; | ||
@@ -101,0 +109,0 @@ super.destroy(); |
@@ -73,3 +73,3 @@ import * as THREE from 'three'; | ||
*/ | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.markers = null; | ||
@@ -94,2 +94,11 @@ /** | ||
/** | ||
* @member {HTMLCanvasElement} | ||
* @readonly | ||
* @private | ||
*/ | ||
this.canvas = document.createElement('canvas'); | ||
this.container.appendChild(this.canvas); | ||
if (this.config.navigation) { | ||
@@ -101,17 +110,21 @@ this.container.addEventListener('mouseenter', this); | ||
this.container.addEventListener('mouseup', this); | ||
this.container.addEventListener('touchstart', this); | ||
this.container.addEventListener('touchmove', this); | ||
this.container.addEventListener('touchend', this); | ||
} | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.psv.container.appendChild(this.container); | ||
/** | ||
* @member {HTMLCanvasElement} | ||
* @readonly | ||
* @private | ||
*/ | ||
this.canvas = document.createElement('canvas'); | ||
this.canvas.width = this.container.clientWidth * SYSTEM.pixelRatio; | ||
this.canvas.height = this.container.clientWidth * SYSTEM.pixelRatio; | ||
this.container.appendChild(this.canvas); | ||
this.psv.on(CONSTANTS.EVENTS.RENDER, this); | ||
@@ -156,3 +169,4 @@ | ||
case 'mousemove': | ||
this.prop.mouse = e; | ||
case 'touchmove': | ||
this.prop.mouse = e.changedTouches?.[0] || e; | ||
if (this.prop.mouseDown) { | ||
@@ -165,11 +179,21 @@ this.__click(); | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
break; | ||
case 'mousedown': | ||
case 'touchstart': | ||
this.prop.mouseDown = true; | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
break; | ||
case 'mouseup': | ||
this.prop.mouse = e; | ||
case 'touchend': | ||
this.prop.mouse = e.changedTouches?.[0] || e; | ||
this.prop.mouseDown = false; | ||
this.__click(); | ||
if (e.changedTouches) { | ||
this.prop.mouse = null; | ||
this.__update(); | ||
} | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
break; | ||
@@ -176,0 +200,0 @@ case 'mouseleave': |
@@ -77,3 +77,10 @@ import * as THREE from 'three'; | ||
this.controls = null; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.psv.on(CONSTANTS.EVENTS.STOP_ALL, this); | ||
@@ -95,3 +102,2 @@ this.psv.on(CONSTANTS.EVENTS.BEFORE_ROTATE, this); | ||
delete this.controls; | ||
delete this.prop; | ||
@@ -98,0 +104,0 @@ super.destroy(); |
@@ -65,11 +65,2 @@ import * as THREE from 'three'; | ||
/** | ||
* @member {HTMLElement} | ||
* @readonly | ||
*/ | ||
this.container = document.createElement('div'); | ||
this.container.className = 'psv-markers'; | ||
this.container.style.cursor = this.psv.config.mousemove ? 'move' : 'default'; | ||
this.psv.container.appendChild(this.container); | ||
/** | ||
* @summary All registered markers | ||
@@ -104,2 +95,10 @@ * @member {Object<string, PSV.plugins.MarkersPlugin.Marker>} | ||
/** | ||
* @member {HTMLElement} | ||
* @readonly | ||
*/ | ||
this.container = document.createElement('div'); | ||
this.container.className = 'psv-markers'; | ||
this.container.style.cursor = this.psv.config.mousemove ? 'move' : 'default'; | ||
/** | ||
* @member {SVGElement} | ||
@@ -117,3 +116,12 @@ * @readonly | ||
this.container.addEventListener('contextmenu', this); | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.psv.container.appendChild(this.container); | ||
// Viewer events | ||
@@ -125,5 +133,6 @@ this.psv.on(CONSTANTS.EVENTS.CLICK, this); | ||
if (options?.markers) { | ||
if (this.config.markers) { | ||
this.psv.once(CONSTANTS.EVENTS.READY, () => { | ||
this.setMarkers(options.markers); | ||
this.setMarkers(this.config.markers); | ||
delete this.config.markers; | ||
}); | ||
@@ -154,3 +163,2 @@ } | ||
delete this.container; | ||
delete this.prop; | ||
@@ -157,0 +165,0 @@ super.destroy(); |
@@ -51,17 +51,4 @@ import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError } from '../..'; | ||
*/ | ||
this.settings = psv.getPlugin('settings'); | ||
this.settings = null; | ||
if (!this.settings) { | ||
throw new PSVError('Resolution plugin requires the Settings plugin'); | ||
} | ||
this.settings.addSetting({ | ||
id : ResolutionPlugin.id, | ||
type : 'options', | ||
label : this.psv.config.lang.resolution, | ||
current: () => this.prop.resolution, | ||
options: () => this.__getSettingsOptions(), | ||
apply : resolution => this.setResolution(resolution), | ||
}); | ||
/** | ||
@@ -89,6 +76,36 @@ * @summary Available resolutions | ||
/** | ||
* @type {PSV.plugins.ResolutionPlugin.Options} | ||
*/ | ||
this.config = { | ||
...options, | ||
}; | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.settings = this.psv.getPlugin('settings'); | ||
if (!this.settings) { | ||
throw new PSVError('Resolution plugin requires the Settings plugin'); | ||
} | ||
this.settings.addSetting({ | ||
id : ResolutionPlugin.id, | ||
type : 'options', | ||
label : this.psv.config.lang.resolution, | ||
current: () => this.prop.resolution, | ||
options: () => this.__getSettingsOptions(), | ||
apply : resolution => this.setResolution(resolution), | ||
}); | ||
this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
if (options?.resolutions) { | ||
this.setResolutions(options.resolutions); | ||
if (this.config.resolutions) { | ||
this.setResolutions(this.config.resolutions); | ||
delete this.config.resolutions; | ||
} | ||
@@ -95,0 +112,0 @@ } |
@@ -70,3 +70,12 @@ import { AbstractPlugin, DEFAULTS, PSVError, registerButton, utils } from '../..'; | ||
*/ | ||
init() { | ||
super.init(); | ||
} | ||
/** | ||
* @package | ||
*/ | ||
destroy() { | ||
delete this.settings; | ||
super.destroy(); | ||
@@ -73,0 +82,0 @@ } |
@@ -51,7 +51,10 @@ import { StereoEffect } from 'three/examples/jsm/effects/StereoEffect'; | ||
*/ | ||
this.gyroscope = psv.getPlugin('gyroscope'); | ||
this.gyroscope = null; | ||
if (!this.gyroscope) { | ||
throw new PSVError('Stereo plugin requires the Gyroscope plugin'); | ||
} | ||
/** | ||
* @type {PSV.plugins.MarkersPlugin} | ||
* @readonly | ||
* @private | ||
*/ | ||
this.markers = null; | ||
@@ -67,3 +70,3 @@ /** | ||
this.prop = { | ||
isSupported: this.gyroscope.prop.isSupported, | ||
isSupported: false, | ||
renderer : null, | ||
@@ -73,9 +76,19 @@ noSleep : null, | ||
}; | ||
} | ||
/** | ||
* @type {PSV.plugins.MarkersPlugin} | ||
* @private | ||
*/ | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.gyroscope = this.psv.getPlugin('gyroscope'); | ||
if (!this.gyroscope) { | ||
throw new PSVError('Stereo plugin requires the Gyroscope plugin'); | ||
} | ||
this.prop.isSupported = this.gyroscope.prop.isSupported; | ||
this.psv.on(CONSTANTS.EVENTS.STOP_ALL, this); | ||
@@ -94,6 +107,2 @@ this.psv.on(CONSTANTS.EVENTS.CLICK, this); | ||
if (this.prop.noSleep) { | ||
delete this.prop.noSleep; | ||
} | ||
super.destroy(); | ||
@@ -149,5 +158,3 @@ } | ||
if (this.markers) { | ||
this.markers.hide(); | ||
} | ||
this.markers?.hide(); | ||
this.psv.navbar.hide(); | ||
@@ -180,5 +187,3 @@ this.psv.panel.hide(); | ||
if (this.markers) { | ||
this.markers.show(); | ||
} | ||
this.markers?.show(); | ||
this.psv.navbar.show(); | ||
@@ -185,0 +190,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from 'photo-sphere-viewer'; | ||
import * as THREE from 'three'; | ||
import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..'; | ||
import { ClientSideDatasource } from './ClientSideDatasource'; | ||
@@ -94,2 +94,3 @@ import { | ||
* @property {boolean|PSV.plugins.VirtualTourPlugin.Preload} [preload=false] - preload linked panoramas | ||
* @property {boolean|string|number} [rotateSpeed='20rpm'] - speed of rotation when clicking on a link, if 'false' the viewer won't rotate at all | ||
* @property {boolean} [listButton] - adds a button to show the list of nodes, defaults to `true` only in client data mode | ||
@@ -103,2 +104,9 @@ * @property {boolean} [linksOnCompass] - if the Compass plugin is enabled, displays the links on the compass, defaults to `true` on in markers render mode | ||
/** | ||
* @typedef {Object} PSV.plugins.VirtualTourPlugin.NodeChangedData | ||
* @summary Data associated to the "node-changed" event | ||
* @type {PSV.plugins.VirtualTourPlugin.Node} [fromNode] - The previous node | ||
* @type {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink] - The link that was clicked in the previous node | ||
* @type {PSV.Position} [fromLinkPosition] - The position of the link on the previous node | ||
*/ | ||
@@ -160,2 +168,3 @@ // add markers buttons | ||
preload : false, | ||
rotateSpeed : '20rpm', | ||
markerLatOffset: -0.1, | ||
@@ -166,11 +175,10 @@ arrowPosition : 'bottom', | ||
...options, | ||
markerStyle: { | ||
markerStyle : { | ||
...DEFAULT_MARKER, | ||
...options?.markerStyle, | ||
}, | ||
arrowStyle : { | ||
arrowStyle : { | ||
...DEFAULT_ARROW, | ||
...options?.arrowStyle, | ||
}, | ||
nodes : null, | ||
}; | ||
@@ -182,3 +190,3 @@ | ||
*/ | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.markers = null; | ||
@@ -189,12 +197,8 @@ /** | ||
*/ | ||
this.compass = this.psv.getPlugin('compass'); | ||
this.compass = null; | ||
if (!this.is3D() && !this.markers) { | ||
throw new PSVError('Tour plugin requires the Markers plugin in markers mode'); | ||
} | ||
/** | ||
* @type {PSV.plugins.VirtualTourPlugin.AbstractDatasource} | ||
*/ | ||
this.datasource = this.isServerSide() ? new ServerSideDatasource(this) : new ClientSideDatasource(this); | ||
this.datasource = null; | ||
@@ -213,3 +217,21 @@ /** | ||
this.arrowsGroup.add(localLight); | ||
} | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.markers = this.psv.getPlugin('markers'); | ||
this.compass = this.psv.getPlugin('compass'); | ||
if (!this.is3D() && !this.markers) { | ||
throw new PSVError('Tour plugin requires the Markers plugin in markers mode'); | ||
} | ||
this.datasource = this.isServerSide() ? new ServerSideDatasource(this) : new ClientSideDatasource(this); | ||
if (this.is3D()) { | ||
this.psv.once(CONSTANTS.EVENTS.READY, () => { | ||
@@ -240,7 +262,11 @@ this.__positionArrows(); | ||
} | ||
else if (options?.nodes) { | ||
this.setNodes(options.nodes, this.config.startNodeId); | ||
else if (this.config.nodes) { | ||
this.setNodes(this.config.nodes, this.config.startNodeId); | ||
delete this.config.nodes; | ||
} | ||
} | ||
/** | ||
* @package | ||
*/ | ||
destroy() { | ||
@@ -264,3 +290,3 @@ if (this.markers) { | ||
delete this.markers; | ||
delete this.prop; | ||
delete this.compass; | ||
delete this.arrowsGroup; | ||
@@ -272,8 +298,8 @@ | ||
handleEvent(e) { | ||
let nodeId; | ||
let link; | ||
switch (e.type) { | ||
case 'select-marker': | ||
nodeId = e.args[0].data?.[LINK_DATA]?.nodeId; | ||
if (nodeId) { | ||
this.setCurrentNode(nodeId); | ||
link = e.args[0].data?.[LINK_DATA]; | ||
if (link) { | ||
this.setCurrentNode(link.nodeId, link); | ||
} | ||
@@ -290,10 +316,10 @@ break; | ||
case CONSTANTS.EVENTS.CLICK: | ||
nodeId = this.prop.currentArrow?.userData?.[LINK_DATA]?.nodeId; | ||
if (!nodeId) { | ||
link = this.prop.currentArrow?.userData?.[LINK_DATA]; | ||
if (!link) { | ||
// on touch screens "currentArrow" may be null (no hover state) | ||
const arrow = this.psv.dataHelper.getIntersection({ x: e.args[0].viewerX, y: e.args[0].viewerY }, LINK_DATA)?.object; | ||
nodeId = arrow?.userData?.[LINK_DATA]?.nodeId; | ||
link = arrow?.userData?.[LINK_DATA]; | ||
} | ||
if (nodeId) { | ||
this.setCurrentNode(nodeId); | ||
if (link) { | ||
this.setCurrentNode(link.nodeId, link); | ||
} | ||
@@ -361,5 +387,6 @@ break; | ||
* @param {string} nodeId | ||
* @param {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink] | ||
* @returns {Promise<boolean>} resolves false if the loading was aborted by another call | ||
*/ | ||
setCurrentNode(nodeId) { | ||
setCurrentNode(nodeId, fromLink = null) { | ||
if (nodeId === this.prop.currentNode?.id) { | ||
@@ -369,3 +396,2 @@ return Promise.resolve(true); | ||
this.psv.loader.show(); | ||
this.psv.hideError(); | ||
@@ -375,13 +401,30 @@ | ||
// if this node is already preloading, wait for it | ||
return Promise.resolve(this.preload[nodeId]) | ||
.then(() => { | ||
if (this.prop.loadingNode !== nodeId) { | ||
return Promise.reject(utils.getAbortError()); | ||
} | ||
const fromNode = this.prop.currentNode; | ||
const fromLinkPosition = fromNode && fromLink ? this.__getLinkPosition(fromNode, fromLink) : null; | ||
this.psv.textureLoader.abortLoading(); | ||
return this.datasource.loadNode(nodeId); | ||
}) | ||
.then((node) => { | ||
return Promise.all([ | ||
// if this node is already preloading, wait for it | ||
Promise.resolve(this.preload[nodeId]) | ||
.then(() => { | ||
if (this.prop.loadingNode !== nodeId) { | ||
return Promise.reject(utils.getAbortError()); | ||
} | ||
this.psv.textureLoader.abortLoading(); | ||
return this.datasource.loadNode(nodeId); | ||
}), | ||
Promise.resolve(fromLinkPosition ? this.config.rotateSpeed : false) | ||
.then((speed) => { | ||
if (!speed) { | ||
return Promise.resolve(); | ||
} | ||
else { | ||
return this.psv.animate({ ...fromLinkPosition, speed }); | ||
} | ||
}) | ||
.then(() => { | ||
this.psv.loader.show(); | ||
}), | ||
]) | ||
.then(([node]) => { | ||
if (this.prop.loadingNode !== nodeId) { | ||
@@ -446,4 +489,9 @@ return Promise.reject(utils.getAbortError()); | ||
* @param {string} nodeId | ||
* @param {PSV.plugins.VirtualTourPlugin.NodeChangedData} data | ||
*/ | ||
this.trigger(EVENTS.NODE_CHANGED, nodeId); | ||
this.trigger(EVENTS.NODE_CHANGED, nodeId, { | ||
fromNode, | ||
fromLink, | ||
fromLinkPosition, | ||
}); | ||
@@ -493,7 +541,7 @@ this.prop.loadingNode = null; | ||
mesh.userData = { [LINK_DATA]: link, longitude : position.longitude }; | ||
mesh.userData = { [LINK_DATA]: link, longitude: position.longitude }; | ||
mesh.rotation.order = 'YXZ'; | ||
mesh.rotateY(-position.longitude); | ||
this.psv.dataHelper | ||
.sphericalCoordsToVector3({ longitude: position.longitude, latitude : 0 }, mesh.position) | ||
.sphericalCoordsToVector3({ longitude: position.longitude, latitude: 0 }, mesh.position) | ||
.multiplyScalar(1 / CONSTANTS.SPHERE_RADIUS); | ||
@@ -500,0 +548,0 @@ |
import * as THREE from 'three'; | ||
import { AbstractPlugin, Animation, CONSTANTS, utils } from '../..'; | ||
import { AbstractPlugin, CONSTANTS, utils } from '../..'; | ||
@@ -37,14 +37,20 @@ | ||
usePanoData : false, | ||
...options, | ||
}; | ||
} | ||
if (options) { | ||
this.config.usePanoData = !!options.usePanoData; | ||
this.setLatitudeRange(options.latitudeRange); | ||
this.setLongitudeRange(options.longitudeRange); | ||
} | ||
/** | ||
* @package | ||
*/ | ||
init() { | ||
super.init(); | ||
this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this); | ||
this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this); | ||
this.psv.on(CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION, this); | ||
this.psv.on(CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION, this); | ||
this.setLatitudeRange(this.config.latitudeRange); | ||
this.setLongitudeRange(this.config.longitudeRange); | ||
} | ||
@@ -57,2 +63,3 @@ | ||
this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this); | ||
this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this); | ||
this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this); | ||
@@ -70,28 +77,30 @@ this.psv.off(CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION, this); | ||
handleEvent(e) { | ||
if (e.type === CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION) { | ||
const { rangedPosition } = this.applyRanges(e.value); | ||
return rangedPosition; | ||
} | ||
else if (e.type === CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION) { | ||
const { rangedPosition, sidesReached } = this.applyRanges(e.value); | ||
switch (e.type) { | ||
case CONSTANTS.CHANGE_EVENTS.GET_ANIMATE_POSITION: | ||
case CONSTANTS.CHANGE_EVENTS.GET_ROTATE_POSITION: | ||
return this.applyRanges(e.value).rangedPosition; | ||
if (utils.intersect(['left', 'right'], sidesReached).length > 0 && this.psv.isAutorotateEnabled()) { | ||
this.__reverseAutorotate(); | ||
return e.value; | ||
} | ||
case CONSTANTS.EVENTS.POSITION_UPDATED: | ||
const { sidesReached } = this.applyRanges(e.args[0]); | ||
if ((sidesReached.left || sidesReached.right) && this.psv.isAutorotateEnabled()) { | ||
this.__reverseAutorotate(sidesReached.left, sidesReached.right); | ||
} | ||
break; | ||
return rangedPosition; | ||
case CONSTANTS.EVENTS.PANORAMA_LOADED: | ||
if (this.config.usePanoData) { | ||
this.setRangesFromPanoData(); | ||
} | ||
break; | ||
case CONSTANTS.EVENTS.ZOOM_UPDATED: | ||
const currentPosition = this.psv.getPosition(); | ||
const { rangedPosition } = this.applyRanges(currentPosition); | ||
if (currentPosition.longitude !== rangedPosition.longitude || currentPosition.latitude !== rangedPosition.latitude) { | ||
this.psv.rotate(rangedPosition); | ||
} | ||
break; | ||
default: | ||
} | ||
else if (e.type === CONSTANTS.EVENTS.PANORAMA_LOADED) { | ||
if (this.config.usePanoData) { | ||
this.setRangesFromPanoData(); | ||
} | ||
} | ||
else if (e.type === CONSTANTS.EVENTS.ZOOM_UPDATED) { | ||
const currentPosition = this.psv.getPosition(); | ||
const { rangedPosition } = this.applyRanges(currentPosition); | ||
if (currentPosition.longitude !== rangedPosition.longitude || currentPosition.latitude !== rangedPosition.latitude) { | ||
this.psv.rotate(rangedPosition); | ||
} | ||
} | ||
} | ||
@@ -201,3 +210,3 @@ | ||
}; | ||
const sidesReached = []; | ||
const sidesReached = {}; | ||
@@ -218,7 +227,7 @@ let range; | ||
rangedPosition.longitude = range[0]; | ||
sidesReached.push('left'); | ||
sidesReached.left = true; | ||
} | ||
else { | ||
rangedPosition.longitude = range[1]; | ||
sidesReached.push('right'); | ||
sidesReached.right = true; | ||
} | ||
@@ -229,7 +238,7 @@ } | ||
rangedPosition.longitude = range[0]; | ||
sidesReached.push('left'); | ||
sidesReached.left = true; | ||
} | ||
else if (position.longitude > range[1]) { | ||
rangedPosition.longitude = range[1]; | ||
sidesReached.push('right'); | ||
sidesReached.right = true; | ||
} | ||
@@ -247,7 +256,7 @@ } | ||
rangedPosition.latitude = range[0]; | ||
sidesReached.push('bottom'); | ||
sidesReached.bottom = true; | ||
} | ||
else if (position.latitude > range[1]) { | ||
rangedPosition.latitude = range[1]; | ||
sidesReached.push('top'); | ||
sidesReached.top = true; | ||
} | ||
@@ -263,32 +272,12 @@ } | ||
*/ | ||
__reverseAutorotate() { | ||
const newSpeed = -this.psv.config.autorotateSpeed; | ||
const range = this.config.longitudeRange; | ||
this.config.longitudeRange = null; | ||
__reverseAutorotate(left, right) { | ||
// reverse already ongoing | ||
if (left && this.psv.config.autorotateSpeed > 0 || right && this.psv.config.autorotateSpeed < 0) { | ||
return; | ||
} | ||
new Animation({ | ||
properties: { | ||
speed: { start: this.psv.config.autorotateSpeed, end: 0 }, | ||
}, | ||
duration : 300, | ||
easing : 'inSine', | ||
onTick : (properties) => { | ||
this.psv.config.autorotateSpeed = properties.speed; | ||
}, | ||
}) | ||
.then(() => new Animation({ | ||
properties: { | ||
speed: { start: 0, end: newSpeed }, | ||
}, | ||
duration : 300, | ||
easing : 'outSine', | ||
onTick : (properties) => { | ||
this.psv.config.autorotateSpeed = properties.speed; | ||
}, | ||
})) | ||
.then(() => { | ||
this.config.longitudeRange = range; | ||
}); | ||
this.psv.config.autorotateSpeed = -this.psv.config.autorotateSpeed; | ||
this.psv.startAutorotate(true); | ||
} | ||
} |
@@ -94,7 +94,7 @@ import * as THREE from 'three'; | ||
this.psv.container.addEventListener('mouseleave', this); | ||
this.psv.container.addEventListener('mousemove', this); | ||
window.addEventListener('mouseup', this); | ||
this.psv.container.addEventListener('touchstart', this); | ||
this.psv.container.addEventListener('touchmove', this); | ||
window.addEventListener('touchend', this); | ||
this.psv.container.addEventListener('mousemove', this); | ||
this.psv.container.addEventListener('touchmove', this); | ||
this.psv.container.addEventListener(SYSTEM.mouseWheelEvent, this); | ||
@@ -117,7 +117,7 @@ | ||
this.psv.container.removeEventListener('mouseleave', this); | ||
this.psv.container.removeEventListener('mousemove', this); | ||
window.removeEventListener('mouseup', this); | ||
this.psv.container.removeEventListener('touchstart', this); | ||
this.psv.container.removeEventListener('touchmove', this); | ||
window.removeEventListener('touchend', this); | ||
this.psv.container.removeEventListener('mousemove', this); | ||
this.psv.container.removeEventListener('touchmove', this); | ||
this.psv.container.removeEventListener(SYSTEM.mouseWheelEvent, this); | ||
@@ -164,5 +164,5 @@ | ||
case 'mouseenter': this.__onMouseEnter(evt); break; | ||
case 'touchstart': this.__onTouchStart(evt); break; | ||
case 'mouseleave': this.__onMouseLeave(evt); break; | ||
case 'mousemove': this.__onMouseMove(evt); break; | ||
case 'touchstart': this.__onTouchStart(evt); break; | ||
case 'touchmove': this.__onTouchMove(evt); break; | ||
@@ -492,3 +492,2 @@ case SYSTEM.mouseWheelEvent: this.__onMouseWheel(evt); break; | ||
__startMove(evt) { | ||
this.psv.stopAutorotate(); | ||
this.psv.stopAnimation() | ||
@@ -495,0 +494,0 @@ .then(() => { |
@@ -95,7 +95,4 @@ import * as THREE from 'three'; | ||
psv.on(EVENTS.POSITION_UPDATED, this); | ||
psv.on(EVENTS.CONFIG_CHANGED, this); | ||
psv.on(EVENTS.CONFIG_CHANGED, () => { | ||
this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default'; | ||
}); | ||
this.hide(); | ||
@@ -140,2 +137,10 @@ } | ||
case EVENTS.POSITION_UPDATED: this.__onPositionUpdated(); break; | ||
case EVENTS.CONFIG_CHANGED: | ||
if (evt.args[0].indexOf('fisheye') !== -1) { | ||
this.__onPositionUpdated(); | ||
} | ||
if (evt.args[0].indexOf('mousemove') !== -1) { | ||
this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default'; | ||
} | ||
break; | ||
// @formatter:on | ||
@@ -305,3 +310,3 @@ } | ||
this.psv.adapter.setTextureOpacity(mesh, 0); | ||
this.setPanoramaPose(options.panoData, mesh); | ||
this.setPanoramaPose(textureData.panoData, mesh); | ||
this.setSphereCorrection(options.sphereCorrection, group); | ||
@@ -336,2 +341,3 @@ | ||
this.psv.adapter.setTextureOpacity(mesh, properties.opacity); | ||
this.psv.adapter.setTextureOpacity(this.mesh, 1 - properties.opacity); | ||
@@ -348,3 +354,4 @@ if (zoomProvided) { | ||
this.setTexture(textureData); | ||
this.setPanoramaPose(options.panoData); | ||
this.psv.adapter.setTextureOpacity(this.mesh, 1); | ||
this.setPanoramaPose(textureData.panoData); | ||
this.setSphereCorrection(options.sphereCorrection); | ||
@@ -351,0 +358,0 @@ |
@@ -175,14 +175,2 @@ /** | ||
/** | ||
* @summary Returns the intersection between two arrays | ||
* @memberOf PSV.utils | ||
* @template T | ||
* @param {T[]} array1 | ||
* @param {T[]} array2 | ||
* @returns {T[]} | ||
*/ | ||
export function intersect(array1, array2) { | ||
return array1.filter(value => array2.indexOf(value) !== -1); | ||
} | ||
/** | ||
* @summary Returns if a valu is null or undefined | ||
@@ -189,0 +177,0 @@ * @memberOf PSV.utils |
@@ -236,3 +236,3 @@ import * as THREE from 'three'; | ||
this.dataHelper.sphericalCoordsToVector3(position, this.prop.direction); | ||
this.trigger(EVENTS.POSITION_UPDATED, position); | ||
this.trigger(EVENTS.POSITION_UPDATED, this.dataHelper.cleanPosition(position)); | ||
}), | ||
@@ -254,2 +254,3 @@ }; | ||
}); | ||
each(this.plugins, plugin => plugin.init?.()); | ||
@@ -377,3 +378,3 @@ // init buttons | ||
getPosition() { | ||
return this.dynamics.position.current; | ||
return this.dataHelper.cleanPosition(this.dynamics.position.current); | ||
} | ||
@@ -632,5 +633,11 @@ | ||
*/ | ||
startAutorotate() { | ||
this.__stopAll(); | ||
startAutorotate(refresh = false) { | ||
if (refresh && !this.isAutorotateEnabled()) { | ||
return; | ||
} | ||
if (!refresh) { | ||
this.__stopAll(); | ||
} | ||
this.dynamics.position.roll({ | ||
@@ -646,3 +653,5 @@ longitude: this.config.autorotateSpeed < 0, | ||
this.trigger(EVENTS.AUTOROTATE, true); | ||
if (!refresh) { | ||
this.trigger(EVENTS.AUTOROTATE, true); | ||
} | ||
} | ||
@@ -716,2 +725,3 @@ | ||
this.dynamics.position.setValue(cleanPosition); | ||
this.stopAutorotate(); | ||
} | ||
@@ -718,0 +728,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { AbstractAdapter } from '../..'; | ||
import { AbstractAdapter, Viewer } from '../..'; | ||
@@ -21,2 +21,6 @@ /** | ||
export type CubemapAdapterOptions = { | ||
flipTopBottom?: boolean; | ||
}; | ||
/** | ||
@@ -27,2 +31,4 @@ * @summary Adapter for cubemaps | ||
constructor(psv: Viewer, options: CubemapAdapterOptions); | ||
} |
@@ -17,2 +17,7 @@ import { EventEmitter } from 'uevent'; | ||
/** | ||
* @summary Initializes the plugin | ||
*/ | ||
init(); | ||
/** | ||
* @summary Destroys the plugin | ||
@@ -19,0 +24,0 @@ */ |
import { Event } from 'uevent'; | ||
import { AbstractPlugin, Viewer, ViewerOptions } from '../..'; | ||
import { AbstractPlugin, Position, Viewer, ViewerOptions } from '../..'; | ||
import { Marker, MarkerProperties } from '../markers'; | ||
@@ -41,2 +41,11 @@ | ||
/** | ||
* @summary Data associated to the "node-changed" event | ||
*/ | ||
export type VirtualTourNodeChangedData = { | ||
fromNode?: VirtualTourNode, | ||
fromLink?: VirtualTourNodeLink, | ||
fromLinkPosition?: Position, | ||
}; | ||
export type VirtualTourPluginPluginOptions = { | ||
@@ -51,2 +60,3 @@ dataMode?: 'client' | 'server'; | ||
preload?: boolean | ((node: VirtualTourNode, link: VirtualTourNodeLink) => boolean); | ||
rotateSpeed?: boolean | string | number; | ||
markerStyle?: MarkerProperties; | ||
@@ -56,7 +66,7 @@ arrowStyle?: VirtualTourArrowStyle; | ||
arrowPosition?: 'top' | 'bottom'; | ||
} | ||
}; | ||
export const EVENTS: { | ||
NODE_CHANGED: 'node-changed', | ||
RENDER_NODES_LIST: 'render-nodes-list, | ||
RENDER_NODES_LIST: 'render-nodes-list', | ||
}; | ||
@@ -100,3 +110,3 @@ | ||
*/ | ||
on(e: 'node-changed', cb: (e: Event, node: Node) => void): this; | ||
on(e: 'node-changed', cb: (e: Event, nodeId: VirtualTourNode['id'], data: VirtualTourNodeChangedData) => void): this; | ||
@@ -106,4 +116,4 @@ /** | ||
*/ | ||
on(e: 'render-nodes-list', cb: (e: Event, nodes: Node[]) => Node[]): this; | ||
on(e: 'render-nodes-list', cb: (e: Event, nodes: VirtualTourNode[]) => VirtualTourNode[]): this; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1855745
31768