diff --git a/dist/adapters/cubemap-tiles.js b/dist/adapters/cubemap-tiles.js index 3b555aa83..e52723897 100644 --- a/dist/adapters/cubemap-tiles.js +++ b/dist/adapters/cubemap-tiles.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -295,6 +295,7 @@ /** * @summary Adapter for tiled cubemaps * @memberof PSV.adapters + * @extends PSV.adapters.AbstractAdapter */ var CubemapTilesAdapter = /*#__PURE__*/function (_CubemapAdapter) { diff --git a/dist/adapters/cubemap-tiles.js.map b/dist/adapters/cubemap-tiles.js.map index 29c72b41a..37209c589 100644 --- a/dist/adapters/cubemap-tiles.js.map +++ b/dist/adapters/cubemap-tiles.js.map @@ -1 +1 @@ -{"version":3,"file":"cubemap-tiles.js","sources":["../../src/adapters/tiles-shared/Task.js","../../src/adapters/tiles-shared/Queue.js","../../src/adapters/tiles-shared/utils.js","../../src/adapters/cubemap-tiles/index.js"],"sourcesContent":["/**\n * @summary Loading task\n * @memberOf PSV.adapters\n * @private\n */\nexport class Task {\n\n static STATUS = {\n DISABLED : -1,\n PENDING : 0,\n RUNNING : 1,\n CANCELLED: 2,\n DONE : 3,\n ERROR : 4,\n };\n\n /**\n * @param {string} id\n * @param {number} priority\n * @param {function(Task): Promise} fn\n */\n constructor(id, priority, fn) {\n this.id = id;\n this.priority = priority;\n this.fn = fn;\n this.status = Task.STATUS.PENDING;\n }\n\n start() {\n this.status = Task.STATUS.RUNNING;\n return this.fn(this)\n .then(() => {\n this.status = Task.STATUS.DONE;\n }, () => {\n this.status = Task.STATUS.ERROR;\n });\n }\n\n cancel() {\n this.status = Task.STATUS.CANCELLED;\n }\n\n isCancelled() {\n return this.status === Task.STATUS.CANCELLED;\n }\n\n}\n","import { Task } from './Task';\n\n/**\n * @summary Loading queue\n * @memberOf PSV.adapters\n * @private\n */\nexport class Queue {\n\n /**\n * @param {int} concurency\n */\n constructor(concurency = 4) {\n this.concurency = concurency;\n this.runningTasks = {};\n this.tasks = {};\n }\n\n enqueue(task) {\n this.tasks[task.id] = task;\n }\n\n clear() {\n Object.values(this.tasks).forEach(task => task.cancel());\n this.tasks = {};\n this.runningTasks = {};\n }\n\n setPriority(taskId, priority) {\n const task = this.tasks[taskId];\n if (task) {\n task.priority = priority;\n if (task.status === Task.STATUS.DISABLED) {\n task.status = Task.STATUS.PENDING;\n }\n }\n }\n\n disableAllTasks() {\n Object.values(this.tasks).forEach((task) => {\n task.status = Task.STATUS.DISABLED;\n });\n }\n\n start() {\n if (Object.keys(this.runningTasks).length >= this.concurency) {\n return;\n }\n\n const nextTask = Object.values(this.tasks)\n .filter(task => task.status === Task.STATUS.PENDING)\n .sort((a, b) => b.priority - a.priority)\n .pop();\n\n if (nextTask) {\n this.runningTasks[nextTask.id] = true;\n\n nextTask.start()\n .then(() => {\n if (!nextTask.isCancelled()) {\n delete this.tasks[nextTask.id];\n delete this.runningTasks[nextTask.id];\n this.start();\n }\n });\n\n this.start(); // start tasks until max concurrency is reached\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { SYSTEM, utils } from '../..';\n\n/**\n * @summary Generates an material for errored tiles\n * @memberOf PSV.adapters\n * @return {external:THREE.MeshBasicMaterial}\n * @private\n */\nexport function buildErrorMaterial(width, height) {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n\n const ctx = canvas.getContext('2d');\n\n ctx.fillStyle = '#333';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n ctx.font = `${canvas.width / 5}px serif`;\n ctx.fillStyle = '#a22';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText('⚠', canvas.width / 2, canvas.height / 2);\n\n const texture = new THREE.CanvasTexture(canvas);\n return new THREE.MeshBasicMaterial({ map: texture });\n}\n\n/**\n * @summary Create the texture for the base image\n * @memberOf PSV.adapters\n * @param {HTMLImageElement} img\n * @param {boolean} blur\n * @param {function} getHeight\n * @return {external:THREE.Texture}\n * @private\n */\nexport function createBaseTexture(img, blur, getHeight) {\n if (blur || img.width > SYSTEM.maxTextureWidth) {\n const ratio = Math.min(1, SYSTEM.getMaxCanvasWidth() / img.width);\n\n const buffer = document.createElement('canvas');\n buffer.width = img.width * ratio;\n buffer.height = getHeight(img.width);\n\n const ctx = buffer.getContext('2d');\n if (blur) {\n ctx.filter = 'blur(1px)';\n }\n ctx.drawImage(img, 0, 0, buffer.width, buffer.height);\n\n return utils.createTexture(buffer);\n }\n\n return utils.createTexture(img);\n}\n\n/**\n * @summary Creates a wireframe geometry, for debug\n * @memberOf PSV.adapters\n * @param {THREE.BufferGeometry} geometry\n * @return {THREE.Object3D}\n * @private\n */\nexport function createWireFrame(geometry) {\n const wireframe = new THREE.WireframeGeometry(geometry);\n const line = new THREE.LineSegments(wireframe);\n line.material.depthTest = false;\n line.material.opacity = 0.25;\n line.material.transparent = true;\n return line;\n}\n\n/**\n * @summary Creates a small red sphere, for debug\n * @memberOf PSV.adapters\n * @return {THREE.Object3D}\n * @private\n */\nexport function createDot(x, y, z) {\n const geom = new THREE.SphereGeometry(0.1);\n const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });\n const mesh = new THREE.Mesh(geom, material);\n mesh.position.set(x, y, z);\n return mesh;\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, PSVError, utils } from '../..';\nimport { CUBE_HASHMAP, CubemapAdapter } from '../cubemap';\nimport { Queue } from '../tiles-shared/Queue';\nimport { Task } from '../tiles-shared/Task';\nimport { buildErrorMaterial, createBaseTexture } from '../tiles-shared/utils';\n\nif (!CubemapAdapter) {\n throw new PSVError('CubemapAdapter is missing, please load cubemap.js before cubemap-tiles.js');\n}\n\n\n/**\n * @callback TileUrl\n * @summary Function called to build a tile url\n * @memberOf PSV.adapters.CubemapTilesAdapter\n * @param {'left'|'front'|'right'|'back'|'top'|'bottom'} face\n * @param {int} col\n * @param {int} row\n * @returns {string}\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapTilesAdapter.Panorama\n * @summary Configuration of a tiled cubemap\n * @property {PSV.adapters.CubemapAdapter.Cubemap} [baseUrl] - low resolution panorama loaded before tiles\n * @property {int} faceSize - size of a face\n * @property {int} nbTiles - number of tiles on a side of a face\n * @property {PSV.adapters.CubemapTilesAdapter.TileUrl} tileUrl - function to build a tile url\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapTilesAdapter.Options\n * @property {boolean} [flipTopBottom=false] - set to true if the top and bottom faces are not correctly oriented\n * @property {boolean} [showErrorTile=true] - shows a warning sign on tiles that cannot be loaded\n * @property {boolean} [baseBlur=true] - applies a blur to the low resolution panorama\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapTilesAdapter.Tile\n * @private\n * @property {int} face\n * @property {int} col\n * @property {int} row\n * @property {float} angle\n */\n\n\nconst CUBE_SEGMENTS = 16;\nconst NB_VERTICES_BY_FACE = 6;\nconst NB_VERTICES_BY_PLANE = NB_VERTICES_BY_FACE * CUBE_SEGMENTS * CUBE_SEGMENTS;\nconst NB_VERTICES = 6 * NB_VERTICES_BY_PLANE;\nconst NB_GROUPS_BY_FACE = CUBE_SEGMENTS * CUBE_SEGMENTS;\n\nconst ATTR_UV = 'uv';\nconst ATTR_ORIGINAL_UV = 'originaluv';\nconst ATTR_POSITION = 'position';\n\nfunction tileId(tile) {\n return `${tile.face}:${tile.col}x${tile.row}`;\n}\n\nconst frustum = new THREE.Frustum();\nconst projScreenMatrix = new THREE.Matrix4();\nconst vertexPosition = new THREE.Vector3();\n\n/**\n * @summary Adapter for tiled cubemaps\n * @memberof PSV.adapters\n */\nexport class CubemapTilesAdapter extends CubemapAdapter {\n\n static id = 'cubemap-tiles';\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.CubemapTilesAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.CubemapTilesAdapter.Options}\n * @private\n */\n this.config = {\n flipTopBottom: false,\n showErrorTile: true,\n baseBlur : true,\n ...options,\n };\n\n /**\n * @member {PSV.adapters.Queue}\n * @private\n */\n this.queue = new Queue();\n\n /**\n * @type {Object}\n * @property {int} tileSize - size in pixels of a tile\n * @property {int} facesByTile - number of mesh faces by tile\n * @property {Record} tiles - loaded tiles\n * @property {external:THREE.BoxGeometry} geom\n * @property {external:THREE.MeshBasicMaterial[]} materials\n * @property {external:THREE.MeshBasicMaterial} errorMaterial\n * @private\n */\n this.prop = {\n tileSize : 0,\n facesByTile : 0,\n tiles : {},\n geom : null,\n materials : [],\n errorMaterial: null,\n };\n\n /**\n * @member {external:THREE.ImageLoader}\n * @private\n */\n this.loader = new THREE.ImageLoader();\n if (this.psv.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders);\n }\n\n this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n\n this.__cleanup();\n\n this.prop.errorMaterial?.map?.dispose();\n this.prop.errorMaterial?.dispose();\n\n delete this.queue;\n delete this.loader;\n delete this.prop.geom;\n delete this.prop.errorMaterial;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.POSITION_UPDATED:\n case CONSTANTS.EVENTS.ZOOM_UPDATED:\n this.__refresh();\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Clears loading queue, dispose all materials\n * @private\n */\n __cleanup() {\n this.queue.clear();\n this.prop.tiles = {};\n\n this.prop.materials.forEach((mat) => {\n mat?.map?.dispose();\n mat?.dispose();\n });\n this.prop.materials.length = 0;\n }\n\n /**\n * @override\n */\n supportsTransition(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n */\n supportsPreload(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n * @param {PSV.adapters.CubemapTilesAdapter.Panorama} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n if (typeof panorama !== 'object' || !panorama.faceSize || !panorama.nbTiles || !panorama.tileUrl) {\n return Promise.reject(new PSVError('Invalid panorama configuration, are you using the right adapter?'));\n }\n if (panorama.nbTiles > CUBE_SEGMENTS) {\n return Promise.reject(new PSVError(`Panorama nbTiles must not be greater than ${CUBE_SEGMENTS}.`));\n }\n if (!utils.isPowerOfTwo(panorama.nbTiles)) {\n return Promise.reject(new PSVError('Panorama nbTiles must be power of 2.'));\n }\n\n if (panorama.baseUrl) {\n return super.loadTexture(panorama.baseUrl)\n .then(textureData => ({\n panorama: panorama,\n texture : textureData.texture,\n }));\n }\n else {\n return Promise.resolve({ panorama });\n }\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const cubeSize = CONSTANTS.SPHERE_RADIUS * 2 * scale;\n const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize, CUBE_SEGMENTS, CUBE_SEGMENTS, CUBE_SEGMENTS)\n .scale(1, 1, -1)\n .toNonIndexed();\n\n geometry.clearGroups();\n for (let i = 0, k = 0; i < NB_VERTICES; i += NB_VERTICES_BY_FACE) {\n geometry.addGroup(i, NB_VERTICES_BY_FACE, k++);\n }\n\n geometry.setAttribute(ATTR_ORIGINAL_UV, geometry.getAttribute(ATTR_UV).clone());\n\n return new THREE.Mesh(geometry, []);\n }\n\n /**\n * @summary Applies the base texture and starts the loading of tiles\n * @override\n */\n setTexture(mesh, textureData, transition) {\n const { panorama, texture } = textureData;\n\n if (transition) {\n this.__setTexture(mesh, texture);\n return;\n }\n\n this.__cleanup();\n this.__setTexture(mesh, texture);\n\n this.prop.materials = mesh.material;\n this.prop.geom = mesh.geometry;\n this.prop.geom.setAttribute(ATTR_UV, this.prop.geom.getAttribute(ATTR_ORIGINAL_UV).clone());\n\n this.prop.tileSize = panorama.faceSize / panorama.nbTiles;\n this.prop.facesByTile = CUBE_SEGMENTS / panorama.nbTiles;\n\n // this.psv.renderer.scene.add(createWireFrame(this.prop.geom));\n\n setTimeout(() => this.__refresh(true));\n }\n\n /**\n * @private\n */\n __setTexture(mesh, texture) {\n for (let i = 0; i < 6; i++) {\n let material;\n if (texture) {\n if (this.config.flipTopBottom && (i === 2 || i === 3)) {\n texture[i].center = new THREE.Vector2(0.5, 0.5);\n texture[i].rotation = Math.PI;\n }\n\n material = new THREE.MeshBasicMaterial({ map: texture[i] });\n }\n else {\n material = new THREE.MeshBasicMaterial({ opacity: 0, transparent: true });\n }\n\n for (let j = 0; j < NB_GROUPS_BY_FACE; j++) {\n mesh.material.push(material);\n }\n }\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n for (let i = 0; i < 6; i++) {\n mesh.material[i * NB_GROUPS_BY_FACE].opacity = opacity;\n mesh.material[i * NB_GROUPS_BY_FACE].transparent = opacity < 1;\n }\n }\n\n /**\n * @summary Compute visible tiles and load them\n * @private\n */\n __refresh(init = false) { // eslint-disable-line no-unused-vars\n if (!this.prop.geom) {\n return;\n }\n\n const camera = this.psv.renderer.camera;\n camera.updateMatrixWorld();\n projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n frustum.setFromProjectionMatrix(projScreenMatrix);\n\n const panorama = this.psv.config.panorama;\n const verticesPosition = this.prop.geom.getAttribute(ATTR_POSITION);\n const tilesToLoad = [];\n\n for (let face = 0; face < 6; face++) {\n for (let col = 0; col < panorama.nbTiles; col++) {\n for (let row = 0; row < panorama.nbTiles; row++) {\n // for each tile, find the vertices corresponding to the four corners\n // if at least one vertex is visible, the tile must be loaded\n // for larger tiles we also test the four edges centers and the tile center\n const verticesIndex = [];\n\n // top-left\n const v0 = face * NB_VERTICES_BY_PLANE\n + row * this.prop.facesByTile * CUBE_SEGMENTS * NB_VERTICES_BY_FACE\n + col * this.prop.facesByTile * NB_VERTICES_BY_FACE;\n\n // bottom-left\n const v1 = v0 + CUBE_SEGMENTS * NB_VERTICES_BY_FACE * (this.prop.facesByTile - 1) + 1;\n\n // bottom-right\n const v2 = v1 + this.prop.facesByTile * NB_VERTICES_BY_FACE - 3;\n\n // top-right\n const v3 = v0 + this.prop.facesByTile * NB_VERTICES_BY_FACE - 1;\n\n verticesIndex.push(v0, v1, v2, v3);\n\n if (this.prop.facesByTile >= CUBE_SEGMENTS / 2) {\n // top-center\n const v4 = v0 + this.prop.facesByTile / 2 * NB_VERTICES_BY_FACE - 1;\n\n // bottom-center\n const v5 = v1 + this.prop.facesByTile / 2 * NB_VERTICES_BY_FACE - 3;\n\n // left-center\n const v6 = v0 + CUBE_SEGMENTS * NB_VERTICES_BY_FACE * (this.prop.facesByTile / 2 - 1) + 1;\n\n // right-center\n const v7 = v6 + this.prop.facesByTile * NB_VERTICES_BY_FACE - 3;\n\n // center-center\n const v8 = v6 + this.prop.facesByTile / 2 * NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4, v5, v6, v7, v8);\n }\n\n // if (init && face === 5 && col === 0 && row === 0) {\n // verticesIndex.forEach((vertexIdx) => {\n // this.psv.renderer.scene.add(createDot(\n // verticesPosition.getX(vertexIdx),\n // verticesPosition.getY(vertexIdx),\n // verticesPosition.getZ(vertexIdx)\n // ));\n // });\n // }\n\n const vertexVisible = verticesIndex.some((vertexIdx) => {\n vertexPosition.set(\n verticesPosition.getX(vertexIdx),\n verticesPosition.getY(vertexIdx),\n verticesPosition.getZ(vertexIdx)\n );\n vertexPosition.applyEuler(this.psv.renderer.meshContainer.rotation);\n return frustum.containsPoint(vertexPosition);\n });\n\n if (vertexVisible) {\n const angle = vertexPosition.angleTo(this.psv.prop.direction);\n tilesToLoad.push({ face, col, row, angle });\n }\n }\n }\n }\n\n this.__loadTiles(tilesToLoad);\n }\n\n /**\n * @summary Loads tiles and change existing tiles priority\n * @param {PSV.adapters.CubemapTilesAdapter.Tile[]} tiles\n * @private\n */\n __loadTiles(tiles) {\n this.queue.disableAllTasks();\n\n tiles.forEach((tile) => {\n const id = tileId(tile);\n\n if (this.prop.tiles[id]) {\n this.queue.setPriority(id, tile.angle);\n }\n else {\n this.prop.tiles[id] = true;\n this.queue.enqueue(new Task(id, tile.angle, task => this.__loadTile(tile, task)));\n }\n });\n\n this.queue.start();\n }\n\n /**\n * @summary Loads and draw a tile\n * @param {PSV.adapters.CubemapTilesAdapter.Tile} tile\n * @param {PSV.adapters.Task} task\n * @return {Promise}\n * @private\n */\n __loadTile(tile, task) {\n const panorama = this.psv.config.panorama;\n\n let { col, row } = tile;\n if (this.config.flipTopBottom && (tile.face === 2 || tile.face === 3)) {\n col = panorama.nbTiles - col - 1;\n row = panorama.nbTiles - row - 1;\n }\n const url = panorama.tileUrl(CUBE_HASHMAP[tile.face], col, row);\n\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders(url));\n }\n\n return new Promise((resolve, reject) => {\n this.loader.load(url, resolve, undefined, reject);\n })\n .then((image) => {\n if (!task.isCancelled()) {\n const material = new THREE.MeshBasicMaterial({ map: utils.createTexture(image) });\n this.__swapMaterial(tile.face, tile.col, tile.row, material);\n this.psv.needsUpdate();\n }\n })\n .catch(() => {\n if (!task.isCancelled() && this.config.showErrorTile) {\n if (!this.prop.errorMaterial) {\n this.prop.errorMaterial = buildErrorMaterial(this.prop.tileSize, this.prop.tileSize);\n }\n this.__swapMaterial(tile.face, tile.col, tile.row, this.prop.errorMaterial);\n this.psv.needsUpdate();\n }\n });\n }\n\n /**\n * @summary Applies a new texture to the faces\n * @param {int} face\n * @param {int} col\n * @param {int} row\n * @param {external:THREE.MeshBasicMaterial} material\n * @private\n */\n __swapMaterial(face, col, row, material) {\n const uvs = this.prop.geom.getAttribute(ATTR_UV);\n\n for (let c = 0; c < this.prop.facesByTile; c++) {\n for (let r = 0; r < this.prop.facesByTile; r++) {\n // position of the face (two triangles of the same square)\n const faceCol = col * this.prop.facesByTile + c;\n const faceRow = row * this.prop.facesByTile + r;\n\n // first vertex for this face (6 vertices in total)\n const firstVertex = NB_VERTICES_BY_PLANE * face + 6 * (CUBE_SEGMENTS * faceRow + faceCol);\n\n // swap material\n const matIndex = this.prop.geom.groups.find(g => g.start === firstVertex).materialIndex;\n this.prop.materials[matIndex] = material;\n\n // define new uvs\n let top = 1 - r / this.prop.facesByTile;\n let bottom = 1 - (r + 1) / this.prop.facesByTile;\n let left = c / this.prop.facesByTile;\n let right = (c + 1) / this.prop.facesByTile;\n\n if (this.config.flipTopBottom && (face === 2 || face === 3)) {\n top = 1 - top;\n bottom = 1 - bottom;\n left = 1 - left;\n right = 1 - right;\n }\n\n uvs.setXY(firstVertex, left, top);\n uvs.setXY(firstVertex + 1, left, bottom);\n uvs.setXY(firstVertex + 2, right, top);\n uvs.setXY(firstVertex + 3, left, bottom);\n uvs.setXY(firstVertex + 4, right, bottom);\n uvs.setXY(firstVertex + 5, right, top);\n }\n }\n\n uvs.needsUpdate = true;\n }\n\n /**\n * @summary Create the texture for the base image\n * @param {HTMLImageElement} img\n * @return {external:THREE.Texture}\n * @override\n * @private\n */\n __createCubemapTexture(img) {\n if (img.width !== img.height) {\n utils.logWarn('Invalid base image, the width should equals the height');\n }\n\n return createBaseTexture(img, this.config.baseBlur, w => w);\n }\n\n}\n"],"names":["Task","id","priority","fn","status","STATUS","PENDING","start","RUNNING","then","DONE","ERROR","cancel","CANCELLED","isCancelled","DISABLED","Queue","concurency","runningTasks","tasks","enqueue","task","clear","Object","values","forEach","setPriority","taskId","disableAllTasks","keys","length","nextTask","filter","sort","a","b","pop","buildErrorMaterial","width","height","canvas","document","createElement","ctx","getContext","fillStyle","fillRect","font","textAlign","textBaseline","fillText","texture","THREE","CanvasTexture","MeshBasicMaterial","map","createBaseTexture","img","blur","getHeight","SYSTEM","maxTextureWidth","ratio","Math","min","getMaxCanvasWidth","buffer","drawImage","utils","createTexture","CubemapAdapter","PSVError","CUBE_SEGMENTS","NB_VERTICES_BY_FACE","NB_VERTICES_BY_PLANE","NB_VERTICES","NB_GROUPS_BY_FACE","ATTR_UV","ATTR_ORIGINAL_UV","ATTR_POSITION","tileId","tile","face","col","row","frustum","Frustum","projScreenMatrix","Matrix4","vertexPosition","Vector3","CubemapTilesAdapter","psv","options","config","flipTopBottom","showErrorTile","baseBlur","queue","prop","tileSize","facesByTile","tiles","geom","materials","errorMaterial","loader","ImageLoader","withCredentials","setWithCredentials","requestHeaders","setRequestHeader","on","CONSTANTS","EVENTS","POSITION_UPDATED","ZOOM_UPDATED","destroy","off","__cleanup","dispose","handleEvent","e","type","__refresh","mat","supportsTransition","panorama","baseUrl","supportsPreload","loadTexture","faceSize","nbTiles","tileUrl","Promise","reject","isPowerOfTwo","textureData","resolve","createMesh","scale","cubeSize","SPHERE_RADIUS","geometry","BoxGeometry","toNonIndexed","clearGroups","i","k","addGroup","setAttribute","getAttribute","clone","Mesh","setTexture","mesh","transition","__setTexture","material","setTimeout","center","Vector2","rotation","PI","opacity","transparent","j","push","setTextureOpacity","init","camera","renderer","updateMatrixWorld","multiplyMatrices","projectionMatrix","matrixWorldInverse","setFromProjectionMatrix","verticesPosition","tilesToLoad","verticesIndex","v0","v1","v2","v3","v4","v5","v6","v7","v8","vertexVisible","some","vertexIdx","set","getX","getY","getZ","applyEuler","meshContainer","containsPoint","angle","angleTo","direction","__loadTiles","__loadTile","url","CUBE_HASHMAP","load","undefined","image","__swapMaterial","needsUpdate","catch","uvs","c","r","faceCol","faceRow","firstVertex","matIndex","groups","find","g","materialIndex","top","bottom","left","right","setXY","__createCubemapTexture","logWarn","w","supportsDownload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;MACaA,IAAb;EAWE;EAC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CAAUV,WAAW,GAAG,CAAxB,EAA2BQ,IAA3B,EAAiCD,MAAjC;EACAZ,QAAAA,GAAG,CAACe,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BS,KAA3B,EAAkCH,GAAlC;EACAX,QAAAA,GAAG,CAACe,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BQ,IAA3B,EAAiCD,MAAjC;EACAZ,QAAAA,GAAG,CAACe,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BS,KAA3B,EAAkCF,MAAlC;EACAZ,QAAAA,GAAG,CAACe,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BS,KAA3B,EAAkCH,GAAlC;EA/B4C;;EAC9C,WAAK,IAAIT,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,KAAKnH,IAAL,CAAUE,WAA9B,EAA2CiH,CAAC,EAA5C,EAAgD;EAAA,cAAvCA,CAAuC;EA+B/C;EACF;;EAEDF,IAAAA,GAAG,CAACF,WAAJ,GAAkB,IAAlB;EACD;EAED;EACF;EACA;EACA;EACA;EACA;EACA;EA/bA;;EAAA,SAgcEkB,sBAhcF,GAgcE,gCAAuB3K,GAAvB,EAA4B;EAC1B,QAAIA,GAAG,CAACnB,KAAJ,KAAcmB,GAAG,CAAClB,MAAtB,EAA8B;EAC5B6B,MAAAA,uBAAK,CAACiK,OAAN,CAAc,wDAAd;EACD;;EAED,WAAO7K,iBAAiB,CAACC,GAAD,EAAM,KAAKqC,MAAL,CAAYG,QAAlB,EAA4B,UAAAqI,CAAC;EAAA,aAAIA,CAAJ;EAAA,KAA7B,CAAxB;EACD,GAtcH;;EAAA;EAAA,EAAyChK,sBAAzC;EAAaqB,oBAEJ1F,KAAK;EAFD0F,oBAGJ4I,mBAAmB;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"cubemap-tiles.js","sources":["../../src/adapters/shared/Task.js","../../src/adapters/shared/Queue.js","../../src/adapters/shared/tiles-utils.js","../../src/adapters/cubemap-tiles/index.js"],"sourcesContent":["/**\n * @summary Loading task\n * @memberOf PSV.adapters\n * @private\n */\nexport class Task {\n\n static STATUS = {\n DISABLED : -1,\n PENDING : 0,\n RUNNING : 1,\n CANCELLED: 2,\n DONE : 3,\n ERROR : 4,\n };\n\n /**\n * @param {string} id\n * @param {number} priority\n * @param {function(Task): Promise} fn\n */\n constructor(id, priority, fn) {\n this.id = id;\n this.priority = priority;\n this.fn = fn;\n this.status = Task.STATUS.PENDING;\n }\n\n start() {\n this.status = Task.STATUS.RUNNING;\n return this.fn(this)\n .then(() => {\n this.status = Task.STATUS.DONE;\n }, () => {\n this.status = Task.STATUS.ERROR;\n });\n }\n\n cancel() {\n this.status = Task.STATUS.CANCELLED;\n }\n\n isCancelled() {\n return this.status === Task.STATUS.CANCELLED;\n }\n\n}\n","import { Task } from './Task';\n\n/**\n * @summary Loading queue\n * @memberOf PSV.adapters\n * @private\n */\nexport class Queue {\n\n /**\n * @param {int} concurency\n */\n constructor(concurency = 4) {\n this.concurency = concurency;\n this.runningTasks = {};\n this.tasks = {};\n }\n\n enqueue(task) {\n this.tasks[task.id] = task;\n }\n\n clear() {\n Object.values(this.tasks).forEach(task => task.cancel());\n this.tasks = {};\n this.runningTasks = {};\n }\n\n setPriority(taskId, priority) {\n const task = this.tasks[taskId];\n if (task) {\n task.priority = priority;\n if (task.status === Task.STATUS.DISABLED) {\n task.status = Task.STATUS.PENDING;\n }\n }\n }\n\n disableAllTasks() {\n Object.values(this.tasks).forEach((task) => {\n task.status = Task.STATUS.DISABLED;\n });\n }\n\n start() {\n if (Object.keys(this.runningTasks).length >= this.concurency) {\n return;\n }\n\n const nextTask = Object.values(this.tasks)\n .filter(task => task.status === Task.STATUS.PENDING)\n .sort((a, b) => b.priority - a.priority)\n .pop();\n\n if (nextTask) {\n this.runningTasks[nextTask.id] = true;\n\n nextTask.start()\n .then(() => {\n if (!nextTask.isCancelled()) {\n delete this.tasks[nextTask.id];\n delete this.runningTasks[nextTask.id];\n this.start();\n }\n });\n\n this.start(); // start tasks until max concurrency is reached\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { SYSTEM, utils } from '../..';\n\n/**\n * @summary Generates an material for errored tiles\n * @memberOf PSV.adapters\n * @return {external:THREE.MeshBasicMaterial}\n * @private\n */\nexport function buildErrorMaterial(width, height) {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n\n const ctx = canvas.getContext('2d');\n\n ctx.fillStyle = '#333';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n ctx.font = `${canvas.width / 5}px serif`;\n ctx.fillStyle = '#a22';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText('⚠', canvas.width / 2, canvas.height / 2);\n\n const texture = new THREE.CanvasTexture(canvas);\n return new THREE.MeshBasicMaterial({ map: texture });\n}\n\n/**\n * @summary Create the texture for the base image\n * @memberOf PSV.adapters\n * @param {HTMLImageElement} img\n * @param {boolean} blur\n * @param {function} getHeight\n * @return {external:THREE.Texture}\n * @private\n */\nexport function createBaseTexture(img, blur, getHeight) {\n if (blur || img.width > SYSTEM.maxTextureWidth) {\n const ratio = Math.min(1, SYSTEM.getMaxCanvasWidth() / img.width);\n\n const buffer = document.createElement('canvas');\n buffer.width = img.width * ratio;\n buffer.height = getHeight(img.width);\n\n const ctx = buffer.getContext('2d');\n if (blur) {\n ctx.filter = 'blur(1px)';\n }\n ctx.drawImage(img, 0, 0, buffer.width, buffer.height);\n\n return utils.createTexture(buffer);\n }\n\n return utils.createTexture(img);\n}\n\n/**\n * @summary Creates a wireframe geometry, for debug\n * @memberOf PSV.adapters\n * @param {THREE.BufferGeometry} geometry\n * @return {THREE.Object3D}\n * @private\n */\nexport function createWireFrame(geometry) {\n const wireframe = new THREE.WireframeGeometry(geometry);\n const line = new THREE.LineSegments(wireframe);\n line.material.depthTest = false;\n line.material.opacity = 0.25;\n line.material.transparent = true;\n return line;\n}\n\n/**\n * @summary Creates a small red sphere, for debug\n * @memberOf PSV.adapters\n * @return {THREE.Object3D}\n * @private\n */\nexport function createDot(x, y, z) {\n const geom = new THREE.SphereGeometry(0.1);\n const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });\n const mesh = new THREE.Mesh(geom, material);\n mesh.position.set(x, y, z);\n return mesh;\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, PSVError, utils } from '../..';\nimport { CUBE_HASHMAP, CubemapAdapter } from '../cubemap';\nimport { Queue } from '../shared/Queue';\nimport { Task } from '../shared/Task';\nimport { buildErrorMaterial, createBaseTexture } from '../shared/tiles-utils';\n\nif (!CubemapAdapter) {\n throw new PSVError('CubemapAdapter is missing, please load cubemap.js before cubemap-tiles.js');\n}\n\n\n/**\n * @callback TileUrl\n * @summary Function called to build a tile url\n * @memberOf PSV.adapters.CubemapTilesAdapter\n * @param {'left'|'front'|'right'|'back'|'top'|'bottom'} face\n * @param {int} col\n * @param {int} row\n * @returns {string}\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapTilesAdapter.Panorama\n * @summary Configuration of a tiled cubemap\n * @property {PSV.adapters.CubemapAdapter.Cubemap} [baseUrl] - low resolution panorama loaded before tiles\n * @property {int} faceSize - size of a face\n * @property {int} nbTiles - number of tiles on a side of a face\n * @property {PSV.adapters.CubemapTilesAdapter.TileUrl} tileUrl - function to build a tile url\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapTilesAdapter.Options\n * @property {boolean} [flipTopBottom=false] - set to true if the top and bottom faces are not correctly oriented\n * @property {boolean} [showErrorTile=true] - shows a warning sign on tiles that cannot be loaded\n * @property {boolean} [baseBlur=true] - applies a blur to the low resolution panorama\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapTilesAdapter.Tile\n * @private\n * @property {int} face\n * @property {int} col\n * @property {int} row\n * @property {float} angle\n */\n\n\nconst CUBE_SEGMENTS = 16;\nconst NB_VERTICES_BY_FACE = 6;\nconst NB_VERTICES_BY_PLANE = NB_VERTICES_BY_FACE * CUBE_SEGMENTS * CUBE_SEGMENTS;\nconst NB_VERTICES = 6 * NB_VERTICES_BY_PLANE;\nconst NB_GROUPS_BY_FACE = CUBE_SEGMENTS * CUBE_SEGMENTS;\n\nconst ATTR_UV = 'uv';\nconst ATTR_ORIGINAL_UV = 'originaluv';\nconst ATTR_POSITION = 'position';\n\nfunction tileId(tile) {\n return `${tile.face}:${tile.col}x${tile.row}`;\n}\n\nconst frustum = new THREE.Frustum();\nconst projScreenMatrix = new THREE.Matrix4();\nconst vertexPosition = new THREE.Vector3();\n\n/**\n * @summary Adapter for tiled cubemaps\n * @memberof PSV.adapters\n * @extends PSV.adapters.AbstractAdapter\n */\nexport class CubemapTilesAdapter extends CubemapAdapter {\n\n static id = 'cubemap-tiles';\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.CubemapTilesAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.CubemapTilesAdapter.Options}\n * @private\n */\n this.config = {\n flipTopBottom: false,\n showErrorTile: true,\n baseBlur : true,\n ...options,\n };\n\n /**\n * @member {PSV.adapters.Queue}\n * @private\n */\n this.queue = new Queue();\n\n /**\n * @type {Object}\n * @property {int} tileSize - size in pixels of a tile\n * @property {int} facesByTile - number of mesh faces by tile\n * @property {Record} tiles - loaded tiles\n * @property {external:THREE.BoxGeometry} geom\n * @property {external:THREE.MeshBasicMaterial[]} materials\n * @property {external:THREE.MeshBasicMaterial} errorMaterial\n * @private\n */\n this.prop = {\n tileSize : 0,\n facesByTile : 0,\n tiles : {},\n geom : null,\n materials : [],\n errorMaterial: null,\n };\n\n /**\n * @member {external:THREE.ImageLoader}\n * @private\n */\n this.loader = new THREE.ImageLoader();\n if (this.psv.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders);\n }\n\n this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n\n this.__cleanup();\n\n this.prop.errorMaterial?.map?.dispose();\n this.prop.errorMaterial?.dispose();\n\n delete this.queue;\n delete this.loader;\n delete this.prop.geom;\n delete this.prop.errorMaterial;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.POSITION_UPDATED:\n case CONSTANTS.EVENTS.ZOOM_UPDATED:\n this.__refresh();\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Clears loading queue, dispose all materials\n * @private\n */\n __cleanup() {\n this.queue.clear();\n this.prop.tiles = {};\n\n this.prop.materials.forEach((mat) => {\n mat?.map?.dispose();\n mat?.dispose();\n });\n this.prop.materials.length = 0;\n }\n\n /**\n * @override\n */\n supportsTransition(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n */\n supportsPreload(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n * @param {PSV.adapters.CubemapTilesAdapter.Panorama} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n if (typeof panorama !== 'object' || !panorama.faceSize || !panorama.nbTiles || !panorama.tileUrl) {\n return Promise.reject(new PSVError('Invalid panorama configuration, are you using the right adapter?'));\n }\n if (panorama.nbTiles > CUBE_SEGMENTS) {\n return Promise.reject(new PSVError(`Panorama nbTiles must not be greater than ${CUBE_SEGMENTS}.`));\n }\n if (!utils.isPowerOfTwo(panorama.nbTiles)) {\n return Promise.reject(new PSVError('Panorama nbTiles must be power of 2.'));\n }\n\n if (panorama.baseUrl) {\n return super.loadTexture(panorama.baseUrl)\n .then(textureData => ({\n panorama: panorama,\n texture : textureData.texture,\n }));\n }\n else {\n return Promise.resolve({ panorama });\n }\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const cubeSize = CONSTANTS.SPHERE_RADIUS * 2 * scale;\n const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize, CUBE_SEGMENTS, CUBE_SEGMENTS, CUBE_SEGMENTS)\n .scale(1, 1, -1)\n .toNonIndexed();\n\n geometry.clearGroups();\n for (let i = 0, k = 0; i < NB_VERTICES; i += NB_VERTICES_BY_FACE) {\n geometry.addGroup(i, NB_VERTICES_BY_FACE, k++);\n }\n\n geometry.setAttribute(ATTR_ORIGINAL_UV, geometry.getAttribute(ATTR_UV).clone());\n\n return new THREE.Mesh(geometry, []);\n }\n\n /**\n * @summary Applies the base texture and starts the loading of tiles\n * @override\n */\n setTexture(mesh, textureData, transition) {\n const { panorama, texture } = textureData;\n\n if (transition) {\n this.__setTexture(mesh, texture);\n return;\n }\n\n this.__cleanup();\n this.__setTexture(mesh, texture);\n\n this.prop.materials = mesh.material;\n this.prop.geom = mesh.geometry;\n this.prop.geom.setAttribute(ATTR_UV, this.prop.geom.getAttribute(ATTR_ORIGINAL_UV).clone());\n\n this.prop.tileSize = panorama.faceSize / panorama.nbTiles;\n this.prop.facesByTile = CUBE_SEGMENTS / panorama.nbTiles;\n\n // this.psv.renderer.scene.add(createWireFrame(this.prop.geom));\n\n setTimeout(() => this.__refresh(true));\n }\n\n /**\n * @private\n */\n __setTexture(mesh, texture) {\n for (let i = 0; i < 6; i++) {\n let material;\n if (texture) {\n if (this.config.flipTopBottom && (i === 2 || i === 3)) {\n texture[i].center = new THREE.Vector2(0.5, 0.5);\n texture[i].rotation = Math.PI;\n }\n\n material = new THREE.MeshBasicMaterial({ map: texture[i] });\n }\n else {\n material = new THREE.MeshBasicMaterial({ opacity: 0, transparent: true });\n }\n\n for (let j = 0; j < NB_GROUPS_BY_FACE; j++) {\n mesh.material.push(material);\n }\n }\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n for (let i = 0; i < 6; i++) {\n mesh.material[i * NB_GROUPS_BY_FACE].opacity = opacity;\n mesh.material[i * NB_GROUPS_BY_FACE].transparent = opacity < 1;\n }\n }\n\n /**\n * @summary Compute visible tiles and load them\n * @private\n */\n __refresh(init = false) { // eslint-disable-line no-unused-vars\n if (!this.prop.geom) {\n return;\n }\n\n const camera = this.psv.renderer.camera;\n camera.updateMatrixWorld();\n projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n frustum.setFromProjectionMatrix(projScreenMatrix);\n\n const panorama = this.psv.config.panorama;\n const verticesPosition = this.prop.geom.getAttribute(ATTR_POSITION);\n const tilesToLoad = [];\n\n for (let face = 0; face < 6; face++) {\n for (let col = 0; col < panorama.nbTiles; col++) {\n for (let row = 0; row < panorama.nbTiles; row++) {\n // for each tile, find the vertices corresponding to the four corners\n // if at least one vertex is visible, the tile must be loaded\n // for larger tiles we also test the four edges centers and the tile center\n const verticesIndex = [];\n\n // top-left\n const v0 = face * NB_VERTICES_BY_PLANE\n + row * this.prop.facesByTile * CUBE_SEGMENTS * NB_VERTICES_BY_FACE\n + col * this.prop.facesByTile * NB_VERTICES_BY_FACE;\n\n // bottom-left\n const v1 = v0 + CUBE_SEGMENTS * NB_VERTICES_BY_FACE * (this.prop.facesByTile - 1) + 1;\n\n // bottom-right\n const v2 = v1 + this.prop.facesByTile * NB_VERTICES_BY_FACE - 3;\n\n // top-right\n const v3 = v0 + this.prop.facesByTile * NB_VERTICES_BY_FACE - 1;\n\n verticesIndex.push(v0, v1, v2, v3);\n\n if (this.prop.facesByTile >= CUBE_SEGMENTS / 2) {\n // top-center\n const v4 = v0 + this.prop.facesByTile / 2 * NB_VERTICES_BY_FACE - 1;\n\n // bottom-center\n const v5 = v1 + this.prop.facesByTile / 2 * NB_VERTICES_BY_FACE - 3;\n\n // left-center\n const v6 = v0 + CUBE_SEGMENTS * NB_VERTICES_BY_FACE * (this.prop.facesByTile / 2 - 1) + 1;\n\n // right-center\n const v7 = v6 + this.prop.facesByTile * NB_VERTICES_BY_FACE - 3;\n\n // center-center\n const v8 = v6 + this.prop.facesByTile / 2 * NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4, v5, v6, v7, v8);\n }\n\n // if (init && face === 5 && col === 0 && row === 0) {\n // verticesIndex.forEach((vertexIdx) => {\n // this.psv.renderer.scene.add(createDot(\n // verticesPosition.getX(vertexIdx),\n // verticesPosition.getY(vertexIdx),\n // verticesPosition.getZ(vertexIdx)\n // ));\n // });\n // }\n\n const vertexVisible = verticesIndex.some((vertexIdx) => {\n vertexPosition.set(\n verticesPosition.getX(vertexIdx),\n verticesPosition.getY(vertexIdx),\n verticesPosition.getZ(vertexIdx)\n );\n vertexPosition.applyEuler(this.psv.renderer.meshContainer.rotation);\n return frustum.containsPoint(vertexPosition);\n });\n\n if (vertexVisible) {\n const angle = vertexPosition.angleTo(this.psv.prop.direction);\n tilesToLoad.push({ face, col, row, angle });\n }\n }\n }\n }\n\n this.__loadTiles(tilesToLoad);\n }\n\n /**\n * @summary Loads tiles and change existing tiles priority\n * @param {PSV.adapters.CubemapTilesAdapter.Tile[]} tiles\n * @private\n */\n __loadTiles(tiles) {\n this.queue.disableAllTasks();\n\n tiles.forEach((tile) => {\n const id = tileId(tile);\n\n if (this.prop.tiles[id]) {\n this.queue.setPriority(id, tile.angle);\n }\n else {\n this.prop.tiles[id] = true;\n this.queue.enqueue(new Task(id, tile.angle, task => this.__loadTile(tile, task)));\n }\n });\n\n this.queue.start();\n }\n\n /**\n * @summary Loads and draw a tile\n * @param {PSV.adapters.CubemapTilesAdapter.Tile} tile\n * @param {PSV.adapters.Task} task\n * @return {Promise}\n * @private\n */\n __loadTile(tile, task) {\n const panorama = this.psv.config.panorama;\n\n let { col, row } = tile;\n if (this.config.flipTopBottom && (tile.face === 2 || tile.face === 3)) {\n col = panorama.nbTiles - col - 1;\n row = panorama.nbTiles - row - 1;\n }\n const url = panorama.tileUrl(CUBE_HASHMAP[tile.face], col, row);\n\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders(url));\n }\n\n return new Promise((resolve, reject) => {\n this.loader.load(url, resolve, undefined, reject);\n })\n .then((image) => {\n if (!task.isCancelled()) {\n const material = new THREE.MeshBasicMaterial({ map: utils.createTexture(image) });\n this.__swapMaterial(tile.face, tile.col, tile.row, material);\n this.psv.needsUpdate();\n }\n })\n .catch(() => {\n if (!task.isCancelled() && this.config.showErrorTile) {\n if (!this.prop.errorMaterial) {\n this.prop.errorMaterial = buildErrorMaterial(this.prop.tileSize, this.prop.tileSize);\n }\n this.__swapMaterial(tile.face, tile.col, tile.row, this.prop.errorMaterial);\n this.psv.needsUpdate();\n }\n });\n }\n\n /**\n * @summary Applies a new texture to the faces\n * @param {int} face\n * @param {int} col\n * @param {int} row\n * @param {external:THREE.MeshBasicMaterial} material\n * @private\n */\n __swapMaterial(face, col, row, material) {\n const uvs = this.prop.geom.getAttribute(ATTR_UV);\n\n for (let c = 0; c < this.prop.facesByTile; c++) {\n for (let r = 0; r < this.prop.facesByTile; r++) {\n // position of the face (two triangles of the same square)\n const faceCol = col * this.prop.facesByTile + c;\n const faceRow = row * this.prop.facesByTile + r;\n\n // first vertex for this face (6 vertices in total)\n const firstVertex = NB_VERTICES_BY_PLANE * face + 6 * (CUBE_SEGMENTS * faceRow + faceCol);\n\n // swap material\n const matIndex = this.prop.geom.groups.find(g => g.start === firstVertex).materialIndex;\n this.prop.materials[matIndex] = material;\n\n // define new uvs\n let top = 1 - r / this.prop.facesByTile;\n let bottom = 1 - (r + 1) / this.prop.facesByTile;\n let left = c / this.prop.facesByTile;\n let right = (c + 1) / this.prop.facesByTile;\n\n if (this.config.flipTopBottom && (face === 2 || face === 3)) {\n top = 1 - top;\n bottom = 1 - bottom;\n left = 1 - left;\n right = 1 - right;\n }\n\n uvs.setXY(firstVertex, left, top);\n uvs.setXY(firstVertex + 1, left, bottom);\n uvs.setXY(firstVertex + 2, right, top);\n uvs.setXY(firstVertex + 3, left, bottom);\n uvs.setXY(firstVertex + 4, right, bottom);\n uvs.setXY(firstVertex + 5, right, top);\n }\n }\n\n uvs.needsUpdate = true;\n }\n\n /**\n * @summary Create the texture for the base image\n * @param {HTMLImageElement} img\n * @return {external:THREE.Texture}\n * @override\n * @private\n */\n __createCubemapTexture(img) {\n if (img.width !== img.height) {\n utils.logWarn('Invalid base image, the width should equals the height');\n }\n\n return createBaseTexture(img, this.config.baseBlur, w => w);\n }\n\n}\n"],"names":["Task","id","priority","fn","status","STATUS","PENDING","start","RUNNING","then","DONE","ERROR","cancel","CANCELLED","isCancelled","DISABLED","Queue","concurency","runningTasks","tasks","enqueue","task","clear","Object","values","forEach","setPriority","taskId","disableAllTasks","keys","length","nextTask","filter","sort","a","b","pop","buildErrorMaterial","width","height","canvas","document","createElement","ctx","getContext","fillStyle","fillRect","font","textAlign","textBaseline","fillText","texture","THREE","CanvasTexture","MeshBasicMaterial","map","createBaseTexture","img","blur","getHeight","SYSTEM","maxTextureWidth","ratio","Math","min","getMaxCanvasWidth","buffer","drawImage","utils","createTexture","CubemapAdapter","PSVError","CUBE_SEGMENTS","NB_VERTICES_BY_FACE","NB_VERTICES_BY_PLANE","NB_VERTICES","NB_GROUPS_BY_FACE","ATTR_UV","ATTR_ORIGINAL_UV","ATTR_POSITION","tileId","tile","face","col","row","frustum","Frustum","projScreenMatrix","Matrix4","vertexPosition","Vector3","CubemapTilesAdapter","psv","options","config","flipTopBottom","showErrorTile","baseBlur","queue","prop","tileSize","facesByTile","tiles","geom","materials","errorMaterial","loader","ImageLoader","withCredentials","setWithCredentials","requestHeaders","setRequestHeader","on","CONSTANTS","EVENTS","POSITION_UPDATED","ZOOM_UPDATED","destroy","off","__cleanup","dispose","handleEvent","e","type","__refresh","mat","supportsTransition","panorama","baseUrl","supportsPreload","loadTexture","faceSize","nbTiles","tileUrl","Promise","reject","isPowerOfTwo","textureData","resolve","createMesh","scale","cubeSize","SPHERE_RADIUS","geometry","BoxGeometry","toNonIndexed","clearGroups","i","k","addGroup","setAttribute","getAttribute","clone","Mesh","setTexture","mesh","transition","__setTexture","material","setTimeout","center","Vector2","rotation","PI","opacity","transparent","j","push","setTextureOpacity","init","camera","renderer","updateMatrixWorld","multiplyMatrices","projectionMatrix","matrixWorldInverse","setFromProjectionMatrix","verticesPosition","tilesToLoad","verticesIndex","v0","v1","v2","v3","v4","v5","v6","v7","v8","vertexVisible","some","vertexIdx","set","getX","getY","getZ","applyEuler","meshContainer","containsPoint","angle","angleTo","direction","__loadTiles","__loadTile","url","CUBE_HASHMAP","load","undefined","image","__swapMaterial","needsUpdate","catch","uvs","c","r","faceCol","faceRow","firstVertex","matIndex","groups","find","g","materialIndex","top","bottom","left","right","setXY","__createCubemapTexture","logWarn","w","supportsDownload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;MACaA,IAAb;EAWE;EACF;EACA;EACA;EACA;EACE,gBAAYC,EAAZ,EAAgBC,QAAhB,EAA0BC,EAA1B,EAA8B;EAC5B,SAAKF,EAAL,GAAUA,EAAV;EACA,SAAKC,QAAL,GAAgBA,QAAhB;EACA,SAAKC,EAAL,GAAUA,EAAV;EACA,SAAKC,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYC,OAA1B;EACD;;EArBH;;EAAA,SAuBEC,KAvBF,GAuBE,iBAAQ;EAAA;;EACN,SAAKH,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYG,OAA1B;EACA,WAAO,KAAKL,EAAL,CAAQ,IAAR,EACJM,IADI,CACC,YAAM;EACV,MAAA,KAAI,CAACL,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYK,IAA1B;EACD,KAHI,EAGF,YAAM;EACP,MAAA,KAAI,CAACN,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYM,KAA1B;EACD,KALI,CAAP;EAMD,GA/BH;;EAAA,SAiCEC,MAjCF,GAiCE,kBAAS;EACP,SAAKR,MAAL,GAA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;EACA;EACA;EACA;EACA;EA/bA;;EAAA,SAgcEkB,sBAhcF,GAgcE,gCAAuB3K,GAAvB,EAA4B;EAC1B,QAAIA,GAAG,CAACnB,KAAJ,KAAcmB,GAAG,CAAClB,MAAtB,EAA8B;EAC5B6B,MAAAA,uBAAK,CAACiK,OAAN,CAAc,wDAAd;EACD;;EAED,WAAO7K,iBAAiB,CAACC,GAAD,EAAM,KAAKqC,MAAL,CAAYG,QAAlB,EAA4B,UAAAqI,CAAC;EAAA,aAAIA,CAAJ;EAAA,KAA7B,CAAxB;EACD,GAtcH;;EAAA;EAAA,EAAyChK,sBAAzC;EAAaqB,oBAEJ1F,KAAK;EAFD0F,oBAGJ4I,mBAAmB;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/adapters/cubemap-video.d.ts b/dist/adapters/cubemap-video.d.ts new file mode 100644 index 000000000..4bfc3f618 --- /dev/null +++ b/dist/adapters/cubemap-video.d.ts @@ -0,0 +1,25 @@ +import { AbstractAdapter, Viewer } from 'photo-sphere-viewer'; + +/** + * @summary Configuration of a cubemap video + */ +type CubemapVideoPanorama = { + source: string; +}; + +type CubemapVideoAdapterOptions = { + autoplay?: boolean; + muted?: boolean; + equiangular?: boolean; +} + +/** + * @summary Adapter for cubemap videos + */ +declare class CubemapVideoAdapter extends AbstractAdapter { + + constructor(psv: Viewer, options: CubemapVideoAdapterOptions); + +} + +export { CubemapVideoAdapter, CubemapVideoAdapterOptions, CubemapVideoPanorama }; diff --git a/dist/adapters/cubemap-video.js b/dist/adapters/cubemap-video.js new file mode 100644 index 000000000..a8a31a51b --- /dev/null +++ b/dist/adapters/cubemap-video.js @@ -0,0 +1,476 @@ +/*! +* Photo Sphere Viewer 4.6.0 +* @copyright 2014-2015 Jérémy Heleine +* @copyright 2015-2022 Damien "Mistic" Sorel +* @licence MIT (https://opensource.org/licenses/MIT) +*/ +(function (global, factory) { + 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.CubemapVideoAdapter = {}), global.THREE, global.PhotoSphereViewer)); +})(this, (function (exports, THREE, photoSphereViewer) { 'use strict'; + + 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) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + + _setPrototypeOf(subClass, superClass); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + /** + * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Video + * @summary Object defining a video + * @property {string} source + */ + + /** + * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Options + * @property {boolean} [autoplay=false] - automatically start the video + * @property {boolean} [muted=autoplay] - initially mute the video + */ + + /** + * @summary Base video adapters class + * @memberof PSV.adapters + * @abstract + * @private + */ + + var AbstractVideoAdapter = /*#__PURE__*/function (_AbstractAdapter) { + _inheritsLoose(AbstractVideoAdapter, _AbstractAdapter); + + function AbstractVideoAdapter(psv, options) { + var _options$autoplay; + + var _this; + + _this = _AbstractAdapter.call(this, psv) || this; + /** + * @member {PSV.adapters.AbstractVideoAdapter.Options} + * @private + */ + + _this.config = _extends({ + autoplay: false, + muted: (_options$autoplay = options == null ? void 0 : options.autoplay) != null ? _options$autoplay : false + }, options); + /** + * @member {HTMLVideoElement} + * @private + */ + + _this.video = null; + + _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, _assertThisInitialized(_this)); + + return _this; + } + /** + * @override + */ + + + var _proto = AbstractVideoAdapter.prototype; + + _proto.destroy = function destroy() { + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this); + + this.__removeVideo(); + + _AbstractAdapter.prototype.destroy.call(this); + } + /** + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER: + if (this.video) { + this.psv.needsUpdate(); + } + + break; + } + /* eslint-enable */ + + } + /** + * @override + * @param {PSV.adapters.AbstractVideoAdapter.Video} panorama + * @returns {Promise.} + */ + ; + + _proto.loadTexture = function loadTexture(panorama) { + if (typeof panorama !== 'object' || !panorama.source) { + return Promise.reject(new photoSphereViewer.PSVError('Invalid panorama configuration, are you using the right adapter?')); + } + + if (!this.psv.getPlugin('video')) { + return Promise.reject(new photoSphereViewer.PSVError('Video adapters require VideoPlugin to be loaded too.')); + } + + var video = this.__createVideo(panorama.source); + + return this.__videoLoadPromise(video).then(function () { + var texture = new THREE.VideoTexture(video); + return { + panorama: panorama, + texture: texture + }; + }); + } + /** + * @override + */ + ; + + _proto.__switchVideo = function __switchVideo(texture) { + var currentTime; + var duration; + var paused = !this.config.autoplay; + var muted = this.config.muted; + var volume = 1; + + if (this.video) { + var _this$video = this.video; + currentTime = _this$video.currentTime; + duration = _this$video.duration; + paused = _this$video.paused; + muted = _this$video.muted; + volume = _this$video.volume; + } + + this.__removeVideo(); + + this.video = texture.image; // keep current time when switching resolution + + if (this.video.duration === duration) { + this.video.currentTime = currentTime; + } // keep volume + + + this.video.muted = muted; + this.video.volume = volume; // play + + if (!paused) { + this.video.play(); + } + } + /** + * @override + */ + ; + + _proto.disposeTexture = function disposeTexture(textureData) { + var _textureData$texture; + + if (textureData.texture) { + var video = textureData.texture.image; + video.pause(); + this.psv.container.removeChild(video); + } + + (_textureData$texture = textureData.texture) == null ? void 0 : _textureData$texture.dispose(); + } + /** + * @summary Removes the current video element + * @private + */ + ; + + _proto.__removeVideo = function __removeVideo() { + if (this.video) { + this.video.pause(); + this.psv.container.removeChild(this.video); + delete this.video; + } + } + /** + * @summary Creates a new video element + * @memberOf PSV.adapters + * @param {string} src + * @return {HTMLVideoElement} + * @private + */ + ; + + _proto.__createVideo = function __createVideo(src) { + var video = document.createElement('video'); + video.crossOrigin = this.psv.config.withCredentials ? 'use-credentials' : 'anonymous'; + video.loop = true; + video.style.display = 'none'; + video.muted = this.config.muted; + video.src = src; + video.preload = 'metadata'; + this.psv.container.appendChild(video); + return video; + } + /** + * @private + */ + ; + + _proto.__videoLoadPromise = function __videoLoadPromise(video) { + var self = this; + return new Promise(function (resolve, reject) { + video.addEventListener('loadedmetadata', function onLoaded() { + if (this.video && video.duration === this.video.duration) { + resolve(self.__videoBufferPromise(video, this.video.currentTime)); + } else { + resolve(); + } + + video.removeEventListener('loadedmetadata', onLoaded); + }); + video.addEventListener('error', function onError(err) { + reject(err); + video.removeEventListener('error', onError); + }); + }); + } + /** + * @private + */ + ; + + _proto.__videoBufferPromise = function __videoBufferPromise(video, currentTime) { + return new Promise(function (resolve) { + function onBuffer() { + var buffer = video.buffered; + + for (var i = 0, l = buffer.length; i < l; i++) { + if (buffer.start(i) <= video.currentTime && buffer.end(i) >= video.currentTime) { + video.pause(); + video.removeEventListener('buffer', onBuffer); + video.removeEventListener('progress', onBuffer); + resolve(); + break; + } + } + } // try to reduce the switching time by preloading in advance + // FIXME find a better way ? + + + video.currentTime = Math.min(currentTime + 2000, video.duration.currentTime); + video.muted = true; + video.addEventListener('buffer', onBuffer); + video.addEventListener('progress', onBuffer); + video.play(); + }); + }; + + return AbstractVideoAdapter; + }(photoSphereViewer.AbstractAdapter); + AbstractVideoAdapter.supportsTransition = false; + AbstractVideoAdapter.supportsPreload = false; + AbstractVideoAdapter.supportsDownload = true; + + /** + * @typedef {Object} PSV.adapters.CubemapVideoAdapter.Video + * @summary Object defining a video + * @property {string} source + */ + + /** + * @typedef {Object} PSV.adapters.CubemapVideoAdapter.Options + * @property {boolean} [autoplay=false] - automatically start the video + * @property {boolean} [muted=autoplay] - initially mute the video + * @property {number} [equiangular=true] - if the video is an equiangular cubemap (EAC) + */ + + /** + * @summary Adapter for cubemap videos + * @memberof PSV.adapters + * @extends PSV.adapters.AbstractAdapter + */ + + var CubemapVideoAdapter = /*#__PURE__*/function (_AbstractVideoAdapter) { + _inheritsLoose(CubemapVideoAdapter, _AbstractVideoAdapter); + + /** + * @param {PSV.Viewer} psv + * @param {PSV.adapters.CubemapVideoAdapter.Options} options + */ + function CubemapVideoAdapter(psv, options) { + return _AbstractVideoAdapter.call(this, psv, _extends({ + equiangular: true + }, options)) || this; + } + /** + * @override + * @param {PSV.adapters.CubemapVideoAdapter.Video} panorama + * @returns {Promise.} + */ + + + var _proto = CubemapVideoAdapter.prototype; + + _proto.loadTexture = function loadTexture(panorama) { + return _AbstractVideoAdapter.prototype.loadTexture.call(this, panorama); + } + /** + * @override + */ + ; + + _proto.createMesh = function createMesh(scale) { + if (scale === void 0) { + scale = 1; + } + + var cubeSize = photoSphereViewer.CONSTANTS.SPHERE_RADIUS * 2 * scale; + var geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize).scale(1, 1, -1).toNonIndexed(); + geometry.clearGroups(); + var uvs = geometry.getAttribute('uv'); + /* + Structure of a frame + 1 +---------+---------+---------+ + | | | | + | Left | Front | Right | + | | | | + 1/2 +---------+---------+---------+ + | | | | + | Bottom | Back | Top | + | | | | + 0 +---------+---------+---------+ + 0 1/3 2/3 1 + Bottom, Back and Top are rotated 90° clockwise + */ + // columns + + var a = 0; + var b = 1 / 3; + var c = 2 / 3; + var d = 1; // lines + + var A = 1; + var B = 1 / 2; + var C = 0; // left + + uvs.setXY(0, a, A); + uvs.setXY(1, a, B); + uvs.setXY(2, b, A); + uvs.setXY(3, a, B); + uvs.setXY(4, b, B); + uvs.setXY(5, b, A); // right + + uvs.setXY(6, c, A); + uvs.setXY(7, c, B); + uvs.setXY(8, d, A); + uvs.setXY(9, c, B); + uvs.setXY(10, d, B); + uvs.setXY(11, d, A); // top + + uvs.setXY(12, d, B); + uvs.setXY(13, c, B); + uvs.setXY(14, d, C); + uvs.setXY(15, c, B); + uvs.setXY(16, c, C); + uvs.setXY(17, d, C); // bottom + + uvs.setXY(18, b, B); + uvs.setXY(19, a, B); + uvs.setXY(20, b, C); + uvs.setXY(21, a, B); + uvs.setXY(22, a, C); + uvs.setXY(23, b, C); // back + + uvs.setXY(24, c, B); + uvs.setXY(25, b, B); + uvs.setXY(26, c, C); + uvs.setXY(27, b, B); + uvs.setXY(28, b, C); + uvs.setXY(29, c, C); // front + + uvs.setXY(30, b, A); + uvs.setXY(31, b, B); + uvs.setXY(32, c, A); + uvs.setXY(33, b, B); + uvs.setXY(34, c, B); + uvs.setXY(35, c, A); // shamelessly copied from https://github.com/videojs/videojs-vr + + var material = new THREE.ShaderMaterial({ + uniforms: { + mapped: { + value: null + }, + contCorrect: { + value: 1 + }, + faceWH: { + value: new THREE.Vector2(1 / 3, 1 / 2) + }, + vidWH: { + value: new THREE.Vector2(1, 1) + } + }, + vertexShader: "\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n}", + fragmentShader: "\nvarying vec2 vUv;\nuniform sampler2D mapped;\nuniform vec2 faceWH;\nuniform vec2 vidWH;\nuniform float contCorrect;\nconst float PI = 3.1415926535897932384626433832795;\nvoid main() {\n vec2 corner = vUv - mod(vUv, faceWH) + vec2(0, contCorrect / vidWH.y);\n vec2 faceWHadj = faceWH - vec2(0, contCorrect * 2. / vidWH.y);\n vec2 p = (vUv - corner) / faceWHadj - .5;\n vec2 q = " + (this.config.equiangular ? '2. / PI * atan(2. * p) + .5' : 'p + .5') + ";\n vec2 eUv = corner + q * faceWHadj;\n gl_FragColor = texture2D(mapped, eUv);\n}" + }); + return new THREE.Mesh(geometry, material); + } + /** + * @override + */ + ; + + _proto.setTexture = function setTexture(mesh, textureData) { + var _mesh$material$unifor; + + var texture = textureData.texture; + (_mesh$material$unifor = mesh.material.uniforms.mapped.value) == null ? void 0 : _mesh$material$unifor.dispose(); + mesh.material.uniforms.mapped.value = texture; + mesh.material.uniforms.vidWH.value.set(texture.image.videoWidth, texture.image.videoHeight); + + this.__switchVideo(textureData.texture); + }; + + return CubemapVideoAdapter; + }(AbstractVideoAdapter); + CubemapVideoAdapter.id = 'cubemap-video'; + + exports.CubemapVideoAdapter = CubemapVideoAdapter; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=cubemap-video.js.map diff --git a/dist/adapters/cubemap-video.js.map b/dist/adapters/cubemap-video.js.map new file mode 100644 index 000000000..34f603ee3 --- /dev/null +++ b/dist/adapters/cubemap-video.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cubemap-video.js","sources":["../../src/adapters/shared/AbstractVideoAdapter.js","../../src/adapters/cubemap-video/index.js"],"sourcesContent":["import * as THREE from 'three';\nimport { AbstractAdapter, CONSTANTS, PSVError } from '../..';\n\n/**\n * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Video\n * @summary Object defining a video\n * @property {string} source\n */\n\n/**\n * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Options\n * @property {boolean} [autoplay=false] - automatically start the video\n * @property {boolean} [muted=autoplay] - initially mute the video\n */\n\n/**\n * @summary Base video adapters class\n * @memberof PSV.adapters\n * @abstract\n * @private\n */\nexport class AbstractVideoAdapter extends AbstractAdapter {\n\n static supportsTransition = false;\n static supportsPreload = false;\n static supportsDownload = true;\n\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.AbstractVideoAdapter.Options}\n * @private\n */\n this.config = {\n autoplay: false,\n muted : options?.autoplay ?? false,\n ...options,\n };\n\n /**\n * @member {HTMLVideoElement}\n * @private\n */\n this.video = null;\n\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n\n this.__removeVideo();\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.BEFORE_RENDER:\n if (this.video) {\n this.psv.needsUpdate();\n }\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @param {PSV.adapters.AbstractVideoAdapter.Video} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n if (typeof panorama !== 'object' || !panorama.source) {\n return Promise.reject(new PSVError('Invalid panorama configuration, are you using the right adapter?'));\n }\n\n if (!this.psv.getPlugin('video')) {\n return Promise.reject(new PSVError('Video adapters require VideoPlugin to be loaded too.'));\n }\n\n const video = this.__createVideo(panorama.source);\n\n return this.__videoLoadPromise(video)\n .then(() => {\n const texture = new THREE.VideoTexture(video);\n return { panorama, texture };\n });\n }\n\n /**\n * @override\n */\n __switchVideo(texture) {\n let currentTime;\n let duration;\n let paused = !this.config.autoplay;\n let muted = this.config.muted;\n let volume = 1;\n if (this.video) {\n ({ currentTime, duration, paused, muted, volume } = this.video);\n }\n\n this.__removeVideo();\n this.video = texture.image;\n\n // keep current time when switching resolution\n if (this.video.duration === duration) {\n this.video.currentTime = currentTime;\n }\n\n // keep volume\n this.video.muted = muted;\n this.video.volume = volume;\n\n // play\n if (!paused) {\n this.video.play();\n }\n }\n\n /**\n * @override\n */\n disposeTexture(textureData) {\n if (textureData.texture) {\n const video = textureData.texture.image;\n video.pause();\n this.psv.container.removeChild(video);\n }\n textureData.texture?.dispose();\n }\n\n /**\n * @summary Removes the current video element\n * @private\n */\n __removeVideo() {\n if (this.video) {\n this.video.pause();\n this.psv.container.removeChild(this.video);\n delete this.video;\n }\n }\n\n /**\n * @summary Creates a new video element\n * @memberOf PSV.adapters\n * @param {string} src\n * @return {HTMLVideoElement}\n * @private\n */\n __createVideo(src) {\n const video = document.createElement('video');\n video.crossOrigin = this.psv.config.withCredentials ? 'use-credentials' : 'anonymous';\n video.loop = true;\n video.style.display = 'none';\n video.muted = this.config.muted;\n video.src = src;\n video.preload = 'metadata';\n\n this.psv.container.appendChild(video);\n\n return video;\n }\n\n /**\n * @private\n */\n __videoLoadPromise(video) {\n const self = this;\n\n return new Promise((resolve, reject) => {\n video.addEventListener('loadedmetadata', function onLoaded() {\n if (this.video && video.duration === this.video.duration) {\n resolve(self.__videoBufferPromise(video, this.video.currentTime));\n }\n else {\n resolve();\n }\n video.removeEventListener('loadedmetadata', onLoaded);\n });\n\n video.addEventListener('error', function onError(err) {\n reject(err);\n video.removeEventListener('error', onError);\n });\n });\n }\n\n /**\n * @private\n */\n __videoBufferPromise(video, currentTime) {\n return new Promise((resolve) => {\n function onBuffer() {\n const buffer = video.buffered;\n for (let i = 0, l = buffer.length; i < l; i++) {\n if (buffer.start(i) <= video.currentTime && buffer.end(i) >= video.currentTime) {\n video.pause();\n video.removeEventListener('buffer', onBuffer);\n video.removeEventListener('progress', onBuffer);\n resolve();\n break;\n }\n }\n }\n\n // try to reduce the switching time by preloading in advance\n // FIXME find a better way ?\n video.currentTime = Math.min(currentTime + 2000, video.duration.currentTime);\n video.muted = true;\n\n video.addEventListener('buffer', onBuffer);\n video.addEventListener('progress', onBuffer);\n\n video.play();\n });\n }\n\n}\n","import * as THREE from 'three';\nimport { CONSTANTS } from '../..';\nimport { AbstractVideoAdapter } from '../shared/AbstractVideoAdapter';\n\n/**\n * @typedef {Object} PSV.adapters.CubemapVideoAdapter.Video\n * @summary Object defining a video\n * @property {string} source\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapVideoAdapter.Options\n * @property {boolean} [autoplay=false] - automatically start the video\n * @property {boolean} [muted=autoplay] - initially mute the video\n * @property {number} [equiangular=true] - if the video is an equiangular cubemap (EAC)\n */\n\n\n/**\n * @summary Adapter for cubemap videos\n * @memberof PSV.adapters\n * @extends PSV.adapters.AbstractAdapter\n */\nexport class CubemapVideoAdapter extends AbstractVideoAdapter {\n\n static id = 'cubemap-video';\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.CubemapVideoAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv, {\n equiangular: true,\n ...options,\n });\n }\n\n /**\n * @override\n * @param {PSV.adapters.CubemapVideoAdapter.Video} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n return super.loadTexture(panorama);\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const cubeSize = CONSTANTS.SPHERE_RADIUS * 2 * scale;\n const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize)\n .scale(1, 1, -1)\n .toNonIndexed();\n\n geometry.clearGroups();\n\n const uvs = geometry.getAttribute('uv');\n\n /*\n Structure of a frame\n\n 1 +---------+---------+---------+\n | | | |\n | Left | Front | Right |\n | | | |\n 1/2 +---------+---------+---------+\n | | | |\n | Bottom | Back | Top |\n | | | |\n 0 +---------+---------+---------+\n 0 1/3 2/3 1\n\n Bottom, Back and Top are rotated 90° clockwise\n */\n\n // columns\n const a = 0;\n const b = 1 / 3;\n const c = 2 / 3;\n const d = 1;\n\n // lines\n const A = 1;\n const B = 1 / 2;\n const C = 0;\n\n // left\n uvs.setXY(0, a, A);\n uvs.setXY(1, a, B);\n uvs.setXY(2, b, A);\n uvs.setXY(3, a, B);\n uvs.setXY(4, b, B);\n uvs.setXY(5, b, A);\n\n // right\n uvs.setXY(6, c, A);\n uvs.setXY(7, c, B);\n uvs.setXY(8, d, A);\n uvs.setXY(9, c, B);\n uvs.setXY(10, d, B);\n uvs.setXY(11, d, A);\n\n // top\n uvs.setXY(12, d, B);\n uvs.setXY(13, c, B);\n uvs.setXY(14, d, C);\n uvs.setXY(15, c, B);\n uvs.setXY(16, c, C);\n uvs.setXY(17, d, C);\n\n // bottom\n uvs.setXY(18, b, B);\n uvs.setXY(19, a, B);\n uvs.setXY(20, b, C);\n uvs.setXY(21, a, B);\n uvs.setXY(22, a, C);\n uvs.setXY(23, b, C);\n\n // back\n uvs.setXY(24, c, B);\n uvs.setXY(25, b, B);\n uvs.setXY(26, c, C);\n uvs.setXY(27, b, B);\n uvs.setXY(28, b, C);\n uvs.setXY(29, c, C);\n\n // front\n uvs.setXY(30, b, A);\n uvs.setXY(31, b, B);\n uvs.setXY(32, c, A);\n uvs.setXY(33, b, B);\n uvs.setXY(34, c, B);\n uvs.setXY(35, c, A);\n\n // shamelessly copied from https://github.com/videojs/videojs-vr\n const material = new THREE.ShaderMaterial({\n uniforms : {\n mapped : { value: null },\n contCorrect: { value: 1 },\n faceWH : { value: new THREE.Vector2(1 / 3, 1 / 2) },\n vidWH : { value: new THREE.Vector2(1, 1) },\n },\n vertexShader : `\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n}`,\n fragmentShader: `\nvarying vec2 vUv;\nuniform sampler2D mapped;\nuniform vec2 faceWH;\nuniform vec2 vidWH;\nuniform float contCorrect;\nconst float PI = 3.1415926535897932384626433832795;\nvoid main() {\n vec2 corner = vUv - mod(vUv, faceWH) + vec2(0, contCorrect / vidWH.y);\n vec2 faceWHadj = faceWH - vec2(0, contCorrect * 2. / vidWH.y);\n vec2 p = (vUv - corner) / faceWHadj - .5;\n vec2 q = ${this.config.equiangular ? '2. / PI * atan(2. * p) + .5' : 'p + .5'};\n vec2 eUv = corner + q * faceWHadj;\n gl_FragColor = texture2D(mapped, eUv);\n}`,\n });\n\n return new THREE.Mesh(geometry, material);\n }\n\n /**\n * @override\n */\n setTexture(mesh, textureData) {\n const { texture } = textureData;\n\n mesh.material.uniforms.mapped.value?.dispose();\n mesh.material.uniforms.mapped.value = texture;\n mesh.material.uniforms.vidWH.value.set(texture.image.videoWidth, texture.image.videoHeight);\n\n this.__switchVideo(textureData.texture);\n }\n\n}\n"],"names":["AbstractVideoAdapter","psv","options","config","autoplay","muted","video","on","CONSTANTS","EVENTS","BEFORE_RENDER","destroy","off","__removeVideo","handleEvent","e","type","needsUpdate","loadTexture","panorama","source","Promise","reject","PSVError","getPlugin","__createVideo","__videoLoadPromise","then","texture","THREE","VideoTexture","__switchVideo","currentTime","duration","paused","volume","image","play","disposeTexture","textureData","pause","container","removeChild","dispose","src","document","createElement","crossOrigin","withCredentials","loop","style","display","preload","appendChild","self","resolve","addEventListener","onLoaded","__videoBufferPromise","removeEventListener","onError","err","onBuffer","buffer","buffered","i","l","length","start","end","Math","min","AbstractAdapter","supportsTransition","supportsPreload","supportsDownload","CubemapVideoAdapter","equiangular","createMesh","scale","cubeSize","SPHERE_RADIUS","geometry","BoxGeometry","toNonIndexed","clearGroups","uvs","getAttribute","a","b","c","d","A","B","C","setXY","material","ShaderMaterial","uniforms","mapped","value","contCorrect","faceWH","Vector2","vidWH","vertexShader","fragmentShader","Mesh","setTexture","mesh","set","videoWidth","videoHeight","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;MACaA,oBAAb;EAAA;;EAME,gCAAYC,GAAZ,EAAiBC,OAAjB,EAA0B;EAAA;;EAAA;;EACxB,wCAAMD,GAAN;EAEA;EACJ;EACA;EACA;;EACI,UAAKE,MAAL;EACEC,MAAAA,QAAQ,EAAE,KADZ;EAEEC,MAAAA,KAAK,uBAAKH,OAAL,oBAAKA,OAAO,CAAEE,QAAd,gCAA0B;EAFjC,OAGKF,OAHL;EAMA;EACJ;EACA;EACA;;EACI,UAAKI,KAAL,GAAa,IAAb;;EAEA,UAAKL,GAAL,CAASM,EAAT,CAAYC,2BAAS,CAACC,MAAV,CAAiBC,aAA7B;;EAnBwB;EAoBzB;EAED;EACF;EACA;;;EA9BA;;EAAA,SA+BEC,OA/BF,GA+BE,mBAAU;EACR,SAAKV,GAAL,CAASW,GAAT,CAAaJ,2BAAS,CAACC,MAAV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sJEY,UAtJF,GAsJE,oBAAWC,IAAX,EAAiBtE,WAAjB,EAA8B;EAAA;;EAC5B,QAAQX,OAAR,GAAoBW,WAApB,CAAQX,OAAR;EAEA,6BAAAiF,IAAI,CAACb,QAAL,CAAcE,QAAd,CAAuBC,MAAvB,CAA8BC,KAA9B,2CAAqCzD,OAArC;EACAkE,IAAAA,IAAI,CAACb,QAAL,CAAcE,QAAd,CAAuBC,MAAvB,CAA8BC,KAA9B,GAAsCxE,OAAtC;EACAiF,IAAAA,IAAI,CAACb,QAAL,CAAcE,QAAd,CAAuBM,KAAvB,CAA6BJ,KAA7B,CAAmCU,GAAnC,CAAuClF,OAAO,CAACQ,KAAR,CAAc2E,UAArD,EAAiEnF,OAAO,CAACQ,KAAR,CAAc4E,WAA/E;;EAEA,SAAKjF,aAAL,CAAmBQ,WAAW,CAACX,OAA/B;EACD,GA9JH;;EAAA;EAAA,EAAyC5B,oBAAzC;EAAa4E,oBAEJqC,KAAK;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/adapters/cubemap.js b/dist/adapters/cubemap.js index fe1b84c3a..0c4d5cded 100644 --- a/dist/adapters/cubemap.js +++ b/dist/adapters/cubemap.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -67,6 +67,7 @@ /** * @summary Adapter for cubemaps * @memberof PSV.adapters + * @extends PSV.adapters.AbstractAdapter */ var CubemapAdapter = /*#__PURE__*/function (_AbstractAdapter) { diff --git a/dist/adapters/cubemap.js.map b/dist/adapters/cubemap.js.map index 94b5e6169..5680a0624 100644 --- a/dist/adapters/cubemap.js.map +++ b/dist/adapters/cubemap.js.map @@ -1 +1 @@ -{"version":3,"file":"cubemap.js","sources":["../../src/adapters/cubemap/index.js"],"sourcesContent":["import * as THREE from 'three';\nimport { AbstractAdapter, CONSTANTS, PSVError, SYSTEM, utils } from '../..';\n\n\n/**\n * @typedef {Object} PSV.adapters.CubemapAdapter.Cubemap\n * @summary Object defining a cubemap\n * @property {string} left\n * @property {string} front\n * @property {string} right\n * @property {string} back\n * @property {string} top\n * @property {string} bottom\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapAdapter.Options\n * @property {boolean} [flipTopBottom=false] - set to true if the top and bottom faces are not correctly oriented\n */\n\n\n// PSV faces order is left, front, right, back, top, bottom\n// 3JS faces order is left, right, top, bottom, back, front\nexport const CUBE_ARRAY = [0, 2, 4, 5, 3, 1];\nexport const CUBE_HASHMAP = ['left', 'right', 'top', 'bottom', 'back', 'front'];\n\n\n/**\n * @summary Adapter for cubemaps\n * @memberof PSV.adapters\n */\nexport class CubemapAdapter extends AbstractAdapter {\n\n static id = 'cubemap';\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.CubemapAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.CubemapAdapter.Options}\n * @private\n */\n this.config = {\n flipTopBottom: false,\n ...options,\n };\n }\n\n /**\n * @override\n */\n supportsTransition() {\n return true;\n }\n\n /**\n * @override\n */\n supportsPreload() {\n return true;\n }\n\n /**\n * @override\n * @param {string[] | PSV.adapters.CubemapAdapter.Cubemap} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n const cleanPanorama = [];\n\n if (Array.isArray(panorama)) {\n if (panorama.length !== 6) {\n return Promise.reject(new PSVError('Must provide exactly 6 image paths when using cubemap.'));\n }\n\n // reorder images\n for (let i = 0; i < 6; i++) {\n cleanPanorama[i] = panorama[CUBE_ARRAY[i]];\n }\n }\n else if (typeof panorama === 'object') {\n if (!CUBE_HASHMAP.every(side => !!panorama[side])) {\n return Promise.reject(new PSVError('Must provide exactly left, front, right, back, top, bottom when using cubemap.'));\n }\n\n // transform into array\n CUBE_HASHMAP.forEach((side, i) => {\n cleanPanorama[i] = panorama[side];\n });\n }\n else {\n return Promise.reject(new PSVError('Invalid cubemap panorama, are you using the right adapter?'));\n }\n\n if (this.psv.config.fisheye) {\n utils.logWarn('fisheye effect with cubemap texture can generate distorsion');\n }\n\n const promises = [];\n const progress = [0, 0, 0, 0, 0, 0];\n\n for (let i = 0; i < 6; i++) {\n promises.push(\n this.psv.textureLoader.loadImage(cleanPanorama[i], (p) => {\n progress[i] = p;\n this.psv.loader.setProgress(utils.sum(progress) / 6);\n })\n .then(img => this.__createCubemapTexture(img))\n );\n }\n\n return Promise.all(promises)\n .then(texture => ({ panorama, texture }));\n }\n\n /**\n * @summary Creates the final texture from image\n * @param {HTMLImageElement} img\n * @returns {external:THREE.Texture}\n * @private\n */\n __createCubemapTexture(img) {\n if (img.width !== img.height) {\n utils.logWarn('Invalid base image, the width equal the height');\n }\n\n // resize image\n if (img.width > SYSTEM.maxTextureWidth) {\n const ratio = SYSTEM.getMaxCanvasWidth() / img.width;\n\n const buffer = document.createElement('canvas');\n buffer.width = img.width * ratio;\n buffer.height = img.height * ratio;\n\n const ctx = buffer.getContext('2d');\n ctx.drawImage(img, 0, 0, buffer.width, buffer.height);\n\n return utils.createTexture(buffer);\n }\n\n return utils.createTexture(img);\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const cubeSize = CONSTANTS.SPHERE_RADIUS * 2 * scale;\n const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize)\n .scale(1, 1, -1);\n\n const materials = [];\n for (let i = 0; i < 6; i++) {\n materials.push(new THREE.MeshBasicMaterial());\n }\n\n return new THREE.Mesh(geometry, materials);\n }\n\n /**\n * @override\n */\n setTexture(mesh, textureData) {\n const { texture } = textureData;\n\n for (let i = 0; i < 6; i++) {\n if (this.config.flipTopBottom && (i === 2 || i === 3)) {\n texture[i].center = new THREE.Vector2(0.5, 0.5);\n texture[i].rotation = Math.PI;\n }\n\n mesh.material[i].map?.dispose();\n mesh.material[i].map = texture[i];\n }\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n for (let i = 0; i < 6; i++) {\n mesh.material[i].opacity = opacity;\n mesh.material[i].transparent = opacity < 1;\n }\n }\n\n /**\n * @override\n */\n disposeTexture(textureData) {\n textureData.texture?.forEach(texture => texture.dispose());\n }\n\n}\n"],"names":["CUBE_ARRAY","CUBE_HASHMAP","CubemapAdapter","psv","options","config","flipTopBottom","supportsTransition","supportsPreload","loadTexture","panorama","cleanPanorama","Array","isArray","length","Promise","reject","PSVError","i","every","side","forEach","fisheye","utils","logWarn","promises","progress","push","textureLoader","loadImage","p","loader","setProgress","sum","then","img","__createCubemapTexture","all","texture","width","height","SYSTEM","maxTextureWidth","ratio","getMaxCanvasWidth","buffer","document","createElement","ctx","getContext","drawImage","createTexture","createMesh","scale","cubeSize","CONSTANTS","SPHERE_RADIUS","geometry","THREE","BoxGeometry","materials","MeshBasicMaterial","Mesh","setTexture","mesh","textureData","center","Vector2","rotation","Math","PI","material","map","dispose","setTextureOpacity","opacity","transparent","disposeTexture","AbstractAdapter","id","supportsDownload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EAGA;EACA;;MACaA,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB;MACbC,YAAY,GAAG,CAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,QAAzB,EAAmC,MAAnC,EAA2C,OAA3C;EAG5B;EACA;EACA;EACA;;MACaC,cAAb;EAAA;;EAKE;EACF;EACA;EACA;EACE,0BAAYC,GAAZ,EAAiBC,OAAjB,EAA0B;EAAA;;EACxB,wCAAMD,GAAN;EAEA;EACJ;EACA;EACA;;EACI,UAAKE,MAAL;EACEC,MAAAA,aAAa,EAAE;EADjB,OAEKF,OAFL;EAPwB;EAWzB;EAED;EACF;EACA;;;E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EACF;EACA;EAlKA;;EAAA,SAmKEE,cAnKF,GAmKE,wBAAeZ,WAAf,EAA4B;EAAA;;EAC1B,4BAAAA,WAAW,CAAC3B,OAAZ,0CAAqBjB,OAArB,CAA6B,UAAAiB,OAAO;EAAA,aAAIA,OAAO,CAACmC,OAAR,EAAJ;EAAA,KAApC;EACD,GArKH;;EAAA;EAAA,EAAoCK,iCAApC;EAAa5E,eAEJ6E,KAAK;EAFD7E,eAGJ8E,mBAAmB;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"cubemap.js","sources":["../../src/adapters/cubemap/index.js"],"sourcesContent":["import * as THREE from 'three';\nimport { AbstractAdapter, CONSTANTS, PSVError, SYSTEM, utils } from '../..';\n\n\n/**\n * @typedef {Object} PSV.adapters.CubemapAdapter.Cubemap\n * @summary Object defining a cubemap\n * @property {string} left\n * @property {string} front\n * @property {string} right\n * @property {string} back\n * @property {string} top\n * @property {string} bottom\n */\n\n/**\n * @typedef {Object} PSV.adapters.CubemapAdapter.Options\n * @property {boolean} [flipTopBottom=false] - set to true if the top and bottom faces are not correctly oriented\n */\n\n\n// PSV faces order is left, front, right, back, top, bottom\n// 3JS faces order is left, right, top, bottom, back, front\nexport const CUBE_ARRAY = [0, 2, 4, 5, 3, 1];\nexport const CUBE_HASHMAP = ['left', 'right', 'top', 'bottom', 'back', 'front'];\n\n\n/**\n * @summary Adapter for cubemaps\n * @memberof PSV.adapters\n * @extends PSV.adapters.AbstractAdapter\n */\nexport class CubemapAdapter extends AbstractAdapter {\n\n static id = 'cubemap';\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.CubemapAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.CubemapAdapter.Options}\n * @private\n */\n this.config = {\n flipTopBottom: false,\n ...options,\n };\n }\n\n /**\n * @override\n */\n supportsTransition() {\n return true;\n }\n\n /**\n * @override\n */\n supportsPreload() {\n return true;\n }\n\n /**\n * @override\n * @param {string[] | PSV.adapters.CubemapAdapter.Cubemap} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n const cleanPanorama = [];\n\n if (Array.isArray(panorama)) {\n if (panorama.length !== 6) {\n return Promise.reject(new PSVError('Must provide exactly 6 image paths when using cubemap.'));\n }\n\n // reorder images\n for (let i = 0; i < 6; i++) {\n cleanPanorama[i] = panorama[CUBE_ARRAY[i]];\n }\n }\n else if (typeof panorama === 'object') {\n if (!CUBE_HASHMAP.every(side => !!panorama[side])) {\n return Promise.reject(new PSVError('Must provide exactly left, front, right, back, top, bottom when using cubemap.'));\n }\n\n // transform into array\n CUBE_HASHMAP.forEach((side, i) => {\n cleanPanorama[i] = panorama[side];\n });\n }\n else {\n return Promise.reject(new PSVError('Invalid cubemap panorama, are you using the right adapter?'));\n }\n\n if (this.psv.config.fisheye) {\n utils.logWarn('fisheye effect with cubemap texture can generate distorsion');\n }\n\n const promises = [];\n const progress = [0, 0, 0, 0, 0, 0];\n\n for (let i = 0; i < 6; i++) {\n promises.push(\n this.psv.textureLoader.loadImage(cleanPanorama[i], (p) => {\n progress[i] = p;\n this.psv.loader.setProgress(utils.sum(progress) / 6);\n })\n .then(img => this.__createCubemapTexture(img))\n );\n }\n\n return Promise.all(promises)\n .then(texture => ({ panorama, texture }));\n }\n\n /**\n * @summary Creates the final texture from image\n * @param {HTMLImageElement} img\n * @returns {external:THREE.Texture}\n * @private\n */\n __createCubemapTexture(img) {\n if (img.width !== img.height) {\n utils.logWarn('Invalid base image, the width equal the height');\n }\n\n // resize image\n if (img.width > SYSTEM.maxTextureWidth) {\n const ratio = SYSTEM.getMaxCanvasWidth() / img.width;\n\n const buffer = document.createElement('canvas');\n buffer.width = img.width * ratio;\n buffer.height = img.height * ratio;\n\n const ctx = buffer.getContext('2d');\n ctx.drawImage(img, 0, 0, buffer.width, buffer.height);\n\n return utils.createTexture(buffer);\n }\n\n return utils.createTexture(img);\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const cubeSize = CONSTANTS.SPHERE_RADIUS * 2 * scale;\n const geometry = new THREE.BoxGeometry(cubeSize, cubeSize, cubeSize)\n .scale(1, 1, -1);\n\n const materials = [];\n for (let i = 0; i < 6; i++) {\n materials.push(new THREE.MeshBasicMaterial());\n }\n\n return new THREE.Mesh(geometry, materials);\n }\n\n /**\n * @override\n */\n setTexture(mesh, textureData) {\n const { texture } = textureData;\n\n for (let i = 0; i < 6; i++) {\n if (this.config.flipTopBottom && (i === 2 || i === 3)) {\n texture[i].center = new THREE.Vector2(0.5, 0.5);\n texture[i].rotation = Math.PI;\n }\n\n mesh.material[i].map?.dispose();\n mesh.material[i].map = texture[i];\n }\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n for (let i = 0; i < 6; i++) {\n mesh.material[i].opacity = opacity;\n mesh.material[i].transparent = opacity < 1;\n }\n }\n\n /**\n * @override\n */\n disposeTexture(textureData) {\n textureData.texture?.forEach(texture => texture.dispose());\n }\n\n}\n"],"names":["CUBE_ARRAY","CUBE_HASHMAP","CubemapAdapter","psv","options","config","flipTopBottom","supportsTransition","supportsPreload","loadTexture","panorama","cleanPanorama","Array","isArray","length","Promise","reject","PSVError","i","every","side","forEach","fisheye","utils","logWarn","promises","progress","push","textureLoader","loadImage","p","loader","setProgress","sum","then","img","__createCubemapTexture","all","texture","width","height","SYSTEM","maxTextureWidth","ratio","getMaxCanvasWidth","buffer","document","createElement","ctx","getContext","drawImage","createTexture","createMesh","scale","cubeSize","CONSTANTS","SPHERE_RADIUS","geometry","THREE","BoxGeometry","materials","MeshBasicMaterial","Mesh","setTexture","mesh","textureData","center","Vector2","rotation","Math","PI","material","map","dispose","setTextureOpacity","opacity","transparent","disposeTexture","AbstractAdapter","id","supportsDownload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EAGA;EACA;;MACa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rD,CAAd,EAAiBsD,GAAjB,GAAuBlC,OAAO,CAACpB,CAAD,CAA9B;EACD;EACF;EAED;EACF;EACA;EAxJA;;EAAA,SAyJEwD,iBAzJF,GAyJE,2BAAkBV,IAAlB,EAAwBW,OAAxB,EAAiC;EAC/B,SAAK,IAAIzD,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,CAApB,EAAuBA,CAAC,EAAxB,EAA4B;EAC1B8C,MAAAA,IAAI,CAACO,QAAL,CAAcrD,CAAd,EAAiByD,OAAjB,GAA2BA,OAA3B;EACAX,MAAAA,IAAI,CAACO,QAAL,CAAcrD,CAAd,EAAiB0D,WAAjB,GAA+BD,OAAO,GAAG,CAAzC;EACD;EACF;EAED;EACF;EACA;EAlKA;;EAAA,SAmKEE,cAnKF,GAmKE,wBAAeZ,WAAf,EAA4B;EAAA;;EAC1B,4BAAAA,WAAW,CAAC3B,OAAZ,0CAAqBjB,OAArB,CAA6B,UAAAiB,OAAO;EAAA,aAAIA,OAAO,CAACmC,OAAR,EAAJ;EAAA,KAApC;EACD,GArKH;;EAAA;EAAA,EAAoCK,iCAApC;EAAa5E,eAEJ6E,KAAK;EAFD7E,eAGJ8E,mBAAmB;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/adapters/equirectangular-tiles.js b/dist/adapters/equirectangular-tiles.js index 280dfac67..1d614a224 100644 --- a/dist/adapters/equirectangular-tiles.js +++ b/dist/adapters/equirectangular-tiles.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -317,6 +317,7 @@ /** * @summary Adapter for tiled panoramas * @memberof PSV.adapters + * @extends PSV.adapters.AbstractAdapter */ var EquirectangularTilesAdapter = /*#__PURE__*/function (_EquirectangularAdapt) { @@ -506,7 +507,10 @@ croppedWidth: panorama.width, croppedHeight: panorama.width / 2, croppedX: 0, - croppedY: 0 + croppedY: 0, + poseHeading: 0, + posePitch: 0, + poseRoll: 0 }; if (panorama.baseUrl) { diff --git a/dist/adapters/equirectangular-tiles.js.map b/dist/adapters/equirectangular-tiles.js.map index 27f1af435..36e6f1a0c 100644 --- a/dist/adapters/equirectangular-tiles.js.map +++ b/dist/adapters/equirectangular-tiles.js.map @@ -1 +1 @@ -{"version":3,"file":"equirectangular-tiles.js","sources":["../../src/adapters/tiles-shared/Task.js","../../src/adapters/tiles-shared/Queue.js","../../src/adapters/tiles-shared/utils.js","../../src/adapters/equirectangular-tiles/index.js"],"sourcesContent":["/**\n * @summary Loading task\n * @memberOf PSV.adapters\n * @private\n */\nexport class Task {\n\n static STATUS = {\n DISABLED : -1,\n PENDING : 0,\n RUNNING : 1,\n CANCELLED: 2,\n DONE : 3,\n ERROR : 4,\n };\n\n /**\n * @param {string} id\n * @param {number} priority\n * @param {function(Task): Promise} fn\n */\n constructor(id, priority, fn) {\n this.id = id;\n this.priority = priority;\n this.fn = fn;\n this.status = Task.STATUS.PENDING;\n }\n\n start() {\n this.status = Task.STATUS.RUNNING;\n return this.fn(this)\n .then(() => {\n this.status = Task.STATUS.DONE;\n }, () => {\n this.status = Task.STATUS.ERROR;\n });\n }\n\n cancel() {\n this.status = Task.STATUS.CANCELLED;\n }\n\n isCancelled() {\n return this.status === Task.STATUS.CANCELLED;\n }\n\n}\n","import { Task } from './Task';\n\n/**\n * @summary Loading queue\n * @memberOf PSV.adapters\n * @private\n */\nexport class Queue {\n\n /**\n * @param {int} concurency\n */\n constructor(concurency = 4) {\n this.concurency = concurency;\n this.runningTasks = {};\n this.tasks = {};\n }\n\n enqueue(task) {\n this.tasks[task.id] = task;\n }\n\n clear() {\n Object.values(this.tasks).forEach(task => task.cancel());\n this.tasks = {};\n this.runningTasks = {};\n }\n\n setPriority(taskId, priority) {\n const task = this.tasks[taskId];\n if (task) {\n task.priority = priority;\n if (task.status === Task.STATUS.DISABLED) {\n task.status = Task.STATUS.PENDING;\n }\n }\n }\n\n disableAllTasks() {\n Object.values(this.tasks).forEach((task) => {\n task.status = Task.STATUS.DISABLED;\n });\n }\n\n start() {\n if (Object.keys(this.runningTasks).length >= this.concurency) {\n return;\n }\n\n const nextTask = Object.values(this.tasks)\n .filter(task => task.status === Task.STATUS.PENDING)\n .sort((a, b) => b.priority - a.priority)\n .pop();\n\n if (nextTask) {\n this.runningTasks[nextTask.id] = true;\n\n nextTask.start()\n .then(() => {\n if (!nextTask.isCancelled()) {\n delete this.tasks[nextTask.id];\n delete this.runningTasks[nextTask.id];\n this.start();\n }\n });\n\n this.start(); // start tasks until max concurrency is reached\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { SYSTEM, utils } from '../..';\n\n/**\n * @summary Generates an material for errored tiles\n * @memberOf PSV.adapters\n * @return {external:THREE.MeshBasicMaterial}\n * @private\n */\nexport function buildErrorMaterial(width, height) {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n\n const ctx = canvas.getContext('2d');\n\n ctx.fillStyle = '#333';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n ctx.font = `${canvas.width / 5}px serif`;\n ctx.fillStyle = '#a22';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText('⚠', canvas.width / 2, canvas.height / 2);\n\n const texture = new THREE.CanvasTexture(canvas);\n return new THREE.MeshBasicMaterial({ map: texture });\n}\n\n/**\n * @summary Create the texture for the base image\n * @memberOf PSV.adapters\n * @param {HTMLImageElement} img\n * @param {boolean} blur\n * @param {function} getHeight\n * @return {external:THREE.Texture}\n * @private\n */\nexport function createBaseTexture(img, blur, getHeight) {\n if (blur || img.width > SYSTEM.maxTextureWidth) {\n const ratio = Math.min(1, SYSTEM.getMaxCanvasWidth() / img.width);\n\n const buffer = document.createElement('canvas');\n buffer.width = img.width * ratio;\n buffer.height = getHeight(img.width);\n\n const ctx = buffer.getContext('2d');\n if (blur) {\n ctx.filter = 'blur(1px)';\n }\n ctx.drawImage(img, 0, 0, buffer.width, buffer.height);\n\n return utils.createTexture(buffer);\n }\n\n return utils.createTexture(img);\n}\n\n/**\n * @summary Creates a wireframe geometry, for debug\n * @memberOf PSV.adapters\n * @param {THREE.BufferGeometry} geometry\n * @return {THREE.Object3D}\n * @private\n */\nexport function createWireFrame(geometry) {\n const wireframe = new THREE.WireframeGeometry(geometry);\n const line = new THREE.LineSegments(wireframe);\n line.material.depthTest = false;\n line.material.opacity = 0.25;\n line.material.transparent = true;\n return line;\n}\n\n/**\n * @summary Creates a small red sphere, for debug\n * @memberOf PSV.adapters\n * @return {THREE.Object3D}\n * @private\n */\nexport function createDot(x, y, z) {\n const geom = new THREE.SphereGeometry(0.1);\n const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });\n const mesh = new THREE.Mesh(geom, material);\n mesh.position.set(x, y, z);\n return mesh;\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, EquirectangularAdapter, PSVError, utils } from '../..';\nimport { Queue } from '../tiles-shared/Queue';\nimport { Task } from '../tiles-shared/Task';\nimport { buildErrorMaterial, createBaseTexture } from '../tiles-shared/utils';\n\n\n/**\n * @callback TileUrl\n * @summary Function called to build a tile url\n * @memberOf PSV.adapters.EquirectangularTilesAdapter\n * @param {int} col\n * @param {int} row\n * @returns {string}\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularTilesAdapter.Panorama\n * @summary Configuration of a tiled panorama\n * @property {string} [baseUrl] - low resolution panorama loaded before tiles\n * @property {int} width - complete panorama width (height is always width/2)\n * @property {int} cols - number of vertical tiles\n * @property {int} rows - number of horizontal tiles\n * @property {PSV.adapters.EquirectangularTilesAdapter.TileUrl} tileUrl - function to build a tile url\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularTilesAdapter.Options\n * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances\n * @property {boolean} [showErrorTile=true] - shows a warning sign on tiles that cannot be loaded\n * @property {boolean} [baseBlur=true] - applies a blur to the low resolution panorama\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularTilesAdapter.Tile\n * @private\n * @property {int} col\n * @property {int} row\n * @property {float} angle\n */\n\n/* the faces of the top and bottom rows are made of a single triangle (3 vertices)\n * all other faces are made of two triangles (6 vertices)\n * bellow is the indexing of each face vertices\n *\n * first row faces:\n * ⋀\n * /0\\\n * / \\\n * / \\\n * /1 2\\\n * ¯¯¯¯¯¯¯¯¯\n *\n * other rows faces:\n * _________\n * |\\1 0|\n * |3\\ |\n * | \\ |\n * | \\ |\n * | \\ |\n * | \\2|\n * |4 5\\|\n * ¯¯¯¯¯¯¯¯¯\n *\n * last row faces:\n * _________\n * \\1 0/\n * \\ /\n * \\ /\n * \\2/\n * ⋁\n */\n\nconst ATTR_UV = 'uv';\nconst ATTR_ORIGINAL_UV = 'originaluv';\nconst ATTR_POSITION = 'position';\n\nfunction tileId(tile) {\n return `${tile.col}x${tile.row}`;\n}\n\nconst frustum = new THREE.Frustum();\nconst projScreenMatrix = new THREE.Matrix4();\nconst vertexPosition = new THREE.Vector3();\n\n\n/**\n * @summary Adapter for tiled panoramas\n * @memberof PSV.adapters\n */\nexport class EquirectangularTilesAdapter extends EquirectangularAdapter {\n\n static id = 'equirectangular-tiles';\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.EquirectangularTilesAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n this.psv.config.useXmpData = false;\n\n /**\n * @member {PSV.adapters.EquirectangularTilesAdapter.Options}\n * @private\n */\n this.config = {\n resolution : 64,\n showErrorTile: true,\n baseBlur : true,\n ...options,\n };\n\n if (!utils.isPowerOfTwo(this.config.resolution)) {\n throw new PSVError('EquirectangularAdapter resolution must be power of two');\n }\n\n this.SPHERE_SEGMENTS = this.config.resolution;\n this.SPHERE_HORIZONTAL_SEGMENTS = this.SPHERE_SEGMENTS / 2;\n this.NB_VERTICES_BY_FACE = 6;\n this.NB_VERTICES_BY_SMALL_FACE = 3;\n this.NB_VERTICES = 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + (this.SPHERE_HORIZONTAL_SEGMENTS - 2) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n this.NB_GROUPS = this.SPHERE_SEGMENTS * this.SPHERE_HORIZONTAL_SEGMENTS;\n\n /**\n * @member {PSV.adapters.Queue}\n * @private\n */\n this.queue = new Queue();\n\n /**\n * @type {Object}\n * @property {int} colSize - size in pixels of a column\n * @property {int} rowSize - size in pixels of a row\n * @property {int} facesByCol - number of mesh faces by column\n * @property {int} facesByRow - number of mesh faces by row\n * @property {Record} tiles - loaded tiles\n * @property {external:THREE.SphereGeometry} geom\n * @property {external:THREE.MeshBasicMaterial[]} materials\n * @property {external:THREE.MeshBasicMaterial} errorMaterial\n * @private\n */\n this.prop = {\n colSize : 0,\n rowSize : 0,\n facesByCol : 0,\n facesByRow : 0,\n tiles : {},\n geom : null,\n materials : [],\n errorMaterial: null,\n };\n\n /**\n * @member {external:THREE.ImageLoader}\n * @private\n */\n this.loader = new THREE.ImageLoader();\n if (this.psv.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders);\n }\n\n this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n\n this.__cleanup();\n\n this.prop.errorMaterial?.map?.dispose();\n this.prop.errorMaterial?.dispose();\n\n delete this.queue;\n delete this.loader;\n delete this.prop.geom;\n delete this.prop.errorMaterial;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.POSITION_UPDATED:\n case CONSTANTS.EVENTS.ZOOM_UPDATED:\n this.__refresh();\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Clears loading queue, dispose all materials\n * @private\n */\n __cleanup() {\n this.queue.clear();\n this.prop.tiles = {};\n\n this.prop.materials.forEach((mat) => {\n mat?.map?.dispose();\n mat?.dispose();\n });\n this.prop.materials.length = 0;\n }\n\n /**\n * @override\n */\n supportsTransition(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n */\n supportsPreload(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n * @param {PSV.adapters.EquirectangularTilesAdapter.Panorama} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n if (typeof panorama !== 'object' || !panorama.width || !panorama.cols || !panorama.rows || !panorama.tileUrl) {\n return Promise.reject(new PSVError('Invalid panorama configuration, are you using the right adapter?'));\n }\n if (panorama.cols > this.SPHERE_SEGMENTS) {\n return Promise.reject(new PSVError(`Panorama cols must not be greater than ${this.SPHERE_SEGMENTS}.`));\n }\n if (panorama.rows > this.SPHERE_HORIZONTAL_SEGMENTS) {\n return Promise.reject(new PSVError(`Panorama rows must not be greater than ${this.SPHERE_HORIZONTAL_SEGMENTS}.`));\n }\n if (!utils.isPowerOfTwo(panorama.cols) || !utils.isPowerOfTwo(panorama.rows)) {\n return Promise.reject(new PSVError('Panorama cols and rows must be powers of 2.'));\n }\n\n const panoData = {\n fullWidth : panorama.width,\n fullHeight : panorama.width / 2,\n croppedWidth : panorama.width,\n croppedHeight: panorama.width / 2,\n croppedX : 0,\n croppedY : 0,\n };\n\n if (panorama.baseUrl) {\n return super.loadTexture(panorama.baseUrl)\n .then(textureData => ({\n panorama: panorama,\n texture : textureData.texture,\n panoData: panoData,\n }));\n }\n else {\n return Promise.resolve({ panorama, panoData });\n }\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const geometry = new THREE.SphereGeometry(CONSTANTS.SPHERE_RADIUS * scale, this.SPHERE_SEGMENTS, this.SPHERE_HORIZONTAL_SEGMENTS, -Math.PI / 2)\n .scale(-1, 1, 1)\n .toNonIndexed();\n\n geometry.clearGroups();\n let i = 0;\n let k = 0;\n // first row\n for (; i < this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE; i += this.NB_VERTICES_BY_SMALL_FACE) {\n geometry.addGroup(i, this.NB_VERTICES_BY_SMALL_FACE, k++);\n }\n // second to before last rows\n for (; i < this.NB_VERTICES - this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE; i += this.NB_VERTICES_BY_FACE) {\n geometry.addGroup(i, this.NB_VERTICES_BY_FACE, k++);\n }\n // last row\n for (; i < this.NB_VERTICES; i += this.NB_VERTICES_BY_SMALL_FACE) {\n geometry.addGroup(i, this.NB_VERTICES_BY_SMALL_FACE, k++);\n }\n\n geometry.setAttribute(ATTR_ORIGINAL_UV, geometry.getAttribute(ATTR_UV).clone());\n\n return new THREE.Mesh(geometry, []);\n }\n\n /**\n * @summary Applies the base texture and starts the loading of tiles\n * @override\n */\n setTexture(mesh, textureData, transition) {\n const { panorama, texture } = textureData;\n\n if (transition) {\n this.__setTexture(mesh, texture);\n return;\n }\n\n this.__cleanup();\n this.__setTexture(mesh, texture);\n\n this.prop.materials = mesh.material;\n this.prop.geom = mesh.geometry;\n this.prop.geom.setAttribute(ATTR_UV, this.prop.geom.getAttribute(ATTR_ORIGINAL_UV).clone());\n\n this.prop.colSize = panorama.width / panorama.cols;\n this.prop.rowSize = panorama.width / 2 / panorama.rows;\n this.prop.facesByCol = this.SPHERE_SEGMENTS / panorama.cols;\n this.prop.facesByRow = this.SPHERE_HORIZONTAL_SEGMENTS / panorama.rows;\n\n // this.psv.renderer.scene.add(createWireFrame(this.prop.geom));\n\n setTimeout(() => this.__refresh(true));\n }\n\n /**\n * @private\n */\n __setTexture(mesh, texture) {\n let material;\n if (texture) {\n material = new THREE.MeshBasicMaterial({ map: texture });\n }\n else {\n material = new THREE.MeshBasicMaterial({ opacity: 0, transparent: true });\n }\n\n for (let i = 0; i < this.NB_GROUPS; i++) {\n mesh.material.push(material);\n }\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n mesh.material[0].opacity = opacity;\n mesh.material[0].transparent = opacity < 1;\n }\n\n /**\n * @summary Compute visible tiles and load them\n * @param {boolean} [init=false] Indicates initial call\n * @private\n */\n __refresh(init = false) { // eslint-disable-line no-unused-vars\n if (!this.prop.geom) {\n return;\n }\n\n const camera = this.psv.renderer.camera;\n camera.updateMatrixWorld();\n projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n frustum.setFromProjectionMatrix(projScreenMatrix);\n\n const panorama = this.psv.config.panorama;\n const verticesPosition = this.prop.geom.getAttribute(ATTR_POSITION);\n const tilesToLoad = [];\n\n for (let col = 0; col < panorama.cols; col++) {\n for (let row = 0; row < panorama.rows; row++) {\n // for each tile, find the vertices corresponding to the four corners (three for first and last rows)\n // if at least one vertex is visible, the tile must be loaded\n // for larger tiles we also test the four edges centers and the tile center\n\n const verticesIndex = [];\n\n if (row === 0) {\n // bottom-left\n const v0 = this.prop.facesByRow === 1\n ? col * this.prop.facesByCol * this.NB_VERTICES_BY_SMALL_FACE + 1\n : this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + (this.prop.facesByRow - 2) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_FACE + 4;\n\n // bottom-right\n const v1 = this.prop.facesByRow === 1\n ? v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_SMALL_FACE + 1\n : v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE + 1;\n\n // top (all vertices are equal)\n const v2 = 0;\n\n verticesIndex.push(v0, v1, v2);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // bottom-center\n const v4 = v0 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4);\n }\n\n if (this.prop.facesByRow >= this.SPHERE_HORIZONTAL_SEGMENTS / 4) {\n // left-center\n const v6 = v0 - this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n // right-center\n const v7 = v1 - this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v6, v7);\n }\n }\n else if (row === panorama.rows - 1) {\n // top-left\n const v0 = this.prop.facesByRow === 1\n ? -this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + row * this.prop.facesByRow * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_SMALL_FACE + 1\n : -this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + row * this.prop.facesByRow * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_FACE + 1;\n\n // top-right\n const v1 = this.prop.facesByRow === 1\n ? v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_SMALL_FACE - 1\n : v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE - 1;\n\n // bottom (all vertices are equal)\n const v2 = this.NB_VERTICES - 1;\n\n verticesIndex.push(v0, v1, v2);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // top-center\n const v4 = v0 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4);\n }\n\n if (this.prop.facesByRow >= this.SPHERE_HORIZONTAL_SEGMENTS / 4) {\n // left-center\n const v6 = v0 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n // right-center\n const v7 = v1 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v6, v7);\n }\n }\n else {\n // top-left\n const v0 = -this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + row * this.prop.facesByRow * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_FACE + 1;\n\n // bottom-left\n const v1 = v0 + (this.prop.facesByRow - 1) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE + 3;\n\n // bottom-right\n const v2 = v1 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE + 1;\n\n // top-right\n const v3 = v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE - 1;\n\n verticesIndex.push(v0, v1, v2, v3);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // top-center\n const v4 = v0 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n // bottom-center\n const v5 = v1 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4, v5);\n }\n\n if (this.prop.facesByRow >= this.SPHERE_HORIZONTAL_SEGMENTS / 4) {\n // left-center\n const v6 = v0 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n // right-center\n const v7 = v3 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v6, v7);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // center-center\n const v8 = v6 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v8);\n }\n }\n }\n\n // if (init && col === 0 && row === 0) {\n // verticesIndex.forEach((vertexIdx) => {\n // this.psv.renderer.scene.add(createDot(\n // verticesPosition.getX(vertexIdx),\n // verticesPosition.getY(vertexIdx),\n // verticesPosition.getZ(vertexIdx)\n // ));\n // });\n // }\n\n const vertexVisible = verticesIndex.some((vertexIdx) => {\n vertexPosition.set(\n verticesPosition.getX(vertexIdx),\n verticesPosition.getY(vertexIdx),\n verticesPosition.getZ(vertexIdx)\n );\n vertexPosition.applyEuler(this.psv.renderer.meshContainer.rotation);\n return frustum.containsPoint(vertexPosition);\n });\n\n if (vertexVisible) {\n let angle = vertexPosition.angleTo(this.psv.prop.direction);\n if (row === 0 || row === panorama.rows - 1) {\n angle *= 2; // lower priority to top and bottom tiles\n }\n tilesToLoad.push({ col, row, angle });\n }\n }\n }\n\n this.__loadTiles(tilesToLoad);\n }\n\n /**\n * @summary Loads tiles and change existing tiles priority\n * @param {PSV.adapters.EquirectangularTilesAdapter.Tile[]} tiles\n * @private\n */\n __loadTiles(tiles) {\n this.queue.disableAllTasks();\n\n tiles.forEach((tile) => {\n const id = tileId(tile);\n\n if (this.prop.tiles[id]) {\n this.queue.setPriority(id, tile.angle);\n }\n else {\n this.prop.tiles[id] = true;\n this.queue.enqueue(new Task(id, tile.angle, task => this.__loadTile(tile, task)));\n }\n });\n\n this.queue.start();\n }\n\n /**\n * @summary Loads and draw a tile\n * @param {PSV.adapters.EquirectangularTilesAdapter.Tile} tile\n * @param {PSV.adapters.Task} task\n * @return {Promise}\n * @private\n */\n __loadTile(tile, task) {\n const panorama = this.psv.config.panorama;\n const url = panorama.tileUrl(tile.col, tile.row);\n\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders(url));\n }\n\n return new Promise((resolve, reject) => {\n this.loader.load(url, resolve, undefined, reject);\n })\n .then((image) => {\n if (!task.isCancelled()) {\n const material = new THREE.MeshBasicMaterial({ map: utils.createTexture(image) });\n this.__swapMaterial(tile.col, tile.row, material);\n this.psv.needsUpdate();\n }\n })\n .catch(() => {\n if (!task.isCancelled() && this.config.showErrorTile) {\n if (!this.prop.errorMaterial) {\n this.prop.errorMaterial = buildErrorMaterial(this.prop.colSize, this.prop.rowSize);\n }\n this.__swapMaterial(tile.col, tile.row, this.prop.errorMaterial);\n this.psv.needsUpdate();\n }\n });\n }\n\n /**\n * @summary Applies a new texture to the faces\n * @param {int} col\n * @param {int} row\n * @param {external:THREE.MeshBasicMaterial} material\n * @private\n */\n __swapMaterial(col, row, material) {\n const uvs = this.prop.geom.getAttribute(ATTR_UV);\n\n for (let c = 0; c < this.prop.facesByCol; c++) {\n for (let r = 0; r < this.prop.facesByRow; r++) {\n // position of the face (two triangles of the same square)\n const faceCol = col * this.prop.facesByCol + c;\n const faceRow = row * this.prop.facesByRow + r;\n const isFirstRow = faceRow === 0;\n const isLastRow = faceRow === (this.SPHERE_HORIZONTAL_SEGMENTS - 1);\n\n // first vertex for this face (3 or 6 vertices in total)\n let firstVertex;\n if (isFirstRow) {\n firstVertex = faceCol * this.NB_VERTICES_BY_SMALL_FACE;\n }\n else if (isLastRow) {\n firstVertex = this.NB_VERTICES\n - this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + faceCol * this.NB_VERTICES_BY_SMALL_FACE;\n }\n else {\n firstVertex = this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + (faceRow - 1) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + faceCol * this.NB_VERTICES_BY_FACE;\n }\n\n // swap material\n const matIndex = this.prop.geom.groups.find(g => g.start === firstVertex).materialIndex;\n this.prop.materials[matIndex] = material;\n\n // define new uvs\n const top = 1 - r / this.prop.facesByRow;\n const bottom = 1 - (r + 1) / this.prop.facesByRow;\n const left = c / this.prop.facesByCol;\n const right = (c + 1) / this.prop.facesByCol;\n\n if (isFirstRow) {\n uvs.setXY(firstVertex, (left + right) / 2, top);\n uvs.setXY(firstVertex + 1, left, bottom);\n uvs.setXY(firstVertex + 2, right, bottom);\n }\n else if (isLastRow) {\n uvs.setXY(firstVertex, right, top);\n uvs.setXY(firstVertex + 1, left, top);\n uvs.setXY(firstVertex + 2, (left + right) / 2, bottom);\n }\n else {\n uvs.setXY(firstVertex, right, top);\n uvs.setXY(firstVertex + 1, left, top);\n uvs.setXY(firstVertex + 2, right, bottom);\n uvs.setXY(firstVertex + 3, left, top);\n uvs.setXY(firstVertex + 4, left, bottom);\n uvs.setXY(firstVertex + 5, right, bottom);\n }\n }\n }\n\n uvs.needsUpdate = true;\n }\n\n /**\n * @summary Create the texture for the base image\n * @param {HTMLImageElement} img\n * @return {external:THREE.Texture}\n * @private\n */\n __createBaseTexture(img) {\n if (img.width !== img.height * 2) {\n utils.logWarn('Invalid base image, the width should be twice the height');\n }\n\n return createBaseTexture(img, this.config.baseBlur, w => w / 2);\n }\n\n}\n"],"names":["Task","id","priority","fn","status","STATUS","PENDING","start","RUNNING","then","DONE","ERROR","cancel","CANCELLED","isCancelled","DISABLED","Queue","concurency","runningTasks","tasks","enqueue","task","clear","Object","values","forEach","setPriority","taskId","disableAllTasks","keys","length","nextTask","filter","sort","a","b","pop","buildErrorMaterial","width","height","canvas","document","createElement","ctx","getContext","fillStyle","fillRect","font","textAlign","textBaseline","fillText","texture","THREE","CanvasTexture","MeshBasicMaterial","map","createBaseTexture","img","blur","getHeight","SYSTEM","maxTextureWidth","ratio","Math","min","getMaxCanvasWidth","buffer","drawImage","utils","createTexture","ATTR_UV","ATTR_ORIGINAL_UV","ATTR_POSITION","tileId","tile","col","row","frustum","Frustum","projScreenMatrix","Matrix4","vertexPosition","Vector3","EquirectangularTilesAdapter","psv","options","config","useXmpData","resolution","showErrorTile","baseBlur","isPowerOfTwo","PSVError","SPHERE_SEGMENTS","SPHERE_HORIZONTAL_SEGMENTS","NB_VERTICES_BY_FACE","NB_VERTICES_BY_SMALL_FACE","NB_VERTICES","NB_GROUPS","queue","prop","colSize","rowSize","facesByCol","facesByRow","tiles","geom","materials","errorMaterial","loader","ImageLoader","withCredentials","setWithCredentials","requestHeaders","setRequestHeader","on","CONSTANTS","EVENTS","POSITION_UPDATED","ZOOM_UPDATED","destroy","off","__cleanup","dispose","handleEvent","e","type","__refresh","mat","supportsTransition","panorama","baseUrl","supportsPreload","loadTexture","cols","rows","tileUrl","Promise","reject","panoData","fullWidth","fullHeight","croppedWidth","croppedHeight","croppedX","croppedY","textureData","resolve","createMesh","scale","geometry","SphereGeometry","SPHERE_RADIUS","PI","toNonIndexed","clearGroups","i","k","addGroup","setAttribute","getAttribute","clone","Mesh","setTexture","mesh","transition","__setTexture","material","setTimeout","opacity","transparent","push","setTextureOpacity","init","camera","renderer","updateMatrixWorld","multiplyMatrices","projectionMatrix","matrixWorldInverse","setFromProjectionMatrix","verticesPosition","tilesToLoad","verticesIndex","v0","v1","v2","v4","v6","v7","v3","v5","v8","vertexVisible","some","vertexIdx","set","getX","getY","getZ","applyEuler","meshContainer","rotation","containsPoint","angle","angleTo","direction","__loadTiles","__loadTile","url","load","undefined","image","__swapMaterial","needsUpdate","catch","uvs","c","r","faceCol","faceRow","isFirstRow","isLastRow","firstVertex","matIndex","groups","find","g","materialIndex","top","bottom","left","right","setXY","__createBaseTexture","logWarn","w","EquirectangularAdapter","supportsDownload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;MACaA,IAAb;EAWE;EACF;EACA;EACA;EACA;EACE,gBAAYC,EAAZ,EAAgBC,QAAhB,EAA0BC,EAA1B,EAA8B;EAC5B,SAAKF,EAAL,GAAUA,EAAV;EACA,SAAKC,QAAL,GAAgBA,QAAhB;EACA,SAAKC,EAAL,GAAUA,EAAV;EACA,SAAKC,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYC,OAA1B;EACD;;EArBH;;EAAA,SAuBEC,KAvBF,GAuBE,iBAAQ;EAAA;;EACN,SAAKH,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYG,OAA1B;EACA,WAAO,KAAKL,EAAL,CAAQ,IAAR,EACJM,IADI,CACC,YAAM;EACV,MAAA,KAAI,CAACL,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYK,IAA1B;EACD,KAHI,EAGF,YAAM;EACP,MAAA,KAAI,CAACN,MA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2BS,KAA3B,EAAkCF,MAAlC;EACAd,UAAAA,GAAG,CAACiB,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BQ,IAA3B,EAAiCF,GAAjC;EACAb,UAAAA,GAAG,CAACiB,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BQ,IAA3B,EAAiCD,MAAjC;EACAd,UAAAA,GAAG,CAACiB,KAAJ,CAAUV,WAAW,GAAG,CAAxB,EAA2BS,KAA3B,EAAkCF,MAAlC;EACD;EAnD0C;;EAC7C,WAAK,IAAIZ,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,KAAKtH,IAAL,CAAUI,UAA9B,EAA0CkH,CAAC,EAA3C,EAA+C;EAAA,cAAtCA,CAAsC;EAmD9C;EACF;;EAEDF,IAAAA,GAAG,CAACF,WAAJ,GAAkB,IAAlB;EACD;EAED;EACF;EACA;EACA;EACA;EACA;EAlkBA;;EAAA,SAmkBEoB,mBAnkBF,GAmkBE,6BAAoBjL,GAApB,EAAyB;EACvB,QAAIA,GAAG,CAACnB,KAAJ,KAAcmB,GAAG,CAAClB,MAAJ,GAAa,CAA/B,EAAkC;EAChC6B,MAAAA,uBAAK,CAACuK,OAAN,CAAc,0DAAd;EACD;;EAED,WAAOnL,iBAAiB,CAACC,GAAD,EAAM,KAAK6B,MAAL,CAAYI,QAAlB,EAA4B,UAAAkJ,CAAC;EAAA,aAAIA,CAAC,GAAG,CAAR;EAAA,KAA7B,CAAxB;EACD,GAzkBH;;EAAA;EAAA,EAAiDC,wCAAjD;EAAa1J,4BAEJlF,KAAK;EAFDkF,4BAGJ2J,mBAAmB;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"equirectangular-tiles.js","sources":["../../src/adapters/shared/Task.js","../../src/adapters/shared/Queue.js","../../src/adapters/shared/tiles-utils.js","../../src/adapters/equirectangular-tiles/index.js"],"sourcesContent":["/**\n * @summary Loading task\n * @memberOf PSV.adapters\n * @private\n */\nexport class Task {\n\n static STATUS = {\n DISABLED : -1,\n PENDING : 0,\n RUNNING : 1,\n CANCELLED: 2,\n DONE : 3,\n ERROR : 4,\n };\n\n /**\n * @param {string} id\n * @param {number} priority\n * @param {function(Task): Promise} fn\n */\n constructor(id, priority, fn) {\n this.id = id;\n this.priority = priority;\n this.fn = fn;\n this.status = Task.STATUS.PENDING;\n }\n\n start() {\n this.status = Task.STATUS.RUNNING;\n return this.fn(this)\n .then(() => {\n this.status = Task.STATUS.DONE;\n }, () => {\n this.status = Task.STATUS.ERROR;\n });\n }\n\n cancel() {\n this.status = Task.STATUS.CANCELLED;\n }\n\n isCancelled() {\n return this.status === Task.STATUS.CANCELLED;\n }\n\n}\n","import { Task } from './Task';\n\n/**\n * @summary Loading queue\n * @memberOf PSV.adapters\n * @private\n */\nexport class Queue {\n\n /**\n * @param {int} concurency\n */\n constructor(concurency = 4) {\n this.concurency = concurency;\n this.runningTasks = {};\n this.tasks = {};\n }\n\n enqueue(task) {\n this.tasks[task.id] = task;\n }\n\n clear() {\n Object.values(this.tasks).forEach(task => task.cancel());\n this.tasks = {};\n this.runningTasks = {};\n }\n\n setPriority(taskId, priority) {\n const task = this.tasks[taskId];\n if (task) {\n task.priority = priority;\n if (task.status === Task.STATUS.DISABLED) {\n task.status = Task.STATUS.PENDING;\n }\n }\n }\n\n disableAllTasks() {\n Object.values(this.tasks).forEach((task) => {\n task.status = Task.STATUS.DISABLED;\n });\n }\n\n start() {\n if (Object.keys(this.runningTasks).length >= this.concurency) {\n return;\n }\n\n const nextTask = Object.values(this.tasks)\n .filter(task => task.status === Task.STATUS.PENDING)\n .sort((a, b) => b.priority - a.priority)\n .pop();\n\n if (nextTask) {\n this.runningTasks[nextTask.id] = true;\n\n nextTask.start()\n .then(() => {\n if (!nextTask.isCancelled()) {\n delete this.tasks[nextTask.id];\n delete this.runningTasks[nextTask.id];\n this.start();\n }\n });\n\n this.start(); // start tasks until max concurrency is reached\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { SYSTEM, utils } from '../..';\n\n/**\n * @summary Generates an material for errored tiles\n * @memberOf PSV.adapters\n * @return {external:THREE.MeshBasicMaterial}\n * @private\n */\nexport function buildErrorMaterial(width, height) {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n\n const ctx = canvas.getContext('2d');\n\n ctx.fillStyle = '#333';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n ctx.font = `${canvas.width / 5}px serif`;\n ctx.fillStyle = '#a22';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText('⚠', canvas.width / 2, canvas.height / 2);\n\n const texture = new THREE.CanvasTexture(canvas);\n return new THREE.MeshBasicMaterial({ map: texture });\n}\n\n/**\n * @summary Create the texture for the base image\n * @memberOf PSV.adapters\n * @param {HTMLImageElement} img\n * @param {boolean} blur\n * @param {function} getHeight\n * @return {external:THREE.Texture}\n * @private\n */\nexport function createBaseTexture(img, blur, getHeight) {\n if (blur || img.width > SYSTEM.maxTextureWidth) {\n const ratio = Math.min(1, SYSTEM.getMaxCanvasWidth() / img.width);\n\n const buffer = document.createElement('canvas');\n buffer.width = img.width * ratio;\n buffer.height = getHeight(img.width);\n\n const ctx = buffer.getContext('2d');\n if (blur) {\n ctx.filter = 'blur(1px)';\n }\n ctx.drawImage(img, 0, 0, buffer.width, buffer.height);\n\n return utils.createTexture(buffer);\n }\n\n return utils.createTexture(img);\n}\n\n/**\n * @summary Creates a wireframe geometry, for debug\n * @memberOf PSV.adapters\n * @param {THREE.BufferGeometry} geometry\n * @return {THREE.Object3D}\n * @private\n */\nexport function createWireFrame(geometry) {\n const wireframe = new THREE.WireframeGeometry(geometry);\n const line = new THREE.LineSegments(wireframe);\n line.material.depthTest = false;\n line.material.opacity = 0.25;\n line.material.transparent = true;\n return line;\n}\n\n/**\n * @summary Creates a small red sphere, for debug\n * @memberOf PSV.adapters\n * @return {THREE.Object3D}\n * @private\n */\nexport function createDot(x, y, z) {\n const geom = new THREE.SphereGeometry(0.1);\n const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });\n const mesh = new THREE.Mesh(geom, material);\n mesh.position.set(x, y, z);\n return mesh;\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, EquirectangularAdapter, PSVError, utils } from '../..';\nimport { Queue } from '../shared/Queue';\nimport { Task } from '../shared/Task';\nimport { buildErrorMaterial, createBaseTexture } from '../shared/tiles-utils';\n\n\n/**\n * @callback TileUrl\n * @summary Function called to build a tile url\n * @memberOf PSV.adapters.EquirectangularTilesAdapter\n * @param {int} col\n * @param {int} row\n * @returns {string}\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularTilesAdapter.Panorama\n * @summary Configuration of a tiled panorama\n * @property {string} [baseUrl] - low resolution panorama loaded before tiles\n * @property {int} width - complete panorama width (height is always width/2)\n * @property {int} cols - number of vertical tiles\n * @property {int} rows - number of horizontal tiles\n * @property {PSV.adapters.EquirectangularTilesAdapter.TileUrl} tileUrl - function to build a tile url\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularTilesAdapter.Options\n * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances\n * @property {boolean} [showErrorTile=true] - shows a warning sign on tiles that cannot be loaded\n * @property {boolean} [baseBlur=true] - applies a blur to the low resolution panorama\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularTilesAdapter.Tile\n * @private\n * @property {int} col\n * @property {int} row\n * @property {float} angle\n */\n\n/* the faces of the top and bottom rows are made of a single triangle (3 vertices)\n * all other faces are made of two triangles (6 vertices)\n * bellow is the indexing of each face vertices\n *\n * first row faces:\n * ⋀\n * /0\\\n * / \\\n * / \\\n * /1 2\\\n * ¯¯¯¯¯¯¯¯¯\n *\n * other rows faces:\n * _________\n * |\\1 0|\n * |3\\ |\n * | \\ |\n * | \\ |\n * | \\ |\n * | \\2|\n * |4 5\\|\n * ¯¯¯¯¯¯¯¯¯\n *\n * last row faces:\n * _________\n * \\1 0/\n * \\ /\n * \\ /\n * \\2/\n * ⋁\n */\n\nconst ATTR_UV = 'uv';\nconst ATTR_ORIGINAL_UV = 'originaluv';\nconst ATTR_POSITION = 'position';\n\nfunction tileId(tile) {\n return `${tile.col}x${tile.row}`;\n}\n\nconst frustum = new THREE.Frustum();\nconst projScreenMatrix = new THREE.Matrix4();\nconst vertexPosition = new THREE.Vector3();\n\n\n/**\n * @summary Adapter for tiled panoramas\n * @memberof PSV.adapters\n * @extends PSV.adapters.AbstractAdapter\n */\nexport class EquirectangularTilesAdapter extends EquirectangularAdapter {\n\n static id = 'equirectangular-tiles';\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.EquirectangularTilesAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n this.psv.config.useXmpData = false;\n\n /**\n * @member {PSV.adapters.EquirectangularTilesAdapter.Options}\n * @private\n */\n this.config = {\n resolution : 64,\n showErrorTile: true,\n baseBlur : true,\n ...options,\n };\n\n if (!utils.isPowerOfTwo(this.config.resolution)) {\n throw new PSVError('EquirectangularAdapter resolution must be power of two');\n }\n\n this.SPHERE_SEGMENTS = this.config.resolution;\n this.SPHERE_HORIZONTAL_SEGMENTS = this.SPHERE_SEGMENTS / 2;\n this.NB_VERTICES_BY_FACE = 6;\n this.NB_VERTICES_BY_SMALL_FACE = 3;\n this.NB_VERTICES = 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + (this.SPHERE_HORIZONTAL_SEGMENTS - 2) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n this.NB_GROUPS = this.SPHERE_SEGMENTS * this.SPHERE_HORIZONTAL_SEGMENTS;\n\n /**\n * @member {PSV.adapters.Queue}\n * @private\n */\n this.queue = new Queue();\n\n /**\n * @type {Object}\n * @property {int} colSize - size in pixels of a column\n * @property {int} rowSize - size in pixels of a row\n * @property {int} facesByCol - number of mesh faces by column\n * @property {int} facesByRow - number of mesh faces by row\n * @property {Record} tiles - loaded tiles\n * @property {external:THREE.SphereGeometry} geom\n * @property {external:THREE.MeshBasicMaterial[]} materials\n * @property {external:THREE.MeshBasicMaterial} errorMaterial\n * @private\n */\n this.prop = {\n colSize : 0,\n rowSize : 0,\n facesByCol : 0,\n facesByRow : 0,\n tiles : {},\n geom : null,\n materials : [],\n errorMaterial: null,\n };\n\n /**\n * @member {external:THREE.ImageLoader}\n * @private\n */\n this.loader = new THREE.ImageLoader();\n if (this.psv.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders);\n }\n\n this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n\n this.__cleanup();\n\n this.prop.errorMaterial?.map?.dispose();\n this.prop.errorMaterial?.dispose();\n\n delete this.queue;\n delete this.loader;\n delete this.prop.geom;\n delete this.prop.errorMaterial;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.POSITION_UPDATED:\n case CONSTANTS.EVENTS.ZOOM_UPDATED:\n this.__refresh();\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Clears loading queue, dispose all materials\n * @private\n */\n __cleanup() {\n this.queue.clear();\n this.prop.tiles = {};\n\n this.prop.materials.forEach((mat) => {\n mat?.map?.dispose();\n mat?.dispose();\n });\n this.prop.materials.length = 0;\n }\n\n /**\n * @override\n */\n supportsTransition(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n */\n supportsPreload(panorama) {\n return !!panorama.baseUrl;\n }\n\n /**\n * @override\n * @param {PSV.adapters.EquirectangularTilesAdapter.Panorama} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n if (typeof panorama !== 'object' || !panorama.width || !panorama.cols || !panorama.rows || !panorama.tileUrl) {\n return Promise.reject(new PSVError('Invalid panorama configuration, are you using the right adapter?'));\n }\n if (panorama.cols > this.SPHERE_SEGMENTS) {\n return Promise.reject(new PSVError(`Panorama cols must not be greater than ${this.SPHERE_SEGMENTS}.`));\n }\n if (panorama.rows > this.SPHERE_HORIZONTAL_SEGMENTS) {\n return Promise.reject(new PSVError(`Panorama rows must not be greater than ${this.SPHERE_HORIZONTAL_SEGMENTS}.`));\n }\n if (!utils.isPowerOfTwo(panorama.cols) || !utils.isPowerOfTwo(panorama.rows)) {\n return Promise.reject(new PSVError('Panorama cols and rows must be powers of 2.'));\n }\n\n const panoData = {\n fullWidth : panorama.width,\n fullHeight : panorama.width / 2,\n croppedWidth : panorama.width,\n croppedHeight: panorama.width / 2,\n croppedX : 0,\n croppedY : 0,\n poseHeading : 0,\n posePitch : 0,\n poseRoll : 0,\n };\n\n if (panorama.baseUrl) {\n return super.loadTexture(panorama.baseUrl)\n .then(textureData => ({\n panorama: panorama,\n texture : textureData.texture,\n panoData: panoData,\n }));\n }\n else {\n return Promise.resolve({ panorama, panoData });\n }\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const geometry = new THREE.SphereGeometry(\n CONSTANTS.SPHERE_RADIUS * scale,\n this.SPHERE_SEGMENTS,\n this.SPHERE_HORIZONTAL_SEGMENTS,\n -Math.PI / 2\n )\n .scale(-1, 1, 1)\n .toNonIndexed();\n\n geometry.clearGroups();\n let i = 0;\n let k = 0;\n // first row\n for (; i < this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE; i += this.NB_VERTICES_BY_SMALL_FACE) {\n geometry.addGroup(i, this.NB_VERTICES_BY_SMALL_FACE, k++);\n }\n // second to before last rows\n for (; i < this.NB_VERTICES - this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE; i += this.NB_VERTICES_BY_FACE) {\n geometry.addGroup(i, this.NB_VERTICES_BY_FACE, k++);\n }\n // last row\n for (; i < this.NB_VERTICES; i += this.NB_VERTICES_BY_SMALL_FACE) {\n geometry.addGroup(i, this.NB_VERTICES_BY_SMALL_FACE, k++);\n }\n\n geometry.setAttribute(ATTR_ORIGINAL_UV, geometry.getAttribute(ATTR_UV).clone());\n\n return new THREE.Mesh(geometry, []);\n }\n\n /**\n * @summary Applies the base texture and starts the loading of tiles\n * @override\n */\n setTexture(mesh, textureData, transition) {\n const { panorama, texture } = textureData;\n\n if (transition) {\n this.__setTexture(mesh, texture);\n return;\n }\n\n this.__cleanup();\n this.__setTexture(mesh, texture);\n\n this.prop.materials = mesh.material;\n this.prop.geom = mesh.geometry;\n this.prop.geom.setAttribute(ATTR_UV, this.prop.geom.getAttribute(ATTR_ORIGINAL_UV).clone());\n\n this.prop.colSize = panorama.width / panorama.cols;\n this.prop.rowSize = panorama.width / 2 / panorama.rows;\n this.prop.facesByCol = this.SPHERE_SEGMENTS / panorama.cols;\n this.prop.facesByRow = this.SPHERE_HORIZONTAL_SEGMENTS / panorama.rows;\n\n // this.psv.renderer.scene.add(createWireFrame(this.prop.geom));\n\n setTimeout(() => this.__refresh(true));\n }\n\n /**\n * @private\n */\n __setTexture(mesh, texture) {\n let material;\n if (texture) {\n material = new THREE.MeshBasicMaterial({ map: texture });\n }\n else {\n material = new THREE.MeshBasicMaterial({ opacity: 0, transparent: true });\n }\n\n for (let i = 0; i < this.NB_GROUPS; i++) {\n mesh.material.push(material);\n }\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n mesh.material[0].opacity = opacity;\n mesh.material[0].transparent = opacity < 1;\n }\n\n /**\n * @summary Compute visible tiles and load them\n * @param {boolean} [init=false] Indicates initial call\n * @private\n */\n __refresh(init = false) { // eslint-disable-line no-unused-vars\n if (!this.prop.geom) {\n return;\n }\n\n const camera = this.psv.renderer.camera;\n camera.updateMatrixWorld();\n projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n frustum.setFromProjectionMatrix(projScreenMatrix);\n\n const panorama = this.psv.config.panorama;\n const verticesPosition = this.prop.geom.getAttribute(ATTR_POSITION);\n const tilesToLoad = [];\n\n for (let col = 0; col < panorama.cols; col++) {\n for (let row = 0; row < panorama.rows; row++) {\n // for each tile, find the vertices corresponding to the four corners (three for first and last rows)\n // if at least one vertex is visible, the tile must be loaded\n // for larger tiles we also test the four edges centers and the tile center\n\n const verticesIndex = [];\n\n if (row === 0) {\n // bottom-left\n const v0 = this.prop.facesByRow === 1\n ? col * this.prop.facesByCol * this.NB_VERTICES_BY_SMALL_FACE + 1\n : this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + (this.prop.facesByRow - 2) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_FACE + 4;\n\n // bottom-right\n const v1 = this.prop.facesByRow === 1\n ? v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_SMALL_FACE + 1\n : v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE + 1;\n\n // top (all vertices are equal)\n const v2 = 0;\n\n verticesIndex.push(v0, v1, v2);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // bottom-center\n const v4 = v0 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4);\n }\n\n if (this.prop.facesByRow >= this.SPHERE_HORIZONTAL_SEGMENTS / 4) {\n // left-center\n const v6 = v0 - this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n // right-center\n const v7 = v1 - this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v6, v7);\n }\n }\n else if (row === panorama.rows - 1) {\n // top-left\n const v0 = this.prop.facesByRow === 1\n ? -this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + row * this.prop.facesByRow * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_SMALL_FACE + 1\n : -this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + row * this.prop.facesByRow * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_FACE + 1;\n\n // top-right\n const v1 = this.prop.facesByRow === 1\n ? v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_SMALL_FACE - 1\n : v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE - 1;\n\n // bottom (all vertices are equal)\n const v2 = this.NB_VERTICES - 1;\n\n verticesIndex.push(v0, v1, v2);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // top-center\n const v4 = v0 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4);\n }\n\n if (this.prop.facesByRow >= this.SPHERE_HORIZONTAL_SEGMENTS / 4) {\n // left-center\n const v6 = v0 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n // right-center\n const v7 = v1 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v6, v7);\n }\n }\n else {\n // top-left\n const v0 = -this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + row * this.prop.facesByRow * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + col * this.prop.facesByCol * this.NB_VERTICES_BY_FACE + 1;\n\n // bottom-left\n const v1 = v0 + (this.prop.facesByRow - 1) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE + 3;\n\n // bottom-right\n const v2 = v1 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE + 1;\n\n // top-right\n const v3 = v0 + (this.prop.facesByCol - 1) * this.NB_VERTICES_BY_FACE - 1;\n\n verticesIndex.push(v0, v1, v2, v3);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // top-center\n const v4 = v0 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n // bottom-center\n const v5 = v1 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v4, v5);\n }\n\n if (this.prop.facesByRow >= this.SPHERE_HORIZONTAL_SEGMENTS / 4) {\n // left-center\n const v6 = v0 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n // right-center\n const v7 = v3 + this.prop.facesByRow / 2 * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v6, v7);\n\n if (this.prop.facesByCol >= this.SPHERE_SEGMENTS / 8) {\n // center-center\n const v8 = v6 + this.prop.facesByCol / 2 * this.NB_VERTICES_BY_FACE;\n\n verticesIndex.push(v8);\n }\n }\n }\n\n // if (init && col === 0 && row === 0) {\n // verticesIndex.forEach((vertexIdx) => {\n // this.psv.renderer.scene.add(createDot(\n // verticesPosition.getX(vertexIdx),\n // verticesPosition.getY(vertexIdx),\n // verticesPosition.getZ(vertexIdx)\n // ));\n // });\n // }\n\n const vertexVisible = verticesIndex.some((vertexIdx) => {\n vertexPosition.set(\n verticesPosition.getX(vertexIdx),\n verticesPosition.getY(vertexIdx),\n verticesPosition.getZ(vertexIdx)\n );\n vertexPosition.applyEuler(this.psv.renderer.meshContainer.rotation);\n return frustum.containsPoint(vertexPosition);\n });\n\n if (vertexVisible) {\n let angle = vertexPosition.angleTo(this.psv.prop.direction);\n if (row === 0 || row === panorama.rows - 1) {\n angle *= 2; // lower priority to top and bottom tiles\n }\n tilesToLoad.push({ col, row, angle });\n }\n }\n }\n\n this.__loadTiles(tilesToLoad);\n }\n\n /**\n * @summary Loads tiles and change existing tiles priority\n * @param {PSV.adapters.EquirectangularTilesAdapter.Tile[]} tiles\n * @private\n */\n __loadTiles(tiles) {\n this.queue.disableAllTasks();\n\n tiles.forEach((tile) => {\n const id = tileId(tile);\n\n if (this.prop.tiles[id]) {\n this.queue.setPriority(id, tile.angle);\n }\n else {\n this.prop.tiles[id] = true;\n this.queue.enqueue(new Task(id, tile.angle, task => this.__loadTile(tile, task)));\n }\n });\n\n this.queue.start();\n }\n\n /**\n * @summary Loads and draw a tile\n * @param {PSV.adapters.EquirectangularTilesAdapter.Tile} tile\n * @param {PSV.adapters.Task} task\n * @return {Promise}\n * @private\n */\n __loadTile(tile, task) {\n const panorama = this.psv.config.panorama;\n const url = panorama.tileUrl(tile.col, tile.row);\n\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders(url));\n }\n\n return new Promise((resolve, reject) => {\n this.loader.load(url, resolve, undefined, reject);\n })\n .then((image) => {\n if (!task.isCancelled()) {\n const material = new THREE.MeshBasicMaterial({ map: utils.createTexture(image) });\n this.__swapMaterial(tile.col, tile.row, material);\n this.psv.needsUpdate();\n }\n })\n .catch(() => {\n if (!task.isCancelled() && this.config.showErrorTile) {\n if (!this.prop.errorMaterial) {\n this.prop.errorMaterial = buildErrorMaterial(this.prop.colSize, this.prop.rowSize);\n }\n this.__swapMaterial(tile.col, tile.row, this.prop.errorMaterial);\n this.psv.needsUpdate();\n }\n });\n }\n\n /**\n * @summary Applies a new texture to the faces\n * @param {int} col\n * @param {int} row\n * @param {external:THREE.MeshBasicMaterial} material\n * @private\n */\n __swapMaterial(col, row, material) {\n const uvs = this.prop.geom.getAttribute(ATTR_UV);\n\n for (let c = 0; c < this.prop.facesByCol; c++) {\n for (let r = 0; r < this.prop.facesByRow; r++) {\n // position of the face (two triangles of the same square)\n const faceCol = col * this.prop.facesByCol + c;\n const faceRow = row * this.prop.facesByRow + r;\n const isFirstRow = faceRow === 0;\n const isLastRow = faceRow === (this.SPHERE_HORIZONTAL_SEGMENTS - 1);\n\n // first vertex for this face (3 or 6 vertices in total)\n let firstVertex;\n if (isFirstRow) {\n firstVertex = faceCol * this.NB_VERTICES_BY_SMALL_FACE;\n }\n else if (isLastRow) {\n firstVertex = this.NB_VERTICES\n - this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + faceCol * this.NB_VERTICES_BY_SMALL_FACE;\n }\n else {\n firstVertex = this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_SMALL_FACE\n + (faceRow - 1) * this.SPHERE_SEGMENTS * this.NB_VERTICES_BY_FACE\n + faceCol * this.NB_VERTICES_BY_FACE;\n }\n\n // swap material\n const matIndex = this.prop.geom.groups.find(g => g.start === firstVertex).materialIndex;\n this.prop.materials[matIndex] = material;\n\n // define new uvs\n const top = 1 - r / this.prop.facesByRow;\n const bottom = 1 - (r + 1) / this.prop.facesByRow;\n const left = c / this.prop.facesByCol;\n const right = (c + 1) / this.prop.facesByCol;\n\n if (isFirstRow) {\n uvs.setXY(firstVertex, (left + right) / 2, top);\n uvs.setXY(firstVertex + 1, left, bottom);\n uvs.setXY(firstVertex + 2, right, bottom);\n }\n else if (isLastRow) {\n uvs.setXY(firstVertex, right, top);\n uvs.setXY(firstVertex + 1, left, top);\n uvs.setXY(firstVertex + 2, (left + right) / 2, bottom);\n }\n else {\n uvs.setXY(firstVertex, right, top);\n uvs.setXY(firstVertex + 1, left, top);\n uvs.setXY(firstVertex + 2, right, bottom);\n uvs.setXY(firstVertex + 3, left, top);\n uvs.setXY(firstVertex + 4, left, bottom);\n uvs.setXY(firstVertex + 5, right, bottom);\n }\n }\n }\n\n uvs.needsUpdate = true;\n }\n\n /**\n * @summary Create the texture for the base image\n * @param {HTMLImageElement} img\n * @return {external:THREE.Texture}\n * @private\n */\n __createBaseTexture(img) {\n if (img.width !== img.height * 2) {\n utils.logWarn('Invalid base image, the width should be twice the height');\n }\n\n return createBaseTexture(img, this.config.baseBlur, w => w / 2);\n }\n\n}\n"],"names":["Task","id","priority","fn","status","STATUS","PENDING","start","RUNNING","then","DONE","ERROR","cancel","CANCELLED","isCancelled","DISABLED","Queue","concurency","runningTasks","tasks","enqueue","task","clear","Object","values","forEach","setPriority","taskId","disableAllTasks","keys","length","nextTask","filter","sort","a","b","pop","buildErrorMaterial","width","height","canvas","document","createElement","ctx","getContext","fillStyle","fillRect","font","textAlign","textBaseline","fillText","texture","THREE","CanvasTexture","MeshBasicMaterial","map","createBaseTexture","img","blur","getHeight","SYSTEM","maxTextureWidth","ratio","Math","min","getMaxCanvasWidth","buffer","drawImage","utils","createTexture","ATTR_UV","ATTR_ORIGINAL_UV","ATTR_POSITION","tileId","tile","col","row","frustum","Frustum","projScreenMatrix","Matrix4","vertexPosition","Vector3","EquirectangularTilesAdapter","psv","options","config","useXmpData","resolution","showErrorTile","baseBlur","isPowerOfTwo","PSVError","SPHERE_SEGMENTS","SPHERE_HORIZONTAL_SEGMENTS","NB_VERTICES_BY_FACE","NB_VERTICES_BY_SMALL_FACE","NB_VERTICES","NB_GROUPS","queue","prop","colSize","rowSize","facesByCol","facesByRow","tiles","geom","materials","errorMaterial","loader","ImageLoader","withCredentials","setWithCredentials","requestHeaders","setRequestHeader","on","CONSTANTS","EVENTS","POSITION_UPDATED","ZOOM_UPDATED","destroy","off","__cleanup","dispose","handleEvent","e","type","__refresh","mat","supportsTransition","panorama","baseUrl","supportsPreload","loadTexture","cols","rows","tileUrl","Promise","reject","panoData","fullWidth","fullHeight","croppedWidth","croppedHeight","croppedX","croppedY","poseHeading","posePitch","poseRoll","textureData","resolve","createMesh","scale","geometry","SphereGeometry","SPHERE_RADIUS","PI","toNonIndexed","clearGroups","i","k","addGroup","setAttribute","getAttribute","clone","Mesh","setTexture","mesh","transition","__setTexture","material","setTimeout","opacity","transparent","push","setTextureOpacity","init","camera","renderer","updateMatrixWorld","multiplyMatrices","projectionMatrix","matrixWorldInverse","setFromProjectionMatrix","verticesPosition","tilesToLoad","verticesIndex","v0","v1","v2","v4","v6","v7","v3","v5","v8","vertexVisible","some","vertexIdx","set","getX","getY","getZ","applyEuler","meshContainer","rotation","containsPoint","angle","angleTo","direction","__loadTiles","__loadTile","url","load","undefined","image","__swapMaterial","needsUpdate","catch","uvs","c","r","faceCol","faceRow","isFirstRow","isLastRow","firstVertex","matIndex","groups","find","g","materialIndex","top","bottom","left","right","setXY","__createBaseTexture","logWarn","w","EquirectangularAdapter","supportsDownload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;MACaA,IAAb;EAWE;EACF;EACA;EACA;EACA;EACE,gBAAYC,EAAZ,EAAgBC,QAAhB,EAA0BC,EAA1B,EAA8B;EAC5B,SAAKF,EAAL,GAAUA,EAAV;EACA,SAAKC,QAAL,GAAgBA,QAAhB;EACA,SAAKC,EAAL,GAAUA,EAAV;EACA,SAAKC,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYC,OAA1B;EACD;;EArBH;;EAAA,SAuBEC,KAvBF,GAuBE,iBAAQ;EAAA;;EACN,SAAKH,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYG,OAA1B;EACA,WAAO,KAAKL,EAAL,CAAQ,IAAR,EACJM,IADI,CACC,YAAM;EACV,MAAA,KAAI,CAACL,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYK,IAA1B;EACD,KAHI,EAGF,YAAM;EACP,MAAA,KAAI,CAACN,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYM,KAA1B;EACD,KALI,CAAP;EAMD,GA/BH;;EAAA,SAiCEC,MAjCF,GAiCE,kBAAS;EACP,SAAKR,MAAL,GAAcJ,IAAI,CAACK,MAAL,CAAYQ,SAA1B;EACD,GAnCH;;EAAA,SAqCEC,WArCF,GAqCE,uBAAc;EACZ,WAAO,KAAKV,MAAL,KAAgBJ,IAAI,CAACK,MAAL,CAAYQ,SAAnC;EACD,GAvCH;;EAAA;EAAA;EAAab,KAEJK,SAAS;EACdU,EAAAA,QAAQ,EAAG,CAAC,CADE;EA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AA2BS,KAA3B,EAAkCF,MAAlC;EACD;EAnD0C;;EAC7C,WAAK,IAAIZ,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,KAAKzH,IAAL,CAAUI,UAA9B,EAA0CqH,CAAC,EAA3C,EAA+C;EAAA,cAAtCA,CAAsC;EAmD9C;EACF;;EAEDF,IAAAA,GAAG,CAACF,WAAJ,GAAkB,IAAlB;EACD;EAED;EACF;EACA;EACA;EACA;EACA;EA1kBA;;EAAA,SA2kBEoB,mBA3kBF,GA2kBE,6BAAoBpL,GAApB,EAAyB;EACvB,QAAIA,GAAG,CAACnB,KAAJ,KAAcmB,GAAG,CAAClB,MAAJ,GAAa,CAA/B,EAAkC;EAChC6B,MAAAA,uBAAK,CAAC0K,OAAN,CAAc,0DAAd;EACD;;EAED,WAAOtL,iBAAiB,CAACC,GAAD,EAAM,KAAK6B,MAAL,CAAYI,QAAlB,EAA4B,UAAAqJ,CAAC;EAAA,aAAIA,CAAC,GAAG,CAAR;EAAA,KAA7B,CAAxB;EACD,GAjlBH;;EAAA;EAAA,EAAiDC,wCAAjD;EAAa7J,4BAEJlF,KAAK;EAFDkF,4BAGJ8J,mBAAmB;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/adapters/equirectangular-video.d.ts b/dist/adapters/equirectangular-video.d.ts new file mode 100644 index 000000000..7b4614ef7 --- /dev/null +++ b/dist/adapters/equirectangular-video.d.ts @@ -0,0 +1,25 @@ +import { AbstractAdapter, Viewer } from 'photo-sphere-viewer'; + +/** + * @summary Configuration of an equirectangular video + */ +type EquirectangularVideoPanorama = { + source: string; +}; + +type EquirectangularVideoAdapterOptions = { + autoplay?: boolean; + muted?: boolean; + resolution?: number; +} + +/** + * @summary Adapter for equirectangular videos + */ +declare class EquirectangularVideoAdapter extends AbstractAdapter { + + constructor(psv: Viewer, options: EquirectangularVideoAdapterOptions); + +} + +export { EquirectangularVideoAdapter, EquirectangularVideoAdapterOptions, EquirectangularVideoPanorama }; diff --git a/dist/adapters/equirectangular-video.js b/dist/adapters/equirectangular-video.js new file mode 100644 index 000000000..c4b985025 --- /dev/null +++ b/dist/adapters/equirectangular-video.js @@ -0,0 +1,415 @@ +/*! +* Photo Sphere Viewer 4.6.0 +* @copyright 2014-2015 Jérémy Heleine +* @copyright 2015-2022 Damien "Mistic" Sorel +* @licence MIT (https://opensource.org/licenses/MIT) +*/ +(function (global, factory) { + 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.EquirectangularVideoAdapter = {}), global.THREE, global.PhotoSphereViewer)); +})(this, (function (exports, THREE, photoSphereViewer) { 'use strict'; + + 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) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + + _setPrototypeOf(subClass, superClass); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + /** + * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Video + * @summary Object defining a video + * @property {string} source + */ + + /** + * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Options + * @property {boolean} [autoplay=false] - automatically start the video + * @property {boolean} [muted=autoplay] - initially mute the video + */ + + /** + * @summary Base video adapters class + * @memberof PSV.adapters + * @abstract + * @private + */ + + var AbstractVideoAdapter = /*#__PURE__*/function (_AbstractAdapter) { + _inheritsLoose(AbstractVideoAdapter, _AbstractAdapter); + + function AbstractVideoAdapter(psv, options) { + var _options$autoplay; + + var _this; + + _this = _AbstractAdapter.call(this, psv) || this; + /** + * @member {PSV.adapters.AbstractVideoAdapter.Options} + * @private + */ + + _this.config = _extends({ + autoplay: false, + muted: (_options$autoplay = options == null ? void 0 : options.autoplay) != null ? _options$autoplay : false + }, options); + /** + * @member {HTMLVideoElement} + * @private + */ + + _this.video = null; + + _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, _assertThisInitialized(_this)); + + return _this; + } + /** + * @override + */ + + + var _proto = AbstractVideoAdapter.prototype; + + _proto.destroy = function destroy() { + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this); + + this.__removeVideo(); + + _AbstractAdapter.prototype.destroy.call(this); + } + /** + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER: + if (this.video) { + this.psv.needsUpdate(); + } + + break; + } + /* eslint-enable */ + + } + /** + * @override + * @param {PSV.adapters.AbstractVideoAdapter.Video} panorama + * @returns {Promise.} + */ + ; + + _proto.loadTexture = function loadTexture(panorama) { + if (typeof panorama !== 'object' || !panorama.source) { + return Promise.reject(new photoSphereViewer.PSVError('Invalid panorama configuration, are you using the right adapter?')); + } + + if (!this.psv.getPlugin('video')) { + return Promise.reject(new photoSphereViewer.PSVError('Video adapters require VideoPlugin to be loaded too.')); + } + + var video = this.__createVideo(panorama.source); + + return this.__videoLoadPromise(video).then(function () { + var texture = new THREE.VideoTexture(video); + return { + panorama: panorama, + texture: texture + }; + }); + } + /** + * @override + */ + ; + + _proto.__switchVideo = function __switchVideo(texture) { + var currentTime; + var duration; + var paused = !this.config.autoplay; + var muted = this.config.muted; + var volume = 1; + + if (this.video) { + var _this$video = this.video; + currentTime = _this$video.currentTime; + duration = _this$video.duration; + paused = _this$video.paused; + muted = _this$video.muted; + volume = _this$video.volume; + } + + this.__removeVideo(); + + this.video = texture.image; // keep current time when switching resolution + + if (this.video.duration === duration) { + this.video.currentTime = currentTime; + } // keep volume + + + this.video.muted = muted; + this.video.volume = volume; // play + + if (!paused) { + this.video.play(); + } + } + /** + * @override + */ + ; + + _proto.disposeTexture = function disposeTexture(textureData) { + var _textureData$texture; + + if (textureData.texture) { + var video = textureData.texture.image; + video.pause(); + this.psv.container.removeChild(video); + } + + (_textureData$texture = textureData.texture) == null ? void 0 : _textureData$texture.dispose(); + } + /** + * @summary Removes the current video element + * @private + */ + ; + + _proto.__removeVideo = function __removeVideo() { + if (this.video) { + this.video.pause(); + this.psv.container.removeChild(this.video); + delete this.video; + } + } + /** + * @summary Creates a new video element + * @memberOf PSV.adapters + * @param {string} src + * @return {HTMLVideoElement} + * @private + */ + ; + + _proto.__createVideo = function __createVideo(src) { + var video = document.createElement('video'); + video.crossOrigin = this.psv.config.withCredentials ? 'use-credentials' : 'anonymous'; + video.loop = true; + video.style.display = 'none'; + video.muted = this.config.muted; + video.src = src; + video.preload = 'metadata'; + this.psv.container.appendChild(video); + return video; + } + /** + * @private + */ + ; + + _proto.__videoLoadPromise = function __videoLoadPromise(video) { + var self = this; + return new Promise(function (resolve, reject) { + video.addEventListener('loadedmetadata', function onLoaded() { + if (this.video && video.duration === this.video.duration) { + resolve(self.__videoBufferPromise(video, this.video.currentTime)); + } else { + resolve(); + } + + video.removeEventListener('loadedmetadata', onLoaded); + }); + video.addEventListener('error', function onError(err) { + reject(err); + video.removeEventListener('error', onError); + }); + }); + } + /** + * @private + */ + ; + + _proto.__videoBufferPromise = function __videoBufferPromise(video, currentTime) { + return new Promise(function (resolve) { + function onBuffer() { + var buffer = video.buffered; + + for (var i = 0, l = buffer.length; i < l; i++) { + if (buffer.start(i) <= video.currentTime && buffer.end(i) >= video.currentTime) { + video.pause(); + video.removeEventListener('buffer', onBuffer); + video.removeEventListener('progress', onBuffer); + resolve(); + break; + } + } + } // try to reduce the switching time by preloading in advance + // FIXME find a better way ? + + + video.currentTime = Math.min(currentTime + 2000, video.duration.currentTime); + video.muted = true; + video.addEventListener('buffer', onBuffer); + video.addEventListener('progress', onBuffer); + video.play(); + }); + }; + + return AbstractVideoAdapter; + }(photoSphereViewer.AbstractAdapter); + AbstractVideoAdapter.supportsTransition = false; + AbstractVideoAdapter.supportsPreload = false; + AbstractVideoAdapter.supportsDownload = true; + + /** + * @typedef {Object} PSV.adapters.EquirectangularVideoAdapter.Video + * @summary Object defining a video + * @property {string} source + */ + + /** + * @typedef {Object} PSV.adapters.EquirectangularVideoAdapter.Options + * @property {boolean} [autoplay=false] - automatically start the video + * @property {boolean} [muted=autoplay] - initially mute the video + * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances + */ + + /** + * @summary Adapter for equirectangular videos + * @memberof PSV.adapters + * @extends PSV.adapters.AbstractAdapter + */ + + var EquirectangularVideoAdapter = /*#__PURE__*/function (_AbstractVideoAdapter) { + _inheritsLoose(EquirectangularVideoAdapter, _AbstractVideoAdapter); + + /** + * @param {PSV.Viewer} psv + * @param {PSV.adapters.EquirectangularVideoAdapter.Options} options + */ + function EquirectangularVideoAdapter(psv, options) { + var _this; + + _this = _AbstractVideoAdapter.call(this, psv, _extends({ + resolution: 64 + }, options)) || this; + + if (!photoSphereViewer.utils.isPowerOfTwo(_this.config.resolution)) { + throw new photoSphereViewer.PSVError('EquirectangularVideoAdapter resolution must be power of two'); + } + + _this.SPHERE_SEGMENTS = _this.config.resolution; + _this.SPHERE_HORIZONTAL_SEGMENTS = _this.SPHERE_SEGMENTS / 2; + return _this; + } + /** + * @override + * @param {PSV.adapters.EquirectangularVideoAdapter.Video} panorama + * @returns {Promise.} + */ + + + var _proto = EquirectangularVideoAdapter.prototype; + + _proto.loadTexture = function loadTexture(panorama) { + return _AbstractVideoAdapter.prototype.loadTexture.call(this, panorama).then(function (_ref) { + var texture = _ref.texture; + var panoData = { + fullWidth: texture.image.width, + fullHeight: texture.image.height, + croppedWidth: texture.image.width, + croppedHeight: texture.image.height, + croppedX: 0, + croppedY: 0, + poseHeading: 0, + posePitch: 0, + poseRoll: 0 + }; + return { + panorama: panorama, + texture: texture, + panoData: panoData + }; + }); + } + /** + * @override + */ + ; + + _proto.createMesh = function createMesh(scale) { + if (scale === void 0) { + scale = 1; + } + + var geometry = new THREE.SphereGeometry(photoSphereViewer.CONSTANTS.SPHERE_RADIUS * scale, this.SPHERE_SEGMENTS, this.SPHERE_HORIZONTAL_SEGMENTS, -Math.PI / 2).scale(-1, 1, 1); + var material = new THREE.MeshBasicMaterial(); + return new THREE.Mesh(geometry, material); + } + /** + * @override + */ + ; + + _proto.setTexture = function setTexture(mesh, textureData) { + var _mesh$material$map; + + (_mesh$material$map = mesh.material.map) == null ? void 0 : _mesh$material$map.dispose(); + mesh.material.map = textureData.texture; + + this.__switchVideo(textureData.texture); + }; + + return EquirectangularVideoAdapter; + }(AbstractVideoAdapter); + EquirectangularVideoAdapter.id = 'equirectangular-video'; + + exports.EquirectangularVideoAdapter = EquirectangularVideoAdapter; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=equirectangular-video.js.map diff --git a/dist/adapters/equirectangular-video.js.map b/dist/adapters/equirectangular-video.js.map new file mode 100644 index 000000000..59eb710f5 --- /dev/null +++ b/dist/adapters/equirectangular-video.js.map @@ -0,0 +1 @@ +{"version":3,"file":"equirectangular-video.js","sources":["../../src/adapters/shared/AbstractVideoAdapter.js","../../src/adapters/equirectangular-video/index.js"],"sourcesContent":["import * as THREE from 'three';\nimport { AbstractAdapter, CONSTANTS, PSVError } from '../..';\n\n/**\n * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Video\n * @summary Object defining a video\n * @property {string} source\n */\n\n/**\n * @typedef {Object} PSV.adapters.AbstractVideoAdapter.Options\n * @property {boolean} [autoplay=false] - automatically start the video\n * @property {boolean} [muted=autoplay] - initially mute the video\n */\n\n/**\n * @summary Base video adapters class\n * @memberof PSV.adapters\n * @abstract\n * @private\n */\nexport class AbstractVideoAdapter extends AbstractAdapter {\n\n static supportsTransition = false;\n static supportsPreload = false;\n static supportsDownload = true;\n\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.AbstractVideoAdapter.Options}\n * @private\n */\n this.config = {\n autoplay: false,\n muted : options?.autoplay ?? false,\n ...options,\n };\n\n /**\n * @member {HTMLVideoElement}\n * @private\n */\n this.video = null;\n\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n\n this.__removeVideo();\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.BEFORE_RENDER:\n if (this.video) {\n this.psv.needsUpdate();\n }\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @param {PSV.adapters.AbstractVideoAdapter.Video} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n if (typeof panorama !== 'object' || !panorama.source) {\n return Promise.reject(new PSVError('Invalid panorama configuration, are you using the right adapter?'));\n }\n\n if (!this.psv.getPlugin('video')) {\n return Promise.reject(new PSVError('Video adapters require VideoPlugin to be loaded too.'));\n }\n\n const video = this.__createVideo(panorama.source);\n\n return this.__videoLoadPromise(video)\n .then(() => {\n const texture = new THREE.VideoTexture(video);\n return { panorama, texture };\n });\n }\n\n /**\n * @override\n */\n __switchVideo(texture) {\n let currentTime;\n let duration;\n let paused = !this.config.autoplay;\n let muted = this.config.muted;\n let volume = 1;\n if (this.video) {\n ({ currentTime, duration, paused, muted, volume } = this.video);\n }\n\n this.__removeVideo();\n this.video = texture.image;\n\n // keep current time when switching resolution\n if (this.video.duration === duration) {\n this.video.currentTime = currentTime;\n }\n\n // keep volume\n this.video.muted = muted;\n this.video.volume = volume;\n\n // play\n if (!paused) {\n this.video.play();\n }\n }\n\n /**\n * @override\n */\n disposeTexture(textureData) {\n if (textureData.texture) {\n const video = textureData.texture.image;\n video.pause();\n this.psv.container.removeChild(video);\n }\n textureData.texture?.dispose();\n }\n\n /**\n * @summary Removes the current video element\n * @private\n */\n __removeVideo() {\n if (this.video) {\n this.video.pause();\n this.psv.container.removeChild(this.video);\n delete this.video;\n }\n }\n\n /**\n * @summary Creates a new video element\n * @memberOf PSV.adapters\n * @param {string} src\n * @return {HTMLVideoElement}\n * @private\n */\n __createVideo(src) {\n const video = document.createElement('video');\n video.crossOrigin = this.psv.config.withCredentials ? 'use-credentials' : 'anonymous';\n video.loop = true;\n video.style.display = 'none';\n video.muted = this.config.muted;\n video.src = src;\n video.preload = 'metadata';\n\n this.psv.container.appendChild(video);\n\n return video;\n }\n\n /**\n * @private\n */\n __videoLoadPromise(video) {\n const self = this;\n\n return new Promise((resolve, reject) => {\n video.addEventListener('loadedmetadata', function onLoaded() {\n if (this.video && video.duration === this.video.duration) {\n resolve(self.__videoBufferPromise(video, this.video.currentTime));\n }\n else {\n resolve();\n }\n video.removeEventListener('loadedmetadata', onLoaded);\n });\n\n video.addEventListener('error', function onError(err) {\n reject(err);\n video.removeEventListener('error', onError);\n });\n });\n }\n\n /**\n * @private\n */\n __videoBufferPromise(video, currentTime) {\n return new Promise((resolve) => {\n function onBuffer() {\n const buffer = video.buffered;\n for (let i = 0, l = buffer.length; i < l; i++) {\n if (buffer.start(i) <= video.currentTime && buffer.end(i) >= video.currentTime) {\n video.pause();\n video.removeEventListener('buffer', onBuffer);\n video.removeEventListener('progress', onBuffer);\n resolve();\n break;\n }\n }\n }\n\n // try to reduce the switching time by preloading in advance\n // FIXME find a better way ?\n video.currentTime = Math.min(currentTime + 2000, video.duration.currentTime);\n video.muted = true;\n\n video.addEventListener('buffer', onBuffer);\n video.addEventListener('progress', onBuffer);\n\n video.play();\n });\n }\n\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, PSVError, utils } from '../..';\nimport { AbstractVideoAdapter } from '../shared/AbstractVideoAdapter';\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularVideoAdapter.Video\n * @summary Object defining a video\n * @property {string} source\n */\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularVideoAdapter.Options\n * @property {boolean} [autoplay=false] - automatically start the video\n * @property {boolean} [muted=autoplay] - initially mute the video\n * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances\n */\n\n\n/**\n * @summary Adapter for equirectangular videos\n * @memberof PSV.adapters\n * @extends PSV.adapters.AbstractAdapter\n */\nexport class EquirectangularVideoAdapter extends AbstractVideoAdapter {\n\n static id = 'equirectangular-video';\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.EquirectangularVideoAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv, {\n resolution: 64,\n ...options,\n });\n\n if (!utils.isPowerOfTwo(this.config.resolution)) {\n throw new PSVError('EquirectangularVideoAdapter resolution must be power of two');\n }\n\n this.SPHERE_SEGMENTS = this.config.resolution;\n this.SPHERE_HORIZONTAL_SEGMENTS = this.SPHERE_SEGMENTS / 2;\n }\n\n /**\n * @override\n * @param {PSV.adapters.EquirectangularVideoAdapter.Video} panorama\n * @returns {Promise.}\n */\n loadTexture(panorama) {\n return super.loadTexture(panorama)\n .then(({ texture }) => {\n const panoData = {\n fullWidth : texture.image.width,\n fullHeight : texture.image.height,\n croppedWidth : texture.image.width,\n croppedHeight: texture.image.height,\n croppedX : 0,\n croppedY : 0,\n poseHeading : 0,\n posePitch : 0,\n poseRoll : 0,\n };\n\n return { panorama, texture, panoData };\n });\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n const geometry = new THREE.SphereGeometry(\n CONSTANTS.SPHERE_RADIUS * scale,\n this.SPHERE_SEGMENTS,\n this.SPHERE_HORIZONTAL_SEGMENTS,\n -Math.PI / 2\n )\n .scale(-1, 1, 1);\n\n const material = new THREE.MeshBasicMaterial();\n\n return new THREE.Mesh(geometry, material);\n }\n\n /**\n * @override\n */\n setTexture(mesh, textureData) {\n mesh.material.map?.dispose();\n mesh.material.map = textureData.texture;\n\n this.__switchVideo(textureData.texture);\n }\n\n}\n"],"names":["AbstractVideoAdapter","psv","options","config","autoplay","muted","video","on","CONSTANTS","EVENTS","BEFORE_RENDER","destroy","off","__removeVideo","handleEvent","e","type","needsUpdate","loadTexture","panorama","source","Promise","reject","PSVError","getPlugin","__createVideo","__videoLoadPromise","then","texture","THREE","VideoTexture","__switchVideo","currentTime","duration","paused","volume","image","play","disposeTexture","textureData","pause","container","removeChild","dispose","src","document","createElement","crossOrigin","withCredentials","loop","style","display","preload","appendChild","self","resolve","addEventListener","onLoaded","__videoBufferPromise","removeEventListener","onError","err","onBuffer","buffer","buffered","i","l","length","start","end","Math","min","AbstractAdapter","supportsTransition","supportsPreload","supportsDownload","EquirectangularVideoAdapter","resolution","utils","isPowerOfTwo","SPHERE_SEGMENTS","SPHERE_HORIZONTAL_SEGMENTS","panoData","fullWidth","width","fullHeight","height","croppedWidth","croppedHeight","croppedX","croppedY","poseHeading","posePitch","poseRoll","createMesh","scale","geometry","SphereGeometry","SPHERE_RADIUS","PI","material","MeshBasicMaterial","Mesh","setTexture","mesh","map","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;MACaA,oBAAb;EAAA;;EAME,gCAAYC,GAAZ,EAAiBC,OAAjB,EAA0B;EAAA;;EAAA;;EACxB,wCAAMD,GAAN;EAEA;EACJ;EACA;EACA;;EACI,UAAKE,MAAL;EACEC,MAAAA,QAAQ,EAAE,KADZ;EAEEC,MAAAA,KAAK,uBAAKH,OAAL,oBAAKA,OAAO,CAAEE,QAAd,gCAA0B;EAFjC,OAGKF,OAHL;EAMA;EACJ;EACA;EACA;;EACI,UAAKI,KAAL,GAAa,IAAb;;EAEA,UAAKL,GAAL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QAAL,CAAcK,GAAd,GAAoBlE,WAAW,CAACX,OAAhC;;EAEA,SAAKG,aAAL,CAAmBQ,WAAW,CAACX,OAA/B;EACD,GAvEH;;EAAA;EAAA,EAAiD5B,oBAAjD;EAAa4E,4BAEJ8B,KAAK;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/photo-sphere-viewer.css b/dist/photo-sphere-viewer.css index f5a7851d9..54911ec35 100644 --- a/dist/photo-sphere-viewer.css +++ b/dist/photo-sphere-viewer.css @@ -1,5 +1,5 @@ /*! - * Photo Sphere Viewer 4.5.3 + * Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -146,7 +146,7 @@ pointer-events: none; opacity: 0.5; } -.psv-button .psv-button-svg { +.psv-button-svg { width: 100%; -webkit-transform: scale(1); transform: scale(1); @@ -420,7 +420,20 @@ display: block; } +.psv-panel-menu { + height: 100%; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; +} .psv-panel-menu-title { + -webkit-box-flex: 0; + -ms-flex: none; + flex: none; display: -webkit-box; display: -ms-flexbox; display: flex; @@ -436,10 +449,13 @@ margin-right: 12px; } .psv-panel-menu-list { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; list-style: none; margin: 0; padding: 0; - overflow: hidden; + overflow-x: hidden; } .psv-panel-menu-item { min-height: 20px; diff --git a/dist/photo-sphere-viewer.css.map b/dist/photo-sphere-viewer.css.map index ac6aa0a65..c6532f942 100644 --- a/dist/photo-sphere-viewer.css.map +++ b/dist/photo-sphere-viewer.css.map @@ -1 +1 @@ -{"version":3,"sources":["","index.scss"],"names":[],"mappings":"AAAA;;;;;GAAA;ACAA;EACE,WAAW;EACX,YAAY;EACZ,SAAS;EACT,UAAU;EACV,kBAAkB;EAClB,mHAAmH;EACnH,gBAAgB;AACl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C;AACA;EACE,0CAA0C;AAC5C;AACA;EACE,mDAA2C;UAA3C,2CAA2C;EAC3C,0CAAkC;UAAlC,kCAAkC;EAClC,uDAAuC;EAAvC,+CAAuC;EAAvC,uCAAuC;EAAvC,0DAAuC;AACzC;AACA;EACE,0CAA0C;AAC5C;AACA;EACE,qDAA6C;UAA7C,6CAA6C;EAC7C,yCAAiC;UAAjC,iCAAiC;EACjC,uDAAuC;EAAvC,+CAAuC;EAAvC,uCAAuC;EAAvC,0DAAuC;AACzC;AACA;EACE,uCAAuC;AACzC;AACA;EACE,oDAA4C;UAA5C,4CAA4C;EAC5C,yCAAiC;UAAjC,iCAAiC;EACjC,uDAAuC;EAAvC,+CAAuC;EAAvC,uCAAuC;EAAvC,0DAAuC;AACzC;AACA;EACE,uCAAuC;AACzC;AACA;EACE,uCAA+B;UAA/B,+BAA+B;EAC/B,UAAU;EACV,kCAA0B;UAA1B,0BAA0B;AAC5B","file":"photo-sphere-viewer.css","sourcesContent":[null,".psv-container {\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n position: relative;\n background: radial-gradient(#fff 0%, #fdfdfd 16%, #fbfbfb 33%, #f8f8f8 49%, #efefef 66%, #dfdfdf 82%, #bfbfbf 100%);\n overflow: hidden;\n}\n\n.psv-container--fullscreen {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n}\n\n.psv-canvas-container {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 0;\n transition: opacity linear 100ms;\n}\n\n.psv-canvas {\n display: block;\n}\n\n.psv-loader-container {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 80;\n}\n\n.psv-loader {\n position: relative;\n text-align: center;\n color: rgba(61, 61, 61, 0.7);\n width: 150px;\n height: 150px;\n border: 10px solid transparent;\n}\n.psv-loader::before {\n content: \"\";\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n}\n.psv-loader, .psv-loader-image, .psv-loader-text {\n display: inline-block;\n vertical-align: middle;\n}\n.psv-loader-canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n.psv-loader-text {\n font: 14px sans-serif;\n}\n\n.psv-navbar {\n display: flex;\n position: absolute;\n z-index: 90;\n bottom: -40px;\n left: 0;\n width: 100%;\n height: 40px;\n background: rgba(61, 61, 61, 0.5);\n transition: bottom ease-in-out 0.1s;\n}\n.psv-navbar--open {\n bottom: 0;\n}\n.psv-navbar, .psv-navbar * {\n box-sizing: content-box;\n}\n\n.psv-caption {\n flex: 1 1 100%;\n color: rgba(255, 255, 255, 0.7);\n overflow: hidden;\n text-align: center;\n}\n.psv-caption-icon {\n height: 20px;\n width: 20px;\n cursor: pointer;\n}\n.psv-caption-icon * {\n fill: rgba(255, 255, 255, 0.7);\n}\n.psv-caption-content {\n display: inline-block;\n padding: 10px;\n font: 16px sans-serif;\n white-space: nowrap;\n}\n\n.psv-button {\n flex: 0 0 auto;\n padding: 10px;\n position: relative;\n cursor: pointer;\n height: 20px;\n width: 20px;\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n}\n.psv-button--active {\n background: rgba(255, 255, 255, 0.2);\n}\n.psv-button--disabled {\n pointer-events: none;\n opacity: 0.5;\n}\n.psv-button .psv-button-svg {\n width: 100%;\n transform: scale(1);\n transition: transform 200ms ease;\n}\n\n.psv-button:not(.psv-button--disabled):focus-visible {\n outline: 2px dotted currentcolor;\n outline-offset: -2px;\n}\n\n.psv-container:not(.psv--is-touch) .psv-button--hover-scale:not(.psv-button--disabled):hover .psv-button-svg {\n transform: scale(1.2);\n}\n\n.psv-move-button + .psv-move-button {\n margin-left: -10px;\n}\n\n.psv-custom-button {\n width: auto;\n}\n\n.psv-autorotate-button.psv-button {\n width: 25px;\n height: 25px;\n padding: 7.5px;\n}\n\n.psv-zoom-range.psv-button {\n width: 80px;\n height: 1px;\n margin: 10px 0;\n padding: 9.5px 0;\n max-width: 600px;\n}\n.psv-zoom-range-line {\n position: relative;\n width: 80px;\n height: 1px;\n background: rgba(255, 255, 255, 0.7);\n transition: all 0.3s ease;\n}\n.psv-zoom-range-handle {\n position: absolute;\n border-radius: 50%;\n top: -3px;\n width: 7px;\n height: 7px;\n background: rgba(255, 255, 255, 0.7);\n transform: scale(1);\n transition: transform 0.3s ease;\n}\n.psv-zoom-range:not(.psv-button--disabled):hover .psv-zoom-range-line {\n box-shadow: 0 0 2px rgba(255, 255, 255, 0.7);\n}\n.psv-zoom-range:not(.psv-button--disabled):hover .psv-zoom-range-handle {\n transform: scale(1.3);\n}\n\n.psv-notification {\n position: absolute;\n z-index: 100;\n bottom: -40px;\n display: flex;\n justify-content: center;\n box-sizing: border-box;\n width: 100%;\n padding: 0 2em;\n opacity: 0;\n transition-property: opacity, bottom;\n transition-timing-function: ease-in-out;\n transition-duration: 200ms;\n}\n.psv-notification-content {\n max-width: 50em;\n background-color: rgba(61, 61, 61, 0.8);\n border-radius: 4px;\n padding: 0.5em 1em;\n font: 14px sans-serif;\n color: white;\n}\n.psv-notification--visible {\n opacity: 100;\n bottom: 80px;\n}\n\n.psv-overlay {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: absolute;\n z-index: 110;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n background: radial-gradient(#fff 0%, #fdfdfd 16%, #fbfbfb 33%, #f8f8f8 49%, #efefef 66%, #dfdfdf 82%, #bfbfbf 100%);\n color: black;\n opacity: 0.8;\n}\n.psv-overlay-image {\n margin-bottom: 4vh;\n}\n.psv-overlay-image svg {\n width: 50vw;\n}\n@media (orientation: landscape) {\n .psv-overlay-image svg {\n width: 25vw;\n }\n}\n.psv-overlay-text {\n font: 30px sans-serif;\n text-align: center;\n}\n.psv-overlay-subtext {\n font: 20px sans-serif;\n opacity: 0.8;\n text-align: center;\n}\n\n.psv-panel {\n position: absolute;\n z-index: 90;\n right: 0;\n height: 100%;\n width: 400px;\n max-width: calc(100% - 24px);\n background: rgba(10, 10, 10, 0.7);\n transform: translate3d(100%, 0, 0);\n opacity: 0;\n transition-property: opacity, transform;\n transition-timing-function: ease-in-out;\n transition-duration: 0.1s;\n cursor: default;\n margin-left: 9px;\n}\n.psv--has-navbar .psv-panel {\n height: calc(100% - 40px);\n}\n.psv-panel-close-button {\n display: none;\n position: absolute;\n top: 0;\n left: -24px;\n width: 24px;\n height: 24px;\n background: rgba(0, 0, 0, 0.9);\n}\n.psv-panel-close-button::before, .psv-panel-close-button::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 4px;\n width: 15px;\n height: 1px;\n background-color: #fff;\n transition: 0.2s ease-in-out;\n transition-property: width, left, transform;\n}\n.psv-panel-close-button::before {\n transform: rotate(45deg);\n}\n.psv-panel-close-button::after {\n transform: rotate(-45deg);\n}\n.psv-panel-close-button:hover::before, .psv-panel-close-button:hover::after {\n left: 0;\n width: 23px;\n}\n.psv-panel-close-button:hover::before {\n transform: rotate(135deg);\n}\n.psv-panel-close-button:hover::after {\n transform: rotate(45deg);\n}\n.psv-panel-resizer {\n display: none;\n position: absolute;\n top: 0;\n left: -9px;\n width: 9px;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.9);\n cursor: col-resize;\n}\n.psv-panel-resizer::before {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 1px;\n margin-top: -14.5px;\n width: 1px;\n height: 1px;\n box-shadow: 1px 0 #fff, 3px 0px #fff, 5px 0px #fff, 1px 2px #fff, 3px 2px #fff, 5px 2px #fff, 1px 4px #fff, 3px 4px #fff, 5px 4px #fff, 1px 6px #fff, 3px 6px #fff, 5px 6px #fff, 1px 8px #fff, 3px 8px #fff, 5px 8px #fff, 1px 10px #fff, 3px 10px #fff, 5px 10px #fff, 1px 12px #fff, 3px 12px #fff, 5px 12px #fff, 1px 14px #fff, 3px 14px #fff, 5px 14px #fff, 1px 16px #fff, 3px 16px #fff, 5px 16px #fff, 1px 18px #fff, 3px 18px #fff, 5px 18px #fff, 1px 20px #fff, 3px 20px #fff, 5px 20px #fff, 1px 22px #fff, 3px 22px #fff, 5px 22px #fff, 1px 24px #fff, 3px 24px #fff, 5px 24px #fff, 1px 26px #fff, 3px 26px #fff, 5px 26px #fff, 1px 28px #fff, 3px 28px #fff, 5px 28px #fff;\n background: transparent;\n}\n.psv-panel-content {\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n color: gainsboro;\n font: 16px sans-serif;\n overflow: auto;\n}\n.psv-panel-content:not(.psv-panel-content--no-margin) {\n padding: 1em;\n}\n.psv-panel-content--no-interaction {\n user-select: none;\n pointer-events: none;\n}\n.psv-panel--open {\n transform: translate3d(0, 0, 0);\n opacity: 1;\n transition-duration: 0.2s;\n}\n.psv-panel--open .psv-panel-close-button,\n.psv-panel--open .psv-panel-resizer {\n display: block;\n}\n\n.psv-panel-menu-title {\n display: flex;\n align-items: center;\n font: 24px sans-serif;\n margin: 24px 12px;\n}\n.psv-panel-menu-title svg {\n width: 24px;\n height: 24px;\n margin-right: 12px;\n}\n.psv-panel-menu-list {\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: hidden;\n}\n.psv-panel-menu-item {\n min-height: 20px;\n padding: 0.5em 1em;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n transition: background 0.1s ease-in-out;\n}\n.psv-panel-menu-item--active {\n outline: 1px solid currentcolor;\n outline-offset: -1px;\n}\n.psv-panel-menu-item-icon {\n flex: none;\n height: 20px;\n width: 20px;\n margin-right: 0.5em;\n}\n.psv-panel-menu-item-icon img {\n max-width: 100%;\n max-height: 100%;\n}\n.psv-panel-menu-item-icon svg {\n width: 100%;\n height: 100%;\n}\n.psv-panel-menu-item:focus-visible {\n outline: 1px dotted currentcolor;\n outline-offset: -1px;\n}\n.psv-panel-menu--stripped .psv-panel-menu-item:hover {\n background: rgba(255, 255, 255, 0.2);\n}\n.psv-panel-menu--stripped .psv-panel-menu-item:nth-child(odd), .psv-panel-menu--stripped .psv-panel-menu-item:nth-child(odd)::before {\n background: rgba(255, 255, 255, 0.1);\n}\n.psv-panel-menu--stripped .psv-panel-menu-item:nth-child(even), .psv-panel-menu--stripped .psv-panel-menu-item:nth-child(even)::before {\n background: transparent;\n}\n\n.psv-container:not(.psv--is-touch) .psv-panel-menu-item:hover {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.psv-tooltip {\n position: absolute;\n z-index: 50;\n box-sizing: border-box;\n max-width: 200px;\n background-color: rgba(61, 61, 61, 0.8);\n border-radius: 4px;\n padding: 0.5em 1em;\n opacity: 0;\n transition-property: opacity;\n transition-timing-function: ease-in-out;\n transition-duration: 100ms;\n outline: 5px solid transparent;\n}\n.psv-tooltip-content {\n color: white;\n font: 14px sans-serif;\n text-shadow: 0 1px #000;\n}\n.psv-tooltip-arrow {\n position: absolute;\n height: 0;\n width: 0;\n border: 7px solid transparent;\n}\n.psv-tooltip--bottom-center {\n box-shadow: 0 3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, -5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--bottom-center .psv-tooltip-arrow {\n border-bottom-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--center-left {\n box-shadow: -3px 0 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(5px, 0, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--center-left .psv-tooltip-arrow {\n border-left-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--top-center {\n box-shadow: 0 -3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, 5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--top-center .psv-tooltip-arrow {\n border-top-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--center-right {\n box-shadow: 3px 0 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(-5px, 0, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--center-right .psv-tooltip-arrow {\n border-right-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--bottom-left {\n box-shadow: -3px 3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, -5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--bottom-left .psv-tooltip-arrow {\n border-bottom-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--bottom-right {\n box-shadow: 3px 3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, -5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--bottom-right .psv-tooltip-arrow {\n border-bottom-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--top-left {\n box-shadow: -3px -3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, 5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--top-left .psv-tooltip-arrow {\n border-top-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--top-right {\n box-shadow: 3px -3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, 5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--top-right .psv-tooltip-arrow {\n border-top-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--visible {\n transform: translate3d(0, 0, 0);\n opacity: 1;\n transition-duration: 100ms;\n}"]} \ No newline at end of file +{"version":3,"sources":["","index.scss"],"names":[],"mappings":"AAAA;;;;;GAAA;ACAA;EACE,WAAW;EACX,YAAY;EACZ,SAAS;EACT,UAAU;EACV,kBAAkB;EAClB,mHAAmH;EACnH,gBAAgB;AAClB;;AAEA;EACE,eAAe;EACf,MAAM;EACN,QAAQ;EACR,SAAS;EACT,OAAO;AACT;;AAEA;EACE,kBAAkB;EAClB,MAAM;EACN,OAAO;EACP,UAAU;EACV,wCAAgC;EAAhC,gCAAgC;AAClC;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;EACnB,wBAAuB;MAAvB,qBAAuB;UAAvB,uBAAuB;EACvB,kBAAkB;EAClB,MAAM;EACN,OAAO;EACP,WAAW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AA0C;AAC5C;AACA;EACE,qDAA6C;UAA7C,6CAA6C;EAC7C,yCAAiC;UAAjC,iCAAiC;EACjC,uDAAuC;EAAvC,+CAAuC;EAAvC,uCAAuC;EAAvC,0DAAuC;AACzC;AACA;EACE,uCAAuC;AACzC;AACA;EACE,oDAA4C;UAA5C,4CAA4C;EAC5C,yCAAiC;UAAjC,iCAAiC;EACjC,uDAAuC;EAAvC,+CAAuC;EAAvC,uCAAuC;EAAvC,0DAAuC;AACzC;AACA;EACE,uCAAuC;AACzC;AACA;EACE,uCAA+B;UAA/B,+BAA+B;EAC/B,UAAU;EACV,kCAA0B;UAA1B,0BAA0B;AAC5B","file":"photo-sphere-viewer.css","sourcesContent":[null,".psv-container {\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n position: relative;\n background: radial-gradient(#fff 0%, #fdfdfd 16%, #fbfbfb 33%, #f8f8f8 49%, #efefef 66%, #dfdfdf 82%, #bfbfbf 100%);\n overflow: hidden;\n}\n\n.psv-container--fullscreen {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n}\n\n.psv-canvas-container {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 0;\n transition: opacity linear 100ms;\n}\n\n.psv-canvas {\n display: block;\n}\n\n.psv-loader-container {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 80;\n}\n\n.psv-loader {\n position: relative;\n text-align: center;\n color: rgba(61, 61, 61, 0.7);\n width: 150px;\n height: 150px;\n border: 10px solid transparent;\n}\n.psv-loader::before {\n content: \"\";\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n}\n.psv-loader, .psv-loader-image, .psv-loader-text {\n display: inline-block;\n vertical-align: middle;\n}\n.psv-loader-canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n.psv-loader-text {\n font: 14px sans-serif;\n}\n\n.psv-navbar {\n display: flex;\n position: absolute;\n z-index: 90;\n bottom: -40px;\n left: 0;\n width: 100%;\n height: 40px;\n background: rgba(61, 61, 61, 0.5);\n transition: bottom ease-in-out 0.1s;\n}\n.psv-navbar--open {\n bottom: 0;\n}\n.psv-navbar, .psv-navbar * {\n box-sizing: content-box;\n}\n\n.psv-caption {\n flex: 1 1 100%;\n color: rgba(255, 255, 255, 0.7);\n overflow: hidden;\n text-align: center;\n}\n.psv-caption-icon {\n height: 20px;\n width: 20px;\n cursor: pointer;\n}\n.psv-caption-icon * {\n fill: rgba(255, 255, 255, 0.7);\n}\n.psv-caption-content {\n display: inline-block;\n padding: 10px;\n font: 16px sans-serif;\n white-space: nowrap;\n}\n\n.psv-button {\n flex: 0 0 auto;\n padding: 10px;\n position: relative;\n cursor: pointer;\n height: 20px;\n width: 20px;\n background: transparent;\n color: rgba(255, 255, 255, 0.7);\n}\n.psv-button--active {\n background: rgba(255, 255, 255, 0.2);\n}\n.psv-button--disabled {\n pointer-events: none;\n opacity: 0.5;\n}\n.psv-button-svg {\n width: 100%;\n transform: scale(1);\n transition: transform 200ms ease;\n}\n\n.psv-button:not(.psv-button--disabled):focus-visible {\n outline: 2px dotted currentcolor;\n outline-offset: -2px;\n}\n\n.psv-container:not(.psv--is-touch) .psv-button--hover-scale:not(.psv-button--disabled):hover .psv-button-svg {\n transform: scale(1.2);\n}\n\n.psv-move-button + .psv-move-button {\n margin-left: -10px;\n}\n\n.psv-custom-button {\n width: auto;\n}\n\n.psv-autorotate-button.psv-button {\n width: 25px;\n height: 25px;\n padding: 7.5px;\n}\n\n.psv-zoom-range.psv-button {\n width: 80px;\n height: 1px;\n margin: 10px 0;\n padding: 9.5px 0;\n max-width: 600px;\n}\n.psv-zoom-range-line {\n position: relative;\n width: 80px;\n height: 1px;\n background: rgba(255, 255, 255, 0.7);\n transition: all 0.3s ease;\n}\n.psv-zoom-range-handle {\n position: absolute;\n border-radius: 50%;\n top: -3px;\n width: 7px;\n height: 7px;\n background: rgba(255, 255, 255, 0.7);\n transform: scale(1);\n transition: transform 0.3s ease;\n}\n.psv-zoom-range:not(.psv-button--disabled):hover .psv-zoom-range-line {\n box-shadow: 0 0 2px rgba(255, 255, 255, 0.7);\n}\n.psv-zoom-range:not(.psv-button--disabled):hover .psv-zoom-range-handle {\n transform: scale(1.3);\n}\n\n.psv-notification {\n position: absolute;\n z-index: 100;\n bottom: -40px;\n display: flex;\n justify-content: center;\n box-sizing: border-box;\n width: 100%;\n padding: 0 2em;\n opacity: 0;\n transition-property: opacity, bottom;\n transition-timing-function: ease-in-out;\n transition-duration: 200ms;\n}\n.psv-notification-content {\n max-width: 50em;\n background-color: rgba(61, 61, 61, 0.8);\n border-radius: 4px;\n padding: 0.5em 1em;\n font: 14px sans-serif;\n color: white;\n}\n.psv-notification--visible {\n opacity: 100;\n bottom: 80px;\n}\n\n.psv-overlay {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: absolute;\n z-index: 110;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n background: radial-gradient(#fff 0%, #fdfdfd 16%, #fbfbfb 33%, #f8f8f8 49%, #efefef 66%, #dfdfdf 82%, #bfbfbf 100%);\n color: black;\n opacity: 0.8;\n}\n.psv-overlay-image {\n margin-bottom: 4vh;\n}\n.psv-overlay-image svg {\n width: 50vw;\n}\n@media (orientation: landscape) {\n .psv-overlay-image svg {\n width: 25vw;\n }\n}\n.psv-overlay-text {\n font: 30px sans-serif;\n text-align: center;\n}\n.psv-overlay-subtext {\n font: 20px sans-serif;\n opacity: 0.8;\n text-align: center;\n}\n\n.psv-panel {\n position: absolute;\n z-index: 90;\n right: 0;\n height: 100%;\n width: 400px;\n max-width: calc(100% - 24px);\n background: rgba(10, 10, 10, 0.7);\n transform: translate3d(100%, 0, 0);\n opacity: 0;\n transition-property: opacity, transform;\n transition-timing-function: ease-in-out;\n transition-duration: 0.1s;\n cursor: default;\n margin-left: 9px;\n}\n.psv--has-navbar .psv-panel {\n height: calc(100% - 40px);\n}\n.psv-panel-close-button {\n display: none;\n position: absolute;\n top: 0;\n left: -24px;\n width: 24px;\n height: 24px;\n background: rgba(0, 0, 0, 0.9);\n}\n.psv-panel-close-button::before, .psv-panel-close-button::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 4px;\n width: 15px;\n height: 1px;\n background-color: #fff;\n transition: 0.2s ease-in-out;\n transition-property: width, left, transform;\n}\n.psv-panel-close-button::before {\n transform: rotate(45deg);\n}\n.psv-panel-close-button::after {\n transform: rotate(-45deg);\n}\n.psv-panel-close-button:hover::before, .psv-panel-close-button:hover::after {\n left: 0;\n width: 23px;\n}\n.psv-panel-close-button:hover::before {\n transform: rotate(135deg);\n}\n.psv-panel-close-button:hover::after {\n transform: rotate(45deg);\n}\n.psv-panel-resizer {\n display: none;\n position: absolute;\n top: 0;\n left: -9px;\n width: 9px;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.9);\n cursor: col-resize;\n}\n.psv-panel-resizer::before {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 1px;\n margin-top: -14.5px;\n width: 1px;\n height: 1px;\n box-shadow: 1px 0 #fff, 3px 0px #fff, 5px 0px #fff, 1px 2px #fff, 3px 2px #fff, 5px 2px #fff, 1px 4px #fff, 3px 4px #fff, 5px 4px #fff, 1px 6px #fff, 3px 6px #fff, 5px 6px #fff, 1px 8px #fff, 3px 8px #fff, 5px 8px #fff, 1px 10px #fff, 3px 10px #fff, 5px 10px #fff, 1px 12px #fff, 3px 12px #fff, 5px 12px #fff, 1px 14px #fff, 3px 14px #fff, 5px 14px #fff, 1px 16px #fff, 3px 16px #fff, 5px 16px #fff, 1px 18px #fff, 3px 18px #fff, 5px 18px #fff, 1px 20px #fff, 3px 20px #fff, 5px 20px #fff, 1px 22px #fff, 3px 22px #fff, 5px 22px #fff, 1px 24px #fff, 3px 24px #fff, 5px 24px #fff, 1px 26px #fff, 3px 26px #fff, 5px 26px #fff, 1px 28px #fff, 3px 28px #fff, 5px 28px #fff;\n background: transparent;\n}\n.psv-panel-content {\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n color: gainsboro;\n font: 16px sans-serif;\n overflow: auto;\n}\n.psv-panel-content:not(.psv-panel-content--no-margin) {\n padding: 1em;\n}\n.psv-panel-content--no-interaction {\n user-select: none;\n pointer-events: none;\n}\n.psv-panel--open {\n transform: translate3d(0, 0, 0);\n opacity: 1;\n transition-duration: 0.2s;\n}\n.psv-panel--open .psv-panel-close-button,\n.psv-panel--open .psv-panel-resizer {\n display: block;\n}\n\n.psv-panel-menu {\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n.psv-panel-menu-title {\n flex: none;\n display: flex;\n align-items: center;\n font: 24px sans-serif;\n margin: 24px 12px;\n}\n.psv-panel-menu-title svg {\n width: 24px;\n height: 24px;\n margin-right: 12px;\n}\n.psv-panel-menu-list {\n flex: 1;\n list-style: none;\n margin: 0;\n padding: 0;\n overflow-x: hidden;\n}\n.psv-panel-menu-item {\n min-height: 20px;\n padding: 0.5em 1em;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n transition: background 0.1s ease-in-out;\n}\n.psv-panel-menu-item--active {\n outline: 1px solid currentcolor;\n outline-offset: -1px;\n}\n.psv-panel-menu-item-icon {\n flex: none;\n height: 20px;\n width: 20px;\n margin-right: 0.5em;\n}\n.psv-panel-menu-item-icon img {\n max-width: 100%;\n max-height: 100%;\n}\n.psv-panel-menu-item-icon svg {\n width: 100%;\n height: 100%;\n}\n.psv-panel-menu-item:focus-visible {\n outline: 1px dotted currentcolor;\n outline-offset: -1px;\n}\n.psv-panel-menu--stripped .psv-panel-menu-item:hover {\n background: rgba(255, 255, 255, 0.2);\n}\n.psv-panel-menu--stripped .psv-panel-menu-item:nth-child(odd), .psv-panel-menu--stripped .psv-panel-menu-item:nth-child(odd)::before {\n background: rgba(255, 255, 255, 0.1);\n}\n.psv-panel-menu--stripped .psv-panel-menu-item:nth-child(even), .psv-panel-menu--stripped .psv-panel-menu-item:nth-child(even)::before {\n background: transparent;\n}\n\n.psv-container:not(.psv--is-touch) .psv-panel-menu-item:hover {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.psv-tooltip {\n position: absolute;\n z-index: 50;\n box-sizing: border-box;\n max-width: 200px;\n background-color: rgba(61, 61, 61, 0.8);\n border-radius: 4px;\n padding: 0.5em 1em;\n opacity: 0;\n transition-property: opacity;\n transition-timing-function: ease-in-out;\n transition-duration: 100ms;\n outline: 5px solid transparent;\n}\n.psv-tooltip-content {\n color: white;\n font: 14px sans-serif;\n text-shadow: 0 1px #000;\n}\n.psv-tooltip-arrow {\n position: absolute;\n height: 0;\n width: 0;\n border: 7px solid transparent;\n}\n.psv-tooltip--bottom-center {\n box-shadow: 0 3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, -5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--bottom-center .psv-tooltip-arrow {\n border-bottom-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--center-left {\n box-shadow: -3px 0 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(5px, 0, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--center-left .psv-tooltip-arrow {\n border-left-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--top-center {\n box-shadow: 0 -3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, 5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--top-center .psv-tooltip-arrow {\n border-top-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--center-right {\n box-shadow: 3px 0 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(-5px, 0, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--center-right .psv-tooltip-arrow {\n border-right-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--bottom-left {\n box-shadow: -3px 3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, -5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--bottom-left .psv-tooltip-arrow {\n border-bottom-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--bottom-right {\n box-shadow: 3px 3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, -5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--bottom-right .psv-tooltip-arrow {\n border-bottom-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--top-left {\n box-shadow: -3px -3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, 5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--top-left .psv-tooltip-arrow {\n border-top-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--top-right {\n box-shadow: 3px -3px 0 rgba(90, 90, 90, 0.7);\n transform: translate3d(0, 5px, 0);\n transition-property: opacity, transform;\n}\n.psv-tooltip--top-right .psv-tooltip-arrow {\n border-top-color: rgba(61, 61, 61, 0.8);\n}\n.psv-tooltip--visible {\n transform: translate3d(0, 0, 0);\n opacity: 1;\n transition-duration: 100ms;\n}"]} \ No newline at end of file diff --git a/dist/photo-sphere-viewer.d.ts b/dist/photo-sphere-viewer.d.ts index ed4fa794d..c71ec55ce 100644 --- a/dist/photo-sphere-viewer.d.ts +++ b/dist/photo-sphere-viewer.d.ts @@ -1,4 +1,4 @@ -import { Texture, Vector3, Euler, Mesh, Intersection } from 'three'; +import { Texture, Vector3, Euler, Intersection, Mesh } from 'three'; import { EventEmitter, Event } from 'uevent'; /** @@ -160,11 +160,6 @@ declare function hasParent(el: HTMLElement, parent: HTMLElement): boolean; */ declare function getClosest(el: HTMLElement | SVGElement, selector: string): HTMLElement; -/** - * @summary Returns the key name of a KeyboardEvent - */ -declare function getEventKey(evt: KeyboardEvent): string; - /** * @summary Detects if fullscreen is enabled */ @@ -269,6 +264,7 @@ type PanoDataProvider = (image: HTMLImageElement) => PanoData; */ type PanoramaOptions = (ExtendedPosition | {}) & { caption?: string; + description?: string; transition?: boolean | number; showLoader?: boolean; zoom?: number; @@ -465,12 +461,55 @@ declare function createTexture(img: HTMLImageElement | HTMLCanvasElement): Textu */ declare function applyEulerInverse(vector: Vector3, euler: Euler); +type AnimationOptions = { + properties: { [key in keyof T]: { start: number, end: number } }; + duration: number; + delay?: number; + easing?: string | ((progress: number) => number); + onTick: (properties: { [key in keyof T]: number }, progress: number) => void; +}; + +/** + * @summary Interpolation helper for animations + * @description + * Implements the Promise API with an additional "cancel" method. + * The promise is resolved when the animation is complete and rejected if the animation is cancelled. + */ +declare class Animation implements PromiseLike { + + constructor(options: AnimationOptions); + + then(onFulfilled?: ((completed: boolean) => TResult | PromiseLike) | undefined | null): PromiseLike; + + cancel(); + + /** + * @deprecated does not accept a rejection handler anymore + */ + then(onFulfilled?: (() => void | Animation | PromiseLike) | undefined | null, onRejected?: (() => void | Animation | PromiseLike) | undefined | null): Animation; + + /** + * @deprecated not supported anymore + */ + catch(onRejected?: (() => void | Animation | PromiseLike) | undefined | null): Animation; + + /** + * @deprecated not supported anymore + */ + finally(onFinally?: (() => void | Animation | PromiseLike) | undefined | null): Animation; + + /** + * @deprecated not supported anymore + */ + static resolve(): Animation; + +} + declare const index_d_toggleClass: typeof toggleClass; declare const index_d_addClasses: typeof addClasses; declare const index_d_removeClasses: typeof removeClasses; declare const index_d_hasParent: typeof hasParent; declare const index_d_getClosest: typeof getClosest; -declare const index_d_getEventKey: typeof getEventKey; declare const index_d_isFullscreenEnabled: typeof isFullscreenEnabled; declare const index_d_requestFullscreen: typeof requestFullscreen; declare const index_d_exitFullscreen: typeof exitFullscreen; @@ -502,6 +541,9 @@ declare const index_d_parseSpeed: typeof parseSpeed; declare const index_d_parseAngle: typeof parseAngle; declare const index_d_createTexture: typeof createTexture; declare const index_d_applyEulerInverse: typeof applyEulerInverse; +type index_d_AnimationOptions = AnimationOptions; +type index_d_Animation = Animation; +declare const index_d_Animation: typeof Animation; declare namespace index_d { export { index_d_toggleClass as toggleClass, @@ -509,7 +551,6 @@ declare namespace index_d { index_d_removeClasses as removeClasses, index_d_hasParent as hasParent, index_d_getClosest as getClosest, - index_d_getEventKey as getEventKey, index_d_isFullscreenEnabled as isFullscreenEnabled, index_d_requestFullscreen as requestFullscreen, index_d_exitFullscreen as exitFullscreen, @@ -541,116 +582,11 @@ declare namespace index_d { index_d_parseAngle as parseAngle, index_d_createTexture as createTexture, index_d_applyEulerInverse as applyEulerInverse, + index_d_AnimationOptions as AnimationOptions, + index_d_Animation as Animation, }; } -/** - * @summary Base adapters class - * @template T type of the panorama configuration object - */ -declare abstract class AbstractAdapter { - - /** - * @summary Unique identifier of the adapter - */ - static id: string; - - /** - * @summary Indicates if the adapter supports panorama download natively - */ - static supportsDownload: boolean; - - constructor(parent: Viewer); - - /** - * @summary Destroys the adapter - */ - destroy(); - - /** - * @summary Indicates if the adapter supports transitions between panoramas - */ - supportsTransition(panorama: T): boolean; - - /** - * @summary Indicates if the adapter supports preload of a panorama - */ - supportsPreload(panorama: T): boolean; - - /** - * @summary Loads the panorama texture(s) - */ - loadTexture(panorama: T, newPanoData?: PanoData | PanoDataProvider): Promise; - - /** - * @summary Creates the cube mesh - * @param {number} [scale=1] - */ - createMesh(scale?: number): Mesh; - - /** - * @summary Applies the texture to the mesh - */ - setTexture(mesh: Mesh, textureData: TextureData, transition?: boolean); - - /** - * @summary Changes the opacity of the mesh - */ - setTextureOpacity(mesh: Mesh, opacity: number); - - /** - * @abstract - */ - disposeTexture(textureData: TextureData); - -} - -type AdapterConstructor> = new (psv: Viewer, options?: any) => T; - -type AnimationOptions = { - properties: { [key in keyof T]: { start: number, end: number } }; - duration: number; - delay?: number; - easing?: string | ((progress: number) => number); - onTick: (properties: { [key in keyof T]: number }, progress: number) => void; -}; - -/** - * @summary Interpolation helper for animations - * @description - * Implements the Promise API with an additional "cancel" method. - * The promise is resolved when the animation is complete and rejected if the animation is cancelled. - */ -declare class Animation implements PromiseLike { - - constructor(options: AnimationOptions); - - then(onFulfilled?: ((completed: boolean) => TResult | PromiseLike) | undefined | null): PromiseLike; - - cancel(); - - /** - * @deprecated does not accept a rejection handler anymore - */ - then(onFulfilled?: (() => void | Animation | PromiseLike) | undefined | null, onRejected?: (() => void | Animation | PromiseLike) | undefined | null): Animation; - - /** - * @deprecated not supported anymore - */ - catch(onRejected?: (() => void | Animation | PromiseLike) | undefined | null): Animation; - - /** - * @deprecated not supported anymore - */ - finally(onFinally?: (() => void | Animation | PromiseLike) | undefined | null): Animation; - - /** - * @deprecated not supported anymore - */ - static resolve(): Animation; - -} - /** * @summary Base component class */ @@ -703,6 +639,11 @@ declare abstract class AbstractButton extends AbstractComponent { */ static id: string; + /** + * @summary Identifier to declare a group of buttons + */ + static groupId?: string; + /** * @summary SVG icon name injected in the button */ @@ -780,6 +721,7 @@ declare class Navbar extends AbstractComponent { } type NotificationOptions = { + id?: string; content: string; timeout?: number; }; @@ -1025,6 +967,7 @@ type ViewerOptions = { panorama?: any; adapter?: AdapterConstructor | [AdapterConstructor, any]; caption?: string; + description?: string; downloadUrl?: string; loadingImg?: string; loadingTxt?: string; @@ -1331,7 +1274,7 @@ declare class Viewer extends EventEmitter { /** * @summary Triggered when the notification is hidden */ - on(e: 'hide-notification', cb: (e: Event) => void): this; + on(e: 'hide-notification', cb: (e: Event, id: string | undefined) => void): this; /** * @summary Triggered when the overlay is hidden */ @@ -1340,6 +1283,10 @@ declare class Viewer extends EventEmitter { * @summary Triggered when the tooltip is hidden */ on(e: 'hide-tooltip', cb: (e: Event, data: any) => void): this; + /** + * @summary Triggered when a key is pressed, can be cancelled + */ + on(e: 'key-press', cb: (e: Event, key: string) => void): this; /** * @summary Triggered when the loader value changes */ @@ -1351,7 +1298,7 @@ declare class Viewer extends EventEmitter { /** * @summary Triggered when a panorama image has been loaded */ - on(e: 'panorama-loaded', cb: (e: Event) => void): this; + on(e: 'panorama-loaded', cb: (e: Event, textureData: TextureData) => void): this; /** * @summary Triggered when the view longitude and/or latitude changes */ @@ -1363,7 +1310,7 @@ declare class Viewer extends EventEmitter { /** * @summary Trigered when the notification is shown */ - on(e: 'show-notification', cb: (e: Event) => void): this; + on(e: 'show-notification', cb: (e: Event, id: string | undefined) => void): this; /** * @summary Trigered when the overlay is shown */ @@ -1387,6 +1334,82 @@ declare class Viewer extends EventEmitter { } +/** + * @summary Base adapters class + * @template T type of the panorama configuration object + */ +declare abstract class AbstractAdapter { + + /** + * @summary Unique identifier of the adapter + */ + static id: string; + + /** + * @summary Indicates if the adapter supports panorama download natively + */ + static supportsDownload: boolean; + + constructor(parent: Viewer); + + /** + * @summary Destroys the adapter + */ + destroy(); + + /** + * @summary Indicates if the adapter supports transitions between panoramas + */ + supportsTransition(panorama: T): boolean; + + /** + * @summary Indicates if the adapter supports preload of a panorama + */ + supportsPreload(panorama: T): boolean; + + /** + * @summary Loads the panorama texture(s) + */ + loadTexture(panorama: T, newPanoData?: PanoData | PanoDataProvider): Promise; + + /** + * @summary Creates the cube mesh + * @param {number} [scale=1] + */ + createMesh(scale?: number): Mesh; + + /** + * @summary Applies the texture to the mesh + */ + setTexture(mesh: Mesh, textureData: TextureData, transition?: boolean); + + /** + * @summary Changes the opacity of the mesh + */ + setTextureOpacity(mesh: Mesh, opacity: number); + + /** + * @summary Cleanup a loaded texture, used on load abort + */ + disposeTexture(textureData: TextureData); + +} + +type AdapterConstructor> = new (psv: Viewer, options?: any) => T; + +type EquirectangularAdapterOptions = { + resolution?: number, +}; + +/** + * @summary Adapter for equirectangular panoramas + */ +declare class EquirectangularAdapter extends AbstractAdapter { + + constructor(psv: Viewer, options: EquirectangularAdapterOptions); + +} + /** * @summary Default options */ @@ -1406,19 +1429,6 @@ declare const SYSTEM: { isTouchEnabled: Promise; }; -type EquirectangularAdapterOptions = { - resolution?: number, -}; - -/** - * @summary Adapter for equirectangular panoramas - */ -declare class EquirectangularAdapter extends AbstractAdapter { - - constructor(psv: Viewer, options: EquirectangularAdapterOptions); - -} - /** * @summary Custom error used in the lib */ @@ -1426,4 +1436,4 @@ declare class PSVError extends Error { name: 'PSVError'; } -export { AbstractAdapter, AbstractButton, AbstractPlugin, AdapterConstructor, AnimateOptions, Animation, AnimationOptions, constants_d as CONSTANTS, ClickData, CssSize, DEFAULTS, DataHelper, EquirectangularAdapter, EquirectangularAdapterOptions, ExtendedPosition, Loader, Navbar, NavbarCustomButton, Notification, NotificationOptions, Overlay, OverlayOptions, PSVError, Panel, PanelOptions, PanoData, PanoDataProvider, PanoramaOptions, PluginConstructor, Point, Position, SYSTEM, Size, SphereCorrection, TextureData, TextureLoader, Tooltip, TooltipOptions, TooltipPosition, TooltipRenderer, Viewer, ViewerOptions, ViewerProps, registerButton, index_d as utils }; +export { AbstractAdapter, AbstractButton, AbstractComponent, AbstractPlugin, AdapterConstructor, AnimateOptions, Animation, AnimationOptions, constants_d as CONSTANTS, ClickData, CssSize, DEFAULTS, DataHelper, EquirectangularAdapter, EquirectangularAdapterOptions, ExtendedPosition, Loader, Navbar, NavbarCustomButton, Notification, NotificationOptions, Overlay, OverlayOptions, PSVError, Panel, PanelOptions, PanoData, PanoDataProvider, PanoramaOptions, PluginConstructor, Point, Position, SYSTEM, Size, SphereCorrection, TextureData, TextureLoader, Tooltip, TooltipOptions, TooltipPosition, TooltipRenderer, Viewer, ViewerOptions, ViewerProps, registerButton, index_d as utils }; diff --git a/dist/photo-sphere-viewer.js b/dist/photo-sphere-viewer.js index 0d006b456..5135c2911 100644 --- a/dist/photo-sphere-viewer.js +++ b/dist/photo-sphere-viewer.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -10,6 +10,224 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PhotoSphereViewer = {}, global.THREE, global.uEvent)); })(this, (function (exports, THREE, uevent) { 'use strict'; + /** + * @summary Custom error used in the lib + * @param {string} message + * @constructor + * @memberOf PSV + */ + function PSVError(message) { + this.message = message; // Use V8's native method if available, otherwise fallback + + if ('captureStackTrace' in Error) { + Error.captureStackTrace(this, PSVError); + } else { + this.stack = new Error().stack; + } + } + + PSVError.prototype = Object.create(Error.prototype); + PSVError.prototype.name = 'PSVError'; + PSVError.prototype.constructor = PSVError; + + /** + * @namespace PSV.adapters + */ + + /** + * @summary Base adapters class + * @memberof PSV.adapters + * @abstract + */ + + var AbstractAdapter = /*#__PURE__*/function () { + /** + * @summary Unique identifier of the adapter + * @member {string} + * @readonly + * @static + */ + + /** + * @summary Indicates if the adapter supports panorama download natively + * @type {boolean} + * @readonly + * @static + */ + + /** + * @param {PSV.Viewer} psv + */ + function AbstractAdapter(psv) { + /** + * @summary Reference to main controller + * @type {PSV.Viewer} + * @readonly + */ + this.psv = psv; + } + /** + * @summary Destroys the adapter + */ + + + var _proto = AbstractAdapter.prototype; + + _proto.destroy = function destroy() { + delete this.psv; + } + /** + * @summary Indicates if the adapter supports transitions between panoramas + * @param {*} panorama + * @return {boolean} + */ + ; + + _proto.supportsTransition = function supportsTransition(panorama) { + // eslint-disable-line no-unused-vars + return false; + } + /** + * @summary Indicates if the adapter supports preload of a panorama + * @param {*} panorama + * @return {boolean} + */ + ; + + _proto.supportsPreload = function supportsPreload(panorama) { + // eslint-disable-line no-unused-vars + return false; + } + /** + * @abstract + * @summary Loads the panorama texture(s) + * @param {*} panorama + * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData] + * @returns {Promise.} + */ + ; + + _proto.loadTexture = function loadTexture(panorama, newPanoData) { + // eslint-disable-line no-unused-vars + throw new PSVError('loadTexture not implemented'); + } + /** + * @abstract + * @summary Creates the cube mesh + * @param {number} [scale=1] + * @returns {external:THREE.Mesh} + */ + ; + + _proto.createMesh = function createMesh(scale) { + + // eslint-disable-line no-unused-vars + throw new PSVError('createMesh not implemented'); + } + /** + * @abstract + * @summary Applies the texture to the mesh + * @param {external:THREE.Mesh} mesh + * @param {PSV.TextureData} textureData + * @param {boolean} [transition=false] + */ + ; + + _proto.setTexture = function setTexture(mesh, textureData, transition) { + + // eslint-disable-line no-unused-vars + throw new PSVError('setTexture not implemented'); + } + /** + * @abstract + * @summary Changes the opacity of the mesh + * @param {external:THREE.Mesh} mesh + * @param {number} opacity + */ + ; + + _proto.setTextureOpacity = function setTextureOpacity(mesh, opacity) { + // eslint-disable-line no-unused-vars + throw new PSVError('setTextureOpacity not implemented'); + } + /** + * @abstract + * @summary Clear a loaded texture from memory + * @param {PSV.TextureData} textureData + */ + ; + + _proto.disposeTexture = function disposeTexture(textureData) { + // eslint-disable-line no-unused-vars + throw new PSVError('disposeTexture not implemented'); + }; + + return AbstractAdapter; + }(); + AbstractAdapter.id = null; + AbstractAdapter.supportsDownload = false; + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; + } + + 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) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + + _setPrototypeOf(subClass, superClass); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + /** * @namespace PSV.constants */ @@ -186,6 +404,7 @@ * @event hide-notification * @memberof PSV * @summary Triggered when the notification is hidden + * @param {string} [id] */ HIDE_NOTIFICATION: 'hide-notification', @@ -205,6 +424,14 @@ */ HIDE_TOOLTIP: 'hide-tooltip', + /** + * @event key-press + * @memberof PSV + * @summary Triggered when a key is pressed, can be cancelled + * @param {string} key + */ + KEY_PRESS: 'key-press', + /** * @event load-progress * @memberof PSV @@ -225,6 +452,7 @@ * @event panorama-loaded * @memberof PSV * @summary Triggered when a panorama image has been loaded + * @param {PSV.TextureData} textureData */ PANORAMA_LOADED: 'panorama-loaded', @@ -254,6 +482,7 @@ * @event show-notification * @memberof PSV * @summary Triggered when the notification is shown + * @param {string} [id] */ SHOW_NOTIFICATION: 'show-notification', @@ -346,7 +575,8 @@ MENU: 'menu', TWO_FINGERS: 'twoFingers', CTRL_ZOOM: 'ctrlZoom', - ERROR: 'error' + ERROR: 'error', + DESCRIPTION: 'description' }; /* eslint-disable */ // @formatter:off @@ -475,27 +705,214 @@ }); /** - * @summary Toggles a CSS class - * @memberOf PSV.utils - * @param {HTMLElement|SVGElement} element - * @param {string} className - * @param {boolean} [active] - forced state + * @summary General information about the system + * @constant + * @memberOf PSV + * @property {boolean} loaded - Indicates if the system data has been loaded + * @property {Function} load - Loads the system if not already loaded + * @property {number} pixelRatio + * @property {boolean} isWebGLSupported + * @property {number} maxCanvasWidth + * @property {string} mouseWheelEvent + * @property {string} fullscreenEvent + * @property {Function} getMaxCanvasWidth - Returns the max width of a canvas allowed by the browser + * @property {Promise} isTouchEnabled */ - function toggleClass(element, className, active) { - // manual implementation for IE11 and SVGElement - if (!element.classList) { - var currentClassName = element.getAttribute('class') || ''; - var currentActive = currentClassName.indexOf(className) !== -1; - var regex = new RegExp('(?:^|\\s)' + className + '(?:\\s|$)'); - if ((active === undefined || active) && !currentActive) { - currentClassName += currentClassName.length > 0 ? ' ' + className : className; - } else if (!active) { - currentClassName = currentClassName.replace(regex, ' '); - } + var SYSTEM = { + loaded: false, + pixelRatio: 1, + isWebGLSupported: false, + isTouchEnabled: null, + maxTextureWidth: 0, + mouseWheelEvent: null, + fullscreenEvent: null + }; + /** + * @summary Loads the system if not already loaded + */ - element.setAttribute('class', currentClassName); - } else if (active === undefined) { + SYSTEM.load = function () { + if (!SYSTEM.loaded) { + var ctx = getWebGLCtx(); + SYSTEM.loaded = true; + SYSTEM.pixelRatio = window.devicePixelRatio || 1; + SYSTEM.isWebGLSupported = ctx != null; + SYSTEM.isTouchEnabled = isTouchEnabled(); + SYSTEM.maxTextureWidth = getMaxTextureWidth(ctx); + SYSTEM.mouseWheelEvent = getMouseWheelEvent(); + SYSTEM.fullscreenEvent = getFullscreenEvent(); + } + }; + + var maxCanvasWidth = null; + + SYSTEM.getMaxCanvasWidth = function () { + if (maxCanvasWidth === null) { + maxCanvasWidth = getMaxCanvasWidth(SYSTEM.maxTextureWidth); + } + + return maxCanvasWidth; + }; + /** + * @summary Tries to return a canvas webgl context + * @returns {WebGLRenderingContext} + * @private + */ + + + function getWebGLCtx() { + var canvas = document.createElement('canvas'); + var names = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d']; + var context = null; + + if (!canvas.getContext) { + return null; + } + + if (names.some(function (name) { + try { + context = canvas.getContext(name); + return context !== null; + } catch (e) { + return false; + } + })) { + return context; + } else { + return null; + } + } + /** + * @summary Detects if the user is using a touch screen + * @returns {Promise} + * @private + */ + + + function isTouchEnabled() { + return new Promise(function (resolve) { + var listener = function listener(e) { + if (e) { + resolve(true); + } else { + resolve(false); + } + + window.removeEventListener('touchstart', listener); + }; + + window.addEventListener('touchstart', listener, false); // after 10 secs auto-reject the promise + + setTimeout(listener, 10000); + }); + } + /** + * @summary Gets max texture width in WebGL context + * @returns {number} + * @private + */ + + + function getMaxTextureWidth(ctx) { + if (ctx !== null) { + return ctx.getParameter(ctx.MAX_TEXTURE_SIZE); + } else { + return 0; + } + } + /** + * @summary Gets max canvas width supported by the browser. + * We only test powers of 2 and height = width / 2 because that's what we need to generate WebGL textures + * @param maxWidth + * @return {number} + * @private + */ + + + function getMaxCanvasWidth(maxWidth) { + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + canvas.width = maxWidth; + canvas.height = maxWidth / 2; + + while (canvas.width > 1024) { + ctx.fillStyle = 'white'; + ctx.fillRect(0, 0, 1, 1); + + try { + if (ctx.getImageData(0, 0, 1, 1).data[0] === 255) { + return canvas.width; + } + } catch (e) {// continue + } + + canvas.width /= 2; + canvas.height /= 2; + } + + throw new PSVError('Unable to detect system capabilities'); + } + /** + * @summary Gets the event name for mouse wheel + * @returns {string} + * @private + */ + + + function getMouseWheelEvent() { + if ('onwheel' in document.createElement('div')) { + // Modern browsers support "wheel" + return 'wheel'; + } else if (document.onmousewheel !== undefined) { + // Webkit and IE support at least "mousewheel" + return 'mousewheel'; + } else { + // let's assume that remaining browsers are older Firefox + return 'DOMMouseScroll'; + } + } + /** + * @summary Map between fullsceen method and fullscreen event name + * @type {Object} + * @readonly + * @private + */ + + + var FULLSCREEN_EVT_MAP = { + exitFullscreen: 'fullscreenchange', + webkitExitFullscreen: 'webkitfullscreenchange', + mozCancelFullScreen: 'mozfullscreenchange', + msExitFullscreen: 'MSFullscreenChange' + }; + /** + * @summary Gets the event name for fullscreen + * @returns {string} + * @private + */ + + function getFullscreenEvent() { + var validExits = Object.keys(FULLSCREEN_EVT_MAP).filter(function (exit) { + return exit in document; + }); + + if (validExits.length) { + return FULLSCREEN_EVT_MAP[validExits[0]]; + } else { + return null; + } + } + + /** + * @summary Toggles a CSS class + * @memberOf PSV.utils + * @param {HTMLElement|SVGElement} element + * @param {string} className + * @param {boolean} [active] - forced state + */ + function toggleClass(element, className, active) { + if (active === undefined) { element.classList.toggle(className); } else if (active && !element.classList.contains(className)) { element.classList.add(className); @@ -561,15 +978,15 @@ */ function getClosest(el, selector) { - var matches = el.matches || el.msMatchesSelector; - var test = el; // When el is document or window, the matches does not exist - - if (!matches) { + // When el is document or window, the matches does not exist + if (!el.matches) { return null; } + var test = el; + do { - if (matches.bind(test)(selector)) { + if (test.matches(selector)) { return test; } @@ -602,64 +1019,6 @@ top: top }; } - /** - * @summary Map between keyboard events `keyCode|which` and `key` - * @memberOf PSV.utils - * @type {Object} - * @readonly - * @private - */ - - var KEYMAP = { - 13: 'Enter', - 17: 'Control', - 27: 'Escape', - 32: ' ', - 33: 'PageUp', - 34: 'PageDown', - 37: 'ArrowLeft', - 38: 'ArrowUp', - 39: 'ArrowRight', - 40: 'ArrowDown', - 46: 'Delete', - 107: '+', - 109: '-' - }; - /** - * @summary Map for non standard keyboard events `key` for IE and Edge - * @see https://github.com/shvaikalesh/shim-keyboard-event-key - * @type {Object} - * @readonly - * @private - */ - - var MS_KEYMAP = { - Add: '+', - Del: 'Delete', - Down: 'ArrowDown', - Esc: 'Escape', - Left: 'ArrowLeft', - Right: 'ArrowRight', - Spacebar: ' ', - Subtract: '-', - Up: 'ArrowUp' - }; - /** - * @summary Returns the key name of a KeyboardEvent - * @memberOf PSV.utils - * @param {KeyboardEvent} evt - * @returns {string} - */ - - function getEventKey(evt) { - var key = evt.key || KEYMAP[evt.keyCode || evt.which]; - - if (key && MS_KEYMAP[key]) { - key = MS_KEYMAP[key]; - } - - return key; - } /** * @summary Detects if fullscreen is enabled * @memberOf PSV.utils @@ -668,8 +1027,7 @@ */ function isFullscreenEnabled(elt) { - /* eslint-disable-next-line max-len */ - return (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) === elt; + return (document.fullscreenElement || document.webkitFullscreenElement) === elt; } /** * @summary Enters fullscreen mode @@ -678,8 +1036,7 @@ */ function requestFullscreen(elt) { - /* eslint-disable-next-line max-len */ - (elt.requestFullscreen || elt.mozRequestFullScreen || elt.webkitRequestFullscreen || elt.msRequestFullscreen).call(elt); + (elt.requestFullscreen || elt.webkitRequestFullscreen).call(elt); } /** * @summary Exits fullscreen mode @@ -687,8 +1044,7 @@ */ function exitFullscreen() { - /* eslint-disable-next-line max-len */ - (document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.msExitFullscreen).call(document); + (document.exitFullscreen || document.webkitExitFullscreen).call(document); } /** * @summary Gets an element style @@ -793,6 +1149,22 @@ function bound(x, min, max) { return Math.max(min, Math.min(max, x)); } + /** + * @summary Ensure a value is within 0 and `max` + * @param {number} value + * @param {number} max + * @return {number} + */ + + function loop(value, max) { + var result = value % max; + + if (result < 0) { + result += max; + } + + return result; + } /** * @summary Checks if a value is an integer * @memberOf PSV.utils @@ -1097,26 +1469,6 @@ return undefined; } - /** - * @summary Custom error used in the lib - * @param {string} message - * @constructor - * @memberOf PSV - */ - function PSVError(message) { - this.message = message; // Use V8's native method if available, otherwise fallback - - if ('captureStackTrace' in Error) { - Error.captureStackTrace(this, PSVError); - } else { - this.stack = new Error().stack; - } - } - - PSVError.prototype = Object.create(Error.prototype); - PSVError.prototype.name = 'PSVError'; - PSVError.prototype.constructor = PSVError; - /** * @summary Returns the plugin constructor from the imported object * For retrocompatibility with previous default exports @@ -1443,12 +1795,7 @@ throw new PSVError('Unknown angle "' + angle + '"'); } - parsed = (zeroCenter ? parsed + Math.PI : parsed) % (Math.PI * 2); - - if (parsed < 0) { - parsed += Math.PI * 2; - } - + parsed = loop(zeroCenter ? parsed + Math.PI : parsed, Math.PI * 2); return zeroCenter ? bound(parsed - Math.PI, -Math.PI / (halfCircle ? 2 : 1), Math.PI / (halfCircle ? 2 : 1)) : parsed; } /** @@ -1479,65 +1826,16 @@ } /** - * @namespace PSV.utils - */ - - var index = /*#__PURE__*/Object.freeze({ - __proto__: null, - toggleClass: toggleClass, - addClasses: addClasses, - removeClasses: removeClasses, - hasParent: hasParent, - getClosest: getClosest, - getPosition: getPosition, - getEventKey: getEventKey, - isFullscreenEnabled: isFullscreenEnabled, - requestFullscreen: requestFullscreen, - exitFullscreen: exitFullscreen, - getStyle: getStyle, - normalizeWheel: normalizeWheel, - bound: bound, - isInteger: isInteger, - isPowerOfTwo: isPowerOfTwo, - sum: sum, - distance: distance, - getShortestArc: getShortestArc, - getAngle: getAngle, - greatArcDistance: greatArcDistance, - dasherize: dasherize, - throttle: throttle, - isPlainObject: isPlainObject, - deepmerge: deepmerge, - clone: clone, - isEmpty: isEmpty, - each: each, - isNil: isNil, - firstNonNull: firstNonNull, - pluginInterop: pluginInterop, - getAbortError: getAbortError, - isAbortError: isAbortError, - logWarn: logWarn, - isExtendedPosition: isExtendedPosition, - getXMPValue: getXMPValue, - parsePosition: parsePosition, - cleanPosition: cleanPosition, - parseSpeed: parseSpeed, - parseAngle: parseAngle, - createTexture: createTexture, - applyEulerInverse: applyEulerInverse - }); - - /** - * @callback OnTick - * @summary Function called for each animation frame with computed properties - * @memberOf PSV.Animation - * @param {Object.} properties - current values - * @param {float} progress - 0 to 1 + * @callback OnTick + * @summary Function called for each animation frame with computed properties + * @memberOf PSV.utils.Animation + * @param {Object.} properties - current values + * @param {float} progress - 0 to 1 */ /** * @summary Interpolation helper for animations - * @memberOf PSV + * @memberOf PSV.utils * @description * Implements the Promise API with an additional "cancel" method. * The promise is resolved with `true` when the animation is completed and `false` if the animation is cancelled. @@ -1564,7 +1862,7 @@ * @param {number} options.duration * @param {number} [options.delay=0] * @param {string} [options.easing='linear'] - * @param {PSV.Animation.OnTick} options.onTick - called on each frame + * @param {PSV.utils.Animation.OnTick} options.onTick - called on each frame */ function Animation(options) { var _this = this; @@ -1658,7 +1956,7 @@ * @summary Promise chaining * @param {Function} [onFulfilled] - Called when the animation is complete (true) or cancelled (false) * @param {Function} [onRejected] - deprecated - * @returns {PSV.Promise} + * @returns {Promise} */ ; @@ -1737,525 +2035,501 @@ return Animation; }(); - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { - writable: false - }); - return Constructor; - } - - function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; + /** + * @summary Represents a variable that can dynamically change with time (using requestAnimationFrame) + * @memberOf PSV.utils + */ - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } + var Dynamic = /*#__PURE__*/function () { + /** + * @param {Function} [fn] Callback function + * @param {number} [defaultValue] Default position + * @param {number} [min] Minimum position + * @param {number} [max] Maximum position + * @param {boolean} [loopValue] Loop value between min and max + */ + function Dynamic(fn, defaultValue, min, max, loopValue) { + if (defaultValue === void 0) { + defaultValue = 0; } - return target; - }; - - return _extends.apply(this, arguments); - } - - function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - - _setPrototypeOf(subClass, superClass); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } + if (min === void 0) { + min = -Infinity; + } - return self; - } + if (max === void 0) { + max = Infinity; + } - /** - * @namespace PSV.components - */ + if (loopValue === void 0) { + loopValue = false; + } - /** - * @summary Base component class - * @memberof PSV.components - * @abstract - */ - var AbstractComponent = /*#__PURE__*/function () { - /** - * @param {PSV.Viewer | PSV.components.AbstractComponent} parent - * @param {string} className - CSS class added to the component's container - */ - function AbstractComponent(parent, className) { /** - * @summary Reference to main controller - * @type {PSV.Viewer} + * @type {Function} + * @private * @readonly */ - this.psv = parent.psv || parent; + this.fn = fn; /** - * @member {PSV.Viewer|PSV.components.AbstractComponent} - * @readonly + * @type {number} + * @private */ - this.parent = parent; - this.parent.children.push(this); + this.mode = Dynamic.STOP; /** - * @summary All child components - * @type {PSV.components.AbstractComponent[]} - * @readonly - * @package + * @type {number} + * @private */ - this.children = []; + this.speed = 0; /** - * @summary Internal properties - * @member {Object} - * @protected - * @property {boolean} visible - Visibility of the component + * @type {number} + * @private */ - this.prop = { - visible: true - }; + this.speedMult = 1; /** - * @member {HTMLElement} + * @type {number} + * @private + */ + + this.currentSpeed = 0; + /** + * @type {number} + * @private + */ + + this.target = 0; + /** + * @type {number} * @readonly */ - this.container = document.createElement('div'); - this.container.className = className; - this.parent.container.appendChild(this.container); - } - /** - * @summary Destroys the component - * @protected - */ + this.current = defaultValue; + /** + * @type {number} + * @private + */ + this.min = min; + /** + * @type {number} + * @private + */ - var _proto = AbstractComponent.prototype; + this.max = max; + /** + * @type {boolean} + * @private + */ - _proto.destroy = function destroy() { - this.parent.container.removeChild(this.container); - var childIdx = this.parent.children.indexOf(this); + this.loopValue = loopValue; - if (childIdx !== -1) { - this.parent.children.splice(childIdx, 1); + if (loopValue && min !== 0) { + throw new PSVError('invalid config'); } - this.children.slice().forEach(function (child) { - return child.destroy(); - }); - this.children.length = 0; - delete this.container; - delete this.parent; - delete this.psv; - delete this.prop; + if (this.fn) { + this.fn(defaultValue); + } } /** - * @summary Refresh UI - * @description Must be be a very lightweight operation - * @package + * Changes base speed + * @param {number} speed */ - ; - _proto.refreshUi = function refreshUi() { - var _this = this; - this.children.every(function (child) { - child.refreshUi(); - return _this.psv.prop.uiRefresh === true; - }); + var _proto = Dynamic.prototype; + + _proto.setSpeed = function setSpeed(speed) { + this.speed = speed; } /** - * @summary Displays or hides the component + * Defines the target position + * @param {number} position + * @param {number} [speedMult=1] */ ; - _proto.toggle = function toggle() { - if (this.isVisible()) { - this.hide(); - } else { - this.show(); + _proto.goto = function goto(position, speedMult) { + if (speedMult === void 0) { + speedMult = 1; } - } - /** - * @summary Hides the component - */ - ; - _proto.hide = function hide() { - this.container.style.display = 'none'; - this.prop.visible = false; + this.mode = Dynamic.POSITION; + this.target = this.loopValue ? loop(position, this.max) : bound(position, this.min, this.max); + this.speedMult = speedMult; } /** - * @summary Displays the component + * Increase/decrease the target position + * @param {number} step + * @param {number} [speedMult=1] */ ; - _proto.show = function show() { - this.container.style.display = ''; - this.prop.visible = true; + _proto.step = function step(_step, speedMult) { + if (speedMult === void 0) { + speedMult = 1; + } + + if (this.mode !== Dynamic.POSITION) { + this.target = this.current; + } + + this.goto(this.target + _step, speedMult); } /** - * @summary Checks if the component is visible - * @returns {boolean} + * Starts infinite movement + * @param {boolean} [invert=false] + * @param {number} [speedMult=1] */ ; - _proto.isVisible = function isVisible() { - return this.prop.visible; - }; - - return AbstractComponent; - }(); - - /** - * @namespace PSV.buttons - */ - - /** - * @summary Base navbar button class - * @extends PSV.components.AbstractComponent - * @memberof PSV.buttons - * @abstract - */ + _proto.roll = function roll(invert, speedMult) { + if (invert === void 0) { + invert = false; + } - var AbstractButton = /*#__PURE__*/function (_AbstractComponent) { - _inheritsLoose(AbstractButton, _AbstractComponent); + if (speedMult === void 0) { + speedMult = 1; + } + this.mode = Dynamic.INFINITE; + this.target = invert ? -Infinity : Infinity; + this.speedMult = speedMult; + } /** - * @summary Unique identifier of the button - * @member {string} - * @readonly - * @static + * Stops movement */ + ; + _proto.stop = function stop() { + this.mode = Dynamic.STOP; + } /** - * @summary SVG icon name injected in the button - * @member {string} - * @readonly - * @static + * Defines the current position and immediately stops movement + * @param {number} value */ + ; - /** - * @summary SVG icon name injected in the button when it is active - * @member {string} - * @readonly - * @static - */ + _proto.setValue = function setValue(value) { + this.target = this.loopValue ? loop(value, this.max) : bound(value, this.min, this.max); + this.mode = Dynamic.STOP; + + if (this.target !== this.current) { + this.current = this.target; + if (this.fn) { + this.fn(this.current); + } + + return true; + } + + return false; + } /** - * @param {PSV.components.Navbar} navbar - * @param {string} [className] - Additional CSS classes - * @param {boolean} [collapsable=false] - `true` if the button can be moved to menu when the navbar is too small - * @param {boolean} [tabbable=true] - `true` if the button is accessible with the keyboard + * @package */ - function AbstractButton(navbar, className, collapsable, tabbable) { - var _this; + ; - if (className === void 0) { - className = ''; - } + _proto.update = function update(elapsed) { + // in position mode switch to stop mode when in the decceleration window + if (this.mode === Dynamic.POSITION) { + // in loop mode, alter "current" to avoid crossing the origin + if (this.loopValue && Math.abs(this.target - this.current) > this.max / 2) { + this.current = this.current < this.target ? this.current + this.max : this.current - this.max; + } - if (collapsable === void 0) { - collapsable = false; - } + var dstStop = this.currentSpeed * this.currentSpeed / (this.speed * this.speedMult * 4); - if (tabbable === void 0) { - tabbable = true; - } + if (Math.abs(this.target - this.current) <= dstStop) { + this.mode = Dynamic.STOP; + } + } // compute speed - _this = _AbstractComponent.call(this, navbar, 'psv-button ' + className) || this; - /** - * @override - * @property {string} id - Unique identifier of the button - * @property {boolean} enabled - * @property {boolean} supported - * @property {boolean} collapsed - * @property {boolean} active - * @property {number} width - */ - _this.prop = _extends({}, _this.prop, { - id: _this.constructor.id, - collapsable: collapsable, - enabled: true, - supported: true, - collapsed: false, - active: false, - width: _this.container.offsetWidth - }); + var targetSpeed = this.mode === Dynamic.STOP ? 0 : this.speed * this.speedMult; - if (_this.constructor.icon) { - _this.__setIcon(_this.constructor.icon); + if (this.target < this.current) { + targetSpeed = -targetSpeed; } - if (_this.prop.id && _this.psv.config.lang[_this.prop.id]) { - _this.container.title = _this.psv.config.lang[_this.prop.id]; - } + if (this.currentSpeed < targetSpeed) { + this.currentSpeed = Math.min(targetSpeed, this.currentSpeed + elapsed / 1000 * this.speed * this.speedMult * 2); + } else if (this.currentSpeed > targetSpeed) { + this.currentSpeed = Math.max(targetSpeed, this.currentSpeed - elapsed / 1000 * this.speed * this.speedMult * 2); + } // compute new position - if (tabbable) { - _this.container.tabIndex = 0; - } - _this.container.addEventListener('click', function (e) { - if (_this.prop.enabled) { - _this.onClick(); - } + var next = null; - e.stopPropagation(); - }); + if (this.current > this.target && this.currentSpeed) { + next = Math.max(this.target, this.current + this.currentSpeed * elapsed / 1000); + } else if (this.current < this.target && this.currentSpeed) { + next = Math.min(this.target, this.current + this.currentSpeed * elapsed / 1000); + } // apply value - _this.container.addEventListener('keydown', function (e) { - if (getEventKey(e) === KEY_CODES.Enter && _this.prop.enabled) { - _this.onClick(); - e.stopPropagation(); - } - }); + if (next !== null) { + next = this.loopValue ? loop(next, this.max) : bound(next, this.min, this.max); - return _this; - } - /** - * @package - */ + if (next !== this.current) { + this.current = next; + if (this.fn) { + this.fn(this.current); + } - var _proto = AbstractButton.prototype; + return true; + } + } - _proto.checkSupported = function checkSupported() { - var _this2 = this; + return false; + }; - var supportedOrObject = this.isSupported(); + return Dynamic; + }(); + Dynamic.STOP = 0; + Dynamic.INFINITE = 1; + Dynamic.POSITION = 2; - if (isPlainObject(supportedOrObject)) { - if (supportedOrObject.initial === false) { - this.hide(); - this.prop.supported = false; - } + /** + * @summary Wrapper for multiple {@link PSV.utils.Dynamic} evolving together + * @memberOf PSV.utils + */ - supportedOrObject.promise.then(function (supported) { - if (!_this2.prop) { - return; // the component has been destroyed - } + var MultiDynamic = /*#__PURE__*/function () { + /** + * @param {Record} dynamics + * @param {Function} [fn] Callback function + */ + function MultiDynamic(dynamics, fn) { + /** + * @type {Function} + * @private + * @readonly + */ + this.fn = fn; + /** + * @type {Record} + * @private + * @readonly + */ - _this2.prop.supported = supported; + this.dynamics = dynamics; - if (!supported && _this2.prop.visible) { - _this2.hide(); - } else if (supported && !_this2.prop.visible) { - _this2.show(); - } - }); - } else if (!supportedOrObject) { - this.hide(); - this.prop.supported = false; + if (this.fn) { + this.fn(this.current); } } /** - * @summary Checks if the button can be displayed - * @returns {boolean|{initial: boolean, promise: Promise}} + * Changes base speed + * @param {number} speed */ - ; - _proto.isSupported = function isSupported() { - return true; + + var _proto = MultiDynamic.prototype; + + _proto.setSpeed = function setSpeed(speed) { + each(this.dynamics, function (d) { + d.setSpeed(speed); + }); } /** - * @summary Changes the active state of the button - * @param {boolean} [active] - forced state + * Defines the target positions + * @param {Record} positions + * @param {number} [speedMult=1] */ ; - _proto.toggleActive = function toggleActive(active) { - this.prop.active = active !== undefined ? active : !this.prop.active; - toggleClass(this.container, 'psv-button--active', this.prop.active); + _proto.goto = function goto(positions, speedMult) { + var _this = this; - if (this.constructor.iconActive) { - this.__setIcon(this.prop.active ? this.constructor.iconActive : this.constructor.icon); + if (speedMult === void 0) { + speedMult = 1; } + + each(positions, function (position, name) { + _this.dynamics[name].goto(position, speedMult); + }); } /** - * @override + * Increase/decrease the target positions + * @param {Record} steps + * @param {number} [speedMult=1] */ ; - _proto.show = function show(refresh) { - if (refresh === void 0) { - refresh = true; - } - - if (!this.isVisible()) { - this.prop.visible = true; - - if (!this.prop.collapsed) { - this.container.style.display = ''; - } + _proto.step = function step(steps, speedMult) { + var _this2 = this; - if (refresh) { - this.psv.refreshUi("show button " + this.prop.id); - } + if (speedMult === void 0) { + speedMult = 1; } + + each(steps, function (step, name) { + _this2.dynamics[name].step(step, speedMult); + }); } /** - * @override + * Starts infinite movements + * @param {Record} rolls + * @param {number} [speedMult=1] */ ; - _proto.hide = function hide(refresh) { - if (refresh === void 0) { - refresh = true; - } - - if (this.isVisible()) { - this.prop.visible = false; - this.container.style.display = 'none'; + _proto.roll = function roll(rolls, speedMult) { + var _this3 = this; - if (refresh) { - this.psv.refreshUi("hide button " + this.prop.id); - } + if (speedMult === void 0) { + speedMult = 1; } - } - /** - * @summary Disables the button - */ - ; - _proto.disable = function disable() { - this.container.classList.add('psv-button--disabled'); - this.prop.enabled = false; + each(rolls, function (roll, name) { + _this3.dynamics[name].roll(roll, speedMult); + }); } /** - * @summary Enables the button + * Stops movements */ ; - _proto.enable = function enable() { - this.container.classList.remove('psv-button--disabled'); - this.prop.enabled = true; + _proto.stop = function stop() { + each(this.dynamics, function (d) { + return d.stop(); + }); } /** - * @summary Collapses the button in the navbar menu + * Defines the current positions and immediately stops movements + * @param {Record} values */ ; - _proto.collapse = function collapse() { - this.prop.collapsed = true; - this.container.style.display = 'none'; - } - /** - * @summary Uncollapses the button from the navbar menu - */ - ; + _proto.setValue = function setValue(values) { + var _this4 = this; - _proto.uncollapse = function uncollapse() { - this.prop.collapsed = false; + var hasUpdates = false; + each(values, function (value, name) { + hasUpdates |= _this4.dynamics[name].setValue(value); + }); - if (this.prop.visible) { - this.container.style.display = ''; + if (hasUpdates && this.fn) { + this.fn(this.current); } + + return hasUpdates; } /** - * @summary Set the button icon - * @param {string} icon SVG - * @param {HTMLElement} [container] - default is the main button container - * @private + * @package */ ; - _proto.__setIcon = function __setIcon(icon, container) { - if (container === void 0) { - container = this.container; - } - - if (icon) { - container.innerHTML = icon; // classList not supported on IE11, className is read-only !!!! + _proto.update = function update(elapsed) { + var hasUpdates = false; + each(this.dynamics, function (dynamic) { + hasUpdates |= dynamic.update(elapsed); + }); - container.querySelector('svg').setAttribute('class', 'psv-button-svg'); - } else { - container.innerHTML = ''; + if (hasUpdates && this.fn) { + this.fn(this.current); } - } - /** - * @summary Action when the button is clicked - * @private - * @abstract - */ - ; - _proto.onClick = function onClick() { - throw new PSVError("onClick not implemented for button \"" + this.prop.id + "\"."); + return hasUpdates; }; - return AbstractButton; - }(AbstractComponent); - AbstractButton.id = null; - AbstractButton.icon = null; - AbstractButton.iconActive = null; - - var playActive = "\n"; + _createClass(MultiDynamic, [{ + key: "current", + get: + /** + * @type {Object} + * @readonly + */ + function get() { + var values = {}; + each(this.dynamics, function (dynamic, name) { + values[name] = dynamic.current; + }); + return values; + } + }]); - var play = "\n"; + return MultiDynamic; + }(); /** - * @summary Navigation bar autorotate button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons + * @summary Helper to make sliders elements + * @memberOf PSV.utils */ - var AutorotateButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(AutorotateButton, _AbstractButton); + var Slider = /*#__PURE__*/function (_EventEmitter) { + _inheritsLoose(Slider, _EventEmitter); - /** - * @param {PSV.components.Navbar} navbar - */ - function AutorotateButton(navbar) { + function Slider(_ref) { var _this; - _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-autorotate-button', true) || this; + var psv = _ref.psv, + container = _ref.container, + direction = _ref.direction, + onUpdate = _ref.onUpdate; + _this = _EventEmitter.call(this) || this; + /** + * @summary Reference to main controller + * @type {PSV.Viewer} + * @readonly + */ - _this.psv.on(EVENTS.AUTOROTATE, _assertThisInitialized(_this)); + _this.psv = psv; + /** + * @member {HTMLElement} + * @readonly + */ + + _this.container = container; + /** + * @summary Internal properties + * @member {Object} + * @protected + * @property {boolean} mousedown + * @property {number} mediaMinWidth + */ + + _this.prop = { + onUpdate: onUpdate, + direction: direction, + mousedown: false, + mouseover: false + }; + _this.container.addEventListener('click', _assertThisInitialized(_this)); + + _this.container.addEventListener('mousedown', _assertThisInitialized(_this)); + + _this.container.addEventListener('mouseenter', _assertThisInitialized(_this)); + + _this.container.addEventListener('mouseleave', _assertThisInitialized(_this)); + + _this.container.addEventListener('touchstart', _assertThisInitialized(_this)); + + _this.container.addEventListener('mousemove', _assertThisInitialized(_this), true); + + _this.container.addEventListener('touchmove', _assertThisInitialized(_this), true); + + window.addEventListener('mouseup', _assertThisInitialized(_this)); + window.addEventListener('touchend', _assertThisInitialized(_this)); return _this; } /** - * @override + * @protected */ - var _proto = AutorotateButton.prototype; + var _proto = Slider.prototype; _proto.destroy = function destroy() { - this.psv.off(EVENTS.AUTOROTATE, this); - - _AbstractButton.prototype.destroy.call(this); + window.removeEventListener('mouseup', this); + window.removeEventListener('touchend', this); } /** * @summary Handles events @@ -2268,8 +2542,48 @@ /* eslint-disable */ switch (e.type) { // @formatter:off - case EVENTS.AUTOROTATE: - this.toggleActive(e.args[0]); + case 'click': + e.stopPropagation(); + break; + + case 'mousedown': + this.__onMouseDown(e); + + break; + + case 'mouseenter': + this.__onMouseEnter(e); + + break; + + case 'mouseleave': + this.__onMouseLeave(e); + + break; + + case 'touchstart': + this.__onTouchStart(e); + + break; + + case 'mousemove': + this.__onMouseMove(e); + + break; + + case 'touchmove': + this.__onTouchMove(e); + + break; + + case 'mouseup': + this.__onMouseUp(e); + + break; + + case 'touchend': + this.__onTouchEnd(e); + break; // @formatter:on } @@ -2277,177 +2591,224 @@ } /** - * @override - * @description Toggles autorotate + * @private */ ; - _proto.onClick = function onClick() { - this.psv.toggleAutorotate(); - }; + _proto.__onMouseDown = function __onMouseDown(evt) { + this.prop.mousedown = true; - return AutorotateButton; - }(AbstractButton); - AutorotateButton.id = 'autorotate'; - AutorotateButton.icon = play; - AutorotateButton.iconActive = playActive; + this.__update(evt, true); + } + /** + * @private + */ + ; - /** - * @summary Navigation bar custom button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons - */ - - var CustomButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(CustomButton, _AbstractButton); + _proto.__onMouseEnter = function __onMouseEnter(evt) { + this.prop.mouseover = true; + this.__update(evt, true); + } /** - * @param {PSV.components.Navbar} navbar - * @param {PSV.NavbarCustomButton} config + * @private */ - function CustomButton(navbar, config) { - var _this; - - _this = _AbstractButton.call(this, navbar, 'psv-custom-button', config.collapsable !== false, config.tabbable !== false) || this; - /** - * @member {Object} - * @readonly - * @private - */ - - _this.config = config; + ; - if (_this.config.id) { - _this.prop.id = _this.config.id; - } else { - _this.prop.id = 'psvButton-' + Math.random().toString(36).substr(2, 9); - } + _proto.__onTouchStart = function __onTouchStart(evt) { + this.prop.mouseover = true; + this.prop.mousedown = true; - if (_this.config.className) { - addClasses(_this.container, _this.config.className); - } + this.__update(evt.changedTouches[0], true); + } + /** + * @private + */ + ; - if (_this.config.title) { - _this.container.title = _this.config.title; - } + _proto.__onMouseMove = function __onMouseMove(evt) { + if (this.prop.mousedown || this.prop.mouseover) { + evt.stopPropagation(); - if (_this.config.content) { - _this.container.innerHTML = _this.config.content; + this.__update(evt, true); } + } + /** + * @private + */ + ; - _this.prop.width = _this.container.offsetWidth; - - if (_this.config.enabled === false) { - _this.disable(); - } + _proto.__onTouchMove = function __onTouchMove(evt) { + if (this.prop.mousedown || this.prop.mouseover) { + evt.stopPropagation(); - if (_this.config.visible === false) { - _this.hide(); + this.__update(evt.changedTouches[0], true); } - - return _this; } /** - * @override + * @private */ + ; + _proto.__onMouseUp = function __onMouseUp(evt) { + if (this.prop.mousedown) { + this.prop.mousedown = false; - var _proto = CustomButton.prototype; - - _proto.destroy = function destroy() { - delete this.config; - - _AbstractButton.prototype.destroy.call(this); + this.__update(evt, false); + } } /** - * @override - * @description Calls user method + * @private */ ; - _proto.onClick = function onClick() { - if (this.config.onClick) { - this.config.onClick.apply(this.psv); - } - }; - - return CustomButton; - }(AbstractButton); - - var download = "\n"; - - /** - * @summary Navigation bar download button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons - */ - - var DownloadButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(DownloadButton, _AbstractButton); + _proto.__onMouseLeave = function __onMouseLeave(evt) { + if (this.prop.mouseover) { + this.prop.mouseover = false; - /** - * @param {PSV.components.Navbar} navbar - */ - function DownloadButton(navbar) { - return _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-download-button', true) || this; + this.__update(evt, true); + } } /** - * @override + * @private */ + ; + _proto.__onTouchEnd = function __onTouchEnd(evt) { + if (this.prop.mousedown) { + this.prop.mouseover = false; + this.prop.mousedown = false; - var _proto = DownloadButton.prototype; - - _proto.isSupported = function isSupported() { - return this.psv.adapter.constructor.supportsDownload || !!this.psv.config.downloadUrl; + this.__update(evt.changedTouches[0], false); + } } /** - * @override - * @description Asks the browser to download the panorama source file + * @private */ ; - _proto.onClick = function onClick() { - var _this = this; - - var link = document.createElement('a'); - link.href = this.psv.config.downloadUrl || this.psv.config.panorama; - link.download = link.href.split('/').pop(); - this.psv.container.appendChild(link); - link.click(); - setTimeout(function () { - _this.psv.container.removeChild(link); - }, 100); + _proto.__update = function __update(evt, moving) { + var boundingClientRect = this.container.getBoundingClientRect(); + var cursor = evt[this.vertical ? 'clientY' : 'clientX']; + var pos = boundingClientRect[this.vertical ? 'bottom' : 'left']; + var size = boundingClientRect[this.vertical ? 'height' : 'width']; + var val = Math.abs((pos - cursor) / size); + this.prop.onUpdate({ + value: val, + click: !moving, + mousedown: this.prop.mousedown, + mouseover: this.prop.mouseover, + cursor: evt + }); }; - return DownloadButton; - }(AbstractButton); - DownloadButton.id = 'download'; - DownloadButton.icon = download; + _createClass(Slider, [{ + key: "vertical", + get: + /** + * @type {boolean} + * @readonly + */ + function get() { + return this.prop.direction === Slider.VERTICAL; + } + }]); - var fullscreenIn = "\n"; + return Slider; + }(uevent.EventEmitter); + Slider.VERTICAL = 1; + Slider.HORIZONTAL = 2; - var fullscreenOut = "\n"; + /** + * @namespace PSV.utils + */ + + var index = /*#__PURE__*/Object.freeze({ + __proto__: null, + toggleClass: toggleClass, + addClasses: addClasses, + removeClasses: removeClasses, + hasParent: hasParent, + getClosest: getClosest, + getPosition: getPosition, + isFullscreenEnabled: isFullscreenEnabled, + requestFullscreen: requestFullscreen, + exitFullscreen: exitFullscreen, + getStyle: getStyle, + normalizeWheel: normalizeWheel, + bound: bound, + loop: loop, + isInteger: isInteger, + isPowerOfTwo: isPowerOfTwo, + sum: sum, + distance: distance, + getShortestArc: getShortestArc, + getAngle: getAngle, + greatArcDistance: greatArcDistance, + dasherize: dasherize, + throttle: throttle, + isPlainObject: isPlainObject, + deepmerge: deepmerge, + clone: clone, + isEmpty: isEmpty, + each: each, + isNil: isNil, + firstNonNull: firstNonNull, + pluginInterop: pluginInterop, + getAbortError: getAbortError, + isAbortError: isAbortError, + logWarn: logWarn, + isExtendedPosition: isExtendedPosition, + getXMPValue: getXMPValue, + parsePosition: parsePosition, + cleanPosition: cleanPosition, + parseSpeed: parseSpeed, + parseAngle: parseAngle, + createTexture: createTexture, + applyEulerInverse: applyEulerInverse, + Animation: Animation, + Dynamic: Dynamic, + MultiDynamic: MultiDynamic, + Slider: Slider + }); /** - * @summary Navigation bar fullscreen button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons + * @typedef {Object} PSV.adapters.EquirectangularAdapter.Options + * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances */ - var FullscreenButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(FullscreenButton, _AbstractButton); + /** + * @summary Adapter for equirectangular panoramas + * @memberof PSV.adapters + * @extends PSV.adapters.AbstractAdapter + */ + + var EquirectangularAdapter = /*#__PURE__*/function (_AbstractAdapter) { + _inheritsLoose(EquirectangularAdapter, _AbstractAdapter); /** - * @param {PSV.components.Navbar} navbar + * @param {PSV.Viewer} psv + * @param {PSV.adapters.EquirectangularAdapter.Options} options */ - function FullscreenButton(navbar) { + function EquirectangularAdapter(psv, options) { var _this; - _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-fullscreen-button') || this; + _this = _AbstractAdapter.call(this, psv) || this; + /** + * @member {PSV.adapters.EquirectangularAdapter.Options} + * @private + */ - _this.psv.on(EVENTS.FULLSCREEN_UPDATED, _assertThisInitialized(_this)); + _this.config = _extends({ + resolution: 64 + }, options); + + if (!isPowerOfTwo(_this.config.resolution)) { + throw new PSVError('EquirectangularAdapter resolution must be power of two'); + } + _this.SPHERE_SEGMENTS = _this.config.resolution; + _this.SPHERE_HORIZONTAL_SEGMENTS = _this.SPHERE_SEGMENTS / 2; return _this; } /** @@ -2455,406 +2816,1403 @@ */ - var _proto = FullscreenButton.prototype; - - _proto.destroy = function destroy() { - this.psv.off(EVENTS.FULLSCREEN_UPDATED, this); + var _proto = EquirectangularAdapter.prototype; - _AbstractButton.prototype.destroy.call(this); + _proto.supportsTransition = function supportsTransition() { + return true; } /** - * Handle events - * @param {Event} e - * @private + * @override */ ; - _proto.handleEvent = function handleEvent(e) { - /* eslint-disable */ - switch (e.type) { - // @formatter:off - case EVENTS.FULLSCREEN_UPDATED: - this.toggleActive(e.args[0]); - break; - // @formatter:on - } - /* eslint-enable */ - + _proto.supportsPreload = function supportsPreload() { + return true; } /** * @override - * @description Toggles fullscreen + * @param {string} panorama + * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData] + * @returns {Promise.} */ ; - _proto.onClick = function onClick() { - this.psv.toggleFullscreen(); - }; + _proto.loadTexture = function loadTexture(panorama, newPanoData) { + var _this2 = this; - return FullscreenButton; - }(AbstractButton); - FullscreenButton.id = 'fullscreen'; - FullscreenButton.icon = fullscreenIn; - FullscreenButton.iconActive = fullscreenOut; + if (typeof panorama !== 'string') { + if (Array.isArray(panorama) || typeof panorama === 'object' && !!panorama.left) { + logWarn('Cubemap support now requires an additional adapter, see https://photo-sphere-viewer.js.org/guide/adapters'); + } - var menuIcon = "\n"; + return Promise.reject(new PSVError('Invalid panorama url, are you using the right adapter?')); + } - /** - * @summary Navigation bar menu button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons - */ + return (!this.psv.config.useXmpData ? this.psv.textureLoader.loadImage(panorama, function (p) { + return _this2.psv.loader.setProgress(p); + }).then(function (img) { + return { + img: img, + xmpPanoData: null + }; + }) : this.__loadXMP(panorama, function (p) { + return _this2.psv.loader.setProgress(p); + }).then(function (xmpPanoData) { + return _this2.psv.textureLoader.loadImage(panorama).then(function (img) { + return { + img: img, + xmpPanoData: xmpPanoData + }; + }); + })).then(function (_ref) { + var _newPanoData, _newPanoData2, _newPanoData3, _newPanoData4, _newPanoData5, _newPanoData6, _newPanoData7, _newPanoData8, _newPanoData9; - var MenuButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(MenuButton, _AbstractButton); + var img = _ref.img, + xmpPanoData = _ref.xmpPanoData; - /** - * @summary Property name added to buttons list - * @type {string} - * @constant - */ + if (typeof newPanoData === 'function') { + newPanoData = newPanoData(img); + } - /** - * @summary Menu template - * @param {AbstractButton[]} buttons - * @param {PSV.Viewer} psv - * @param {string} dataKey - * @returns {string} - */ + var panoData = { + fullWidth: firstNonNull((_newPanoData = newPanoData) == null ? void 0 : _newPanoData.fullWidth, xmpPanoData == null ? void 0 : xmpPanoData.fullWidth, img.width), + fullHeight: firstNonNull((_newPanoData2 = newPanoData) == null ? void 0 : _newPanoData2.fullHeight, xmpPanoData == null ? void 0 : xmpPanoData.fullHeight, img.height), + croppedWidth: firstNonNull((_newPanoData3 = newPanoData) == null ? void 0 : _newPanoData3.croppedWidth, xmpPanoData == null ? void 0 : xmpPanoData.croppedWidth, img.width), + croppedHeight: firstNonNull((_newPanoData4 = newPanoData) == null ? void 0 : _newPanoData4.croppedHeight, xmpPanoData == null ? void 0 : xmpPanoData.croppedHeight, img.height), + croppedX: firstNonNull((_newPanoData5 = newPanoData) == null ? void 0 : _newPanoData5.croppedX, xmpPanoData == null ? void 0 : xmpPanoData.croppedX, 0), + croppedY: firstNonNull((_newPanoData6 = newPanoData) == null ? void 0 : _newPanoData6.croppedY, xmpPanoData == null ? void 0 : xmpPanoData.croppedY, 0), + poseHeading: firstNonNull((_newPanoData7 = newPanoData) == null ? void 0 : _newPanoData7.poseHeading, xmpPanoData == null ? void 0 : xmpPanoData.poseHeading, 0), + posePitch: firstNonNull((_newPanoData8 = newPanoData) == null ? void 0 : _newPanoData8.posePitch, xmpPanoData == null ? void 0 : xmpPanoData.posePitch, 0), + poseRoll: firstNonNull((_newPanoData9 = newPanoData) == null ? void 0 : _newPanoData9.poseRoll, xmpPanoData == null ? void 0 : xmpPanoData.poseRoll, 0) + }; + + if (panoData.croppedWidth !== img.width || panoData.croppedHeight !== img.height) { + logWarn("Invalid panoData, croppedWidth and/or croppedHeight is not coherent with loaded image.\n panoData: " + panoData.croppedWidth + "x" + panoData.croppedHeight + ", image: " + img.width + "x" + img.height); + } + + if ((newPanoData || xmpPanoData) && panoData.fullWidth !== panoData.fullHeight * 2) { + logWarn('Invalid panoData, fullWidth should be twice fullHeight'); + } + + var texture = _this2.__createEquirectangularTexture(img, panoData); + return { + panorama: panorama, + texture: texture, + panoData: panoData + }; + }); + } /** - * @param {PSV.components.Navbar} navbar + * @summary Loads the XMP data of an image + * @param {string} panorama + * @param {function(number)} [onProgress] + * @returns {Promise} + * @throws {PSV.PSVError} when the image cannot be loaded + * @private */ - function MenuButton(navbar) { - var _this; - - _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-menu-button') || this; + ; - _this.psv.on(EVENTS.OPEN_PANEL, _assertThisInitialized(_this)); + _proto.__loadXMP = function __loadXMP(panorama, onProgress) { + var _this3 = this; - _this.psv.on(EVENTS.CLOSE_PANEL, _assertThisInitialized(_this)); + return this.psv.textureLoader.loadFile(panorama, onProgress).then(function (blob) { + return _this3.__loadBlobAsString(blob); + }).then(function (binary) { + var a = binary.indexOf(''); + var data = binary.substring(a, b); - _this.hide(); + if (a !== -1 && b !== -1 && data.includes('GPano:')) { + return { + fullWidth: getXMPValue(data, 'FullPanoWidthPixels'), + fullHeight: getXMPValue(data, 'FullPanoHeightPixels'), + croppedWidth: getXMPValue(data, 'CroppedAreaImageWidthPixels'), + croppedHeight: getXMPValue(data, 'CroppedAreaImageHeightPixels'), + croppedX: getXMPValue(data, 'CroppedAreaLeftPixels'), + croppedY: getXMPValue(data, 'CroppedAreaTopPixels'), + poseHeading: getXMPValue(data, 'PoseHeadingDegrees'), + posePitch: getXMPValue(data, 'PosePitchDegrees'), + poseRoll: getXMPValue(data, 'PoseRollDegrees') + }; + } - return _this; + return null; + }); } /** - * @override + * @summmary read a Blob as string + * @param {Blob} blob + * @returns {Promise} + * @private */ + ; + _proto.__loadBlobAsString = function __loadBlobAsString(blob) { + return new Promise(function (resolve, reject) { + var reader = new FileReader(); - var _proto = MenuButton.prototype; - - _proto.destroy = function destroy() { - this.psv.off(EVENTS.OPEN_PANEL, this); - this.psv.off(EVENTS.CLOSE_PANEL, this); + reader.onload = function () { + return resolve(reader.result); + }; - _AbstractButton.prototype.destroy.call(this); + reader.onerror = reject; + reader.readAsText(blob); + }); } /** - * @summary Handles events - * @param {Event} e + * @summary Creates the final texture from image and panorama data + * @param {Image} img + * @param {PSV.PanoData} panoData + * @returns {external:THREE.Texture} * @private */ ; - _proto.handleEvent = function handleEvent(e) { - /* eslint-disable */ - switch (e.type) { - // @formatter:off - case EVENTS.OPEN_PANEL: - this.toggleActive(e.args[0] === IDS.MENU); - break; + _proto.__createEquirectangularTexture = function __createEquirectangularTexture(img, panoData) { + // resize image / fill cropped parts with black + if (panoData.fullWidth > SYSTEM.maxTextureWidth || panoData.croppedWidth !== panoData.fullWidth || panoData.croppedHeight !== panoData.fullHeight) { + var ratio = SYSTEM.getMaxCanvasWidth() / panoData.fullWidth; - case EVENTS.CLOSE_PANEL: - this.toggleActive(false); - break; - // @formatter:on + var resizedPanoData = _extends({}, panoData); + + if (ratio < 1) { + resizedPanoData.fullWidth *= ratio; + resizedPanoData.fullHeight *= ratio; + resizedPanoData.croppedWidth *= ratio; + resizedPanoData.croppedHeight *= ratio; + resizedPanoData.croppedX *= ratio; + resizedPanoData.croppedY *= ratio; + } + + var buffer = document.createElement('canvas'); + buffer.width = resizedPanoData.fullWidth; + buffer.height = resizedPanoData.fullHeight; + var ctx = buffer.getContext('2d'); + ctx.drawImage(img, resizedPanoData.croppedX, resizedPanoData.croppedY, resizedPanoData.croppedWidth, resizedPanoData.croppedHeight); + return createTexture(buffer); } - /* eslint-enable */ + return createTexture(img); } /** * @override */ ; - _proto.hide = function hide(refresh) { - _AbstractButton.prototype.hide.call(this, refresh); + _proto.createMesh = function createMesh(scale) { + if (scale === void 0) { + scale = 1; + } - this.__hideMenu(); + // The middle of the panorama is placed at longitude=0 + var geometry = new THREE.SphereGeometry(SPHERE_RADIUS * scale, this.SPHERE_SEGMENTS, this.SPHERE_HORIZONTAL_SEGMENTS, -Math.PI / 2).scale(-1, 1, 1); + var material = new THREE.MeshBasicMaterial(); + return new THREE.Mesh(geometry, material); } /** * @override */ ; - _proto.show = function show(refresh) { - _AbstractButton.prototype.show.call(this, refresh); + _proto.setTexture = function setTexture(mesh, textureData) { + var _mesh$material$map; - if (this.prop.active) { - this.__showMenu(); - } + (_mesh$material$map = mesh.material.map) == null ? void 0 : _mesh$material$map.dispose(); + mesh.material.map = textureData.texture; } /** * @override - * @description Toggles menu */ ; - _proto.onClick = function onClick() { - if (this.prop.active) { - this.__hideMenu(); - } else { - this.__showMenu(); - } - }; - - _proto.__showMenu = function __showMenu() { - var _this2 = this; - - this.psv.panel.show({ - id: IDS.MENU, - content: MenuButton.MENU_TEMPLATE(this.parent.collapsed, this.psv, dasherize(MenuButton.BUTTON_DATA)), - noMargin: true, - clickHandler: function clickHandler(e) { - var li = e.target ? getClosest(e.target, 'li') : undefined; - var buttonId = li ? li.dataset[MenuButton.BUTTON_DATA] : undefined; - - if (buttonId) { - _this2.parent.getButton(buttonId).onClick(); + _proto.setTextureOpacity = function setTextureOpacity(mesh, opacity) { + mesh.material.opacity = opacity; + mesh.material.transparent = opacity < 1; + } + /** + * @override + */ + ; - _this2.__hideMenu(); - } - } - }); - }; + _proto.disposeTexture = function disposeTexture(textureData) { + var _textureData$texture; - _proto.__hideMenu = function __hideMenu() { - if (this.psv.panel) { - this.psv.panel.hide(IDS.MENU); - } + (_textureData$texture = textureData.texture) == null ? void 0 : _textureData$texture.dispose(); }; - return MenuButton; - }(AbstractButton); - MenuButton.id = 'menu'; - MenuButton.icon = menuIcon; - MenuButton.BUTTON_DATA = 'psvButton'; + return EquirectangularAdapter; + }(AbstractAdapter); + EquirectangularAdapter.id = 'equirectangular'; + EquirectangularAdapter.supportsDownload = true; - MenuButton.MENU_TEMPLATE = function (buttons, psv, dataKey) { - return "\n
\n

" + menuIcon + " " + psv.config.lang.menu + "

\n
    \n " + buttons.map(function (button) { - return "\n
  • \n " + button.container.innerHTML + "\n " + button.container.title + "\n
  • \n "; - }).join('') + "\n
\n
\n"; - }; + /** + * @namespace PSV.components + */ /** - * @summary General information about the system - * @constant - * @memberOf PSV - * @property {boolean} loaded - Indicates if the system data has been loaded - * @property {Function} load - Loads the system if not already loaded - * @property {number} pixelRatio - * @property {boolean} isWebGLSupported - * @property {number} maxCanvasWidth - * @property {string} mouseWheelEvent - * @property {string} fullscreenEvent - * @property {Function} getMaxCanvasWidth - Returns the max width of a canvas allowed by the browser - * @property {Promise} isTouchEnabled + * @summary Base component class + * @memberof PSV.components + * @abstract + */ + var AbstractComponent = /*#__PURE__*/function () { + /** + * @param {PSV.Viewer | PSV.components.AbstractComponent} parent + * @param {string} className - CSS class added to the component's container + */ + function AbstractComponent(parent, className) { + /** + * @summary Reference to main controller + * @type {PSV.Viewer} + * @readonly + */ + this.psv = parent.psv || parent; + /** + * @member {PSV.Viewer|PSV.components.AbstractComponent} + * @readonly + */ + + this.parent = parent; + this.parent.children.push(this); + /** + * @summary All child components + * @type {PSV.components.AbstractComponent[]} + * @readonly + * @package + */ + + this.children = []; + /** + * @summary Internal properties + * @member {Object} + * @protected + * @property {boolean} visible - Visibility of the component + */ + + this.prop = { + visible: true + }; + /** + * @member {HTMLElement} + * @readonly + */ + + this.container = document.createElement('div'); + this.container.className = className; + this.parent.container.appendChild(this.container); + } + /** + * @summary Destroys the component + * @protected + */ + + + var _proto = AbstractComponent.prototype; + + _proto.destroy = function destroy() { + this.parent.container.removeChild(this.container); + var childIdx = this.parent.children.indexOf(this); + + if (childIdx !== -1) { + this.parent.children.splice(childIdx, 1); + } + + this.children.slice().forEach(function (child) { + return child.destroy(); + }); + this.children.length = 0; + delete this.container; + delete this.parent; + delete this.psv; + delete this.prop; + } + /** + * @summary Refresh UI + * @description Must be be a very lightweight operation + * @package + */ + ; + + _proto.refreshUi = function refreshUi() { + var _this = this; + + this.children.every(function (child) { + child.refreshUi(); + return _this.psv.prop.uiRefresh === true; + }); + } + /** + * @summary Displays or hides the component + */ + ; + + _proto.toggle = function toggle() { + if (this.isVisible()) { + this.hide(); + } else { + this.show(); + } + } + /** + * @summary Hides the component + */ + ; + + _proto.hide = function hide() { + this.container.style.display = 'none'; + this.prop.visible = false; + } + /** + * @summary Displays the component + */ + ; + + _proto.show = function show() { + this.container.style.display = ''; + this.prop.visible = true; + } + /** + * @summary Checks if the component is visible + * @returns {boolean} + */ + ; + + _proto.isVisible = function isVisible() { + return this.prop.visible; + }; + + return AbstractComponent; + }(); + + /** + * @namespace PSV.buttons + */ + + /** + * @summary Base navbar button class + * @extends PSV.components.AbstractComponent + * @memberof PSV.buttons + * @abstract + */ + + var AbstractButton = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(AbstractButton, _AbstractComponent); + + /** + * @summary Unique identifier of the button + * @member {string} + * @readonly + * @static + */ + + /** + * @summary Identifier to declare a group of buttons + * @member {string} + * @readonly + * @static + */ + + /** + * @summary SVG icon name injected in the button + * @member {string} + * @readonly + * @static + */ + + /** + * @summary SVG icon name injected in the button when it is active + * @member {string} + * @readonly + * @static + */ + + /** + * @param {PSV.components.Navbar} navbar + * @param {string} [className] - Additional CSS classes + * @param {boolean} [collapsable=false] - `true` if the button can be moved to menu when the navbar is too small + * @param {boolean} [tabbable=true] - `true` if the button is accessible with the keyboard + */ + function AbstractButton(navbar, className, collapsable, tabbable) { + var _this; + + if (className === void 0) { + className = ''; + } + + if (collapsable === void 0) { + collapsable = false; + } + + if (tabbable === void 0) { + tabbable = true; + } + + _this = _AbstractComponent.call(this, navbar, 'psv-button ' + className) || this; + /** + * @override + * @property {string} id - Unique identifier of the button + * @property {boolean} enabled + * @property {boolean} supported + * @property {boolean} collapsed + * @property {boolean} active + * @property {number} width + */ + + _this.prop = _extends({}, _this.prop, { + id: _this.constructor.id, + collapsable: collapsable, + enabled: true, + supported: true, + collapsed: false, + active: false, + width: _this.container.offsetWidth + }); + + if (_this.constructor.icon) { + _this.__setIcon(_this.constructor.icon); + } + + if (_this.prop.id && _this.psv.config.lang[_this.prop.id]) { + _this.container.title = _this.psv.config.lang[_this.prop.id]; + } + + if (tabbable) { + _this.container.tabIndex = 0; + } + + _this.container.addEventListener('click', function (e) { + if (_this.prop.enabled) { + _this.onClick(); + } + + e.stopPropagation(); + }); + + _this.container.addEventListener('keydown', function (e) { + if (e.key === KEY_CODES.Enter && _this.prop.enabled) { + _this.onClick(); + + e.stopPropagation(); + } + }); + + return _this; + } + /** + * @package + */ + + + var _proto = AbstractButton.prototype; + + _proto.checkSupported = function checkSupported() { + var _this2 = this; + + var supportedOrObject = this.isSupported(); + + if (isPlainObject(supportedOrObject)) { + if (supportedOrObject.initial === false) { + this.hide(); + this.prop.supported = false; + } + + supportedOrObject.promise.then(function (supported) { + if (!_this2.prop) { + return; // the component has been destroyed + } + + _this2.prop.supported = supported; + + if (!supported) { + _this2.hide(); + } else { + _this2.show(); + } + }); + } else { + this.prop.supported = supportedOrObject; + + if (!supportedOrObject) { + this.hide(); + } else { + this.show(); + } + } + } + /** + * @summary Checks if the button can be displayed + * @returns {boolean|{initial: boolean, promise: Promise}} + */ + ; + + _proto.isSupported = function isSupported() { + return true; + } + /** + * @summary Changes the active state of the button + * @param {boolean} [active] - forced state + */ + ; + + _proto.toggleActive = function toggleActive(active) { + this.prop.active = active !== undefined ? active : !this.prop.active; + toggleClass(this.container, 'psv-button--active', this.prop.active); + + if (this.constructor.iconActive) { + this.__setIcon(this.prop.active ? this.constructor.iconActive : this.constructor.icon); + } + } + /** + * @override + */ + ; + + _proto.show = function show(refresh) { + if (refresh === void 0) { + refresh = true; + } + + if (!this.isVisible()) { + this.prop.visible = true; + + if (!this.prop.collapsed) { + this.container.style.display = ''; + } + + if (refresh) { + this.psv.refreshUi("show button " + this.prop.id); + } + } + } + /** + * @override + */ + ; + + _proto.hide = function hide(refresh) { + if (refresh === void 0) { + refresh = true; + } + + if (this.isVisible()) { + this.prop.visible = false; + this.container.style.display = 'none'; + + if (refresh) { + this.psv.refreshUi("hide button " + this.prop.id); + } + } + } + /** + * @summary Disables the button + */ + ; + + _proto.disable = function disable() { + this.container.classList.add('psv-button--disabled'); + this.prop.enabled = false; + } + /** + * @summary Enables the button + */ + ; + + _proto.enable = function enable() { + this.container.classList.remove('psv-button--disabled'); + this.prop.enabled = true; + } + /** + * @summary Collapses the button in the navbar menu + */ + ; + + _proto.collapse = function collapse() { + this.prop.collapsed = true; + this.container.style.display = 'none'; + } + /** + * @summary Uncollapses the button from the navbar menu + */ + ; + + _proto.uncollapse = function uncollapse() { + this.prop.collapsed = false; + + if (this.prop.visible) { + this.container.style.display = ''; + } + } + /** + * @summary Set the button icon + * @param {string} icon SVG + * @param {HTMLElement} [container] - default is the main button container + * @private + */ + ; + + _proto.__setIcon = function __setIcon(icon, container) { + if (container === void 0) { + container = this.container; + } + + if (icon) { + container.innerHTML = icon; // className is read-only on SVGElement + + container.querySelector('svg').classList.add('psv-button-svg'); + } else { + container.innerHTML = ''; + } + } + /** + * @summary Action when the button is clicked + * @private + * @abstract + */ + ; + + _proto.onClick = function onClick() { + throw new PSVError("onClick not implemented for button \"" + this.prop.id + "\"."); + }; + + return AbstractButton; + }(AbstractComponent); + AbstractButton.id = null; + AbstractButton.groupId = null; + AbstractButton.icon = null; + AbstractButton.iconActive = null; + + var playActive = "\n"; + + var play = "\n"; + + /** + * @summary Navigation bar autorotate button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ + + var AutorotateButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(AutorotateButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + */ + function AutorotateButton(navbar) { + var _this; + + _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-autorotate-button', true) || this; + + _this.psv.on(EVENTS.AUTOROTATE, _assertThisInitialized(_this)); + + return _this; + } + /** + * @override + */ + + + var _proto = AutorotateButton.prototype; + + _proto.destroy = function destroy() { + this.psv.off(EVENTS.AUTOROTATE, this); + + _AbstractButton.prototype.destroy.call(this); + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + // @formatter:off + case EVENTS.AUTOROTATE: + this.toggleActive(e.args[0]); + break; + // @formatter:on + } + /* eslint-enable */ + + } + /** + * @override + * @description Toggles autorotate + */ + ; + + _proto.onClick = function onClick() { + this.psv.toggleAutorotate(); + }; + + return AutorotateButton; + }(AbstractButton); + AutorotateButton.id = 'autorotate'; + AutorotateButton.icon = play; + AutorotateButton.iconActive = playActive; + + /** + * @summary Navigation bar custom button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ + + var CustomButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(CustomButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + * @param {PSV.NavbarCustomButton} config + */ + function CustomButton(navbar, config) { + var _this; + + _this = _AbstractButton.call(this, navbar, 'psv-custom-button', config.collapsable !== false, config.tabbable !== false) || this; + /** + * @member {Object} + * @readonly + * @private + */ + + _this.config = config; + + if (_this.config.id) { + _this.prop.id = _this.config.id; + } else { + _this.prop.id = 'psvButton-' + Math.random().toString(36).substr(2, 9); + } + + if (_this.config.className) { + addClasses(_this.container, _this.config.className); + } + + if (_this.config.title) { + _this.container.title = _this.config.title; + } + + if (_this.config.content) { + _this.container.innerHTML = _this.config.content; + } + + _this.prop.width = _this.container.offsetWidth; + + if (_this.config.enabled === false) { + _this.disable(); + } + + if (_this.config.visible === false) { + _this.hide(); + } + + return _this; + } + /** + * @override + */ + + + var _proto = CustomButton.prototype; + + _proto.destroy = function destroy() { + delete this.config; + + _AbstractButton.prototype.destroy.call(this); + } + /** + * @override + * @description Calls user method + */ + ; + + _proto.onClick = function onClick() { + if (this.config.onClick) { + this.config.onClick.apply(this.psv); + } + }; + + return CustomButton; + }(AbstractButton); + + /** + * @summary Navbar caption class + * @extends PSV.components.AbstractComponent + * @memberof PSV.components + */ + + var NavbarCaption = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(NavbarCaption, _AbstractComponent); + + /** + * @param {PSV.components.Navbar} navbar + * @param {string} caption + */ + function NavbarCaption(navbar, caption) { + var _this; + + _this = _AbstractComponent.call(this, navbar, 'psv-caption') || this; + /** + * @override + * @property {string} id + * @property {boolean} collapsable + * @property {number} width + * @property {string} caption + * @property {boolean} contentVisible - if the content is visible in the navbar + * @property {number} contentWidth - with of the caption content + */ + + _this.prop = _extends({}, _this.prop, { + id: _this.constructor.id, + collapsable: false, + width: 0, + caption: '', + contentVisible: true, + contentWidth: 0 + }); + /** + * @member {HTMLElement} + * @readonly + * @private + */ + + _this.content = document.createElement('div'); + _this.content.className = 'psv-caption-content'; + + _this.container.appendChild(_this.content); + + _this.setCaption(caption); + + return _this; + } + /** + * @override + */ + + + var _proto = NavbarCaption.prototype; + + _proto.destroy = function destroy() { + delete this.content; + + _AbstractComponent.prototype.destroy.call(this); + } + /** + * @summary Sets the bar caption + * @param {string} html + */ + ; + + _proto.setCaption = function setCaption(html) { + this.prop.caption = html || ''; + this.content.innerHTML = this.prop.caption; + + if (html) { + this.prop.contentWidth = this.content.offsetWidth; + this.refreshUi('caption change'); + } else if (!this.prop.contentVisible) { + this.prop.contentVisible = true; + + this.__refreshButton(); + } + } + /** + * @summary Toggles content and icon depending on available space + * @private + */ + ; + + _proto.refreshUi = function refreshUi() { + var availableWidth = this.container.offsetWidth; + + if (availableWidth >= this.prop.contentWidth && !this.prop.contentVisible) { + this.content.style.display = ''; + this.prop.contentVisible = true; + } else if (availableWidth < this.prop.contentWidth && this.prop.contentVisible) { + this.content.style.display = 'none'; + this.prop.contentVisible = false; + } + + this.__refreshButton(); + } + /** + * @private + */ + ; + + _proto.__refreshButton = function __refreshButton() { + var _this$psv$navbar$getB; + + (_this$psv$navbar$getB = this.psv.navbar.getButton(DescriptionButton.id, false)) == null ? void 0 : _this$psv$navbar$getB.refreshUi(true); + }; + + return NavbarCaption; + }(AbstractComponent); + NavbarCaption.id = 'caption'; + + var info = "\n"; + + var MODE_NOTIF = 1; + var MODE_PANEL = 2; + /** + * @summary Navigation bar description button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons */ - var SYSTEM = { - loaded: false, - pixelRatio: 1, - isWebGLSupported: false, - isTouchEnabled: null, - maxTextureWidth: 0, - mouseWheelEvent: null, - fullscreenEvent: null - }; + var DescriptionButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(DescriptionButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + */ + function DescriptionButton(navbar) { + var _this; + + _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-description-button') || this; + /** + * @override + * @property {string} mode - notification or panel + */ + + _this.prop = _extends({}, _this.prop, { + mode: null + }); + + _this.psv.on(EVENTS.HIDE_NOTIFICATION, _assertThisInitialized(_this)); + + _this.psv.on(EVENTS.SHOW_NOTIFICATION, _assertThisInitialized(_this)); + + _this.psv.on(EVENTS.CLOSE_PANEL, _assertThisInitialized(_this)); + + _this.psv.on(EVENTS.OPEN_PANEL, _assertThisInitialized(_this)); + + return _this; + } + /** + * @override + */ + + + var _proto = DescriptionButton.prototype; + + _proto.destroy = function destroy() { + this.psv.off(EVENTS.HIDE_NOTIFICATION, this); + this.psv.off(EVENTS.SHOW_NOTIFICATION, this); + this.psv.off(EVENTS.CLOSE_PANEL, this); + this.psv.off(EVENTS.OPEN_PANEL, this); + + _AbstractButton.prototype.destroy.call(this); + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + if (!this.prop.mode) { + return; + } + + var closed = false; + + switch (e.type) { + case EVENTS.HIDE_NOTIFICATION: + closed = this.prop.mode === MODE_NOTIF; + break; + + case EVENTS.SHOW_NOTIFICATION: + closed = this.prop.mode === MODE_NOTIF && e.args[0] !== IDS.DESCRIPTION; + break; + + case EVENTS.CLOSE_PANEL: + closed = this.prop.mode === MODE_PANEL; + break; + + case EVENTS.OPEN_PANEL: + closed = this.prop.mode === MODE_PANEL && e.args[0] !== IDS.DESCRIPTION; + break; + } + + if (closed) { + this.toggleActive(false); + this.prop.mode = null; + } + } + /** + * @override + */ + ; + + _proto.hide = function hide(refresh) { + _AbstractButton.prototype.hide.call(this, refresh); + + if (this.prop.mode) { + this.__close(); + } + } + /** + * This button can only be refresh from NavbarCaption + * @override + */ + ; + + _proto.refreshUi = function refreshUi(refresh) { + if (refresh === void 0) { + refresh = false; + } + + if (refresh) { + var caption = this.psv.navbar.getButton(NavbarCaption.id, false); + var captionHidden = caption && !caption.prop.contentVisible; + var hasDescription = !!this.psv.config.description; + + if (captionHidden || hasDescription) { + this.show(false); + } else { + this.hide(false); + } + } + } + /** + * @override + * @description Toggles caption + */ + ; + + _proto.onClick = function onClick() { + if (this.prop.mode) { + this.__close(); + } else { + this.__open(); + } + } + /** + * @private + */ + ; + + _proto.__close = function __close() { + switch (this.prop.mode) { + case MODE_NOTIF: + this.psv.notification.hide(IDS.DESCRIPTION); + break; + + case MODE_PANEL: + this.psv.panel.hide(IDS.DESCRIPTION); + break; + } + } + /** + * @private + */ + ; + + _proto.__open = function __open() { + this.toggleActive(true); + + if (this.psv.config.description) { + this.prop.mode = MODE_PANEL; + this.psv.panel.show({ + id: IDS.DESCRIPTION, + content: "" + (this.psv.config.caption ? "

" + this.psv.config.caption + "

" : '') + this.psv.config.description + }); + } else { + this.prop.mode = MODE_NOTIF; + this.psv.notification.show({ + id: IDS.DESCRIPTION, + content: this.psv.config.caption + }); + } + }; + + return DescriptionButton; + }(AbstractButton); + DescriptionButton.id = 'description'; + DescriptionButton.icon = info; + + var download = "\n"; + /** - * @summary Loads the system if not already loaded + * @summary Navigation bar download button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons */ - SYSTEM.load = function () { - if (!SYSTEM.loaded) { - var ctx = getWebGLCtx(); - SYSTEM.loaded = true; - SYSTEM.pixelRatio = window.devicePixelRatio || 1; - SYSTEM.isWebGLSupported = ctx != null; - SYSTEM.isTouchEnabled = isTouchEnabled(); - SYSTEM.maxTextureWidth = getMaxTextureWidth(ctx); - SYSTEM.mouseWheelEvent = getMouseWheelEvent(); - SYSTEM.fullscreenEvent = getFullscreenEvent(); + var DownloadButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(DownloadButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + */ + function DownloadButton(navbar) { + return _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-download-button', true) || this; } - }; + /** + * @override + */ + + + var _proto = DownloadButton.prototype; + + _proto.isSupported = function isSupported() { + return this.psv.adapter.constructor.supportsDownload || !!this.psv.config.downloadUrl; + } + /** + * @override + * @description Asks the browser to download the panorama source file + */ + ; + + _proto.onClick = function onClick() { + var _this = this; + + var link = document.createElement('a'); + link.href = this.psv.config.downloadUrl || this.psv.config.panorama; + link.download = link.href.split('/').pop(); + this.psv.container.appendChild(link); + link.click(); + setTimeout(function () { + _this.psv.container.removeChild(link); + }, 100); + }; + + return DownloadButton; + }(AbstractButton); + DownloadButton.id = 'download'; + DownloadButton.icon = download; + + var fullscreenIn = "\n"; + + var fullscreenOut = "\n"; + + /** + * @summary Navigation bar fullscreen button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ + + var FullscreenButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(FullscreenButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + */ + function FullscreenButton(navbar) { + var _this; - var maxCanvasWidth = null; + _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-fullscreen-button') || this; - SYSTEM.getMaxCanvasWidth = function () { - if (maxCanvasWidth === null) { - maxCanvasWidth = getMaxCanvasWidth(SYSTEM.maxTextureWidth); + _this.psv.on(EVENTS.FULLSCREEN_UPDATED, _assertThisInitialized(_this)); + + return _this; } + /** + * @override + */ - return maxCanvasWidth; - }; - /** - * @summary Tries to return a canvas webgl context - * @returns {WebGLRenderingContext} - * @private - */ + var _proto = FullscreenButton.prototype; - function getWebGLCtx() { - var canvas = document.createElement('canvas'); - var names = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d']; - var context = null; + _proto.destroy = function destroy() { + this.psv.off(EVENTS.FULLSCREEN_UPDATED, this); - if (!canvas.getContext) { - return null; + _AbstractButton.prototype.destroy.call(this); } + /** + * Handle events + * @param {Event} e + * @private + */ + ; - if (names.some(function (name) { - try { - context = canvas.getContext(name); - return context !== null; - } catch (e) { - return false; + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + // @formatter:off + case EVENTS.FULLSCREEN_UPDATED: + this.toggleActive(e.args[0]); + break; + // @formatter:on } - })) { - return context; - } else { - return null; + /* eslint-enable */ + } - } + /** + * @override + * @description Toggles fullscreen + */ + ; + + _proto.onClick = function onClick() { + this.psv.toggleFullscreen(); + }; + + return FullscreenButton; + }(AbstractButton); + FullscreenButton.id = 'fullscreen'; + FullscreenButton.icon = fullscreenIn; + FullscreenButton.iconActive = fullscreenOut; + + var menuIcon = "\n"; + /** - * @summary Detects if the user is using a touch screen - * @returns {Promise} - * @private + * @summary Navigation bar menu button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons */ + var MenuButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(MenuButton, _AbstractButton); - function isTouchEnabled() { - return new Promise(function (resolve) { - var listener = function listener(e) { - if (e) { - resolve(true); - } else { - resolve(false); - } + /** + * @summary Property name added to buttons list + * @type {string} + * @constant + */ - window.removeEventListener('touchstart', listener); - }; + /** + * @summary Menu template + * @param {AbstractButton[]} buttons + * @param {PSV.Viewer} psv + * @param {string} dataKey + * @returns {string} + */ - window.addEventListener('touchstart', listener, false); // after 10 secs auto-reject the promise + /** + * @param {PSV.components.Navbar} navbar + */ + function MenuButton(navbar) { + var _this; - setTimeout(listener, 10000); - }); - } - /** - * @summary Gets max texture width in WebGL context - * @returns {number} - * @private - */ + _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-menu-button') || this; + _this.psv.on(EVENTS.OPEN_PANEL, _assertThisInitialized(_this)); - function getMaxTextureWidth(ctx) { - if (ctx !== null) { - return ctx.getParameter(ctx.MAX_TEXTURE_SIZE); - } else { - return 0; + _this.psv.on(EVENTS.CLOSE_PANEL, _assertThisInitialized(_this)); + + _this.hide(); + + return _this; } - } - /** - * @summary Gets max canvas width supported by the browser. - * We only test powers of 2 and height = width / 2 because that's what we need to generate WebGL textures - * @param maxWidth - * @return {number} - * @private - */ + /** + * @override + */ - function getMaxCanvasWidth(maxWidth) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - canvas.width = maxWidth; - canvas.height = maxWidth / 2; + var _proto = MenuButton.prototype; - while (canvas.width > 1024) { - ctx.fillStyle = 'white'; - ctx.fillRect(0, 0, 1, 1); + _proto.destroy = function destroy() { + this.psv.off(EVENTS.OPEN_PANEL, this); + this.psv.off(EVENTS.CLOSE_PANEL, this); - try { - if (ctx.getImageData(0, 0, 1, 1).data[0] === 255) { - return canvas.width; - } - } catch (e) {// continue + _AbstractButton.prototype.destroy.call(this); + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + // @formatter:off + case EVENTS.OPEN_PANEL: + this.toggleActive(e.args[0] === IDS.MENU); + break; + + case EVENTS.CLOSE_PANEL: + this.toggleActive(false); + break; + // @formatter:on } + /* eslint-enable */ - canvas.width /= 2; - canvas.height /= 2; } + /** + * @override + */ + ; - throw new PSVError('Unable to detect system capabilities'); - } - /** - * @summary Gets the event name for mouse wheel - * @returns {string} - * @private - */ + _proto.hide = function hide(refresh) { + _AbstractButton.prototype.hide.call(this, refresh); + this.__hideMenu(); + } + /** + * @override + */ + ; - function getMouseWheelEvent() { - if ('onwheel' in document.createElement('div')) { - // Modern browsers support "wheel" - return 'wheel'; - } else if (document.onmousewheel !== undefined) { - // Webkit and IE support at least "mousewheel" - return 'mousewheel'; - } else { - // let's assume that remaining browsers are older Firefox - return 'DOMMouseScroll'; + _proto.show = function show(refresh) { + _AbstractButton.prototype.show.call(this, refresh); + + if (this.prop.active) { + this.__showMenu(); + } } - } - /** - * @summary Map between fullsceen method and fullscreen event name - * @type {Object} - * @readonly - * @private - */ + /** + * @override + * @description Toggles menu + */ + ; + + _proto.onClick = function onClick() { + if (this.prop.active) { + this.__hideMenu(); + } else { + this.__showMenu(); + } + }; + + _proto.__showMenu = function __showMenu() { + var _this2 = this; + + this.psv.panel.show({ + id: IDS.MENU, + content: MenuButton.MENU_TEMPLATE(this.parent.collapsed, this.psv, dasherize(MenuButton.BUTTON_DATA)), + noMargin: true, + clickHandler: function clickHandler(e) { + var li = e.target ? getClosest(e.target, 'li') : undefined; + var buttonId = li ? li.dataset[MenuButton.BUTTON_DATA] : undefined; + + if (buttonId) { + _this2.parent.getButton(buttonId).onClick(); + _this2.__hideMenu(); + } + } + }); + }; - var FULLSCREEN_EVT_MAP = { - exitFullscreen: 'fullscreenchange', - webkitExitFullscreen: 'webkitfullscreenchange', - mozCancelFullScreen: 'mozfullscreenchange', - msExitFullscreen: 'MSFullscreenChange' - }; - /** - * @summary Gets the event name for fullscreen - * @returns {string} - * @private - */ + _proto.__hideMenu = function __hideMenu() { + if (this.psv.panel) { + this.psv.panel.hide(IDS.MENU); + } + }; - function getFullscreenEvent() { - var validExits = Object.keys(FULLSCREEN_EVT_MAP).filter(function (exit) { - return exit in document; - }); + return MenuButton; + }(AbstractButton); + MenuButton.id = 'menu'; + MenuButton.icon = menuIcon; + MenuButton.BUTTON_DATA = 'psvButton'; - if (validExits.length) { - return FULLSCREEN_EVT_MAP[validExits[0]]; - } else { - return null; - } - } + MenuButton.MENU_TEMPLATE = function (buttons, psv, dataKey) { + return "\n
\n

" + menuIcon + " " + psv.config.lang.menu + "

\n
    \n " + buttons.map(function (button) { + return "\n
  • \n " + button.container.innerHTML + "\n " + button.container.title + "\n
  • \n "; + }).join('') + "\n
\n
\n"; + }; var arrow = "\n"; /** * @summary Helper for pressable things (buttons, keyboard) * @description When the pressed thing goes up and was not pressed long enough, wait a bit more before execution - * @package - * @package + * @private */ var PressHandler = /*#__PURE__*/function () { function PressHandler(delay) { @@ -3010,11 +4368,11 @@ break; case 'keydown': - getEventKey(e) === KEY_CODES.Enter && this.__onMouseDown(); + e.key === KEY_CODES.Enter && this.__onMouseDown(); break; case 'keyup': - getEventKey(e) === KEY_CODES.Enter && this.__onMouseUp(); + e.key === KEY_CODES.Enter && this.__onMouseUp(); break; // @formatter:on } @@ -3075,6 +4433,7 @@ return AbstractMoveButton; }(AbstractButton); + AbstractMoveButton.groupId = 'move'; /** * @summary Navigation bar move down button class @@ -3198,240 +4557,14 @@ _this.container.addEventListener('mousedown', _assertThisInitialized(_this)); - _this.container.addEventListener('keydown', _assertThisInitialized(_this)); - - _this.container.addEventListener('keyup', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('mouseup', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('touchend', _assertThisInitialized(_this)); - - return _this; - } - /** - * @override - */ - - - var _proto = AbstractZoomButton.prototype; - - _proto.destroy = function destroy() { - this.__onMouseUp(); - - this.psv.container.removeEventListener('mouseup', this); - this.psv.container.removeEventListener('touchend', this); - - _AbstractButton.prototype.destroy.call(this); - } - /** - * @summary Handles events - * @param {Event} e - * @private - */ - ; - - _proto.handleEvent = function handleEvent(e) { - /* eslint-disable */ - switch (e.type) { - // @formatter:off - case 'mousedown': - this.__onMouseDown(); - - break; - - case 'mouseup': - this.__onMouseUp(); - - break; - - case 'touchend': - this.__onMouseUp(); - - break; - - case 'keydown': - getEventKey(e) === KEY_CODES.Enter && this.__onMouseDown(); - break; - - case 'keyup': - getEventKey(e) === KEY_CODES.Enter && this.__onMouseUp(); - break; - // @formatter:on - } - /* eslint-enable */ - - } - /** - * @override - */ - ; - - _proto.isSupported = function isSupported() { - return { - initial: true, - promise: SYSTEM.isTouchEnabled.then(function (enabled) { - return !enabled; - }) - }; - } - /** - * @override - */ - ; - - _proto.onClick = function onClick() {// nothing - } - /** - * @private - */ - ; - - _proto.__onMouseDown = function __onMouseDown() { - if (!this.prop.enabled) { - return; - } - - this.psv.dynamics.zoom.roll(this.prop.value); - this.prop.handler.down(); - } - /** - * @private - */ - ; - - _proto.__onMouseUp = function __onMouseUp() { - var _this2 = this; - - if (!this.prop.enabled) { - return; - } - - this.prop.handler.up(function () { - return _this2.psv.dynamics.zoom.stop(); - }); - }; - - return AbstractZoomButton; - }(AbstractButton); - - var zoomIn = "\n"; - - /** - * @summary Navigation bar zoom-in button class - * @extends PSV.buttons.AbstractZoomButton - * @memberof PSV.buttons - */ - - var ZoomInButton = /*#__PURE__*/function (_AbstractZoomButton) { - _inheritsLoose(ZoomInButton, _AbstractZoomButton); - - /** - * @param {PSV.components.Navbar} navbar - */ - function ZoomInButton(navbar) { - return _AbstractZoomButton.call(this, navbar, false) || this; - } - - return ZoomInButton; - }(AbstractZoomButton); - ZoomInButton.id = 'zoomIn'; - ZoomInButton.icon = zoomIn; - - var zoomOut = "\n"; - - /** - * @summary Navigation bar zoom-out button class - * @extends PSV.buttons.AbstractZoomButton - * @memberof PSV.buttons - */ - - var ZoomOutButton = /*#__PURE__*/function (_AbstractZoomButton) { - _inheritsLoose(ZoomOutButton, _AbstractZoomButton); - - /** - * @param {PSV.components.Navbar} navbar - */ - function ZoomOutButton(navbar) { - return _AbstractZoomButton.call(this, navbar, true) || this; - } - - return ZoomOutButton; - }(AbstractZoomButton); - ZoomOutButton.id = 'zoomOut'; - ZoomOutButton.icon = zoomOut; - - /** - * @summary Navigation bar zoom button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons - */ - - var ZoomRangeButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(ZoomRangeButton, _AbstractButton); - - /** - * @param {PSV.components.Navbar} navbar - */ - function ZoomRangeButton(navbar) { - var _this; - - _this = _AbstractButton.call(this, navbar, 'psv-zoom-range', false, false) || this; - /** - * @override - * @property {boolean} mousedown - * @property {number} mediaMinWidth - */ - - _this.prop = _extends({}, _this.prop, { - mousedown: false, - mediaMinWidth: 0 - }); - /** - * @member {HTMLElement} - * @readonly - * @private - */ - - _this.zoomRange = document.createElement('div'); - _this.zoomRange.className = 'psv-zoom-range-line'; - - _this.container.appendChild(_this.zoomRange); - /** - * @member {HTMLElement} - * @readonly - * @private - */ - - - _this.zoomValue = document.createElement('div'); - _this.zoomValue.className = 'psv-zoom-range-handle'; - - _this.zoomRange.appendChild(_this.zoomValue); - - _this.prop.mediaMinWidth = parseInt(getStyle(_this.container, 'maxWidth'), 10); - - _this.container.addEventListener('mousedown', _assertThisInitialized(_this)); - - _this.container.addEventListener('touchstart', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('mousemove', _assertThisInitialized(_this)); + _this.container.addEventListener('keydown', _assertThisInitialized(_this)); - _this.psv.container.addEventListener('touchmove', _assertThisInitialized(_this)); + _this.container.addEventListener('keyup', _assertThisInitialized(_this)); _this.psv.container.addEventListener('mouseup', _assertThisInitialized(_this)); _this.psv.container.addEventListener('touchend', _assertThisInitialized(_this)); - _this.psv.on(EVENTS.ZOOM_UPDATED, _assertThisInitialized(_this)); - - if (_this.psv.prop.ready) { - _this.__moveZoomValue(_this.psv.getZoomLevel()); - } else { - _this.psv.once(EVENTS.READY, _assertThisInitialized(_this)); - } - - _this.refreshUi(); - return _this; } /** @@ -3439,18 +4572,13 @@ */ - var _proto = ZoomRangeButton.prototype; + var _proto = AbstractZoomButton.prototype; _proto.destroy = function destroy() { - this.__stopZoomChange(); + this.__onMouseUp(); - this.psv.container.removeEventListener('mousemove', this); - this.psv.container.removeEventListener('touchmove', this); this.psv.container.removeEventListener('mouseup', this); this.psv.container.removeEventListener('touchend', this); - delete this.zoomRange; - delete this.zoomValue; - this.psv.off(EVENTS.ZOOM_UPDATED, this); _AbstractButton.prototype.destroy.call(this); } @@ -3466,43 +4594,26 @@ switch (e.type) { // @formatter:off case 'mousedown': - this.__initZoomChangeWithMouse(e); - - break; - - case 'touchstart': - this.__initZoomChangeByTouch(e); - - break; - - case 'mousemove': - this.__changeZoomWithMouse(e); - - break; - - case 'touchmove': - this.__changeZoomByTouch(e); + this.__onMouseDown(); break; case 'mouseup': - this.__stopZoomChange(e); + this.__onMouseUp(); break; case 'touchend': - this.__stopZoomChange(e); + this.__onMouseUp(); break; - case EVENTS.ZOOM_UPDATED: - this.__moveZoomValue(e.args[0]); - + case 'keydown': + e.key === KEY_CODES.Enter && this.__onMouseDown(); break; - case EVENTS.READY: - this.__moveZoomValue(this.psv.getZoomLevel()); - + case 'keyup': + e.key === KEY_CODES.Enter && this.__onMouseUp(); break; // @formatter:on } @@ -3527,535 +4638,261 @@ */ ; - _proto.refreshUi = function refreshUi() { - if (this.prop.supported) { - if (this.psv.prop.size.width <= this.prop.mediaMinWidth && this.prop.visible) { - this.hide(); - } else if (this.psv.prop.size.width > this.prop.mediaMinWidth && !this.prop.visible) { - this.show(); - } - } - } - /** - * @override - */ - ; - _proto.onClick = function onClick() {// nothing } /** - * @summary Moves the zoom cursor - * @param {number} level - * @private - */ - ; - - _proto.__moveZoomValue = function __moveZoomValue(level) { - this.zoomValue.style.left = level / 100 * this.zoomRange.offsetWidth - this.zoomValue.offsetWidth / 2 + 'px'; - } - /** - * @summary Handles mouse down events - * @param {MouseEvent} evt * @private */ ; - _proto.__initZoomChangeWithMouse = function __initZoomChangeWithMouse(evt) { + _proto.__onMouseDown = function __onMouseDown() { if (!this.prop.enabled) { return; } - this.prop.mousedown = true; - - this.__changeZoom(evt.clientX); + this.psv.dynamics.zoom.roll(this.prop.value); + this.prop.handler.down(); } /** - * @summary Handles touch events - * @param {TouchEvent} evt * @private */ ; - _proto.__initZoomChangeByTouch = function __initZoomChangeByTouch(evt) { - if (!this.prop.enabled) { - return; - } - - this.prop.mousedown = true; - - this.__changeZoom(evt.changedTouches[0].clientX); - } - /** - * @summary Handles mouse up events - * @private - */ - ; + _proto.__onMouseUp = function __onMouseUp() { + var _this2 = this; - _proto.__stopZoomChange = function __stopZoomChange() { if (!this.prop.enabled) { return; - } - - this.prop.mousedown = false; - this.prop.buttondown = false; - } - /** - * @summary Handles mouse move events - * @param {MouseEvent} evt - * @private - */ - ; - - _proto.__changeZoomWithMouse = function __changeZoomWithMouse(evt) { - if (!this.prop.enabled || !this.prop.mousedown) { - return; - } - - evt.preventDefault(); - - this.__changeZoom(evt.clientX); - } - /** - * @summary Handles touch move events - * @param {TouchEvent} evt - * @private - */ - ; - - _proto.__changeZoomByTouch = function __changeZoomByTouch(evt) { - if (!this.prop.enabled || !this.prop.mousedown) { - return; - } - - this.__changeZoom(evt.changedTouches[0].clientX); - } - /** - * @summary Zoom change - * @param {number} x - mouse/touch position - * @private - */ - ; - - _proto.__changeZoom = function __changeZoom(x) { - var userInput = x - this.zoomRange.getBoundingClientRect().left; - var zoomLevel = userInput / this.zoomRange.offsetWidth * 100; - this.psv.zoom(zoomLevel); - }; - - return ZoomRangeButton; - }(AbstractButton); - ZoomRangeButton.id = 'zoomRange'; - - /** - * @namespace PSV.adapters - */ - - /** - * @summary Base adapters class - * @memberof PSV.adapters - * @abstract - */ - - var AbstractAdapter = /*#__PURE__*/function () { - /** - * @summary Unique identifier of the adapter - * @member {string} - * @readonly - * @static - */ - - /** - * @summary Indicates if the adapter supports panorama download natively - * @type {boolean} - * @readonly - * @static - */ - - /** - * @param {PSV.Viewer} psv - */ - function AbstractAdapter(psv) { - /** - * @summary Reference to main controller - * @type {PSV.Viewer} - * @readonly - */ - this.psv = psv; - } - /** - * @summary Destroys the adapter - */ - - - var _proto = AbstractAdapter.prototype; - - _proto.destroy = function destroy() { - delete this.psv; - } - /** - * @summary Indicates if the adapter supports transitions between panoramas - * @param {*} panorama - * @return {boolean} - */ - ; - - _proto.supportsTransition = function supportsTransition(panorama) { - // eslint-disable-line no-unused-vars - return false; - } - /** - * @summary Indicates if the adapter supports preload of a panorama - * @param {*} panorama - * @return {boolean} - */ - ; - - _proto.supportsPreload = function supportsPreload(panorama) { - // eslint-disable-line no-unused-vars - return false; - } - /** - * @abstract - * @summary Loads the panorama texture(s) - * @param {*} panorama - * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData] - * @returns {Promise.} - */ - ; - - _proto.loadTexture = function loadTexture(panorama, newPanoData) { - // eslint-disable-line no-unused-vars - throw new PSVError('loadTexture not implemented'); - } - /** - * @abstract - * @summary Creates the cube mesh - * @param {number} [scale=1] - * @returns {external:THREE.Mesh} - */ - ; - - _proto.createMesh = function createMesh(scale) { - - // eslint-disable-line no-unused-vars - throw new PSVError('createMesh not implemented'); - } - /** - * @abstract - * @summary Applies the texture to the mesh - * @param {external:THREE.Mesh} mesh - * @param {PSV.TextureData} textureData - * @param {boolean} [transition=false] - */ - ; - - _proto.setTexture = function setTexture(mesh, textureData, transition) { - - // eslint-disable-line no-unused-vars - throw new PSVError('setTexture not implemented'); - } - /** - * @abstract - * @summary Changes the opacity of the mesh - * @param {external:THREE.Mesh} mesh - * @param {number} opacity - */ - ; - - _proto.setTextureOpacity = function setTextureOpacity(mesh, opacity) { - // eslint-disable-line no-unused-vars - throw new PSVError('setTextureOpacity not implemented'); - } - /** - * @abstract - * @summary Clear a loaded texture from memory - * @param {PSV.TextureData} textureData - */ - ; + } - _proto.disposeTexture = function disposeTexture(textureData) { - // eslint-disable-line no-unused-vars - throw new PSVError('disposeTexture not implemented'); + this.prop.handler.up(function () { + return _this2.psv.dynamics.zoom.stop(); + }); }; - return AbstractAdapter; - }(); - AbstractAdapter.id = null; - AbstractAdapter.supportsDownload = false; + return AbstractZoomButton; + }(AbstractButton); + AbstractZoomButton.groupId = 'zoom'; - /** - * @typedef {Object} PSV.adapters.EquirectangularAdapter.Options - * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances - */ + var zoomIn = "\n"; /** - * @summary Adapter for equirectangular panoramas - * @memberof PSV.adapters + * @summary Navigation bar zoom-in button class + * @extends PSV.buttons.AbstractZoomButton + * @memberof PSV.buttons */ - var EquirectangularAdapter = /*#__PURE__*/function (_AbstractAdapter) { - _inheritsLoose(EquirectangularAdapter, _AbstractAdapter); + var ZoomInButton = /*#__PURE__*/function (_AbstractZoomButton) { + _inheritsLoose(ZoomInButton, _AbstractZoomButton); /** - * @param {PSV.Viewer} psv - * @param {PSV.adapters.EquirectangularAdapter.Options} options + * @param {PSV.components.Navbar} navbar */ - function EquirectangularAdapter(psv, options) { - var _this; + function ZoomInButton(navbar) { + return _AbstractZoomButton.call(this, navbar, false) || this; + } - _this = _AbstractAdapter.call(this, psv) || this; - /** - * @member {PSV.adapters.EquirectangularAdapter.Options} - * @private - */ + return ZoomInButton; + }(AbstractZoomButton); + ZoomInButton.id = 'zoomIn'; + ZoomInButton.icon = zoomIn; - _this.config = _extends({ - resolution: 64 - }, options); + var zoomOut = "\n"; - if (!isPowerOfTwo(_this.config.resolution)) { - throw new PSVError('EquirectangularAdapter resolution must be power of two'); - } + /** + * @summary Navigation bar zoom-out button class + * @extends PSV.buttons.AbstractZoomButton + * @memberof PSV.buttons + */ + + var ZoomOutButton = /*#__PURE__*/function (_AbstractZoomButton) { + _inheritsLoose(ZoomOutButton, _AbstractZoomButton); - _this.SPHERE_SEGMENTS = _this.config.resolution; - _this.SPHERE_HORIZONTAL_SEGMENTS = _this.SPHERE_SEGMENTS / 2; - return _this; - } /** - * @override + * @param {PSV.components.Navbar} navbar */ + function ZoomOutButton(navbar) { + return _AbstractZoomButton.call(this, navbar, true) || this; + } + return ZoomOutButton; + }(AbstractZoomButton); + ZoomOutButton.id = 'zoomOut'; + ZoomOutButton.icon = zoomOut; - var _proto = EquirectangularAdapter.prototype; + /** + * @summary Navigation bar zoom button class + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ - _proto.supportsTransition = function supportsTransition() { - return true; - } - /** - * @override - */ - ; + var ZoomRangeButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(ZoomRangeButton, _AbstractButton); - _proto.supportsPreload = function supportsPreload() { - return true; - } /** - * @override - * @param {string} panorama - * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData] - * @returns {Promise.} + * @param {PSV.components.Navbar} navbar */ - ; + function ZoomRangeButton(navbar) { + var _this; - _proto.loadTexture = function loadTexture(panorama, newPanoData) { - var _this2 = this; + _this = _AbstractButton.call(this, navbar, 'psv-zoom-range', false, false) || this; + /** + * @override + * @property {number} mediaMinWidth + */ - if (typeof panorama !== 'string') { - if (Array.isArray(panorama) || typeof panorama === 'object' && !!panorama.left) { - logWarn('Cubemap support now requires an additional adapter, see https://photo-sphere-viewer.js.org/guide/adapters'); - } + _this.prop = _extends({}, _this.prop, { + mediaMinWidth: 0 + }); + /** + * @member {HTMLElement} + * @readonly + * @private + */ - return Promise.reject(new PSVError('Invalid panorama url, are you using the right adapter?')); - } + _this.zoomRange = document.createElement('div'); + _this.zoomRange.className = 'psv-zoom-range-line'; - return (!this.psv.config.useXmpData ? this.psv.textureLoader.loadImage(panorama, function (p) { - return _this2.psv.loader.setProgress(p); - }).then(function (img) { - return { - img: img, - xmpPanoData: null - }; - }) : this.__loadXMP(panorama, function (p) { - return _this2.psv.loader.setProgress(p); - }).then(function (xmpPanoData) { - return _this2.psv.textureLoader.loadImage(panorama).then(function (img) { - return { - img: img, - xmpPanoData: xmpPanoData - }; - }); - })).then(function (_ref) { - var _newPanoData, _newPanoData2, _newPanoData3, _newPanoData4, _newPanoData5, _newPanoData6, _newPanoData7, _newPanoData8, _newPanoData9; + _this.container.appendChild(_this.zoomRange); + /** + * @member {HTMLElement} + * @readonly + * @private + */ - var img = _ref.img, - xmpPanoData = _ref.xmpPanoData; - if (typeof newPanoData === 'function') { - newPanoData = newPanoData(img); - } + _this.zoomValue = document.createElement('div'); + _this.zoomValue.className = 'psv-zoom-range-handle'; - var panoData = { - fullWidth: firstNonNull((_newPanoData = newPanoData) == null ? void 0 : _newPanoData.fullWidth, xmpPanoData == null ? void 0 : xmpPanoData.fullWidth, img.width), - fullHeight: firstNonNull((_newPanoData2 = newPanoData) == null ? void 0 : _newPanoData2.fullHeight, xmpPanoData == null ? void 0 : xmpPanoData.fullHeight, img.height), - croppedWidth: firstNonNull((_newPanoData3 = newPanoData) == null ? void 0 : _newPanoData3.croppedWidth, xmpPanoData == null ? void 0 : xmpPanoData.croppedWidth, img.width), - croppedHeight: firstNonNull((_newPanoData4 = newPanoData) == null ? void 0 : _newPanoData4.croppedHeight, xmpPanoData == null ? void 0 : xmpPanoData.croppedHeight, img.height), - croppedX: firstNonNull((_newPanoData5 = newPanoData) == null ? void 0 : _newPanoData5.croppedX, xmpPanoData == null ? void 0 : xmpPanoData.croppedX, 0), - croppedY: firstNonNull((_newPanoData6 = newPanoData) == null ? void 0 : _newPanoData6.croppedY, xmpPanoData == null ? void 0 : xmpPanoData.croppedY, 0), - poseHeading: firstNonNull((_newPanoData7 = newPanoData) == null ? void 0 : _newPanoData7.poseHeading, xmpPanoData == null ? void 0 : xmpPanoData.poseHeading, 0), - posePitch: firstNonNull((_newPanoData8 = newPanoData) == null ? void 0 : _newPanoData8.posePitch, xmpPanoData == null ? void 0 : xmpPanoData.posePitch, 0), - poseRoll: firstNonNull((_newPanoData9 = newPanoData) == null ? void 0 : _newPanoData9.poseRoll, xmpPanoData == null ? void 0 : xmpPanoData.poseRoll, 0) - }; + _this.zoomRange.appendChild(_this.zoomValue); + /** + * @member {PSV.Slider} + * @readonly + * @private + */ - if (panoData.croppedWidth !== img.width || panoData.croppedHeight !== img.height) { - logWarn("Invalid panoData, croppedWidth and/or croppedHeight is not coherent with loaded image.\n panoData: " + panoData.croppedWidth + "x" + panoData.croppedHeight + ", image: " + img.width + "x" + img.height); - } - if ((newPanoData || xmpPanoData) && panoData.fullWidth !== panoData.fullHeight * 2) { - logWarn('Invalid panoData, fullWidth should be twice fullHeight'); + _this.slider = new Slider({ + container: _this.container, + direction: Slider.HORIZONTAL, + onUpdate: function onUpdate(e) { + return _this.__onSliderUpdate(e); } - - var texture = _this2.__createEquirectangularTexture(img, panoData); - - return { - panorama: panorama, - texture: texture, - panoData: panoData - }; }); - } - /** - * @summary Loads the XMP data of an image - * @param {string} panorama - * @param {function(number)} [onProgress] - * @returns {Promise} - * @throws {PSV.PSVError} when the image cannot be loaded - * @private - */ - ; + _this.prop.mediaMinWidth = parseInt(getStyle(_this.container, 'maxWidth'), 10); - _proto.__loadXMP = function __loadXMP(panorama, onProgress) { - var _this3 = this; + _this.psv.on(EVENTS.ZOOM_UPDATED, _assertThisInitialized(_this)); - return this.psv.textureLoader.loadFile(panorama, onProgress).then(function (blob) { - return _this3.__loadBlobAsString(blob); - }).then(function (binary) { - var a = binary.indexOf(''); - var data = binary.substring(a, b); + if (_this.psv.prop.ready) { + _this.__moveZoomValue(_this.psv.getZoomLevel()); + } else { + _this.psv.once(EVENTS.READY, _assertThisInitialized(_this)); + } - if (a !== -1 && b !== -1 && data.indexOf('GPano:') !== -1) { - return { - fullWidth: getXMPValue(data, 'FullPanoWidthPixels'), - fullHeight: getXMPValue(data, 'FullPanoHeightPixels'), - croppedWidth: getXMPValue(data, 'CroppedAreaImageWidthPixels'), - croppedHeight: getXMPValue(data, 'CroppedAreaImageHeightPixels'), - croppedX: getXMPValue(data, 'CroppedAreaLeftPixels'), - croppedY: getXMPValue(data, 'CroppedAreaTopPixels'), - poseHeading: getXMPValue(data, 'PoseHeadingDegrees'), - posePitch: getXMPValue(data, 'PosePitchDegrees'), - poseRoll: getXMPValue(data, 'PoseRollDegrees') - }; - } + _this.refreshUi(); - return null; - }); + return _this; } /** - * @summmary read a Blob as string - * @param {Blob} blob - * @returns {Promise} - * @private + * @override */ - ; - _proto.__loadBlobAsString = function __loadBlobAsString(blob) { - return new Promise(function (resolve, reject) { - var reader = new FileReader(); - reader.onload = function () { - return resolve(reader.result); - }; + var _proto = ZoomRangeButton.prototype; - reader.onerror = reject; - reader.readAsText(blob); - }); + _proto.destroy = function destroy() { + this.slider.destroy(); + delete this.zoomRange; + delete this.zoomValue; + this.psv.off(EVENTS.ZOOM_UPDATED, this); + + _AbstractButton.prototype.destroy.call(this); } /** - * @summary Creates the final texture from image and panorama data - * @param {Image} img - * @param {PSV.PanoData} panoData - * @returns {external:THREE.Texture} + * @summary Handles events + * @param {Event} e * @private */ ; - _proto.__createEquirectangularTexture = function __createEquirectangularTexture(img, panoData) { - // resize image / fill cropped parts with black - if (panoData.fullWidth > SYSTEM.maxTextureWidth || panoData.croppedWidth !== panoData.fullWidth || panoData.croppedHeight !== panoData.fullHeight) { - var ratio = SYSTEM.getMaxCanvasWidth() / panoData.fullWidth; + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + // @formatter:off + case EVENTS.ZOOM_UPDATED: + this.__moveZoomValue(e.args[0]); - var resizedPanoData = _extends({}, panoData); + break; - if (ratio < 1) { - resizedPanoData.fullWidth *= ratio; - resizedPanoData.fullHeight *= ratio; - resizedPanoData.croppedWidth *= ratio; - resizedPanoData.croppedHeight *= ratio; - resizedPanoData.croppedX *= ratio; - resizedPanoData.croppedY *= ratio; - } + case EVENTS.READY: + this.__moveZoomValue(this.psv.getZoomLevel()); - var buffer = document.createElement('canvas'); - buffer.width = resizedPanoData.fullWidth; - buffer.height = resizedPanoData.fullHeight; - var ctx = buffer.getContext('2d'); - ctx.drawImage(img, resizedPanoData.croppedX, resizedPanoData.croppedY, resizedPanoData.croppedWidth, resizedPanoData.croppedHeight); - return createTexture(buffer); + break; + // @formatter:on } + /* eslint-enable */ - return createTexture(img); } /** * @override */ ; - _proto.createMesh = function createMesh(scale) { - if (scale === void 0) { - scale = 1; - } - - // The middle of the panorama is placed at longitude=0 - var geometry = new THREE.SphereGeometry(SPHERE_RADIUS * scale, this.SPHERE_SEGMENTS, this.SPHERE_HORIZONTAL_SEGMENTS, -Math.PI / 2).scale(-1, 1, 1); - var material = new THREE.MeshBasicMaterial(); - return new THREE.Mesh(geometry, material); + _proto.isSupported = function isSupported() { + return { + initial: true, + promise: SYSTEM.isTouchEnabled.then(function (enabled) { + return !enabled; + }) + }; } /** * @override */ ; - _proto.setTexture = function setTexture(mesh, textureData) { - var _mesh$material$map; - - var texture = textureData.texture; - (_mesh$material$map = mesh.material.map) == null ? void 0 : _mesh$material$map.dispose(); - mesh.material.map = texture; + _proto.refreshUi = function refreshUi() { + if (this.prop.supported) { + if (this.psv.prop.size.width <= this.prop.mediaMinWidth && this.prop.visible) { + this.hide(); + } else if (this.psv.prop.size.width > this.prop.mediaMinWidth && !this.prop.visible) { + this.show(); + } + } } /** * @override */ ; - _proto.setTextureOpacity = function setTextureOpacity(mesh, opacity) { - mesh.material.opacity = opacity; - mesh.material.transparent = opacity < 1; + _proto.onClick = function onClick() {// nothing } /** - * @override + * @summary Moves the zoom cursor + * @param {number} level + * @private */ ; - _proto.disposeTexture = function disposeTexture(textureData) { - var _textureData$texture; + _proto.__moveZoomValue = function __moveZoomValue(level) { + this.zoomValue.style.left = level / 100 * this.zoomRange.offsetWidth - this.zoomValue.offsetWidth / 2 + 'px'; + } + /** + * @summary Zoom change + * @private + */ + ; - (_textureData$texture = textureData.texture) == null ? void 0 : _textureData$texture.dispose(); + _proto.__onSliderUpdate = function __onSliderUpdate(e) { + if (e.mousedown) { + this.psv.zoom(e.value * 100); + } }; - return EquirectangularAdapter; - }(AbstractAdapter); - EquirectangularAdapter.id = 'equirectangular'; - EquirectangularAdapter.supportsDownload = true; + return ZoomRangeButton; + }(AbstractButton); + ZoomRangeButton.id = 'zoomRange'; + ZoomRangeButton.groupId = 'zoom'; /** * @namespace PSV.plugins @@ -4130,6 +4967,7 @@ adapter: null, plugins: [], caption: null, + description: null, downloadUrl: null, loadingImg: null, loadingTxt: 'Loading...', @@ -4157,7 +4995,7 @@ requestHeaders: null, canvasBackground: '#000', withCredentials: false, - navbar: ['autorotate', 'zoom', 'move', 'download', 'caption', 'fullscreen'], + navbar: ['autorotate', 'zoom', 'move', 'download', 'description', 'caption', 'fullscreen'], lang: { autorotate: 'Automatic rotation', zoom: 'Zoom', @@ -4335,203 +5173,20 @@ return config; } - var info = "\n"; - - /** - * @summary Navigation bar caption button class - * @extends PSV.buttons.AbstractButton - * @memberof PSV.buttons - */ - - var CaptionButton = /*#__PURE__*/function (_AbstractButton) { - _inheritsLoose(CaptionButton, _AbstractButton); - - /** - * @param {PSV.components.NavbarCaption} caption - */ - function CaptionButton(caption) { - var _this; - - _this = _AbstractButton.call(this, caption, 'psv-button--hover-scale psv-caption-button') || this; - - _this.psv.on(EVENTS.HIDE_NOTIFICATION, _assertThisInitialized(_this)); - - return _this; - } - /** - * @override - */ - - - var _proto = CaptionButton.prototype; - - _proto.destroy = function destroy() { - this.psv.off(EVENTS.HIDE_NOTIFICATION, this); - - _AbstractButton.prototype.destroy.call(this); - } - /** - * @summary Handles events - * @param {Event} e - * @private - */ - ; - - _proto.handleEvent = function handleEvent(e) { - /* eslint-disable */ - switch (e.type) { - // @formatter:off - case EVENTS.HIDE_NOTIFICATION: - this.toggleActive(false); - break; - // @formatter:on - } - /* eslint-enable */ - - } - /** - * @override - * @description Toggles caption - */ - ; - - _proto.onClick = function onClick() { - if (this.psv.notification.prop.visible) { - this.psv.notification.hide(); - } else { - this.psv.notification.show(this.parent.prop.caption); - this.toggleActive(true); - } - }; - - return CaptionButton; - }(AbstractButton); - CaptionButton.id = 'caption'; - CaptionButton.icon = info; - /** - * @summary Navbar caption class - * @extends PSV.components.AbstractComponent - * @memberof PSV.components + * @summary List of available buttons + * @type {Object>} + * @private */ - var NavbarCaption = /*#__PURE__*/function (_AbstractComponent) { - _inheritsLoose(NavbarCaption, _AbstractComponent); - - /** - * @param {PSV.components.Navbar} navbar - * @param {string} caption - */ - function NavbarCaption(navbar, caption) { - var _this; - - _this = _AbstractComponent.call(this, navbar, 'psv-caption') || this; - /** - * @member {PSV.buttons.CaptionButton} - * @readonly - * @private - */ - - _this.button = new CaptionButton(_assertThisInitialized(_this)); - - _this.button.hide(); - /** - * @override - * @property {string} id - * @property {boolean} collapsable - * @property {number} width - * @property {string} caption - * @property {boolean} contentVisible - if the content is visible in the navbar - * @property {number} contentWidth - with of the caption content - */ - - - _this.prop = _extends({}, _this.prop, { - id: _this.constructor.id, - collapsable: false, - width: _this.button.prop.width, - caption: '', - contentVisible: true, - contentWidth: 0 - }); - /** - * @member {HTMLElement} - * @readonly - * @private - */ - - _this.content = document.createElement('div'); - _this.content.className = 'psv-caption-content'; - - _this.container.appendChild(_this.content); - - _this.setCaption(caption); - - return _this; - } - /** - * @override - */ - - - var _proto = NavbarCaption.prototype; - - _proto.destroy = function destroy() { - delete this.button; - delete this.content; - - _AbstractComponent.prototype.destroy.call(this); - } - /** - * @summary Sets the bar caption - * @param {string} html - */ - ; - - _proto.setCaption = function setCaption(html) { - this.prop.caption = html || ''; - this.content.innerHTML = this.prop.caption; - - if (html) { - this.show(false); - this.content.style.display = ''; - this.prop.contentWidth = this.content.offsetWidth; - this.refreshUi(); - } else { - this.hide(); - } - } - /** - * @summary Toggles content and icon depending on available space - * @private - */ - ; - - _proto.refreshUi = function refreshUi() { - var availableWidth = this.container.offsetWidth; - - if (availableWidth >= this.prop.contentWidth && !this.prop.contentVisible) { - this.content.style.display = ''; - this.prop.contentVisible = true; - this.button.hide(false); - } else if (availableWidth < this.prop.contentWidth && this.prop.contentVisible) { - this.content.style.display = 'none'; - this.prop.contentVisible = false; - this.button.show(false); - } - }; - - return NavbarCaption; - }(AbstractComponent); - NavbarCaption.id = 'caption'; - + var AVAILABLE_BUTTONS = {}; /** * @summary List of available buttons - * @type {Object>} + * @type {Object>>} * @private */ - var AVAILABLE_BUTTONS = {}; + var AVAILABLE_GROUPS = {}; /** * @summary Register a new button available for all viewers * @param {Class} button @@ -4547,6 +5202,11 @@ AVAILABLE_BUTTONS[button.id] = button; + if (button.groupId) { + AVAILABLE_GROUPS[button.groupId] = AVAILABLE_GROUPS[button.groupId] || []; + AVAILABLE_GROUPS[button.groupId].push(button); + } + if (typeof defaultPosition === 'string') { switch (defaultPosition) { case 'start': @@ -4566,7 +5226,7 @@ } } } - [AutorotateButton, ZoomInButton, ZoomRangeButton, ZoomOutButton, DownloadButton, FullscreenButton, MoveRightButton, MoveLeftButton, MoveUpButton, MoveDownButton].forEach(registerButton); + [AutorotateButton, ZoomOutButton, ZoomRangeButton, ZoomInButton, DescriptionButton, DownloadButton, FullscreenButton, MoveLeftButton, MoveRightButton, MoveUpButton, MoveDownButton].forEach(registerButton); /** * @summary Navigation bar component * @extends PSV.components.AbstractComponent @@ -4615,29 +5275,31 @@ return item.destroy(); }); this.children.length = 0; + + var cleanedButtons = this.__cleanButtons(buttons); // force description button if caption is present (used on narrow screens) + + + if (cleanedButtons.indexOf(NavbarCaption.id) !== -1 && cleanedButtons.indexOf(DescriptionButton.id) === -1) { + cleanedButtons.splice(cleanedButtons.indexOf(NavbarCaption.id), 0, DescriptionButton.id); + } /* eslint-disable no-new */ - this.__cleanButtons(buttons).forEach(function (button) { + + cleanedButtons.forEach(function (button) { if (typeof button === 'object') { new CustomButton(_this2, button); } else if (AVAILABLE_BUTTONS[button]) { new AVAILABLE_BUTTONS[button](_this2); - } else if (button === 'caption') { + } else if (AVAILABLE_GROUPS[button]) { + AVAILABLE_GROUPS[button].forEach(function (buttonCtor) { + return new buttonCtor(_this2); + }); // eslint-disable-line new-cap + } else if (button === NavbarCaption.id) { new NavbarCaption(_this2, _this2.psv.config.caption); - } else if (button === 'zoom') { - new ZoomOutButton(_this2); - new ZoomRangeButton(_this2); - new ZoomInButton(_this2); - } else if (button === 'move') { - new MoveLeftButton(_this2); - new MoveRightButton(_this2); - new MoveUpButton(_this2); - new MoveDownButton(_this2); } else { throw new PSVError('Unknown button ' + button); } }); - new MenuButton(this); /* eslint-enable no-new */ @@ -4654,7 +5316,7 @@ ; _proto.setCaption = function setCaption(html) { - var caption = this.getButton('caption', false); + var caption = this.getButton(NavbarCaption.id, false); caption == null ? void 0 : caption.setCaption(html); } /** @@ -4922,6 +5584,7 @@ _this.prop = _extends({}, _this.prop, { visible: false, + contentId: undefined, timeout: null }); /** @@ -4954,9 +5617,29 @@ _AbstractComponent.prototype.destroy.call(this); } + /** + * @override + * @param {string} [id] + */ + ; + + _proto.isVisible = function isVisible(id) { + return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id); + } + /** + * @override + * @summary This method is not supported + * @throws {PSV.PSVError} always + */ + ; + + _proto.toggle = function toggle() { + throw new PSVError('Notification cannot be toggled'); + } /** * @summary Displays a notification on the viewer * @param {Object|string} config + * @param {string} [config.id] - unique identifier to use with "hide" * @param {string} config.content * @param {number} [config.timeout] * @fires PSV.show-notification @@ -4982,28 +5665,32 @@ }; } + this.prop.contentId = config.id; this.content.innerHTML = config.content; - this.prop.visible = true; this.container.classList.add('psv-notification--visible'); - this.psv.trigger(EVENTS.SHOW_NOTIFICATION); + this.prop.visible = true; + this.psv.trigger(EVENTS.SHOW_NOTIFICATION, config.id); if (config.timeout) { this.prop.timeout = setTimeout(function () { - return _this2.hide(); + return _this2.hide(config.id); }, config.timeout); } } /** * @summary Hides the notification + * @param {string} [id] * @fires PSV.hide-notification */ ; - _proto.hide = function hide() { - if (this.prop.visible) { + _proto.hide = function hide(id) { + if (this.isVisible(id)) { + var contentId = this.prop.contentId; this.container.classList.remove('psv-notification--visible'); this.prop.visible = false; - this.psv.trigger(EVENTS.HIDE_NOTIFICATION); + this.prop.contentId = undefined; + this.psv.trigger(EVENTS.HIDE_NOTIFICATION, contentId); } }; @@ -5072,9 +5759,9 @@ _this.container.appendChild(_this.subtext); - _this.container.addEventListener('mouseup', _assertThisInitialized(_this)); + _this.psv.on(EVENTS.CLICK, _assertThisInitialized(_this)); - document.addEventListener('keydown', _assertThisInitialized(_this)); + _this.psv.on(EVENTS.KEY_PRESS, _assertThisInitialized(_this)); _AbstractComponent.prototype.hide.call(_assertThisInitialized(_this)); @@ -5088,7 +5775,8 @@ var _proto = Overlay.prototype; _proto.destroy = function destroy() { - document.removeEventListener('keydown', this); + this.psv.off(EVENTS.CLICK, this); + this.psv.off(EVENTS.KEY_PRESS, this); delete this.image; delete this.text; delete this.subtext; @@ -5104,241 +5792,22 @@ _proto.handleEvent = function handleEvent(e) { /* eslint-disable */ - switch (e.type) { - // @formatter:off - case 'mouseup': - this.prop.dissmisable && this.hide(); - break; - - case 'keydown': - getEventKey(e) === KEY_CODES.Escape && this.prop.dissmisable && this.hide(); - break; - // @formatter:on - } - /* eslint-enable */ - - } - /** - * @override - * @param {string} [id] - */ - ; - - _proto.isVisible = function isVisible(id) { - return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id); - } - /** - * @override - * @summary This method is not supported - * @throws {PSV.PSVError} always - */ - ; - - _proto.toggle = function toggle() { - throw new PSVError('Overlay cannot be toggled'); - } - /** - * @summary Displays an overlay on the viewer - * @param {Object|string} config - * @param {string} [config.id] - unique identifier to use with "hide" - * @param {string} config.image - SVG image/icon displayed above the text - * @param {string} config.text - main message - * @param {string} [config.subtext] - secondary message - * @param {boolean} [config.dissmisable=true] - if the user can hide the overlay by clicking - * @fires PSV.show-overlay - */ - ; - - _proto.show = function show(config) { - if (typeof config === 'string') { - config = { - text: config - }; - } - - this.prop.contentId = config.id; - this.prop.dissmisable = config.dissmisable !== false; - this.image.innerHTML = config.image || ''; - this.text.innerHTML = config.text || ''; - this.subtext.innerHTML = config.subtext || ''; - - _AbstractComponent.prototype.show.call(this); - - this.psv.trigger(EVENTS.SHOW_OVERLAY, config.id); - } - /** - * @summary Hides the overlay - * @param {string} [id] - * @fires PSV.hide-overlay - */ - ; - - _proto.hide = function hide(id) { - if (this.isVisible() && (!id || !this.prop.contentId || this.prop.contentId === id)) { - var contentId = this.prop.contentId; - - _AbstractComponent.prototype.hide.call(this); - - this.prop.contentId = undefined; - this.psv.trigger(EVENTS.HIDE_OVERLAY, contentId); - } - }; - - return Overlay; - }(AbstractComponent); - - /** - * @summary Minimum width of the panel - * @type {number} - * @constant - * @private - */ - - var PANEL_MIN_WIDTH = 200; - /** - * @summary Panel component - * @extends PSV.components.AbstractComponent - * @memberof PSV.components - */ - - var Panel = /*#__PURE__*/function (_AbstractComponent) { - _inheritsLoose(Panel, _AbstractComponent); - - /** - * @param {PSV.Viewer} psv - */ - function Panel(psv) { - var _this; - - _this = _AbstractComponent.call(this, psv, 'psv-panel') || this; - /** - * @override - * @property {string} contentId - * @property {number} mouseX - * @property {number} mouseY - * @property {boolean} mousedown - * @property {function} clickHandler - * @property {function} keyHandler - */ - - _this.prop = _extends({}, _this.prop, { - visible: false, - contentId: undefined, - mouseX: 0, - mouseY: 0, - mousedown: false, - clickHandler: null, - keyHandler: null, - width: {} - }); - var resizer = document.createElement('div'); - resizer.className = 'psv-panel-resizer'; - - _this.container.appendChild(resizer); - - var closeBtn = document.createElement('div'); - closeBtn.className = 'psv-panel-close-button'; - - _this.container.appendChild(closeBtn); - /** - * @summary Content container - * @member {HTMLElement} - * @readonly - * @private - */ - - - _this.content = document.createElement('div'); - _this.content.className = 'psv-panel-content'; - - _this.container.appendChild(_this.content); // Stop wheel event bubbling from panel - - - _this.container.addEventListener(SYSTEM.mouseWheelEvent, function (e) { - return e.stopPropagation(); - }); - - closeBtn.addEventListener('click', function () { - return _this.hide(); - }); // Event for panel resizing + stop bubling - - resizer.addEventListener('mousedown', _assertThisInitialized(_this)); - resizer.addEventListener('touchstart', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('mouseup', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('touchend', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('mousemove', _assertThisInitialized(_this)); - - _this.psv.container.addEventListener('touchmove', _assertThisInitialized(_this)); - - document.addEventListener('keydown', _assertThisInitialized(_this)); - return _this; - } - /** - * @override - */ - - - var _proto = Panel.prototype; - - _proto.destroy = function destroy() { - this.psv.container.removeEventListener('mousemove', this); - this.psv.container.removeEventListener('touchmove', this); - this.psv.container.removeEventListener('mouseup', this); - this.psv.container.removeEventListener('touchend', this); - document.removeEventListener('keydown', this); - delete this.prop; - delete this.content; - - _AbstractComponent.prototype.destroy.call(this); - } - /** - * @summary Handles events - * @param {Event} e - * @private - */ - ; - - _proto.handleEvent = function handleEvent(e) { - /* eslint-disable */ - switch (e.type) { - // @formatter:off - case 'mousedown': - this.__onMouseDown(e); - - break; - - case 'touchstart': - this.__onTouchStart(e); - - break; - - case 'mousemove': - this.__onMouseMove(e); - - break; - - case 'touchmove': - this.__onTouchMove(e); - - break; - - case 'mouseup': - this.__onMouseUp(e); - - break; - - case 'touchend': - this.__onMouseUp(e); + switch (e.type) { + case EVENTS.CLICK: + if (this.isVisible() && this.prop.dissmisable) { + this.hide(); + e.stopPropagation(); + } break; - case 'keydown': - getEventKey(e) === KEY_CODES.Escape && this.hide(); + case EVENTS.KEY_PRESS: + if (this.isVisible() && this.prop.dissmisable && e.args[0] === KEY_CODES.Escape) { + this.hide(); + e.preventDefault(); + } + break; - // @formatter:on } /* eslint-enable */ @@ -5360,2421 +5829,2175 @@ ; _proto.toggle = function toggle() { - throw new PSVError('Panel cannot be toggled'); + throw new PSVError('Overlay cannot be toggled'); } /** - * @summary Shows the panel - * @param {string|Object} config - * @param {string} [config.id] - unique identifier to use with "hide" and to store the user desired width - * @param {string} config.content - HTML content of the panel - * @param {boolean} [config.noMargin=false] - remove the default margins - * @param {string} [config.width] - initial width - * @param {Function} [config.clickHandler] - called when the user clicks inside the panel or presses the Enter key while an element focused - * @fires PSV.open-panel + * @summary Displays an overlay on the viewer + * @param {Object|string} config + * @param {string} [config.id] - unique identifier to use with "hide" + * @param {string} config.image - SVG image/icon displayed above the text + * @param {string} config.text - main message + * @param {string} [config.subtext] - secondary message + * @param {boolean} [config.dissmisable=true] - if the user can hide the overlay by clicking + * @fires PSV.show-overlay */ ; _proto.show = function show(config) { - var _this2 = this; - - var wasVisible = this.isVisible(config.id); - if (typeof config === 'string') { config = { - content: config + text: config }; } this.prop.contentId = config.id; - this.prop.visible = true; - - if (this.prop.clickHandler) { - this.content.removeEventListener('click', this.prop.clickHandler); - this.content.removeEventListener('keydown', this.prop.keyHandler); - this.prop.clickHandler = null; - this.prop.keyHandler = null; - } - - if (config.id && this.prop.width[config.id]) { - this.container.style.width = this.prop.width[config.id]; - } else if (config.width) { - this.container.style.width = config.width; - } else { - this.container.style.width = null; - } - - this.content.innerHTML = config.content; - this.content.scrollTop = 0; - this.container.classList.add('psv-panel--open'); - toggleClass(this.content, 'psv-panel-content--no-margin', config.noMargin === true); - - if (config.clickHandler) { - this.prop.clickHandler = config.clickHandler; - - this.prop.keyHandler = function (e) { - if (getEventKey(e) === KEY_CODES.Enter) { - config.clickHandler(e); - } - }; - - this.content.addEventListener('click', this.prop.clickHandler); - this.content.addEventListener('keydown', this.prop.keyHandler); // focus the first element if possible, after animation ends - - if (!wasVisible) { - setTimeout(function () { - var _this2$content$queryS; + this.prop.dissmisable = config.dissmisable !== false; + this.image.innerHTML = config.image || ''; + this.text.innerHTML = config.text || ''; + this.subtext.innerHTML = config.subtext || ''; - (_this2$content$queryS = _this2.content.querySelector('a,button,[tabindex]')) == null ? void 0 : _this2$content$queryS.focus(); - }, 300); - } - } + _AbstractComponent.prototype.show.call(this); - this.psv.trigger(EVENTS.OPEN_PANEL, config.id); + this.psv.trigger(EVENTS.SHOW_OVERLAY, config.id); } /** - * @summary Hides the panel + * @summary Hides the overlay * @param {string} [id] - * @fires PSV.close-panel + * @fires PSV.hide-overlay */ ; _proto.hide = function hide(id) { if (this.isVisible(id)) { var contentId = this.prop.contentId; - this.prop.visible = false; - this.prop.contentId = undefined; - this.content.innerHTML = null; - this.container.classList.remove('psv-panel--open'); - - if (this.prop.clickHandler) { - this.content.removeEventListener('click', this.prop.clickHandler); - this.prop.clickHandler = null; - } - - this.psv.trigger(EVENTS.CLOSE_PANEL, contentId); - } - } - /** - * @summary Handles mouse down events - * @param {MouseEvent} evt - * @private - */ - ; - - _proto.__onMouseDown = function __onMouseDown(evt) { - evt.stopPropagation(); - - this.__startResize(evt); - } - /** - * @summary Handles touch events - * @param {TouchEvent} evt - * @private - */ - ; - - _proto.__onTouchStart = function __onTouchStart(evt) { - evt.stopPropagation(); - - this.__startResize(evt.changedTouches[0]); - } - /** - * @summary Handles mouse up events - * @param {MouseEvent} evt - * @private - */ - ; - - _proto.__onMouseUp = function __onMouseUp(evt) { - if (this.prop.mousedown) { - evt.stopPropagation(); - this.prop.mousedown = false; - this.content.classList.remove('psv-panel-content--no-interaction'); - } - } - /** - * @summary Handles mouse move events - * @param {MouseEvent} evt - * @private - */ - ; - - _proto.__onMouseMove = function __onMouseMove(evt) { - if (this.prop.mousedown) { - evt.stopPropagation(); - - this.__resize(evt); - } - } - /** - * @summary Handles touch move events - * @param {TouchEvent} evt - * @private - */ - ; - - _proto.__onTouchMove = function __onTouchMove(evt) { - if (this.prop.mousedown) { - this.__resize(evt.touches[0]); - } - } - /** - * @summary Initializes the panel resize - * @param {MouseEvent|Touch} evt - * @private - */ - ; - - _proto.__startResize = function __startResize(evt) { - this.prop.mouseX = evt.clientX; - this.prop.mouseY = evt.clientY; - this.prop.mousedown = true; - this.content.classList.add('psv-panel-content--no-interaction'); - } - /** - * @summary Resizes the panel - * @param {MouseEvent|Touch} evt - * @private - */ - ; - _proto.__resize = function __resize(evt) { - var x = evt.clientX; - var y = evt.clientY; - var width = Math.max(PANEL_MIN_WIDTH, this.container.offsetWidth - (x - this.prop.mouseX)) + 'px'; + _AbstractComponent.prototype.hide.call(this); - if (this.prop.contentId) { - this.prop.width[this.prop.contentId] = width; + this.prop.contentId = undefined; + this.psv.trigger(EVENTS.HIDE_OVERLAY, contentId); } - - this.container.style.width = width; - this.prop.mouseX = x; - this.prop.mouseY = y; }; - return Panel; + return Overlay; }(AbstractComponent); - var errorIcon = "\n"; - /** - * @namespace PSV.services + * @summary Minimum width of the panel + * @type {number} + * @constant + * @private */ + var PANEL_MIN_WIDTH = 200; /** - * @summary Base services class - * @memberof PSV.services - * @abstract + * @summary Panel component + * @extends PSV.components.AbstractComponent + * @memberof PSV.components */ - var AbstractService = /*#__PURE__*/function () { + + var Panel = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(Panel, _AbstractComponent); + /** * @param {PSV.Viewer} psv */ - function AbstractService(psv) { - /** - * @summary Reference to main controller - * @type {PSV.Viewer} - * @readonly - */ - this.psv = psv; + function Panel(psv) { + var _this; + + _this = _AbstractComponent.call(this, psv, 'psv-panel') || this; /** - * @summary Configuration holder - * @type {PSV.Options} - * @readonly + * @override + * @property {string} contentId + * @property {number} mouseX + * @property {number} mouseY + * @property {boolean} mousedown + * @property {function} clickHandler + * @property {function} keyHandler */ - this.config = psv.config; + _this.prop = _extends({}, _this.prop, { + visible: false, + contentId: undefined, + mouseX: 0, + mouseY: 0, + mousedown: false, + clickHandler: null, + keyHandler: null, + width: {} + }); + var resizer = document.createElement('div'); + resizer.className = 'psv-panel-resizer'; + + _this.container.appendChild(resizer); + + var closeBtn = document.createElement('div'); + closeBtn.className = 'psv-panel-close-button'; + + _this.container.appendChild(closeBtn); /** - * @summary Properties holder - * @type {Object} + * @summary Content container + * @member {HTMLElement} * @readonly + * @private */ - this.prop = psv.prop; - } - /** - * @summary Destroys the service - */ - - - var _proto = AbstractService.prototype; - _proto.destroy = function destroy() { - delete this.psv; - delete this.config; - delete this.prop; - }; + _this.content = document.createElement('div'); + _this.content.className = 'psv-panel-content'; - return AbstractService; - }(); + _this.container.appendChild(_this.content); // Stop wheel event bubbling from panel - var vector2 = new THREE.Vector2(); - var vector3 = new THREE.Vector3(); - var eulerZero = new THREE.Euler(0, 0, 0, 'ZXY'); - /** - * @summary Collections of data converters for the current viewer - * @extends PSV.services.AbstractService - * @memberof PSV.services - */ - var DataHelper = /*#__PURE__*/function (_AbstractService) { - _inheritsLoose(DataHelper, _AbstractService); + _this.container.addEventListener(SYSTEM.mouseWheelEvent, function (e) { + return e.stopPropagation(); + }); - /** - * @param {PSV.Viewer} psv - */ - function DataHelper(psv) { - return _AbstractService.call(this, psv) || this; - } - /** - * @summary Converts vertical FOV to zoom level - * @param {number} fov - * @returns {number} - */ + closeBtn.addEventListener('click', function () { + return _this.hide(); + }); // Event for panel resizing + stop bubling + resizer.addEventListener('mousedown', _assertThisInitialized(_this)); + resizer.addEventListener('touchstart', _assertThisInitialized(_this)); - var _proto = DataHelper.prototype; + _this.psv.container.addEventListener('mouseup', _assertThisInitialized(_this)); - _proto.fovToZoomLevel = function fovToZoomLevel(fov) { - var temp = Math.round((fov - this.config.minFov) / (this.config.maxFov - this.config.minFov) * 100); - return temp - 2 * (temp - 50); - } - /** - * @summary Converts zoom level to vertical FOV - * @param {number} level - * @returns {number} - */ - ; + _this.psv.container.addEventListener('touchend', _assertThisInitialized(_this)); - _proto.zoomLevelToFov = function zoomLevelToFov(level) { - return this.config.maxFov + level / 100 * (this.config.minFov - this.config.maxFov); - } - /** - * @summary Convert vertical FOV to horizontal FOV - * @param {number} vFov - * @returns {number} - */ - ; + _this.psv.container.addEventListener('mousemove', _assertThisInitialized(_this)); - _proto.vFovToHFov = function vFovToHFov(vFov) { - return THREE.Math.radToDeg(2 * Math.atan(Math.tan(THREE.Math.degToRad(vFov) / 2) * this.prop.aspect)); - } - /** - * @summary Converts a speed into a duration from current position to a new position - * @param {string|number} value - * @param {number} angle - * @returns {number} - */ - ; + _this.psv.container.addEventListener('touchmove', _assertThisInitialized(_this)); - _proto.speedToDuration = function speedToDuration(value, angle) { - if (!value || typeof value !== 'number') { - // desired radial speed - var speed = value ? parseSpeed(value) : this.config.autorotateSpeed; // compute duration + _this.psv.on(EVENTS.KEY_PRESS, _assertThisInitialized(_this)); - return angle / Math.abs(speed) * 1000; - } else { - return Math.abs(value); - } + return _this; } /** - * @summary Converts pixel texture coordinates to spherical radians coordinates - * @param {PSV.Point} point - * @returns {PSV.Position} - * @throws {PSV.PSVError} when the current adapter does not support texture coordinates + * @override */ - ; - _proto.textureCoordsToSphericalCoords = function textureCoordsToSphericalCoords(point) { - var panoData = this.prop.panoData; - if (!panoData) { - throw new PSVError('Current adapter does not support texture coordinates.'); - } + var _proto = Panel.prototype; - var relativeX = (point.x + panoData.croppedX) / panoData.fullWidth * Math.PI * 2; - var relativeY = (point.y + panoData.croppedY) / panoData.fullHeight * Math.PI; - var result = { - longitude: relativeX >= Math.PI ? relativeX - Math.PI : relativeX + Math.PI, - latitude: Math.PI / 2 - relativeY - }; // Apply panoData pose and sphereCorrection + _proto.destroy = function destroy() { + this.psv.off(EVENTS.KEY_PRESS, this); + this.psv.container.removeEventListener('mousemove', this); + this.psv.container.removeEventListener('touchmove', this); + this.psv.container.removeEventListener('mouseup', this); + this.psv.container.removeEventListener('touchend', this); + delete this.prop; + delete this.content; - if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) { - this.sphericalCoordsToVector3(result, vector3); - vector3.applyEuler(this.psv.renderer.mesh.rotation); - vector3.applyEuler(this.psv.renderer.meshContainer.rotation); - return this.vector3ToSphericalCoords(vector3); - } else { - return result; - } + _AbstractComponent.prototype.destroy.call(this); } /** - * @summary Converts spherical radians coordinates to pixel texture coordinates - * @param {PSV.Position} position - * @returns {PSV.Point} - * @throws {PSV.PSVError} when the current adapter does not support texture coordinates + * @summary Handles events + * @param {Event} e + * @private */ ; - _proto.sphericalCoordsToTextureCoords = function sphericalCoordsToTextureCoords(position) { - var panoData = this.prop.panoData; + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + // @formatter:off + case 'mousedown': + this.__onMouseDown(e); - if (!panoData) { - throw new PSVError('Current adapter does not support texture coordinates.'); - } // Apply panoData pose and sphereCorrection + break; + case 'touchstart': + this.__onTouchStart(e); - if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) { - this.sphericalCoordsToVector3(position, vector3); - applyEulerInverse(vector3, this.psv.renderer.meshContainer.rotation); - applyEulerInverse(vector3, this.psv.renderer.mesh.rotation); - position = this.vector3ToSphericalCoords(vector3); - } + break; - var relativeLong = position.longitude / Math.PI / 2 * panoData.fullWidth; - var relativeLat = position.latitude / Math.PI * panoData.fullHeight; - return { - x: Math.round(position.longitude < Math.PI ? relativeLong + panoData.fullWidth / 2 : relativeLong - panoData.fullWidth / 2) - panoData.croppedX, - y: Math.round(panoData.fullHeight / 2 - relativeLat) - panoData.croppedY - }; - } - /** - * @summary Converts spherical radians coordinates to a THREE.Vector3 - * @param {PSV.Position} position - * @param {external:THREE.Vector3} [vector] - * @returns {external:THREE.Vector3} - */ - ; + case 'mousemove': + this.__onMouseMove(e); - _proto.sphericalCoordsToVector3 = function sphericalCoordsToVector3(position, vector) { - if (!vector) { - vector = new THREE.Vector3(); - } + break; - vector.x = SPHERE_RADIUS * -Math.cos(position.latitude) * Math.sin(position.longitude); - vector.y = SPHERE_RADIUS * Math.sin(position.latitude); - vector.z = SPHERE_RADIUS * Math.cos(position.latitude) * Math.cos(position.longitude); - return vector; - } - /** - * @summary Converts a THREE.Vector3 to spherical radians coordinates - * @param {external:THREE.Vector3} vector - * @returns {PSV.Position} - */ - ; + case 'touchmove': + this.__onTouchMove(e); - _proto.vector3ToSphericalCoords = function vector3ToSphericalCoords(vector) { - var phi = Math.acos(vector.y / Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z)); - var theta = Math.atan2(vector.x, vector.z); - return { - longitude: theta < 0 ? -theta : Math.PI * 2 - theta, - latitude: Math.PI / 2 - phi - }; - } - /** - * @summary Converts position on the viewer to a THREE.Vector3 - * @param {PSV.Point} viewerPoint - * @returns {external:THREE.Vector3} - */ - ; + break; - _proto.viewerCoordsToVector3 = function viewerCoordsToVector3(viewerPoint) { - var sphereIntersect = this.getIntersections(viewerPoint).filter(function (i) { - return i.object.userData[MESH_USER_DATA]; - }); + case 'mouseup': + this.__onMouseUp(e); - if (sphereIntersect) { - return sphereIntersect.point; - } else { - return null; - } - } - /** - * @summary Converts a THREE.Vector3 to position on the viewer - * @param {external:THREE.Vector3} vector - * @returns {PSV.Point} - */ - ; + break; - _proto.vector3ToViewerCoords = function vector3ToViewerCoords(vector) { - var vectorClone = vector.clone(); - vectorClone.project(this.psv.renderer.camera); - return { - x: Math.round((vectorClone.x + 1) / 2 * this.prop.size.width), - y: Math.round((1 - vectorClone.y) / 2 * this.prop.size.height) - }; - } - /** - * @summary Converts spherical radians coordinates to position on the viewer - * @param {PSV.Position} position - * @returns {PSV.Point} - */ - ; + case 'touchend': + this.__onMouseUp(e); - _proto.sphericalCoordsToViewerCoords = function sphericalCoordsToViewerCoords(position) { - return this.vector3ToViewerCoords(this.sphericalCoordsToVector3(position, vector3)); - } - /** - * @summary Returns intersections with objects in the scene - * @param {PSV.Point} viewerPoint - * @return {external:THREE.Intersection[]} - */ - ; + break; + + case EVENTS.KEY_PRESS: + if (this.isVisible() && e.args[0] === KEY_CODES.Escape) { + this.hide(); + e.preventDefault(); + } + + break; + // @formatter:on + } + /* eslint-enable */ - _proto.getIntersections = function getIntersections(viewerPoint) { - vector2.x = 2 * viewerPoint.x / this.prop.size.width - 1; - vector2.y = -2 * viewerPoint.y / this.prop.size.height + 1; - this.psv.renderer.raycaster.setFromCamera(vector2, this.psv.renderer.camera); - return this.psv.renderer.raycaster.intersectObjects(this.psv.renderer.scene.children, true).filter(function (i) { - return !!i.object.userData; - }); } /** - * @summary Converts x/y to latitude/longitude if present and ensure boundaries - * @param {PSV.ExtendedPosition} position - * @returns {PSV.Position} + * @override + * @param {string} [id] */ ; - _proto.cleanPosition = function cleanPosition(position) { - if (position.x !== undefined && position.y !== undefined) { - return this.textureCoordsToSphericalCoords(position); - } else { - return { - longitude: parseAngle(position.longitude), - latitude: parseAngle(position.latitude, true) - }; - } + _proto.isVisible = function isVisible(id) { + return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id); } /** - * @summary Ensure a SphereCorrection object is valid - * @param {PSV.SphereCorrection} sphereCorrection - * @returns {PSV.SphereCorrection} + * @override + * @summary This method is not supported + * @throws {PSV.PSVError} always */ ; - _proto.cleanSphereCorrection = function cleanSphereCorrection(sphereCorrection) { - return { - pan: parseAngle((sphereCorrection == null ? void 0 : sphereCorrection.pan) || 0), - tilt: parseAngle((sphereCorrection == null ? void 0 : sphereCorrection.tilt) || 0, true), - roll: parseAngle((sphereCorrection == null ? void 0 : sphereCorrection.roll) || 0, true, false) - }; + _proto.toggle = function toggle() { + throw new PSVError('Panel cannot be toggled'); } /** - * @summary Parse the pose angles of the pano data - * @param {PSV.PanoData} panoData - * @returns {PSV.SphereCorrection} + * @summary Shows the panel + * @param {string|Object} config + * @param {string} [config.id] - unique identifier to use with "hide" and to store the user desired width + * @param {string} config.content - HTML content of the panel + * @param {boolean} [config.noMargin=false] - remove the default margins + * @param {string} [config.width] - initial width + * @param {Function} [config.clickHandler] - called when the user clicks inside the panel or presses the Enter key while an element focused + * @fires PSV.open-panel */ ; - _proto.cleanPanoramaPose = function cleanPanoramaPose(panoData) { - return { - pan: THREE.Math.degToRad((panoData == null ? void 0 : panoData.poseHeading) || 0), - tilt: THREE.Math.degToRad((panoData == null ? void 0 : panoData.posePitch) || 0), - roll: THREE.Math.degToRad((panoData == null ? void 0 : panoData.poseRoll) || 0) - }; - }; + _proto.show = function show(config) { + var _this2 = this; - return DataHelper; - }(AbstractService); + var wasVisible = this.isVisible(config.id); - var gestureIcon = "\n"; + if (typeof config === 'string') { + config = { + content: config + }; + } - var mousewheelIcon = "\n"; + this.prop.contentId = config.id; + this.prop.visible = true; - /** - * @summary Events handler - * @extends PSV.services.AbstractService - * @memberof PSV.services - */ + if (this.prop.clickHandler) { + this.content.removeEventListener('click', this.prop.clickHandler); + this.content.removeEventListener('keydown', this.prop.keyHandler); + this.prop.clickHandler = null; + this.prop.keyHandler = null; + } - var EventsHandler = /*#__PURE__*/function (_AbstractService) { - _inheritsLoose(EventsHandler, _AbstractService); + if (config.id && this.prop.width[config.id]) { + this.container.style.width = this.prop.width[config.id]; + } else if (config.width) { + this.container.style.width = config.width; + } else { + this.container.style.width = null; + } + + this.content.innerHTML = config.content; + this.content.scrollTop = 0; + this.container.classList.add('psv-panel--open'); + toggleClass(this.content, 'psv-panel-content--no-margin', config.noMargin === true); + + if (config.clickHandler) { + this.prop.clickHandler = config.clickHandler; + + this.prop.keyHandler = function (e) { + if (e.key === KEY_CODES.Enter) { + config.clickHandler(e); + } + }; + + this.content.addEventListener('click', this.prop.clickHandler); + this.content.addEventListener('keydown', this.prop.keyHandler); // focus the first element if possible, after animation ends + + if (!wasVisible) { + setTimeout(function () { + var _this2$content$queryS; + + (_this2$content$queryS = _this2.content.querySelector('a,button,[tabindex]')) == null ? void 0 : _this2$content$queryS.focus(); + }, 300); + } + } + this.psv.trigger(EVENTS.OPEN_PANEL, config.id); + } /** - * @param {PSV.Viewer} psv + * @summary Hides the panel + * @param {string} [id] + * @fires PSV.close-panel */ - function EventsHandler(psv) { - var _this; + ; - _this = _AbstractService.call(this, psv) || this; - /** - * @summary Internal properties - * @member {Object} - * @property {number} moveThreshold - computed threshold based on device pixel ratio - * @property {boolean} moving - is the user moving - * @property {boolean} zooming - is the user zooming - * @property {number} startMouseX - start x position of the click/touch - * @property {number} startMouseY - start y position of the click/touch - * @property {number} mouseX - current x position of the cursor - * @property {number} mouseY - current y position of the cursor - * @property {number[][]} mouseHistory - list of latest positions of the cursor, [time, x, y] - * @property {number} pinchDist - distance between fingers when zooming - * @property {PressHandler} keyHandler - * @property {boolean} ctrlKeyDown - when the Ctrl key is pressed - * @property {PSV.ClickData} dblclickData - temporary storage of click data between two clicks - * @property {number} dblclickTimeout - timeout id for double click - * @property {number} twofingersTimeout - timeout id for "two fingers" overlay - * @property {number} ctrlZoomTimeout - timeout id for "ctrol zoom" overlay - * @protected - */ + _proto.hide = function hide(id) { + if (this.isVisible(id)) { + var contentId = this.prop.contentId; + this.prop.visible = false; + this.prop.contentId = undefined; + this.content.innerHTML = null; + this.container.classList.remove('psv-panel--open'); - _this.state = { - moveThreshold: MOVE_THRESHOLD * SYSTEM.pixelRatio, - keyboardEnabled: false, - moving: false, - zooming: false, - startMouseX: 0, - startMouseY: 0, - mouseX: 0, - mouseY: 0, - mouseHistory: [], - pinchDist: 0, - keyHandler: new PressHandler(), - ctrlKeyDown: false, - dblclickData: null, - dblclickTimeout: null, - longtouchTimeout: null, - twofingersTimeout: null, - ctrlZoomTimeout: null - }; - /** - * @summary Throttled wrapper of {@link PSV.Viewer#autoSize} - * @type {Function} - * @private - */ + if (this.prop.clickHandler) { + this.content.removeEventListener('click', this.prop.clickHandler); + this.prop.clickHandler = null; + } - _this.__onResize = throttle(function () { - return _this.psv.autoSize(); - }, 50); - return _this; + this.psv.trigger(EVENTS.CLOSE_PANEL, contentId); + } } /** - * @summary Initializes event handlers - * @protected + * @summary Handles mouse down events + * @param {MouseEvent} evt + * @private */ + ; + _proto.__onMouseDown = function __onMouseDown(evt) { + evt.stopPropagation(); - var _proto = EventsHandler.prototype; + this.__startResize(evt); + } + /** + * @summary Handles touch events + * @param {TouchEvent} evt + * @private + */ + ; - _proto.init = function init() { - window.addEventListener('resize', this); - window.addEventListener('keydown', this); - window.addEventListener('keyup', this); - this.psv.container.addEventListener('mouseenter', this); - this.psv.container.addEventListener('mousedown', this); - 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(SYSTEM.mouseWheelEvent, this); + _proto.__onTouchStart = function __onTouchStart(evt) { + evt.stopPropagation(); - if (SYSTEM.fullscreenEvent) { - document.addEventListener(SYSTEM.fullscreenEvent, this); - } + this.__startResize(evt.changedTouches[0]); } /** - * @override + * @summary Handles mouse up events + * @param {MouseEvent} evt + * @private */ ; - _proto.destroy = function destroy() { - window.removeEventListener('resize', this); - window.removeEventListener('keydown', this); - window.removeEventListener('keyup', this); - this.psv.container.removeEventListener('mouseenter', this); - this.psv.container.removeEventListener('mousedown', this); - 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(SYSTEM.mouseWheelEvent, this); - - if (SYSTEM.fullscreenEvent) { - document.removeEventListener(SYSTEM.fullscreenEvent, this); + _proto.__onMouseUp = function __onMouseUp(evt) { + if (this.prop.mousedown) { + evt.stopPropagation(); + this.prop.mousedown = false; + this.content.classList.remove('psv-panel-content--no-interaction'); } + } + /** + * @summary Handles mouse move events + * @param {MouseEvent} evt + * @private + */ + ; - clearTimeout(this.state.dblclickTimeout); - clearTimeout(this.state.longtouchTimeout); - clearTimeout(this.state.twofingersTimeout); - clearTimeout(this.state.ctrlZoomTimeout); - delete this.state; - - _AbstractService.prototype.destroy.call(this); + _proto.__onMouseMove = function __onMouseMove(evt) { + if (this.prop.mousedown) { + evt.stopPropagation(); + + this.__resize(evt); + } } /** - * @summary Handles events - * @param {Event} evt + * @summary Handles touch move events + * @param {TouchEvent} evt * @private */ ; - _proto.handleEvent = function handleEvent(evt) { - /* eslint-disable */ - switch (evt.type) { - // @formatter:off - case 'resize': - this.__onResize(); - - break; - - case 'keydown': - this.__onKeyDown(evt); - - break; - - case 'keyup': - this.__onKeyUp(); - - break; - - case 'mouseup': - this.__onMouseUp(evt); - - break; - - case 'touchend': - this.__onTouchEnd(evt); + _proto.__onTouchMove = function __onTouchMove(evt) { + if (this.prop.mousedown) { + this.__resize(evt.touches[0]); + } + } + /** + * @summary Initializes the panel resize + * @param {MouseEvent|Touch} evt + * @private + */ + ; - break; + _proto.__startResize = function __startResize(evt) { + this.prop.mouseX = evt.clientX; + this.prop.mouseY = evt.clientY; + this.prop.mousedown = true; + this.content.classList.add('psv-panel-content--no-interaction'); + } + /** + * @summary Resizes the panel + * @param {MouseEvent|Touch} evt + * @private + */ + ; - case SYSTEM.fullscreenEvent: - this.__fullscreenToggled(); + _proto.__resize = function __resize(evt) { + var x = evt.clientX; + var y = evt.clientY; + var width = Math.max(PANEL_MIN_WIDTH, this.container.offsetWidth - (x - this.prop.mouseX)) + 'px'; - break; - // @formatter:on + if (this.prop.contentId) { + this.prop.width[this.prop.contentId] = width; } - /* eslint-enable */ + this.container.style.width = width; + this.prop.mouseX = x; + this.prop.mouseY = y; + }; - if (!getClosest(evt.target, '.psv-navbar') && !getClosest(evt.target, '.psv-panel')) { - /* eslint-disable */ - switch (evt.type) { - // @formatter:off - case 'mousedown': - this.__onMouseDown(evt); + return Panel; + }(AbstractComponent); - break; + var errorIcon = "\n"; - case 'mouseenter': - this.__onMouseEnter(evt); + /** + * @namespace PSV.services + */ - break; + /** + * @summary Base services class + * @memberof PSV.services + * @abstract + */ + var AbstractService = /*#__PURE__*/function () { + /** + * @param {PSV.Viewer} psv + */ + function AbstractService(psv) { + /** + * @summary Reference to main controller + * @type {PSV.Viewer} + * @readonly + */ + this.psv = psv; + /** + * @summary Configuration holder + * @type {PSV.Options} + * @readonly + */ - case 'mouseleave': - this.__onMouseLeave(evt); + this.config = psv.config; + /** + * @summary Properties holder + * @type {Object} + * @readonly + */ - break; + this.prop = psv.prop; + } + /** + * @summary Destroys the service + */ - case 'mousemove': - this.__onMouseMove(evt); - break; + var _proto = AbstractService.prototype; - case 'touchstart': - this.__onTouchStart(evt); + _proto.destroy = function destroy() { + delete this.psv; + delete this.config; + delete this.prop; + }; - break; + return AbstractService; + }(); - case 'touchmove': - this.__onTouchMove(evt); + var vector2 = new THREE.Vector2(); + var vector3 = new THREE.Vector3(); + var eulerZero = new THREE.Euler(0, 0, 0, 'ZXY'); + /** + * @summary Collections of data converters for the current viewer + * @extends PSV.services.AbstractService + * @memberof PSV.services + */ - break; + var DataHelper = /*#__PURE__*/function (_AbstractService) { + _inheritsLoose(DataHelper, _AbstractService); - case SYSTEM.mouseWheelEvent: - this.__onMouseWheel(evt); + /** + * @param {PSV.Viewer} psv + */ + function DataHelper(psv) { + return _AbstractService.call(this, psv) || this; + } + /** + * @summary Converts vertical FOV to zoom level + * @param {number} fov + * @returns {number} + */ - break; - // @formatter:on - } - /* eslint-enable */ - } + var _proto = DataHelper.prototype; + + _proto.fovToZoomLevel = function fovToZoomLevel(fov) { + var temp = Math.round((fov - this.config.minFov) / (this.config.maxFov - this.config.minFov) * 100); + return temp - 2 * (temp - 50); } /** - * @summary Enables the keyboard controls - * @protected + * @summary Converts zoom level to vertical FOV + * @param {number} level + * @returns {number} */ ; - _proto.enableKeyboard = function enableKeyboard() { - this.state.keyboardEnabled = true; + _proto.zoomLevelToFov = function zoomLevelToFov(level) { + return this.config.maxFov + level / 100 * (this.config.minFov - this.config.maxFov); } /** - * @summary Disables the keyboard controls - * @protected + * @summary Convert vertical FOV to horizontal FOV + * @param {number} vFov + * @returns {number} */ ; - _proto.disableKeyboard = function disableKeyboard() { - this.state.keyboardEnabled = false; + _proto.vFovToHFov = function vFovToHFov(vFov) { + return THREE.Math.radToDeg(2 * Math.atan(Math.tan(THREE.Math.degToRad(vFov) / 2) * this.prop.aspect)); } /** - * @summary Handles keyboard events - * @param {KeyboardEvent} evt - * @private + * @summary Converts a speed into a duration from current position to a new position + * @param {string|number} value + * @param {number} angle + * @returns {number} */ ; - _proto.__onKeyDown = function __onKeyDown(evt) { - var key = getEventKey(evt); - - if (this.config.mousewheelCtrlKey) { - this.state.ctrlKeyDown = key === KEY_CODES.Control; - - if (this.state.ctrlKeyDown) { - clearTimeout(this.state.ctrlZoomTimeout); - this.psv.overlay.hide(IDS.CTRL_ZOOM); - } - } - - if (!this.state.keyboardEnabled) { - return; - } - - if (this.config.keyboard[key] === ACTIONS.TOGGLE_AUTOROTATE) { - this.psv.toggleAutorotate(); - } else if (this.config.keyboard[key] && !this.state.keyHandler.time) { - /* eslint-disable */ - switch (this.config.keyboard[key]) { - // @formatter:off - case ACTIONS.ROTATE_LAT_UP: - this.psv.dynamics.position.roll({ - latitude: false - }); - break; - - case ACTIONS.ROTATE_LAT_DOWN: - this.psv.dynamics.position.roll({ - latitude: true - }); - break; - - case ACTIONS.ROTATE_LONG_RIGHT: - this.psv.dynamics.position.roll({ - longitude: false - }); - break; - - case ACTIONS.ROTATE_LONG_LEFT: - this.psv.dynamics.position.roll({ - longitude: true - }); - break; - - case ACTIONS.ZOOM_IN: - this.psv.dynamics.zoom.roll(false); - break; - - case ACTIONS.ZOOM_OUT: - this.psv.dynamics.zoom.roll(true); - break; - // @formatter:on - } - /* eslint-enable */ - + _proto.speedToDuration = function speedToDuration(value, angle) { + if (!value || typeof value !== 'number') { + // desired radial speed + var speed = value ? parseSpeed(value) : this.config.autorotateSpeed; // compute duration - this.state.keyHandler.down(); + return angle / Math.abs(speed) * 1000; + } else { + return Math.abs(value); } } /** - * @summary Handles keyboard events - * @private + * @summary Converts pixel texture coordinates to spherical radians coordinates + * @param {PSV.Point} point + * @returns {PSV.Position} + * @throws {PSV.PSVError} when the current adapter does not support texture coordinates */ ; - _proto.__onKeyUp = function __onKeyUp() { - var _this2 = this; - - this.state.ctrlKeyDown = false; + _proto.textureCoordsToSphericalCoords = function textureCoordsToSphericalCoords(point) { + var panoData = this.prop.panoData; - if (!this.state.keyboardEnabled) { - return; + if (!panoData) { + throw new PSVError('Current adapter does not support texture coordinates.'); } - this.state.keyHandler.up(function () { - _this2.psv.dynamics.position.stop(); + var relativeX = (point.x + panoData.croppedX) / panoData.fullWidth * Math.PI * 2; + var relativeY = (point.y + panoData.croppedY) / panoData.fullHeight * Math.PI; + var result = { + longitude: relativeX >= Math.PI ? relativeX - Math.PI : relativeX + Math.PI, + latitude: Math.PI / 2 - relativeY + }; // Apply panoData pose and sphereCorrection - _this2.psv.dynamics.zoom.stop(); - }); + if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) { + this.sphericalCoordsToVector3(result, vector3); + vector3.applyEuler(this.psv.renderer.mesh.rotation); + vector3.applyEuler(this.psv.renderer.meshContainer.rotation); + return this.vector3ToSphericalCoords(vector3); + } else { + return result; + } } /** - * @summary Handles mouse down events - * @param {MouseEvent} evt - * @private + * @summary Converts spherical radians coordinates to pixel texture coordinates + * @param {PSV.Position} position + * @returns {PSV.Point} + * @throws {PSV.PSVError} when the current adapter does not support texture coordinates */ ; - _proto.__onMouseDown = function __onMouseDown(evt) { - if (!this.config.mousemove || this.config.captureCursor) { - return; + _proto.sphericalCoordsToTextureCoords = function sphericalCoordsToTextureCoords(position) { + var panoData = this.prop.panoData; + + if (!panoData) { + throw new PSVError('Current adapter does not support texture coordinates.'); + } // Apply panoData pose and sphereCorrection + + + if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) { + this.sphericalCoordsToVector3(position, vector3); + applyEulerInverse(vector3, this.psv.renderer.meshContainer.rotation); + applyEulerInverse(vector3, this.psv.renderer.mesh.rotation); + position = this.vector3ToSphericalCoords(vector3); } - this.__startMove(evt); + var relativeLong = position.longitude / Math.PI / 2 * panoData.fullWidth; + var relativeLat = position.latitude / Math.PI * panoData.fullHeight; + return { + x: Math.round(position.longitude < Math.PI ? relativeLong + panoData.fullWidth / 2 : relativeLong - panoData.fullWidth / 2) - panoData.croppedX, + y: Math.round(panoData.fullHeight / 2 - relativeLat) - panoData.croppedY + }; } /** - * @summary Handles mouse enter events - * @param {MouseEvent} evt - * @private + * @summary Converts spherical radians coordinates to a THREE.Vector3 + * @param {PSV.Position} position + * @param {external:THREE.Vector3} [vector] + * @returns {external:THREE.Vector3} */ ; - _proto.__onMouseEnter = function __onMouseEnter(evt) { - if (!this.config.mousemove || !this.config.captureCursor) { - return; + _proto.sphericalCoordsToVector3 = function sphericalCoordsToVector3(position, vector) { + if (!vector) { + vector = new THREE.Vector3(); } - this.__startMove(evt); + vector.x = SPHERE_RADIUS * -Math.cos(position.latitude) * Math.sin(position.longitude); + vector.y = SPHERE_RADIUS * Math.sin(position.latitude); + vector.z = SPHERE_RADIUS * Math.cos(position.latitude) * Math.cos(position.longitude); + return vector; } /** - * @summary Handles mouse up events - * @param {MouseEvent} evt - * @private + * @summary Converts a THREE.Vector3 to spherical radians coordinates + * @param {external:THREE.Vector3} vector + * @returns {PSV.Position} */ ; - _proto.__onMouseUp = function __onMouseUp(evt) { - if (!this.config.mousemove || this.config.captureCursor) { - return; - } - - this.__stopMove(evt); + _proto.vector3ToSphericalCoords = function vector3ToSphericalCoords(vector) { + var phi = Math.acos(vector.y / Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z)); + var theta = Math.atan2(vector.x, vector.z); + return { + longitude: theta < 0 ? -theta : Math.PI * 2 - theta, + latitude: Math.PI / 2 - phi + }; } /** - * @summary Handles mouse leave events - * @param {MouseEvent} evt - * @private + * @summary Converts position on the viewer to a THREE.Vector3 + * @param {PSV.Point} viewerPoint + * @returns {external:THREE.Vector3} */ ; - _proto.__onMouseLeave = function __onMouseLeave(evt) { - if (!this.config.mousemove || !this.config.captureCursor) { - return; - } + _proto.viewerCoordsToVector3 = function viewerCoordsToVector3(viewerPoint) { + var sphereIntersect = this.getIntersections(viewerPoint).filter(function (i) { + return i.object.userData[MESH_USER_DATA]; + }); - this.__stopMove(evt); + if (sphereIntersect) { + return sphereIntersect.point; + } else { + return null; + } } /** - * @summary Handles mouse move events - * @param {MouseEvent} evt - * @private + * @summary Converts a THREE.Vector3 to position on the viewer + * @param {external:THREE.Vector3} vector + * @returns {PSV.Point} */ ; - _proto.__onMouseMove = function __onMouseMove(evt) { - if (this.config.mousemove) { - if (evt.buttons !== 0) { - evt.preventDefault(); - - this.__move(evt); - } else if (this.config.captureCursor) { - this.__moveAbsolute(evt); - } - } - - if (!isEmpty(this.prop.objectsObservers)) { - var viewerPos = getPosition(this.psv.container); - var viewerPoint = { - x: evt.clientX - viewerPos.left, - y: evt.clientY - viewerPos.top - }; - var intersections = this.psv.dataHelper.getIntersections(viewerPoint); - - var emit = function emit(observer, key, type) { - observer.listener.handleEvent(new CustomEvent(type, { - detail: { - originalEvent: evt, - object: observer.object, - data: observer.object.userData[key], - viewerPoint: viewerPoint - } - })); - }; - - each(this.prop.objectsObservers, function (observer, key) { - var intersection = intersections.find(function (i) { - return i.object.userData[key]; - }); - - if (intersection) { - if (observer.object && intersection.object !== observer.object) { - emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT); - delete observer.object; - } - - if (!observer.object) { - observer.object = intersection.object; - emit(observer, key, OBJECT_EVENTS.ENTER_OBJECT); - } else { - emit(observer, key, OBJECT_EVENTS.HOVER_OBJECT); - } - } else if (observer.object) { - emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT); - delete observer.object; - } - }); - } + _proto.vector3ToViewerCoords = function vector3ToViewerCoords(vector) { + var vectorClone = vector.clone(); + vectorClone.project(this.psv.renderer.camera); + return { + x: Math.round((vectorClone.x + 1) / 2 * this.prop.size.width), + y: Math.round((1 - vectorClone.y) / 2 * this.prop.size.height) + }; } /** - * @summary Handles touch events - * @param {TouchEvent} evt - * @private + * @summary Converts spherical radians coordinates to position on the viewer + * @param {PSV.Position} position + * @returns {PSV.Point} */ ; - _proto.__onTouchStart = function __onTouchStart(evt) { - var _this3 = this; - - if (!this.config.mousemove) { - return; - } - - if (evt.touches.length === 1) { - if (!this.config.touchmoveTwoFingers) { - this.__startMove(evt.touches[0]); - - evt.preventDefault(); // prevent mouse events emulation - } - - if (!this.prop.longtouchTimeout) { - this.prop.longtouchTimeout = setTimeout(function () { - _this3.__click(evt.touches[0], true); - - _this3.prop.longtouchTimeout = null; - }, LONGTOUCH_DELAY); - } - } else if (evt.touches.length === 2) { - this.__cancelLongTouch(); - - this.__cancelTwoFingersOverlay(); + _proto.sphericalCoordsToViewerCoords = function sphericalCoordsToViewerCoords(position) { + return this.vector3ToViewerCoords(this.sphericalCoordsToVector3(position, vector3)); + } + /** + * @summary Returns intersections with objects in the scene + * @param {PSV.Point} viewerPoint + * @return {external:THREE.Intersection[]} + */ + ; - this.__startMoveZoom(evt); + _proto.getIntersections = function getIntersections(viewerPoint) { + vector2.x = 2 * viewerPoint.x / this.prop.size.width - 1; + vector2.y = -2 * viewerPoint.y / this.prop.size.height + 1; + this.psv.renderer.raycaster.setFromCamera(vector2, this.psv.renderer.camera); + return this.psv.renderer.raycaster.intersectObjects(this.psv.renderer.scene.children, true).filter(function (i) { + return !!i.object.userData; + }); + } + /** + * @summary Converts x/y to latitude/longitude if present and ensure boundaries + * @param {PSV.ExtendedPosition} position + * @returns {PSV.Position} + */ + ; - evt.preventDefault(); + _proto.cleanPosition = function cleanPosition(position) { + if (position.x !== undefined && position.y !== undefined) { + return this.textureCoordsToSphericalCoords(position); + } else { + return { + longitude: parseAngle(position.longitude), + latitude: parseAngle(position.latitude, true) + }; } } /** - * @summary Handles touch events - * @param {TouchEvent} evt - * @private + * @summary Ensure a SphereCorrection object is valid + * @param {PSV.SphereCorrection} sphereCorrection + * @returns {PSV.SphereCorrection} */ ; - _proto.__onTouchEnd = function __onTouchEnd(evt) { - if (!this.config.mousemove) { - return; - } - - this.__cancelLongTouch(); - - this.__cancelTwoFingersOverlay(); - - if (evt.touches.length === 1) { - this.__stopMoveZoom(); - } else if (evt.touches.length === 0) { - this.__stopMove(evt.changedTouches[0]); - } + _proto.cleanSphereCorrection = function cleanSphereCorrection(sphereCorrection) { + return { + pan: parseAngle((sphereCorrection == null ? void 0 : sphereCorrection.pan) || 0), + tilt: parseAngle((sphereCorrection == null ? void 0 : sphereCorrection.tilt) || 0, true), + roll: parseAngle((sphereCorrection == null ? void 0 : sphereCorrection.roll) || 0, true, false) + }; } /** - * @summary Handles touch move events - * @param {TouchEvent} evt - * @private + * @summary Parse the pose angles of the pano data + * @param {PSV.PanoData} panoData + * @returns {PSV.SphereCorrection} */ ; - _proto.__onTouchMove = function __onTouchMove(evt) { - var _this4 = this; + _proto.cleanPanoramaPose = function cleanPanoramaPose(panoData) { + return { + pan: THREE.Math.degToRad((panoData == null ? void 0 : panoData.poseHeading) || 0), + tilt: THREE.Math.degToRad((panoData == null ? void 0 : panoData.posePitch) || 0), + roll: THREE.Math.degToRad((panoData == null ? void 0 : panoData.poseRoll) || 0) + }; + }; - if (!this.config.mousemove) { - return; - } + return DataHelper; + }(AbstractService); - this.__cancelLongTouch(); + var gestureIcon = "\n"; - if (evt.touches.length === 1) { - if (this.config.touchmoveTwoFingers) { - if (!this.prop.twofingersTimeout) { - this.prop.twofingersTimeout = setTimeout(function () { - _this4.psv.overlay.show({ - id: IDS.TWO_FINGERS, - image: gestureIcon, - text: _this4.config.lang.twoFingers - }); - }, TWOFINGERSOVERLAY_DELAY); - } - } else { - evt.preventDefault(); + var mousewheelIcon = "\n"; - this.__move(evt.touches[0]); - } - } else if (evt.touches.length === 2) { - evt.preventDefault(); + /** + * @summary Events handler + * @extends PSV.services.AbstractService + * @memberof PSV.services + */ - this.__moveZoom(evt); + var EventsHandler = /*#__PURE__*/function (_AbstractService) { + _inheritsLoose(EventsHandler, _AbstractService); - this.__cancelTwoFingersOverlay(); - } + /** + * @param {PSV.Viewer} psv + */ + function EventsHandler(psv) { + var _this; + + _this = _AbstractService.call(this, psv) || this; + /** + * @summary Internal properties + * @member {Object} + * @property {number} moveThreshold - computed threshold based on device pixel ratio + * @property {boolean} moving - is the user moving + * @property {boolean} zooming - is the user zooming + * @property {number} startMouseX - start x position of the click/touch + * @property {number} startMouseY - start y position of the click/touch + * @property {number} mouseX - current x position of the cursor + * @property {number} mouseY - current y position of the cursor + * @property {number[][]} mouseHistory - list of latest positions of the cursor, [time, x, y] + * @property {number} pinchDist - distance between fingers when zooming + * @property {PressHandler} keyHandler + * @property {boolean} ctrlKeyDown - when the Ctrl key is pressed + * @property {PSV.ClickData} dblclickData - temporary storage of click data between two clicks + * @property {number} dblclickTimeout - timeout id for double click + * @property {number} twofingersTimeout - timeout id for "two fingers" overlay + * @property {number} ctrlZoomTimeout - timeout id for "ctrol zoom" overlay + * @protected + */ + + _this.state = { + moveThreshold: MOVE_THRESHOLD * SYSTEM.pixelRatio, + keyboardEnabled: false, + moving: false, + zooming: false, + startMouseX: 0, + startMouseY: 0, + mouseX: 0, + mouseY: 0, + mouseHistory: [], + pinchDist: 0, + keyHandler: new PressHandler(), + ctrlKeyDown: false, + dblclickData: null, + dblclickTimeout: null, + longtouchTimeout: null, + twofingersTimeout: null, + ctrlZoomTimeout: null + }; + /** + * @summary Throttled wrapper of {@link PSV.Viewer#autoSize} + * @type {Function} + * @private + */ + + _this.__onResize = throttle(function () { + return _this.psv.autoSize(); + }, 50); + return _this; } /** - * @summary Cancel the long touch timer if any - * @private + * @summary Initializes event handlers + * @protected */ - ; - _proto.__cancelLongTouch = function __cancelLongTouch() { - if (this.prop.longtouchTimeout) { - clearTimeout(this.prop.longtouchTimeout); - this.prop.longtouchTimeout = null; + + var _proto = EventsHandler.prototype; + + _proto.init = function init() { + window.addEventListener('resize', this); + window.addEventListener('keydown', this); + window.addEventListener('keyup', this); + this.psv.container.addEventListener('mouseenter', this); + this.psv.container.addEventListener('mousedown', this); + 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(SYSTEM.mouseWheelEvent, this); + + if (SYSTEM.fullscreenEvent) { + document.addEventListener(SYSTEM.fullscreenEvent, this); } } /** - * @summary Cancel the two fingers overlay timer if any - * @private + * @override */ ; - _proto.__cancelTwoFingersOverlay = function __cancelTwoFingersOverlay() { - if (this.prop.twofingersTimeout) { - clearTimeout(this.prop.twofingersTimeout); - this.prop.twofingersTimeout = null; + _proto.destroy = function destroy() { + window.removeEventListener('resize', this); + window.removeEventListener('keydown', this); + window.removeEventListener('keyup', this); + this.psv.container.removeEventListener('mouseenter', this); + this.psv.container.removeEventListener('mousedown', this); + 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(SYSTEM.mouseWheelEvent, this); + + if (SYSTEM.fullscreenEvent) { + document.removeEventListener(SYSTEM.fullscreenEvent, this); } - this.psv.overlay.hide(IDS.TWO_FINGERS); + clearTimeout(this.state.dblclickTimeout); + clearTimeout(this.state.longtouchTimeout); + clearTimeout(this.state.twofingersTimeout); + clearTimeout(this.state.ctrlZoomTimeout); + delete this.state; + + _AbstractService.prototype.destroy.call(this); } /** - * @summary Handles mouse wheel events - * @param {WheelEvent} evt + * @summary Handles events + * @param {Event} evt * @private */ ; - _proto.__onMouseWheel = function __onMouseWheel(evt) { - var _this5 = this; + _proto.handleEvent = function handleEvent(evt) { + /* eslint-disable */ + switch (evt.type) { + // @formatter:off + case 'resize': + this.__onResize(); - if (!this.config.mousewheel) { - return; - } + break; - if (this.config.mousewheelCtrlKey && !this.state.ctrlKeyDown) { - this.psv.overlay.show({ - id: IDS.CTRL_ZOOM, - image: mousewheelIcon, - text: this.config.lang.ctrlZoom - }); - clearTimeout(this.state.ctrlZoomTimeout); - this.state.ctrlZoomTimeout = setTimeout(function () { - return _this5.psv.overlay.hide(IDS.CTRL_ZOOM); - }, CTRLZOOM_TIMEOUT); - return; + case 'keydown': + this.__onKeyDown(evt); + + break; + + case 'keyup': + this.__onKeyUp(); + + break; + + case 'mouseup': + this.__onMouseUp(evt); + + break; + + case 'touchend': + this.__onTouchEnd(evt); + + break; + + case SYSTEM.fullscreenEvent: + this.__fullscreenToggled(); + + break; + // @formatter:on } + /* eslint-enable */ - evt.preventDefault(); - evt.stopPropagation(); - var delta = normalizeWheel(evt).spinY * 5 * this.config.zoomSpeed; - if (delta !== 0) { - this.psv.dynamics.zoom.step(-delta, 5); - } - } - /** - * @summary Handles fullscreen events - * @param {boolean} [force] force state - * @fires PSV.fullscreen-updated - * @package - */ - ; + if (!getClosest(evt.target, '.psv-navbar') && !getClosest(evt.target, '.psv-panel')) { + /* eslint-disable */ + switch (evt.type) { + // @formatter:off + case 'mousedown': + this.__onMouseDown(evt); + + break; + + case 'mouseenter': + this.__onMouseEnter(evt); - _proto.__fullscreenToggled = function __fullscreenToggled(force) { - this.prop.fullscreen = force !== undefined ? force : isFullscreenEnabled(this.psv.container); + break; - if (this.config.keyboard) { - if (this.prop.fullscreen) { - this.psv.startKeyboardControl(); - } else { - this.psv.stopKeyboardControl(); - } - } + case 'mouseleave': + this.__onMouseLeave(evt); - this.psv.trigger(EVENTS.FULLSCREEN_UPDATED, this.prop.fullscreen); - } - /** - * @summary Initializes the movement - * @param {MouseEvent|Touch} evt - * @private - */ - ; + break; - _proto.__startMove = function __startMove(evt) { - var _this6 = this; + case 'mousemove': + this.__onMouseMove(evt); - this.psv.stopAutorotate(); - this.psv.stopAnimation().then(function () { - _this6.state.mouseX = evt.clientX; - _this6.state.mouseY = evt.clientY; - _this6.state.startMouseX = _this6.state.mouseX; - _this6.state.startMouseY = _this6.state.mouseY; - _this6.state.moving = true; - _this6.state.zooming = false; - _this6.state.mouseHistory.length = 0; + break; - _this6.__logMouseMove(evt); - }); - } - /** - * @summary Initializes the combines move and zoom - * @param {TouchEvent} evt - * @private - */ - ; + case 'touchstart': + this.__onTouchStart(evt); - _proto.__startMoveZoom = function __startMoveZoom(evt) { - var p1 = { - x: evt.touches[0].clientX, - y: evt.touches[0].clientY - }; - var p2 = { - x: evt.touches[1].clientX, - y: evt.touches[1].clientY - }; - this.state.pinchDist = distance(p1, p2); - this.state.mouseX = (p1.x + p2.x) / 2; - this.state.mouseY = (p1.y + p2.y) / 2; - this.state.startMouseX = this.state.mouseX; - this.state.startMouseY = this.state.mouseY; - this.state.moving = true; - this.state.zooming = true; - } - /** - * @summary Stops the movement - * @description If the move threshold was not reached a click event is triggered, otherwise an animation is launched to simulate inertia - * @param {MouseEvent|Touch} evt - * @private - */ - ; + break; - _proto.__stopMove = function __stopMove(evt) { - if (!getClosest(evt.target, '.psv-container')) { - this.state.moving = false; - this.state.mouseHistory.length = 0; - return; - } + case 'touchmove': + this.__onTouchMove(evt); - if (this.state.moving) { - // move threshold to trigger a click - if (Math.abs(evt.clientX - this.state.startMouseX) < this.state.moveThreshold && Math.abs(evt.clientY - this.state.startMouseY) < this.state.moveThreshold) { - this.__click(evt); + break; - this.state.moving = false; - } // inertia animation - else if (this.config.moveInertia) { - this.__logMouseMove(evt); + case SYSTEM.mouseWheelEvent: + this.__onMouseWheel(evt); - this.__stopMoveInertia(evt); - } else { - this.state.moving = false; + break; + // @formatter:on } + /* eslint-enable */ - this.state.mouseHistory.length = 0; } } /** - * @summary Stops the combined move and zoom - * @private + * @summary Enables the keyboard controls + * @protected */ ; - _proto.__stopMoveZoom = function __stopMoveZoom() { - this.state.mouseHistory.length = 0; - this.state.moving = false; - this.state.zooming = false; + _proto.enableKeyboard = function enableKeyboard() { + this.state.keyboardEnabled = true; } /** - * @summary Performs an animation to simulate inertia when the movement stops - * @param {MouseEvent|Touch} evt - * @private + * @summary Disables the keyboard controls + * @protected */ ; - _proto.__stopMoveInertia = function __stopMoveInertia(evt) { - var _this7 = this; - - var direction = { - x: evt.clientX - this.state.mouseHistory[0][1], - y: evt.clientY - this.state.mouseHistory[0][2] - }; - var norm = Math.sqrt(direction.x * direction.x + direction.y * direction.y); - this.prop.animationPromise = new Animation({ - properties: { - clientX: { - start: evt.clientX, - end: evt.clientX + direction.x - }, - clientY: { - start: evt.clientY, - end: evt.clientY + direction.y - } - }, - duration: norm * INERTIA_WINDOW / 100, - easing: 'outCirc', - onTick: function onTick(properties) { - _this7.__move(properties, false); - } - }); - this.prop.animationPromise.then(function () { - _this7.state.moving = false; - }); + _proto.disableKeyboard = function disableKeyboard() { + this.state.keyboardEnabled = false; } /** - * @summary Triggers an event with all coordinates when a simple click is performed - * @param {MouseEvent|Touch} evt - * @param {boolean} [longtouch=false] - * @fires PSV.click - * @fires PSV.dblclick + * @summary Handles keyboard events + * @param {KeyboardEvent} e * @private */ ; - _proto.__click = function __click(evt, longtouch) { - var _this8 = this; + _proto.__onKeyDown = function __onKeyDown(e) { + if (this.config.mousewheelCtrlKey) { + this.state.ctrlKeyDown = e.key === KEY_CODES.Control; - if (longtouch === void 0) { - longtouch = false; + if (this.state.ctrlKeyDown) { + clearTimeout(this.state.ctrlZoomTimeout); + this.psv.overlay.hide(IDS.CTRL_ZOOM); + } } - var boundingRect = this.psv.container.getBoundingClientRect(); - /** - * @type {PSV.ClickData} - */ + var e2 = this.psv.trigger(EVENTS.KEY_PRESS, e.key); - var data = { - rightclick: longtouch || evt.button === 2, - target: evt.target, - clientX: evt.clientX, - clientY: evt.clientY, - viewerX: evt.clientX - boundingRect.left, - viewerY: evt.clientY - boundingRect.top - }; - var intersections = this.psv.dataHelper.getIntersections({ - x: data.viewerX, - y: data.viewerY - }); - var sphereIntersection = intersections.find(function (i) { - return i.object.userData.psvSphere; - }); + if (e2.isDefaultPrevented()) { + return; + } - if (sphereIntersection) { - var sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(sphereIntersection.point); - data.longitude = sphericalCoords.longitude; - data.latitude = sphericalCoords.latitude; - data.objects = intersections.map(function (i) { - return i.object; - }).filter(function (o) { - return !o.userData.psvSphere; - }); + if (!this.state.keyboardEnabled) { + return; + } - try { - var textureCoords = this.psv.dataHelper.sphericalCoordsToTextureCoords(data); - data.textureX = textureCoords.x; - data.textureY = textureCoords.y; - } catch (e) { - data.textureX = NaN; - data.textureY = NaN; - } + if (this.config.keyboard[e.key] === ACTIONS.TOGGLE_AUTOROTATE) { + this.psv.toggleAutorotate(); + } else if (this.config.keyboard[e.key] && !this.state.keyHandler.time) { + /* eslint-disable */ + switch (this.config.keyboard[e.key]) { + // @formatter:off + case ACTIONS.ROTATE_LAT_UP: + this.psv.dynamics.position.roll({ + latitude: false + }); + break; - if (!this.state.dblclickTimeout) { - this.psv.trigger(EVENTS.CLICK, data); - this.state.dblclickData = clone(data); - this.state.dblclickTimeout = setTimeout(function () { - _this8.state.dblclickTimeout = null; - _this8.state.dblclickData = null; - }, DBLCLICK_DELAY); - } else { - if (Math.abs(this.state.dblclickData.clientX - data.clientX) < this.state.moveThreshold && Math.abs(this.state.dblclickData.clientY - data.clientY) < this.state.moveThreshold) { - this.psv.trigger(EVENTS.DOUBLE_CLICK, this.state.dblclickData); - } + case ACTIONS.ROTATE_LAT_DOWN: + this.psv.dynamics.position.roll({ + latitude: true + }); + break; - clearTimeout(this.state.dblclickTimeout); - this.state.dblclickTimeout = null; - this.state.dblclickData = null; + case ACTIONS.ROTATE_LONG_RIGHT: + this.psv.dynamics.position.roll({ + longitude: false + }); + break; + + case ACTIONS.ROTATE_LONG_LEFT: + this.psv.dynamics.position.roll({ + longitude: true + }); + break; + + case ACTIONS.ZOOM_IN: + this.psv.dynamics.zoom.roll(false); + break; + + case ACTIONS.ZOOM_OUT: + this.psv.dynamics.zoom.roll(true); + break; + // @formatter:on } + /* eslint-enable */ + + + this.state.keyHandler.down(); } } /** - * @summary Performs movement - * @param {MouseEvent|Touch} evt - * @param {boolean} [log=true] + * @summary Handles keyboard events * @private */ ; - _proto.__move = function __move(evt, log) { - if (this.state.moving) { - var x = evt.clientX; - var y = evt.clientY; - var rotation = { - longitude: (x - this.state.mouseX) / this.prop.size.width * this.config.moveSpeed * THREE.Math.degToRad(this.prop.hFov), - latitude: (y - this.state.mouseY) / this.prop.size.height * this.config.moveSpeed * THREE.Math.degToRad(this.prop.vFov) - }; - var currentPosition = this.psv.getPosition(); - this.psv.rotate({ - longitude: currentPosition.longitude - rotation.longitude, - latitude: currentPosition.latitude + rotation.latitude - }); - this.state.mouseX = x; - this.state.mouseY = y; + _proto.__onKeyUp = function __onKeyUp() { + var _this2 = this; - if (log !== false) { - this.__logMouseMove(evt); - } + this.state.ctrlKeyDown = false; + + if (!this.state.keyboardEnabled) { + return; } + + this.state.keyHandler.up(function () { + _this2.psv.dynamics.position.stop(); + + _this2.psv.dynamics.zoom.stop(); + }); } /** - * @summary Performs movement absolute to cursor position in viewer + * @summary Handles mouse down events * @param {MouseEvent} evt * @private */ ; - _proto.__moveAbsolute = function __moveAbsolute(evt) { - if (this.state.moving) { - var containerRect = this.psv.container.getBoundingClientRect(); - this.psv.dynamics.position.goto({ - longitude: ((evt.clientX - containerRect.left) / containerRect.width - 0.5) * Math.PI * 2, - latitude: -((evt.clientY - containerRect.top) / containerRect.height - 0.5) * Math.PI - }, 10); + _proto.__onMouseDown = function __onMouseDown(evt) { + if (!this.config.mousemove || this.config.captureCursor) { + return; } + + this.__startMove(evt); } /** - * @summary Perfoms combined move and zoom - * @param {TouchEvent} evt + * @summary Handles mouse enter events + * @param {MouseEvent} evt * @private */ ; - _proto.__moveZoom = function __moveZoom(evt) { - if (this.state.zooming && this.state.moving) { - var p1 = { - x: evt.touches[0].clientX, - y: evt.touches[0].clientY - }; - var p2 = { - x: evt.touches[1].clientX, - y: evt.touches[1].clientY - }; - var p = distance(p1, p2); - var delta = 80 * (p - this.state.pinchDist) / this.prop.size.width * this.config.zoomSpeed; - this.psv.zoom(this.psv.getZoomLevel() + delta); - - this.__move({ - clientX: (p1.x + p2.x) / 2, - clientY: (p1.y + p2.y) / 2 - }); - - this.state.pinchDist = p; + _proto.__onMouseEnter = function __onMouseEnter(evt) { + if (!this.config.mousemove || !this.config.captureCursor) { + return; } + + this.__startMove(evt); } /** - * @summary Stores each mouse position during a mouse move - * @description Positions older than "INERTIA_WINDOW" are removed
- * Positions before a pause of "INERTIA_WINDOW" / 10 are removed - * @param {MouseEvent|Touch} evt + * @summary Handles mouse up events + * @param {MouseEvent} evt * @private */ ; - _proto.__logMouseMove = function __logMouseMove(evt) { - var now = Date.now(); - this.state.mouseHistory.push([now, evt.clientX, evt.clientY]); - var previous = null; - - for (var i = 0; i < this.state.mouseHistory.length;) { - if (this.state.mouseHistory[0][i] < now - INERTIA_WINDOW) { - this.state.mouseHistory.splice(i, 1); - } else if (previous && this.state.mouseHistory[0][i] - previous > INERTIA_WINDOW / 10) { - this.state.mouseHistory.splice(0, i); - i = 0; - previous = this.state.mouseHistory[0][i]; - } else { - i++; - previous = this.state.mouseHistory[0][i]; - } + _proto.__onMouseUp = function __onMouseUp(evt) { + if (!this.config.mousemove || this.config.captureCursor) { + return; } - }; - - return EventsHandler; - }(AbstractService); - - /** - * @summary Viewer and renderer - * @extends PSV.services.AbstractService - * @memberof PSV.services - */ - - var Renderer = /*#__PURE__*/function (_AbstractService) { - _inheritsLoose(Renderer, _AbstractService); + this.__stopMove(evt); + } /** - * @param {PSV.Viewer} psv + * @summary Handles mouse leave events + * @param {MouseEvent} evt + * @private */ - function Renderer(psv) { - var _this$mesh$userData; - - var _this; + ; - _this = _AbstractService.call(this, psv) || this; - /** - * @member {external:THREE.WebGLRenderer} - * @readonly - * @protected - */ + _proto.__onMouseLeave = function __onMouseLeave(evt) { + if (!this.config.mousemove || !this.config.captureCursor) { + return; + } - _this.renderer = new THREE.WebGLRenderer({ - alpha: true, - antialias: true - }); + this.__stopMove(evt); + } + /** + * @summary Handles mouse move events + * @param {MouseEvent} evt + * @private + */ + ; - _this.renderer.setPixelRatio(SYSTEM.pixelRatio); + _proto.__onMouseMove = function __onMouseMove(evt) { + if (this.config.mousemove) { + if (evt.buttons !== 0) { + evt.preventDefault(); - _this.renderer.domElement.className = 'psv-canvas'; - /** - * @member {external:THREE.Scene} - * @readonly - * @protected - */ + this.__move(evt); + } else if (this.config.captureCursor) { + this.__moveAbsolute(evt); + } + } - _this.scene = new THREE.Scene(); - /** - * @member {external:THREE.PerspectiveCamera} - * @readonly - * @protected - */ + if (!isEmpty(this.prop.objectsObservers)) { + var viewerPos = getPosition(this.psv.container); + var viewerPoint = { + x: evt.clientX - viewerPos.left, + y: evt.clientY - viewerPos.top + }; + var intersections = this.psv.dataHelper.getIntersections(viewerPoint); - _this.camera = new THREE.PerspectiveCamera(50, 16 / 9, 1, 2 * SPHERE_RADIUS); - /** - * @member {external:THREE.Mesh} - * @readonly - * @protected - */ + var emit = function emit(observer, key, type) { + observer.listener.handleEvent(new CustomEvent(type, { + detail: { + originalEvent: evt, + object: observer.object, + data: observer.object.userData[key], + viewerPoint: viewerPoint + } + })); + }; - _this.mesh = _this.psv.adapter.createMesh(); - _this.mesh.userData = (_this$mesh$userData = {}, _this$mesh$userData[MESH_USER_DATA] = true, _this$mesh$userData); - /** - * @member {external:THREE.Group} - * @readonly - * @private - */ + each(this.prop.objectsObservers, function (observer, key) { + var intersection = intersections.find(function (i) { + return i.object.userData[key]; + }); - _this.meshContainer = new THREE.Group(); + if (intersection) { + if (observer.object && intersection.object !== observer.object) { + emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT); + delete observer.object; + } - _this.meshContainer.add(_this.mesh); + if (!observer.object) { + observer.object = intersection.object; + emit(observer, key, OBJECT_EVENTS.ENTER_OBJECT); + } else { + emit(observer, key, OBJECT_EVENTS.HOVER_OBJECT); + } + } else if (observer.object) { + emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT); + delete observer.object; + } + }); + } + } + /** + * @summary Handles touch events + * @param {TouchEvent} evt + * @private + */ + ; - _this.scene.add(_this.meshContainer); - /** - * @member {external:THREE.Raycaster} - * @readonly - * @protected - */ + _proto.__onTouchStart = function __onTouchStart(evt) { + var _this3 = this; + if (!this.config.mousemove) { + return; + } - _this.raycaster = new THREE.Raycaster(); - /** - * @member {number} - * @private - */ + if (evt.touches.length === 1) { + if (!this.config.touchmoveTwoFingers) { + this.__startMove(evt.touches[0]); - _this.timestamp = null; - /** - * @member {boolean} - * @private - */ + evt.preventDefault(); // prevent mouse events emulation + } - _this.ready = false; - /** - * @member {HTMLElement} - * @readonly - * @package - */ + if (!this.prop.longtouchTimeout) { + this.prop.longtouchTimeout = setTimeout(function () { + _this3.__click(evt.touches[0], true); - _this.canvasContainer = document.createElement('div'); - _this.canvasContainer.className = 'psv-canvas-container'; - _this.canvasContainer.style.background = _this.psv.config.canvasBackground; - _this.canvasContainer.style.cursor = _this.psv.config.mousemove ? 'move' : 'default'; + _this3.prop.longtouchTimeout = null; + }, LONGTOUCH_DELAY); + } + } else if (evt.touches.length === 2) { + this.__cancelLongTouch(); - _this.canvasContainer.appendChild(_this.renderer.domElement); + this.__cancelTwoFingersOverlay(); - _this.psv.container.appendChild(_this.canvasContainer); + this.__startMoveZoom(evt); - psv.on(EVENTS.SIZE_UPDATED, _assertThisInitialized(_this)); - psv.on(EVENTS.ZOOM_UPDATED, _assertThisInitialized(_this)); - psv.on(EVENTS.POSITION_UPDATED, _assertThisInitialized(_this)); - psv.on(EVENTS.CONFIG_CHANGED, _assertThisInitialized(_this)); + evt.preventDefault(); + } + } + /** + * @summary Handles touch events + * @param {TouchEvent} evt + * @private + */ + ; - _this.hide(); + _proto.__onTouchEnd = function __onTouchEnd(evt) { + if (!this.config.mousemove) { + return; + } - return _this; + this.__cancelLongTouch(); + + this.__cancelTwoFingersOverlay(); + + if (evt.touches.length === 1) { + this.__stopMoveZoom(); + } else if (evt.touches.length === 0) { + this.__stopMove(evt.changedTouches[0]); + } } /** - * @override + * @summary Handles touch move events + * @param {TouchEvent} evt + * @private */ + ; + _proto.__onTouchMove = function __onTouchMove(evt) { + var _this4 = this; - var _proto = Renderer.prototype; + if (!this.config.mousemove) { + return; + } - _proto.destroy = function destroy() { - // cancel render loop - this.renderer.setAnimationLoop(null); // destroy ThreeJS view + this.__cancelLongTouch(); - this.__cleanTHREEScene(this.scene); // remove container + if (evt.touches.length === 1) { + if (this.config.touchmoveTwoFingers) { + if (!this.prop.twofingersTimeout) { + this.prop.twofingersTimeout = setTimeout(function () { + _this4.psv.overlay.show({ + id: IDS.TWO_FINGERS, + image: gestureIcon, + text: _this4.config.lang.twoFingers + }); + }, TWOFINGERSOVERLAY_DELAY); + } + } else { + evt.preventDefault(); + this.__move(evt.touches[0]); + } + } else if (evt.touches.length === 2) { + evt.preventDefault(); - this.psv.container.removeChild(this.canvasContainer); - delete this.canvasContainer; - delete this.renderer; - delete this.scene; - delete this.camera; - delete this.mesh; - delete this.meshContainer; - delete this.raycaster; + this.__moveZoom(evt); - _AbstractService.prototype.destroy.call(this); + this.__cancelTwoFingersOverlay(); + } } /** - * @summary Handles events - * @param {Event} evt + * @summary Cancel the long touch timer if any * @private */ ; - _proto.handleEvent = function handleEvent(evt) { - /* eslint-disable */ - switch (evt.type) { - // @formatter:off - case EVENTS.SIZE_UPDATED: - this.__onSizeUpdated(); + _proto.__cancelLongTouch = function __cancelLongTouch() { + if (this.prop.longtouchTimeout) { + clearTimeout(this.prop.longtouchTimeout); + this.prop.longtouchTimeout = null; + } + } + /** + * @summary Cancel the two fingers overlay timer if any + * @private + */ + ; - break; + _proto.__cancelTwoFingersOverlay = function __cancelTwoFingersOverlay() { + if (this.prop.twofingersTimeout) { + clearTimeout(this.prop.twofingersTimeout); + this.prop.twofingersTimeout = null; + } - case EVENTS.ZOOM_UPDATED: - this.__onZoomUpdated(); + this.psv.overlay.hide(IDS.TWO_FINGERS); + } + /** + * @summary Handles mouse wheel events + * @param {WheelEvent} evt + * @private + */ + ; - break; + _proto.__onMouseWheel = function __onMouseWheel(evt) { + var _this5 = this; - case EVENTS.POSITION_UPDATED: - this.__onPositionUpdated(); + if (!this.config.mousewheel) { + return; + } - break; + if (this.config.mousewheelCtrlKey && !this.state.ctrlKeyDown) { + this.psv.overlay.show({ + id: IDS.CTRL_ZOOM, + image: mousewheelIcon, + text: this.config.lang.ctrlZoom + }); + clearTimeout(this.state.ctrlZoomTimeout); + this.state.ctrlZoomTimeout = setTimeout(function () { + return _this5.psv.overlay.hide(IDS.CTRL_ZOOM); + }, CTRLZOOM_TIMEOUT); + return; + } - case EVENTS.CONFIG_CHANGED: - if (evt.args[0].indexOf('fisheye') !== -1) { - this.__onPositionUpdated(); - } + evt.preventDefault(); + evt.stopPropagation(); + var delta = normalizeWheel(evt).spinY * 5 * this.config.zoomSpeed; - if (evt.args[0].indexOf('mousemove') !== -1) { - this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default'; - } + if (delta !== 0) { + this.psv.dynamics.zoom.step(-delta, 5); + } + } + /** + * @summary Handles fullscreen events + * @param {boolean} [force] force state + * @fires PSV.fullscreen-updated + * @package + */ + ; - break; - // @formatter:on + _proto.__fullscreenToggled = function __fullscreenToggled(force) { + this.prop.fullscreen = force !== undefined ? force : isFullscreenEnabled(this.psv.container); + + if (this.config.keyboard) { + if (this.prop.fullscreen) { + this.psv.startKeyboardControl(); + } else { + this.psv.stopKeyboardControl(); + } } - /* eslint-enable */ + this.psv.trigger(EVENTS.FULLSCREEN_UPDATED, this.prop.fullscreen); } /** - * @summary Hides the viewer + * @summary Initializes the movement + * @param {MouseEvent|Touch} evt + * @private */ ; - _proto.hide = function hide() { - this.canvasContainer.style.opacity = 0; + _proto.__startMove = function __startMove(evt) { + var _this6 = this; + + this.psv.stopAutorotate(); + this.psv.stopAnimation().then(function () { + _this6.state.mouseX = evt.clientX; + _this6.state.mouseY = evt.clientY; + _this6.state.startMouseX = _this6.state.mouseX; + _this6.state.startMouseY = _this6.state.mouseY; + _this6.state.moving = true; + _this6.state.zooming = false; + _this6.state.mouseHistory.length = 0; + + _this6.__logMouseMove(evt); + }); } /** - * @summary Shows the viewer + * @summary Initializes the combines move and zoom + * @param {TouchEvent} evt + * @private + */ + ; + + _proto.__startMoveZoom = function __startMoveZoom(evt) { + var p1 = { + x: evt.touches[0].clientX, + y: evt.touches[0].clientY + }; + var p2 = { + x: evt.touches[1].clientX, + y: evt.touches[1].clientY + }; + this.state.pinchDist = distance(p1, p2); + this.state.mouseX = (p1.x + p2.x) / 2; + this.state.mouseY = (p1.y + p2.y) / 2; + this.state.startMouseX = this.state.mouseX; + this.state.startMouseY = this.state.mouseY; + this.state.moving = true; + this.state.zooming = true; + } + /** + * @summary Stops the movement + * @description If the move threshold was not reached a click event is triggered, otherwise an animation is launched to simulate inertia + * @param {MouseEvent|Touch} evt + * @private */ ; - _proto.show = function show() { - this.canvasContainer.style.opacity = 1; + _proto.__stopMove = function __stopMove(evt) { + if (!getClosest(evt.target, '.psv-container')) { + this.state.moving = false; + this.state.mouseHistory.length = 0; + return; + } + + if (this.state.moving) { + // move threshold to trigger a click + if (Math.abs(evt.clientX - this.state.startMouseX) < this.state.moveThreshold && Math.abs(evt.clientY - this.state.startMouseY) < this.state.moveThreshold) { + this.__click(evt); + + this.state.moving = false; + } // inertia animation + else if (this.config.moveInertia) { + this.__logMouseMove(evt); + + this.__stopMoveInertia(evt); + } else { + this.state.moving = false; + } + + this.state.mouseHistory.length = 0; + } } /** - * @summary Updates the size of the renderer and the aspect of the camera + * @summary Stops the combined move and zoom * @private */ ; - _proto.__onSizeUpdated = function __onSizeUpdated() { - this.renderer.setSize(this.prop.size.width, this.prop.size.height); - this.camera.aspect = this.prop.aspect; - this.camera.updateProjectionMatrix(); - this.prop.needsUpdate = true; + _proto.__stopMoveZoom = function __stopMoveZoom() { + this.state.mouseHistory.length = 0; + this.state.moving = false; + this.state.zooming = false; } /** - * @summary Updates the fov of the camera + * @summary Performs an animation to simulate inertia when the movement stops + * @param {MouseEvent|Touch} evt * @private */ ; - _proto.__onZoomUpdated = function __onZoomUpdated() { - this.camera.fov = this.prop.vFov; - this.camera.updateProjectionMatrix(); - this.prop.needsUpdate = true; + _proto.__stopMoveInertia = function __stopMoveInertia(evt) { + var _this7 = this; + + var direction = { + x: evt.clientX - this.state.mouseHistory[0][1], + y: evt.clientY - this.state.mouseHistory[0][2] + }; + var norm = Math.sqrt(direction.x * direction.x + direction.y * direction.y); + this.prop.animationPromise = new Animation({ + properties: { + clientX: { + start: evt.clientX, + end: evt.clientX + direction.x + }, + clientY: { + start: evt.clientY, + end: evt.clientY + direction.y + } + }, + duration: norm * INERTIA_WINDOW / 100, + easing: 'outCirc', + onTick: function onTick(properties) { + _this7.__move(properties, false); + } + }); + this.prop.animationPromise.then(function () { + _this7.state.moving = false; + }); } /** - * @summary Updates the position of the camera + * @summary Triggers an event with all coordinates when a simple click is performed + * @param {MouseEvent|Touch} evt + * @param {boolean} [longtouch=false] + * @fires PSV.click + * @fires PSV.dblclick * @private */ ; - _proto.__onPositionUpdated = function __onPositionUpdated() { - this.camera.position.set(0, 0, 0); - this.camera.lookAt(this.prop.direction); + _proto.__click = function __click(evt, longtouch) { + var _this8 = this; - if (this.config.fisheye) { - this.camera.position.copy(this.prop.direction).multiplyScalar(this.config.fisheye / 2).negate(); + if (longtouch === void 0) { + longtouch = false; } - this.prop.needsUpdate = true; + var boundingRect = this.psv.container.getBoundingClientRect(); + /** + * @type {PSV.ClickData} + */ + + var data = { + rightclick: longtouch || evt.button === 2, + target: evt.target, + clientX: evt.clientX, + clientY: evt.clientY, + viewerX: evt.clientX - boundingRect.left, + viewerY: evt.clientY - boundingRect.top + }; + var intersections = this.psv.dataHelper.getIntersections({ + x: data.viewerX, + y: data.viewerY + }); + var sphereIntersection = intersections.find(function (i) { + return i.object.userData.psvSphere; + }); + + if (sphereIntersection) { + var sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(sphereIntersection.point); + data.longitude = sphericalCoords.longitude; + data.latitude = sphericalCoords.latitude; + data.objects = intersections.map(function (i) { + return i.object; + }).filter(function (o) { + return !o.userData.psvSphere; + }); + + try { + var textureCoords = this.psv.dataHelper.sphericalCoordsToTextureCoords(data); + data.textureX = textureCoords.x; + data.textureY = textureCoords.y; + } catch (e) { + data.textureX = NaN; + data.textureY = NaN; + } + + if (!this.state.dblclickTimeout) { + this.psv.trigger(EVENTS.CLICK, data); + this.state.dblclickData = clone(data); + this.state.dblclickTimeout = setTimeout(function () { + _this8.state.dblclickTimeout = null; + _this8.state.dblclickData = null; + }, DBLCLICK_DELAY); + } else { + if (Math.abs(this.state.dblclickData.clientX - data.clientX) < this.state.moveThreshold && Math.abs(this.state.dblclickData.clientY - data.clientY) < this.state.moveThreshold) { + this.psv.trigger(EVENTS.DOUBLE_CLICK, this.state.dblclickData); + } + + clearTimeout(this.state.dblclickTimeout); + this.state.dblclickTimeout = null; + this.state.dblclickData = null; + } + } } /** - * @summary Main event loop, calls {@link render} if `prop.needsUpdate` is true - * @param {number} timestamp - * @fires PSV.before-render + * @summary Performs movement + * @param {MouseEvent|Touch} evt + * @param {boolean} [log=true] * @private */ ; - _proto.__renderLoop = function __renderLoop(timestamp) { - var elapsed = this.timestamp !== null ? timestamp - this.timestamp : 0; - this.timestamp = timestamp; - this.psv.trigger(EVENTS.BEFORE_RENDER, timestamp, elapsed); - each(this.psv.dynamics, function (d) { - return d.update(elapsed); - }); + _proto.__move = function __move(evt, log) { + if (this.state.moving) { + var x = evt.clientX; + var y = evt.clientY; + var rotation = { + longitude: (x - this.state.mouseX) / this.prop.size.width * this.config.moveSpeed * THREE.Math.degToRad(this.prop.hFov), + latitude: (y - this.state.mouseY) / this.prop.size.height * this.config.moveSpeed * THREE.Math.degToRad(this.prop.vFov) + }; + var currentPosition = this.psv.getPosition(); + this.psv.rotate({ + longitude: currentPosition.longitude - rotation.longitude, + latitude: currentPosition.latitude + rotation.latitude + }); + this.state.mouseX = x; + this.state.mouseY = y; - if (this.prop.needsUpdate) { - this.render(); - this.prop.needsUpdate = false; + if (log !== false) { + this.__logMouseMove(evt); + } } } /** - * @summary Performs a render - * @description Do not call this method directly, instead call - * {@link PSV.Viewer#needsUpdate} on {@link PSV.event:before-render}. - * @fires PSV.render + * @summary Performs movement absolute to cursor position in viewer + * @param {MouseEvent} evt + * @private */ ; - _proto.render = function render() { - this.renderer.render(this.scene, this.camera); - this.psv.trigger(EVENTS.RENDER); + _proto.__moveAbsolute = function __moveAbsolute(evt) { + if (this.state.moving) { + var containerRect = this.psv.container.getBoundingClientRect(); + this.psv.dynamics.position.goto({ + longitude: ((evt.clientX - containerRect.left) / containerRect.width - 0.5) * Math.PI * 2, + latitude: -((evt.clientY - containerRect.top) / containerRect.height - 0.5) * Math.PI + }, 10); + } } /** - * @summary Applies the texture to the scene, creates the scene if needed - * @param {PSV.TextureData} textureData - * @fires PSV.panorama-loaded - * @package + * @summary Perfoms combined move and zoom + * @param {TouchEvent} evt + * @private */ ; - _proto.setTexture = function setTexture(textureData) { - var _this2 = this; - - this.prop.panoData = textureData.panoData; - this.psv.adapter.setTexture(this.mesh, textureData); + _proto.__moveZoom = function __moveZoom(evt) { + if (this.state.zooming && this.state.moving) { + var p1 = { + x: evt.touches[0].clientX, + y: evt.touches[0].clientY + }; + var p2 = { + x: evt.touches[1].clientX, + y: evt.touches[1].clientY + }; + var p = distance(p1, p2); + var delta = 80 * (p - this.state.pinchDist) / this.prop.size.width * this.config.zoomSpeed; + this.psv.zoom(this.psv.getZoomLevel() + delta); - if (!this.ready) { - this.renderer.setAnimationLoop(function (t) { - return _this2.__renderLoop(t); + this.__move({ + clientX: (p1.x + p2.x) / 2, + clientY: (p1.y + p2.y) / 2 }); - this.ready = true; - } - - this.psv.needsUpdate(); - this.psv.trigger(EVENTS.PANORAMA_LOADED); - } - /** - * @summary Apply a panorama data pose to a Mesh - * @param {PSV.PanoData} [panoData] - * @param {external:THREE.Mesh} [mesh=this.mesh] - * @package - */ - ; - _proto.setPanoramaPose = function setPanoramaPose(panoData, mesh) { - if (mesh === void 0) { - mesh = this.mesh; + this.state.pinchDist = p; } - - // By Google documentation the angles are applied on the camera in order : heading, pitch, roll - // here we apply the reverse transformation on the sphere - var cleanCorrection = this.psv.dataHelper.cleanPanoramaPose(panoData); - mesh.rotation.set(-cleanCorrection.tilt, -cleanCorrection.pan, -cleanCorrection.roll, 'ZXY'); } /** - * @summary Apply a SphereCorrection to a Mesh - * @param {PSV.SphereCorrection} [sphereCorrection] - * @param {external:THREE.Mesh} [mesh=this.meshContainer] - * @package + * @summary Stores each mouse position during a mouse move + * @description Positions older than "INERTIA_WINDOW" are removed
+ * Positions before a pause of "INERTIA_WINDOW" / 10 are removed + * @param {MouseEvent|Touch} evt + * @private */ ; - _proto.setSphereCorrection = function setSphereCorrection(sphereCorrection, mesh) { - if (mesh === void 0) { - mesh = this.meshContainer; + _proto.__logMouseMove = function __logMouseMove(evt) { + var now = Date.now(); + this.state.mouseHistory.push([now, evt.clientX, evt.clientY]); + var previous = null; + + for (var i = 0; i < this.state.mouseHistory.length;) { + if (this.state.mouseHistory[0][i] < now - INERTIA_WINDOW) { + this.state.mouseHistory.splice(i, 1); + } else if (previous && this.state.mouseHistory[0][i] - previous > INERTIA_WINDOW / 10) { + this.state.mouseHistory.splice(0, i); + i = 0; + previous = this.state.mouseHistory[0][i]; + } else { + i++; + previous = this.state.mouseHistory[0][i]; + } } + }; + + return EventsHandler; + }(AbstractService); + + /** + * @summary Viewer and renderer + * @extends PSV.services.AbstractService + * @memberof PSV.services + */ + + var Renderer = /*#__PURE__*/function (_AbstractService) { + _inheritsLoose(Renderer, _AbstractService); - var cleanCorrection = this.psv.dataHelper.cleanSphereCorrection(sphereCorrection); - mesh.rotation.set(cleanCorrection.tilt, cleanCorrection.pan, cleanCorrection.roll, 'ZXY'); - } /** - * @summary Performs transition between the current and a new texture - * @param {PSV.TextureData} textureData - * @param {PSV.PanoramaOptions} options - * @returns {PSV.Animation} - * @package + * @param {PSV.Viewer} psv */ - ; + function Renderer(psv) { + var _this$mesh$userData; - _proto.transition = function transition(textureData, options) { - var _this3 = this; + var _this; - var positionProvided = isExtendedPosition(options); - var zoomProvided = ('zoom' in options); // create temp group and new mesh, half size to be in "front" of the first one + _this = _AbstractService.call(this, psv) || this; + /** + * @member {external:THREE.WebGLRenderer} + * @readonly + * @protected + */ - var group = new THREE.Group(); - var mesh = this.psv.adapter.createMesh(0.5); - this.psv.adapter.setTexture(mesh, textureData, true); - this.psv.adapter.setTextureOpacity(mesh, 0); - this.setPanoramaPose(textureData.panoData, mesh); - this.setSphereCorrection(options.sphereCorrection, group); // rotate the new sphere to make the target position face the camera + _this.renderer = new THREE.WebGLRenderer({ + alpha: true, + antialias: true + }); - if (positionProvided) { - var cleanPosition = this.psv.dataHelper.cleanPosition(options); - var currentPosition = this.psv.getPosition(); // Longitude rotation along the vertical axis + _this.renderer.setPixelRatio(SYSTEM.pixelRatio); - var verticalAxis = new THREE.Vector3(0, 1, 0); - group.rotateOnWorldAxis(verticalAxis, cleanPosition.longitude - currentPosition.longitude); // Latitude rotation along the camera horizontal axis + _this.renderer.domElement.className = 'psv-canvas'; + /** + * @member {external:THREE.Scene} + * @readonly + * @protected + */ - var horizontalAxis = new THREE.Vector3(0, 1, 0).cross(this.camera.getWorldDirection(new THREE.Vector3())).normalize(); - group.rotateOnWorldAxis(horizontalAxis, cleanPosition.latitude - currentPosition.latitude); - } + _this.scene = new THREE.Scene(); + /** + * @member {external:THREE.PerspectiveCamera} + * @readonly + * @protected + */ - group.add(mesh); - this.scene.add(group); - var animation = new Animation({ - properties: { - opacity: { - start: 0.0, - end: 1.0 - }, - zoom: zoomProvided ? { - start: this.psv.getZoomLevel(), - end: options.zoom - } : undefined - }, - duration: options.transition, - easing: 'outCubic', - onTick: function onTick(properties) { - _this3.psv.adapter.setTextureOpacity(mesh, properties.opacity); + _this.camera = new THREE.PerspectiveCamera(50, 16 / 9, 1, 2 * SPHERE_RADIUS); + /** + * @member {external:THREE.Mesh} + * @readonly + * @protected + */ - _this3.psv.adapter.setTextureOpacity(_this3.mesh, 1 - properties.opacity); + _this.mesh = _this.psv.adapter.createMesh(); + _this.mesh.userData = (_this$mesh$userData = {}, _this$mesh$userData[MESH_USER_DATA] = true, _this$mesh$userData); + /** + * @member {external:THREE.Group} + * @readonly + * @private + */ - if (zoomProvided) { - _this3.psv.zoom(properties.zoom); - } + _this.meshContainer = new THREE.Group(); - _this3.psv.needsUpdate(); - } - }); - animation.then(function (completed) { - if (completed) { - // remove temp sphere and transfer the texture to the main mesh - _this3.setTexture(textureData); + _this.meshContainer.add(_this.mesh); - _this3.psv.adapter.setTextureOpacity(_this3.mesh, 1); + _this.scene.add(_this.meshContainer); + /** + * @member {external:THREE.Raycaster} + * @readonly + * @protected + */ - _this3.setPanoramaPose(textureData.panoData); - _this3.setSphereCorrection(options.sphereCorrection); // actually rotate the camera + _this.raycaster = new THREE.Raycaster(); + /** + * @member {number} + * @private + */ + _this.timestamp = null; + /** + * @member {boolean} + * @private + */ - if (positionProvided) { - _this3.psv.rotate(options); - } - } else { - _this3.psv.adapter.disposeTexture(textureData); - } + _this.ready = false; + /** + * @member {HTMLElement} + * @readonly + * @package + */ - _this3.scene.remove(group); + _this.canvasContainer = document.createElement('div'); + _this.canvasContainer.className = 'psv-canvas-container'; + _this.canvasContainer.style.background = _this.psv.config.canvasBackground; + _this.canvasContainer.style.cursor = _this.psv.config.mousemove ? 'move' : 'default'; - mesh.geometry.dispose(); - mesh.geometry = null; - }); - return animation; - } - /** - * @summary Calls `dispose` on all objects and textures - * @param {external:THREE.Object3D} object - * @private - */ - ; + _this.canvasContainer.appendChild(_this.renderer.domElement); - _proto.__cleanTHREEScene = function __cleanTHREEScene(object) { - var _this4 = this; + _this.psv.container.appendChild(_this.canvasContainer); - object.traverse(function (item) { - if (item.geometry) { - item.geometry.dispose(); - } + psv.on(EVENTS.SIZE_UPDATED, _assertThisInitialized(_this)); + psv.on(EVENTS.ZOOM_UPDATED, _assertThisInitialized(_this)); + psv.on(EVENTS.POSITION_UPDATED, _assertThisInitialized(_this)); + psv.on(EVENTS.CONFIG_CHANGED, _assertThisInitialized(_this)); - if (item.material) { - if (Array.isArray(item.material)) { - item.material.forEach(function (material) { - if (material.map) { - material.map.dispose(); - } + _this.hide(); - material.dispose(); - }); - } else { - if (item.material.map) { - item.material.map.dispose(); - } + return _this; + } + /** + * @override + */ - item.material.dispose(); - } - } - if (item.dispose && !(item instanceof THREE.Scene)) { - item.dispose(); - } + var _proto = Renderer.prototype; - if (item !== object) { - _this4.__cleanTHREEScene(item); - } - }); - }; + _proto.destroy = function destroy() { + // cancel render loop + this.renderer.setAnimationLoop(null); // destroy ThreeJS view - return Renderer; - }(AbstractService); + this.__cleanTHREEScene(this.scene); // remove container - /** - * @summary Texture loader - * @extends PSV.services.AbstractService - * @memberof PSV.services - */ - var TextureLoader = /*#__PURE__*/function (_AbstractService) { - _inheritsLoose(TextureLoader, _AbstractService); + this.psv.container.removeChild(this.canvasContainer); + delete this.canvasContainer; + delete this.renderer; + delete this.scene; + delete this.camera; + delete this.mesh; + delete this.meshContainer; + delete this.raycaster; + _AbstractService.prototype.destroy.call(this); + } /** - * @param {PSV.Viewer} psv + * @summary Handles events + * @param {Event} evt + * @private */ - function TextureLoader(psv) { - var _this; - - _this = _AbstractService.call(this, psv) || this; - /** - * @summary THREE file loader - * @type {external:THREE:FileLoader} - * @private - */ + ; - _this.loader = new THREE.FileLoader(); + _proto.handleEvent = function handleEvent(evt) { + /* eslint-disable */ + switch (evt.type) { + // @formatter:off + case EVENTS.SIZE_UPDATED: + this.__onSizeUpdated(); - _this.loader.setResponseType('blob'); + break; - if (_this.config.withCredentials) { - _this.loader.setWithCredentials(true); - } + case EVENTS.ZOOM_UPDATED: + this.__onZoomUpdated(); - if (_this.config.requestHeaders && typeof _this.config.requestHeaders === 'object') { - _this.loader.setRequestHeader(_this.config.requestHeaders); - } + break; - return _this; - } - /** - * @override - */ + case EVENTS.POSITION_UPDATED: + this.__onPositionUpdated(); + break; - var _proto = TextureLoader.prototype; + case EVENTS.CONFIG_CHANGED: + if (evt.args[0].includes('fisheye')) { + this.__onPositionUpdated(); + } - _proto.destroy = function destroy() { - this.abortLoading(); + if (evt.args[0].includes('mousemove')) { + this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default'; + } + + break; + // @formatter:on + } + /* eslint-enable */ - _AbstractService.prototype.destroy.call(this); } /** - * @summary Loads the panorama texture(s) - * @param {*} panorama - * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData] - * @returns {Promise.} - * @throws {PSV.PSVError} when the image cannot be loaded - * @package - * @deprecated + * @summary Hides the viewer */ ; - _proto.loadTexture = function loadTexture(panorama, newPanoData) { - return this.psv.adapter.loadTexture(panorama, newPanoData); + _proto.hide = function hide() { + this.canvasContainer.style.opacity = 0; } /** - * @summary Cancels current HTTP requests - * @package + * @summary Shows the viewer */ ; - _proto.abortLoading = function abortLoading() {// noop implementation waiting for https://github.com/mrdoob/three.js/pull/23070 + _proto.show = function show() { + this.canvasContainer.style.opacity = 1; } /** - * @summary Loads a Blob with FileLoader - * @param {string} url - * @param {function(number)} [onProgress] - * @returns {Promise} + * @summary Updates the size of the renderer and the aspect of the camera + * @private */ ; - _proto.loadFile = function loadFile(url, onProgress) { - var _this2 = this; - - if (this.config.requestHeaders && typeof this.config.requestHeaders === 'function') { - this.loader.setRequestHeader(this.config.requestHeaders(url)); - } - - return new Promise(function (resolve, reject) { - var progress = 0; - onProgress && onProgress(progress); - - _this2.loader.load(url, function (result) { - progress = 100; - onProgress && onProgress(progress); - resolve(result); - }, function (e) { - if (e.lengthComputable) { - var newProgress = e.loaded / e.total * 100; - - if (newProgress > progress) { - progress = newProgress; - onProgress && onProgress(progress); - } - } - }, function (err) { - reject(err); - }); - }); + _proto.__onSizeUpdated = function __onSizeUpdated() { + this.renderer.setSize(this.prop.size.width, this.prop.size.height); + this.camera.aspect = this.prop.aspect; + this.camera.updateProjectionMatrix(); + this.prop.needsUpdate = true; } /** - * @summary Loads an Image using FileLoader to have progress events - * @param {string} url - * @param {function(number)} [onProgress] - * @returns {Promise} + * @summary Updates the fov of the camera + * @private */ ; - _proto.loadImage = function loadImage(url, onProgress) { - return this.loadFile(url, onProgress).then(function (result) { - return new Promise(function (resolve, reject) { - var img = document.createElementNS('http://www.w3.org/1999/xhtml', 'img'); - - img.onload = function () { - URL.revokeObjectURL(img.src); - resolve(img); - }; - - img.onerror = reject; - img.src = URL.createObjectURL(result); - }); - }); + _proto.__onZoomUpdated = function __onZoomUpdated() { + this.camera.fov = this.prop.vFov; + this.camera.updateProjectionMatrix(); + this.prop.needsUpdate = true; } /** - * @summary Preload a panorama file without displaying it - * @param {*} panorama - * @returns {Promise} + * @summary Updates the position of the camera + * @private */ ; - _proto.preloadPanorama = function preloadPanorama(panorama) { - if (this.psv.adapter.supportsPreload(panorama)) { - return this.psv.adapter.loadTexture(panorama); - } else { - return Promise.resolve(); - } - }; - - return TextureLoader; - }(AbstractService); - - var STATE = { - NONE: 0, - SHOWING: 1, - HIDING: 2, - READY: 3 - }; - /** - * @typedef {Object} PSV.components.Tooltip.Position - * @summary Object defining the tooltip position - * @property {number} top - Position of the tip of the arrow of the tooltip, in pixels - * @property {number} left - Position of the tip of the arrow of the tooltip, in pixels - * @property {string|string[]} [position='top center'] - Tooltip position toward it's arrow tip. - * Accepted values are combinations of `top`, `center`, `bottom` and `left`, `center`, `right` - * @property {Object} [box] - Used when displaying a tooltip on a marker - * @property {number} [box.width=0] - * @property {number} [box.height=0] - */ - - /** - * @typedef {PSV.components.Tooltip.Position} PSV.components.Tooltip.Config - * @summary Object defining the tooltip configuration - * @property {string} content - HTML content of the tooltip - * @property {string} [className] - Additional CSS class added to the tooltip - * @property {*} [data] - Userdata associated to the tooltip - */ - - /** - * @summary Tooltip component - * @description Never instanciate tooltips directly use {@link PSV.services.TooltipRenderer} instead - * @extends PSV.components.AbstractComponent - * @memberof PSV.components - */ + _proto.__onPositionUpdated = function __onPositionUpdated() { + this.camera.position.set(0, 0, 0); + this.camera.lookAt(this.prop.direction); - var Tooltip = /*#__PURE__*/function (_AbstractComponent) { - _inheritsLoose(Tooltip, _AbstractComponent); + if (this.config.fisheye) { + this.camera.position.copy(this.prop.direction).multiplyScalar(this.config.fisheye / 2).negate(); + } + this.prop.needsUpdate = true; + } /** - * @param {PSV.Viewer} psv - * @param {{arrow: number, offset: number}} size + * @summary Main event loop, calls {@link render} if `prop.needsUpdate` is true + * @param {number} timestamp + * @fires PSV.before-render + * @private */ - function Tooltip(psv, size) { - var _this; - - _this = _AbstractComponent.call(this, psv, 'psv-tooltip') || this; - /** - * @override - * @property {number} arrow - * @property {number} offset - * @property {number} width - * @property {number} height - * @property {string} pos - * @property {string} state - * @property {*} data - */ + ; - _this.prop = _extends({}, _this.prop, size, { - state: STATE.NONE, - width: 0, - height: 0, - pos: '', - data: null + _proto.__renderLoop = function __renderLoop(timestamp) { + var elapsed = this.timestamp !== null ? timestamp - this.timestamp : 0; + this.timestamp = timestamp; + this.psv.trigger(EVENTS.BEFORE_RENDER, timestamp, elapsed); + each(this.psv.dynamics, function (d) { + return d.update(elapsed); }); - /** - * Tooltip content - * @member {HTMLElement} - * @readonly - * @private - */ - - _this.content = document.createElement('div'); - _this.content.className = 'psv-tooltip-content'; - - _this.container.appendChild(_this.content); - /** - * Tooltip arrow - * @member {HTMLElement} - * @readonly - * @package - */ - - _this.arrow = document.createElement('div'); - _this.arrow.className = 'psv-tooltip-arrow'; - - _this.container.appendChild(_this.arrow); - - _this.container.addEventListener('transitionend', _assertThisInitialized(_this)); - - _this.container.style.top = '-1000px'; - _this.container.style.left = '-1000px'; - return _this; + if (this.prop.needsUpdate) { + this.render(); + this.prop.needsUpdate = false; + } } /** - * @override + * @summary Performs a render + * @description Do not call this method directly, instead call + * {@link PSV.Viewer#needsUpdate} on {@link PSV.event:before-render}. + * @fires PSV.render */ + ; - - var _proto = Tooltip.prototype; - - _proto.destroy = function destroy() { - delete this.arrow; - delete this.content; - - _AbstractComponent.prototype.destroy.call(this); + _proto.render = function render() { + this.renderer.render(this.scene, this.camera); + this.psv.trigger(EVENTS.RENDER); } /** - * @summary Handles events - * @param {Event} e - * @private + * @summary Applies the texture to the scene, creates the scene if needed + * @param {PSV.TextureData} textureData + * @fires PSV.panorama-loaded + * @package */ ; - _proto.handleEvent = function handleEvent(e) { - /* eslint-disable */ - switch (e.type) { - // @formatter:off - case 'transitionend': - this.__onTransitionEnd(e); + _proto.setTexture = function setTexture(textureData) { + var _this2 = this; + + this.prop.panoData = textureData.panoData; + this.psv.adapter.setTexture(this.mesh, textureData); - break; - // @formatter:on + if (!this.ready) { + this.renderer.setAnimationLoop(function (t) { + return _this2.__renderLoop(t); + }); + this.ready = true; } - /* eslint-enable */ + this.psv.needsUpdate(); + this.psv.trigger(EVENTS.PANORAMA_LOADED, textureData); } /** - * @override - * @summary This method is not supported - * @throws {PSV.PSVError} always + * @summary Apply a panorama data pose to a Mesh + * @param {PSV.PanoData} [panoData] + * @param {external:THREE.Mesh} [mesh=this.mesh] + * @package */ ; - _proto.toggle = function toggle() { - throw new PSVError('Tooltip cannot be toggled'); + _proto.setPanoramaPose = function setPanoramaPose(panoData, mesh) { + if (mesh === void 0) { + mesh = this.mesh; + } + + // By Google documentation the angles are applied on the camera in order : heading, pitch, roll + // here we apply the reverse transformation on the sphere + var cleanCorrection = this.psv.dataHelper.cleanPanoramaPose(panoData); + mesh.rotation.set(-cleanCorrection.tilt, -cleanCorrection.pan, -cleanCorrection.roll, 'ZXY'); } /** - * @summary Displays the tooltip on the viewer - * Do not call this method directly, use {@link PSV.services.TooltipRenderer} instead. - * @param {PSV.components.Tooltip.Config} config - * - * @fires PSV.show-tooltip - * @throws {PSV.PSVError} when the configuration is incorrect - * + * @summary Apply a SphereCorrection to a Mesh + * @param {PSV.SphereCorrection} [sphereCorrection] + * @param {external:THREE.Mesh} [mesh=this.meshContainer] * @package */ ; - _proto.show = function show(config) { - if (this.prop.state !== STATE.NONE) { - throw new PSVError('Initialized tooltip cannot be re-initialized'); - } - - if (config.className) { - addClasses(this.container, config.className); + _proto.setSphereCorrection = function setSphereCorrection(sphereCorrection, mesh) { + if (mesh === void 0) { + mesh = this.meshContainer; } - this.content.innerHTML = config.content; - var rect = this.container.getBoundingClientRect(); - this.prop.width = rect.right - rect.left; - this.prop.height = rect.bottom - rect.top; - this.prop.state = STATE.READY; - this.move(config); - this.prop.data = config.data; - this.prop.state = STATE.SHOWING; - this.psv.trigger(EVENTS.SHOW_TOOLTIP, this.prop.data, this); + var cleanCorrection = this.psv.dataHelper.cleanSphereCorrection(sphereCorrection); + mesh.rotation.set(cleanCorrection.tilt, cleanCorrection.pan, cleanCorrection.roll, 'ZXY'); } /** - * @summary Moves the tooltip to a new position - * @param {PSV.components.Tooltip.Position} config - * - * @throws {PSV.PSVError} when the configuration is incorrect + * @summary Performs transition between the current and a new texture + * @param {PSV.TextureData} textureData + * @param {PSV.PanoramaOptions} options + * @returns {PSV.Animation} + * @package */ ; - _proto.move = function move(config) { - if (this.prop.state !== STATE.SHOWING && this.prop.state !== STATE.READY) { - throw new PSVError('Uninitialized tooltip cannot be moved'); - } - - var t = this.container; - var a = this.arrow; // compute size + _proto.transition = function transition(textureData, options) { + var _this3 = this; - var style = { - posClass: cleanPosition(config.position, 'top center', false), - width: this.prop.width, - height: this.prop.height, - top: 0, - left: 0, - arrowTop: 0, - arrowLeft: 0 - }; // set initial position + var positionProvided = isExtendedPosition(options); + var zoomProvided = ('zoom' in options); // create temp group and new mesh, half size to be in "front" of the first one - this.__computeTooltipPosition(style, config); // correct position if overflow + var group = new THREE.Group(); + var mesh = this.psv.adapter.createMesh(0.5); + this.psv.adapter.setTexture(mesh, textureData, true); + this.psv.adapter.setTextureOpacity(mesh, 0); + this.setPanoramaPose(textureData.panoData, mesh); + this.setSphereCorrection(options.sphereCorrection, group); // rotate the new sphere to make the target position face the camera + if (positionProvided) { + var cleanPosition = this.psv.dataHelper.cleanPosition(options); + var currentPosition = this.psv.getPosition(); // Longitude rotation along the vertical axis - var refresh = false; + var verticalAxis = new THREE.Vector3(0, 1, 0); + group.rotateOnWorldAxis(verticalAxis, cleanPosition.longitude - currentPosition.longitude); // Latitude rotation along the camera horizontal axis - if (style.top < this.prop.offset) { - style.posClass[0] = 'bottom'; - refresh = true; - } else if (style.top + style.height > this.psv.prop.size.height - this.prop.offset) { - style.posClass[0] = 'top'; - refresh = true; + var horizontalAxis = new THREE.Vector3(0, 1, 0).cross(this.camera.getWorldDirection(new THREE.Vector3())).normalize(); + group.rotateOnWorldAxis(horizontalAxis, cleanPosition.latitude - currentPosition.latitude); } - if (style.left < this.prop.offset) { - style.posClass[1] = 'right'; - refresh = true; - } else if (style.left + style.width > this.psv.prop.size.width - this.prop.offset) { - style.posClass[1] = 'left'; - refresh = true; - } + group.add(mesh); + this.scene.add(group); + var animation = new Animation({ + properties: { + opacity: { + start: 0.0, + end: 1.0 + }, + zoom: zoomProvided ? { + start: this.psv.getZoomLevel(), + end: options.zoom + } : undefined + }, + duration: options.transition, + easing: 'outCubic', + onTick: function onTick(properties) { + _this3.psv.adapter.setTextureOpacity(mesh, properties.opacity); - if (refresh) { - this.__computeTooltipPosition(style, config); - } // apply position + _this3.psv.adapter.setTextureOpacity(_this3.mesh, 1 - properties.opacity); + if (zoomProvided) { + _this3.psv.zoom(properties.zoom); + } - t.style.top = style.top + 'px'; - t.style.left = style.left + 'px'; - a.style.top = style.arrowTop + 'px'; - a.style.left = style.arrowLeft + 'px'; - var newPos = style.posClass.join('-'); + _this3.psv.needsUpdate(); + } + }); + animation.then(function (completed) { + if (completed) { + // remove temp sphere and transfer the texture to the main mesh + _this3.setTexture(textureData); - if (newPos !== this.prop.pos) { - t.classList.remove("psv-tooltip--" + this.prop.pos); - this.prop.pos = newPos; - t.classList.add("psv-tooltip--" + this.prop.pos); - } - } - /** - * @summary Hides the tooltip - * @fires PSV.hide-tooltip - */ - ; + _this3.psv.adapter.setTextureOpacity(_this3.mesh, 1); - _proto.hide = function hide() { - this.container.classList.remove('psv-tooltip--visible'); - this.prop.state = STATE.HIDING; - this.psv.trigger(EVENTS.HIDE_TOOLTIP, this.prop.data); - } - /** - * @summary Finalize transition - * @param {TransitionEvent} e - * @private - */ - ; + _this3.setPanoramaPose(textureData.panoData); - _proto.__onTransitionEnd = function __onTransitionEnd(e) { - if (e.propertyName === 'transform') { - switch (this.prop.state) { - case STATE.SHOWING: - this.container.classList.add('psv-tooltip--visible'); - this.prop.state = STATE.READY; - break; + _this3.setSphereCorrection(options.sphereCorrection); // actually rotate the camera - case STATE.HIDING: - this.prop.state = STATE.NONE; - this.destroy(); - break; + if (positionProvided) { + _this3.psv.rotate(options); + } + } else { + _this3.psv.adapter.disposeTexture(textureData); } - } + + _this3.scene.remove(group); + + mesh.geometry.dispose(); + mesh.geometry = null; + }); + return animation; } /** - * @summary Computes the position of the tooltip and its arrow - * @param {Object} style - * @param {Object} config + * @summary Calls `dispose` on all objects and textures + * @param {external:THREE.Object3D} object * @private - */ - ; - - _proto.__computeTooltipPosition = function __computeTooltipPosition(style, config) { - var topBottom = false; - - if (!config.box) { - config.box = { - width: 0, - height: 0 - }; - } - - switch (style.posClass[0]) { - case 'bottom': - style.top = config.top + config.box.height + this.prop.offset + this.prop.arrow; - style.arrowTop = -this.prop.arrow * 2; - topBottom = true; - break; - - case 'center': - style.top = config.top + config.box.height / 2 - style.height / 2; - style.arrowTop = style.height / 2 - this.prop.arrow; - break; - - case 'top': - style.top = config.top - style.height - this.prop.offset - this.prop.arrow; - style.arrowTop = style.height; - topBottom = true; - break; - // no default - } - - switch (style.posClass[1]) { - case 'right': - if (topBottom) { - style.left = config.left + config.box.width / 2 - this.prop.offset - this.prop.arrow; - style.arrowLeft = this.prop.offset; - } else { - style.left = config.left + config.box.width + this.prop.offset + this.prop.arrow; - style.arrowLeft = -this.prop.arrow * 2; - } + */ + ; - break; + _proto.__cleanTHREEScene = function __cleanTHREEScene(object) { + var _this4 = this; - case 'center': - style.left = config.left + config.box.width / 2 - style.width / 2; - style.arrowLeft = style.width / 2 - this.prop.arrow; - break; + object.traverse(function (item) { + if (item.geometry) { + item.geometry.dispose(); + } - case 'left': - if (topBottom) { - style.left = config.left - style.width + config.box.width / 2 + this.prop.offset + this.prop.arrow; - style.arrowLeft = style.width - this.prop.offset - this.prop.arrow * 2; + if (item.material) { + if (Array.isArray(item.material)) { + item.material.forEach(function (material) { + if (material.map) { + material.map.dispose(); + } + + material.dispose(); + }); } else { - style.left = config.left - style.width - this.prop.offset - this.prop.arrow; - style.arrowLeft = style.width; + if (item.material.map) { + item.material.map.dispose(); + } + + item.material.dispose(); } + } - break; - // no default - } + if (item.dispose && !(item instanceof THREE.Scene)) { + item.dispose(); + } + + if (item !== object) { + _this4.__cleanTHREEScene(item); + } + }); }; - return Tooltip; - }(AbstractComponent); + return Renderer; + }(AbstractService); /** - * @summary Tooltip renderer + * @summary Texture loader * @extends PSV.services.AbstractService * @memberof PSV.services */ - var TooltipRenderer = /*#__PURE__*/function (_AbstractService) { - _inheritsLoose(TooltipRenderer, _AbstractService); + var TextureLoader = /*#__PURE__*/function (_AbstractService) { + _inheritsLoose(TextureLoader, _AbstractService); /** * @param {PSV.Viewer} psv */ - function TooltipRenderer(psv) { + function TextureLoader(psv) { var _this; _this = _AbstractService.call(this, psv) || this; - var testTooltip = new Tooltip(_this.psv); /** - * @summary Computed static sizes - * @member {Object} - * @package - * @property {number} arrowSize - * @property {number} offset + * @summary THREE file loader + * @type {external:THREE:FileLoader} + * @private */ - _this.size = { - arrow: parseInt(getStyle(testTooltip.arrow, 'borderTopWidth'), 10), - offset: parseInt(getStyle(testTooltip.container, 'outlineWidth'), 10) - }; - testTooltip.destroy(); + _this.loader = new THREE.FileLoader(); + + _this.loader.setResponseType('blob'); + + if (_this.config.withCredentials) { + _this.loader.setWithCredentials(true); + } + + if (_this.config.requestHeaders && typeof _this.config.requestHeaders === 'object') { + _this.loader.setRequestHeader(_this.config.requestHeaders); + } + return _this; } /** @@ -7782,440 +8005,514 @@ */ - var _proto = TooltipRenderer.prototype; + var _proto = TextureLoader.prototype; _proto.destroy = function destroy() { - delete this.size; + this.abortLoading(); _AbstractService.prototype.destroy.call(this); } /** - * @summary Displays a tooltip on the viewer - * @param {PSV.components.Tooltip.Config} config - * @returns {PSV.components.Tooltip} - * - * @fires PSV.show-tooltip - * @throws {PSV.PSVError} when the configuration is incorrect - * - * @example - * viewer.tooltip.create({ content: 'Hello world', top: 200, left: 450, position: 'center bottom'}) + * @summary Loads the panorama texture(s) + * @param {*} panorama + * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData] + * @returns {Promise.} + * @throws {PSV.PSVError} when the image cannot be loaded + * @package + * @deprecated */ ; - _proto.create = function create(config) { - var tooltip = new Tooltip(this.psv, this.size); - tooltip.show(config); - return tooltip; - }; + _proto.loadTexture = function loadTexture(panorama, newPanoData) { + return this.psv.adapter.loadTexture(panorama, newPanoData); + } + /** + * @summary Cancels current HTTP requests + * @package + */ + ; - return TooltipRenderer; - }(AbstractService); + _proto.abortLoading = function abortLoading() {// noop implementation waiting for https://github.com/mrdoob/three.js/pull/23070 + } + /** + * @summary Loads a Blob with FileLoader + * @param {string} url + * @param {function(number)} [onProgress] + * @returns {Promise} + */ + ; - /** - * @summary Represents a variable that can dynamically change with time (using requestAnimationFrame) - * @memberOf PSV - * @package - */ + _proto.loadFile = function loadFile(url, onProgress) { + var _this2 = this; - var Dynamic = /*#__PURE__*/function () { + if (this.config.requestHeaders && typeof this.config.requestHeaders === 'function') { + this.loader.setRequestHeader(this.config.requestHeaders(url)); + } + + return new Promise(function (resolve, reject) { + var progress = 0; + onProgress && onProgress(progress); + + _this2.loader.load(url, function (result) { + progress = 100; + onProgress && onProgress(progress); + resolve(result); + }, function (e) { + if (e.lengthComputable) { + var newProgress = e.loaded / e.total * 100; + + if (newProgress > progress) { + progress = newProgress; + onProgress && onProgress(progress); + } + } + }, function (err) { + reject(err); + }); + }); + } /** - * @param {Function} [fn] Callback function - * @param {number} [defaultValue] Default position - * @param {number} [min] Minimum position - * @param {number} [max] Maximum position + * @summary Loads an Image using FileLoader to have progress events + * @param {string} url + * @param {function(number)} [onProgress] + * @returns {Promise} */ - function Dynamic(fn, defaultValue, min, max) { - if (defaultValue === void 0) { - defaultValue = 0; - } + ; - if (min === void 0) { - min = -Infinity; - } + _proto.loadImage = function loadImage(url, onProgress) { + return this.loadFile(url, onProgress).then(function (result) { + return new Promise(function (resolve, reject) { + var img = document.createElementNS('http://www.w3.org/1999/xhtml', 'img'); - if (max === void 0) { - max = Infinity; + img.onload = function () { + URL.revokeObjectURL(img.src); + resolve(img); + }; + + img.onerror = reject; + img.src = URL.createObjectURL(result); + }); + }); + } + /** + * @summary Preload a panorama file without displaying it + * @param {*} panorama + * @returns {Promise} + */ + ; + + _proto.preloadPanorama = function preloadPanorama(panorama) { + if (this.psv.adapter.supportsPreload(panorama)) { + return this.psv.adapter.loadTexture(panorama); + } else { + return Promise.resolve(); } + }; - /** - * @type {Function} - * @private - * @readonly - */ - this.fn = fn; - /** - * @type {number} - * @private - */ + return TextureLoader; + }(AbstractService); - this.mode = Dynamic.STOP; - /** - * @type {number} - * @private - */ + var STATE = { + NONE: 0, + SHOWING: 1, + HIDING: 2, + READY: 3 + }; + /** + * @typedef {Object} PSV.components.Tooltip.Position + * @summary Object defining the tooltip position + * @property {number} top - Position of the tip of the arrow of the tooltip, in pixels + * @property {number} left - Position of the tip of the arrow of the tooltip, in pixels + * @property {string|string[]} [position='top center'] - Tooltip position toward it's arrow tip. + * Accepted values are combinations of `top`, `center`, `bottom` and `left`, `center`, `right` + * @property {Object} [box] - Used when displaying a tooltip on a marker + * @property {number} [box.width=0] + * @property {number} [box.height=0] + */ - this.speed = 0; - /** - * @type {number} - * @private - */ + /** + * @typedef {PSV.components.Tooltip.Position} PSV.components.Tooltip.Config + * @summary Object defining the tooltip configuration + * @property {string} content - HTML content of the tooltip + * @property {string} [className] - Additional CSS class added to the tooltip + * @property {*} [data] - Userdata associated to the tooltip + */ + + /** + * @summary Tooltip component + * @description Never instanciate tooltips directly use {@link PSV.services.TooltipRenderer} instead + * @extends PSV.components.AbstractComponent + * @memberof PSV.components + */ - this.speedMult = 1; - /** - * @type {number} - * @private - */ + var Tooltip = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(Tooltip, _AbstractComponent); - this.currentSpeed = 0; - /** - * @type {number} - * @private - */ + /** + * @param {PSV.Viewer} psv + * @param {{arrow: number, offset: number}} size + */ + function Tooltip(psv, size) { + var _this; - this.target = 0; + _this = _AbstractComponent.call(this, psv, 'psv-tooltip') || this; /** - * @type {number} - * @readonly + * @override + * @property {number} arrow + * @property {number} offset + * @property {number} width + * @property {number} height + * @property {string} pos + * @property {string} state + * @property {*} data */ - this.current = defaultValue; + _this.prop = _extends({}, _this.prop, size, { + state: STATE.NONE, + width: 0, + height: 0, + pos: '', + data: null + }); /** - * @type {number} + * Tooltip content + * @member {HTMLElement} + * @readonly * @private */ - this.min = min; + _this.content = document.createElement('div'); + _this.content.className = 'psv-tooltip-content'; + + _this.container.appendChild(_this.content); /** - * @type {number} - * @private + * Tooltip arrow + * @member {HTMLElement} + * @readonly + * @package */ - this.max = max; - if (this.fn) { - this.fn(defaultValue); - } - } - /** - * Changes base speed - * @param {number} speed - */ + _this.arrow = document.createElement('div'); + _this.arrow.className = 'psv-tooltip-arrow'; + _this.container.appendChild(_this.arrow); - var _proto = Dynamic.prototype; + _this.container.addEventListener('transitionend', _assertThisInitialized(_this)); - _proto.setSpeed = function setSpeed(speed) { - this.speed = speed; + _this.container.style.top = '-1000px'; + _this.container.style.left = '-1000px'; + return _this; } /** - * Defines the target position - * @param {number} position - * @param {number} [speedMult=1] + * @override */ - ; - - _proto.goto = function goto(position, speedMult) { - if (speedMult === void 0) { - speedMult = 1; - } - this.mode = Dynamic.POSITION; - this.target = bound(position, this.min, this.max); - this.speedMult = speedMult; - } - /** - * Increase/decrease the target position - * @param {number} step - * @param {number} [speedMult=1] - */ - ; - _proto.step = function step(_step, speedMult) { - if (speedMult === void 0) { - speedMult = 1; - } + var _proto = Tooltip.prototype; - if (this.mode !== Dynamic.POSITION) { - this.target = this.current; - } + _proto.destroy = function destroy() { + delete this.arrow; + delete this.content; - this.goto(this.target + _step, speedMult); + _AbstractComponent.prototype.destroy.call(this); } /** - * Starts infinite movement - * @param {boolean} [invert=false] - * @param {number} [speedMult=1] + * @summary Handles events + * @param {Event} e + * @private */ ; - _proto.roll = function roll(invert, speedMult) { - if (invert === void 0) { - invert = false; - } + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + // @formatter:off + case 'transitionend': + this.__onTransitionEnd(e); - if (speedMult === void 0) { - speedMult = 1; + break; + // @formatter:on } + /* eslint-enable */ - this.mode = Dynamic.INFINITE; - this.target = invert ? -Infinity : Infinity; - this.speedMult = speedMult; } /** - * Stops movement + * @override + * @summary This method is not supported + * @throws {PSV.PSVError} always */ ; - _proto.stop = function stop() { - this.mode = Dynamic.STOP; + _proto.toggle = function toggle() { + throw new PSVError('Tooltip cannot be toggled'); } /** - * Defines the current position and immediately stops movement - * @param {number} values + * @summary Displays the tooltip on the viewer + * Do not call this method directly, use {@link PSV.services.TooltipRenderer} instead. + * @param {PSV.components.Tooltip.Config} config + * + * @fires PSV.show-tooltip + * @throws {PSV.PSVError} when the configuration is incorrect + * + * @package */ ; - _proto.setValue = function setValue(values) { - var next = bound(values, this.min, this.max); - this.target = next; - this.mode = Dynamic.STOP; - - if (next !== this.current) { - this.current = next; - - if (this.fn) { - this.fn(this.current); - } + _proto.show = function show(config) { + if (this.prop.state !== STATE.NONE) { + throw new PSVError('Initialized tooltip cannot be re-initialized'); + } - return true; + if (config.className) { + addClasses(this.container, config.className); } - return false; + this.content.innerHTML = config.content; + var rect = this.container.getBoundingClientRect(); + this.prop.width = rect.right - rect.left; + this.prop.height = rect.bottom - rect.top; + this.prop.state = STATE.READY; + this.move(config); + this.prop.data = config.data; + this.prop.state = STATE.SHOWING; + this.psv.trigger(EVENTS.SHOW_TOOLTIP, this.prop.data, this); } /** - * @package + * @summary Moves the tooltip to a new position + * @param {PSV.components.Tooltip.Position} config + * + * @throws {PSV.PSVError} when the configuration is incorrect */ ; - _proto.update = function update(elapsed) { - // in position mode switch to stop mode when in the decceleration window - if (this.mode === Dynamic.POSITION) { - var dstStop = this.currentSpeed * this.currentSpeed / (this.speed * this.speedMult * 4); - - if (Math.abs(this.target - this.current) <= dstStop) { - this.mode = Dynamic.STOP; - } - } // compute speed - - - var targetSpeed = this.mode === Dynamic.STOP ? 0 : this.speed * this.speedMult; - - if (this.target < this.current) { - targetSpeed = -targetSpeed; + _proto.move = function move(config) { + if (this.prop.state !== STATE.SHOWING && this.prop.state !== STATE.READY) { + throw new PSVError('Uninitialized tooltip cannot be moved'); } - if (this.currentSpeed < targetSpeed) { - this.currentSpeed = Math.min(targetSpeed, this.currentSpeed + elapsed / 1000 * this.speed * this.speedMult * 2); - } else if (this.currentSpeed > targetSpeed) { - this.currentSpeed = Math.max(targetSpeed, this.currentSpeed - elapsed / 1000 * this.speed * this.speedMult * 2); - } // compute new position - - - var next = null; - - if (this.current > this.target && this.currentSpeed) { - next = Math.max(this.target, this.current + this.currentSpeed * elapsed / 1000); - } else if (this.current < this.target && this.currentSpeed) { - next = Math.min(this.target, this.current + this.currentSpeed * elapsed / 1000); - } // apply value + var t = this.container; + var a = this.arrow; // compute size + var style = { + posClass: cleanPosition(config.position, 'top center', false), + width: this.prop.width, + height: this.prop.height, + top: 0, + left: 0, + arrowTop: 0, + arrowLeft: 0 + }; // set initial position - if (next !== null) { - next = bound(next, this.min, this.max); + this.__computeTooltipPosition(style, config); // correct position if overflow - if (next !== this.current) { - this.current = next; - if (this.fn) { - this.fn(this.current); - } + var refresh = false; - return true; - } + if (style.top < this.prop.offset) { + style.posClass[0] = 'bottom'; + refresh = true; + } else if (style.top + style.height > this.psv.prop.size.height - this.prop.offset) { + style.posClass[0] = 'top'; + refresh = true; } - return false; - }; - - return Dynamic; - }(); - Dynamic.STOP = 0; - Dynamic.INFINITE = 1; - Dynamic.POSITION = 2; + if (style.left < this.prop.offset) { + style.posClass[1] = 'right'; + refresh = true; + } else if (style.left + style.width > this.psv.prop.size.width - this.prop.offset) { + style.posClass[1] = 'left'; + refresh = true; + } - /** - * @summary Wrapper for multiple {@link PSV.Dynamic} evolving together - * @memberOf PSV - * @package - */ + if (refresh) { + this.__computeTooltipPosition(style, config); + } // apply position - var MultiDynamic = /*#__PURE__*/function () { - /** - * @param {Record} dynamics - * @param {Function} [fn] Callback function - */ - function MultiDynamic(dynamics, fn) { - /** - * @type {Function} - * @private - * @readonly - */ - this.fn = fn; - /** - * @type {Record} - * @private - * @readonly - */ - this.dynamics = dynamics; + t.style.top = style.top + 'px'; + t.style.left = style.left + 'px'; + a.style.top = style.arrowTop + 'px'; + a.style.left = style.arrowLeft + 'px'; + var newPos = style.posClass.join('-'); - if (this.fn) { - this.fn(this.current); + if (newPos !== this.prop.pos) { + t.classList.remove("psv-tooltip--" + this.prop.pos); + this.prop.pos = newPos; + t.classList.add("psv-tooltip--" + this.prop.pos); } } /** - * Changes base speed - * @param {number} speed + * @summary Hides the tooltip + * @fires PSV.hide-tooltip */ + ; - - var _proto = MultiDynamic.prototype; - - _proto.setSpeed = function setSpeed(speed) { - each(this.dynamics, function (d) { - d.setSpeed(speed); - }); + _proto.hide = function hide() { + this.container.classList.remove('psv-tooltip--visible'); + this.prop.state = STATE.HIDING; + this.psv.trigger(EVENTS.HIDE_TOOLTIP, this.prop.data); } /** - * Defines the target positions - * @param {Record} positions - * @param {number} [speedMult=1] + * @summary Finalize transition + * @param {TransitionEvent} e + * @private */ ; - _proto.goto = function goto(positions, speedMult) { - var _this = this; + _proto.__onTransitionEnd = function __onTransitionEnd(e) { + if (e.propertyName === 'transform') { + switch (this.prop.state) { + case STATE.SHOWING: + this.container.classList.add('psv-tooltip--visible'); + this.prop.state = STATE.READY; + break; - if (speedMult === void 0) { - speedMult = 1; - } + case STATE.HIDING: + this.prop.state = STATE.NONE; + this.destroy(); + break; - each(positions, function (position, name) { - _this.dynamics[name].goto(position, speedMult); - }); + } + } } /** - * Increase/decrease the target positions - * @param {Record} steps - * @param {number} [speedMult=1] + * @summary Computes the position of the tooltip and its arrow + * @param {Object} style + * @param {Object} config + * @private */ ; - _proto.step = function step(steps, speedMult) { - var _this2 = this; + _proto.__computeTooltipPosition = function __computeTooltipPosition(style, config) { + var topBottom = false; - if (speedMult === void 0) { - speedMult = 1; + if (!config.box) { + config.box = { + width: 0, + height: 0 + }; } - each(steps, function (step, name) { - _this2.dynamics[name].step(step, speedMult); - }); - } - /** - * Starts infinite movements - * @param {Record} rolls - * @param {number} [speedMult=1] - */ - ; + switch (style.posClass[0]) { + case 'bottom': + style.top = config.top + config.box.height + this.prop.offset + this.prop.arrow; + style.arrowTop = -this.prop.arrow * 2; + topBottom = true; + break; - _proto.roll = function roll(rolls, speedMult) { - var _this3 = this; + case 'center': + style.top = config.top + config.box.height / 2 - style.height / 2; + style.arrowTop = style.height / 2 - this.prop.arrow; + break; - if (speedMult === void 0) { - speedMult = 1; + case 'top': + style.top = config.top - style.height - this.prop.offset - this.prop.arrow; + style.arrowTop = style.height; + topBottom = true; + break; + // no default } - each(rolls, function (roll, name) { - _this3.dynamics[name].roll(roll, speedMult); - }); - } + switch (style.posClass[1]) { + case 'right': + if (topBottom) { + style.left = config.left + config.box.width / 2 - this.prop.offset - this.prop.arrow; + style.arrowLeft = this.prop.offset; + } else { + style.left = config.left + config.box.width + this.prop.offset + this.prop.arrow; + style.arrowLeft = -this.prop.arrow * 2; + } + + break; + + case 'center': + style.left = config.left + config.box.width / 2 - style.width / 2; + style.arrowLeft = style.width / 2 - this.prop.arrow; + break; + + case 'left': + if (topBottom) { + style.left = config.left - style.width + config.box.width / 2 + this.prop.offset + this.prop.arrow; + style.arrowLeft = style.width - this.prop.offset - this.prop.arrow * 2; + } else { + style.left = config.left - style.width - this.prop.offset - this.prop.arrow; + style.arrowLeft = style.width; + } + + break; + // no default + } + }; + + return Tooltip; + }(AbstractComponent); + + /** + * @summary Tooltip renderer + * @extends PSV.services.AbstractService + * @memberof PSV.services + */ + + var TooltipRenderer = /*#__PURE__*/function (_AbstractService) { + _inheritsLoose(TooltipRenderer, _AbstractService); + /** - * Stops movements + * @param {PSV.Viewer} psv */ - ; + function TooltipRenderer(psv) { + var _this; - _proto.stop = function stop() { - each(this.dynamics, function (d) { - return d.stop(); - }); + _this = _AbstractService.call(this, psv) || this; + var testTooltip = new Tooltip(_this.psv); + /** + * @summary Computed static sizes + * @member {Object} + * @package + * @property {number} arrowSize + * @property {number} offset + */ + + _this.size = { + arrow: parseInt(getStyle(testTooltip.arrow, 'borderTopWidth'), 10), + offset: parseInt(getStyle(testTooltip.container, 'outlineWidth'), 10) + }; + testTooltip.destroy(); + return _this; } /** - * Defines the current positions and immediately stops movements - * @param {Record} values + * @override */ - ; - _proto.setValue = function setValue(values) { - var _this4 = this; - var hasUpdates = false; - each(values, function (value, name) { - hasUpdates |= _this4.dynamics[name].setValue(value); - }); + var _proto = TooltipRenderer.prototype; - if (hasUpdates && this.fn) { - this.fn(this.current); - } + _proto.destroy = function destroy() { + delete this.size; - return hasUpdates; + _AbstractService.prototype.destroy.call(this); } /** - * @package + * @summary Displays a tooltip on the viewer + * @param {PSV.components.Tooltip.Config} config + * @returns {PSV.components.Tooltip} + * + * @fires PSV.show-tooltip + * @throws {PSV.PSVError} when the configuration is incorrect + * + * @example + * viewer.tooltip.create({ content: 'Hello world', top: 200, left: 450, position: 'center bottom'}) */ ; - _proto.update = function update(elapsed) { - var hasUpdates = false; - each(this.dynamics, function (dynamic) { - hasUpdates |= dynamic.update(elapsed); - }); - - if (hasUpdates && this.fn) { - this.fn(this.current); - } - - return hasUpdates; + _proto.create = function create(config) { + var tooltip = new Tooltip(this.psv, this.size); + tooltip.show(config); + return tooltip; }; - _createClass(MultiDynamic, [{ - key: "current", - get: - /** - * @type {Object} - * @readonly - */ - function get() { - var values = {}; - each(this.dynamics, function (dynamic, name) { - values[name] = dynamic.current; - }); - return values; - } - }]); - - return MultiDynamic; - }(); + return TooltipRenderer; + }(AbstractService); THREE.Cache.enabled = true; /** @@ -8410,7 +8707,7 @@ _this.overlay = new Overlay(_assertThisInitialized(_this)); /** - * @member {Record} + * @member {Record} * @package */ @@ -8422,12 +8719,12 @@ _this.trigger(EVENTS.ZOOM_UPDATED, value); }, _this.config.defaultZoomLvl, 0, 100), position: new MultiDynamic({ - longitude: new Dynamic(null, _this.config.defaultLong), + longitude: new Dynamic(null, _this.config.defaultLong, 0, 2 * Math.PI, true), latitude: new Dynamic(null, _this.config.defaultLat, -Math.PI / 2, Math.PI / 2) }, function (position) { _this.dataHelper.sphericalCoordsToVector3(position, _this.prop.direction); - _this.trigger(EVENTS.POSITION_UPDATED, _this.dataHelper.cleanPosition(position)); + _this.trigger(EVENTS.POSITION_UPDATED, position); }) }; @@ -8689,6 +8986,10 @@ options.caption = this.config.caption; } + if (options.description === undefined) { + options.description = this.config.description; + } + var positionProvided = isExtendedPosition(options); var zoomProvided = ('zoom' in options); @@ -8699,6 +9000,7 @@ this.hideError(); this.config.panorama = path; this.config.caption = options.caption; + this.config.description = options.description; var done = function done(err) { _this3.loader.hide(); @@ -8806,7 +9108,8 @@ switch (key) { case 'caption': - _this4.navbar.setCaption(value); + case 'description': + _this4.navbar.setCaption(_this4.config.caption); break; @@ -9228,6 +9531,7 @@ exports.AbstractAdapter = AbstractAdapter; exports.AbstractButton = AbstractButton; + exports.AbstractComponent = AbstractComponent; exports.AbstractPlugin = AbstractPlugin; exports.Animation = Animation; exports.CONSTANTS = constants; diff --git a/dist/photo-sphere-viewer.js.map b/dist/photo-sphere-viewer.js.map index 635afd73f..2993513e8 100644 --- a/dist/photo-sphere-viewer.js.map +++ b/dist/photo-sphere-viewer.js.map @@ -1 +1 @@ -{"version":3,"file":"photo-sphere-viewer.js","sources":["../src/data/constants.js","../src/utils/browser.js","../src/utils/math.js","../src/utils/misc.js","../src/PSVError.js","../src/utils/psv.js","../src/utils/index.js","../src/Animation.js","../src/components/AbstractComponent.js","../src/buttons/AbstractButton.js","../src/buttons/AutorotateButton.js","../src/buttons/CustomButton.js","../src/buttons/DownloadButton.js","../src/buttons/FullscreenButton.js","../src/buttons/MenuButton.js","../src/data/system.js","../src/utils/PressHandler.js","../src/buttons/AbstractMoveButton.js","../src/buttons/MoveDownButton.js","../src/buttons/MoveLeftButton.js","../src/buttons/MoveRightButton.js","../src/buttons/MoveUpButton.js","../src/buttons/AbstractZoomButton.js","../src/buttons/ZoomInButton.js","../src/buttons/ZoomOutButton.js","../src/buttons/ZoomRangeButton.js","../src/adapters/AbstractAdapter.js","../src/adapters/equirectangular/index.js","../src/plugins/AbstractPlugin.js","../src/data/config.js","../src/buttons/CaptionButton.js","../src/components/NavbarCaption.js","../src/components/Navbar.js","../src/components/Loader.js","../src/components/Notification.js","../src/components/Overlay.js","../src/components/Panel.js","../src/services/AbstractService.js","../src/services/DataHelper.js","../src/services/EventsHandler.js","../src/services/Renderer.js","../src/services/TextureLoader.js","../src/components/Tooltip.js","../src/services/TooltipRenderer.js","../src/utils/Dynamic.js","../src/utils/MultiDynamic.js","../src/Viewer.js"],"sourcesContent":["/**\n * @namespace PSV.constants\n */\n\n/**\n * @summary Default duration of the transition between panoramas\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const DEFAULT_TRANSITION = 1500;\n\n/**\n * @summary Number of pixels bellow which a mouse move will be considered as a click\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const MOVE_THRESHOLD = 4;\n\n/**\n * @summary Delay in milliseconds between two clicks to consider a double click\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const DBLCLICK_DELAY = 300;\n\n/**\n * @summary Delay in milliseconds to emulate a long touch\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const LONGTOUCH_DELAY = 500;\n\n/**\n * @summary Delay in milliseconds to for the two fingers overlay to appear\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const TWOFINGERSOVERLAY_DELAY = 100;\n\n/**\n * @summary Duration in milliseconds of the \"ctrl zoom\" overlay\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const CTRLZOOM_TIMEOUT = 2000;\n\n/**\n * @summary Time size of the mouse position history used to compute inertia\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const INERTIA_WINDOW = 300;\n\n/**\n * @summary Radius of the THREE.SphereGeometry, Half-length of the THREE.BoxGeometry\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const SPHERE_RADIUS = 10;\n\n/**\n * @summary Property name added to viewer element\n * @memberOf PSV.constants\n * @type {string}\n * @constant\n */\nexport const VIEWER_DATA = 'photoSphereViewer';\n\n/**\n * @summary Property added the the main Mesh object\n * @memberOf PSV.constants\n * @type {string}\n * @constant\n */\nexport const MESH_USER_DATA = 'psvSphere';\n\n/**\n * @summary Available actions\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const ACTIONS = {\n ROTATE_LAT_UP : 'rotateLatitudeUp',\n ROTATE_LAT_DOWN : 'rotateLatitudeDown',\n ROTATE_LONG_RIGHT: 'rotateLongitudeRight',\n ROTATE_LONG_LEFT : 'rotateLongitudeLeft',\n ZOOM_IN : 'zoomIn',\n ZOOM_OUT : 'zoomOut',\n TOGGLE_AUTOROTATE: 'toggleAutorotate',\n};\n\n/**\n * @summary Available events names\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event autorotate\n * @memberof PSV\n * @summary Triggered when the automatic rotation is enabled/disabled\n * @param {boolean} enabled\n */\n AUTOROTATE : 'autorotate',\n /**\n * @event before-render\n * @memberof PSV\n * @summary Triggered before a render, used to modify the view\n * @param {number} timestamp - time provided by requestAnimationFrame\n * @param {number} elapsed - time elapsed from the previous frame\n */\n BEFORE_RENDER : 'before-render',\n /**\n * @event before-rotate\n * @memberOf PSV\n * @summary Triggered before a rotate operation, can be cancelled\n * @param {PSV.ExtendedPosition}\n */\n BEFORE_ROTATE : 'before-rotate',\n /**\n * @event click\n * @memberof PSV\n * @summary Triggered when the user clicks on the viewer (everywhere excluding the navbar and the side panel)\n * @param {PSV.ClickData} data\n */\n CLICK : 'click',\n /**\n * @event close-panel\n * @memberof PSV\n * @summary Triggered when the panel is closed\n * @param {string} [id]\n */\n CLOSE_PANEL : 'close-panel',\n /**\n * @event config-changed\n * @memberOf PSV\n * @summary Triggered after a call to setOption/setOptions\n * @param {string[]} name of changed options\n */\n CONFIG_CHANGED : 'config-changed',\n /**\n * @event dblclick\n * @memberof PSV\n * @summary Triggered when the user double clicks on the viewer. The simple `click` event is always fired before `dblclick`\n * @param {PSV.ClickData} data\n */\n DOUBLE_CLICK : 'dblclick',\n /**\n * @event fullscreen-updated\n * @memberof PSV\n * @summary Triggered when the fullscreen mode is enabled/disabled\n * @param {boolean} enabled\n */\n FULLSCREEN_UPDATED: 'fullscreen-updated',\n /**\n * @event hide-notification\n * @memberof PSV\n * @summary Triggered when the notification is hidden\n */\n HIDE_NOTIFICATION : 'hide-notification',\n /**\n * @event hide-overlay\n * @memberof PSV\n * @summary Triggered when the overlay is hidden\n * @param {string} [id]\n */\n HIDE_OVERLAY : 'hide-overlay',\n /**\n * @event hide-tooltip\n * @memberof PSV\n * @summary Triggered when the tooltip is hidden\n * @param {*} Data associated to this tooltip\n */\n HIDE_TOOLTIP : 'hide-tooltip',\n /**\n * @event load-progress\n * @memberof PSV\n * @summary Triggered when the loader value changes\n * @param {number} value from 0 to 100\n */\n LOAD_PROGRESS : 'load-progress',\n /**\n * @event open-panel\n * @memberof PSV\n * @summary Triggered when the panel is opened\n * @param {string} [id]\n */\n OPEN_PANEL : 'open-panel',\n /**\n * @event panorama-loaded\n * @memberof PSV\n * @summary Triggered when a panorama image has been loaded\n */\n PANORAMA_LOADED : 'panorama-loaded',\n /**\n * @event position-updated\n * @memberof PSV\n * @summary Triggered when the view longitude and/or latitude changes\n * @param {PSV.Position} position\n */\n POSITION_UPDATED : 'position-updated',\n /**\n * @event ready\n * @memberof PSV\n * @summary Triggered when the panorama image has been loaded and the viewer is ready to perform the first render\n */\n READY : 'ready',\n /**\n * @event render\n * @memberof PSV\n * @summary Triggered on each viewer render, **this event is triggered very often**\n */\n RENDER : 'render',\n /**\n * @event show-notification\n * @memberof PSV\n * @summary Triggered when the notification is shown\n */\n SHOW_NOTIFICATION : 'show-notification',\n /**\n * @event show-overlay\n * @memberof PSV\n * @summary Triggered when the overlay is shown\n * @param {string} [id]\n */\n SHOW_OVERLAY : 'show-overlay',\n /**\n * @event show-tooltip\n * @memberof PSV\n * @summary Triggered when the tooltip is shown\n * @param {*} Data associated to this tooltip\n * @param {PSV.components.Tooltip} Instance of the tooltip\n */\n SHOW_TOOLTIP : 'show-tooltip',\n /**\n * @event size-updated\n * @memberof PSV\n * @summary Triggered when the viewer size changes\n * @param {PSV.Size} size\n */\n SIZE_UPDATED : 'size-updated',\n /**\n * @event stop-all\n * @memberof PSV\n * @summary Triggered when all current animations are stopped\n */\n STOP_ALL : 'stop-all',\n /**\n * @event zoom-updated\n * @memberof PSV\n * @summary Triggered when the zoom level changes\n * @param {number} zoomLevel\n */\n ZOOM_UPDATED : 'zoom-updated',\n};\n\n/**\n * @summary Available change events names\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const CHANGE_EVENTS = {\n /**\n * @event get-animate-position\n * @memberof PSV\n * @param {Position} position\n * @returns {Position}\n * @summary Called to alter the target position of an animation\n */\n GET_ANIMATE_POSITION: 'get-animate-position',\n /**\n * @event get-rotate-position\n * @memberof PSV\n * @param {Position} position\n * @returns {Position}\n * @summary Called to alter the target position of a rotation\n */\n GET_ROTATE_POSITION : 'get-rotate-position',\n};\n\n/**\n * @summary Special events emitted to listener using {@link Viewer#observeObjects}\n * @memberOf PSV.constants\n * @constant\n * @package\n */\nexport const OBJECT_EVENTS = {\n ENTER_OBJECT: 'enter-object',\n HOVER_OBJECT: 'hover-object',\n LEAVE_OBJECT: 'leave-object',\n};\n\n/**\n * @summary Internal identifiers for various stuff\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const IDS = {\n MENU : 'menu',\n TWO_FINGERS: 'twoFingers',\n CTRL_ZOOM : 'ctrlZoom',\n ERROR : 'error',\n};\n\n/* eslint-disable */\n// @formatter:off\n/**\n * @summary Collection of easing functions\n * @memberOf PSV.constants\n * @see {@link https://gist.github.com/frederickk/6165768}\n * @type {Object}\n * @constant\n */\nexport const EASINGS = {\n linear : (t) => t,\n\n inQuad : (t) => t*t,\n outQuad : (t) => t*(2-t),\n inOutQuad : (t) => t<.5 ? 2*t*t : -1+(4-2*t)*t,\n\n inCubic : (t) => t*t*t,\n outCubic : (t) => (--t)*t*t+1,\n inOutCubic: (t) => t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1,\n\n inQuart : (t) => t*t*t*t,\n outQuart : (t) => 1-(--t)*t*t*t,\n inOutQuart: (t) => t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t,\n\n inQuint : (t) => t*t*t*t*t,\n outQuint : (t) => 1+(--t)*t*t*t*t,\n inOutQuint: (t) => t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t,\n\n inSine : (t) => 1-Math.cos(t*(Math.PI/2)),\n outSine : (t) => Math.sin(t*(Math.PI/2)),\n inOutSine : (t) => .5-.5*Math.cos(Math.PI*t),\n\n inExpo : (t) => Math.pow(2, 10*(t-1)),\n outExpo : (t) => 1-Math.pow(2, -10*t),\n inOutExpo : (t) => (t=t*2-1)<0 ? .5*Math.pow(2, 10*t) : 1-.5*Math.pow(2, -10*t),\n\n inCirc : (t) => 1-Math.sqrt(1-t*t),\n outCirc : (t) => Math.sqrt(1-(t-1)*(t-1)),\n inOutCirc : (t) => (t*=2)<1 ? .5-.5*Math.sqrt(1-t*t) : .5+.5*Math.sqrt(1-(t-=2)*t)\n};\n// @formatter:on\n/* eslint-enable */\n\n/**\n * @summary Subset of key codes\n * @memberOf PSV.constants\n * @type {Object}\n * @constant\n */\nexport const KEY_CODES = {\n Enter : 'Enter',\n Control : 'Control',\n Escape : 'Escape',\n Space : ' ',\n PageUp : 'PageUp',\n PageDown : 'PageDown',\n ArrowLeft : 'ArrowLeft',\n ArrowUp : 'ArrowUp',\n ArrowRight: 'ArrowRight',\n ArrowDown : 'ArrowDown',\n Delete : 'Delete',\n Plus : '+',\n Minus : '-',\n};\n","/**\n * @summary Toggles a CSS class\n * @memberOf PSV.utils\n * @param {HTMLElement|SVGElement} element\n * @param {string} className\n * @param {boolean} [active] - forced state\n */\nexport function toggleClass(element, className, active) {\n // manual implementation for IE11 and SVGElement\n if (!element.classList) {\n let currentClassName = element.getAttribute('class') || '';\n const currentActive = currentClassName.indexOf(className) !== -1;\n const regex = new RegExp('(?:^|\\\\s)' + className + '(?:\\\\s|$)');\n\n if ((active === undefined || active) && !currentActive) {\n currentClassName += currentClassName.length > 0 ? ' ' + className : className;\n }\n else if (!active) {\n currentClassName = currentClassName.replace(regex, ' ');\n }\n\n element.setAttribute('class', currentClassName);\n }\n else if (active === undefined) {\n element.classList.toggle(className);\n }\n else if (active && !element.classList.contains(className)) {\n element.classList.add(className);\n }\n else if (!active) {\n element.classList.remove(className);\n }\n}\n\n/**\n * @summary Adds one or several CSS classes to an element\n * @memberOf PSV.utils\n * @param {HTMLElement} element\n * @param {string} className\n */\nexport function addClasses(element, className) {\n if (className) {\n className.split(' ').forEach((name) => {\n toggleClass(element, name, true);\n });\n }\n}\n\n/**\n * @summary Removes one or several CSS classes to an element\n * @memberOf PSV.utils\n * @param {HTMLElement} element\n * @param {string} className\n */\nexport function removeClasses(element, className) {\n if (className) {\n className.split(' ').forEach((name) => {\n toggleClass(element, name, false);\n });\n }\n}\n\n/**\n * @summary Searches if an element has a particular parent at any level including itself\n * @memberOf PSV.utils\n * @param {HTMLElement} el\n * @param {HTMLElement} parent\n * @returns {boolean}\n */\nexport function hasParent(el, parent) {\n let test = el;\n\n do {\n if (test === parent) {\n return true;\n }\n test = test.parentNode;\n } while (test);\n\n return false;\n}\n\n/**\n * @summary Gets the closest parent (can by itself)\n * @memberOf PSV.utils\n * @param {HTMLElement|SVGElement} el\n * @param {string} selector\n * @returns {HTMLElement}\n */\nexport function getClosest(el, selector) {\n const matches = el.matches || el.msMatchesSelector;\n let test = el;\n // When el is document or window, the matches does not exist\n if (!matches) {\n return null;\n }\n\n do {\n if (matches.bind(test)(selector)) {\n return test;\n }\n test = test instanceof SVGElement ? test.parentNode : test.parentElement;\n } while (test);\n\n return null;\n}\n\n/**\n * @summary Gets the position of an element in the viewer without reflow\n * @description Will gives the same result as getBoundingClientRect() as soon as there are no CSS transforms\n * @memberOf PSV.utils\n * @param {HTMLElement} el\n * @return {{left: number, top: number}}\n */\nexport function getPosition(el) {\n let left = 0;\n let top = 0;\n let test = el;\n\n while (test) {\n left += (test.offsetLeft - test.scrollLeft + test.clientLeft);\n top += (test.offsetTop - test.scrollTop + test.clientTop);\n test = test.offsetParent;\n }\n\n return { left, top };\n}\n\n/**\n * @summary Map between keyboard events `keyCode|which` and `key`\n * @memberOf PSV.utils\n * @type {Object}\n * @readonly\n * @private\n */\nconst KEYMAP = {\n 13 : 'Enter',\n 17 : 'Control',\n 27 : 'Escape',\n 32 : ' ',\n 33 : 'PageUp',\n 34 : 'PageDown',\n 37 : 'ArrowLeft',\n 38 : 'ArrowUp',\n 39 : 'ArrowRight',\n 40 : 'ArrowDown',\n 46 : 'Delete',\n 107: '+',\n 109: '-',\n};\n\n/**\n * @summary Map for non standard keyboard events `key` for IE and Edge\n * @see https://github.com/shvaikalesh/shim-keyboard-event-key\n * @type {Object}\n * @readonly\n * @private\n */\nconst MS_KEYMAP = {\n Add : '+',\n Del : 'Delete',\n Down : 'ArrowDown',\n Esc : 'Escape',\n Left : 'ArrowLeft',\n Right : 'ArrowRight',\n Spacebar: ' ',\n Subtract: '-',\n Up : 'ArrowUp',\n};\n\n/**\n * @summary Returns the key name of a KeyboardEvent\n * @memberOf PSV.utils\n * @param {KeyboardEvent} evt\n * @returns {string}\n */\nexport function getEventKey(evt) {\n let key = evt.key || KEYMAP[evt.keyCode || evt.which];\n\n if (key && MS_KEYMAP[key]) {\n key = MS_KEYMAP[key];\n }\n\n return key;\n}\n\n/**\n * @summary Detects if fullscreen is enabled\n * @memberOf PSV.utils\n * @param {HTMLElement} elt\n * @returns {boolean}\n */\nexport function isFullscreenEnabled(elt) {\n /* eslint-disable-next-line max-len */\n return (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) === elt;\n}\n\n/**\n * @summary Enters fullscreen mode\n * @memberOf PSV.utils\n * @param {HTMLElement} elt\n */\nexport function requestFullscreen(elt) {\n /* eslint-disable-next-line max-len */\n (elt.requestFullscreen || elt.mozRequestFullScreen || elt.webkitRequestFullscreen || elt.msRequestFullscreen).call(elt);\n}\n\n/**\n * @summary Exits fullscreen mode\n * @memberOf PSV.utils\n */\nexport function exitFullscreen() {\n /* eslint-disable-next-line max-len */\n (document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.msExitFullscreen).call(document);\n}\n\n/**\n * @summary Gets an element style\n * @memberOf PSV.utils\n * @param {HTMLElement} elt\n * @param {string} prop\n * @returns {*}\n */\nexport function getStyle(elt, prop) {\n return window.getComputedStyle(elt, null)[prop];\n}\n\n/**\n * @summary Normalize mousewheel values accross browsers\n * @memberOf PSV.utils\n * @description From Facebook's Fixed Data Table\n * {@link https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js}\n * @copyright Facebook\n * @param {WheelEvent} event\n * @returns {{spinX: number, spinY: number, pixelX: number, pixelY: number}}\n */\nexport function normalizeWheel(event) {\n const PIXEL_STEP = 10;\n const LINE_HEIGHT = 40;\n const PAGE_HEIGHT = 800;\n\n let spinX = 0;\n let spinY = 0;\n let pixelX = 0;\n let pixelY = 0;\n\n // Legacy\n if ('detail' in event) {\n spinY = event.detail;\n }\n if ('wheelDelta' in event) {\n spinY = -event.wheelDelta / 120;\n }\n if ('wheelDeltaY' in event) {\n spinY = -event.wheelDeltaY / 120;\n }\n if ('wheelDeltaX' in event) {\n spinX = -event.wheelDeltaX / 120;\n }\n\n // side scrolling on FF with DOMMouseScroll\n if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {\n spinX = spinY;\n spinY = 0;\n }\n\n pixelX = spinX * PIXEL_STEP;\n pixelY = spinY * PIXEL_STEP;\n\n if ('deltaY' in event) {\n pixelY = event.deltaY;\n }\n if ('deltaX' in event) {\n pixelX = event.deltaX;\n }\n\n if ((pixelX || pixelY) && event.deltaMode) {\n // delta in LINE units\n if (event.deltaMode === 1) {\n pixelX *= LINE_HEIGHT;\n pixelY *= LINE_HEIGHT;\n }\n // delta in PAGE units\n else {\n pixelX *= PAGE_HEIGHT;\n pixelY *= PAGE_HEIGHT;\n }\n }\n\n // Fall-back if spin cannot be determined\n if (pixelX && !spinX) {\n spinX = (pixelX < 1) ? -1 : 1;\n }\n if (pixelY && !spinY) {\n spinY = (pixelY < 1) ? -1 : 1;\n }\n\n return { spinX, spinY, pixelX, pixelY };\n}\n","/**\n * @summary Ensures that a number is in a given interval\n * @memberOf PSV.utils\n * @param {number} x\n * @param {number} min\n * @param {number} max\n * @returns {number}\n */\nexport function bound(x, min, max) {\n return Math.max(min, Math.min(max, x));\n}\n\n/**\n * @summary Checks if a value is an integer\n * @memberOf PSV.utils\n * @param {*} value\n * @returns {boolean}\n */\nexport function isInteger(value) {\n if (Number.isInteger) {\n return Number.isInteger(value);\n }\n return typeof value === 'number' && Number.isFinite(value) && Math.floor(value) === value;\n}\n\n/**\n * @summary Tests if a number is power of two\n * @memberOf PSV.utils\n * @param {number} x\n * @return {boolean}\n */\nexport function isPowerOfTwo(x) {\n return (Math.log(x) / Math.log(2)) % 1 === 0;\n}\n\n/**\n * @summary Computes the sum of an array\n * @memberOf PSV.utils\n * @param {number[]} array\n * @returns {number}\n */\nexport function sum(array) {\n return array.reduce((a, b) => a + b, 0);\n}\n\n/**\n * @summary Computes the distance between two points\n * @memberOf PSV.utils\n * @param {PSV.Point} p1\n * @param {PSV.Point} p2\n * @returns {number}\n */\nexport function distance(p1, p2) {\n return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));\n}\n\n/**\n * @summary Compute the shortest offset between two longitudes\n * @memberOf PSV.utils\n * @param {number} from\n * @param {number} to\n * @returns {number}\n */\nexport function getShortestArc(from, to) {\n const tCandidates = [\n 0, // direct\n Math.PI * 2, // clock-wise cross zero\n -Math.PI * 2, // counter-clock-wise cross zero\n ];\n\n return tCandidates.reduce((value, candidate) => {\n const newCandidate = to - from + candidate;\n return Math.abs(newCandidate) < Math.abs(value) ? newCandidate : value;\n }, Infinity);\n}\n\n/**\n * @summary Computes the angle between the current position and a target position\n * @memberOf PSV.utils\n * @param {PSV.Position} position1\n * @param {PSV.Position} position2\n * @returns {number}\n */\nexport function getAngle(position1, position2) {\n return Math.acos(\n Math.cos(position1.latitude)\n * Math.cos(position2.latitude)\n * Math.cos(position1.longitude - position2.longitude)\n + Math.sin(position1.latitude)\n * Math.sin(position2.latitude)\n );\n}\n\n/**\n * @summary Returns the distance between two points on a sphere of radius one\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @memberOf PSV.utils\n * @param {number[]} p1\n * @param {number[]} p2\n * @returns {number}\n */\nexport function greatArcDistance(p1, p2) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const x = (λ2 - λ1) * Math.cos((φ1 + φ2) / 2);\n const y = (φ2 - φ1);\n return Math.sqrt(x * x + y * y);\n}\n","/**\n * @summary Transforms a string to dash-case {@link https://github.com/shahata/dasherize}\n * @memberOf PSV.utils\n * @param {string} str\n * @returns {string}\n */\nexport function dasherize(str) {\n return str.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {\n return (i > 0 ? '-' : '') + s.toLowerCase();\n });\n}\n\n/**\n * @summary Returns a function, that, when invoked, will only be triggered at most once during a given window of time.\n * @memberOf PSV.utils\n * @copyright underscore.js - modified by Clément Prévost {@link http://stackoverflow.com/a/27078401}\n * @param {Function} func\n * @param {number} wait\n * @returns {Function}\n */\nexport function throttle(func, wait) {\n /* eslint-disable */\n let self, args, result;\n let timeout;\n let previous = 0;\n const later = function() {\n previous = Date.now();\n timeout = undefined;\n result = func.apply(self, args);\n if (!timeout) {\n self = args = null;\n }\n };\n return function() {\n const now = Date.now();\n if (!previous) {\n previous = now;\n }\n const remaining = wait - (now - previous);\n self = this;\n args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = undefined;\n }\n previous = now;\n result = func.apply(self, args);\n if (!timeout) {\n self = args = null;\n }\n }\n else if (!timeout) {\n timeout = setTimeout(later, remaining);\n }\n return result;\n };\n /* eslint-enable */\n}\n\n/**\n * @summary Test if an object is a plain object\n * @memberOf PSV.utils\n * @description Test if an object is a plain object, i.e. is constructed\n * by the built-in Object constructor and inherits directly from Object.prototype\n * or null. Some built-in objects pass the test, e.g. Math which is a plain object\n * and some host or exotic objects may pass also.\n * {@link http://stackoverflow.com/a/5878101/1207670}\n * @param {*} obj\n * @returns {boolean}\n */\nexport function isPlainObject(obj) {\n // Basic check for Type object that's not null\n if (typeof obj === 'object' && obj !== null) {\n // If Object.getPrototypeOf supported, use it\n if (typeof Object.getPrototypeOf === 'function') {\n const proto = Object.getPrototypeOf(obj);\n return proto === Object.prototype || proto === null;\n }\n\n // Otherwise, use internal class\n // This should be reliable as if getPrototypeOf not supported, is pre-ES5\n return Object.prototype.toString.call(obj) === '[object Object]';\n }\n\n // Not an object\n return false;\n}\n\n/**\n * @summary Merges the enumerable attributes of two objects\n * @memberOf PSV.utils\n * @description Replaces arrays and alters the target object.\n * @copyright Nicholas Fisher \n * @param {Object} target\n * @param {Object} src\n * @returns {Object} target\n */\nexport function deepmerge(target, src) {\n /* eslint-disable */\n let first = src;\n\n return (function merge(target, src) {\n if (Array.isArray(src)) {\n if (!target || !Array.isArray(target)) {\n target = [];\n }\n else {\n target.length = 0;\n }\n src.forEach(function(e, i) {\n target[i] = merge(null, e);\n });\n }\n else if (typeof src === 'object') {\n if (!target || Array.isArray(target)) {\n target = {};\n }\n Object.keys(src).forEach(function(key) {\n if (typeof src[key] !== 'object' || !src[key] || !isPlainObject(src[key])) {\n target[key] = src[key];\n }\n else if (src[key] != first) {\n if (!target[key]) {\n target[key] = merge(null, src[key]);\n }\n else {\n merge(target[key], src[key]);\n }\n }\n });\n }\n else {\n target = src;\n }\n\n return target;\n }(target, src));\n /* eslint-enable */\n}\n\n/**\n * @summary Deeply clones an object\n * @memberOf PSV.utils\n * @param {Object} src\n * @returns {Object}\n */\nexport function clone(src) {\n return deepmerge(null, src);\n}\n\n/**\n * @summery Test of an object is empty\n * @memberOf PSV.utils\n * @param {object} obj\n * @returns {boolean}\n */\nexport function isEmpty(obj) {\n return !obj || (Object.keys(obj).length === 0 && obj.constructor === Object);\n}\n\n/**\n * @summary Loops over enumerable properties of an object\n * @memberOf PSV.utils\n * @param {Object} object\n * @param {Function} callback\n */\nexport function each(object, callback) {\n Object.keys(object).forEach((key) => {\n callback(object[key], key);\n });\n}\n\n/**\n * @summary Returns if a valu is null or undefined\n * @memberOf PSV.utils\n * @param {*} val\n * @return {boolean}\n */\nexport function isNil(val) {\n return val === null || val === undefined;\n}\n\n/**\n * @summary Returns the first non null non undefined parameter\n * @memberOf PSV.utils\n * @param {*} values\n * @return {*}\n */\nexport function firstNonNull(...values) {\n for (const val of values) {\n if (!isNil(val)) {\n return val;\n }\n }\n\n return undefined;\n}\n","/**\n * @summary Custom error used in the lib\n * @param {string} message\n * @constructor\n * @memberOf PSV\n */\nfunction PSVError(message) {\n this.message = message;\n\n // Use V8's native method if available, otherwise fallback\n if ('captureStackTrace' in Error) {\n Error.captureStackTrace(this, PSVError);\n }\n else {\n this.stack = (new Error()).stack;\n }\n}\n\nPSVError.prototype = Object.create(Error.prototype);\nPSVError.prototype.name = 'PSVError';\nPSVError.prototype.constructor = PSVError;\n\nexport { PSVError };\n","import * as THREE from 'three';\nimport { PSVError } from '../PSVError';\nimport { bound } from './math';\n\n/**\n * @summary Returns the plugin constructor from the imported object\n * For retrocompatibility with previous default exports\n * @memberOf PSV.utils\n * @package\n */\nexport function pluginInterop(plugin, target) {\n if (plugin) {\n for (const [, p] of [['_', plugin], ...Object.entries(plugin)]) {\n if (p.prototype instanceof target) {\n return p;\n }\n }\n }\n return null;\n}\n\n/**\n * @summary Builds an Error with name 'AbortError'\n * @memberOf PSV.utils\n * @return {Error}\n */\nexport function getAbortError() {\n const error = new Error('Loading was aborted.');\n error.name = 'AbortError';\n return error;\n}\n\n/**\n * @summary Tests if an Error has name 'AbortError'\n * @memberOf PSV.utils\n * @param {Error} err\n * @return {boolean}\n */\nexport function isAbortError(err) {\n return err?.name === 'AbortError';\n}\n\n/**\n * @summary Displays a warning in the console\n * @memberOf PSV.utils\n * @param {string} message\n */\nexport function logWarn(message) {\n console.warn(`PhotoSphereViewer: ${message}`);\n}\n\n/**\n * @summary Checks if an object is a {PSV.ExtendedPosition}, ie has x/y or longitude/latitude\n * @memberOf PSV.utils\n * @param {object} object\n * @returns {boolean}\n */\nexport function isExtendedPosition(object) {\n return [['x', 'y'], ['longitude', 'latitude']].some(([key1, key2]) => {\n return object[key1] !== undefined && object[key2] !== undefined;\n });\n}\n\n/**\n * @summary Returns the value of a given attribute in the panorama metadata\n * @memberOf PSV.utils\n * @param {string} data\n * @param {string} attr\n * @returns (number)\n */\nexport function getXMPValue(data, attr) {\n // XMP data are stored in children\n let result = data.match('(.*)');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n // XMP data are stored in attributes\n result = data.match('GPano:' + attr + '=\"(.*?)\"');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n return null;\n}\n\n/**\n * @readonly\n * @private\n * @type {{top: string, left: string, bottom: string, center: string, right: string}}\n */\nconst CSS_POSITIONS = {\n top : '0%',\n bottom: '100%',\n left : '0%',\n right : '100%',\n center: '50%',\n};\n\n/**\n * @summary Translate CSS values like \"top center\" or \"10% 50%\" as top and left positions\n * @memberOf PSV.utils\n * @description The implementation is as close as possible to the \"background-position\" specification\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/background-position}\n * @param {string|PSV.Point} value\n * @returns {PSV.Point}\n */\nexport function parsePosition(value) {\n if (!value) {\n return { x: 0.5, y: 0.5 };\n }\n\n if (typeof value === 'object') {\n return value;\n }\n\n let tokens = value.toLocaleLowerCase().split(' ').slice(0, 2);\n\n if (tokens.length === 1) {\n if (CSS_POSITIONS[tokens[0]] !== undefined) {\n tokens = [tokens[0], 'center'];\n }\n else {\n tokens = [tokens[0], tokens[0]];\n }\n }\n\n const xFirst = tokens[1] !== 'left' && tokens[1] !== 'right' && tokens[0] !== 'top' && tokens[0] !== 'bottom';\n\n tokens = tokens.map(token => CSS_POSITIONS[token] || token);\n\n if (!xFirst) {\n tokens.reverse();\n }\n\n const parsed = tokens.join(' ').match(/^([0-9.]+)% ([0-9.]+)%$/);\n\n if (parsed) {\n return {\n x: parseFloat(parsed[1]) / 100,\n y: parseFloat(parsed[2]) / 100,\n };\n }\n else {\n return { x: 0.5, y: 0.5 };\n }\n}\n\n/**\n * @readonly\n * @private\n */\nconst LEFT_MAP = { 0: 'left', 0.5: 'center', 1: 'right' };\n/**\n * @readonly\n * @private\n */\nconst TOP_MAP = { 0: 'top', 0.5: 'center', 1: 'bottom' };\n\n/**\n * @summary Parse a CSS-like position into an array of position keywords among top, bottom, left, right and center\n * @memberOf PSV.utils\n * @param {string | string[]} value\n * @param {string} defaultValue\n * @param {boolean} [allowCenter=true]\n * @return {string[]}\n */\nexport function cleanPosition(value, defaultValue, allowCenter = true) {\n if (!value) {\n return defaultValue.split(' ');\n }\n\n if (typeof value === 'string') {\n const tempPos = parsePosition(value);\n\n if (!(tempPos.x in LEFT_MAP) || !(tempPos.y in TOP_MAP)) {\n throw new PSVError(`Unable to parse position \"${value}\"`);\n }\n\n value = [TOP_MAP[tempPos.y], LEFT_MAP[tempPos.x]];\n }\n\n if (!allowCenter && value[0] === 'center' && value[1] === 'center') {\n throw new PSVError('Unable to parse position \"center center\"');\n }\n\n return value;\n}\n\n/**\n * @summary Parses an speed\n * @memberOf PSV.utils\n * @param {string|number} speed - The speed, in radians/degrees/revolutions per second/minute\n * @returns {number} radians per second\n * @throws {PSV.PSVError} when the speed cannot be parsed\n */\nexport function parseSpeed(speed) {\n let parsed;\n\n if (typeof speed === 'string') {\n const speedStr = speed.toString().trim();\n\n // Speed extraction\n let speedValue = parseFloat(speedStr.replace(/^(-?[0-9]+(?:\\.[0-9]*)?).*$/, '$1'));\n const speedUnit = speedStr.replace(/^-?[0-9]+(?:\\.[0-9]*)?(.*)$/, '$1').trim();\n\n // \"per minute\" -> \"per second\"\n if (speedUnit.match(/(pm|per minute)$/)) {\n speedValue /= 60;\n }\n\n // Which unit?\n switch (speedUnit) {\n // Degrees per minute / second\n case 'dpm':\n case 'degrees per minute':\n case 'dps':\n case 'degrees per second':\n parsed = THREE.Math.degToRad(speedValue);\n break;\n\n // Radians per minute / second\n case 'rdpm':\n case 'radians per minute':\n case 'rdps':\n case 'radians per second':\n parsed = speedValue;\n break;\n\n // Revolutions per minute / second\n case 'rpm':\n case 'revolutions per minute':\n case 'rps':\n case 'revolutions per second':\n parsed = speedValue * Math.PI * 2;\n break;\n\n // Unknown unit\n default:\n throw new PSVError('Unknown speed unit \"' + speedUnit + '\"');\n }\n }\n else {\n parsed = speed;\n }\n\n return parsed;\n}\n\n/**\n * @summary Parses an angle value in radians or degrees and returns a normalized value in radians\n * @memberOf PSV.utils\n * @param {string|number} angle - eg: 3.14, 3.14rad, 180deg\n * @param {boolean} [zeroCenter=false] - normalize between -Pi - Pi instead of 0 - 2*Pi\n * @param {boolean} [halfCircle=zeroCenter] - normalize between -Pi/2 - Pi/2 instead of -Pi - Pi\n * @returns {number}\n * @throws {PSV.PSVError} when the angle cannot be parsed\n */\nexport function parseAngle(angle, zeroCenter = false, halfCircle = zeroCenter) {\n let parsed;\n\n if (typeof angle === 'string') {\n const match = angle.toLowerCase().trim().match(/^(-?[0-9]+(?:\\.[0-9]*)?)(.*)$/);\n\n if (!match) {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n const value = parseFloat(match[1]);\n const unit = match[2];\n\n if (unit) {\n switch (unit) {\n case 'deg':\n case 'degs':\n parsed = THREE.Math.degToRad(value);\n break;\n case 'rad':\n case 'rads':\n parsed = value;\n break;\n default:\n throw new PSVError('Unknown angle unit \"' + unit + '\"');\n }\n }\n else {\n parsed = value;\n }\n }\n else if (typeof angle === 'number' && !isNaN(angle)) {\n parsed = angle;\n }\n else {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n parsed = (zeroCenter ? parsed + Math.PI : parsed) % (Math.PI * 2);\n\n if (parsed < 0) {\n parsed += Math.PI * 2;\n }\n\n return zeroCenter ? bound(parsed - Math.PI, -Math.PI / (halfCircle ? 2 : 1), Math.PI / (halfCircle ? 2 : 1)) : parsed;\n}\n\n/**\n * @summary Creates a THREE texture from an image\n * @memberOf PSV.utils\n * @param {HTMLImageElement | HTMLCanvasElement} img\n * @return {external:THREE.Texture}\n */\nexport function createTexture(img) {\n const texture = new THREE.Texture(img);\n texture.needsUpdate = true;\n texture.minFilter = THREE.LinearFilter;\n texture.generateMipmaps = false;\n return texture;\n}\n\nconst quaternion = new THREE.Quaternion();\n\n/**\n * @summary Applies the inverse of Euler angles to a vector\n * @memberOf PSV.utils\n * @param {external:THREE.Vector3} vector\n * @param {external:THREE.Euler} euler\n */\nexport function applyEulerInverse(vector, euler) {\n quaternion.setFromEuler(euler).invert();\n vector.applyQuaternion(quaternion);\n}\n","/**\n * @namespace PSV.utils\n */\n\nexport * from './browser';\nexport * from './math';\nexport * from './misc';\nexport * from './psv';\n","import { EASINGS } from './data/constants';\nimport { each, logWarn } from './utils';\n\n/**\n * @callback OnTick\n * @summary Function called for each animation frame with computed properties\n * @memberOf PSV.Animation\n * @param {Object.} properties - current values\n * @param {float} progress - 0 to 1\n */\n\n/**\n * @summary Interpolation helper for animations\n * @memberOf PSV\n * @description\n * Implements the Promise API with an additional \"cancel\" method.\n * The promise is resolved with `true` when the animation is completed and `false` if the animation is cancelled.\n * @example\n * const anim = new Animation({\n * properties: {\n * width: {start: 100, end: 200}\n * },\n * duration: 5000,\n * onTick: (properties) => element.style.width = `${properties.width}px`;\n * });\n *\n * anim.then((completed) => ...);\n *\n * anim.cancel()\n */\nexport class Animation {\n\n /**\n * @param {Object} options\n * @param {Object.} options.properties\n * @param {number} options.properties[].start\n * @param {number} options.properties[].end\n * @param {number} options.duration\n * @param {number} [options.delay=0]\n * @param {string} [options.easing='linear']\n * @param {PSV.Animation.OnTick} options.onTick - called on each frame\n */\n constructor(options) {\n this.__callbacks = [];\n\n if (options) {\n if (!options.easing || typeof options.easing === 'string') {\n options.easing = EASINGS[options.easing || 'linear'];\n }\n\n this.__start = null;\n this.options = options;\n\n if (options.delay) {\n this.__delayTimeout = setTimeout(() => {\n this.__delayTimeout = null;\n this.__animationFrame = window.requestAnimationFrame(t => this.__run(t));\n }, options.delay);\n }\n else {\n this.__animationFrame = window.requestAnimationFrame(t => this.__run(t));\n }\n }\n else {\n this.__resolved = true;\n }\n }\n\n /**\n * @summary Main loop for the animation\n * @param {number} timestamp\n * @private\n */\n __run(timestamp) {\n // first iteration\n if (this.__start === null) {\n this.__start = timestamp;\n }\n\n // compute progress\n const progress = (timestamp - this.__start) / this.options.duration;\n const current = {};\n\n if (progress < 1.0) {\n // interpolate properties\n each(this.options.properties, (prop, name) => {\n if (prop) {\n current[name] = prop.start + (prop.end - prop.start) * this.options.easing(progress);\n }\n });\n this.options.onTick(current, progress);\n\n this.__animationFrame = window.requestAnimationFrame(t => this.__run(t));\n }\n else {\n // call onTick one last time with final values\n each(this.options.properties, (prop, name) => {\n if (prop) {\n current[name] = prop.end;\n }\n });\n this.options.onTick(current, 1.0);\n\n this.__animationFrame = window.requestAnimationFrame(() => {\n this.__resolved = true;\n this.__resolve(true);\n });\n }\n }\n\n /**\n * @private\n */\n __resolve(value) {\n this.__callbacks.forEach(cb => cb(value));\n this.__callbacks.length = 0;\n }\n\n /**\n * @summary Promise chaining\n * @param {Function} [onFulfilled] - Called when the animation is complete (true) or cancelled (false)\n * @param {Function} [onRejected] - deprecated\n * @returns {PSV.Promise}\n */\n then(onFulfilled = null, onRejected = null) {\n if (onRejected) {\n logWarn('Animation#then does not accept a rejection handler anymore');\n }\n\n if (this.__resolved || this.__cancelled) {\n return Promise.resolve(this.__resolved)\n .then(onFulfilled);\n }\n\n return new Promise((resolve) => {\n this.__callbacks.push(resolve);\n })\n .then(onFulfilled);\n }\n\n /**\n * @summary Cancels the animation\n */\n cancel() {\n if (!this.__cancelled && !this.__resolved) {\n this.__cancelled = true;\n this.__resolve(false);\n\n if (this.__delayTimeout) {\n window.clearTimeout(this.__delayTimeout);\n this.__delayTimeout = null;\n }\n if (this.__animationFrame) {\n window.cancelAnimationFrame(this.__animationFrame);\n this.__animationFrame = null;\n }\n }\n }\n\n /**\n * @deprecated not supported anymore\n */\n catch() {\n logWarn('Animation#catch is not supported anymore');\n return this.then();\n }\n\n /**\n * @deprecated not supported anymore\n */\n finally(onFinally) {\n logWarn('Animation#finally is not supported anymore');\n return this.then(onFinally);\n }\n\n /**\n * @deprecated not supported anymore\n */\n static resolve() {\n logWarn('Animation.resolve is not supported anymore');\n }\n\n}\n","/**\n * @namespace PSV.components\n */\n\n/**\n * @summary Base component class\n * @memberof PSV.components\n * @abstract\n */\nexport class AbstractComponent {\n\n /**\n * @param {PSV.Viewer | PSV.components.AbstractComponent} parent\n * @param {string} className - CSS class added to the component's container\n */\n constructor(parent, className) {\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = parent.psv || parent;\n\n /**\n * @member {PSV.Viewer|PSV.components.AbstractComponent}\n * @readonly\n */\n this.parent = parent;\n this.parent.children.push(this);\n\n /**\n * @summary All child components\n * @type {PSV.components.AbstractComponent[]}\n * @readonly\n * @package\n */\n this.children = [];\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @protected\n * @property {boolean} visible - Visibility of the component\n */\n this.prop = {\n visible: true,\n };\n\n /**\n * @member {HTMLElement}\n * @readonly\n */\n this.container = document.createElement('div');\n this.container.className = className;\n this.parent.container.appendChild(this.container);\n }\n\n /**\n * @summary Destroys the component\n * @protected\n */\n destroy() {\n this.parent.container.removeChild(this.container);\n\n const childIdx = this.parent.children.indexOf(this);\n if (childIdx !== -1) {\n this.parent.children.splice(childIdx, 1);\n }\n\n this.children.slice().forEach(child => child.destroy());\n this.children.length = 0;\n\n delete this.container;\n delete this.parent;\n delete this.psv;\n delete this.prop;\n }\n\n /**\n * @summary Refresh UI\n * @description Must be be a very lightweight operation\n * @package\n */\n refreshUi() {\n this.children.every((child) => {\n child.refreshUi();\n return this.psv.prop.uiRefresh === true;\n });\n }\n\n /**\n * @summary Displays or hides the component\n */\n toggle() {\n if (this.isVisible()) {\n this.hide();\n }\n else {\n this.show();\n }\n }\n\n /**\n * @summary Hides the component\n */\n hide() {\n this.container.style.display = 'none';\n this.prop.visible = false;\n }\n\n /**\n * @summary Displays the component\n */\n show() {\n this.container.style.display = '';\n this.prop.visible = true;\n }\n\n /**\n * @summary Checks if the component is visible\n * @returns {boolean}\n */\n isVisible() {\n return this.prop.visible;\n }\n\n}\n","import { AbstractComponent } from '../components/AbstractComponent';\nimport { KEY_CODES } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { getEventKey, isPlainObject, toggleClass } from '../utils';\n\n/**\n * @namespace PSV.buttons\n */\n\n/**\n * @summary Base navbar button class\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.buttons\n * @abstract\n */\nexport class AbstractButton extends AbstractComponent {\n\n /**\n * @summary Unique identifier of the button\n * @member {string}\n * @readonly\n * @static\n */\n static id = null;\n\n /**\n * @summary SVG icon name injected in the button\n * @member {string}\n * @readonly\n * @static\n */\n static icon = null;\n\n /**\n * @summary SVG icon name injected in the button when it is active\n * @member {string}\n * @readonly\n * @static\n */\n static iconActive = null;\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {string} [className] - Additional CSS classes\n * @param {boolean} [collapsable=false] - `true` if the button can be moved to menu when the navbar is too small\n * @param {boolean} [tabbable=true] - `true` if the button is accessible with the keyboard\n */\n constructor(navbar, className = '', collapsable = false, tabbable = true) {\n super(navbar, 'psv-button ' + className);\n\n /**\n * @override\n * @property {string} id - Unique identifier of the button\n * @property {boolean} enabled\n * @property {boolean} supported\n * @property {boolean} collapsed\n * @property {boolean} active\n * @property {number} width\n */\n this.prop = {\n ...this.prop,\n id : this.constructor.id,\n collapsable: collapsable,\n enabled : true,\n supported : true,\n collapsed : false,\n active : false,\n width : this.container.offsetWidth,\n };\n\n if (this.constructor.icon) {\n this.__setIcon(this.constructor.icon);\n }\n\n if (this.prop.id && this.psv.config.lang[this.prop.id]) {\n this.container.title = this.psv.config.lang[this.prop.id];\n }\n\n if (tabbable) {\n this.container.tabIndex = 0;\n }\n\n this.container.addEventListener('click', (e) => {\n if (this.prop.enabled) {\n this.onClick();\n }\n e.stopPropagation();\n });\n\n this.container.addEventListener('keydown', (e) => {\n if (getEventKey(e) === KEY_CODES.Enter && this.prop.enabled) {\n this.onClick();\n e.stopPropagation();\n }\n });\n }\n\n /**\n * @package\n */\n checkSupported() {\n const supportedOrObject = this.isSupported();\n if (isPlainObject(supportedOrObject)) {\n if (supportedOrObject.initial === false) {\n this.hide();\n this.prop.supported = false;\n }\n\n supportedOrObject.promise.then((supported) => {\n if (!this.prop) {\n return; // the component has been destroyed\n }\n this.prop.supported = supported;\n if (!supported && this.prop.visible) {\n this.hide();\n }\n else if (supported && !this.prop.visible) {\n this.show();\n }\n });\n }\n else if (!supportedOrObject) {\n this.hide();\n this.prop.supported = false;\n }\n }\n\n /**\n * @summary Checks if the button can be displayed\n * @returns {boolean|{initial: boolean, promise: Promise}}\n */\n isSupported() {\n return true;\n }\n\n /**\n * @summary Changes the active state of the button\n * @param {boolean} [active] - forced state\n */\n toggleActive(active) {\n this.prop.active = active !== undefined ? active : !this.prop.active;\n toggleClass(this.container, 'psv-button--active', this.prop.active);\n\n if (this.constructor.iconActive) {\n this.__setIcon(this.prop.active ? this.constructor.iconActive : this.constructor.icon);\n }\n }\n\n /**\n * @override\n */\n show(refresh = true) {\n if (!this.isVisible()) {\n this.prop.visible = true;\n if (!this.prop.collapsed) {\n this.container.style.display = '';\n }\n if (refresh) {\n this.psv.refreshUi(`show button ${this.prop.id}`);\n }\n }\n }\n\n /**\n * @override\n */\n hide(refresh = true) {\n if (this.isVisible()) {\n this.prop.visible = false;\n this.container.style.display = 'none';\n if (refresh) {\n this.psv.refreshUi(`hide button ${this.prop.id}`);\n }\n }\n }\n\n /**\n * @summary Disables the button\n */\n disable() {\n this.container.classList.add('psv-button--disabled');\n this.prop.enabled = false;\n }\n\n /**\n * @summary Enables the button\n */\n enable() {\n this.container.classList.remove('psv-button--disabled');\n this.prop.enabled = true;\n }\n\n /**\n * @summary Collapses the button in the navbar menu\n */\n collapse() {\n this.prop.collapsed = true;\n this.container.style.display = 'none';\n }\n\n /**\n * @summary Uncollapses the button from the navbar menu\n */\n uncollapse() {\n this.prop.collapsed = false;\n if (this.prop.visible) {\n this.container.style.display = '';\n }\n }\n\n /**\n * @summary Set the button icon\n * @param {string} icon SVG\n * @param {HTMLElement} [container] - default is the main button container\n * @private\n */\n __setIcon(icon, container = this.container) {\n if (icon) {\n container.innerHTML = icon;\n // classList not supported on IE11, className is read-only !!!!\n container.querySelector('svg').setAttribute('class', 'psv-button-svg');\n }\n else {\n container.innerHTML = '';\n }\n }\n\n /**\n * @summary Action when the button is clicked\n * @private\n * @abstract\n */\n onClick() {\n throw new PSVError(`onClick not implemented for button \"${this.prop.id}\".`);\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport playActive from '../icons/play-active.svg';\nimport play from '../icons/play.svg';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar autorotate button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class AutorotateButton extends AbstractButton {\n\n static id = 'autorotate';\n static icon = play;\n static iconActive = playActive;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-autorotate-button', true);\n\n this.psv.on(EVENTS.AUTOROTATE, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.AUTOROTATE, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.AUTOROTATE: this.toggleActive(e.args[0]); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles autorotate\n */\n onClick() {\n this.psv.toggleAutorotate();\n }\n\n}\n","import { addClasses } from '../utils';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar custom button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class CustomButton extends AbstractButton {\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {PSV.NavbarCustomButton} config\n */\n constructor(navbar, config) {\n super(navbar, 'psv-custom-button', config.collapsable !== false, config.tabbable !== false);\n\n /**\n * @member {Object}\n * @readonly\n * @private\n */\n this.config = config;\n\n if (this.config.id) {\n this.prop.id = this.config.id;\n }\n else {\n this.prop.id = 'psvButton-' + Math.random().toString(36).substr(2, 9);\n }\n\n if (this.config.className) {\n addClasses(this.container, this.config.className);\n }\n\n if (this.config.title) {\n this.container.title = this.config.title;\n }\n\n if (this.config.content) {\n this.container.innerHTML = this.config.content;\n }\n\n this.prop.width = this.container.offsetWidth;\n\n if (this.config.enabled === false) {\n this.disable();\n }\n\n if (this.config.visible === false) {\n this.hide();\n }\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.config;\n\n super.destroy();\n }\n\n /**\n * @override\n * @description Calls user method\n */\n onClick() {\n if (this.config.onClick) {\n this.config.onClick.apply(this.psv);\n }\n }\n\n}\n","import { AbstractButton } from './AbstractButton';\nimport download from '../icons/download.svg';\n\n/**\n * @summary Navigation bar download button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class DownloadButton extends AbstractButton {\n\n static id = 'download';\n static icon = download;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-download-button', true);\n }\n\n /**\n * @override\n */\n isSupported() {\n return this.psv.adapter.constructor.supportsDownload || !!this.psv.config.downloadUrl;\n }\n\n /**\n * @override\n * @description Asks the browser to download the panorama source file\n */\n onClick() {\n const link = document.createElement('a');\n link.href = this.psv.config.downloadUrl || this.psv.config.panorama;\n link.download = link.href.split('/').pop();\n this.psv.container.appendChild(link);\n link.click();\n\n setTimeout(() => {\n this.psv.container.removeChild(link);\n }, 100);\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport fullscreenIn from '../icons/fullscreen-in.svg';\nimport fullscreenOut from '../icons/fullscreen-out.svg';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar fullscreen button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class FullscreenButton extends AbstractButton {\n\n static id = 'fullscreen';\n static icon = fullscreenIn;\n static iconActive = fullscreenOut;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-fullscreen-button');\n\n this.psv.on(EVENTS.FULLSCREEN_UPDATED, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.FULLSCREEN_UPDATED, this);\n\n super.destroy();\n }\n\n /**\n * Handle events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.FULLSCREEN_UPDATED: this.toggleActive(e.args[0]); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles fullscreen\n */\n onClick() {\n this.psv.toggleFullscreen();\n }\n\n}\n","import { EVENTS, IDS } from '../data/constants';\nimport menuIcon from '../icons/menu.svg';\nimport { dasherize, getClosest } from '../utils';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar menu button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class MenuButton extends AbstractButton {\n\n static id = 'menu';\n static icon = menuIcon;\n\n /**\n * @summary Property name added to buttons list\n * @type {string}\n * @constant\n */\n static BUTTON_DATA = 'psvButton';\n\n /**\n * @summary Menu template\n * @param {AbstractButton[]} buttons\n * @param {PSV.Viewer} psv\n * @param {string} dataKey\n * @returns {string}\n */\n static MENU_TEMPLATE = (buttons, psv, dataKey) => `\n
\n

${menuIcon} ${psv.config.lang.menu}

\n
    \n ${buttons.map(button => `\n
  • \n ${button.container.innerHTML}\n ${button.container.title}\n
  • \n `).join('')}\n
\n
\n`;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-menu-button');\n\n this.psv.on(EVENTS.OPEN_PANEL, this);\n this.psv.on(EVENTS.CLOSE_PANEL, this);\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.OPEN_PANEL, this);\n this.psv.off(EVENTS.CLOSE_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === IDS.MENU); break;\n case EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n hide(refresh) {\n super.hide(refresh);\n this.__hideMenu();\n }\n\n /**\n * @override\n */\n show(refresh) {\n super.show(refresh);\n\n if (this.prop.active) {\n this.__showMenu();\n }\n }\n\n /**\n * @override\n * @description Toggles menu\n */\n onClick() {\n if (this.prop.active) {\n this.__hideMenu();\n }\n else {\n this.__showMenu();\n }\n }\n\n __showMenu() {\n this.psv.panel.show({\n id : IDS.MENU,\n content : MenuButton.MENU_TEMPLATE(this.parent.collapsed, this.psv, dasherize(MenuButton.BUTTON_DATA)),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? getClosest(e.target, 'li') : undefined;\n const buttonId = li ? li.dataset[MenuButton.BUTTON_DATA] : undefined;\n\n if (buttonId) {\n this.parent.getButton(buttonId).onClick();\n this.__hideMenu();\n }\n },\n });\n }\n\n __hideMenu() {\n if (this.psv.panel) {\n this.psv.panel.hide(IDS.MENU);\n }\n }\n\n}\n","import { PSVError } from '../PSVError';\n\n/**\n * @summary General information about the system\n * @constant\n * @memberOf PSV\n * @property {boolean} loaded - Indicates if the system data has been loaded\n * @property {Function} load - Loads the system if not already loaded\n * @property {number} pixelRatio\n * @property {boolean} isWebGLSupported\n * @property {number} maxCanvasWidth\n * @property {string} mouseWheelEvent\n * @property {string} fullscreenEvent\n * @property {Function} getMaxCanvasWidth - Returns the max width of a canvas allowed by the browser\n * @property {Promise} isTouchEnabled\n */\nexport const SYSTEM = {\n loaded : false,\n pixelRatio : 1,\n isWebGLSupported: false,\n isTouchEnabled : null,\n maxTextureWidth : 0,\n mouseWheelEvent : null,\n fullscreenEvent : null,\n};\n\n/**\n * @summary Loads the system if not already loaded\n */\nSYSTEM.load = () => {\n if (!SYSTEM.loaded) {\n const ctx = getWebGLCtx();\n\n SYSTEM.loaded = true;\n SYSTEM.pixelRatio = window.devicePixelRatio || 1;\n SYSTEM.isWebGLSupported = ctx != null;\n SYSTEM.isTouchEnabled = isTouchEnabled();\n SYSTEM.maxTextureWidth = getMaxTextureWidth(ctx);\n SYSTEM.mouseWheelEvent = getMouseWheelEvent();\n SYSTEM.fullscreenEvent = getFullscreenEvent();\n }\n};\n\nlet maxCanvasWidth = null;\nSYSTEM.getMaxCanvasWidth = () => {\n if (maxCanvasWidth === null) {\n maxCanvasWidth = getMaxCanvasWidth(SYSTEM.maxTextureWidth);\n }\n return maxCanvasWidth;\n};\n\n/**\n * @summary Tries to return a canvas webgl context\n * @returns {WebGLRenderingContext}\n * @private\n */\nfunction getWebGLCtx() {\n const canvas = document.createElement('canvas');\n const names = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d'];\n let context = null;\n\n if (!canvas.getContext) {\n return null;\n }\n\n if (names.some((name) => {\n try {\n context = canvas.getContext(name);\n return context !== null;\n }\n catch (e) {\n return false;\n }\n })) {\n return context;\n }\n else {\n return null;\n }\n}\n\n/**\n * @summary Detects if the user is using a touch screen\n * @returns {Promise}\n * @private\n */\nfunction isTouchEnabled() {\n return new Promise((resolve) => {\n const listener = (e) => {\n if (e) {\n resolve(true);\n }\n else {\n resolve(false);\n }\n\n window.removeEventListener('touchstart', listener);\n };\n\n window.addEventListener('touchstart', listener, false);\n\n // after 10 secs auto-reject the promise\n setTimeout(listener, 10000);\n });\n}\n\n/**\n * @summary Gets max texture width in WebGL context\n * @returns {number}\n * @private\n */\nfunction getMaxTextureWidth(ctx) {\n if (ctx !== null) {\n return ctx.getParameter(ctx.MAX_TEXTURE_SIZE);\n }\n else {\n return 0;\n }\n}\n\n/**\n * @summary Gets max canvas width supported by the browser.\n * We only test powers of 2 and height = width / 2 because that's what we need to generate WebGL textures\n * @param maxWidth\n * @return {number}\n * @private\n */\nfunction getMaxCanvasWidth(maxWidth) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n canvas.width = maxWidth;\n canvas.height = maxWidth / 2;\n\n while (canvas.width > 1024) {\n ctx.fillStyle = 'white';\n ctx.fillRect(0, 0, 1, 1);\n\n try {\n if (ctx.getImageData(0, 0, 1, 1).data[0] === 255) {\n return canvas.width;\n }\n }\n catch (e) {\n // continue\n }\n\n canvas.width /= 2;\n canvas.height /= 2;\n }\n\n throw new PSVError('Unable to detect system capabilities');\n}\n\n/**\n * @summary Gets the event name for mouse wheel\n * @returns {string}\n * @private\n */\nfunction getMouseWheelEvent() {\n if ('onwheel' in document.createElement('div')) { // Modern browsers support \"wheel\"\n return 'wheel';\n }\n else if (document.onmousewheel !== undefined) { // Webkit and IE support at least \"mousewheel\"\n return 'mousewheel';\n }\n else { // let's assume that remaining browsers are older Firefox\n return 'DOMMouseScroll';\n }\n}\n\n/**\n * @summary Map between fullsceen method and fullscreen event name\n * @type {Object}\n * @readonly\n * @private\n */\nconst FULLSCREEN_EVT_MAP = {\n exitFullscreen : 'fullscreenchange',\n webkitExitFullscreen: 'webkitfullscreenchange',\n mozCancelFullScreen : 'mozfullscreenchange',\n msExitFullscreen : 'MSFullscreenChange',\n};\n\n\n/**\n * @summary Gets the event name for fullscreen\n * @returns {string}\n * @private\n */\nfunction getFullscreenEvent() {\n const validExits = Object.keys(FULLSCREEN_EVT_MAP).filter(exit => exit in document);\n\n if (validExits.length) {\n return FULLSCREEN_EVT_MAP[validExits[0]];\n }\n else {\n return null;\n }\n}\n","/**\n * @summary Helper for pressable things (buttons, keyboard)\n * @description When the pressed thing goes up and was not pressed long enough, wait a bit more before execution\n * @package\n * @package\n */\nexport class PressHandler {\n\n constructor(delay = 200) {\n this.delay = delay;\n this.time = 0;\n this.timeout = null;\n }\n\n down() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n }\n\n this.time = new Date().getTime();\n }\n\n up(cb) {\n if (!this.time) {\n return;\n }\n\n const elapsed = new Date().getTime() - this.time;\n if (elapsed < this.delay) {\n this.timeout = setTimeout(() => {\n cb();\n this.timeout = null;\n this.time = 0;\n }, this.delay);\n }\n else {\n cb();\n this.time = 0;\n }\n }\n\n}\n","import { KEY_CODES } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport arrow from '../icons/arrow.svg';\nimport { getEventKey } from '../utils';\nimport { PressHandler } from '../utils/PressHandler';\nimport { AbstractButton } from './AbstractButton';\n\nexport function getOrientedArrow(direction) {\n let angle = 0;\n switch (direction) {\n // @formatter:off\n case 'up': angle = 90; break;\n case 'right': angle = 180; break;\n case 'down': angle = -90; break;\n default: angle = 0; break;\n // @formatter:on\n }\n\n return arrow.replace('rotate(0', `rotate(${angle}`);\n}\n\n/**\n * @summary Navigation bar move button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class AbstractMoveButton extends AbstractButton {\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {number} value\n */\n constructor(navbar, value) {\n super(navbar, 'psv-button--hover-scale psv-move-button');\n\n this.container.title = this.psv.config.lang.move;\n\n /**\n * @override\n * @property {{longitude: boolean, latitude: boolean}} value\n * @property {PressHandler} handler\n */\n this.prop = {\n ...this.prop,\n value : value,\n handler: new PressHandler(),\n };\n\n this.container.addEventListener('mousedown', this);\n this.container.addEventListener('keydown', this);\n this.container.addEventListener('keyup', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.__onMouseUp();\n\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(); break;\n case 'mouseup': this.__onMouseUp(); break;\n case 'touchend': this.__onMouseUp(); break;\n case 'keydown': getEventKey(e) === KEY_CODES.Enter && this.__onMouseDown(); break;\n case 'keyup': getEventKey(e) === KEY_CODES.Enter && this.__onMouseUp(); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n isSupported() {\n return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) };\n }\n\n /**\n * @override\n */\n onClick() {\n // nothing\n }\n\n /**\n * @private\n */\n __onMouseDown() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.psv.__stopAll();\n this.psv.dynamics.position.roll(this.prop.value);\n this.prop.handler.down();\n }\n\n /**\n * @private\n */\n __onMouseUp() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.handler.up(() => this.psv.dynamics.position.stop());\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move down button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveDownButton extends AbstractMoveButton {\n\n static id = 'moveDown';\n static icon = getOrientedArrow('down');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { latitude: true });\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move left button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveLeftButton extends AbstractMoveButton {\n\n static id = 'moveLeft';\n static icon = getOrientedArrow('left');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { longitude: true });\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move right button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveRightButton extends AbstractMoveButton {\n\n static id = 'moveRight';\n static icon = getOrientedArrow('right');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { longitude: false });\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move up button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveUpButton extends AbstractMoveButton {\n\n static id = 'moveUp';\n static icon = getOrientedArrow('up');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { latitude: false });\n }\n\n}\n","import { KEY_CODES } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { getEventKey } from '../utils';\nimport { PressHandler } from '../utils/PressHandler';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar zoom button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class AbstractZoomButton extends AbstractButton {\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {number} value\n */\n constructor(navbar, value) {\n super(navbar, 'psv-button--hover-scale psv-zoom-button');\n\n /**\n * @override\n * @property {boolean} value\n * @property {PressHandler} handler\n */\n this.prop = {\n ...this.prop,\n value : value,\n handler: new PressHandler(),\n };\n\n this.container.addEventListener('mousedown', this);\n this.container.addEventListener('keydown', this);\n this.container.addEventListener('keyup', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.__onMouseUp();\n\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(); break;\n case 'mouseup': this.__onMouseUp(); break;\n case 'touchend': this.__onMouseUp(); break;\n case 'keydown': getEventKey(e) === KEY_CODES.Enter && this.__onMouseDown(); break;\n case 'keyup': getEventKey(e) === KEY_CODES.Enter && this.__onMouseUp(); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n isSupported() {\n return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) };\n }\n\n /**\n * @override\n */\n onClick() {\n // nothing\n }\n\n /**\n * @private\n */\n __onMouseDown() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.psv.dynamics.zoom.roll(this.prop.value);\n this.prop.handler.down();\n }\n\n /**\n * @private\n */\n __onMouseUp() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.handler.up(() => this.psv.dynamics.zoom.stop());\n }\n\n}\n","import { AbstractZoomButton } from './AbstractZoomButton';\nimport zoomIn from '../icons/zoom-in.svg';\n\n/**\n * @summary Navigation bar zoom-in button class\n * @extends PSV.buttons.AbstractZoomButton\n * @memberof PSV.buttons\n */\nexport class ZoomInButton extends AbstractZoomButton {\n\n static id = 'zoomIn';\n static icon = zoomIn;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, false);\n }\n\n}\n","import { AbstractZoomButton } from './AbstractZoomButton';\nimport zoomOut from '../icons/zoom-out.svg';\n\n/**\n * @summary Navigation bar zoom-out button class\n * @extends PSV.buttons.AbstractZoomButton\n * @memberof PSV.buttons\n */\nexport class ZoomOutButton extends AbstractZoomButton {\n\n static id = 'zoomOut';\n static icon = zoomOut;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, true);\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { getStyle } from '../utils';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar zoom button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class ZoomRangeButton extends AbstractButton {\n\n static id = 'zoomRange';\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-zoom-range', false, false);\n\n /**\n * @override\n * @property {boolean} mousedown\n * @property {number} mediaMinWidth\n */\n this.prop = {\n ...this.prop,\n mousedown : false,\n mediaMinWidth: 0,\n };\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.zoomRange = document.createElement('div');\n this.zoomRange.className = 'psv-zoom-range-line';\n this.container.appendChild(this.zoomRange);\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.zoomValue = document.createElement('div');\n this.zoomValue.className = 'psv-zoom-range-handle';\n this.zoomRange.appendChild(this.zoomValue);\n\n this.prop.mediaMinWidth = parseInt(getStyle(this.container, 'maxWidth'), 10);\n\n this.container.addEventListener('mousedown', this);\n this.container.addEventListener('touchstart', this);\n this.psv.container.addEventListener('mousemove', this);\n this.psv.container.addEventListener('touchmove', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n\n this.psv.on(EVENTS.ZOOM_UPDATED, this);\n\n if (this.psv.prop.ready) {\n this.__moveZoomValue(this.psv.getZoomLevel());\n }\n else {\n this.psv.once(EVENTS.READY, this);\n }\n\n this.refreshUi();\n }\n\n /**\n * @override\n */\n destroy() {\n this.__stopZoomChange();\n\n this.psv.container.removeEventListener('mousemove', this);\n this.psv.container.removeEventListener('touchmove', this);\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n delete this.zoomRange;\n delete this.zoomValue;\n\n this.psv.off(EVENTS.ZOOM_UPDATED, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__initZoomChangeWithMouse(e); break;\n case 'touchstart': this.__initZoomChangeByTouch(e); break;\n case 'mousemove': this.__changeZoomWithMouse(e); break;\n case 'touchmove': this.__changeZoomByTouch(e); break;\n case 'mouseup': this.__stopZoomChange(e); break;\n case 'touchend': this.__stopZoomChange(e); break;\n case EVENTS.ZOOM_UPDATED: this.__moveZoomValue(e.args[0]); break;\n case EVENTS.READY: this.__moveZoomValue(this.psv.getZoomLevel()); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n isSupported() {\n return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) };\n }\n\n /**\n * @override\n */\n refreshUi() {\n if (this.prop.supported) {\n if (this.psv.prop.size.width <= this.prop.mediaMinWidth && this.prop.visible) {\n this.hide();\n }\n else if (this.psv.prop.size.width > this.prop.mediaMinWidth && !this.prop.visible) {\n this.show();\n }\n }\n }\n\n /**\n * @override\n */\n onClick() {\n // nothing\n }\n\n /**\n * @summary Moves the zoom cursor\n * @param {number} level\n * @private\n */\n __moveZoomValue(level) {\n this.zoomValue.style.left = (level / 100 * this.zoomRange.offsetWidth - this.zoomValue.offsetWidth / 2) + 'px';\n }\n\n /**\n * @summary Handles mouse down events\n * @param {MouseEvent} evt\n * @private\n */\n __initZoomChangeWithMouse(evt) {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.mousedown = true;\n this.__changeZoom(evt.clientX);\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __initZoomChangeByTouch(evt) {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.mousedown = true;\n this.__changeZoom(evt.changedTouches[0].clientX);\n }\n\n /**\n * @summary Handles mouse up events\n * @private\n */\n __stopZoomChange() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.mousedown = false;\n this.prop.buttondown = false;\n }\n\n /**\n * @summary Handles mouse move events\n * @param {MouseEvent} evt\n * @private\n */\n __changeZoomWithMouse(evt) {\n if (!this.prop.enabled || !this.prop.mousedown) {\n return;\n }\n\n evt.preventDefault();\n this.__changeZoom(evt.clientX);\n }\n\n /**\n * @summary Handles touch move events\n * @param {TouchEvent} evt\n * @private\n */\n __changeZoomByTouch(evt) {\n if (!this.prop.enabled || !this.prop.mousedown) {\n return;\n }\n this.__changeZoom(evt.changedTouches[0].clientX);\n }\n\n /**\n * @summary Zoom change\n * @param {number} x - mouse/touch position\n * @private\n */\n __changeZoom(x) {\n const userInput = x - this.zoomRange.getBoundingClientRect().left;\n const zoomLevel = userInput / this.zoomRange.offsetWidth * 100;\n this.psv.zoom(zoomLevel);\n }\n\n}\n","import { PSVError } from '../PSVError';\n\n/**\n * @namespace PSV.adapters\n */\n\n/**\n * @summary Base adapters class\n * @memberof PSV.adapters\n * @abstract\n */\nexport class AbstractAdapter {\n\n /**\n * @summary Unique identifier of the adapter\n * @member {string}\n * @readonly\n * @static\n */\n static id = null;\n\n /**\n * @summary Indicates if the adapter supports panorama download natively\n * @type {boolean}\n * @readonly\n * @static\n */\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n }\n\n /**\n * @summary Destroys the adapter\n */\n destroy() {\n delete this.psv;\n }\n\n /**\n * @summary Indicates if the adapter supports transitions between panoramas\n * @param {*} panorama\n * @return {boolean}\n */\n supportsTransition(panorama) { // eslint-disable-line no-unused-vars\n return false;\n }\n\n /**\n * @summary Indicates if the adapter supports preload of a panorama\n * @param {*} panorama\n * @return {boolean}\n */\n supportsPreload(panorama) { // eslint-disable-line no-unused-vars\n return false;\n }\n\n /**\n * @abstract\n * @summary Loads the panorama texture(s)\n * @param {*} panorama\n * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData]\n * @returns {Promise.}\n */\n loadTexture(panorama, newPanoData) { // eslint-disable-line no-unused-vars\n throw new PSVError('loadTexture not implemented');\n }\n\n /**\n * @abstract\n * @summary Creates the cube mesh\n * @param {number} [scale=1]\n * @returns {external:THREE.Mesh}\n */\n createMesh(scale = 1) { // eslint-disable-line no-unused-vars\n throw new PSVError('createMesh not implemented');\n }\n\n /**\n * @abstract\n * @summary Applies the texture to the mesh\n * @param {external:THREE.Mesh} mesh\n * @param {PSV.TextureData} textureData\n * @param {boolean} [transition=false]\n */\n setTexture(mesh, textureData, transition = false) { // eslint-disable-line no-unused-vars\n throw new PSVError('setTexture not implemented');\n }\n\n /**\n * @abstract\n * @summary Changes the opacity of the mesh\n * @param {external:THREE.Mesh} mesh\n * @param {number} opacity\n */\n setTextureOpacity(mesh, opacity) { // eslint-disable-line no-unused-vars\n throw new PSVError('setTextureOpacity not implemented');\n }\n\n /**\n * @abstract\n * @summary Clear a loaded texture from memory\n * @param {PSV.TextureData} textureData\n */\n disposeTexture(textureData) { // eslint-disable-line no-unused-vars\n throw new PSVError('disposeTexture not implemented');\n }\n\n}\n","import * as THREE from 'three';\nimport { SPHERE_RADIUS } from '../../data/constants';\nimport { SYSTEM } from '../../data/system';\nimport { PSVError } from '../../PSVError';\nimport { createTexture, firstNonNull, getXMPValue, isPowerOfTwo, logWarn } from '../../utils';\nimport { AbstractAdapter } from '../AbstractAdapter';\n\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularAdapter.Options\n * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances\n */\n\n\n/**\n * @summary Adapter for equirectangular panoramas\n * @memberof PSV.adapters\n */\nexport class EquirectangularAdapter extends AbstractAdapter {\n\n static id = 'equirectangular';\n static supportsDownload = true;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.EquirectangularAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.EquirectangularAdapter.Options}\n * @private\n */\n this.config = {\n resolution: 64,\n ...options,\n };\n\n if (!isPowerOfTwo(this.config.resolution)) {\n throw new PSVError('EquirectangularAdapter resolution must be power of two');\n }\n\n this.SPHERE_SEGMENTS = this.config.resolution;\n this.SPHERE_HORIZONTAL_SEGMENTS = this.SPHERE_SEGMENTS / 2;\n }\n\n /**\n * @override\n */\n supportsTransition() {\n return true;\n }\n\n /**\n * @override\n */\n supportsPreload() {\n return true;\n }\n\n /**\n * @override\n * @param {string} panorama\n * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData]\n * @returns {Promise.}\n */\n loadTexture(panorama, newPanoData) {\n if (typeof panorama !== 'string') {\n if (Array.isArray(panorama) || typeof panorama === 'object' && !!panorama.left) {\n logWarn('Cubemap support now requires an additional adapter, see https://photo-sphere-viewer.js.org/guide/adapters');\n }\n return Promise.reject(new PSVError('Invalid panorama url, are you using the right adapter?'));\n }\n\n return (\n !this.psv.config.useXmpData\n ? this.psv.textureLoader.loadImage(panorama, p => this.psv.loader.setProgress(p))\n .then(img => ({ img: img, xmpPanoData: null }))\n : this.__loadXMP(panorama, p => this.psv.loader.setProgress(p))\n .then(xmpPanoData => this.psv.textureLoader.loadImage(panorama).then(img => ({ img, xmpPanoData })))\n )\n .then(({ img, xmpPanoData }) => {\n if (typeof newPanoData === 'function') {\n newPanoData = newPanoData(img);\n }\n\n const panoData = {\n fullWidth : firstNonNull(newPanoData?.fullWidth, xmpPanoData?.fullWidth, img.width),\n fullHeight : firstNonNull(newPanoData?.fullHeight, xmpPanoData?.fullHeight, img.height),\n croppedWidth : firstNonNull(newPanoData?.croppedWidth, xmpPanoData?.croppedWidth, img.width),\n croppedHeight: firstNonNull(newPanoData?.croppedHeight, xmpPanoData?.croppedHeight, img.height),\n croppedX : firstNonNull(newPanoData?.croppedX, xmpPanoData?.croppedX, 0),\n croppedY : firstNonNull(newPanoData?.croppedY, xmpPanoData?.croppedY, 0),\n poseHeading : firstNonNull(newPanoData?.poseHeading, xmpPanoData?.poseHeading, 0),\n posePitch : firstNonNull(newPanoData?.posePitch, xmpPanoData?.posePitch, 0),\n poseRoll : firstNonNull(newPanoData?.poseRoll, xmpPanoData?.poseRoll, 0),\n };\n\n if (panoData.croppedWidth !== img.width || panoData.croppedHeight !== img.height) {\n logWarn(`Invalid panoData, croppedWidth and/or croppedHeight is not coherent with loaded image.\n panoData: ${panoData.croppedWidth}x${panoData.croppedHeight}, image: ${img.width}x${img.height}`);\n }\n if ((newPanoData || xmpPanoData) && panoData.fullWidth !== panoData.fullHeight * 2) {\n logWarn('Invalid panoData, fullWidth should be twice fullHeight');\n }\n\n const texture = this.__createEquirectangularTexture(img, panoData);\n\n return { panorama, texture, panoData };\n });\n }\n\n /**\n * @summary Loads the XMP data of an image\n * @param {string} panorama\n * @param {function(number)} [onProgress]\n * @returns {Promise}\n * @throws {PSV.PSVError} when the image cannot be loaded\n * @private\n */\n __loadXMP(panorama, onProgress) {\n return this.psv.textureLoader.loadFile(panorama, onProgress)\n .then(blob => this.__loadBlobAsString(blob))\n .then((binary) => {\n const a = binary.indexOf('');\n const data = binary.substring(a, b);\n\n if (a !== -1 && b !== -1 && data.indexOf('GPano:') !== -1) {\n return {\n fullWidth : getXMPValue(data, 'FullPanoWidthPixels'),\n fullHeight : getXMPValue(data, 'FullPanoHeightPixels'),\n croppedWidth : getXMPValue(data, 'CroppedAreaImageWidthPixels'),\n croppedHeight: getXMPValue(data, 'CroppedAreaImageHeightPixels'),\n croppedX : getXMPValue(data, 'CroppedAreaLeftPixels'),\n croppedY : getXMPValue(data, 'CroppedAreaTopPixels'),\n poseHeading : getXMPValue(data, 'PoseHeadingDegrees'),\n posePitch : getXMPValue(data, 'PosePitchDegrees'),\n poseRoll : getXMPValue(data, 'PoseRollDegrees'),\n };\n }\n\n return null;\n });\n }\n\n /**\n * @summmary read a Blob as string\n * @param {Blob} blob\n * @returns {Promise}\n * @private\n */\n __loadBlobAsString(blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result);\n reader.onerror = reject;\n reader.readAsText(blob);\n });\n }\n\n /**\n * @summary Creates the final texture from image and panorama data\n * @param {Image} img\n * @param {PSV.PanoData} panoData\n * @returns {external:THREE.Texture}\n * @private\n */\n __createEquirectangularTexture(img, panoData) {\n // resize image / fill cropped parts with black\n if (panoData.fullWidth > SYSTEM.maxTextureWidth\n || panoData.croppedWidth !== panoData.fullWidth\n || panoData.croppedHeight !== panoData.fullHeight\n ) {\n const ratio = SYSTEM.getMaxCanvasWidth() / panoData.fullWidth;\n\n const resizedPanoData = { ...panoData };\n if (ratio < 1) {\n resizedPanoData.fullWidth *= ratio;\n resizedPanoData.fullHeight *= ratio;\n resizedPanoData.croppedWidth *= ratio;\n resizedPanoData.croppedHeight *= ratio;\n resizedPanoData.croppedX *= ratio;\n resizedPanoData.croppedY *= ratio;\n }\n\n const buffer = document.createElement('canvas');\n buffer.width = resizedPanoData.fullWidth;\n buffer.height = resizedPanoData.fullHeight;\n\n const ctx = buffer.getContext('2d');\n ctx.drawImage(img,\n resizedPanoData.croppedX, resizedPanoData.croppedY,\n resizedPanoData.croppedWidth, resizedPanoData.croppedHeight);\n\n return createTexture(buffer);\n }\n\n return createTexture(img);\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n // The middle of the panorama is placed at longitude=0\n const geometry = new THREE.SphereGeometry(SPHERE_RADIUS * scale, this.SPHERE_SEGMENTS, this.SPHERE_HORIZONTAL_SEGMENTS, -Math.PI / 2)\n .scale(-1, 1, 1);\n\n const material = new THREE.MeshBasicMaterial();\n\n return new THREE.Mesh(geometry, material);\n }\n\n /**\n * @override\n */\n setTexture(mesh, textureData) {\n const { texture } = textureData;\n\n mesh.material.map?.dispose();\n mesh.material.map = texture;\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n mesh.material.opacity = opacity;\n mesh.material.transparent = opacity < 1;\n }\n\n /**\n * @override\n */\n disposeTexture(textureData) {\n textureData.texture?.dispose();\n }\n\n}\n","import { EventEmitter } from 'uevent';\n\n/**\n * @namespace PSV.plugins\n */\n\n/**\n * @summary Base plugins class\n * @memberof PSV.plugins\n * @abstract\n */\nexport class AbstractPlugin extends EventEmitter {\n\n /**\n * @summary Unique identifier of the plugin\n * @member {string}\n * @readonly\n * @static\n */\n static id = null;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super();\n\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n }\n\n /**\n * @summary Initializes the plugin\n * @package\n */\n init() {\n }\n\n /**\n * @summary Destroys the plugin\n * @package\n */\n destroy() {\n delete this.psv;\n }\n\n}\n","import { AbstractAdapter } from '../adapters/AbstractAdapter';\nimport { EquirectangularAdapter } from '../adapters/equirectangular';\nimport { AbstractPlugin } from '../plugins/AbstractPlugin';\nimport { PSVError } from '../PSVError';\nimport { bound, clone, deepmerge, each, logWarn, parseAngle, parseSpeed, pluginInterop } from '../utils';\nimport { ACTIONS, KEY_CODES } from './constants';\n\n/**\n * @summary Default options\n * @type {PSV.Options}\n * @memberOf PSV\n * @constant\n */\nexport const DEFAULTS = {\n panorama : null,\n container : null,\n adapter : null,\n plugins : [],\n caption : null,\n downloadUrl : null,\n loadingImg : null,\n loadingTxt : 'Loading...',\n size : null,\n fisheye : false,\n minFov : 30,\n maxFov : 90,\n defaultZoomLvl : 50,\n defaultLong : 0,\n defaultLat : 0,\n sphereCorrection : null,\n moveSpeed : 1,\n zoomSpeed : 1,\n autorotateDelay : null,\n autorotateSpeed : '2rpm',\n autorotateLat : null,\n moveInertia : true,\n mousewheel : true,\n mousemove : true,\n captureCursor : false,\n mousewheelCtrlKey : false,\n touchmoveTwoFingers: false,\n useXmpData : true,\n panoData : null,\n requestHeaders : null,\n canvasBackground : '#000',\n withCredentials : false,\n navbar : [\n 'autorotate',\n 'zoom',\n 'move',\n 'download',\n 'caption',\n 'fullscreen',\n ],\n lang : {\n autorotate: 'Automatic rotation',\n zoom : 'Zoom',\n zoomOut : 'Zoom out',\n zoomIn : 'Zoom in',\n move : 'Move',\n download : 'Download',\n fullscreen: 'Fullscreen',\n menu : 'Menu',\n twoFingers: 'Use two fingers to navigate',\n ctrlZoom : 'Use ctrl + scroll to zoom the image',\n loadError : 'The panorama can\\'t be loaded',\n },\n keyboard : {\n [KEY_CODES.ArrowUp] : ACTIONS.ROTATE_LAT_UP,\n [KEY_CODES.ArrowDown] : ACTIONS.ROTATE_LAT_DOWN,\n [KEY_CODES.ArrowRight]: ACTIONS.ROTATE_LONG_RIGHT,\n [KEY_CODES.ArrowLeft] : ACTIONS.ROTATE_LONG_LEFT,\n [KEY_CODES.PageUp] : ACTIONS.ZOOM_IN,\n [KEY_CODES.PageDown] : ACTIONS.ZOOM_OUT,\n [KEY_CODES.Plus] : ACTIONS.ZOOM_IN,\n [KEY_CODES.Minus] : ACTIONS.ZOOM_OUT,\n [KEY_CODES.Space] : ACTIONS.TOGGLE_AUTOROTATE,\n },\n};\n\n/**\n * @summary List of unmodifiable options and their error messages\n * @private\n */\nexport const READONLY_OPTIONS = {\n panorama : 'Use setPanorama method to change the panorama',\n panoData : 'Use setPanorama method to change the panorama',\n container: 'Cannot change viewer container',\n adapter : 'Cannot change adapter',\n plugins : 'Cannot change plugins',\n};\n\n/**\n * @summary List of deprecated options and their warning messages\n * @private\n */\nexport const DEPRECATED_OPTIONS = {\n zoomButtonIncrement : 'zoomButtonIncrement is deprecated, use zoomSpeed',\n mousewheelSpeed : 'mousewheelSpeed is deprecated, use zoomSpeed',\n sphereCorrectionReorder: 'sphereCorrectionReorder is deprecated',\n};\n\n/**\n * @summary Parsers/validators for each option\n * @private\n */\nexport const CONFIG_PARSERS = {\n container : (container) => {\n if (!container) {\n throw new PSVError('No value given for container.');\n }\n return container;\n },\n adapter : (adapter) => {\n if (!adapter) {\n adapter = [EquirectangularAdapter];\n }\n else if (Array.isArray(adapter)) {\n adapter = [pluginInterop(adapter[0], AbstractAdapter), adapter[1]];\n }\n else {\n adapter = [pluginInterop(adapter, AbstractAdapter)];\n }\n if (!adapter[0]) {\n throw new PSVError('Un undefined value with given for adapter.');\n }\n return adapter;\n },\n defaultLong : (defaultLong) => {\n // defaultLat is between 0 and PI\n return parseAngle(defaultLong);\n },\n defaultLat : (defaultLat) => {\n // defaultLat is between -PI/2 and PI/2\n return parseAngle(defaultLat, true);\n },\n minFov : (minFov, config) => {\n // minFov and maxFov must be ordered\n if (config.maxFov < minFov) {\n logWarn('maxFov cannot be lower than minFov');\n minFov = config.maxFov;\n }\n // minFov between 1 and 179\n return bound(minFov, 1, 179);\n },\n maxFov : (maxFov, config) => {\n // minFov and maxFov must be ordered\n if (maxFov < config.minFov) {\n maxFov = config.minFov;\n }\n // maxFov between 1 and 179\n return bound(maxFov, 1, 179);\n },\n lang : (lang) => {\n if (Array.isArray(lang.twoFingers)) {\n logWarn('lang.twoFingers must not be an array');\n lang.twoFingers = lang.twoFingers[0];\n }\n return {\n ...DEFAULTS.lang,\n ...lang,\n };\n },\n keyboard : (keyboard) => {\n // keyboard=true becomes the default map\n if (keyboard === true) {\n return clone(DEFAULTS.keyboard);\n }\n return keyboard;\n },\n autorotateLat : (autorotateLat, config) => {\n // default autorotateLat is defaultLat\n if (autorotateLat === null) {\n return parseAngle(config.defaultLat, true);\n }\n // autorotateLat is between -PI/2 and PI/2\n else {\n return parseAngle(autorotateLat, true);\n }\n },\n autorotateSpeed: (autorotateSpeed) => {\n return parseSpeed(autorotateSpeed);\n },\n fisheye : (fisheye) => {\n // translate boolean fisheye to amount\n if (fisheye === true) {\n return 1;\n }\n else if (fisheye === false) {\n return 0;\n }\n return fisheye;\n },\n plugins : (plugins) => {\n return plugins\n .map((plugin) => {\n if (Array.isArray(plugin)) {\n plugin = [pluginInterop(plugin[0], AbstractPlugin), plugin[1]];\n }\n else {\n plugin = [pluginInterop(plugin, AbstractPlugin)];\n }\n if (!plugin[0]) {\n throw new PSVError('Un undefined value was given for plugins.');\n }\n return plugin;\n });\n },\n};\n\n/**\n * @summary Merge user config with default config and performs validation\n * @param {PSV.Options} options\n * @returns {PSV.Options}\n * @memberOf PSV\n * @private\n */\nexport function getConfig(options) {\n const tempConfig = clone(DEFAULTS);\n deepmerge(tempConfig, options);\n\n const config = {};\n\n each(tempConfig, (value, key) => {\n if (DEPRECATED_OPTIONS[key]) {\n logWarn(DEPRECATED_OPTIONS[key]);\n return;\n }\n\n if (!Object.prototype.hasOwnProperty.call(DEFAULTS, key)) {\n throw new PSVError(`Unknown option ${key}`);\n }\n\n if (CONFIG_PARSERS[key]) {\n config[key] = CONFIG_PARSERS[key](value, tempConfig);\n }\n else {\n config[key] = value;\n }\n });\n\n return config;\n}\n","import { AbstractButton } from './AbstractButton';\nimport { EVENTS } from '../data/constants';\nimport info from '../icons/info.svg';\n\n/**\n * @summary Navigation bar caption button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class CaptionButton extends AbstractButton {\n\n static id = 'caption';\n static icon = info;\n\n /**\n * @param {PSV.components.NavbarCaption} caption\n */\n constructor(caption) {\n super(caption, 'psv-button--hover-scale psv-caption-button');\n\n this.psv.on(EVENTS.HIDE_NOTIFICATION, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.HIDE_NOTIFICATION, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.HIDE_NOTIFICATION: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles caption\n */\n onClick() {\n if (this.psv.notification.prop.visible) {\n this.psv.notification.hide();\n }\n else {\n this.psv.notification.show(this.parent.prop.caption);\n this.toggleActive(true);\n }\n }\n\n}\n","import { CaptionButton } from '../buttons/CaptionButton';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Navbar caption class\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class NavbarCaption extends AbstractComponent {\n\n static id = 'caption';\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {string} caption\n */\n constructor(navbar, caption) {\n super(navbar, 'psv-caption');\n\n /**\n * @member {PSV.buttons.CaptionButton}\n * @readonly\n * @private\n */\n this.button = new CaptionButton(this);\n this.button.hide();\n\n /**\n * @override\n * @property {string} id\n * @property {boolean} collapsable\n * @property {number} width\n * @property {string} caption\n * @property {boolean} contentVisible - if the content is visible in the navbar\n * @property {number} contentWidth - with of the caption content\n */\n this.prop = {\n ...this.prop,\n id : this.constructor.id,\n collapsable : false,\n width : this.button.prop.width,\n caption : '',\n contentVisible: true,\n contentWidth : 0,\n };\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-caption-content';\n this.container.appendChild(this.content);\n\n this.setCaption(caption);\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.button;\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Sets the bar caption\n * @param {string} html\n */\n setCaption(html) {\n this.prop.caption = html || '';\n this.content.innerHTML = this.prop.caption;\n\n if (html) {\n this.show(false);\n\n this.content.style.display = '';\n this.prop.contentWidth = this.content.offsetWidth;\n\n this.refreshUi();\n }\n else {\n this.hide();\n }\n }\n\n /**\n * @summary Toggles content and icon depending on available space\n * @private\n */\n refreshUi() {\n const availableWidth = this.container.offsetWidth;\n if (availableWidth >= this.prop.contentWidth && !this.prop.contentVisible) {\n this.content.style.display = '';\n this.prop.contentVisible = true;\n this.button.hide(false);\n }\n else if (availableWidth < this.prop.contentWidth && this.prop.contentVisible) {\n this.content.style.display = 'none';\n this.prop.contentVisible = false;\n this.button.show(false);\n }\n }\n\n}\n","import { AutorotateButton } from '../buttons/AutorotateButton';\nimport { CustomButton } from '../buttons/CustomButton';\nimport { DownloadButton } from '../buttons/DownloadButton';\nimport { FullscreenButton } from '../buttons/FullscreenButton';\nimport { MenuButton } from '../buttons/MenuButton';\nimport { MoveDownButton } from '../buttons/MoveDownButton';\nimport { MoveLeftButton } from '../buttons/MoveLeftButton';\nimport { MoveRightButton } from '../buttons/MoveRightButton';\nimport { MoveUpButton } from '../buttons/MoveUpButton';\nimport { ZoomInButton } from '../buttons/ZoomInButton';\nimport { ZoomOutButton } from '../buttons/ZoomOutButton';\nimport { ZoomRangeButton } from '../buttons/ZoomRangeButton';\nimport { DEFAULTS } from '../data/config';\nimport { PSVError } from '../PSVError';\nimport { clone, logWarn } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\nimport { NavbarCaption } from './NavbarCaption';\n\n/**\n * @summary List of available buttons\n * @type {Object>}\n * @private\n */\nconst AVAILABLE_BUTTONS = {};\n\n/**\n * @summary Register a new button available for all viewers\n * @param {Class} button\n * @param {'start' | 'end' | '[id]:left' | '[id]:right'} [defaultPosition]\n * If provided the default configuration of the navbar will be modified.\n * @memberOf PSV\n */\nexport function registerButton(button, defaultPosition) {\n if (!button.id) {\n throw new PSVError('Button ID is required');\n }\n\n AVAILABLE_BUTTONS[button.id] = button;\n\n if (typeof defaultPosition === 'string') {\n switch (defaultPosition) {\n case 'start':\n DEFAULTS.navbar.unshift(button.id);\n break;\n case 'end':\n DEFAULTS.navbar.push(button.id);\n break;\n default:\n const [id, pos] = defaultPosition.split(':');\n DEFAULTS.navbar.splice(DEFAULTS.navbar.indexOf(id) + (pos === 'right' ? 1 : 0), 0, button.id);\n }\n }\n}\n\n[\n AutorotateButton,\n ZoomInButton,\n ZoomRangeButton,\n ZoomOutButton,\n DownloadButton,\n FullscreenButton,\n MoveRightButton,\n MoveLeftButton,\n MoveUpButton,\n MoveDownButton,\n].forEach(registerButton);\n\n/**\n * @summary Navigation bar component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Navbar extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-navbar');\n\n /**\n * @summary List of buttons of the navbar\n * @member {PSV.buttons.AbstractButton[]}\n * @override\n */\n this.children = [];\n\n /**\n * @summary List of collapsed buttons\n * @member {PSV.buttons.AbstractButton[]}\n * @private\n */\n this.collapsed = [];\n }\n\n /**\n * @summary Change the buttons visible on the navbar\n * @param {string|Array} buttons\n * @throws {PSV.PSVError} when a button is unknown\n */\n setButtons(buttons) {\n this.children.slice().forEach(item => item.destroy());\n this.children.length = 0;\n\n /* eslint-disable no-new */\n this.__cleanButtons(buttons).forEach((button) => {\n if (typeof button === 'object') {\n new CustomButton(this, button);\n }\n else if (AVAILABLE_BUTTONS[button]) {\n new AVAILABLE_BUTTONS[button](this);\n }\n else if (button === 'caption') {\n new NavbarCaption(this, this.psv.config.caption);\n }\n else if (button === 'zoom') {\n new ZoomOutButton(this);\n new ZoomRangeButton(this);\n new ZoomInButton(this);\n }\n else if (button === 'move') {\n new MoveLeftButton(this);\n new MoveRightButton(this);\n new MoveUpButton(this);\n new MoveDownButton(this);\n }\n else {\n throw new PSVError('Unknown button ' + button);\n }\n });\n\n new MenuButton(this);\n /* eslint-enable no-new */\n\n this.children.forEach((item) => {\n if (typeof item.checkSupported === 'function') {\n item.checkSupported();\n }\n });\n }\n\n /**\n * @summary Sets the bar caption\n * @param {string} html\n */\n setCaption(html) {\n const caption = this.getButton('caption', false);\n caption?.setCaption(html);\n }\n\n /**\n * @summary Returns a button by its identifier\n * @param {string} id\n * @param {boolean} [warnNotFound=true]\n * @returns {PSV.buttons.AbstractButton}\n */\n getButton(id, warnNotFound = true) {\n let button = null;\n\n this.children.some((item) => {\n if (item.prop.id === id) {\n button = item;\n return true;\n }\n else {\n return false;\n }\n });\n\n if (!button && warnNotFound) {\n logWarn(`button \"${id}\" not found in the navbar`);\n }\n\n return button;\n }\n\n /**\n * @summary Shows the navbar\n */\n show() {\n this.container.classList.add('psv-navbar--open');\n this.prop.visible = true;\n }\n\n /**\n * @summary Hides the navbar\n */\n hide() {\n this.container.classList.remove('psv-navbar--open');\n this.prop.visible = false;\n }\n\n /**\n * @override\n */\n refreshUi() {\n super.refreshUi();\n\n if (this.psv.prop.uiRefresh === true) {\n const availableWidth = this.container.offsetWidth;\n\n let totalWidth = 0;\n const visibleButtons = [];\n const collapsableButtons = [];\n\n this.children.forEach((item) => {\n if (item.prop.visible) {\n totalWidth += item.prop.width;\n visibleButtons.push(item);\n if (item.prop.collapsable) {\n collapsableButtons.push(item);\n }\n }\n });\n\n if (!visibleButtons.length) {\n return;\n }\n\n if (availableWidth < totalWidth && collapsableButtons.length > 0) {\n collapsableButtons.forEach(item => item.collapse());\n this.collapsed = collapsableButtons;\n\n this.getButton(MenuButton.id).show(false);\n }\n else if (availableWidth >= totalWidth && this.collapsed.length > 0) {\n this.collapsed.forEach(item => item.uncollapse());\n this.collapsed = [];\n\n this.getButton(MenuButton.id).hide(false);\n }\n\n const caption = this.getButton(NavbarCaption.id, false);\n if (caption) {\n caption.refreshUi();\n }\n }\n }\n\n /**\n * @summary Ensure the buttons configuration is correct\n * @private\n */\n __cleanButtons(buttons) {\n // true becomes the default array\n if (buttons === true) {\n return clone(DEFAULTS.navbar);\n }\n // can be a space or coma separated list\n else if (typeof buttons === 'string') {\n return buttons.split(/[ ,]/);\n }\n else {\n return buttons || [];\n }\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { bound, getStyle } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Loader component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Loader extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-loader-container');\n\n /**\n * @summary Inner container for vertical center\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.loader = document.createElement('div');\n this.loader.className = 'psv-loader';\n this.container.appendChild(this.loader);\n\n /**\n * @summary Animation canvas\n * @member {HTMLCanvasElement}\n * @readonly\n * @private\n */\n this.canvas = document.createElement('canvas');\n this.canvas.className = 'psv-loader-canvas';\n\n this.canvas.width = this.loader.clientWidth * SYSTEM.pixelRatio;\n this.canvas.height = this.loader.clientWidth * SYSTEM.pixelRatio;\n this.loader.appendChild(this.canvas);\n\n /**\n * @override\n * @property {number} thickness\n * @property {string} current\n */\n this.prop = {\n ...this.prop,\n tickness: (this.loader.offsetWidth - this.loader.clientWidth) / 2 * SYSTEM.pixelRatio,\n current : null,\n };\n\n this.refreshUi();\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.loader;\n delete this.canvas;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n refreshUi() {\n if (this.prop.current !== (this.psv.config.loadingImg || this.psv.config.loadingTxt)) {\n if (this.prop.current) {\n this.loader.removeChild(this.loader.lastChild);\n }\n\n let inner;\n if (this.psv.config.loadingImg) {\n inner = document.createElement('img');\n inner.className = 'psv-loader-image';\n inner.src = this.psv.config.loadingImg;\n }\n else if (this.psv.config.loadingTxt) {\n inner = document.createElement('div');\n inner.className = 'psv-loader-text';\n inner.innerHTML = this.psv.config.loadingTxt;\n }\n if (inner) {\n const size = Math.round(Math.sqrt(2 * Math.pow((this.canvas.width / 2 - this.prop.tickness / 2) / SYSTEM.pixelRatio, 2)));\n inner.style.maxWidth = size + 'px';\n inner.style.maxHeight = size + 'px';\n this.loader.appendChild(inner);\n }\n\n this.prop.current = this.psv.config.loadingImg || this.psv.config.loadingTxt;\n }\n }\n\n /**\n * @summary Sets the loader progression\n * @param {number} value - from 0 to 100\n */\n setProgress(value) {\n const context = this.canvas.getContext('2d');\n\n context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\n context.lineWidth = this.prop.tickness;\n context.strokeStyle = getStyle(this.loader, 'color');\n\n context.beginPath();\n context.arc(\n this.canvas.width / 2, this.canvas.height / 2,\n this.canvas.width / 2 - this.prop.tickness / 2,\n -Math.PI / 2, bound(value, 0, 100) / 100 * 2 * Math.PI - Math.PI / 2\n );\n context.stroke();\n\n this.psv.trigger(EVENTS.LOAD_PROGRESS, Math.round(value));\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Notification component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Notification extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-notification');\n\n /**\n * @override\n * @property {*} timeout\n */\n this.prop = {\n ...this.prop,\n visible: false,\n timeout: null,\n };\n\n /**\n * Notification content\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-notification-content';\n this.container.appendChild(this.content);\n\n this.content.addEventListener('click', () => this.hide());\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Displays a notification on the viewer\n * @param {Object|string} config\n * @param {string} config.content\n * @param {number} [config.timeout]\n * @fires PSV.show-notification\n *\n * @example\n * viewer.showNotification({ content: 'Hello world', timeout: 5000 })\n * @example\n * viewer.showNotification('Hello world')\n */\n show(config) {\n if (this.prop.timeout) {\n clearTimeout(this.prop.timeout);\n this.prop.timeout = null;\n }\n\n if (typeof config === 'string') {\n config = { content: config };\n }\n\n this.content.innerHTML = config.content;\n this.prop.visible = true;\n\n this.container.classList.add('psv-notification--visible');\n\n this.psv.trigger(EVENTS.SHOW_NOTIFICATION);\n\n if (config.timeout) {\n this.prop.timeout = setTimeout(() => this.hide(), config.timeout);\n }\n }\n\n /**\n * @summary Hides the notification\n * @fires PSV.hide-notification\n */\n hide() {\n if (this.prop.visible) {\n this.container.classList.remove('psv-notification--visible');\n\n this.prop.visible = false;\n\n this.psv.trigger(EVENTS.HIDE_NOTIFICATION);\n }\n }\n\n}\n","import { EVENTS, KEY_CODES } from '../data/constants';\nimport { getEventKey } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\nimport { PSVError } from '../PSVError';\n\n/**\n * @summary Overlay component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Overlay extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-overlay');\n\n /**\n * @override\n * @property {string} contentId\n * @property {boolean} dissmisable\n */\n this.prop = {\n ...this.prop,\n contentId : undefined,\n dissmisable: true,\n };\n\n /**\n * Image container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.image = document.createElement('div');\n this.image.className = 'psv-overlay-image';\n this.container.appendChild(this.image);\n\n /**\n * Text container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.text = document.createElement('div');\n this.text.className = 'psv-overlay-text';\n this.container.appendChild(this.text);\n\n /**\n * Subtext container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.subtext = document.createElement('div');\n this.subtext.className = 'psv-overlay-subtext';\n this.container.appendChild(this.subtext);\n\n this.container.addEventListener('mouseup', this);\n\n document.addEventListener('keydown', this);\n\n super.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n document.removeEventListener('keydown', this);\n\n delete this.image;\n delete this.text;\n delete this.subtext;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mouseup': this.prop.dissmisable && this.hide(); break;\n case 'keydown': getEventKey(e) === KEY_CODES.Escape && this.prop.dissmisable && this.hide(); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @param {string} [id]\n */\n isVisible(id) {\n return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id);\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Overlay cannot be toggled');\n }\n\n /**\n * @summary Displays an overlay on the viewer\n * @param {Object|string} config\n * @param {string} [config.id] - unique identifier to use with \"hide\"\n * @param {string} config.image - SVG image/icon displayed above the text\n * @param {string} config.text - main message\n * @param {string} [config.subtext] - secondary message\n * @param {boolean} [config.dissmisable=true] - if the user can hide the overlay by clicking\n * @fires PSV.show-overlay\n */\n show(config) {\n if (typeof config === 'string') {\n config = { text: config };\n }\n\n this.prop.contentId = config.id;\n this.prop.dissmisable = config.dissmisable !== false;\n this.image.innerHTML = config.image || '';\n this.text.innerHTML = config.text || '';\n this.subtext.innerHTML = config.subtext || '';\n\n super.show();\n\n this.psv.trigger(EVENTS.SHOW_OVERLAY, config.id);\n }\n\n /**\n * @summary Hides the overlay\n * @param {string} [id]\n * @fires PSV.hide-overlay\n */\n hide(id) {\n if (this.isVisible() && (!id || !this.prop.contentId || this.prop.contentId === id)) {\n const contentId = this.prop.contentId;\n\n super.hide();\n\n this.prop.contentId = undefined;\n\n this.psv.trigger(EVENTS.HIDE_OVERLAY, contentId);\n }\n }\n\n}\n","import { EVENTS, KEY_CODES } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { PSVError } from '../PSVError';\nimport { getEventKey, toggleClass } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Minimum width of the panel\n * @type {number}\n * @constant\n * @private\n */\nconst PANEL_MIN_WIDTH = 200;\n\n/**\n * @summary Panel component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Panel extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-panel');\n\n /**\n * @override\n * @property {string} contentId\n * @property {number} mouseX\n * @property {number} mouseY\n * @property {boolean} mousedown\n * @property {function} clickHandler\n * @property {function} keyHandler\n */\n this.prop = {\n ...this.prop,\n visible : false,\n contentId : undefined,\n mouseX : 0,\n mouseY : 0,\n mousedown : false,\n clickHandler: null,\n keyHandler : null,\n width : {},\n };\n\n const resizer = document.createElement('div');\n resizer.className = 'psv-panel-resizer';\n this.container.appendChild(resizer);\n\n const closeBtn = document.createElement('div');\n closeBtn.className = 'psv-panel-close-button';\n this.container.appendChild(closeBtn);\n\n /**\n * @summary Content container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-panel-content';\n this.container.appendChild(this.content);\n\n // Stop wheel event bubbling from panel\n this.container.addEventListener(SYSTEM.mouseWheelEvent, e => e.stopPropagation());\n\n closeBtn.addEventListener('click', () => this.hide());\n\n // Event for panel resizing + stop bubling\n resizer.addEventListener('mousedown', this);\n resizer.addEventListener('touchstart', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n this.psv.container.addEventListener('mousemove', this);\n this.psv.container.addEventListener('touchmove', this);\n\n document.addEventListener('keydown', this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.container.removeEventListener('mousemove', this);\n this.psv.container.removeEventListener('touchmove', this);\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n document.removeEventListener('keydown', this);\n\n delete this.prop;\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(e); break;\n case 'touchstart': this.__onTouchStart(e); break;\n case 'mousemove': this.__onMouseMove(e); break;\n case 'touchmove': this.__onTouchMove(e); break;\n case 'mouseup': this.__onMouseUp(e); break;\n case 'touchend': this.__onMouseUp(e); break;\n case 'keydown': getEventKey(e) === KEY_CODES.Escape && this.hide(); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @param {string} [id]\n */\n isVisible(id) {\n return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id);\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Panel cannot be toggled');\n }\n\n /**\n * @summary Shows the panel\n * @param {string|Object} config\n * @param {string} [config.id] - unique identifier to use with \"hide\" and to store the user desired width\n * @param {string} config.content - HTML content of the panel\n * @param {boolean} [config.noMargin=false] - remove the default margins\n * @param {string} [config.width] - initial width\n * @param {Function} [config.clickHandler] - called when the user clicks inside the panel or presses the Enter key while an element focused\n * @fires PSV.open-panel\n */\n show(config) {\n const wasVisible = this.isVisible(config.id);\n\n if (typeof config === 'string') {\n config = { content: config };\n }\n\n this.prop.contentId = config.id;\n this.prop.visible = true;\n\n if (this.prop.clickHandler) {\n this.content.removeEventListener('click', this.prop.clickHandler);\n this.content.removeEventListener('keydown', this.prop.keyHandler);\n this.prop.clickHandler = null;\n this.prop.keyHandler = null;\n }\n\n if (config.id && this.prop.width[config.id]) {\n this.container.style.width = this.prop.width[config.id];\n }\n else if (config.width) {\n this.container.style.width = config.width;\n }\n else {\n this.container.style.width = null;\n }\n\n this.content.innerHTML = config.content;\n this.content.scrollTop = 0;\n this.container.classList.add('psv-panel--open');\n\n toggleClass(this.content, 'psv-panel-content--no-margin', config.noMargin === true);\n\n if (config.clickHandler) {\n this.prop.clickHandler = config.clickHandler;\n this.prop.keyHandler = (e) => {\n if (getEventKey(e) === KEY_CODES.Enter) {\n config.clickHandler(e);\n }\n };\n this.content.addEventListener('click', this.prop.clickHandler);\n this.content.addEventListener('keydown', this.prop.keyHandler);\n\n // focus the first element if possible, after animation ends\n if (!wasVisible) {\n setTimeout(() => {\n this.content.querySelector('a,button,[tabindex]')?.focus();\n }, 300);\n }\n }\n\n this.psv.trigger(EVENTS.OPEN_PANEL, config.id);\n }\n\n /**\n * @summary Hides the panel\n * @param {string} [id]\n * @fires PSV.close-panel\n */\n hide(id) {\n if (this.isVisible(id)) {\n const contentId = this.prop.contentId;\n\n this.prop.visible = false;\n this.prop.contentId = undefined;\n\n this.content.innerHTML = null;\n this.container.classList.remove('psv-panel--open');\n\n if (this.prop.clickHandler) {\n this.content.removeEventListener('click', this.prop.clickHandler);\n this.prop.clickHandler = null;\n }\n\n this.psv.trigger(EVENTS.CLOSE_PANEL, contentId);\n }\n }\n\n /**\n * @summary Handles mouse down events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseDown(evt) {\n evt.stopPropagation();\n this.__startResize(evt);\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchStart(evt) {\n evt.stopPropagation();\n this.__startResize(evt.changedTouches[0]);\n }\n\n /**\n * @summary Handles mouse up events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseUp(evt) {\n if (this.prop.mousedown) {\n evt.stopPropagation();\n this.prop.mousedown = false;\n this.content.classList.remove('psv-panel-content--no-interaction');\n }\n }\n\n /**\n * @summary Handles mouse move events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseMove(evt) {\n if (this.prop.mousedown) {\n evt.stopPropagation();\n this.__resize(evt);\n }\n }\n\n /**\n * @summary Handles touch move events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchMove(evt) {\n if (this.prop.mousedown) {\n this.__resize(evt.touches[0]);\n }\n }\n\n /**\n * @summary Initializes the panel resize\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __startResize(evt) {\n this.prop.mouseX = evt.clientX;\n this.prop.mouseY = evt.clientY;\n this.prop.mousedown = true;\n this.content.classList.add('psv-panel-content--no-interaction');\n }\n\n /**\n * @summary Resizes the panel\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __resize(evt) {\n const x = evt.clientX;\n const y = evt.clientY;\n const width = Math.max(PANEL_MIN_WIDTH, this.container.offsetWidth - (x - this.prop.mouseX)) + 'px';\n\n if (this.prop.contentId) {\n this.prop.width[this.prop.contentId] = width;\n }\n\n this.container.style.width = width;\n\n this.prop.mouseX = x;\n this.prop.mouseY = y;\n }\n\n}\n","/**\n * @namespace PSV.services\n */\n\n/**\n * @summary Base services class\n * @memberof PSV.services\n * @abstract\n */\nexport class AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n\n /**\n * @summary Configuration holder\n * @type {PSV.Options}\n * @readonly\n */\n this.config = psv.config;\n\n /**\n * @summary Properties holder\n * @type {Object}\n * @readonly\n */\n this.prop = psv.prop;\n }\n\n /**\n * @summary Destroys the service\n */\n destroy() {\n delete this.psv;\n delete this.config;\n delete this.prop;\n }\n\n}\n","import * as THREE from 'three';\nimport { MESH_USER_DATA, SPHERE_RADIUS } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { applyEulerInverse, parseAngle, parseSpeed } from '../utils';\nimport { AbstractService } from './AbstractService';\n\nconst vector2 = new THREE.Vector2();\nconst vector3 = new THREE.Vector3();\nconst eulerZero = new THREE.Euler(0, 0, 0, 'ZXY');\n\n/**\n * @summary Collections of data converters for the current viewer\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class DataHelper extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n }\n\n /**\n * @summary Converts vertical FOV to zoom level\n * @param {number} fov\n * @returns {number}\n */\n fovToZoomLevel(fov) {\n const temp = Math.round((fov - this.config.minFov) / (this.config.maxFov - this.config.minFov) * 100);\n return temp - 2 * (temp - 50);\n }\n\n /**\n * @summary Converts zoom level to vertical FOV\n * @param {number} level\n * @returns {number}\n */\n zoomLevelToFov(level) {\n return this.config.maxFov + (level / 100) * (this.config.minFov - this.config.maxFov);\n }\n\n /**\n * @summary Convert vertical FOV to horizontal FOV\n * @param {number} vFov\n * @returns {number}\n */\n vFovToHFov(vFov) {\n return THREE.Math.radToDeg(2 * Math.atan(Math.tan(THREE.Math.degToRad(vFov) / 2) * this.prop.aspect));\n }\n\n /**\n * @summary Converts a speed into a duration from current position to a new position\n * @param {string|number} value\n * @param {number} angle\n * @returns {number}\n */\n speedToDuration(value, angle) {\n if (!value || typeof value !== 'number') {\n // desired radial speed\n const speed = value ? parseSpeed(value) : this.config.autorotateSpeed;\n // compute duration\n return angle / Math.abs(speed) * 1000;\n }\n else {\n return Math.abs(value);\n }\n }\n\n /**\n * @summary Converts pixel texture coordinates to spherical radians coordinates\n * @param {PSV.Point} point\n * @returns {PSV.Position}\n * @throws {PSV.PSVError} when the current adapter does not support texture coordinates\n */\n textureCoordsToSphericalCoords(point) {\n const panoData = this.prop.panoData;\n if (!panoData) {\n throw new PSVError('Current adapter does not support texture coordinates.');\n }\n\n const relativeX = (point.x + panoData.croppedX) / panoData.fullWidth * Math.PI * 2;\n const relativeY = (point.y + panoData.croppedY) / panoData.fullHeight * Math.PI;\n\n const result = {\n longitude: relativeX >= Math.PI ? relativeX - Math.PI : relativeX + Math.PI,\n latitude : Math.PI / 2 - relativeY,\n };\n\n // Apply panoData pose and sphereCorrection\n if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) {\n this.sphericalCoordsToVector3(result, vector3);\n vector3.applyEuler(this.psv.renderer.mesh.rotation);\n vector3.applyEuler(this.psv.renderer.meshContainer.rotation);\n return this.vector3ToSphericalCoords(vector3);\n }\n else {\n return result;\n }\n }\n\n /**\n * @summary Converts spherical radians coordinates to pixel texture coordinates\n * @param {PSV.Position} position\n * @returns {PSV.Point}\n * @throws {PSV.PSVError} when the current adapter does not support texture coordinates\n */\n sphericalCoordsToTextureCoords(position) {\n const panoData = this.prop.panoData;\n if (!panoData) {\n throw new PSVError('Current adapter does not support texture coordinates.');\n }\n\n // Apply panoData pose and sphereCorrection\n if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) {\n this.sphericalCoordsToVector3(position, vector3);\n applyEulerInverse(vector3, this.psv.renderer.meshContainer.rotation);\n applyEulerInverse(vector3, this.psv.renderer.mesh.rotation);\n position = this.vector3ToSphericalCoords(vector3);\n }\n\n const relativeLong = position.longitude / Math.PI / 2 * panoData.fullWidth;\n const relativeLat = position.latitude / Math.PI * panoData.fullHeight;\n\n return {\n x: Math.round(position.longitude < Math.PI ? relativeLong + panoData.fullWidth / 2 : relativeLong - panoData.fullWidth / 2) - panoData.croppedX,\n y: Math.round(panoData.fullHeight / 2 - relativeLat) - panoData.croppedY,\n };\n }\n\n /**\n * @summary Converts spherical radians coordinates to a THREE.Vector3\n * @param {PSV.Position} position\n * @param {external:THREE.Vector3} [vector]\n * @returns {external:THREE.Vector3}\n */\n sphericalCoordsToVector3(position, vector) {\n if (!vector) {\n vector = new THREE.Vector3();\n }\n vector.x = SPHERE_RADIUS * -Math.cos(position.latitude) * Math.sin(position.longitude);\n vector.y = SPHERE_RADIUS * Math.sin(position.latitude);\n vector.z = SPHERE_RADIUS * Math.cos(position.latitude) * Math.cos(position.longitude);\n return vector;\n }\n\n /**\n * @summary Converts a THREE.Vector3 to spherical radians coordinates\n * @param {external:THREE.Vector3} vector\n * @returns {PSV.Position}\n */\n vector3ToSphericalCoords(vector) {\n const phi = Math.acos(vector.y / Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z));\n const theta = Math.atan2(vector.x, vector.z);\n\n return {\n longitude: theta < 0 ? -theta : Math.PI * 2 - theta,\n latitude : Math.PI / 2 - phi,\n };\n }\n\n /**\n * @summary Converts position on the viewer to a THREE.Vector3\n * @param {PSV.Point} viewerPoint\n * @returns {external:THREE.Vector3}\n */\n viewerCoordsToVector3(viewerPoint) {\n const sphereIntersect = this.getIntersections(viewerPoint).filter(i => i.object.userData[MESH_USER_DATA]);\n\n if (sphereIntersect) {\n return sphereIntersect.point;\n }\n else {\n return null;\n }\n }\n\n /**\n * @summary Converts a THREE.Vector3 to position on the viewer\n * @param {external:THREE.Vector3} vector\n * @returns {PSV.Point}\n */\n vector3ToViewerCoords(vector) {\n const vectorClone = vector.clone();\n vectorClone.project(this.psv.renderer.camera);\n\n return {\n x: Math.round((vectorClone.x + 1) / 2 * this.prop.size.width),\n y: Math.round((1 - vectorClone.y) / 2 * this.prop.size.height),\n };\n }\n\n /**\n * @summary Converts spherical radians coordinates to position on the viewer\n * @param {PSV.Position} position\n * @returns {PSV.Point}\n */\n sphericalCoordsToViewerCoords(position) {\n return this.vector3ToViewerCoords(this.sphericalCoordsToVector3(position, vector3));\n }\n\n /**\n * @summary Returns intersections with objects in the scene\n * @param {PSV.Point} viewerPoint\n * @return {external:THREE.Intersection[]}\n */\n getIntersections(viewerPoint) {\n vector2.x = 2 * viewerPoint.x / this.prop.size.width - 1;\n vector2.y = -2 * viewerPoint.y / this.prop.size.height + 1;\n\n this.psv.renderer.raycaster.setFromCamera(vector2, this.psv.renderer.camera);\n\n return this.psv.renderer.raycaster.intersectObjects(this.psv.renderer.scene.children, true)\n .filter(i => !!i.object.userData);\n }\n\n /**\n * @summary Converts x/y to latitude/longitude if present and ensure boundaries\n * @param {PSV.ExtendedPosition} position\n * @returns {PSV.Position}\n */\n cleanPosition(position) {\n if (position.x !== undefined && position.y !== undefined) {\n return this.textureCoordsToSphericalCoords(position);\n }\n else {\n return {\n longitude: parseAngle(position.longitude),\n latitude : parseAngle(position.latitude, true),\n };\n }\n }\n\n /**\n * @summary Ensure a SphereCorrection object is valid\n * @param {PSV.SphereCorrection} sphereCorrection\n * @returns {PSV.SphereCorrection}\n */\n cleanSphereCorrection(sphereCorrection) {\n return {\n pan : parseAngle(sphereCorrection?.pan || 0),\n tilt: parseAngle(sphereCorrection?.tilt || 0, true),\n roll: parseAngle(sphereCorrection?.roll || 0, true, false),\n };\n }\n\n /**\n * @summary Parse the pose angles of the pano data\n * @param {PSV.PanoData} panoData\n * @returns {PSV.SphereCorrection}\n */\n cleanPanoramaPose(panoData) {\n return {\n pan : THREE.Math.degToRad(panoData?.poseHeading || 0),\n tilt: THREE.Math.degToRad(panoData?.posePitch || 0),\n roll: THREE.Math.degToRad(panoData?.poseRoll || 0),\n };\n }\n\n}\n","import * as THREE from 'three';\nimport { Animation } from '../Animation';\nimport {\n ACTIONS,\n CTRLZOOM_TIMEOUT,\n DBLCLICK_DELAY,\n EVENTS,\n IDS,\n INERTIA_WINDOW,\n KEY_CODES,\n LONGTOUCH_DELAY,\n MOVE_THRESHOLD,\n OBJECT_EVENTS,\n TWOFINGERSOVERLAY_DELAY\n} from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport gestureIcon from '../icons/gesture.svg';\nimport mousewheelIcon from '../icons/mousewheel.svg';\nimport {\n clone,\n distance,\n each,\n getClosest,\n getEventKey,\n getPosition,\n isEmpty,\n isFullscreenEnabled,\n normalizeWheel,\n throttle\n} from '../utils';\nimport { PressHandler } from '../utils/PressHandler';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Events handler\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class EventsHandler extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @property {number} moveThreshold - computed threshold based on device pixel ratio\n * @property {boolean} moving - is the user moving\n * @property {boolean} zooming - is the user zooming\n * @property {number} startMouseX - start x position of the click/touch\n * @property {number} startMouseY - start y position of the click/touch\n * @property {number} mouseX - current x position of the cursor\n * @property {number} mouseY - current y position of the cursor\n * @property {number[][]} mouseHistory - list of latest positions of the cursor, [time, x, y]\n * @property {number} pinchDist - distance between fingers when zooming\n * @property {PressHandler} keyHandler\n * @property {boolean} ctrlKeyDown - when the Ctrl key is pressed\n * @property {PSV.ClickData} dblclickData - temporary storage of click data between two clicks\n * @property {number} dblclickTimeout - timeout id for double click\n * @property {number} twofingersTimeout - timeout id for \"two fingers\" overlay\n * @property {number} ctrlZoomTimeout - timeout id for \"ctrol zoom\" overlay\n * @protected\n */\n this.state = {\n moveThreshold : MOVE_THRESHOLD * SYSTEM.pixelRatio,\n keyboardEnabled : false,\n moving : false,\n zooming : false,\n startMouseX : 0,\n startMouseY : 0,\n mouseX : 0,\n mouseY : 0,\n mouseHistory : [],\n pinchDist : 0,\n keyHandler : new PressHandler(),\n ctrlKeyDown : false,\n dblclickData : null,\n dblclickTimeout : null,\n longtouchTimeout : null,\n twofingersTimeout: null,\n ctrlZoomTimeout : null,\n };\n\n /**\n * @summary Throttled wrapper of {@link PSV.Viewer#autoSize}\n * @type {Function}\n * @private\n */\n this.__onResize = throttle(() => this.psv.autoSize(), 50);\n }\n\n /**\n * @summary Initializes event handlers\n * @protected\n */\n init() {\n window.addEventListener('resize', this);\n window.addEventListener('keydown', this);\n window.addEventListener('keyup', this);\n this.psv.container.addEventListener('mouseenter', this);\n this.psv.container.addEventListener('mousedown', this);\n this.psv.container.addEventListener('mouseleave', this);\n this.psv.container.addEventListener('mousemove', this);\n window.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchstart', this);\n this.psv.container.addEventListener('touchmove', this);\n window.addEventListener('touchend', this);\n this.psv.container.addEventListener(SYSTEM.mouseWheelEvent, this);\n\n if (SYSTEM.fullscreenEvent) {\n document.addEventListener(SYSTEM.fullscreenEvent, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n window.removeEventListener('resize', this);\n window.removeEventListener('keydown', this);\n window.removeEventListener('keyup', this);\n this.psv.container.removeEventListener('mouseenter', this);\n this.psv.container.removeEventListener('mousedown', this);\n this.psv.container.removeEventListener('mouseleave', this);\n this.psv.container.removeEventListener('mousemove', this);\n window.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchstart', this);\n this.psv.container.removeEventListener('touchmove', this);\n window.removeEventListener('touchend', this);\n this.psv.container.removeEventListener(SYSTEM.mouseWheelEvent, this);\n\n if (SYSTEM.fullscreenEvent) {\n document.removeEventListener(SYSTEM.fullscreenEvent, this);\n }\n\n clearTimeout(this.state.dblclickTimeout);\n clearTimeout(this.state.longtouchTimeout);\n clearTimeout(this.state.twofingersTimeout);\n clearTimeout(this.state.ctrlZoomTimeout);\n\n delete this.state;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} evt\n * @private\n */\n handleEvent(evt) {\n /* eslint-disable */\n switch (evt.type) {\n // @formatter:off\n case 'resize': this.__onResize(); break;\n case 'keydown': this.__onKeyDown(evt); break;\n case 'keyup': this.__onKeyUp(); break;\n case 'mouseup': this.__onMouseUp(evt); break;\n case 'touchend': this.__onTouchEnd(evt); break;\n case SYSTEM.fullscreenEvent: this.__fullscreenToggled(); break;\n // @formatter:on\n }\n /* eslint-enable */\n\n if (!getClosest(evt.target, '.psv-navbar') && !getClosest(evt.target, '.psv-panel')) {\n /* eslint-disable */\n switch (evt.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(evt); break;\n case 'mouseenter': this.__onMouseEnter(evt); break;\n case 'mouseleave': this.__onMouseLeave(evt); break;\n case 'mousemove': this.__onMouseMove(evt); break;\n case 'touchstart': this.__onTouchStart(evt); break;\n case 'touchmove': this.__onTouchMove(evt); break;\n case SYSTEM.mouseWheelEvent: this.__onMouseWheel(evt); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n }\n\n /**\n * @summary Enables the keyboard controls\n * @protected\n */\n enableKeyboard() {\n this.state.keyboardEnabled = true;\n }\n\n /**\n * @summary Disables the keyboard controls\n * @protected\n */\n disableKeyboard() {\n this.state.keyboardEnabled = false;\n }\n\n /**\n * @summary Handles keyboard events\n * @param {KeyboardEvent} evt\n * @private\n */\n __onKeyDown(evt) {\n const key = getEventKey(evt);\n\n if (this.config.mousewheelCtrlKey) {\n this.state.ctrlKeyDown = key === KEY_CODES.Control;\n\n if (this.state.ctrlKeyDown) {\n clearTimeout(this.state.ctrlZoomTimeout);\n this.psv.overlay.hide(IDS.CTRL_ZOOM);\n }\n }\n\n if (!this.state.keyboardEnabled) {\n return;\n }\n\n if (this.config.keyboard[key] === ACTIONS.TOGGLE_AUTOROTATE) {\n this.psv.toggleAutorotate();\n }\n else if (this.config.keyboard[key] && !this.state.keyHandler.time) {\n /* eslint-disable */\n switch (this.config.keyboard[key]) {\n // @formatter:off\n case ACTIONS.ROTATE_LAT_UP: this.psv.dynamics.position.roll({latitude: false}); break;\n case ACTIONS.ROTATE_LAT_DOWN: this.psv.dynamics.position.roll({latitude: true}); break;\n case ACTIONS.ROTATE_LONG_RIGHT: this.psv.dynamics.position.roll({longitude: false}); break;\n case ACTIONS.ROTATE_LONG_LEFT: this.psv.dynamics.position.roll({longitude: true}); break;\n case ACTIONS.ZOOM_IN: this.psv.dynamics.zoom.roll(false); break;\n case ACTIONS.ZOOM_OUT: this.psv.dynamics.zoom.roll(true); break;\n // @formatter:on\n }\n /* eslint-enable */\n\n this.state.keyHandler.down();\n }\n }\n\n /**\n * @summary Handles keyboard events\n * @private\n */\n __onKeyUp() {\n this.state.ctrlKeyDown = false;\n\n if (!this.state.keyboardEnabled) {\n return;\n }\n\n this.state.keyHandler.up(() => {\n this.psv.dynamics.position.stop();\n this.psv.dynamics.zoom.stop();\n });\n }\n\n /**\n * @summary Handles mouse down events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseDown(evt) {\n if (!this.config.mousemove || this.config.captureCursor) {\n return;\n }\n\n this.__startMove(evt);\n }\n\n /**\n * @summary Handles mouse enter events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseEnter(evt) {\n if (!this.config.mousemove || !this.config.captureCursor) {\n return;\n }\n\n this.__startMove(evt);\n }\n\n /**\n * @summary Handles mouse up events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseUp(evt) {\n if (!this.config.mousemove || this.config.captureCursor) {\n return;\n }\n\n this.__stopMove(evt);\n }\n\n /**\n * @summary Handles mouse leave events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseLeave(evt) {\n if (!this.config.mousemove || !this.config.captureCursor) {\n return;\n }\n\n this.__stopMove(evt);\n }\n\n /**\n * @summary Handles mouse move events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseMove(evt) {\n if (this.config.mousemove) {\n if (evt.buttons !== 0) {\n evt.preventDefault();\n this.__move(evt);\n }\n else if (this.config.captureCursor) {\n this.__moveAbsolute(evt);\n }\n }\n\n if (!isEmpty(this.prop.objectsObservers)) {\n const viewerPos = getPosition(this.psv.container);\n\n const viewerPoint = {\n x: evt.clientX - viewerPos.left,\n y: evt.clientY - viewerPos.top,\n };\n\n const intersections = this.psv.dataHelper.getIntersections(viewerPoint);\n\n const emit = (observer, key, type) => {\n observer.listener.handleEvent(new CustomEvent(type, {\n detail: {\n originalEvent: evt,\n object : observer.object,\n data : observer.object.userData[key],\n viewerPoint : viewerPoint,\n },\n }));\n };\n\n each(this.prop.objectsObservers, (observer, key) => {\n const intersection = intersections.find(i => i.object.userData[key]);\n\n if (intersection) {\n if (observer.object && intersection.object !== observer.object) {\n emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT);\n delete observer.object;\n }\n\n if (!observer.object) {\n observer.object = intersection.object;\n emit(observer, key, OBJECT_EVENTS.ENTER_OBJECT);\n }\n else {\n emit(observer, key, OBJECT_EVENTS.HOVER_OBJECT);\n }\n }\n else if (observer.object) {\n emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT);\n delete observer.object;\n }\n });\n }\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchStart(evt) {\n if (!this.config.mousemove) {\n return;\n }\n\n if (evt.touches.length === 1) {\n if (!this.config.touchmoveTwoFingers) {\n this.__startMove(evt.touches[0]);\n evt.preventDefault(); // prevent mouse events emulation\n }\n\n if (!this.prop.longtouchTimeout) {\n this.prop.longtouchTimeout = setTimeout(() => {\n this.__click(evt.touches[0], true);\n this.prop.longtouchTimeout = null;\n }, LONGTOUCH_DELAY);\n }\n }\n else if (evt.touches.length === 2) {\n this.__cancelLongTouch();\n this.__cancelTwoFingersOverlay();\n this.__startMoveZoom(evt);\n evt.preventDefault();\n }\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchEnd(evt) {\n if (!this.config.mousemove) {\n return;\n }\n\n this.__cancelLongTouch();\n this.__cancelTwoFingersOverlay();\n\n if (evt.touches.length === 1) {\n this.__stopMoveZoom();\n }\n else if (evt.touches.length === 0) {\n this.__stopMove(evt.changedTouches[0]);\n }\n }\n\n /**\n * @summary Handles touch move events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchMove(evt) {\n if (!this.config.mousemove) {\n return;\n }\n\n this.__cancelLongTouch();\n\n if (evt.touches.length === 1) {\n if (this.config.touchmoveTwoFingers) {\n if (!this.prop.twofingersTimeout) {\n this.prop.twofingersTimeout = setTimeout(() => {\n this.psv.overlay.show({\n id : IDS.TWO_FINGERS,\n image: gestureIcon,\n text : this.config.lang.twoFingers,\n });\n }, TWOFINGERSOVERLAY_DELAY);\n }\n }\n else {\n evt.preventDefault();\n this.__move(evt.touches[0]);\n }\n }\n else if (evt.touches.length === 2) {\n evt.preventDefault();\n this.__moveZoom(evt);\n this.__cancelTwoFingersOverlay();\n }\n }\n\n /**\n * @summary Cancel the long touch timer if any\n * @private\n */\n __cancelLongTouch() {\n if (this.prop.longtouchTimeout) {\n clearTimeout(this.prop.longtouchTimeout);\n this.prop.longtouchTimeout = null;\n }\n }\n\n /**\n * @summary Cancel the two fingers overlay timer if any\n * @private\n */\n __cancelTwoFingersOverlay() {\n if (this.prop.twofingersTimeout) {\n clearTimeout(this.prop.twofingersTimeout);\n this.prop.twofingersTimeout = null;\n }\n this.psv.overlay.hide(IDS.TWO_FINGERS);\n }\n\n /**\n * @summary Handles mouse wheel events\n * @param {WheelEvent} evt\n * @private\n */\n __onMouseWheel(evt) {\n if (!this.config.mousewheel) {\n return;\n }\n\n if (this.config.mousewheelCtrlKey && !this.state.ctrlKeyDown) {\n this.psv.overlay.show({\n id : IDS.CTRL_ZOOM,\n image: mousewheelIcon,\n text : this.config.lang.ctrlZoom,\n });\n\n clearTimeout(this.state.ctrlZoomTimeout);\n this.state.ctrlZoomTimeout = setTimeout(() => this.psv.overlay.hide(IDS.CTRL_ZOOM), CTRLZOOM_TIMEOUT);\n\n return;\n }\n\n evt.preventDefault();\n evt.stopPropagation();\n\n const delta = normalizeWheel(evt).spinY * 5 * this.config.zoomSpeed;\n if (delta !== 0) {\n this.psv.dynamics.zoom.step(-delta, 5);\n }\n }\n\n /**\n * @summary Handles fullscreen events\n * @param {boolean} [force] force state\n * @fires PSV.fullscreen-updated\n * @package\n */\n __fullscreenToggled(force) {\n this.prop.fullscreen = force !== undefined ? force : isFullscreenEnabled(this.psv.container);\n\n if (this.config.keyboard) {\n if (this.prop.fullscreen) {\n this.psv.startKeyboardControl();\n }\n else {\n this.psv.stopKeyboardControl();\n }\n }\n\n this.psv.trigger(EVENTS.FULLSCREEN_UPDATED, this.prop.fullscreen);\n }\n\n /**\n * @summary Initializes the movement\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __startMove(evt) {\n this.psv.stopAutorotate();\n this.psv.stopAnimation()\n .then(() => {\n this.state.mouseX = evt.clientX;\n this.state.mouseY = evt.clientY;\n this.state.startMouseX = this.state.mouseX;\n this.state.startMouseY = this.state.mouseY;\n this.state.moving = true;\n this.state.zooming = false;\n\n this.state.mouseHistory.length = 0;\n this.__logMouseMove(evt);\n });\n }\n\n /**\n * @summary Initializes the combines move and zoom\n * @param {TouchEvent} evt\n * @private\n */\n __startMoveZoom(evt) {\n const p1 = { x: evt.touches[0].clientX, y: evt.touches[0].clientY };\n const p2 = { x: evt.touches[1].clientX, y: evt.touches[1].clientY };\n\n this.state.pinchDist = distance(p1, p2);\n this.state.mouseX = (p1.x + p2.x) / 2;\n this.state.mouseY = (p1.y + p2.y) / 2;\n this.state.startMouseX = this.state.mouseX;\n this.state.startMouseY = this.state.mouseY;\n this.state.moving = true;\n this.state.zooming = true;\n }\n\n /**\n * @summary Stops the movement\n * @description If the move threshold was not reached a click event is triggered, otherwise an animation is launched to simulate inertia\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __stopMove(evt) {\n if (!getClosest(evt.target, '.psv-container')) {\n this.state.moving = false;\n this.state.mouseHistory.length = 0;\n return;\n }\n\n if (this.state.moving) {\n // move threshold to trigger a click\n if (Math.abs(evt.clientX - this.state.startMouseX) < this.state.moveThreshold\n && Math.abs(evt.clientY - this.state.startMouseY) < this.state.moveThreshold) {\n this.__click(evt);\n this.state.moving = false;\n }\n // inertia animation\n else if (this.config.moveInertia) {\n this.__logMouseMove(evt);\n this.__stopMoveInertia(evt);\n }\n else {\n this.state.moving = false;\n }\n\n this.state.mouseHistory.length = 0;\n }\n }\n\n /**\n * @summary Stops the combined move and zoom\n * @private\n */\n __stopMoveZoom() {\n this.state.mouseHistory.length = 0;\n this.state.moving = false;\n this.state.zooming = false;\n }\n\n /**\n * @summary Performs an animation to simulate inertia when the movement stops\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __stopMoveInertia(evt) {\n const direction = {\n x: evt.clientX - this.state.mouseHistory[0][1],\n y: evt.clientY - this.state.mouseHistory[0][2],\n };\n\n const norm = Math.sqrt(direction.x * direction.x + direction.y * direction.y);\n\n this.prop.animationPromise = new Animation({\n properties: {\n clientX: { start: evt.clientX, end: evt.clientX + direction.x },\n clientY: { start: evt.clientY, end: evt.clientY + direction.y },\n },\n duration : norm * INERTIA_WINDOW / 100,\n easing : 'outCirc',\n onTick : (properties) => {\n this.__move(properties, false);\n },\n });\n\n this.prop.animationPromise\n .then(() => {\n this.state.moving = false;\n });\n }\n\n /**\n * @summary Triggers an event with all coordinates when a simple click is performed\n * @param {MouseEvent|Touch} evt\n * @param {boolean} [longtouch=false]\n * @fires PSV.click\n * @fires PSV.dblclick\n * @private\n */\n __click(evt, longtouch = false) {\n const boundingRect = this.psv.container.getBoundingClientRect();\n\n /**\n * @type {PSV.ClickData}\n */\n const data = {\n rightclick: longtouch || evt.button === 2,\n target : evt.target,\n clientX : evt.clientX,\n clientY : evt.clientY,\n viewerX : evt.clientX - boundingRect.left,\n viewerY : evt.clientY - boundingRect.top,\n };\n\n const intersections = this.psv.dataHelper.getIntersections({\n x: data.viewerX,\n y: data.viewerY,\n });\n\n const sphereIntersection = intersections.find(i => i.object.userData.psvSphere);\n\n if (sphereIntersection) {\n const sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(sphereIntersection.point);\n data.longitude = sphericalCoords.longitude;\n data.latitude = sphericalCoords.latitude;\n\n data.objects = intersections.map(i => i.object).filter(o => !o.userData.psvSphere);\n\n try {\n const textureCoords = this.psv.dataHelper.sphericalCoordsToTextureCoords(data);\n data.textureX = textureCoords.x;\n data.textureY = textureCoords.y;\n }\n catch (e) {\n data.textureX = NaN;\n data.textureY = NaN;\n }\n\n if (!this.state.dblclickTimeout) {\n this.psv.trigger(EVENTS.CLICK, data);\n\n this.state.dblclickData = clone(data);\n this.state.dblclickTimeout = setTimeout(() => {\n this.state.dblclickTimeout = null;\n this.state.dblclickData = null;\n }, DBLCLICK_DELAY);\n }\n else {\n if (Math.abs(this.state.dblclickData.clientX - data.clientX) < this.state.moveThreshold\n && Math.abs(this.state.dblclickData.clientY - data.clientY) < this.state.moveThreshold) {\n this.psv.trigger(EVENTS.DOUBLE_CLICK, this.state.dblclickData);\n }\n\n clearTimeout(this.state.dblclickTimeout);\n this.state.dblclickTimeout = null;\n this.state.dblclickData = null;\n }\n }\n }\n\n /**\n * @summary Performs movement\n * @param {MouseEvent|Touch} evt\n * @param {boolean} [log=true]\n * @private\n */\n __move(evt, log) {\n if (this.state.moving) {\n const x = evt.clientX;\n const y = evt.clientY;\n\n const rotation = {\n longitude: (x - this.state.mouseX) / this.prop.size.width * this.config.moveSpeed * THREE.Math.degToRad(this.prop.hFov),\n latitude : (y - this.state.mouseY) / this.prop.size.height * this.config.moveSpeed * THREE.Math.degToRad(this.prop.vFov),\n };\n\n const currentPosition = this.psv.getPosition();\n this.psv.rotate({\n longitude: currentPosition.longitude - rotation.longitude,\n latitude : currentPosition.latitude + rotation.latitude,\n });\n\n this.state.mouseX = x;\n this.state.mouseY = y;\n\n if (log !== false) {\n this.__logMouseMove(evt);\n }\n }\n }\n\n /**\n * @summary Performs movement absolute to cursor position in viewer\n * @param {MouseEvent} evt\n * @private\n */\n __moveAbsolute(evt) {\n if (this.state.moving) {\n const containerRect = this.psv.container.getBoundingClientRect();\n this.psv.dynamics.position.goto({\n longitude: ((evt.clientX - containerRect.left) / containerRect.width - 0.5) * Math.PI * 2,\n latitude : -((evt.clientY - containerRect.top) / containerRect.height - 0.5) * Math.PI,\n }, 10);\n }\n }\n\n /**\n * @summary Perfoms combined move and zoom\n * @param {TouchEvent} evt\n * @private\n */\n __moveZoom(evt) {\n if (this.state.zooming && this.state.moving) {\n const p1 = { x: evt.touches[0].clientX, y: evt.touches[0].clientY };\n const p2 = { x: evt.touches[1].clientX, y: evt.touches[1].clientY };\n\n const p = distance(p1, p2);\n const delta = 80 * (p - this.state.pinchDist) / this.prop.size.width * this.config.zoomSpeed;\n\n this.psv.zoom(this.psv.getZoomLevel() + delta);\n\n this.__move({\n clientX: (p1.x + p2.x) / 2,\n clientY: (p1.y + p2.y) / 2,\n });\n\n this.state.pinchDist = p;\n }\n }\n\n /**\n * @summary Stores each mouse position during a mouse move\n * @description Positions older than \"INERTIA_WINDOW\" are removed
\n * Positions before a pause of \"INERTIA_WINDOW\" / 10 are removed\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __logMouseMove(evt) {\n const now = Date.now();\n this.state.mouseHistory.push([now, evt.clientX, evt.clientY]);\n\n let previous = null;\n\n for (let i = 0; i < this.state.mouseHistory.length;) {\n if (this.state.mouseHistory[0][i] < now - INERTIA_WINDOW) {\n this.state.mouseHistory.splice(i, 1);\n }\n else if (previous && this.state.mouseHistory[0][i] - previous > INERTIA_WINDOW / 10) {\n this.state.mouseHistory.splice(0, i);\n i = 0;\n previous = this.state.mouseHistory[0][i];\n }\n else {\n i++;\n previous = this.state.mouseHistory[0][i];\n }\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { Animation } from '../Animation';\nimport { EVENTS, MESH_USER_DATA, SPHERE_RADIUS } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { each, isExtendedPosition } from '../utils';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Viewer and renderer\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class Renderer extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @member {external:THREE.WebGLRenderer}\n * @readonly\n * @protected\n */\n this.renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });\n this.renderer.setPixelRatio(SYSTEM.pixelRatio);\n this.renderer.domElement.className = 'psv-canvas';\n\n /**\n * @member {external:THREE.Scene}\n * @readonly\n * @protected\n */\n this.scene = new THREE.Scene();\n\n /**\n * @member {external:THREE.PerspectiveCamera}\n * @readonly\n * @protected\n */\n this.camera = new THREE.PerspectiveCamera(50, 16 / 9, 1, 2 * SPHERE_RADIUS);\n\n /**\n * @member {external:THREE.Mesh}\n * @readonly\n * @protected\n */\n this.mesh = this.psv.adapter.createMesh();\n this.mesh.userData = { [MESH_USER_DATA]: true };\n\n /**\n * @member {external:THREE.Group}\n * @readonly\n * @private\n */\n this.meshContainer = new THREE.Group();\n this.meshContainer.add(this.mesh);\n this.scene.add(this.meshContainer);\n\n /**\n * @member {external:THREE.Raycaster}\n * @readonly\n * @protected\n */\n this.raycaster = new THREE.Raycaster();\n\n /**\n * @member {number}\n * @private\n */\n this.timestamp = null;\n\n /**\n * @member {boolean}\n * @private\n */\n this.ready = false;\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @package\n */\n this.canvasContainer = document.createElement('div');\n this.canvasContainer.className = 'psv-canvas-container';\n this.canvasContainer.style.background = this.psv.config.canvasBackground;\n this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n this.canvasContainer.appendChild(this.renderer.domElement);\n this.psv.container.appendChild(this.canvasContainer);\n\n psv.on(EVENTS.SIZE_UPDATED, this);\n psv.on(EVENTS.ZOOM_UPDATED, this);\n psv.on(EVENTS.POSITION_UPDATED, this);\n psv.on(EVENTS.CONFIG_CHANGED, this);\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n // cancel render loop\n this.renderer.setAnimationLoop(null);\n\n // destroy ThreeJS view\n this.__cleanTHREEScene(this.scene);\n\n // remove container\n this.psv.container.removeChild(this.canvasContainer);\n\n delete this.canvasContainer;\n delete this.renderer;\n delete this.scene;\n delete this.camera;\n delete this.mesh;\n delete this.meshContainer;\n delete this.raycaster;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} evt\n * @private\n */\n handleEvent(evt) {\n /* eslint-disable */\n switch (evt.type) {\n // @formatter:off\n case EVENTS.SIZE_UPDATED: this.__onSizeUpdated(); break;\n case EVENTS.ZOOM_UPDATED: this.__onZoomUpdated(); break;\n case EVENTS.POSITION_UPDATED: this.__onPositionUpdated(); break;\n case EVENTS.CONFIG_CHANGED:\n if (evt.args[0].indexOf('fisheye') !== -1) {\n this.__onPositionUpdated();\n }\n if (evt.args[0].indexOf('mousemove') !== -1) {\n this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n }\n break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Hides the viewer\n */\n hide() {\n this.canvasContainer.style.opacity = 0;\n }\n\n /**\n * @summary Shows the viewer\n */\n show() {\n this.canvasContainer.style.opacity = 1;\n }\n\n /**\n * @summary Updates the size of the renderer and the aspect of the camera\n * @private\n */\n __onSizeUpdated() {\n this.renderer.setSize(this.prop.size.width, this.prop.size.height);\n this.camera.aspect = this.prop.aspect;\n this.camera.updateProjectionMatrix();\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Updates the fov of the camera\n * @private\n */\n __onZoomUpdated() {\n this.camera.fov = this.prop.vFov;\n this.camera.updateProjectionMatrix();\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Updates the position of the camera\n * @private\n */\n __onPositionUpdated() {\n this.camera.position.set(0, 0, 0);\n this.camera.lookAt(this.prop.direction);\n if (this.config.fisheye) {\n this.camera.position.copy(this.prop.direction).multiplyScalar(this.config.fisheye / 2).negate();\n }\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Main event loop, calls {@link render} if `prop.needsUpdate` is true\n * @param {number} timestamp\n * @fires PSV.before-render\n * @private\n */\n __renderLoop(timestamp) {\n const elapsed = this.timestamp !== null ? timestamp - this.timestamp : 0;\n this.timestamp = timestamp;\n\n this.psv.trigger(EVENTS.BEFORE_RENDER, timestamp, elapsed);\n each(this.psv.dynamics, d => d.update(elapsed));\n\n if (this.prop.needsUpdate) {\n this.render();\n this.prop.needsUpdate = false;\n }\n }\n\n /**\n * @summary Performs a render\n * @description Do not call this method directly, instead call\n * {@link PSV.Viewer#needsUpdate} on {@link PSV.event:before-render}.\n * @fires PSV.render\n */\n render() {\n this.renderer.render(this.scene, this.camera);\n this.psv.trigger(EVENTS.RENDER);\n }\n\n /**\n * @summary Applies the texture to the scene, creates the scene if needed\n * @param {PSV.TextureData} textureData\n * @fires PSV.panorama-loaded\n * @package\n */\n setTexture(textureData) {\n this.prop.panoData = textureData.panoData;\n\n this.psv.adapter.setTexture(this.mesh, textureData);\n\n if (!this.ready) {\n this.renderer.setAnimationLoop(t => this.__renderLoop(t));\n this.ready = true;\n }\n\n this.psv.needsUpdate();\n\n this.psv.trigger(EVENTS.PANORAMA_LOADED);\n }\n\n /**\n * @summary Apply a panorama data pose to a Mesh\n * @param {PSV.PanoData} [panoData]\n * @param {external:THREE.Mesh} [mesh=this.mesh]\n * @package\n */\n setPanoramaPose(panoData, mesh = this.mesh) {\n // By Google documentation the angles are applied on the camera in order : heading, pitch, roll\n // here we apply the reverse transformation on the sphere\n const cleanCorrection = this.psv.dataHelper.cleanPanoramaPose(panoData);\n\n mesh.rotation.set(\n -cleanCorrection.tilt,\n -cleanCorrection.pan,\n -cleanCorrection.roll,\n 'ZXY'\n );\n }\n\n /**\n * @summary Apply a SphereCorrection to a Mesh\n * @param {PSV.SphereCorrection} [sphereCorrection]\n * @param {external:THREE.Mesh} [mesh=this.meshContainer]\n * @package\n */\n setSphereCorrection(sphereCorrection, mesh = this.meshContainer) {\n const cleanCorrection = this.psv.dataHelper.cleanSphereCorrection(sphereCorrection);\n\n mesh.rotation.set(\n cleanCorrection.tilt,\n cleanCorrection.pan,\n cleanCorrection.roll,\n 'ZXY'\n );\n }\n\n /**\n * @summary Performs transition between the current and a new texture\n * @param {PSV.TextureData} textureData\n * @param {PSV.PanoramaOptions} options\n * @returns {PSV.Animation}\n * @package\n */\n transition(textureData, options) {\n const positionProvided = isExtendedPosition(options);\n const zoomProvided = 'zoom' in options;\n\n // create temp group and new mesh, half size to be in \"front\" of the first one\n const group = new THREE.Group();\n const mesh = this.psv.adapter.createMesh(0.5);\n this.psv.adapter.setTexture(mesh, textureData, true);\n this.psv.adapter.setTextureOpacity(mesh, 0);\n this.setPanoramaPose(textureData.panoData, mesh);\n this.setSphereCorrection(options.sphereCorrection, group);\n\n // rotate the new sphere to make the target position face the camera\n if (positionProvided) {\n const cleanPosition = this.psv.dataHelper.cleanPosition(options);\n const currentPosition = this.psv.getPosition();\n\n // Longitude rotation along the vertical axis\n const verticalAxis = new THREE.Vector3(0, 1, 0);\n group.rotateOnWorldAxis(verticalAxis, cleanPosition.longitude - currentPosition.longitude);\n\n // Latitude rotation along the camera horizontal axis\n const horizontalAxis = new THREE.Vector3(0, 1, 0).cross(this.camera.getWorldDirection(new THREE.Vector3())).normalize();\n group.rotateOnWorldAxis(horizontalAxis, cleanPosition.latitude - currentPosition.latitude);\n }\n\n group.add(mesh);\n this.scene.add(group);\n\n const animation = new Animation({\n properties: {\n opacity: { start: 0.0, end: 1.0 },\n zoom : zoomProvided ? { start: this.psv.getZoomLevel(), end: options.zoom } : undefined,\n },\n duration : options.transition,\n easing : 'outCubic',\n onTick : (properties) => {\n this.psv.adapter.setTextureOpacity(mesh, properties.opacity);\n this.psv.adapter.setTextureOpacity(this.mesh, 1 - properties.opacity);\n\n if (zoomProvided) {\n this.psv.zoom(properties.zoom);\n }\n\n this.psv.needsUpdate();\n },\n });\n\n animation\n .then((completed) => {\n if (completed) {\n // remove temp sphere and transfer the texture to the main mesh\n this.setTexture(textureData);\n this.psv.adapter.setTextureOpacity(this.mesh, 1);\n this.setPanoramaPose(textureData.panoData);\n this.setSphereCorrection(options.sphereCorrection);\n\n // actually rotate the camera\n if (positionProvided) {\n this.psv.rotate(options);\n }\n }\n else {\n this.psv.adapter.disposeTexture(textureData);\n }\n\n this.scene.remove(group);\n mesh.geometry.dispose();\n mesh.geometry = null;\n });\n\n return animation;\n }\n\n /**\n * @summary Calls `dispose` on all objects and textures\n * @param {external:THREE.Object3D} object\n * @private\n */\n __cleanTHREEScene(object) {\n object.traverse((item) => {\n if (item.geometry) {\n item.geometry.dispose();\n }\n\n if (item.material) {\n if (Array.isArray(item.material)) {\n item.material.forEach((material) => {\n if (material.map) {\n material.map.dispose();\n }\n\n material.dispose();\n });\n }\n else {\n if (item.material.map) {\n item.material.map.dispose();\n }\n\n item.material.dispose();\n }\n }\n\n if (item.dispose && !(item instanceof THREE.Scene)) {\n item.dispose();\n }\n\n if (item !== object) {\n this.__cleanTHREEScene(item);\n }\n });\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Texture loader\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class TextureLoader extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @summary THREE file loader\n * @type {external:THREE:FileLoader}\n * @private\n */\n this.loader = new THREE.FileLoader();\n this.loader.setResponseType('blob');\n if (this.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.config.requestHeaders && typeof this.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.config.requestHeaders);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n this.abortLoading();\n super.destroy();\n }\n\n /**\n * @summary Loads the panorama texture(s)\n * @param {*} panorama\n * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData]\n * @returns {Promise.}\n * @throws {PSV.PSVError} when the image cannot be loaded\n * @package\n * @deprecated\n */\n loadTexture(panorama, newPanoData) {\n return this.psv.adapter.loadTexture(panorama, newPanoData);\n }\n\n /**\n * @summary Cancels current HTTP requests\n * @package\n */\n abortLoading() {\n // noop implementation waiting for https://github.com/mrdoob/three.js/pull/23070\n }\n\n /**\n * @summary Loads a Blob with FileLoader\n * @param {string} url\n * @param {function(number)} [onProgress]\n * @returns {Promise}\n */\n loadFile(url, onProgress) {\n if (this.config.requestHeaders && typeof this.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.config.requestHeaders(url));\n }\n\n return new Promise((resolve, reject) => {\n let progress = 0;\n onProgress && onProgress(progress);\n\n this.loader.load(\n url,\n (result) => {\n progress = 100;\n onProgress && onProgress(progress);\n resolve(result);\n },\n (e) => {\n if (e.lengthComputable) {\n const newProgress = e.loaded / e.total * 100;\n if (newProgress > progress) {\n progress = newProgress;\n onProgress && onProgress(progress);\n }\n }\n },\n (err) => {\n reject(err);\n }\n );\n });\n }\n\n /**\n * @summary Loads an Image using FileLoader to have progress events\n * @param {string} url\n * @param {function(number)} [onProgress]\n * @returns {Promise}\n */\n loadImage(url, onProgress) {\n return this.loadFile(url, onProgress)\n .then(result => new Promise((resolve, reject) => {\n const img = document.createElementNS('http://www.w3.org/1999/xhtml', 'img');\n img.onload = () => {\n URL.revokeObjectURL(img.src);\n resolve(img);\n };\n img.onerror = reject;\n img.src = URL.createObjectURL(result);\n }));\n }\n\n /**\n * @summary Preload a panorama file without displaying it\n * @param {*} panorama\n * @returns {Promise}\n */\n preloadPanorama(panorama) {\n if (this.psv.adapter.supportsPreload(panorama)) {\n return this.psv.adapter.loadTexture(panorama);\n }\n else {\n return Promise.resolve();\n }\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { addClasses, cleanPosition } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\n\nconst STATE = { NONE: 0, SHOWING: 1, HIDING: 2, READY: 3 };\n\n/**\n * @typedef {Object} PSV.components.Tooltip.Position\n * @summary Object defining the tooltip position\n * @property {number} top - Position of the tip of the arrow of the tooltip, in pixels\n * @property {number} left - Position of the tip of the arrow of the tooltip, in pixels\n * @property {string|string[]} [position='top center'] - Tooltip position toward it's arrow tip.\n * Accepted values are combinations of `top`, `center`, `bottom` and `left`, `center`, `right`\n * @property {Object} [box] - Used when displaying a tooltip on a marker\n * @property {number} [box.width=0]\n * @property {number} [box.height=0]\n */\n\n/**\n * @typedef {PSV.components.Tooltip.Position} PSV.components.Tooltip.Config\n * @summary Object defining the tooltip configuration\n * @property {string} content - HTML content of the tooltip\n * @property {string} [className] - Additional CSS class added to the tooltip\n * @property {*} [data] - Userdata associated to the tooltip\n */\n\n/**\n * @summary Tooltip component\n * @description Never instanciate tooltips directly use {@link PSV.services.TooltipRenderer} instead\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Tooltip extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n * @param {{arrow: number, offset: number}} size\n */\n constructor(psv, size) {\n super(psv, 'psv-tooltip');\n\n /**\n * @override\n * @property {number} arrow\n * @property {number} offset\n * @property {number} width\n * @property {number} height\n * @property {string} pos\n * @property {string} state\n * @property {*} data\n */\n this.prop = {\n ...this.prop,\n ...size,\n state : STATE.NONE,\n width : 0,\n height: 0,\n pos : '',\n data : null,\n };\n\n /**\n * Tooltip content\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-tooltip-content';\n this.container.appendChild(this.content);\n\n /**\n * Tooltip arrow\n * @member {HTMLElement}\n * @readonly\n * @package\n */\n this.arrow = document.createElement('div');\n this.arrow.className = 'psv-tooltip-arrow';\n this.container.appendChild(this.arrow);\n\n this.container.addEventListener('transitionend', this);\n\n this.container.style.top = '-1000px';\n this.container.style.left = '-1000px';\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.arrow;\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'transitionend': this.__onTransitionEnd(e); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Tooltip cannot be toggled');\n }\n\n /**\n * @summary Displays the tooltip on the viewer\n * Do not call this method directly, use {@link PSV.services.TooltipRenderer} instead.\n * @param {PSV.components.Tooltip.Config} config\n *\n * @fires PSV.show-tooltip\n * @throws {PSV.PSVError} when the configuration is incorrect\n *\n * @package\n */\n show(config) {\n if (this.prop.state !== STATE.NONE) {\n throw new PSVError('Initialized tooltip cannot be re-initialized');\n }\n\n if (config.className) {\n addClasses(this.container, config.className);\n }\n\n this.content.innerHTML = config.content;\n\n const rect = this.container.getBoundingClientRect();\n this.prop.width = rect.right - rect.left;\n this.prop.height = rect.bottom - rect.top;\n\n this.prop.state = STATE.READY;\n\n this.move(config);\n\n this.prop.data = config.data;\n this.prop.state = STATE.SHOWING;\n\n this.psv.trigger(EVENTS.SHOW_TOOLTIP, this.prop.data, this);\n }\n\n /**\n * @summary Moves the tooltip to a new position\n * @param {PSV.components.Tooltip.Position} config\n *\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n move(config) {\n if (this.prop.state !== STATE.SHOWING && this.prop.state !== STATE.READY) {\n throw new PSVError('Uninitialized tooltip cannot be moved');\n }\n\n const t = this.container;\n const a = this.arrow;\n\n // compute size\n const style = {\n posClass : cleanPosition(config.position, 'top center', false),\n width : this.prop.width,\n height : this.prop.height,\n top : 0,\n left : 0,\n arrowTop : 0,\n arrowLeft: 0,\n };\n\n // set initial position\n this.__computeTooltipPosition(style, config);\n\n // correct position if overflow\n let refresh = false;\n if (style.top < this.prop.offset) {\n style.posClass[0] = 'bottom';\n refresh = true;\n }\n else if (style.top + style.height > this.psv.prop.size.height - this.prop.offset) {\n style.posClass[0] = 'top';\n refresh = true;\n }\n if (style.left < this.prop.offset) {\n style.posClass[1] = 'right';\n refresh = true;\n }\n else if (style.left + style.width > this.psv.prop.size.width - this.prop.offset) {\n style.posClass[1] = 'left';\n refresh = true;\n }\n if (refresh) {\n this.__computeTooltipPosition(style, config);\n }\n\n // apply position\n t.style.top = style.top + 'px';\n t.style.left = style.left + 'px';\n\n a.style.top = style.arrowTop + 'px';\n a.style.left = style.arrowLeft + 'px';\n\n const newPos = style.posClass.join('-');\n if (newPos !== this.prop.pos) {\n t.classList.remove(`psv-tooltip--${this.prop.pos}`);\n\n this.prop.pos = newPos;\n t.classList.add(`psv-tooltip--${this.prop.pos}`);\n }\n }\n\n /**\n * @summary Hides the tooltip\n * @fires PSV.hide-tooltip\n */\n hide() {\n this.container.classList.remove('psv-tooltip--visible');\n this.prop.state = STATE.HIDING;\n\n this.psv.trigger(EVENTS.HIDE_TOOLTIP, this.prop.data);\n }\n\n /**\n * @summary Finalize transition\n * @param {TransitionEvent} e\n * @private\n */\n __onTransitionEnd(e) {\n if (e.propertyName === 'transform') {\n switch (this.prop.state) {\n case STATE.SHOWING:\n this.container.classList.add('psv-tooltip--visible');\n this.prop.state = STATE.READY;\n break;\n\n case STATE.HIDING:\n this.prop.state = STATE.NONE;\n this.destroy();\n break;\n\n default:\n // nothing\n }\n }\n }\n\n /**\n * @summary Computes the position of the tooltip and its arrow\n * @param {Object} style\n * @param {Object} config\n * @private\n */\n __computeTooltipPosition(style, config) {\n let topBottom = false;\n\n if (!config.box) {\n config.box = {\n width : 0,\n height: 0,\n };\n }\n\n switch (style.posClass[0]) {\n case 'bottom':\n style.top = config.top + config.box.height + this.prop.offset + this.prop.arrow;\n style.arrowTop = -this.prop.arrow * 2;\n topBottom = true;\n break;\n\n case 'center':\n style.top = config.top + config.box.height / 2 - style.height / 2;\n style.arrowTop = style.height / 2 - this.prop.arrow;\n break;\n\n case 'top':\n style.top = config.top - style.height - this.prop.offset - this.prop.arrow;\n style.arrowTop = style.height;\n topBottom = true;\n break;\n\n // no default\n }\n\n switch (style.posClass[1]) {\n case 'right':\n if (topBottom) {\n style.left = config.left + config.box.width / 2 - this.prop.offset - this.prop.arrow;\n style.arrowLeft = this.prop.offset;\n }\n else {\n style.left = config.left + config.box.width + this.prop.offset + this.prop.arrow;\n style.arrowLeft = -this.prop.arrow * 2;\n }\n break;\n\n case 'center':\n style.left = config.left + config.box.width / 2 - style.width / 2;\n style.arrowLeft = style.width / 2 - this.prop.arrow;\n break;\n\n case 'left':\n if (topBottom) {\n style.left = config.left - style.width + config.box.width / 2 + this.prop.offset + this.prop.arrow;\n style.arrowLeft = style.width - this.prop.offset - this.prop.arrow * 2;\n }\n else {\n style.left = config.left - style.width - this.prop.offset - this.prop.arrow;\n style.arrowLeft = style.width;\n }\n break;\n\n // no default\n }\n }\n\n}\n","import { Tooltip } from '../components/Tooltip';\nimport { getStyle } from '../utils';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Tooltip renderer\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class TooltipRenderer extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n const testTooltip = new Tooltip(this.psv);\n\n /**\n * @summary Computed static sizes\n * @member {Object}\n * @package\n * @property {number} arrowSize\n * @property {number} offset\n */\n this.size = {\n arrow : parseInt(getStyle(testTooltip.arrow, 'borderTopWidth'), 10),\n offset: parseInt(getStyle(testTooltip.container, 'outlineWidth'), 10),\n };\n\n testTooltip.destroy();\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.size;\n\n super.destroy();\n }\n\n /**\n * @summary Displays a tooltip on the viewer\n * @param {PSV.components.Tooltip.Config} config\n * @returns {PSV.components.Tooltip}\n *\n * @fires PSV.show-tooltip\n * @throws {PSV.PSVError} when the configuration is incorrect\n *\n * @example\n * viewer.tooltip.create({ content: 'Hello world', top: 200, left: 450, position: 'center bottom'})\n */\n create(config) {\n const tooltip = new Tooltip(this.psv, this.size);\n tooltip.show(config);\n\n return tooltip;\n }\n\n}\n","import { bound } from './index';\n\n/**\n * @summary Represents a variable that can dynamically change with time (using requestAnimationFrame)\n * @memberOf PSV\n * @package\n */\nexport class Dynamic {\n\n static STOP = 0;\n static INFINITE = 1;\n static POSITION = 2;\n\n /**\n * @param {Function} [fn] Callback function\n * @param {number} [defaultValue] Default position\n * @param {number} [min] Minimum position\n * @param {number} [max] Maximum position\n */\n constructor(fn, defaultValue = 0, min = -Infinity, max = Infinity) {\n /**\n * @type {Function}\n * @private\n * @readonly\n */\n this.fn = fn;\n\n /**\n * @type {number}\n * @private\n */\n this.mode = Dynamic.STOP;\n\n /**\n * @type {number}\n * @private\n */\n this.speed = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.speedMult = 1;\n\n /**\n * @type {number}\n * @private\n */\n this.currentSpeed = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.target = 0;\n\n /**\n * @type {number}\n * @readonly\n */\n this.current = defaultValue;\n\n /**\n * @type {number}\n * @private\n */\n this.min = min;\n\n /**\n * @type {number}\n * @private\n */\n this.max = max;\n\n if (this.fn) {\n this.fn(defaultValue);\n }\n }\n\n /**\n * Changes base speed\n * @param {number} speed\n */\n setSpeed(speed) {\n this.speed = speed;\n }\n\n /**\n * Defines the target position\n * @param {number} position\n * @param {number} [speedMult=1]\n */\n goto(position, speedMult = 1) {\n this.mode = Dynamic.POSITION;\n this.target = bound(position, this.min, this.max);\n this.speedMult = speedMult;\n }\n\n /**\n * Increase/decrease the target position\n * @param {number} step\n * @param {number} [speedMult=1]\n */\n step(step, speedMult = 1) {\n if (this.mode !== Dynamic.POSITION) {\n this.target = this.current;\n }\n this.goto(this.target + step, speedMult);\n }\n\n /**\n * Starts infinite movement\n * @param {boolean} [invert=false]\n * @param {number} [speedMult=1]\n */\n roll(invert = false, speedMult = 1) {\n this.mode = Dynamic.INFINITE;\n this.target = invert ? -Infinity : Infinity;\n this.speedMult = speedMult;\n }\n\n /**\n * Stops movement\n */\n stop() {\n this.mode = Dynamic.STOP;\n }\n\n /**\n * Defines the current position and immediately stops movement\n * @param {number} values\n */\n setValue(values) {\n const next = bound(values, this.min, this.max);\n this.target = next;\n this.mode = Dynamic.STOP;\n if (next !== this.current) {\n this.current = next;\n if (this.fn) {\n this.fn(this.current);\n }\n return true;\n }\n return false;\n }\n\n /**\n * @package\n */\n update(elapsed) {\n // in position mode switch to stop mode when in the decceleration window\n if (this.mode === Dynamic.POSITION) {\n const dstStop = this.currentSpeed * this.currentSpeed / (this.speed * this.speedMult * 4);\n if (Math.abs(this.target - this.current) <= dstStop) {\n this.mode = Dynamic.STOP;\n }\n }\n\n // compute speed\n let targetSpeed = this.mode === Dynamic.STOP ? 0 : this.speed * this.speedMult;\n if (this.target < this.current) {\n targetSpeed = -targetSpeed;\n }\n if (this.currentSpeed < targetSpeed) {\n this.currentSpeed = Math.min(targetSpeed, this.currentSpeed + elapsed / 1000 * this.speed * this.speedMult * 2);\n }\n else if (this.currentSpeed > targetSpeed) {\n this.currentSpeed = Math.max(targetSpeed, this.currentSpeed - elapsed / 1000 * this.speed * this.speedMult * 2);\n }\n\n // compute new position\n let next = null;\n if (this.current > this.target && this.currentSpeed) {\n next = Math.max(this.target, this.current + this.currentSpeed * elapsed / 1000);\n }\n else if (this.current < this.target && this.currentSpeed) {\n next = Math.min(this.target, this.current + this.currentSpeed * elapsed / 1000);\n }\n\n // apply value\n if (next !== null) {\n next = bound(next, this.min, this.max);\n if (next !== this.current) {\n this.current = next;\n if (this.fn) {\n this.fn(this.current);\n }\n return true;\n }\n }\n\n return false;\n }\n\n}\n","import { each } from './index';\n\n/**\n * @summary Wrapper for multiple {@link PSV.Dynamic} evolving together\n * @memberOf PSV\n * @package\n */\nexport class MultiDynamic {\n\n /**\n * @type {Object}\n * @readonly\n */\n get current() {\n const values = {};\n each(this.dynamics, (dynamic, name) => {\n values[name] = dynamic.current;\n });\n return values;\n }\n\n /**\n * @param {Record} dynamics\n * @param {Function} [fn] Callback function\n */\n constructor(dynamics, fn) {\n /**\n * @type {Function}\n * @private\n * @readonly\n */\n this.fn = fn;\n\n /**\n * @type {Record}\n * @private\n * @readonly\n */\n this.dynamics = dynamics;\n\n if (this.fn) {\n this.fn(this.current);\n }\n }\n\n /**\n * Changes base speed\n * @param {number} speed\n */\n setSpeed(speed) {\n each(this.dynamics, (d) => {\n d.setSpeed(speed);\n });\n }\n\n /**\n * Defines the target positions\n * @param {Record} positions\n * @param {number} [speedMult=1]\n */\n goto(positions, speedMult = 1) {\n each(positions, (position, name) => {\n this.dynamics[name].goto(position, speedMult);\n });\n }\n\n /**\n * Increase/decrease the target positions\n * @param {Record} steps\n * @param {number} [speedMult=1]\n */\n step(steps, speedMult = 1) {\n each(steps, (step, name) => {\n this.dynamics[name].step(step, speedMult);\n });\n }\n\n /**\n * Starts infinite movements\n * @param {Record} rolls\n * @param {number} [speedMult=1]\n */\n roll(rolls, speedMult = 1) {\n each(rolls, (roll, name) => {\n this.dynamics[name].roll(roll, speedMult);\n });\n }\n\n /**\n * Stops movements\n */\n stop() {\n each(this.dynamics, d => d.stop());\n }\n\n /**\n * Defines the current positions and immediately stops movements\n * @param {Record} values\n */\n setValue(values) {\n let hasUpdates = false;\n each(values, (value, name) => {\n hasUpdates |= this.dynamics[name].setValue(value);\n });\n\n if (hasUpdates && this.fn) {\n this.fn(this.current);\n }\n\n return hasUpdates;\n }\n\n /**\n * @package\n */\n update(elapsed) {\n let hasUpdates = false;\n each(this.dynamics, (dynamic) => {\n hasUpdates |= dynamic.update(elapsed);\n });\n\n if (hasUpdates && this.fn) {\n this.fn(this.current);\n }\n\n return hasUpdates;\n }\n\n}\n","import * as THREE from 'three';\nimport { EventEmitter } from 'uevent';\nimport { Animation } from './Animation';\nimport { Loader } from './components/Loader';\nimport { Navbar } from './components/Navbar';\nimport { Notification } from './components/Notification';\nimport { Overlay } from './components/Overlay';\nimport { Panel } from './components/Panel';\nimport { CONFIG_PARSERS, DEFAULTS, DEPRECATED_OPTIONS, getConfig, READONLY_OPTIONS } from './data/config';\nimport { CHANGE_EVENTS, DEFAULT_TRANSITION, EVENTS, IDS, SPHERE_RADIUS, VIEWER_DATA } from './data/constants';\nimport { SYSTEM } from './data/system';\nimport errorIcon from './icons/error.svg';\nimport { AbstractPlugin } from './plugins/AbstractPlugin';\nimport { PSVError } from './PSVError';\nimport { DataHelper } from './services/DataHelper';\nimport { EventsHandler } from './services/EventsHandler';\nimport { Renderer } from './services/Renderer';\nimport { TextureLoader } from './services/TextureLoader';\nimport { TooltipRenderer } from './services/TooltipRenderer';\nimport {\n each,\n exitFullscreen,\n getAbortError,\n getAngle,\n getShortestArc,\n isAbortError,\n isExtendedPosition,\n isFullscreenEnabled,\n logWarn,\n pluginInterop,\n requestFullscreen,\n throttle,\n toggleClass\n} from './utils';\nimport { Dynamic } from './utils/Dynamic';\nimport { MultiDynamic } from './utils/MultiDynamic';\n\nTHREE.Cache.enabled = true;\n\n/**\n * @summary Main class\n * @memberOf PSV\n * @extends {external:uEvent.EventEmitter}\n */\nexport class Viewer extends EventEmitter {\n\n /**\n * @param {PSV.Options} options\n * @fires PSV.ready\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n constructor(options) {\n super();\n\n SYSTEM.load();\n\n // must support WebGL\n if (!SYSTEM.isWebGLSupported) {\n throw new PSVError('WebGL is not supported.');\n }\n\n if (SYSTEM.maxTextureWidth === 0) {\n throw new PSVError('Unable to detect system capabilities');\n }\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @protected\n * @property {boolean} ready - when all components are loaded\n * @property {boolean} uiRefresh - if the UI needs to be renderer\n * @property {boolean} needsUpdate - if the view needs to be renderer\n * @property {boolean} fullscreen - if the viewer is currently fullscreen\n * @property {external:THREE.Vector3} direction - direction of the camera\n * @property {number} vFov - vertical FOV\n * @property {number} hFov - horizontal FOV\n * @property {number} aspect - viewer aspect ratio\n * @property {boolean} autorotateEnabled - automatic rotation is enabled\n * @property {PSV.Animation} animationPromise - promise of the current animation\n * @property {Promise} loadingPromise - promise of the setPanorama method\n * @property startTimeout - timeout id of the automatic rotation delay\n * @property {object} objectsObservers\n * @property {PSV.Size} size - size of the container\n * @property {PSV.PanoData} panoData - panorama metadata, if supported\n */\n this.prop = {\n ready : false,\n uiRefresh : false,\n needsUpdate : false,\n fullscreen : false,\n direction : new THREE.Vector3(0, 0, SPHERE_RADIUS),\n vFov : null,\n hFov : null,\n aspect : null,\n autorotateEnabled: false,\n animationPromise : null,\n loadingPromise : null,\n startTimeout : null,\n objectsObservers : {},\n size : {\n width : 0,\n height: 0,\n },\n panoData : {\n fullWidth : 0,\n fullHeight : 0,\n croppedWidth : 0,\n croppedHeight: 0,\n croppedX : 0,\n croppedY : 0,\n poseHeading : 0,\n posePitch : 0,\n poseRoll : 0,\n },\n };\n\n /**\n * @summary Configuration holder\n * @type {PSV.Options}\n * @readonly\n */\n this.config = getConfig(options);\n\n /**\n * @summary Top most parent\n * @member {HTMLElement}\n * @readonly\n */\n this.parent = (typeof options.container === 'string') ? document.getElementById(options.container) : options.container;\n this.parent[VIEWER_DATA] = this;\n\n /**\n * @summary Main container\n * @member {HTMLElement}\n * @readonly\n */\n this.container = document.createElement('div');\n this.container.classList.add('psv-container');\n this.parent.appendChild(this.container);\n\n /**\n * @summary Render adapter\n * @type {PSV.adapters.AbstractAdapter}\n * @readonly\n * @package\n */\n this.adapter = new this.config.adapter[0](this, this.config.adapter[1]); // eslint-disable-line new-cap\n\n /**\n * @summary All child components\n * @type {PSV.components.AbstractComponent[]}\n * @readonly\n * @package\n */\n this.children = [];\n\n /**\n * @summary All plugins\n * @type {Object}\n * @readonly\n * @package\n */\n this.plugins = {};\n\n /**\n * @type {PSV.services.Renderer}\n * @readonly\n */\n this.renderer = new Renderer(this);\n\n /**\n * @type {PSV.services.TextureLoader}\n * @readonly\n */\n this.textureLoader = new TextureLoader(this);\n\n /**\n * @type {PSV.services.EventsHandler}\n * @readonly\n */\n this.eventsHandler = new EventsHandler(this);\n\n /**\n * @type {PSV.services.DataHelper}\n * @readonly\n */\n this.dataHelper = new DataHelper(this);\n\n /**\n * @member {PSV.components.Loader}\n * @readonly\n */\n this.loader = new Loader(this);\n\n /**\n * @member {PSV.components.Navbar}\n * @readonly\n */\n this.navbar = new Navbar(this);\n\n /**\n * @member {PSV.components.Panel}\n * @readonly\n */\n this.panel = new Panel(this);\n\n /**\n * @member {PSV.services.TooltipRenderer}\n * @readonly\n */\n this.tooltip = new TooltipRenderer(this);\n\n /**\n * @member {PSV.components.Notification}\n * @readonly\n */\n this.notification = new Notification(this);\n\n /**\n * @member {PSV.components.Overlay}\n * @readonly\n */\n this.overlay = new Overlay(this);\n\n /**\n * @member {Record}\n * @package\n */\n this.dynamics = {\n zoom: new Dynamic((value) => {\n this.prop.vFov = this.dataHelper.zoomLevelToFov(value);\n this.prop.hFov = this.dataHelper.vFovToHFov(this.prop.vFov);\n this.trigger(EVENTS.ZOOM_UPDATED, value);\n }, this.config.defaultZoomLvl, 0, 100),\n\n position: new MultiDynamic({\n longitude: new Dynamic(null, this.config.defaultLong),\n latitude : new Dynamic(null, this.config.defaultLat, -Math.PI / 2, Math.PI / 2),\n }, (position) => {\n this.dataHelper.sphericalCoordsToVector3(position, this.prop.direction);\n this.trigger(EVENTS.POSITION_UPDATED, this.dataHelper.cleanPosition(position));\n }),\n };\n\n this.__updateSpeeds();\n\n this.eventsHandler.init();\n\n this.__resizeRefresh = throttle(() => this.refreshUi('resize'), 500);\n\n // apply container size\n this.resize(this.config.size);\n\n // init plugins\n this.config.plugins.forEach(([plugin, opts]) => {\n this.plugins[plugin.id] = new plugin(this, opts); // eslint-disable-line new-cap\n });\n each(this.plugins, plugin => plugin.init?.());\n\n // init buttons\n this.navbar.setButtons(this.config.navbar);\n\n // load panorama\n if (this.config.panorama) {\n this.setPanorama(this.config.panorama);\n }\n\n SYSTEM.isTouchEnabled.then(enabled => toggleClass(this.container, 'psv--is-touch', enabled));\n\n // enable GUI after first render\n this.once(EVENTS.RENDER, () => {\n if (this.config.navbar) {\n this.container.classList.add('psv--has-navbar');\n this.navbar.show();\n }\n\n // Queue autorotate\n if (this.config.autorotateDelay) {\n this.prop.startTimeout = setTimeout(() => this.startAutorotate(), this.config.autorotateDelay);\n }\n\n this.prop.ready = true;\n\n setTimeout(() => {\n this.refreshUi('init');\n\n this.trigger(EVENTS.READY);\n }, 0);\n });\n }\n\n /**\n * @summary Destroys the viewer\n * @description The memory used by the ThreeJS context is not totally cleared. This will be fixed as soon as possible.\n */\n destroy() {\n this.__stopAll();\n this.stopKeyboardControl();\n this.exitFullscreen();\n\n this.eventsHandler.destroy();\n this.renderer.destroy();\n this.textureLoader.destroy();\n this.dataHelper.destroy();\n this.adapter.destroy();\n\n this.children.slice().forEach(child => child.destroy());\n this.children.length = 0;\n\n each(this.plugins, plugin => plugin.destroy());\n delete this.plugins;\n\n this.parent.removeChild(this.container);\n delete this.parent[VIEWER_DATA];\n\n delete this.parent;\n delete this.container;\n\n delete this.loader;\n delete this.navbar;\n delete this.panel;\n delete this.tooltip;\n delete this.notification;\n delete this.overlay;\n\n delete this.config;\n }\n\n /**\n * @summary Refresh UI\n * @package\n */\n refreshUi(reason) {\n if (!this.prop.ready) {\n return;\n }\n\n if (!this.prop.uiRefresh) {\n // console.log(`PhotoSphereViewer: UI Refresh, ${reason}`);\n\n this.prop.uiRefresh = true;\n\n this.children.every((child) => {\n child.refreshUi();\n return this.prop.uiRefresh === true;\n });\n\n this.prop.uiRefresh = false;\n }\n else if (this.prop.uiRefresh !== 'new') {\n this.prop.uiRefresh = 'new';\n\n // wait for current refresh to cancel\n setTimeout(() => {\n this.prop.uiRefresh = false;\n this.refreshUi(reason);\n });\n }\n }\n\n /**\n * @summary Returns the instance of a plugin if it exists\n * @param {Class|string} pluginId\n * @returns {PSV.plugins.AbstractPlugin}\n */\n getPlugin(pluginId) {\n if (typeof pluginId === 'string') {\n return this.plugins[pluginId];\n }\n else {\n const pluginCtor = pluginInterop(pluginId, AbstractPlugin);\n return pluginCtor ? this.plugins[pluginCtor.id] : undefined;\n }\n }\n\n /**\n * @summary Returns the current position of the camera\n * @returns {PSV.Position}\n */\n getPosition() {\n return this.dataHelper.cleanPosition(this.dynamics.position.current);\n }\n\n /**\n * @summary Returns the current zoom level\n * @returns {number}\n */\n getZoomLevel() {\n return this.dynamics.zoom.current;\n }\n\n /**\n * @summary Returns the current viewer size\n * @returns {PSV.Size}\n */\n getSize() {\n return { ...this.prop.size };\n }\n\n /**\n * @summary Checks if the automatic rotation is enabled\n * @returns {boolean}\n */\n isAutorotateEnabled() {\n return this.prop.autorotateEnabled;\n }\n\n /**\n * @summary Checks if the viewer is in fullscreen\n * @returns {boolean}\n */\n isFullscreenEnabled() {\n if (SYSTEM.fullscreenEvent) {\n return isFullscreenEnabled(this.container);\n }\n else {\n return this.prop.fullscreen;\n }\n }\n\n /**\n * @summary Flags the view has changed for the next render\n */\n needsUpdate() {\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Resizes the canvas when the window is resized\n * @fires PSV.size-updated\n */\n autoSize() {\n if (this.container.clientWidth !== this.prop.size.width || this.container.clientHeight !== this.prop.size.height) {\n this.prop.size.width = Math.round(this.container.clientWidth);\n this.prop.size.height = Math.round(this.container.clientHeight);\n this.prop.aspect = this.prop.size.width / this.prop.size.height;\n this.prop.hFov = this.dataHelper.vFovToHFov(this.prop.vFov);\n\n this.trigger(EVENTS.SIZE_UPDATED, this.getSize());\n this.__resizeRefresh();\n }\n }\n\n /**\n * @summary Loads a new panorama file\n * @description Loads a new panorama file, optionally changing the camera position/zoom and activating the transition animation.
\n * If the \"options\" parameter is not defined, the camera will not move and the ongoing animation will continue.
\n * If another loading is already in progress it will be aborted.\n * @param {*} path - URL of the new panorama file\n * @param {PSV.PanoramaOptions} [options]\n * @returns {Promise} resolves false if the loading was aborted by another call\n */\n setPanorama(path, options = {}) {\n this.textureLoader.abortLoading();\n this.prop.transitionAnimation?.cancel();\n\n // apply default parameters on first load\n if (!this.prop.ready) {\n if (!('sphereCorrection' in options)) {\n options.sphereCorrection = this.config.sphereCorrection;\n }\n if (!('panoData' in options)) {\n options.panoData = this.config.panoData;\n }\n }\n\n if (options.transition === undefined || options.transition === true) {\n options.transition = DEFAULT_TRANSITION;\n }\n if (options.showLoader === undefined) {\n options.showLoader = true;\n }\n if (options.caption === undefined) {\n options.caption = this.config.caption;\n }\n\n const positionProvided = isExtendedPosition(options);\n const zoomProvided = 'zoom' in options;\n\n if (positionProvided || zoomProvided) {\n this.__stopAll();\n }\n\n this.hideError();\n\n this.config.panorama = path;\n this.config.caption = options.caption;\n\n const done = (err) => {\n this.loader.hide();\n\n this.prop.loadingPromise = null;\n\n if (isAbortError(err)) {\n return false;\n }\n else if (err) {\n this.navbar.setCaption('');\n this.showError(this.config.lang.loadError);\n console.error(err);\n throw err;\n }\n else {\n this.navbar.setCaption(this.config.caption);\n return true;\n }\n };\n\n this.navbar.setCaption(`${this.config.loadingTxt || ''}`);\n if (options.showLoader || !this.prop.ready) {\n this.loader.show();\n }\n\n const loadingPromise = this.adapter.loadTexture(this.config.panorama, options.panoData)\n .then((textureData) => {\n // check if another panorama was requested\n if (textureData.panorama !== this.config.panorama) {\n this.adapter.disposeTexture(textureData);\n throw getAbortError();\n }\n return textureData;\n });\n\n if (!options.transition || !this.prop.ready || !this.adapter.supportsTransition(this.config.panorama)) {\n this.prop.loadingPromise = loadingPromise\n .then((textureData) => {\n this.renderer.show();\n this.renderer.setTexture(textureData);\n this.renderer.setPanoramaPose(textureData.panoData);\n this.renderer.setSphereCorrection(options.sphereCorrection);\n\n if (zoomProvided) {\n this.zoom(options.zoom);\n }\n if (positionProvided) {\n this.rotate(options);\n }\n })\n .then(done, done);\n }\n else {\n this.prop.loadingPromise = loadingPromise\n .then((textureData) => {\n this.loader.hide();\n\n this.prop.transitionAnimation = this.renderer.transition(textureData, options);\n return this.prop.transitionAnimation\n .then((completed) => {\n this.prop.transitionAnimation = null;\n if (!completed) {\n throw getAbortError();\n }\n });\n })\n .then(done, done);\n }\n\n return this.prop.loadingPromise;\n }\n\n /**\n * @summary Update options\n * @param {PSV.Options} options\n * @fires PSV.config-changed\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n setOptions(options) {\n each(options, (value, key) => {\n if (DEPRECATED_OPTIONS[key]) {\n logWarn(DEPRECATED_OPTIONS[key]);\n return;\n }\n\n if (!Object.prototype.hasOwnProperty.call(DEFAULTS, key)) {\n throw new PSVError(`Unknown option ${key}`);\n }\n\n if (READONLY_OPTIONS[key]) {\n throw new PSVError(READONLY_OPTIONS[key]);\n }\n\n if (CONFIG_PARSERS[key]) {\n this.config[key] = CONFIG_PARSERS[key](value, options);\n }\n else {\n this.config[key] = value;\n }\n\n switch (key) {\n case 'caption':\n this.navbar.setCaption(value);\n break;\n\n case 'size':\n this.resize(value);\n break;\n\n case 'sphereCorrection':\n this.renderer.setSphereCorrection(value);\n break;\n\n case 'navbar':\n case 'lang':\n this.navbar.setButtons(this.config.navbar);\n break;\n\n case 'moveSpeed':\n case 'zoomSpeed':\n this.__updateSpeeds();\n break;\n\n case 'minFov':\n case 'maxFov':\n this.dynamics.zoom.setValue(this.dataHelper.fovToZoomLevel(this.prop.vFov));\n this.trigger(EVENTS.ZOOM_UPDATED, this.getZoomLevel());\n break;\n\n case 'canvasBackground':\n this.renderer.canvasContainer.style.background = this.config.canvasBackground;\n break;\n\n default:\n break;\n }\n });\n\n this.needsUpdate();\n this.refreshUi('set options');\n\n this.trigger(EVENTS.CONFIG_CHANGED, Object.keys(options));\n }\n\n /**\n * @summary Update options\n * @param {string} option\n * @param {any} value\n * @fires PSV.config-changed\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n setOption(option, value) {\n this.setOptions({ [option]: value });\n }\n\n /**\n * @summary Starts the automatic rotation\n * @fires PSV.autorotate\n */\n startAutorotate(refresh = false) {\n if (refresh && !this.isAutorotateEnabled()) {\n return;\n }\n\n if (!refresh) {\n this.__stopAll();\n }\n\n this.dynamics.position.roll({\n longitude: this.config.autorotateSpeed < 0,\n }, Math.abs(this.config.autorotateSpeed / this.config.moveSpeed));\n\n this.dynamics.position.goto({\n latitude: this.config.autorotateLat,\n }, Math.abs(this.config.autorotateSpeed / this.config.moveSpeed));\n\n this.prop.autorotateEnabled = true;\n\n if (!refresh) {\n this.trigger(EVENTS.AUTOROTATE, true);\n }\n }\n\n /**\n * @summary Stops the automatic rotation\n * @fires PSV.autorotate\n */\n stopAutorotate() {\n if (this.prop.startTimeout) {\n clearTimeout(this.prop.startTimeout);\n this.prop.startTimeout = null;\n }\n\n if (this.isAutorotateEnabled()) {\n this.dynamics.position.stop();\n\n this.prop.autorotateEnabled = false;\n\n this.trigger(EVENTS.AUTOROTATE, false);\n }\n }\n\n /**\n * @summary Starts or stops the automatic rotation\n * @fires PSV.autorotate\n */\n toggleAutorotate() {\n if (this.isAutorotateEnabled()) {\n this.stopAutorotate();\n }\n else {\n this.startAutorotate();\n }\n }\n\n /**\n * @summary Displays an error message over the viewer\n * @param {string} message\n */\n showError(message) {\n this.overlay.show({\n id : IDS.ERROR,\n image : errorIcon,\n text : message,\n dissmisable: false,\n });\n }\n\n /**\n * @summary Hides the error message\n */\n hideError() {\n this.overlay.hide(IDS.ERROR);\n }\n\n /**\n * @summary Rotates the view to specific longitude and latitude\n * @param {PSV.ExtendedPosition} position\n * @fires PSV.before-rotate\n * @fires PSV.position-updated\n */\n rotate(position) {\n const e = this.trigger(EVENTS.BEFORE_ROTATE, position);\n if (e.isDefaultPrevented()) {\n return;\n }\n\n const cleanPosition = this.change(CHANGE_EVENTS.GET_ROTATE_POSITION, this.dataHelper.cleanPosition(position));\n this.dynamics.position.setValue(cleanPosition);\n }\n\n /**\n * @summary Rotates and zooms the view with a smooth animation\n * @param {PSV.AnimateOptions} options - position and/or zoom level\n * @returns {PSV.Animation}\n */\n animate(options) {\n this.__stopAll();\n\n const positionProvided = isExtendedPosition(options);\n const zoomProvided = 'zoom' in options;\n\n const animProperties = {};\n let duration;\n\n // clean/filter position and compute duration\n if (positionProvided) {\n const cleanPosition = this.change(CHANGE_EVENTS.GET_ANIMATE_POSITION, this.dataHelper.cleanPosition(options));\n const currentPosition = this.getPosition();\n\n // longitude offset for shortest arc\n const tOffset = getShortestArc(currentPosition.longitude, cleanPosition.longitude);\n\n animProperties.longitude = { start: currentPosition.longitude, end: currentPosition.longitude + tOffset };\n animProperties.latitude = { start: currentPosition.latitude, end: cleanPosition.latitude };\n\n duration = this.dataHelper.speedToDuration(options.speed, getAngle(currentPosition, cleanPosition));\n }\n\n // clean/filter zoom and compute duration\n if (zoomProvided) {\n const dZoom = Math.abs(options.zoom - this.getZoomLevel());\n\n animProperties.zoom = { start: this.getZoomLevel(), end: options.zoom };\n\n if (!duration) {\n // if animating zoom only and a speed is given, use an arbitrary PI/4 to compute the duration\n duration = this.dataHelper.speedToDuration(options.speed, Math.PI / 4 * dZoom / 100);\n }\n }\n\n // if no animation needed\n if (!duration) {\n if (positionProvided) {\n this.rotate(options);\n }\n if (zoomProvided) {\n this.zoom(options.zoom);\n }\n\n return new Animation();\n }\n\n this.prop.animationPromise = new Animation({\n properties: animProperties,\n duration : duration,\n easing : 'inOutSine',\n onTick : (properties) => {\n if (positionProvided) {\n this.rotate(properties);\n }\n if (zoomProvided) {\n this.zoom(properties.zoom);\n }\n },\n });\n\n return this.prop.animationPromise;\n }\n\n /**\n * @summary Stops the ongoing animation\n * @description The return value is a Promise because the is no guaranty the animation can be stopped synchronously.\n * @returns {Promise} Resolved when the animation has ben cancelled\n */\n stopAnimation() {\n if (this.prop.animationPromise) {\n return new Promise((resolve) => {\n this.prop.animationPromise.then(resolve);\n this.prop.animationPromise.cancel();\n this.prop.animationPromise = null;\n });\n }\n else {\n return Promise.resolve();\n }\n }\n\n /**\n * @summary Zooms to a specific level between `max_fov` and `min_fov`\n * @param {number} level - new zoom level from 0 to 100\n * @fires PSV.zoom-updated\n */\n zoom(level) {\n this.dynamics.zoom.setValue(level);\n }\n\n /**\n * @summary Increases the zoom level\n * @param {number} [step=1]\n */\n zoomIn(step = 1) {\n this.dynamics.zoom.step(step);\n }\n\n /**\n * @summary Decreases the zoom level\n * @param {number} [step=1]\n */\n zoomOut(step = 1) {\n this.dynamics.zoom.step(-step);\n }\n\n /**\n * @summary Resizes the viewer\n * @param {PSV.CssSize} size\n */\n resize(size) {\n ['width', 'height'].forEach((dim) => {\n if (size && size[dim]) {\n if (/^[0-9.]+$/.test(size[dim])) {\n size[dim] += 'px';\n }\n this.parent.style[dim] = size[dim];\n }\n });\n\n this.autoSize();\n }\n\n /**\n * @summary Enters the fullscreen mode\n * @fires PSV.fullscreen-updated\n */\n enterFullscreen() {\n if (SYSTEM.fullscreenEvent) {\n requestFullscreen(this.container);\n }\n else {\n this.container.classList.add('psv-container--fullscreen');\n this.autoSize();\n this.eventsHandler.__fullscreenToggled(true);\n }\n }\n\n /**\n * @summary Exits the fullscreen mode\n * @fires PSV.fullscreen-updated\n */\n exitFullscreen() {\n if (this.isFullscreenEnabled()) {\n if (SYSTEM.fullscreenEvent) {\n exitFullscreen();\n }\n else {\n this.container.classList.remove('psv-container--fullscreen');\n this.autoSize();\n this.eventsHandler.__fullscreenToggled(false);\n }\n }\n }\n\n /**\n * @summary Enters or exits the fullscreen mode\n * @fires PSV.fullscreen-updated\n */\n toggleFullscreen() {\n if (!this.isFullscreenEnabled()) {\n this.enterFullscreen();\n }\n else {\n this.exitFullscreen();\n }\n }\n\n /**\n * @summary Enables the keyboard controls (done automatically when entering fullscreen)\n */\n startKeyboardControl() {\n this.eventsHandler.enableKeyboard();\n }\n\n /**\n * @summary Disables the keyboard controls (done automatically when exiting fullscreen)\n */\n stopKeyboardControl() {\n this.eventsHandler.disableKeyboard();\n }\n\n /**\n * @summary Subscribes to events on objects in the scene\n * @param {string} userDataKey - only objects with the following `userData` will be emitted\n * @param {EventListener} listener - must implement `handleEvent\n * @return {function} call to stop the subscription\n * @package\n */\n observeObjects(userDataKey, listener) {\n this.prop.objectsObservers[userDataKey] = { listener };\n\n return () => {\n delete this.prop.objectsObservers[userDataKey];\n };\n }\n\n /**\n * @summary Stops all current animations\n * @package\n */\n __stopAll() {\n this.stopAutorotate();\n this.stopAnimation();\n\n this.trigger(EVENTS.STOP_ALL);\n }\n\n /**\n * @summary Recomputes dynamics speeds\n * @private\n */\n __updateSpeeds() {\n this.dynamics.zoom.setSpeed(this.config.zoomSpeed * 50);\n this.dynamics.position.setSpeed(THREE.Math.degToRad(this.config.moveSpeed * 50));\n }\n\n}\n"],"names":["DEFAULT_TRANSITION","MOVE_THRESHOLD","DBLCLICK_DELAY","LONGTOUCH_DELAY","TWOFINGERSOVERLAY_DELAY","CTRLZOOM_TIMEOUT","INERTIA_WINDOW","SPHERE_RADIUS","VIEWER_DATA","MESH_USER_DATA","ACTIONS","ROTATE_LAT_UP","ROTATE_LAT_DOWN","ROTATE_LONG_RIGHT","ROTATE_LONG_LEFT","ZOOM_IN","ZOOM_OUT","TOGGLE_AUTOROTATE","EVENTS","AUTOROTATE","BEFORE_RENDER","BEFORE_ROTATE","CLICK","CLOSE_PANEL","CONFIG_CHANGED","DOUBLE_CLICK","FULLSCREEN_UPDATED","HIDE_NOTIFICATION","HIDE_OVERLAY","HIDE_TOOLTIP","LOAD_PROGRESS","OPEN_PANEL","PANORAMA_LOADED","POSITION_UPDATED","READY","RENDER","SHOW_NOTIFICATION","SHOW_OVERLAY","SHOW_TOOLTIP","SIZE_UPDATED","STOP_ALL","ZOOM_UPDATED","CHANGE_EVENTS","GET_ANIMATE_POSITION","GET_ROTATE_POSITION","OBJECT_EVENTS","ENTER_OBJECT","HOVER_OBJECT","LEAVE_OBJECT","IDS","MENU","TWO_FINGERS","CTRL_ZOOM","ERROR","EASINGS","linear","t","inQuad","outQuad","inOutQuad","inCubic","outCubic","inOutCubic","inQuart","outQuart","inOutQuart","inQuint","outQuint","inOutQuint","inSine","Math","cos","PI","outSine","sin","inOutSine","inExpo","pow","outExpo","inOutExpo","inCirc","sqrt","outCirc","inOutCirc","KEY_CODES","Enter","Control","Escape","Space","PageUp","PageDown","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Delete","Plus","Minus","toggleClass","element","className","active","classList","currentClassName","getAttribute","currentActive","indexOf","regex","RegExp","undefined","length","replace","setAttribute","toggle","contains","add","remove","addClasses","split","forEach","name","removeClasses","hasParent","el","parent","test","parentNode","getClosest","selector","matches","msMatchesSelector","bind","SVGElement","parentElement","getPosition","left","top","offsetLeft","scrollLeft","clientLeft","offsetTop","scrollTop","clientTop","offsetParent","KEYMAP","MS_KEYMAP","Add","Del","Down","Esc","Left","Right","Spacebar","Subtract","Up","getEventKey","evt","key","keyCode","which","isFullscreenEnabled","elt","document","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","requestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","msRequestFullscreen","call","exitFullscreen","mozCancelFullScreen","webkitExitFullscreen","msExitFullscreen","getStyle","prop","window","getComputedStyle","normalizeWheel","event","PIXEL_STEP","LINE_HEIGHT","PAGE_HEIGHT","spinX","spinY","pixelX","pixelY","detail","wheelDelta","wheelDeltaY","wheelDeltaX","axis","HORIZONTAL_AXIS","deltaY","deltaX","deltaMode","bound","x","min","max","isInteger","value","Number","isFinite","floor","isPowerOfTwo","log","sum","array","reduce","a","b","distance","p1","p2","y","getShortestArc","from","to","tCandidates","candidate","newCandidate","abs","Infinity","getAngle","position1","position2","acos","latitude","longitude","greatArcDistance","λ1","φ1","λ2","φ2","dasherize","str","s","i","toLowerCase","throttle","func","wait","self","args","result","timeout","previous","later","Date","now","apply","remaining","arguments","clearTimeout","setTimeout","isPlainObject","obj","Object","getPrototypeOf","proto","prototype","toString","deepmerge","target","src","first","merge","Array","isArray","e","keys","clone","isEmpty","constructor","each","object","callback","isNil","val","firstNonNull","values","PSVError","message","Error","captureStackTrace","stack","create","pluginInterop","plugin","entries","p","getAbortError","error","isAbortError","err","logWarn","console","warn","isExtendedPosition","some","key1","key2","getXMPValue","data","attr","match","parseInt","isNaN","CSS_POSITIONS","bottom","right","center","parsePosition","tokens","toLocaleLowerCase","slice","xFirst","map","token","reverse","parsed","join","parseFloat","LEFT_MAP","TOP_MAP","cleanPosition","defaultValue","allowCenter","tempPos","parseSpeed","speed","speedStr","trim","speedValue","speedUnit","THREE","degToRad","parseAngle","angle","zeroCenter","halfCircle","unit","createTexture","img","texture","Texture","needsUpdate","minFilter","LinearFilter","generateMipmaps","quaternion","Quaternion","applyEulerInverse","vector","euler","setFromEuler","invert","applyQuaternion","Animation","options","__callbacks","easing","__start","delay","__delayTimeout","__animationFrame","requestAnimationFrame","__run","__resolved","timestamp","progress","duration","current","properties","start","end","onTick","__resolve","cb","then","onFulfilled","onRejected","__cancelled","Promise","resolve","push","cancel","cancelAnimationFrame","catch","finally","onFinally","AbstractComponent","psv","children","visible","container","createElement","appendChild","destroy","removeChild","childIdx","splice","child","refreshUi","every","uiRefresh","isVisible","hide","show","style","display","AbstractButton","navbar","collapsable","tabbable","id","enabled","supported","collapsed","width","offsetWidth","icon","__setIcon","config","lang","title","tabIndex","addEventListener","onClick","stopPropagation","checkSupported","supportedOrObject","isSupported","initial","promise","toggleActive","iconActive","refresh","disable","enable","collapse","uncollapse","innerHTML","querySelector","AutorotateButton","on","off","handleEvent","type","toggleAutorotate","play","playActive","CustomButton","random","substr","content","DownloadButton","adapter","supportsDownload","downloadUrl","link","href","panorama","download","pop","click","FullscreenButton","toggleFullscreen","fullscreenIn","fullscreenOut","MenuButton","__hideMenu","__showMenu","panel","MENU_TEMPLATE","BUTTON_DATA","noMargin","clickHandler","li","buttonId","dataset","getButton","menuIcon","buttons","dataKey","menu","button","SYSTEM","loaded","pixelRatio","isWebGLSupported","isTouchEnabled","maxTextureWidth","mouseWheelEvent","fullscreenEvent","load","ctx","getWebGLCtx","devicePixelRatio","getMaxTextureWidth","getMouseWheelEvent","getFullscreenEvent","maxCanvasWidth","getMaxCanvasWidth","canvas","names","context","getContext","listener","removeEventListener","getParameter","MAX_TEXTURE_SIZE","maxWidth","height","fillStyle","fillRect","getImageData","onmousewheel","FULLSCREEN_EVT_MAP","validExits","filter","exit","PressHandler","time","down","getTime","up","elapsed","getOrientedArrow","direction","arrow","AbstractMoveButton","move","handler","__onMouseUp","__onMouseDown","__stopAll","dynamics","position","roll","stop","MoveDownButton","MoveLeftButton","MoveRightButton","MoveUpButton","AbstractZoomButton","zoom","ZoomInButton","zoomIn","ZoomOutButton","zoomOut","ZoomRangeButton","mousedown","mediaMinWidth","zoomRange","zoomValue","ready","__moveZoomValue","getZoomLevel","once","__stopZoomChange","__initZoomChangeWithMouse","__initZoomChangeByTouch","__changeZoomWithMouse","__changeZoomByTouch","size","level","__changeZoom","clientX","changedTouches","buttondown","preventDefault","userInput","getBoundingClientRect","zoomLevel","AbstractAdapter","supportsTransition","supportsPreload","loadTexture","newPanoData","createMesh","scale","setTexture","mesh","textureData","transition","setTextureOpacity","opacity","disposeTexture","EquirectangularAdapter","resolution","SPHERE_SEGMENTS","SPHERE_HORIZONTAL_SEGMENTS","reject","useXmpData","textureLoader","loadImage","loader","setProgress","xmpPanoData","__loadXMP","panoData","fullWidth","fullHeight","croppedWidth","croppedHeight","croppedX","croppedY","poseHeading","posePitch","poseRoll","__createEquirectangularTexture","onProgress","loadFile","blob","__loadBlobAsString","binary","substring","reader","FileReader","onload","onerror","readAsText","ratio","resizedPanoData","buffer","drawImage","geometry","SphereGeometry","material","MeshBasicMaterial","Mesh","dispose","transparent","AbstractPlugin","init","EventEmitter","DEFAULTS","plugins","caption","loadingImg","loadingTxt","fisheye","minFov","maxFov","defaultZoomLvl","defaultLong","defaultLat","sphereCorrection","moveSpeed","zoomSpeed","autorotateDelay","autorotateSpeed","autorotateLat","moveInertia","mousewheel","mousemove","captureCursor","mousewheelCtrlKey","touchmoveTwoFingers","requestHeaders","canvasBackground","withCredentials","autorotate","fullscreen","twoFingers","ctrlZoom","loadError","keyboard","READONLY_OPTIONS","DEPRECATED_OPTIONS","zoomButtonIncrement","mousewheelSpeed","sphereCorrectionReorder","CONFIG_PARSERS","getConfig","tempConfig","hasOwnProperty","CaptionButton","notification","info","NavbarCaption","contentVisible","contentWidth","setCaption","html","availableWidth","AVAILABLE_BUTTONS","registerButton","defaultPosition","unshift","pos","Navbar","setButtons","item","__cleanButtons","warnNotFound","totalWidth","visibleButtons","collapsableButtons","Loader","clientWidth","tickness","lastChild","inner","round","maxHeight","clearRect","lineWidth","strokeStyle","beginPath","arc","stroke","trigger","Notification","Overlay","contentId","dissmisable","image","text","subtext","PANEL_MIN_WIDTH","Panel","mouseX","mouseY","keyHandler","resizer","closeBtn","__onTouchStart","__onMouseMove","__onTouchMove","wasVisible","focus","__startResize","__resize","touches","clientY","AbstractService","vector2","Vector2","vector3","Vector3","eulerZero","Euler","DataHelper","fovToZoomLevel","fov","temp","zoomLevelToFov","vFovToHFov","vFov","radToDeg","atan","tan","aspect","speedToDuration","textureCoordsToSphericalCoords","point","relativeX","relativeY","equals","renderer","rotation","meshContainer","sphericalCoordsToVector3","applyEuler","vector3ToSphericalCoords","sphericalCoordsToTextureCoords","relativeLong","relativeLat","z","phi","theta","atan2","viewerCoordsToVector3","viewerPoint","sphereIntersect","getIntersections","userData","vector3ToViewerCoords","vectorClone","project","camera","sphericalCoordsToViewerCoords","raycaster","setFromCamera","intersectObjects","scene","cleanSphereCorrection","pan","tilt","cleanPanoramaPose","EventsHandler","state","moveThreshold","keyboardEnabled","moving","zooming","startMouseX","startMouseY","mouseHistory","pinchDist","ctrlKeyDown","dblclickData","dblclickTimeout","longtouchTimeout","twofingersTimeout","ctrlZoomTimeout","__onResize","autoSize","__onKeyDown","__onKeyUp","__onTouchEnd","__fullscreenToggled","__onMouseEnter","__onMouseLeave","__onMouseWheel","enableKeyboard","disableKeyboard","overlay","__startMove","__stopMove","__move","__moveAbsolute","objectsObservers","viewerPos","intersections","dataHelper","emit","observer","CustomEvent","originalEvent","intersection","find","__click","__cancelLongTouch","__cancelTwoFingersOverlay","__startMoveZoom","__stopMoveZoom","gestureIcon","__moveZoom","mousewheelIcon","delta","step","force","startKeyboardControl","stopKeyboardControl","stopAutorotate","stopAnimation","__logMouseMove","__stopMoveInertia","norm","animationPromise","longtouch","boundingRect","rightclick","viewerX","viewerY","sphereIntersection","psvSphere","sphericalCoords","objects","o","textureCoords","textureX","textureY","NaN","hFov","currentPosition","rotate","containerRect","goto","Renderer","WebGLRenderer","alpha","antialias","setPixelRatio","domElement","Scene","PerspectiveCamera","Group","Raycaster","canvasContainer","background","cursor","setAnimationLoop","__cleanTHREEScene","__onSizeUpdated","__onZoomUpdated","__onPositionUpdated","setSize","updateProjectionMatrix","set","lookAt","copy","multiplyScalar","negate","__renderLoop","d","update","render","setPanoramaPose","cleanCorrection","setSphereCorrection","positionProvided","zoomProvided","group","verticalAxis","rotateOnWorldAxis","horizontalAxis","cross","getWorldDirection","normalize","animation","completed","traverse","TextureLoader","FileLoader","setResponseType","setWithCredentials","setRequestHeader","abortLoading","url","lengthComputable","newProgress","total","createElementNS","URL","revokeObjectURL","createObjectURL","preloadPanorama","STATE","NONE","SHOWING","HIDING","Tooltip","__onTransitionEnd","rect","posClass","arrowTop","arrowLeft","__computeTooltipPosition","offset","newPos","propertyName","topBottom","box","TooltipRenderer","testTooltip","tooltip","Dynamic","fn","mode","STOP","speedMult","currentSpeed","setSpeed","POSITION","INFINITE","setValue","next","dstStop","targetSpeed","MultiDynamic","positions","steps","rolls","hasUpdates","dynamic","Cache","Viewer","autorotateEnabled","loadingPromise","startTimeout","getElementById","eventsHandler","__updateSpeeds","__resizeRefresh","resize","opts","setPanorama","startAutorotate","reason","getPlugin","pluginId","pluginCtor","getSize","isAutorotateEnabled","clientHeight","path","transitionAnimation","showLoader","hideError","done","showError","setOptions","setOption","option","errorIcon","isDefaultPrevented","change","animate","animProperties","tOffset","dZoom","dim","enterFullscreen","observeObjects","userDataKey"],"mappings":";;;;;;;;;;;;EAAA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACO,IAAMA,kBAAkB,GAAG,IAA3B;EAEP;EACA;EACA;EACA;EACA;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EAqCpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,cAAc,EAAM,gBA3CA;;EA4CpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,UAlDA;;EAmDpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,kBAAkB,EAAE,oBAzDA;;EA0DpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,iBAAiB,EAAG,mBA/DA;;EAgEpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cAtEA;;EAuEpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cA7EA;;EA8EpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,aAAa,EAAO,eApFA;;EAqFpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,UAAU,EAAU,YA3FA;;EA4FpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,eAAe,EAAK,iBAjGA;;EAkGpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,gBAAgB,EAAI,kBAxGA;;EAyGpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,KAAK,EAAe,OA9GA;;EA+GpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,MAAM,EAAc,QApHA;;EAqHpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,iBAAiB,EAAG,mBA1HA;;EA2HpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cAjIA;;EAkIpB;EACF;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cAzIA;;EA0IpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cAhJA;;EAiJpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,QAAQ,EAAY,UAtJA;;EAuJpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ;EA7JA,CAAf;EAgKP;EACA;EACA;EACA;EACA;EACA;;EACO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,IAAd,CAAmB0Z,QAAnB,CAA4B,KAAKrhB,MAAL,CAAYmO,SAAZ,GAAwB,EAApD;EACA,SAAKjH,QAAL,CAAcC,QAAd,CAAuBka,QAAvB,CAAgC7mB,KAAK,CAAC5Q,IAAN,CAAW6Q,QAAX,CAAoB,KAAKuF,MAAL,CAAYkO,SAAZ,GAAwB,EAA5C,CAAhC;EACD,GAp5BH;;EAAA;EAAA,EAA4Bb,mBAA5B;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"photo-sphere-viewer.js","sources":["../src/PSVError.js","../src/adapters/AbstractAdapter.js","../src/data/constants.js","../src/data/system.js","../src/utils/browser.js","../src/utils/math.js","../src/utils/misc.js","../src/utils/psv.js","../src/utils/Animation.js","../src/utils/Dynamic.js","../src/utils/MultiDynamic.js","../src/utils/Slider.js","../src/utils/index.js","../src/adapters/equirectangular/index.js","../src/components/AbstractComponent.js","../src/buttons/AbstractButton.js","../src/buttons/AutorotateButton.js","../src/buttons/CustomButton.js","../src/components/NavbarCaption.js","../src/buttons/DescriptionButton.js","../src/buttons/DownloadButton.js","../src/buttons/FullscreenButton.js","../src/buttons/MenuButton.js","../src/utils/PressHandler.js","../src/buttons/AbstractMoveButton.js","../src/buttons/MoveDownButton.js","../src/buttons/MoveLeftButton.js","../src/buttons/MoveRightButton.js","../src/buttons/MoveUpButton.js","../src/buttons/AbstractZoomButton.js","../src/buttons/ZoomInButton.js","../src/buttons/ZoomOutButton.js","../src/buttons/ZoomRangeButton.js","../src/plugins/AbstractPlugin.js","../src/data/config.js","../src/components/Navbar.js","../src/components/Loader.js","../src/components/Notification.js","../src/components/Overlay.js","../src/components/Panel.js","../src/services/AbstractService.js","../src/services/DataHelper.js","../src/services/EventsHandler.js","../src/services/Renderer.js","../src/services/TextureLoader.js","../src/components/Tooltip.js","../src/services/TooltipRenderer.js","../src/Viewer.js"],"sourcesContent":["/**\n * @summary Custom error used in the lib\n * @param {string} message\n * @constructor\n * @memberOf PSV\n */\nfunction PSVError(message) {\n this.message = message;\n\n // Use V8's native method if available, otherwise fallback\n if ('captureStackTrace' in Error) {\n Error.captureStackTrace(this, PSVError);\n }\n else {\n this.stack = (new Error()).stack;\n }\n}\n\nPSVError.prototype = Object.create(Error.prototype);\nPSVError.prototype.name = 'PSVError';\nPSVError.prototype.constructor = PSVError;\n\nexport { PSVError };\n","import { PSVError } from '../PSVError';\n\n/**\n * @namespace PSV.adapters\n */\n\n/**\n * @summary Base adapters class\n * @memberof PSV.adapters\n * @abstract\n */\nexport class AbstractAdapter {\n\n /**\n * @summary Unique identifier of the adapter\n * @member {string}\n * @readonly\n * @static\n */\n static id = null;\n\n /**\n * @summary Indicates if the adapter supports panorama download natively\n * @type {boolean}\n * @readonly\n * @static\n */\n static supportsDownload = false;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n }\n\n /**\n * @summary Destroys the adapter\n */\n destroy() {\n delete this.psv;\n }\n\n /**\n * @summary Indicates if the adapter supports transitions between panoramas\n * @param {*} panorama\n * @return {boolean}\n */\n supportsTransition(panorama) { // eslint-disable-line no-unused-vars\n return false;\n }\n\n /**\n * @summary Indicates if the adapter supports preload of a panorama\n * @param {*} panorama\n * @return {boolean}\n */\n supportsPreload(panorama) { // eslint-disable-line no-unused-vars\n return false;\n }\n\n /**\n * @abstract\n * @summary Loads the panorama texture(s)\n * @param {*} panorama\n * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData]\n * @returns {Promise.}\n */\n loadTexture(panorama, newPanoData) { // eslint-disable-line no-unused-vars\n throw new PSVError('loadTexture not implemented');\n }\n\n /**\n * @abstract\n * @summary Creates the cube mesh\n * @param {number} [scale=1]\n * @returns {external:THREE.Mesh}\n */\n createMesh(scale = 1) { // eslint-disable-line no-unused-vars\n throw new PSVError('createMesh not implemented');\n }\n\n /**\n * @abstract\n * @summary Applies the texture to the mesh\n * @param {external:THREE.Mesh} mesh\n * @param {PSV.TextureData} textureData\n * @param {boolean} [transition=false]\n */\n setTexture(mesh, textureData, transition = false) { // eslint-disable-line no-unused-vars\n throw new PSVError('setTexture not implemented');\n }\n\n /**\n * @abstract\n * @summary Changes the opacity of the mesh\n * @param {external:THREE.Mesh} mesh\n * @param {number} opacity\n */\n setTextureOpacity(mesh, opacity) { // eslint-disable-line no-unused-vars\n throw new PSVError('setTextureOpacity not implemented');\n }\n\n /**\n * @abstract\n * @summary Clear a loaded texture from memory\n * @param {PSV.TextureData} textureData\n */\n disposeTexture(textureData) { // eslint-disable-line no-unused-vars\n throw new PSVError('disposeTexture not implemented');\n }\n\n}\n","/**\n * @namespace PSV.constants\n */\n\n/**\n * @summary Default duration of the transition between panoramas\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const DEFAULT_TRANSITION = 1500;\n\n/**\n * @summary Number of pixels bellow which a mouse move will be considered as a click\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const MOVE_THRESHOLD = 4;\n\n/**\n * @summary Delay in milliseconds between two clicks to consider a double click\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const DBLCLICK_DELAY = 300;\n\n/**\n * @summary Delay in milliseconds to emulate a long touch\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const LONGTOUCH_DELAY = 500;\n\n/**\n * @summary Delay in milliseconds to for the two fingers overlay to appear\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const TWOFINGERSOVERLAY_DELAY = 100;\n\n/**\n * @summary Duration in milliseconds of the \"ctrl zoom\" overlay\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const CTRLZOOM_TIMEOUT = 2000;\n\n/**\n * @summary Time size of the mouse position history used to compute inertia\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const INERTIA_WINDOW = 300;\n\n/**\n * @summary Radius of the THREE.SphereGeometry, Half-length of the THREE.BoxGeometry\n * @memberOf PSV.constants\n * @type {number}\n * @constant\n */\nexport const SPHERE_RADIUS = 10;\n\n/**\n * @summary Property name added to viewer element\n * @memberOf PSV.constants\n * @type {string}\n * @constant\n */\nexport const VIEWER_DATA = 'photoSphereViewer';\n\n/**\n * @summary Property added the the main Mesh object\n * @memberOf PSV.constants\n * @type {string}\n * @constant\n */\nexport const MESH_USER_DATA = 'psvSphere';\n\n/**\n * @summary Available actions\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const ACTIONS = {\n ROTATE_LAT_UP : 'rotateLatitudeUp',\n ROTATE_LAT_DOWN : 'rotateLatitudeDown',\n ROTATE_LONG_RIGHT: 'rotateLongitudeRight',\n ROTATE_LONG_LEFT : 'rotateLongitudeLeft',\n ZOOM_IN : 'zoomIn',\n ZOOM_OUT : 'zoomOut',\n TOGGLE_AUTOROTATE: 'toggleAutorotate',\n};\n\n/**\n * @summary Available events names\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event autorotate\n * @memberof PSV\n * @summary Triggered when the automatic rotation is enabled/disabled\n * @param {boolean} enabled\n */\n AUTOROTATE : 'autorotate',\n /**\n * @event before-render\n * @memberof PSV\n * @summary Triggered before a render, used to modify the view\n * @param {number} timestamp - time provided by requestAnimationFrame\n * @param {number} elapsed - time elapsed from the previous frame\n */\n BEFORE_RENDER : 'before-render',\n /**\n * @event before-rotate\n * @memberOf PSV\n * @summary Triggered before a rotate operation, can be cancelled\n * @param {PSV.ExtendedPosition}\n */\n BEFORE_ROTATE : 'before-rotate',\n /**\n * @event click\n * @memberof PSV\n * @summary Triggered when the user clicks on the viewer (everywhere excluding the navbar and the side panel)\n * @param {PSV.ClickData} data\n */\n CLICK : 'click',\n /**\n * @event close-panel\n * @memberof PSV\n * @summary Triggered when the panel is closed\n * @param {string} [id]\n */\n CLOSE_PANEL : 'close-panel',\n /**\n * @event config-changed\n * @memberOf PSV\n * @summary Triggered after a call to setOption/setOptions\n * @param {string[]} name of changed options\n */\n CONFIG_CHANGED : 'config-changed',\n /**\n * @event dblclick\n * @memberof PSV\n * @summary Triggered when the user double clicks on the viewer. The simple `click` event is always fired before `dblclick`\n * @param {PSV.ClickData} data\n */\n DOUBLE_CLICK : 'dblclick',\n /**\n * @event fullscreen-updated\n * @memberof PSV\n * @summary Triggered when the fullscreen mode is enabled/disabled\n * @param {boolean} enabled\n */\n FULLSCREEN_UPDATED: 'fullscreen-updated',\n /**\n * @event hide-notification\n * @memberof PSV\n * @summary Triggered when the notification is hidden\n * @param {string} [id]\n */\n HIDE_NOTIFICATION : 'hide-notification',\n /**\n * @event hide-overlay\n * @memberof PSV\n * @summary Triggered when the overlay is hidden\n * @param {string} [id]\n */\n HIDE_OVERLAY : 'hide-overlay',\n /**\n * @event hide-tooltip\n * @memberof PSV\n * @summary Triggered when the tooltip is hidden\n * @param {*} Data associated to this tooltip\n */\n HIDE_TOOLTIP : 'hide-tooltip',\n /**\n * @event key-press\n * @memberof PSV\n * @summary Triggered when a key is pressed, can be cancelled\n * @param {string} key\n */\n KEY_PRESS : 'key-press',\n /**\n * @event load-progress\n * @memberof PSV\n * @summary Triggered when the loader value changes\n * @param {number} value from 0 to 100\n */\n LOAD_PROGRESS : 'load-progress',\n /**\n * @event open-panel\n * @memberof PSV\n * @summary Triggered when the panel is opened\n * @param {string} [id]\n */\n OPEN_PANEL : 'open-panel',\n /**\n * @event panorama-loaded\n * @memberof PSV\n * @summary Triggered when a panorama image has been loaded\n * @param {PSV.TextureData} textureData\n */\n PANORAMA_LOADED : 'panorama-loaded',\n /**\n * @event position-updated\n * @memberof PSV\n * @summary Triggered when the view longitude and/or latitude changes\n * @param {PSV.Position} position\n */\n POSITION_UPDATED : 'position-updated',\n /**\n * @event ready\n * @memberof PSV\n * @summary Triggered when the panorama image has been loaded and the viewer is ready to perform the first render\n */\n READY : 'ready',\n /**\n * @event render\n * @memberof PSV\n * @summary Triggered on each viewer render, **this event is triggered very often**\n */\n RENDER : 'render',\n /**\n * @event show-notification\n * @memberof PSV\n * @summary Triggered when the notification is shown\n * @param {string} [id]\n */\n SHOW_NOTIFICATION : 'show-notification',\n /**\n * @event show-overlay\n * @memberof PSV\n * @summary Triggered when the overlay is shown\n * @param {string} [id]\n */\n SHOW_OVERLAY : 'show-overlay',\n /**\n * @event show-tooltip\n * @memberof PSV\n * @summary Triggered when the tooltip is shown\n * @param {*} Data associated to this tooltip\n * @param {PSV.components.Tooltip} Instance of the tooltip\n */\n SHOW_TOOLTIP : 'show-tooltip',\n /**\n * @event size-updated\n * @memberof PSV\n * @summary Triggered when the viewer size changes\n * @param {PSV.Size} size\n */\n SIZE_UPDATED : 'size-updated',\n /**\n * @event stop-all\n * @memberof PSV\n * @summary Triggered when all current animations are stopped\n */\n STOP_ALL : 'stop-all',\n /**\n * @event zoom-updated\n * @memberof PSV\n * @summary Triggered when the zoom level changes\n * @param {number} zoomLevel\n */\n ZOOM_UPDATED : 'zoom-updated',\n};\n\n/**\n * @summary Available change events names\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const CHANGE_EVENTS = {\n /**\n * @event get-animate-position\n * @memberof PSV\n * @param {Position} position\n * @returns {Position}\n * @summary Called to alter the target position of an animation\n */\n GET_ANIMATE_POSITION: 'get-animate-position',\n /**\n * @event get-rotate-position\n * @memberof PSV\n * @param {Position} position\n * @returns {Position}\n * @summary Called to alter the target position of a rotation\n */\n GET_ROTATE_POSITION : 'get-rotate-position',\n};\n\n/**\n * @summary Special events emitted to listener using {@link Viewer#observeObjects}\n * @memberOf PSV.constants\n * @constant\n * @package\n */\nexport const OBJECT_EVENTS = {\n ENTER_OBJECT: 'enter-object',\n HOVER_OBJECT: 'hover-object',\n LEAVE_OBJECT: 'leave-object',\n};\n\n/**\n * @summary Internal identifiers for various stuff\n * @memberOf PSV.constants\n * @enum {string}\n * @constant\n */\nexport const IDS = {\n MENU : 'menu',\n TWO_FINGERS: 'twoFingers',\n CTRL_ZOOM : 'ctrlZoom',\n ERROR : 'error',\n DESCRIPTION: 'description',\n};\n\n/* eslint-disable */\n// @formatter:off\n/**\n * @summary Collection of easing functions\n * @memberOf PSV.constants\n * @see {@link https://gist.github.com/frederickk/6165768}\n * @type {Object}\n * @constant\n */\nexport const EASINGS = {\n linear : (t) => t,\n\n inQuad : (t) => t*t,\n outQuad : (t) => t*(2-t),\n inOutQuad : (t) => t<.5 ? 2*t*t : -1+(4-2*t)*t,\n\n inCubic : (t) => t*t*t,\n outCubic : (t) => (--t)*t*t+1,\n inOutCubic: (t) => t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1,\n\n inQuart : (t) => t*t*t*t,\n outQuart : (t) => 1-(--t)*t*t*t,\n inOutQuart: (t) => t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t,\n\n inQuint : (t) => t*t*t*t*t,\n outQuint : (t) => 1+(--t)*t*t*t*t,\n inOutQuint: (t) => t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t,\n\n inSine : (t) => 1-Math.cos(t*(Math.PI/2)),\n outSine : (t) => Math.sin(t*(Math.PI/2)),\n inOutSine : (t) => .5-.5*Math.cos(Math.PI*t),\n\n inExpo : (t) => Math.pow(2, 10*(t-1)),\n outExpo : (t) => 1-Math.pow(2, -10*t),\n inOutExpo : (t) => (t=t*2-1)<0 ? .5*Math.pow(2, 10*t) : 1-.5*Math.pow(2, -10*t),\n\n inCirc : (t) => 1-Math.sqrt(1-t*t),\n outCirc : (t) => Math.sqrt(1-(t-1)*(t-1)),\n inOutCirc : (t) => (t*=2)<1 ? .5-.5*Math.sqrt(1-t*t) : .5+.5*Math.sqrt(1-(t-=2)*t)\n};\n// @formatter:on\n/* eslint-enable */\n\n/**\n * @summary Subset of key codes\n * @memberOf PSV.constants\n * @type {Object}\n * @constant\n */\nexport const KEY_CODES = {\n Enter : 'Enter',\n Control : 'Control',\n Escape : 'Escape',\n Space : ' ',\n PageUp : 'PageUp',\n PageDown : 'PageDown',\n ArrowLeft : 'ArrowLeft',\n ArrowUp : 'ArrowUp',\n ArrowRight: 'ArrowRight',\n ArrowDown : 'ArrowDown',\n Delete : 'Delete',\n Plus : '+',\n Minus : '-',\n};\n","import { PSVError } from '../PSVError';\n\n/**\n * @summary General information about the system\n * @constant\n * @memberOf PSV\n * @property {boolean} loaded - Indicates if the system data has been loaded\n * @property {Function} load - Loads the system if not already loaded\n * @property {number} pixelRatio\n * @property {boolean} isWebGLSupported\n * @property {number} maxCanvasWidth\n * @property {string} mouseWheelEvent\n * @property {string} fullscreenEvent\n * @property {Function} getMaxCanvasWidth - Returns the max width of a canvas allowed by the browser\n * @property {Promise} isTouchEnabled\n */\nexport const SYSTEM = {\n loaded : false,\n pixelRatio : 1,\n isWebGLSupported: false,\n isTouchEnabled : null,\n maxTextureWidth : 0,\n mouseWheelEvent : null,\n fullscreenEvent : null,\n};\n\n/**\n * @summary Loads the system if not already loaded\n */\nSYSTEM.load = () => {\n if (!SYSTEM.loaded) {\n const ctx = getWebGLCtx();\n\n SYSTEM.loaded = true;\n SYSTEM.pixelRatio = window.devicePixelRatio || 1;\n SYSTEM.isWebGLSupported = ctx != null;\n SYSTEM.isTouchEnabled = isTouchEnabled();\n SYSTEM.maxTextureWidth = getMaxTextureWidth(ctx);\n SYSTEM.mouseWheelEvent = getMouseWheelEvent();\n SYSTEM.fullscreenEvent = getFullscreenEvent();\n }\n};\n\nlet maxCanvasWidth = null;\nSYSTEM.getMaxCanvasWidth = () => {\n if (maxCanvasWidth === null) {\n maxCanvasWidth = getMaxCanvasWidth(SYSTEM.maxTextureWidth);\n }\n return maxCanvasWidth;\n};\n\n/**\n * @summary Tries to return a canvas webgl context\n * @returns {WebGLRenderingContext}\n * @private\n */\nfunction getWebGLCtx() {\n const canvas = document.createElement('canvas');\n const names = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d'];\n let context = null;\n\n if (!canvas.getContext) {\n return null;\n }\n\n if (names.some((name) => {\n try {\n context = canvas.getContext(name);\n return context !== null;\n }\n catch (e) {\n return false;\n }\n })) {\n return context;\n }\n else {\n return null;\n }\n}\n\n/**\n * @summary Detects if the user is using a touch screen\n * @returns {Promise}\n * @private\n */\nfunction isTouchEnabled() {\n return new Promise((resolve) => {\n const listener = (e) => {\n if (e) {\n resolve(true);\n }\n else {\n resolve(false);\n }\n\n window.removeEventListener('touchstart', listener);\n };\n\n window.addEventListener('touchstart', listener, false);\n\n // after 10 secs auto-reject the promise\n setTimeout(listener, 10000);\n });\n}\n\n/**\n * @summary Gets max texture width in WebGL context\n * @returns {number}\n * @private\n */\nfunction getMaxTextureWidth(ctx) {\n if (ctx !== null) {\n return ctx.getParameter(ctx.MAX_TEXTURE_SIZE);\n }\n else {\n return 0;\n }\n}\n\n/**\n * @summary Gets max canvas width supported by the browser.\n * We only test powers of 2 and height = width / 2 because that's what we need to generate WebGL textures\n * @param maxWidth\n * @return {number}\n * @private\n */\nfunction getMaxCanvasWidth(maxWidth) {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n canvas.width = maxWidth;\n canvas.height = maxWidth / 2;\n\n while (canvas.width > 1024) {\n ctx.fillStyle = 'white';\n ctx.fillRect(0, 0, 1, 1);\n\n try {\n if (ctx.getImageData(0, 0, 1, 1).data[0] === 255) {\n return canvas.width;\n }\n }\n catch (e) {\n // continue\n }\n\n canvas.width /= 2;\n canvas.height /= 2;\n }\n\n throw new PSVError('Unable to detect system capabilities');\n}\n\n/**\n * @summary Gets the event name for mouse wheel\n * @returns {string}\n * @private\n */\nfunction getMouseWheelEvent() {\n if ('onwheel' in document.createElement('div')) { // Modern browsers support \"wheel\"\n return 'wheel';\n }\n else if (document.onmousewheel !== undefined) { // Webkit and IE support at least \"mousewheel\"\n return 'mousewheel';\n }\n else { // let's assume that remaining browsers are older Firefox\n return 'DOMMouseScroll';\n }\n}\n\n/**\n * @summary Map between fullsceen method and fullscreen event name\n * @type {Object}\n * @readonly\n * @private\n */\nconst FULLSCREEN_EVT_MAP = {\n exitFullscreen : 'fullscreenchange',\n webkitExitFullscreen: 'webkitfullscreenchange',\n mozCancelFullScreen : 'mozfullscreenchange',\n msExitFullscreen : 'MSFullscreenChange',\n};\n\n\n/**\n * @summary Gets the event name for fullscreen\n * @returns {string}\n * @private\n */\nfunction getFullscreenEvent() {\n const validExits = Object.keys(FULLSCREEN_EVT_MAP).filter(exit => exit in document);\n\n if (validExits.length) {\n return FULLSCREEN_EVT_MAP[validExits[0]];\n }\n else {\n return null;\n }\n}\n","/**\n * @summary Toggles a CSS class\n * @memberOf PSV.utils\n * @param {HTMLElement|SVGElement} element\n * @param {string} className\n * @param {boolean} [active] - forced state\n */\nexport function toggleClass(element, className, active) {\n if (active === undefined) {\n element.classList.toggle(className);\n }\n else if (active && !element.classList.contains(className)) {\n element.classList.add(className);\n }\n else if (!active) {\n element.classList.remove(className);\n }\n}\n\n/**\n * @summary Adds one or several CSS classes to an element\n * @memberOf PSV.utils\n * @param {HTMLElement} element\n * @param {string} className\n */\nexport function addClasses(element, className) {\n if (className) {\n className.split(' ').forEach((name) => {\n toggleClass(element, name, true);\n });\n }\n}\n\n/**\n * @summary Removes one or several CSS classes to an element\n * @memberOf PSV.utils\n * @param {HTMLElement} element\n * @param {string} className\n */\nexport function removeClasses(element, className) {\n if (className) {\n className.split(' ').forEach((name) => {\n toggleClass(element, name, false);\n });\n }\n}\n\n/**\n * @summary Searches if an element has a particular parent at any level including itself\n * @memberOf PSV.utils\n * @param {HTMLElement} el\n * @param {HTMLElement} parent\n * @returns {boolean}\n */\nexport function hasParent(el, parent) {\n let test = el;\n\n do {\n if (test === parent) {\n return true;\n }\n test = test.parentNode;\n } while (test);\n\n return false;\n}\n\n/**\n * @summary Gets the closest parent (can by itself)\n * @memberOf PSV.utils\n * @param {HTMLElement|SVGElement} el\n * @param {string} selector\n * @returns {HTMLElement}\n */\nexport function getClosest(el, selector) {\n // When el is document or window, the matches does not exist\n if (!el.matches) {\n return null;\n }\n\n let test = el;\n\n do {\n if (test.matches(selector)) {\n return test;\n }\n test = test instanceof SVGElement ? test.parentNode : test.parentElement;\n } while (test);\n\n return null;\n}\n\n/**\n * @summary Gets the position of an element in the viewer without reflow\n * @description Will gives the same result as getBoundingClientRect() as soon as there are no CSS transforms\n * @memberOf PSV.utils\n * @param {HTMLElement} el\n * @return {{left: number, top: number}}\n */\nexport function getPosition(el) {\n let left = 0;\n let top = 0;\n let test = el;\n\n while (test) {\n left += (test.offsetLeft - test.scrollLeft + test.clientLeft);\n top += (test.offsetTop - test.scrollTop + test.clientTop);\n test = test.offsetParent;\n }\n\n return { left, top };\n}\n\n/**\n * @summary Detects if fullscreen is enabled\n * @memberOf PSV.utils\n * @param {HTMLElement} elt\n * @returns {boolean}\n */\nexport function isFullscreenEnabled(elt) {\n return (document.fullscreenElement || document.webkitFullscreenElement) === elt;\n}\n\n/**\n * @summary Enters fullscreen mode\n * @memberOf PSV.utils\n * @param {HTMLElement} elt\n */\nexport function requestFullscreen(elt) {\n (elt.requestFullscreen || elt.webkitRequestFullscreen).call(elt);\n}\n\n/**\n * @summary Exits fullscreen mode\n * @memberOf PSV.utils\n */\nexport function exitFullscreen() {\n (document.exitFullscreen || document.webkitExitFullscreen).call(document);\n}\n\n/**\n * @summary Gets an element style\n * @memberOf PSV.utils\n * @param {HTMLElement} elt\n * @param {string} prop\n * @returns {*}\n */\nexport function getStyle(elt, prop) {\n return window.getComputedStyle(elt, null)[prop];\n}\n\n/**\n * @summary Normalize mousewheel values accross browsers\n * @memberOf PSV.utils\n * @description From Facebook's Fixed Data Table\n * {@link https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js}\n * @copyright Facebook\n * @param {WheelEvent} event\n * @returns {{spinX: number, spinY: number, pixelX: number, pixelY: number}}\n */\nexport function normalizeWheel(event) {\n const PIXEL_STEP = 10;\n const LINE_HEIGHT = 40;\n const PAGE_HEIGHT = 800;\n\n let spinX = 0;\n let spinY = 0;\n let pixelX = 0;\n let pixelY = 0;\n\n // Legacy\n if ('detail' in event) {\n spinY = event.detail;\n }\n if ('wheelDelta' in event) {\n spinY = -event.wheelDelta / 120;\n }\n if ('wheelDeltaY' in event) {\n spinY = -event.wheelDeltaY / 120;\n }\n if ('wheelDeltaX' in event) {\n spinX = -event.wheelDeltaX / 120;\n }\n\n // side scrolling on FF with DOMMouseScroll\n if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {\n spinX = spinY;\n spinY = 0;\n }\n\n pixelX = spinX * PIXEL_STEP;\n pixelY = spinY * PIXEL_STEP;\n\n if ('deltaY' in event) {\n pixelY = event.deltaY;\n }\n if ('deltaX' in event) {\n pixelX = event.deltaX;\n }\n\n if ((pixelX || pixelY) && event.deltaMode) {\n // delta in LINE units\n if (event.deltaMode === 1) {\n pixelX *= LINE_HEIGHT;\n pixelY *= LINE_HEIGHT;\n }\n // delta in PAGE units\n else {\n pixelX *= PAGE_HEIGHT;\n pixelY *= PAGE_HEIGHT;\n }\n }\n\n // Fall-back if spin cannot be determined\n if (pixelX && !spinX) {\n spinX = (pixelX < 1) ? -1 : 1;\n }\n if (pixelY && !spinY) {\n spinY = (pixelY < 1) ? -1 : 1;\n }\n\n return { spinX, spinY, pixelX, pixelY };\n}\n","/**\n * @summary Ensures that a number is in a given interval\n * @memberOf PSV.utils\n * @param {number} x\n * @param {number} min\n * @param {number} max\n * @returns {number}\n */\nexport function bound(x, min, max) {\n return Math.max(min, Math.min(max, x));\n}\n\n/**\n * @summary Ensure a value is within 0 and `max`\n * @param {number} value\n * @param {number} max\n * @return {number}\n */\nexport function loop(value, max) {\n let result = value % max;\n\n if (result < 0) {\n result += max;\n }\n\n return result;\n}\n\n/**\n * @summary Checks if a value is an integer\n * @memberOf PSV.utils\n * @param {*} value\n * @returns {boolean}\n */\nexport function isInteger(value) {\n if (Number.isInteger) {\n return Number.isInteger(value);\n }\n return typeof value === 'number' && Number.isFinite(value) && Math.floor(value) === value;\n}\n\n/**\n * @summary Tests if a number is power of two\n * @memberOf PSV.utils\n * @param {number} x\n * @return {boolean}\n */\nexport function isPowerOfTwo(x) {\n return (Math.log(x) / Math.log(2)) % 1 === 0;\n}\n\n/**\n * @summary Computes the sum of an array\n * @memberOf PSV.utils\n * @param {number[]} array\n * @returns {number}\n */\nexport function sum(array) {\n return array.reduce((a, b) => a + b, 0);\n}\n\n/**\n * @summary Computes the distance between two points\n * @memberOf PSV.utils\n * @param {PSV.Point} p1\n * @param {PSV.Point} p2\n * @returns {number}\n */\nexport function distance(p1, p2) {\n return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));\n}\n\n/**\n * @summary Compute the shortest offset between two longitudes\n * @memberOf PSV.utils\n * @param {number} from\n * @param {number} to\n * @returns {number}\n */\nexport function getShortestArc(from, to) {\n const tCandidates = [\n 0, // direct\n Math.PI * 2, // clock-wise cross zero\n -Math.PI * 2, // counter-clock-wise cross zero\n ];\n\n return tCandidates.reduce((value, candidate) => {\n const newCandidate = to - from + candidate;\n return Math.abs(newCandidate) < Math.abs(value) ? newCandidate : value;\n }, Infinity);\n}\n\n/**\n * @summary Computes the angle between the current position and a target position\n * @memberOf PSV.utils\n * @param {PSV.Position} position1\n * @param {PSV.Position} position2\n * @returns {number}\n */\nexport function getAngle(position1, position2) {\n return Math.acos(\n Math.cos(position1.latitude)\n * Math.cos(position2.latitude)\n * Math.cos(position1.longitude - position2.longitude)\n + Math.sin(position1.latitude)\n * Math.sin(position2.latitude)\n );\n}\n\n/**\n * @summary Returns the distance between two points on a sphere of radius one\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @memberOf PSV.utils\n * @param {number[]} p1\n * @param {number[]} p2\n * @returns {number}\n */\nexport function greatArcDistance(p1, p2) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const x = (λ2 - λ1) * Math.cos((φ1 + φ2) / 2);\n const y = (φ2 - φ1);\n return Math.sqrt(x * x + y * y);\n}\n","/**\n * @summary Transforms a string to dash-case {@link https://github.com/shahata/dasherize}\n * @memberOf PSV.utils\n * @param {string} str\n * @returns {string}\n */\nexport function dasherize(str) {\n return str.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {\n return (i > 0 ? '-' : '') + s.toLowerCase();\n });\n}\n\n/**\n * @summary Returns a function, that, when invoked, will only be triggered at most once during a given window of time.\n * @memberOf PSV.utils\n * @copyright underscore.js - modified by Clément Prévost {@link http://stackoverflow.com/a/27078401}\n * @param {Function} func\n * @param {number} wait\n * @returns {Function}\n */\nexport function throttle(func, wait) {\n /* eslint-disable */\n let self, args, result;\n let timeout;\n let previous = 0;\n const later = function() {\n previous = Date.now();\n timeout = undefined;\n result = func.apply(self, args);\n if (!timeout) {\n self = args = null;\n }\n };\n return function() {\n const now = Date.now();\n if (!previous) {\n previous = now;\n }\n const remaining = wait - (now - previous);\n self = this;\n args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = undefined;\n }\n previous = now;\n result = func.apply(self, args);\n if (!timeout) {\n self = args = null;\n }\n }\n else if (!timeout) {\n timeout = setTimeout(later, remaining);\n }\n return result;\n };\n /* eslint-enable */\n}\n\n/**\n * @summary Test if an object is a plain object\n * @memberOf PSV.utils\n * @description Test if an object is a plain object, i.e. is constructed\n * by the built-in Object constructor and inherits directly from Object.prototype\n * or null. Some built-in objects pass the test, e.g. Math which is a plain object\n * and some host or exotic objects may pass also.\n * {@link http://stackoverflow.com/a/5878101/1207670}\n * @param {*} obj\n * @returns {boolean}\n */\nexport function isPlainObject(obj) {\n // Basic check for Type object that's not null\n if (typeof obj === 'object' && obj !== null) {\n // If Object.getPrototypeOf supported, use it\n if (typeof Object.getPrototypeOf === 'function') {\n const proto = Object.getPrototypeOf(obj);\n return proto === Object.prototype || proto === null;\n }\n\n // Otherwise, use internal class\n // This should be reliable as if getPrototypeOf not supported, is pre-ES5\n return Object.prototype.toString.call(obj) === '[object Object]';\n }\n\n // Not an object\n return false;\n}\n\n/**\n * @summary Merges the enumerable attributes of two objects\n * @memberOf PSV.utils\n * @description Replaces arrays and alters the target object.\n * @copyright Nicholas Fisher \n * @param {Object} target\n * @param {Object} src\n * @returns {Object} target\n */\nexport function deepmerge(target, src) {\n /* eslint-disable */\n let first = src;\n\n return (function merge(target, src) {\n if (Array.isArray(src)) {\n if (!target || !Array.isArray(target)) {\n target = [];\n }\n else {\n target.length = 0;\n }\n src.forEach(function(e, i) {\n target[i] = merge(null, e);\n });\n }\n else if (typeof src === 'object') {\n if (!target || Array.isArray(target)) {\n target = {};\n }\n Object.keys(src).forEach(function(key) {\n if (typeof src[key] !== 'object' || !src[key] || !isPlainObject(src[key])) {\n target[key] = src[key];\n }\n else if (src[key] != first) {\n if (!target[key]) {\n target[key] = merge(null, src[key]);\n }\n else {\n merge(target[key], src[key]);\n }\n }\n });\n }\n else {\n target = src;\n }\n\n return target;\n }(target, src));\n /* eslint-enable */\n}\n\n/**\n * @summary Deeply clones an object\n * @memberOf PSV.utils\n * @param {Object} src\n * @returns {Object}\n */\nexport function clone(src) {\n return deepmerge(null, src);\n}\n\n/**\n * @summery Test of an object is empty\n * @memberOf PSV.utils\n * @param {object} obj\n * @returns {boolean}\n */\nexport function isEmpty(obj) {\n return !obj || (Object.keys(obj).length === 0 && obj.constructor === Object);\n}\n\n/**\n * @summary Loops over enumerable properties of an object\n * @memberOf PSV.utils\n * @param {Object} object\n * @param {Function} callback\n */\nexport function each(object, callback) {\n Object.keys(object).forEach((key) => {\n callback(object[key], key);\n });\n}\n\n/**\n * @summary Returns if a valu is null or undefined\n * @memberOf PSV.utils\n * @param {*} val\n * @return {boolean}\n */\nexport function isNil(val) {\n return val === null || val === undefined;\n}\n\n/**\n * @summary Returns the first non null non undefined parameter\n * @memberOf PSV.utils\n * @param {*} values\n * @return {*}\n */\nexport function firstNonNull(...values) {\n for (const val of values) {\n if (!isNil(val)) {\n return val;\n }\n }\n\n return undefined;\n}\n","import * as THREE from 'three';\nimport { PSVError } from '../PSVError';\nimport { bound, loop } from './math';\n\n/**\n * @summary Returns the plugin constructor from the imported object\n * For retrocompatibility with previous default exports\n * @memberOf PSV.utils\n * @package\n */\nexport function pluginInterop(plugin, target) {\n if (plugin) {\n for (const [, p] of [['_', plugin], ...Object.entries(plugin)]) {\n if (p.prototype instanceof target) {\n return p;\n }\n }\n }\n return null;\n}\n\n/**\n * @summary Builds an Error with name 'AbortError'\n * @memberOf PSV.utils\n * @return {Error}\n */\nexport function getAbortError() {\n const error = new Error('Loading was aborted.');\n error.name = 'AbortError';\n return error;\n}\n\n/**\n * @summary Tests if an Error has name 'AbortError'\n * @memberOf PSV.utils\n * @param {Error} err\n * @return {boolean}\n */\nexport function isAbortError(err) {\n return err?.name === 'AbortError';\n}\n\n/**\n * @summary Displays a warning in the console\n * @memberOf PSV.utils\n * @param {string} message\n */\nexport function logWarn(message) {\n console.warn(`PhotoSphereViewer: ${message}`);\n}\n\n/**\n * @summary Checks if an object is a {PSV.ExtendedPosition}, ie has x/y or longitude/latitude\n * @memberOf PSV.utils\n * @param {object} object\n * @returns {boolean}\n */\nexport function isExtendedPosition(object) {\n return [['x', 'y'], ['longitude', 'latitude']].some(([key1, key2]) => {\n return object[key1] !== undefined && object[key2] !== undefined;\n });\n}\n\n/**\n * @summary Returns the value of a given attribute in the panorama metadata\n * @memberOf PSV.utils\n * @param {string} data\n * @param {string} attr\n * @returns (number)\n */\nexport function getXMPValue(data, attr) {\n // XMP data are stored in children\n let result = data.match('(.*)');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n // XMP data are stored in attributes\n result = data.match('GPano:' + attr + '=\"(.*?)\"');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n return null;\n}\n\n/**\n * @readonly\n * @private\n * @type {{top: string, left: string, bottom: string, center: string, right: string}}\n */\nconst CSS_POSITIONS = {\n top : '0%',\n bottom: '100%',\n left : '0%',\n right : '100%',\n center: '50%',\n};\n\n/**\n * @summary Translate CSS values like \"top center\" or \"10% 50%\" as top and left positions\n * @memberOf PSV.utils\n * @description The implementation is as close as possible to the \"background-position\" specification\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/background-position}\n * @param {string|PSV.Point} value\n * @returns {PSV.Point}\n */\nexport function parsePosition(value) {\n if (!value) {\n return { x: 0.5, y: 0.5 };\n }\n\n if (typeof value === 'object') {\n return value;\n }\n\n let tokens = value.toLocaleLowerCase().split(' ').slice(0, 2);\n\n if (tokens.length === 1) {\n if (CSS_POSITIONS[tokens[0]] !== undefined) {\n tokens = [tokens[0], 'center'];\n }\n else {\n tokens = [tokens[0], tokens[0]];\n }\n }\n\n const xFirst = tokens[1] !== 'left' && tokens[1] !== 'right' && tokens[0] !== 'top' && tokens[0] !== 'bottom';\n\n tokens = tokens.map(token => CSS_POSITIONS[token] || token);\n\n if (!xFirst) {\n tokens.reverse();\n }\n\n const parsed = tokens.join(' ').match(/^([0-9.]+)% ([0-9.]+)%$/);\n\n if (parsed) {\n return {\n x: parseFloat(parsed[1]) / 100,\n y: parseFloat(parsed[2]) / 100,\n };\n }\n else {\n return { x: 0.5, y: 0.5 };\n }\n}\n\n/**\n * @readonly\n * @private\n */\nconst LEFT_MAP = { 0: 'left', 0.5: 'center', 1: 'right' };\n/**\n * @readonly\n * @private\n */\nconst TOP_MAP = { 0: 'top', 0.5: 'center', 1: 'bottom' };\n\n/**\n * @summary Parse a CSS-like position into an array of position keywords among top, bottom, left, right and center\n * @memberOf PSV.utils\n * @param {string | string[]} value\n * @param {string} defaultValue\n * @param {boolean} [allowCenter=true]\n * @return {string[]}\n */\nexport function cleanPosition(value, defaultValue, allowCenter = true) {\n if (!value) {\n return defaultValue.split(' ');\n }\n\n if (typeof value === 'string') {\n const tempPos = parsePosition(value);\n\n if (!(tempPos.x in LEFT_MAP) || !(tempPos.y in TOP_MAP)) {\n throw new PSVError(`Unable to parse position \"${value}\"`);\n }\n\n value = [TOP_MAP[tempPos.y], LEFT_MAP[tempPos.x]];\n }\n\n if (!allowCenter && value[0] === 'center' && value[1] === 'center') {\n throw new PSVError('Unable to parse position \"center center\"');\n }\n\n return value;\n}\n\n/**\n * @summary Parses an speed\n * @memberOf PSV.utils\n * @param {string|number} speed - The speed, in radians/degrees/revolutions per second/minute\n * @returns {number} radians per second\n * @throws {PSV.PSVError} when the speed cannot be parsed\n */\nexport function parseSpeed(speed) {\n let parsed;\n\n if (typeof speed === 'string') {\n const speedStr = speed.toString().trim();\n\n // Speed extraction\n let speedValue = parseFloat(speedStr.replace(/^(-?[0-9]+(?:\\.[0-9]*)?).*$/, '$1'));\n const speedUnit = speedStr.replace(/^-?[0-9]+(?:\\.[0-9]*)?(.*)$/, '$1').trim();\n\n // \"per minute\" -> \"per second\"\n if (speedUnit.match(/(pm|per minute)$/)) {\n speedValue /= 60;\n }\n\n // Which unit?\n switch (speedUnit) {\n // Degrees per minute / second\n case 'dpm':\n case 'degrees per minute':\n case 'dps':\n case 'degrees per second':\n parsed = THREE.Math.degToRad(speedValue);\n break;\n\n // Radians per minute / second\n case 'rdpm':\n case 'radians per minute':\n case 'rdps':\n case 'radians per second':\n parsed = speedValue;\n break;\n\n // Revolutions per minute / second\n case 'rpm':\n case 'revolutions per minute':\n case 'rps':\n case 'revolutions per second':\n parsed = speedValue * Math.PI * 2;\n break;\n\n // Unknown unit\n default:\n throw new PSVError('Unknown speed unit \"' + speedUnit + '\"');\n }\n }\n else {\n parsed = speed;\n }\n\n return parsed;\n}\n\n/**\n * @summary Parses an angle value in radians or degrees and returns a normalized value in radians\n * @memberOf PSV.utils\n * @param {string|number} angle - eg: 3.14, 3.14rad, 180deg\n * @param {boolean} [zeroCenter=false] - normalize between -Pi - Pi instead of 0 - 2*Pi\n * @param {boolean} [halfCircle=zeroCenter] - normalize between -Pi/2 - Pi/2 instead of -Pi - Pi\n * @returns {number}\n * @throws {PSV.PSVError} when the angle cannot be parsed\n */\nexport function parseAngle(angle, zeroCenter = false, halfCircle = zeroCenter) {\n let parsed;\n\n if (typeof angle === 'string') {\n const match = angle.toLowerCase().trim().match(/^(-?[0-9]+(?:\\.[0-9]*)?)(.*)$/);\n\n if (!match) {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n const value = parseFloat(match[1]);\n const unit = match[2];\n\n if (unit) {\n switch (unit) {\n case 'deg':\n case 'degs':\n parsed = THREE.Math.degToRad(value);\n break;\n case 'rad':\n case 'rads':\n parsed = value;\n break;\n default:\n throw new PSVError('Unknown angle unit \"' + unit + '\"');\n }\n }\n else {\n parsed = value;\n }\n }\n else if (typeof angle === 'number' && !isNaN(angle)) {\n parsed = angle;\n }\n else {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n parsed = loop(zeroCenter ? parsed + Math.PI : parsed, Math.PI * 2);\n\n return zeroCenter ? bound(parsed - Math.PI, -Math.PI / (halfCircle ? 2 : 1), Math.PI / (halfCircle ? 2 : 1)) : parsed;\n}\n\n/**\n * @summary Creates a THREE texture from an image\n * @memberOf PSV.utils\n * @param {HTMLImageElement | HTMLCanvasElement} img\n * @return {external:THREE.Texture}\n */\nexport function createTexture(img) {\n const texture = new THREE.Texture(img);\n texture.needsUpdate = true;\n texture.minFilter = THREE.LinearFilter;\n texture.generateMipmaps = false;\n return texture;\n}\n\nconst quaternion = new THREE.Quaternion();\n\n/**\n * @summary Applies the inverse of Euler angles to a vector\n * @memberOf PSV.utils\n * @param {external:THREE.Vector3} vector\n * @param {external:THREE.Euler} euler\n */\nexport function applyEulerInverse(vector, euler) {\n quaternion.setFromEuler(euler).invert();\n vector.applyQuaternion(quaternion);\n}\n","import { EASINGS } from '../data/constants';\nimport { each } from './misc';\nimport { logWarn } from './psv';\n\n/**\n * @callback OnTick\n * @summary Function called for each animation frame with computed properties\n * @memberOf PSV.utils.Animation\n * @param {Object.} properties - current values\n * @param {float} progress - 0 to 1\n */\n\n/**\n * @summary Interpolation helper for animations\n * @memberOf PSV.utils\n * @description\n * Implements the Promise API with an additional \"cancel\" method.\n * The promise is resolved with `true` when the animation is completed and `false` if the animation is cancelled.\n * @example\n * const anim = new Animation({\n * properties: {\n * width: {start: 100, end: 200}\n * },\n * duration: 5000,\n * onTick: (properties) => element.style.width = `${properties.width}px`;\n * });\n *\n * anim.then((completed) => ...);\n *\n * anim.cancel()\n */\nexport class Animation {\n\n /**\n * @param {Object} options\n * @param {Object.} options.properties\n * @param {number} options.properties[].start\n * @param {number} options.properties[].end\n * @param {number} options.duration\n * @param {number} [options.delay=0]\n * @param {string} [options.easing='linear']\n * @param {PSV.utils.Animation.OnTick} options.onTick - called on each frame\n */\n constructor(options) {\n this.__callbacks = [];\n\n if (options) {\n if (!options.easing || typeof options.easing === 'string') {\n options.easing = EASINGS[options.easing || 'linear'];\n }\n\n this.__start = null;\n this.options = options;\n\n if (options.delay) {\n this.__delayTimeout = setTimeout(() => {\n this.__delayTimeout = null;\n this.__animationFrame = window.requestAnimationFrame(t => this.__run(t));\n }, options.delay);\n }\n else {\n this.__animationFrame = window.requestAnimationFrame(t => this.__run(t));\n }\n }\n else {\n this.__resolved = true;\n }\n }\n\n /**\n * @summary Main loop for the animation\n * @param {number} timestamp\n * @private\n */\n __run(timestamp) {\n // first iteration\n if (this.__start === null) {\n this.__start = timestamp;\n }\n\n // compute progress\n const progress = (timestamp - this.__start) / this.options.duration;\n const current = {};\n\n if (progress < 1.0) {\n // interpolate properties\n each(this.options.properties, (prop, name) => {\n if (prop) {\n current[name] = prop.start + (prop.end - prop.start) * this.options.easing(progress);\n }\n });\n this.options.onTick(current, progress);\n\n this.__animationFrame = window.requestAnimationFrame(t => this.__run(t));\n }\n else {\n // call onTick one last time with final values\n each(this.options.properties, (prop, name) => {\n if (prop) {\n current[name] = prop.end;\n }\n });\n this.options.onTick(current, 1.0);\n\n this.__animationFrame = window.requestAnimationFrame(() => {\n this.__resolved = true;\n this.__resolve(true);\n });\n }\n }\n\n /**\n * @private\n */\n __resolve(value) {\n this.__callbacks.forEach(cb => cb(value));\n this.__callbacks.length = 0;\n }\n\n /**\n * @summary Promise chaining\n * @param {Function} [onFulfilled] - Called when the animation is complete (true) or cancelled (false)\n * @param {Function} [onRejected] - deprecated\n * @returns {Promise}\n */\n then(onFulfilled = null, onRejected = null) {\n if (onRejected) {\n logWarn('Animation#then does not accept a rejection handler anymore');\n }\n\n if (this.__resolved || this.__cancelled) {\n return Promise.resolve(this.__resolved)\n .then(onFulfilled);\n }\n\n return new Promise((resolve) => {\n this.__callbacks.push(resolve);\n })\n .then(onFulfilled);\n }\n\n /**\n * @summary Cancels the animation\n */\n cancel() {\n if (!this.__cancelled && !this.__resolved) {\n this.__cancelled = true;\n this.__resolve(false);\n\n if (this.__delayTimeout) {\n window.clearTimeout(this.__delayTimeout);\n this.__delayTimeout = null;\n }\n if (this.__animationFrame) {\n window.cancelAnimationFrame(this.__animationFrame);\n this.__animationFrame = null;\n }\n }\n }\n\n /**\n * @deprecated not supported anymore\n */\n catch() {\n logWarn('Animation#catch is not supported anymore');\n return this.then();\n }\n\n /**\n * @deprecated not supported anymore\n */\n finally(onFinally) {\n logWarn('Animation#finally is not supported anymore');\n return this.then(onFinally);\n }\n\n /**\n * @deprecated not supported anymore\n */\n static resolve() {\n logWarn('Animation.resolve is not supported anymore');\n }\n\n}\n","import { PSVError } from '../PSVError';\nimport { bound, loop } from './index';\n\n/**\n * @summary Represents a variable that can dynamically change with time (using requestAnimationFrame)\n * @memberOf PSV.utils\n */\nexport class Dynamic {\n\n static STOP = 0;\n static INFINITE = 1;\n static POSITION = 2;\n\n /**\n * @param {Function} [fn] Callback function\n * @param {number} [defaultValue] Default position\n * @param {number} [min] Minimum position\n * @param {number} [max] Maximum position\n * @param {boolean} [loopValue] Loop value between min and max\n */\n constructor(fn, defaultValue = 0, min = -Infinity, max = Infinity, loopValue = false) {\n /**\n * @type {Function}\n * @private\n * @readonly\n */\n this.fn = fn;\n\n /**\n * @type {number}\n * @private\n */\n this.mode = Dynamic.STOP;\n\n /**\n * @type {number}\n * @private\n */\n this.speed = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.speedMult = 1;\n\n /**\n * @type {number}\n * @private\n */\n this.currentSpeed = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.target = 0;\n\n /**\n * @type {number}\n * @readonly\n */\n this.current = defaultValue;\n\n /**\n * @type {number}\n * @private\n */\n this.min = min;\n\n /**\n * @type {number}\n * @private\n */\n this.max = max;\n\n /**\n * @type {boolean}\n * @private\n */\n this.loopValue = loopValue;\n\n if (loopValue && min !== 0) {\n throw new PSVError('invalid config');\n }\n\n if (this.fn) {\n this.fn(defaultValue);\n }\n }\n\n /**\n * Changes base speed\n * @param {number} speed\n */\n setSpeed(speed) {\n this.speed = speed;\n }\n\n /**\n * Defines the target position\n * @param {number} position\n * @param {number} [speedMult=1]\n */\n goto(position, speedMult = 1) {\n this.mode = Dynamic.POSITION;\n this.target = this.loopValue ? loop(position, this.max) : bound(position, this.min, this.max);\n this.speedMult = speedMult;\n }\n\n /**\n * Increase/decrease the target position\n * @param {number} step\n * @param {number} [speedMult=1]\n */\n step(step, speedMult = 1) {\n if (this.mode !== Dynamic.POSITION) {\n this.target = this.current;\n }\n this.goto(this.target + step, speedMult);\n }\n\n /**\n * Starts infinite movement\n * @param {boolean} [invert=false]\n * @param {number} [speedMult=1]\n */\n roll(invert = false, speedMult = 1) {\n this.mode = Dynamic.INFINITE;\n this.target = invert ? -Infinity : Infinity;\n this.speedMult = speedMult;\n }\n\n /**\n * Stops movement\n */\n stop() {\n this.mode = Dynamic.STOP;\n }\n\n /**\n * Defines the current position and immediately stops movement\n * @param {number} value\n */\n setValue(value) {\n this.target = this.loopValue ? loop(value, this.max) : bound(value, this.min, this.max);\n this.mode = Dynamic.STOP;\n if (this.target !== this.current) {\n this.current = this.target;\n if (this.fn) {\n this.fn(this.current);\n }\n return true;\n }\n return false;\n }\n\n /**\n * @package\n */\n update(elapsed) {\n // in position mode switch to stop mode when in the decceleration window\n if (this.mode === Dynamic.POSITION) {\n // in loop mode, alter \"current\" to avoid crossing the origin\n if (this.loopValue && Math.abs(this.target - this.current) > this.max / 2) {\n this.current = this.current < this.target ? this.current + this.max : this.current - this.max;\n }\n\n const dstStop = this.currentSpeed * this.currentSpeed / (this.speed * this.speedMult * 4);\n if (Math.abs(this.target - this.current) <= dstStop) {\n this.mode = Dynamic.STOP;\n }\n }\n\n // compute speed\n let targetSpeed = this.mode === Dynamic.STOP ? 0 : this.speed * this.speedMult;\n if (this.target < this.current) {\n targetSpeed = -targetSpeed;\n }\n if (this.currentSpeed < targetSpeed) {\n this.currentSpeed = Math.min(targetSpeed, this.currentSpeed + elapsed / 1000 * this.speed * this.speedMult * 2);\n }\n else if (this.currentSpeed > targetSpeed) {\n this.currentSpeed = Math.max(targetSpeed, this.currentSpeed - elapsed / 1000 * this.speed * this.speedMult * 2);\n }\n\n // compute new position\n let next = null;\n if (this.current > this.target && this.currentSpeed) {\n next = Math.max(this.target, this.current + this.currentSpeed * elapsed / 1000);\n }\n else if (this.current < this.target && this.currentSpeed) {\n next = Math.min(this.target, this.current + this.currentSpeed * elapsed / 1000);\n }\n\n // apply value\n if (next !== null) {\n next = this.loopValue ? loop(next, this.max) : bound(next, this.min, this.max);\n if (next !== this.current) {\n this.current = next;\n if (this.fn) {\n this.fn(this.current);\n }\n return true;\n }\n }\n\n return false;\n }\n\n}\n","import { each } from './index';\n\n/**\n * @summary Wrapper for multiple {@link PSV.utils.Dynamic} evolving together\n * @memberOf PSV.utils\n */\nexport class MultiDynamic {\n\n /**\n * @type {Object}\n * @readonly\n */\n get current() {\n const values = {};\n each(this.dynamics, (dynamic, name) => {\n values[name] = dynamic.current;\n });\n return values;\n }\n\n /**\n * @param {Record} dynamics\n * @param {Function} [fn] Callback function\n */\n constructor(dynamics, fn) {\n /**\n * @type {Function}\n * @private\n * @readonly\n */\n this.fn = fn;\n\n /**\n * @type {Record}\n * @private\n * @readonly\n */\n this.dynamics = dynamics;\n\n if (this.fn) {\n this.fn(this.current);\n }\n }\n\n /**\n * Changes base speed\n * @param {number} speed\n */\n setSpeed(speed) {\n each(this.dynamics, (d) => {\n d.setSpeed(speed);\n });\n }\n\n /**\n * Defines the target positions\n * @param {Record} positions\n * @param {number} [speedMult=1]\n */\n goto(positions, speedMult = 1) {\n each(positions, (position, name) => {\n this.dynamics[name].goto(position, speedMult);\n });\n }\n\n /**\n * Increase/decrease the target positions\n * @param {Record} steps\n * @param {number} [speedMult=1]\n */\n step(steps, speedMult = 1) {\n each(steps, (step, name) => {\n this.dynamics[name].step(step, speedMult);\n });\n }\n\n /**\n * Starts infinite movements\n * @param {Record} rolls\n * @param {number} [speedMult=1]\n */\n roll(rolls, speedMult = 1) {\n each(rolls, (roll, name) => {\n this.dynamics[name].roll(roll, speedMult);\n });\n }\n\n /**\n * Stops movements\n */\n stop() {\n each(this.dynamics, d => d.stop());\n }\n\n /**\n * Defines the current positions and immediately stops movements\n * @param {Record} values\n */\n setValue(values) {\n let hasUpdates = false;\n each(values, (value, name) => {\n hasUpdates |= this.dynamics[name].setValue(value);\n });\n\n if (hasUpdates && this.fn) {\n this.fn(this.current);\n }\n\n return hasUpdates;\n }\n\n /**\n * @package\n */\n update(elapsed) {\n let hasUpdates = false;\n each(this.dynamics, (dynamic) => {\n hasUpdates |= dynamic.update(elapsed);\n });\n\n if (hasUpdates && this.fn) {\n this.fn(this.current);\n }\n\n return hasUpdates;\n }\n\n}\n","import { EventEmitter } from 'uevent';\n\n/**\n * @summary Helper to make sliders elements\n * @memberOf PSV.utils\n */\nexport class Slider extends EventEmitter {\n\n static VERTICAL = 1;\n static HORIZONTAL = 2;\n\n /**\n * @type {boolean}\n * @readonly\n */\n get vertical() {\n return this.prop.direction === Slider.VERTICAL;\n }\n\n constructor({ psv, container, direction, onUpdate }) {\n super();\n\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n\n /**\n * @member {HTMLElement}\n * @readonly\n */\n this.container = container;\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @protected\n * @property {boolean} mousedown\n * @property {number} mediaMinWidth\n */\n this.prop = {\n onUpdate : onUpdate,\n direction: direction,\n mousedown: false,\n mouseover: false,\n };\n\n this.container.addEventListener('click', this);\n this.container.addEventListener('mousedown', this);\n this.container.addEventListener('mouseenter', this);\n this.container.addEventListener('mouseleave', this);\n this.container.addEventListener('touchstart', this);\n this.container.addEventListener('mousemove', this, true);\n this.container.addEventListener('touchmove', this, true);\n window.addEventListener('mouseup', this);\n window.addEventListener('touchend', this);\n }\n\n /**\n * @protected\n */\n destroy() {\n window.removeEventListener('mouseup', this);\n window.removeEventListener('touchend', this);\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'click': e.stopPropagation(); break;\n case 'mousedown': this.__onMouseDown(e); break;\n case 'mouseenter': this.__onMouseEnter(e); break;\n case 'mouseleave': this.__onMouseLeave(e); break;\n case 'touchstart': this.__onTouchStart(e); break;\n case 'mousemove': this.__onMouseMove(e); break;\n case 'touchmove': this.__onTouchMove(e); break;\n case 'mouseup': this.__onMouseUp(e); break;\n case 'touchend': this.__onTouchEnd(e); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @private\n */\n __onMouseDown(evt) {\n this.prop.mousedown = true;\n this.__update(evt, true);\n }\n\n /**\n * @private\n */\n __onMouseEnter(evt) {\n this.prop.mouseover = true;\n this.__update(evt, true);\n }\n\n /**\n * @private\n */\n __onTouchStart(evt) {\n this.prop.mouseover = true;\n this.prop.mousedown = true;\n this.__update(evt.changedTouches[0], true);\n }\n\n /**\n * @private\n */\n __onMouseMove(evt) {\n if (this.prop.mousedown || this.prop.mouseover) {\n evt.stopPropagation();\n this.__update(evt, true);\n }\n }\n\n /**\n * @private\n */\n __onTouchMove(evt) {\n if (this.prop.mousedown || this.prop.mouseover) {\n evt.stopPropagation();\n this.__update(evt.changedTouches[0], true);\n }\n }\n\n /**\n * @private\n */\n __onMouseUp(evt) {\n if (this.prop.mousedown) {\n this.prop.mousedown = false;\n this.__update(evt, false);\n }\n }\n\n /**\n * @private\n */\n __onMouseLeave(evt) {\n if (this.prop.mouseover) {\n this.prop.mouseover = false;\n this.__update(evt, true);\n }\n }\n\n /**\n * @private\n */\n __onTouchEnd(evt) {\n if (this.prop.mousedown) {\n this.prop.mouseover = false;\n this.prop.mousedown = false;\n this.__update(evt.changedTouches[0], false);\n }\n }\n\n /**\n * @private\n */\n __update(evt, moving) {\n const boundingClientRect = this.container.getBoundingClientRect();\n const cursor = evt[this.vertical ? 'clientY' : 'clientX'];\n const pos = boundingClientRect[this.vertical ? 'bottom' : 'left'];\n const size = boundingClientRect[this.vertical ? 'height' : 'width'];\n const val = Math.abs((pos - cursor) / size);\n\n this.prop.onUpdate({\n value : val,\n click : !moving,\n mousedown: this.prop.mousedown,\n mouseover: this.prop.mouseover,\n cursor : evt,\n });\n }\n\n}\n","/**\n * @namespace PSV.utils\n */\n\nexport * from './browser';\nexport * from './math';\nexport * from './misc';\nexport * from './psv';\n\nexport * from './Animation';\nexport * from './Dynamic';\nexport * from './MultiDynamic';\nexport * from './Slider';\n","import * as THREE from 'three';\nimport { SPHERE_RADIUS } from '../../data/constants';\nimport { SYSTEM } from '../../data/system';\nimport { PSVError } from '../../PSVError';\nimport { createTexture, firstNonNull, getXMPValue, isPowerOfTwo, logWarn } from '../../utils';\nimport { AbstractAdapter } from '../AbstractAdapter';\n\n\n/**\n * @typedef {Object} PSV.adapters.EquirectangularAdapter.Options\n * @property {number} [resolution=64] - number of faces of the sphere geometry, higher values may decrease performances\n */\n\n\n/**\n * @summary Adapter for equirectangular panoramas\n * @memberof PSV.adapters\n * @extends PSV.adapters.AbstractAdapter\n */\nexport class EquirectangularAdapter extends AbstractAdapter {\n\n static id = 'equirectangular';\n static supportsDownload = true;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.adapters.EquirectangularAdapter.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {PSV.adapters.EquirectangularAdapter.Options}\n * @private\n */\n this.config = {\n resolution: 64,\n ...options,\n };\n\n if (!isPowerOfTwo(this.config.resolution)) {\n throw new PSVError('EquirectangularAdapter resolution must be power of two');\n }\n\n this.SPHERE_SEGMENTS = this.config.resolution;\n this.SPHERE_HORIZONTAL_SEGMENTS = this.SPHERE_SEGMENTS / 2;\n }\n\n /**\n * @override\n */\n supportsTransition() {\n return true;\n }\n\n /**\n * @override\n */\n supportsPreload() {\n return true;\n }\n\n /**\n * @override\n * @param {string} panorama\n * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData]\n * @returns {Promise.}\n */\n loadTexture(panorama, newPanoData) {\n if (typeof panorama !== 'string') {\n if (Array.isArray(panorama) || typeof panorama === 'object' && !!panorama.left) {\n logWarn('Cubemap support now requires an additional adapter, see https://photo-sphere-viewer.js.org/guide/adapters');\n }\n return Promise.reject(new PSVError('Invalid panorama url, are you using the right adapter?'));\n }\n\n return (\n !this.psv.config.useXmpData\n ? this.psv.textureLoader.loadImage(panorama, p => this.psv.loader.setProgress(p))\n .then(img => ({ img: img, xmpPanoData: null }))\n : this.__loadXMP(panorama, p => this.psv.loader.setProgress(p))\n .then(xmpPanoData => this.psv.textureLoader.loadImage(panorama).then(img => ({ img, xmpPanoData })))\n )\n .then(({ img, xmpPanoData }) => {\n if (typeof newPanoData === 'function') {\n newPanoData = newPanoData(img);\n }\n\n const panoData = {\n fullWidth : firstNonNull(newPanoData?.fullWidth, xmpPanoData?.fullWidth, img.width),\n fullHeight : firstNonNull(newPanoData?.fullHeight, xmpPanoData?.fullHeight, img.height),\n croppedWidth : firstNonNull(newPanoData?.croppedWidth, xmpPanoData?.croppedWidth, img.width),\n croppedHeight: firstNonNull(newPanoData?.croppedHeight, xmpPanoData?.croppedHeight, img.height),\n croppedX : firstNonNull(newPanoData?.croppedX, xmpPanoData?.croppedX, 0),\n croppedY : firstNonNull(newPanoData?.croppedY, xmpPanoData?.croppedY, 0),\n poseHeading : firstNonNull(newPanoData?.poseHeading, xmpPanoData?.poseHeading, 0),\n posePitch : firstNonNull(newPanoData?.posePitch, xmpPanoData?.posePitch, 0),\n poseRoll : firstNonNull(newPanoData?.poseRoll, xmpPanoData?.poseRoll, 0),\n };\n\n if (panoData.croppedWidth !== img.width || panoData.croppedHeight !== img.height) {\n logWarn(`Invalid panoData, croppedWidth and/or croppedHeight is not coherent with loaded image.\n panoData: ${panoData.croppedWidth}x${panoData.croppedHeight}, image: ${img.width}x${img.height}`);\n }\n if ((newPanoData || xmpPanoData) && panoData.fullWidth !== panoData.fullHeight * 2) {\n logWarn('Invalid panoData, fullWidth should be twice fullHeight');\n }\n\n const texture = this.__createEquirectangularTexture(img, panoData);\n\n return { panorama, texture, panoData };\n });\n }\n\n /**\n * @summary Loads the XMP data of an image\n * @param {string} panorama\n * @param {function(number)} [onProgress]\n * @returns {Promise}\n * @throws {PSV.PSVError} when the image cannot be loaded\n * @private\n */\n __loadXMP(panorama, onProgress) {\n return this.psv.textureLoader.loadFile(panorama, onProgress)\n .then(blob => this.__loadBlobAsString(blob))\n .then((binary) => {\n const a = binary.indexOf('');\n const data = binary.substring(a, b);\n\n if (a !== -1 && b !== -1 && data.includes('GPano:')) {\n return {\n fullWidth : getXMPValue(data, 'FullPanoWidthPixels'),\n fullHeight : getXMPValue(data, 'FullPanoHeightPixels'),\n croppedWidth : getXMPValue(data, 'CroppedAreaImageWidthPixels'),\n croppedHeight: getXMPValue(data, 'CroppedAreaImageHeightPixels'),\n croppedX : getXMPValue(data, 'CroppedAreaLeftPixels'),\n croppedY : getXMPValue(data, 'CroppedAreaTopPixels'),\n poseHeading : getXMPValue(data, 'PoseHeadingDegrees'),\n posePitch : getXMPValue(data, 'PosePitchDegrees'),\n poseRoll : getXMPValue(data, 'PoseRollDegrees'),\n };\n }\n\n return null;\n });\n }\n\n /**\n * @summmary read a Blob as string\n * @param {Blob} blob\n * @returns {Promise}\n * @private\n */\n __loadBlobAsString(blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result);\n reader.onerror = reject;\n reader.readAsText(blob);\n });\n }\n\n /**\n * @summary Creates the final texture from image and panorama data\n * @param {Image} img\n * @param {PSV.PanoData} panoData\n * @returns {external:THREE.Texture}\n * @private\n */\n __createEquirectangularTexture(img, panoData) {\n // resize image / fill cropped parts with black\n if (panoData.fullWidth > SYSTEM.maxTextureWidth\n || panoData.croppedWidth !== panoData.fullWidth\n || panoData.croppedHeight !== panoData.fullHeight\n ) {\n const ratio = SYSTEM.getMaxCanvasWidth() / panoData.fullWidth;\n\n const resizedPanoData = { ...panoData };\n if (ratio < 1) {\n resizedPanoData.fullWidth *= ratio;\n resizedPanoData.fullHeight *= ratio;\n resizedPanoData.croppedWidth *= ratio;\n resizedPanoData.croppedHeight *= ratio;\n resizedPanoData.croppedX *= ratio;\n resizedPanoData.croppedY *= ratio;\n }\n\n const buffer = document.createElement('canvas');\n buffer.width = resizedPanoData.fullWidth;\n buffer.height = resizedPanoData.fullHeight;\n\n const ctx = buffer.getContext('2d');\n ctx.drawImage(img,\n resizedPanoData.croppedX, resizedPanoData.croppedY,\n resizedPanoData.croppedWidth, resizedPanoData.croppedHeight);\n\n return createTexture(buffer);\n }\n\n return createTexture(img);\n }\n\n /**\n * @override\n */\n createMesh(scale = 1) {\n // The middle of the panorama is placed at longitude=0\n const geometry = new THREE.SphereGeometry(\n SPHERE_RADIUS * scale,\n this.SPHERE_SEGMENTS,\n this.SPHERE_HORIZONTAL_SEGMENTS,\n -Math.PI / 2\n )\n .scale(-1, 1, 1);\n\n const material = new THREE.MeshBasicMaterial();\n\n return new THREE.Mesh(geometry, material);\n }\n\n /**\n * @override\n */\n setTexture(mesh, textureData) {\n mesh.material.map?.dispose();\n mesh.material.map = textureData.texture;\n }\n\n /**\n * @override\n */\n setTextureOpacity(mesh, opacity) {\n mesh.material.opacity = opacity;\n mesh.material.transparent = opacity < 1;\n }\n\n /**\n * @override\n */\n disposeTexture(textureData) {\n textureData.texture?.dispose();\n }\n\n}\n","/**\n * @namespace PSV.components\n */\n\n/**\n * @summary Base component class\n * @memberof PSV.components\n * @abstract\n */\nexport class AbstractComponent {\n\n /**\n * @param {PSV.Viewer | PSV.components.AbstractComponent} parent\n * @param {string} className - CSS class added to the component's container\n */\n constructor(parent, className) {\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = parent.psv || parent;\n\n /**\n * @member {PSV.Viewer|PSV.components.AbstractComponent}\n * @readonly\n */\n this.parent = parent;\n this.parent.children.push(this);\n\n /**\n * @summary All child components\n * @type {PSV.components.AbstractComponent[]}\n * @readonly\n * @package\n */\n this.children = [];\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @protected\n * @property {boolean} visible - Visibility of the component\n */\n this.prop = {\n visible: true,\n };\n\n /**\n * @member {HTMLElement}\n * @readonly\n */\n this.container = document.createElement('div');\n this.container.className = className;\n this.parent.container.appendChild(this.container);\n }\n\n /**\n * @summary Destroys the component\n * @protected\n */\n destroy() {\n this.parent.container.removeChild(this.container);\n\n const childIdx = this.parent.children.indexOf(this);\n if (childIdx !== -1) {\n this.parent.children.splice(childIdx, 1);\n }\n\n this.children.slice().forEach(child => child.destroy());\n this.children.length = 0;\n\n delete this.container;\n delete this.parent;\n delete this.psv;\n delete this.prop;\n }\n\n /**\n * @summary Refresh UI\n * @description Must be be a very lightweight operation\n * @package\n */\n refreshUi() {\n this.children.every((child) => {\n child.refreshUi();\n return this.psv.prop.uiRefresh === true;\n });\n }\n\n /**\n * @summary Displays or hides the component\n */\n toggle() {\n if (this.isVisible()) {\n this.hide();\n }\n else {\n this.show();\n }\n }\n\n /**\n * @summary Hides the component\n */\n hide() {\n this.container.style.display = 'none';\n this.prop.visible = false;\n }\n\n /**\n * @summary Displays the component\n */\n show() {\n this.container.style.display = '';\n this.prop.visible = true;\n }\n\n /**\n * @summary Checks if the component is visible\n * @returns {boolean}\n */\n isVisible() {\n return this.prop.visible;\n }\n\n}\n","import { AbstractComponent } from '../components/AbstractComponent';\nimport { KEY_CODES } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { isPlainObject, toggleClass } from '../utils';\n\n/**\n * @namespace PSV.buttons\n */\n\n/**\n * @summary Base navbar button class\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.buttons\n * @abstract\n */\nexport class AbstractButton extends AbstractComponent {\n\n /**\n * @summary Unique identifier of the button\n * @member {string}\n * @readonly\n * @static\n */\n static id = null;\n\n /**\n * @summary Identifier to declare a group of buttons\n * @member {string}\n * @readonly\n * @static\n */\n static groupId = null;\n\n /**\n * @summary SVG icon name injected in the button\n * @member {string}\n * @readonly\n * @static\n */\n static icon = null;\n\n /**\n * @summary SVG icon name injected in the button when it is active\n * @member {string}\n * @readonly\n * @static\n */\n static iconActive = null;\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {string} [className] - Additional CSS classes\n * @param {boolean} [collapsable=false] - `true` if the button can be moved to menu when the navbar is too small\n * @param {boolean} [tabbable=true] - `true` if the button is accessible with the keyboard\n */\n constructor(navbar, className = '', collapsable = false, tabbable = true) {\n super(navbar, 'psv-button ' + className);\n\n /**\n * @override\n * @property {string} id - Unique identifier of the button\n * @property {boolean} enabled\n * @property {boolean} supported\n * @property {boolean} collapsed\n * @property {boolean} active\n * @property {number} width\n */\n this.prop = {\n ...this.prop,\n id : this.constructor.id,\n collapsable: collapsable,\n enabled : true,\n supported : true,\n collapsed : false,\n active : false,\n width : this.container.offsetWidth,\n };\n\n if (this.constructor.icon) {\n this.__setIcon(this.constructor.icon);\n }\n\n if (this.prop.id && this.psv.config.lang[this.prop.id]) {\n this.container.title = this.psv.config.lang[this.prop.id];\n }\n\n if (tabbable) {\n this.container.tabIndex = 0;\n }\n\n this.container.addEventListener('click', (e) => {\n if (this.prop.enabled) {\n this.onClick();\n }\n e.stopPropagation();\n });\n\n this.container.addEventListener('keydown', (e) => {\n if (e.key === KEY_CODES.Enter && this.prop.enabled) {\n this.onClick();\n e.stopPropagation();\n }\n });\n }\n\n /**\n * @package\n */\n checkSupported() {\n const supportedOrObject = this.isSupported();\n if (isPlainObject(supportedOrObject)) {\n if (supportedOrObject.initial === false) {\n this.hide();\n this.prop.supported = false;\n }\n\n supportedOrObject.promise.then((supported) => {\n if (!this.prop) {\n return; // the component has been destroyed\n }\n this.prop.supported = supported;\n if (!supported) {\n this.hide();\n }\n else {\n this.show();\n }\n });\n }\n else {\n this.prop.supported = supportedOrObject;\n if (!supportedOrObject) {\n this.hide();\n }\n else {\n this.show();\n }\n }\n }\n\n /**\n * @summary Checks if the button can be displayed\n * @returns {boolean|{initial: boolean, promise: Promise}}\n */\n isSupported() {\n return true;\n }\n\n /**\n * @summary Changes the active state of the button\n * @param {boolean} [active] - forced state\n */\n toggleActive(active) {\n this.prop.active = active !== undefined ? active : !this.prop.active;\n toggleClass(this.container, 'psv-button--active', this.prop.active);\n\n if (this.constructor.iconActive) {\n this.__setIcon(this.prop.active ? this.constructor.iconActive : this.constructor.icon);\n }\n }\n\n /**\n * @override\n */\n show(refresh = true) {\n if (!this.isVisible()) {\n this.prop.visible = true;\n if (!this.prop.collapsed) {\n this.container.style.display = '';\n }\n if (refresh) {\n this.psv.refreshUi(`show button ${this.prop.id}`);\n }\n }\n }\n\n /**\n * @override\n */\n hide(refresh = true) {\n if (this.isVisible()) {\n this.prop.visible = false;\n this.container.style.display = 'none';\n if (refresh) {\n this.psv.refreshUi(`hide button ${this.prop.id}`);\n }\n }\n }\n\n /**\n * @summary Disables the button\n */\n disable() {\n this.container.classList.add('psv-button--disabled');\n this.prop.enabled = false;\n }\n\n /**\n * @summary Enables the button\n */\n enable() {\n this.container.classList.remove('psv-button--disabled');\n this.prop.enabled = true;\n }\n\n /**\n * @summary Collapses the button in the navbar menu\n */\n collapse() {\n this.prop.collapsed = true;\n this.container.style.display = 'none';\n }\n\n /**\n * @summary Uncollapses the button from the navbar menu\n */\n uncollapse() {\n this.prop.collapsed = false;\n if (this.prop.visible) {\n this.container.style.display = '';\n }\n }\n\n /**\n * @summary Set the button icon\n * @param {string} icon SVG\n * @param {HTMLElement} [container] - default is the main button container\n * @private\n */\n __setIcon(icon, container = this.container) {\n if (icon) {\n container.innerHTML = icon;\n // className is read-only on SVGElement\n container.querySelector('svg').classList.add('psv-button-svg');\n }\n else {\n container.innerHTML = '';\n }\n }\n\n /**\n * @summary Action when the button is clicked\n * @private\n * @abstract\n */\n onClick() {\n throw new PSVError(`onClick not implemented for button \"${this.prop.id}\".`);\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport playActive from '../icons/play-active.svg';\nimport play from '../icons/play.svg';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar autorotate button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class AutorotateButton extends AbstractButton {\n\n static id = 'autorotate';\n static icon = play;\n static iconActive = playActive;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-autorotate-button', true);\n\n this.psv.on(EVENTS.AUTOROTATE, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.AUTOROTATE, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.AUTOROTATE: this.toggleActive(e.args[0]); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles autorotate\n */\n onClick() {\n this.psv.toggleAutorotate();\n }\n\n}\n","import { addClasses } from '../utils';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar custom button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class CustomButton extends AbstractButton {\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {PSV.NavbarCustomButton} config\n */\n constructor(navbar, config) {\n super(navbar, 'psv-custom-button', config.collapsable !== false, config.tabbable !== false);\n\n /**\n * @member {Object}\n * @readonly\n * @private\n */\n this.config = config;\n\n if (this.config.id) {\n this.prop.id = this.config.id;\n }\n else {\n this.prop.id = 'psvButton-' + Math.random().toString(36).substr(2, 9);\n }\n\n if (this.config.className) {\n addClasses(this.container, this.config.className);\n }\n\n if (this.config.title) {\n this.container.title = this.config.title;\n }\n\n if (this.config.content) {\n this.container.innerHTML = this.config.content;\n }\n\n this.prop.width = this.container.offsetWidth;\n\n if (this.config.enabled === false) {\n this.disable();\n }\n\n if (this.config.visible === false) {\n this.hide();\n }\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.config;\n\n super.destroy();\n }\n\n /**\n * @override\n * @description Calls user method\n */\n onClick() {\n if (this.config.onClick) {\n this.config.onClick.apply(this.psv);\n }\n }\n\n}\n","import { DescriptionButton } from '../buttons/DescriptionButton';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Navbar caption class\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class NavbarCaption extends AbstractComponent {\n\n static id = 'caption';\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {string} caption\n */\n constructor(navbar, caption) {\n super(navbar, 'psv-caption');\n\n /**\n * @override\n * @property {string} id\n * @property {boolean} collapsable\n * @property {number} width\n * @property {string} caption\n * @property {boolean} contentVisible - if the content is visible in the navbar\n * @property {number} contentWidth - with of the caption content\n */\n this.prop = {\n ...this.prop,\n id : this.constructor.id,\n collapsable : false,\n width : 0,\n caption : '',\n contentVisible: true,\n contentWidth : 0,\n };\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-caption-content';\n this.container.appendChild(this.content);\n\n this.setCaption(caption);\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Sets the bar caption\n * @param {string} html\n */\n setCaption(html) {\n this.prop.caption = html || '';\n this.content.innerHTML = this.prop.caption;\n\n if (html) {\n this.prop.contentWidth = this.content.offsetWidth;\n this.refreshUi('caption change');\n }\n else if (!this.prop.contentVisible) {\n this.prop.contentVisible = true;\n this.__refreshButton();\n }\n }\n\n /**\n * @summary Toggles content and icon depending on available space\n * @private\n */\n refreshUi() {\n const availableWidth = this.container.offsetWidth;\n if (availableWidth >= this.prop.contentWidth && !this.prop.contentVisible) {\n this.content.style.display = '';\n this.prop.contentVisible = true;\n }\n else if (availableWidth < this.prop.contentWidth && this.prop.contentVisible) {\n this.content.style.display = 'none';\n this.prop.contentVisible = false;\n }\n this.__refreshButton();\n }\n\n /**\n * @private\n */\n __refreshButton() {\n this.psv.navbar.getButton(DescriptionButton.id, false)?.refreshUi(true);\n }\n\n}\n","import { NavbarCaption } from '../components/NavbarCaption';\nimport { EVENTS, IDS } from '../data/constants';\nimport info from '../icons/info.svg';\nimport { AbstractButton } from './AbstractButton';\n\nconst MODE_NOTIF = 1;\nconst MODE_PANEL = 2;\n\n/**\n * @summary Navigation bar description button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class DescriptionButton extends AbstractButton {\n\n static id = 'description';\n static icon = info;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-description-button');\n\n /**\n * @override\n * @property {string} mode - notification or panel\n */\n this.prop = {\n ...this.prop,\n mode: null,\n };\n\n this.psv.on(EVENTS.HIDE_NOTIFICATION, this);\n this.psv.on(EVENTS.SHOW_NOTIFICATION, this);\n this.psv.on(EVENTS.CLOSE_PANEL, this);\n this.psv.on(EVENTS.OPEN_PANEL, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.HIDE_NOTIFICATION, this);\n this.psv.off(EVENTS.SHOW_NOTIFICATION, this);\n this.psv.off(EVENTS.CLOSE_PANEL, this);\n this.psv.off(EVENTS.OPEN_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (!this.prop.mode) {\n return;\n }\n\n let closed = false;\n switch (e.type) {\n case EVENTS.HIDE_NOTIFICATION:\n closed = this.prop.mode === MODE_NOTIF;\n break;\n\n case EVENTS.SHOW_NOTIFICATION:\n closed = this.prop.mode === MODE_NOTIF && e.args[0] !== IDS.DESCRIPTION;\n break;\n\n case EVENTS.CLOSE_PANEL:\n closed = this.prop.mode === MODE_PANEL;\n break;\n\n case EVENTS.OPEN_PANEL:\n closed = this.prop.mode === MODE_PANEL && e.args[0] !== IDS.DESCRIPTION;\n break;\n\n default:\n }\n\n if (closed) {\n this.toggleActive(false);\n this.prop.mode = null;\n }\n }\n\n /**\n * @override\n */\n hide(refresh) {\n super.hide(refresh);\n\n if (this.prop.mode) {\n this.__close();\n }\n }\n\n /**\n * This button can only be refresh from NavbarCaption\n * @override\n */\n refreshUi(refresh = false) {\n if (refresh) {\n const caption = this.psv.navbar.getButton(NavbarCaption.id, false);\n const captionHidden = caption && !caption.prop.contentVisible;\n const hasDescription = !!this.psv.config.description;\n\n if (captionHidden || hasDescription) {\n this.show(false);\n }\n else {\n this.hide(false);\n }\n }\n }\n\n /**\n * @override\n * @description Toggles caption\n */\n onClick() {\n if (this.prop.mode) {\n this.__close();\n }\n else {\n this.__open();\n }\n }\n\n /**\n * @private\n */\n __close() {\n switch (this.prop.mode) {\n case MODE_NOTIF:\n this.psv.notification.hide(IDS.DESCRIPTION);\n break;\n case MODE_PANEL:\n this.psv.panel.hide(IDS.DESCRIPTION);\n break;\n default:\n }\n }\n\n /**\n * @private\n */\n __open() {\n this.toggleActive(true);\n\n if (this.psv.config.description) {\n this.prop.mode = MODE_PANEL;\n this.psv.panel.show({\n id : IDS.DESCRIPTION,\n content: `${this.psv.config.caption ? `

${this.psv.config.caption}

` : ''}${this.psv.config.description}`,\n });\n }\n else {\n this.prop.mode = MODE_NOTIF;\n this.psv.notification.show({\n id : IDS.DESCRIPTION,\n content: this.psv.config.caption,\n });\n }\n }\n\n}\n","import { AbstractButton } from './AbstractButton';\nimport download from '../icons/download.svg';\n\n/**\n * @summary Navigation bar download button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class DownloadButton extends AbstractButton {\n\n static id = 'download';\n static icon = download;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-download-button', true);\n }\n\n /**\n * @override\n */\n isSupported() {\n return this.psv.adapter.constructor.supportsDownload || !!this.psv.config.downloadUrl;\n }\n\n /**\n * @override\n * @description Asks the browser to download the panorama source file\n */\n onClick() {\n const link = document.createElement('a');\n link.href = this.psv.config.downloadUrl || this.psv.config.panorama;\n link.download = link.href.split('/').pop();\n this.psv.container.appendChild(link);\n link.click();\n\n setTimeout(() => {\n this.psv.container.removeChild(link);\n }, 100);\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport fullscreenIn from '../icons/fullscreen-in.svg';\nimport fullscreenOut from '../icons/fullscreen-out.svg';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar fullscreen button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class FullscreenButton extends AbstractButton {\n\n static id = 'fullscreen';\n static icon = fullscreenIn;\n static iconActive = fullscreenOut;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-fullscreen-button');\n\n this.psv.on(EVENTS.FULLSCREEN_UPDATED, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.FULLSCREEN_UPDATED, this);\n\n super.destroy();\n }\n\n /**\n * Handle events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.FULLSCREEN_UPDATED: this.toggleActive(e.args[0]); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles fullscreen\n */\n onClick() {\n this.psv.toggleFullscreen();\n }\n\n}\n","import { EVENTS, IDS } from '../data/constants';\nimport menuIcon from '../icons/menu.svg';\nimport { dasherize, getClosest } from '../utils';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar menu button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class MenuButton extends AbstractButton {\n\n static id = 'menu';\n static icon = menuIcon;\n\n /**\n * @summary Property name added to buttons list\n * @type {string}\n * @constant\n */\n static BUTTON_DATA = 'psvButton';\n\n /**\n * @summary Menu template\n * @param {AbstractButton[]} buttons\n * @param {PSV.Viewer} psv\n * @param {string} dataKey\n * @returns {string}\n */\n static MENU_TEMPLATE = (buttons, psv, dataKey) => `\n
\n

${menuIcon} ${psv.config.lang.menu}

\n
    \n ${buttons.map(button => `\n
  • \n ${button.container.innerHTML}\n ${button.container.title}\n
  • \n `).join('')}\n
\n
\n`;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-menu-button');\n\n this.psv.on(EVENTS.OPEN_PANEL, this);\n this.psv.on(EVENTS.CLOSE_PANEL, this);\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.OPEN_PANEL, this);\n this.psv.off(EVENTS.CLOSE_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === IDS.MENU); break;\n case EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n hide(refresh) {\n super.hide(refresh);\n this.__hideMenu();\n }\n\n /**\n * @override\n */\n show(refresh) {\n super.show(refresh);\n\n if (this.prop.active) {\n this.__showMenu();\n }\n }\n\n /**\n * @override\n * @description Toggles menu\n */\n onClick() {\n if (this.prop.active) {\n this.__hideMenu();\n }\n else {\n this.__showMenu();\n }\n }\n\n __showMenu() {\n this.psv.panel.show({\n id : IDS.MENU,\n content : MenuButton.MENU_TEMPLATE(this.parent.collapsed, this.psv, dasherize(MenuButton.BUTTON_DATA)),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? getClosest(e.target, 'li') : undefined;\n const buttonId = li ? li.dataset[MenuButton.BUTTON_DATA] : undefined;\n\n if (buttonId) {\n this.parent.getButton(buttonId).onClick();\n this.__hideMenu();\n }\n },\n });\n }\n\n __hideMenu() {\n if (this.psv.panel) {\n this.psv.panel.hide(IDS.MENU);\n }\n }\n\n}\n","/**\n * @summary Helper for pressable things (buttons, keyboard)\n * @description When the pressed thing goes up and was not pressed long enough, wait a bit more before execution\n * @private\n */\nexport class PressHandler {\n\n constructor(delay = 200) {\n this.delay = delay;\n this.time = 0;\n this.timeout = null;\n }\n\n down() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n }\n\n this.time = new Date().getTime();\n }\n\n up(cb) {\n if (!this.time) {\n return;\n }\n\n const elapsed = new Date().getTime() - this.time;\n if (elapsed < this.delay) {\n this.timeout = setTimeout(() => {\n cb();\n this.timeout = null;\n this.time = 0;\n }, this.delay);\n }\n else {\n cb();\n this.time = 0;\n }\n }\n\n}\n","import { KEY_CODES } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport arrow from '../icons/arrow.svg';\nimport { PressHandler } from '../utils/PressHandler';\nimport { AbstractButton } from './AbstractButton';\n\nexport function getOrientedArrow(direction) {\n let angle = 0;\n switch (direction) {\n // @formatter:off\n case 'up': angle = 90; break;\n case 'right': angle = 180; break;\n case 'down': angle = -90; break;\n default: angle = 0; break;\n // @formatter:on\n }\n\n return arrow.replace('rotate(0', `rotate(${angle}`);\n}\n\n/**\n * @summary Navigation bar move button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class AbstractMoveButton extends AbstractButton {\n\n static groupId = 'move';\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {number} value\n */\n constructor(navbar, value) {\n super(navbar, 'psv-button--hover-scale psv-move-button');\n\n this.container.title = this.psv.config.lang.move;\n\n /**\n * @override\n * @property {{longitude: boolean, latitude: boolean}} value\n * @property {PressHandler} handler\n */\n this.prop = {\n ...this.prop,\n value : value,\n handler: new PressHandler(),\n };\n\n this.container.addEventListener('mousedown', this);\n this.container.addEventListener('keydown', this);\n this.container.addEventListener('keyup', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.__onMouseUp();\n\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(); break;\n case 'mouseup': this.__onMouseUp(); break;\n case 'touchend': this.__onMouseUp(); break;\n case 'keydown': e.key === KEY_CODES.Enter && this.__onMouseDown(); break;\n case 'keyup': e.key === KEY_CODES.Enter && this.__onMouseUp(); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n isSupported() {\n return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) };\n }\n\n /**\n * @override\n */\n onClick() {\n // nothing\n }\n\n /**\n * @private\n */\n __onMouseDown() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.psv.__stopAll();\n this.psv.dynamics.position.roll(this.prop.value);\n this.prop.handler.down();\n }\n\n /**\n * @private\n */\n __onMouseUp() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.handler.up(() => this.psv.dynamics.position.stop());\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move down button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveDownButton extends AbstractMoveButton {\n\n static id = 'moveDown';\n static icon = getOrientedArrow('down');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { latitude: true });\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move left button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveLeftButton extends AbstractMoveButton {\n\n static id = 'moveLeft';\n static icon = getOrientedArrow('left');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { longitude: true });\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move right button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveRightButton extends AbstractMoveButton {\n\n static id = 'moveRight';\n static icon = getOrientedArrow('right');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { longitude: false });\n }\n\n}\n","import { AbstractMoveButton, getOrientedArrow } from './AbstractMoveButton';\n\n/**\n * @summary Navigation bar move up button class\n * @extends PSV.buttons.AbstractMoveButton\n * @memberof PSV.buttons\n */\nexport class MoveUpButton extends AbstractMoveButton {\n\n static id = 'moveUp';\n static icon = getOrientedArrow('up');\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, { latitude: false });\n }\n\n}\n","import { KEY_CODES } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { PressHandler } from '../utils/PressHandler';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar zoom button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class AbstractZoomButton extends AbstractButton {\n\n static groupId = 'zoom';\n\n /**\n * @param {PSV.components.Navbar} navbar\n * @param {number} value\n */\n constructor(navbar, value) {\n super(navbar, 'psv-button--hover-scale psv-zoom-button');\n\n /**\n * @override\n * @property {boolean} value\n * @property {PressHandler} handler\n */\n this.prop = {\n ...this.prop,\n value : value,\n handler: new PressHandler(),\n };\n\n this.container.addEventListener('mousedown', this);\n this.container.addEventListener('keydown', this);\n this.container.addEventListener('keyup', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.__onMouseUp();\n\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(); break;\n case 'mouseup': this.__onMouseUp(); break;\n case 'touchend': this.__onMouseUp(); break;\n case 'keydown': e.key === KEY_CODES.Enter && this.__onMouseDown(); break;\n case 'keyup': e.key === KEY_CODES.Enter && this.__onMouseUp(); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n isSupported() {\n return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) };\n }\n\n /**\n * @override\n */\n onClick() {\n // nothing\n }\n\n /**\n * @private\n */\n __onMouseDown() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.psv.dynamics.zoom.roll(this.prop.value);\n this.prop.handler.down();\n }\n\n /**\n * @private\n */\n __onMouseUp() {\n if (!this.prop.enabled) {\n return;\n }\n\n this.prop.handler.up(() => this.psv.dynamics.zoom.stop());\n }\n\n}\n","import { AbstractZoomButton } from './AbstractZoomButton';\nimport zoomIn from '../icons/zoom-in.svg';\n\n/**\n * @summary Navigation bar zoom-in button class\n * @extends PSV.buttons.AbstractZoomButton\n * @memberof PSV.buttons\n */\nexport class ZoomInButton extends AbstractZoomButton {\n\n static id = 'zoomIn';\n static icon = zoomIn;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, false);\n }\n\n}\n","import { AbstractZoomButton } from './AbstractZoomButton';\nimport zoomOut from '../icons/zoom-out.svg';\n\n/**\n * @summary Navigation bar zoom-out button class\n * @extends PSV.buttons.AbstractZoomButton\n * @memberof PSV.buttons\n */\nexport class ZoomOutButton extends AbstractZoomButton {\n\n static id = 'zoomOut';\n static icon = zoomOut;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, true);\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { getStyle, Slider } from '../utils';\nimport { AbstractButton } from './AbstractButton';\n\n/**\n * @summary Navigation bar zoom button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class ZoomRangeButton extends AbstractButton {\n\n static id = 'zoomRange';\n static groupId = 'zoom';\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-zoom-range', false, false);\n\n /**\n * @override\n * @property {number} mediaMinWidth\n */\n this.prop = {\n ...this.prop,\n mediaMinWidth: 0,\n };\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.zoomRange = document.createElement('div');\n this.zoomRange.className = 'psv-zoom-range-line';\n this.container.appendChild(this.zoomRange);\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.zoomValue = document.createElement('div');\n this.zoomValue.className = 'psv-zoom-range-handle';\n this.zoomRange.appendChild(this.zoomValue);\n\n /**\n * @member {PSV.Slider}\n * @readonly\n * @private\n */\n this.slider = new Slider({\n container: this.container,\n direction: Slider.HORIZONTAL,\n onUpdate : e => this.__onSliderUpdate(e),\n });\n\n this.prop.mediaMinWidth = parseInt(getStyle(this.container, 'maxWidth'), 10);\n\n this.psv.on(EVENTS.ZOOM_UPDATED, this);\n if (this.psv.prop.ready) {\n this.__moveZoomValue(this.psv.getZoomLevel());\n }\n else {\n this.psv.once(EVENTS.READY, this);\n }\n\n this.refreshUi();\n }\n\n /**\n * @override\n */\n destroy() {\n this.slider.destroy();\n\n delete this.zoomRange;\n delete this.zoomValue;\n\n this.psv.off(EVENTS.ZOOM_UPDATED, this);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.ZOOM_UPDATED: this.__moveZoomValue(e.args[0]); break;\n case EVENTS.READY: this.__moveZoomValue(this.psv.getZoomLevel()); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n */\n isSupported() {\n return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) };\n }\n\n /**\n * @override\n */\n refreshUi() {\n if (this.prop.supported) {\n if (this.psv.prop.size.width <= this.prop.mediaMinWidth && this.prop.visible) {\n this.hide();\n }\n else if (this.psv.prop.size.width > this.prop.mediaMinWidth && !this.prop.visible) {\n this.show();\n }\n }\n }\n\n /**\n * @override\n */\n onClick() {\n // nothing\n }\n\n /**\n * @summary Moves the zoom cursor\n * @param {number} level\n * @private\n */\n __moveZoomValue(level) {\n this.zoomValue.style.left = (level / 100 * this.zoomRange.offsetWidth - this.zoomValue.offsetWidth / 2) + 'px';\n }\n\n\n /**\n * @summary Zoom change\n * @private\n */\n __onSliderUpdate(e) {\n if (e.mousedown) {\n this.psv.zoom(e.value * 100);\n }\n }\n\n}\n","import { EventEmitter } from 'uevent';\n\n/**\n * @namespace PSV.plugins\n */\n\n/**\n * @summary Base plugins class\n * @memberof PSV.plugins\n * @abstract\n */\nexport class AbstractPlugin extends EventEmitter {\n\n /**\n * @summary Unique identifier of the plugin\n * @member {string}\n * @readonly\n * @static\n */\n static id = null;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super();\n\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n }\n\n /**\n * @summary Initializes the plugin\n * @package\n */\n init() {\n }\n\n /**\n * @summary Destroys the plugin\n * @package\n */\n destroy() {\n delete this.psv;\n }\n\n}\n","import { AbstractAdapter } from '../adapters/AbstractAdapter';\nimport { EquirectangularAdapter } from '../adapters/equirectangular';\nimport { AbstractPlugin } from '../plugins/AbstractPlugin';\nimport { PSVError } from '../PSVError';\nimport { bound, clone, deepmerge, each, logWarn, parseAngle, parseSpeed, pluginInterop } from '../utils';\nimport { ACTIONS, KEY_CODES } from './constants';\n\n/**\n * @summary Default options\n * @type {PSV.Options}\n * @memberOf PSV\n * @constant\n */\nexport const DEFAULTS = {\n panorama : null,\n container : null,\n adapter : null,\n plugins : [],\n caption : null,\n description : null,\n downloadUrl : null,\n loadingImg : null,\n loadingTxt : 'Loading...',\n size : null,\n fisheye : false,\n minFov : 30,\n maxFov : 90,\n defaultZoomLvl : 50,\n defaultLong : 0,\n defaultLat : 0,\n sphereCorrection : null,\n moveSpeed : 1,\n zoomSpeed : 1,\n autorotateDelay : null,\n autorotateSpeed : '2rpm',\n autorotateLat : null,\n moveInertia : true,\n mousewheel : true,\n mousemove : true,\n captureCursor : false,\n mousewheelCtrlKey : false,\n touchmoveTwoFingers: false,\n useXmpData : true,\n panoData : null,\n requestHeaders : null,\n canvasBackground : '#000',\n withCredentials : false,\n navbar : [\n 'autorotate',\n 'zoom',\n 'move',\n 'download',\n 'description',\n 'caption',\n 'fullscreen',\n ],\n lang : {\n autorotate: 'Automatic rotation',\n zoom : 'Zoom',\n zoomOut : 'Zoom out',\n zoomIn : 'Zoom in',\n move : 'Move',\n download : 'Download',\n fullscreen: 'Fullscreen',\n menu : 'Menu',\n twoFingers: 'Use two fingers to navigate',\n ctrlZoom : 'Use ctrl + scroll to zoom the image',\n loadError : 'The panorama can\\'t be loaded',\n },\n keyboard : {\n [KEY_CODES.ArrowUp] : ACTIONS.ROTATE_LAT_UP,\n [KEY_CODES.ArrowDown] : ACTIONS.ROTATE_LAT_DOWN,\n [KEY_CODES.ArrowRight]: ACTIONS.ROTATE_LONG_RIGHT,\n [KEY_CODES.ArrowLeft] : ACTIONS.ROTATE_LONG_LEFT,\n [KEY_CODES.PageUp] : ACTIONS.ZOOM_IN,\n [KEY_CODES.PageDown] : ACTIONS.ZOOM_OUT,\n [KEY_CODES.Plus] : ACTIONS.ZOOM_IN,\n [KEY_CODES.Minus] : ACTIONS.ZOOM_OUT,\n [KEY_CODES.Space] : ACTIONS.TOGGLE_AUTOROTATE,\n },\n};\n\n/**\n * @summary List of unmodifiable options and their error messages\n * @private\n */\nexport const READONLY_OPTIONS = {\n panorama : 'Use setPanorama method to change the panorama',\n panoData : 'Use setPanorama method to change the panorama',\n container: 'Cannot change viewer container',\n adapter : 'Cannot change adapter',\n plugins : 'Cannot change plugins',\n};\n\n/**\n * @summary List of deprecated options and their warning messages\n * @private\n */\nexport const DEPRECATED_OPTIONS = {\n zoomButtonIncrement : 'zoomButtonIncrement is deprecated, use zoomSpeed',\n mousewheelSpeed : 'mousewheelSpeed is deprecated, use zoomSpeed',\n sphereCorrectionReorder: 'sphereCorrectionReorder is deprecated',\n};\n\n/**\n * @summary Parsers/validators for each option\n * @private\n */\nexport const CONFIG_PARSERS = {\n container : (container) => {\n if (!container) {\n throw new PSVError('No value given for container.');\n }\n return container;\n },\n adapter : (adapter) => {\n if (!adapter) {\n adapter = [EquirectangularAdapter];\n }\n else if (Array.isArray(adapter)) {\n adapter = [pluginInterop(adapter[0], AbstractAdapter), adapter[1]];\n }\n else {\n adapter = [pluginInterop(adapter, AbstractAdapter)];\n }\n if (!adapter[0]) {\n throw new PSVError('Un undefined value with given for adapter.');\n }\n return adapter;\n },\n defaultLong : (defaultLong) => {\n // defaultLat is between 0 and PI\n return parseAngle(defaultLong);\n },\n defaultLat : (defaultLat) => {\n // defaultLat is between -PI/2 and PI/2\n return parseAngle(defaultLat, true);\n },\n minFov : (minFov, config) => {\n // minFov and maxFov must be ordered\n if (config.maxFov < minFov) {\n logWarn('maxFov cannot be lower than minFov');\n minFov = config.maxFov;\n }\n // minFov between 1 and 179\n return bound(minFov, 1, 179);\n },\n maxFov : (maxFov, config) => {\n // minFov and maxFov must be ordered\n if (maxFov < config.minFov) {\n maxFov = config.minFov;\n }\n // maxFov between 1 and 179\n return bound(maxFov, 1, 179);\n },\n lang : (lang) => {\n if (Array.isArray(lang.twoFingers)) {\n logWarn('lang.twoFingers must not be an array');\n lang.twoFingers = lang.twoFingers[0];\n }\n return {\n ...DEFAULTS.lang,\n ...lang,\n };\n },\n keyboard : (keyboard) => {\n // keyboard=true becomes the default map\n if (keyboard === true) {\n return clone(DEFAULTS.keyboard);\n }\n return keyboard;\n },\n autorotateLat : (autorotateLat, config) => {\n // default autorotateLat is defaultLat\n if (autorotateLat === null) {\n return parseAngle(config.defaultLat, true);\n }\n // autorotateLat is between -PI/2 and PI/2\n else {\n return parseAngle(autorotateLat, true);\n }\n },\n autorotateSpeed: (autorotateSpeed) => {\n return parseSpeed(autorotateSpeed);\n },\n fisheye : (fisheye) => {\n // translate boolean fisheye to amount\n if (fisheye === true) {\n return 1;\n }\n else if (fisheye === false) {\n return 0;\n }\n return fisheye;\n },\n plugins : (plugins) => {\n return plugins\n .map((plugin) => {\n if (Array.isArray(plugin)) {\n plugin = [pluginInterop(plugin[0], AbstractPlugin), plugin[1]];\n }\n else {\n plugin = [pluginInterop(plugin, AbstractPlugin)];\n }\n if (!plugin[0]) {\n throw new PSVError('Un undefined value was given for plugins.');\n }\n return plugin;\n });\n },\n};\n\n/**\n * @summary Merge user config with default config and performs validation\n * @param {PSV.Options} options\n * @returns {PSV.Options}\n * @memberOf PSV\n * @private\n */\nexport function getConfig(options) {\n const tempConfig = clone(DEFAULTS);\n deepmerge(tempConfig, options);\n\n const config = {};\n\n each(tempConfig, (value, key) => {\n if (DEPRECATED_OPTIONS[key]) {\n logWarn(DEPRECATED_OPTIONS[key]);\n return;\n }\n\n if (!Object.prototype.hasOwnProperty.call(DEFAULTS, key)) {\n throw new PSVError(`Unknown option ${key}`);\n }\n\n if (CONFIG_PARSERS[key]) {\n config[key] = CONFIG_PARSERS[key](value, tempConfig);\n }\n else {\n config[key] = value;\n }\n });\n\n return config;\n}\n","import { AutorotateButton } from '../buttons/AutorotateButton';\nimport { CustomButton } from '../buttons/CustomButton';\nimport { DescriptionButton } from '../buttons/DescriptionButton';\nimport { DownloadButton } from '../buttons/DownloadButton';\nimport { FullscreenButton } from '../buttons/FullscreenButton';\nimport { MenuButton } from '../buttons/MenuButton';\nimport { MoveDownButton } from '../buttons/MoveDownButton';\nimport { MoveLeftButton } from '../buttons/MoveLeftButton';\nimport { MoveRightButton } from '../buttons/MoveRightButton';\nimport { MoveUpButton } from '../buttons/MoveUpButton';\nimport { ZoomInButton } from '../buttons/ZoomInButton';\nimport { ZoomOutButton } from '../buttons/ZoomOutButton';\nimport { ZoomRangeButton } from '../buttons/ZoomRangeButton';\nimport { DEFAULTS } from '../data/config';\nimport { PSVError } from '../PSVError';\nimport { clone, logWarn } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\nimport { NavbarCaption } from './NavbarCaption';\n\n/**\n * @summary List of available buttons\n * @type {Object>}\n * @private\n */\nconst AVAILABLE_BUTTONS = {};\n\n/**\n * @summary List of available buttons\n * @type {Object>>}\n * @private\n */\nconst AVAILABLE_GROUPS = {};\n\n/**\n * @summary Register a new button available for all viewers\n * @param {Class} button\n * @param {'start' | 'end' | '[id]:left' | '[id]:right'} [defaultPosition]\n * If provided the default configuration of the navbar will be modified.\n * @memberOf PSV\n */\nexport function registerButton(button, defaultPosition) {\n if (!button.id) {\n throw new PSVError('Button ID is required');\n }\n\n AVAILABLE_BUTTONS[button.id] = button;\n\n if (button.groupId) {\n AVAILABLE_GROUPS[button.groupId] = AVAILABLE_GROUPS[button.groupId] || [];\n AVAILABLE_GROUPS[button.groupId].push(button);\n }\n\n if (typeof defaultPosition === 'string') {\n switch (defaultPosition) {\n case 'start':\n DEFAULTS.navbar.unshift(button.id);\n break;\n case 'end':\n DEFAULTS.navbar.push(button.id);\n break;\n default:\n const [id, pos] = defaultPosition.split(':');\n DEFAULTS.navbar.splice(DEFAULTS.navbar.indexOf(id) + (pos === 'right' ? 1 : 0), 0, button.id);\n }\n }\n}\n\n[\n AutorotateButton,\n ZoomOutButton,\n ZoomRangeButton,\n ZoomInButton,\n DescriptionButton,\n DownloadButton,\n FullscreenButton,\n MoveLeftButton,\n MoveRightButton,\n MoveUpButton,\n MoveDownButton,\n].forEach(registerButton);\n\n/**\n * @summary Navigation bar component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Navbar extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-navbar');\n\n /**\n * @summary List of buttons of the navbar\n * @member {PSV.buttons.AbstractButton[]}\n * @override\n */\n this.children = [];\n\n /**\n * @summary List of collapsed buttons\n * @member {PSV.buttons.AbstractButton[]}\n * @private\n */\n this.collapsed = [];\n }\n\n /**\n * @summary Change the buttons visible on the navbar\n * @param {string|Array} buttons\n * @throws {PSV.PSVError} when a button is unknown\n */\n setButtons(buttons) {\n this.children.slice().forEach(item => item.destroy());\n this.children.length = 0;\n\n const cleanedButtons = this.__cleanButtons(buttons);\n\n // force description button if caption is present (used on narrow screens)\n if (cleanedButtons.indexOf(NavbarCaption.id) !== -1 && cleanedButtons.indexOf(DescriptionButton.id) === -1) {\n cleanedButtons.splice(cleanedButtons.indexOf(NavbarCaption.id), 0, DescriptionButton.id);\n }\n\n /* eslint-disable no-new */\n cleanedButtons.forEach((button) => {\n if (typeof button === 'object') {\n new CustomButton(this, button);\n }\n else if (AVAILABLE_BUTTONS[button]) {\n new AVAILABLE_BUTTONS[button](this);\n }\n else if (AVAILABLE_GROUPS[button]) {\n AVAILABLE_GROUPS[button].forEach(buttonCtor => new buttonCtor(this)); // eslint-disable-line new-cap\n }\n else if (button === NavbarCaption.id) {\n new NavbarCaption(this, this.psv.config.caption);\n }\n else {\n throw new PSVError('Unknown button ' + button);\n }\n });\n\n new MenuButton(this);\n /* eslint-enable no-new */\n\n this.children.forEach((item) => {\n if (typeof item.checkSupported === 'function') {\n item.checkSupported();\n }\n });\n }\n\n /**\n * @summary Sets the bar caption\n * @param {string} html\n */\n setCaption(html) {\n const caption = this.getButton(NavbarCaption.id, false);\n caption?.setCaption(html);\n }\n\n /**\n * @summary Returns a button by its identifier\n * @param {string} id\n * @param {boolean} [warnNotFound=true]\n * @returns {PSV.buttons.AbstractButton}\n */\n getButton(id, warnNotFound = true) {\n let button = null;\n\n this.children.some((item) => {\n if (item.prop.id === id) {\n button = item;\n return true;\n }\n else {\n return false;\n }\n });\n\n if (!button && warnNotFound) {\n logWarn(`button \"${id}\" not found in the navbar`);\n }\n\n return button;\n }\n\n /**\n * @summary Shows the navbar\n */\n show() {\n this.container.classList.add('psv-navbar--open');\n this.prop.visible = true;\n }\n\n /**\n * @summary Hides the navbar\n */\n hide() {\n this.container.classList.remove('psv-navbar--open');\n this.prop.visible = false;\n }\n\n /**\n * @override\n */\n refreshUi() {\n super.refreshUi();\n\n if (this.psv.prop.uiRefresh === true) {\n const availableWidth = this.container.offsetWidth;\n\n let totalWidth = 0;\n const visibleButtons = [];\n const collapsableButtons = [];\n\n this.children.forEach((item) => {\n if (item.prop.visible) {\n totalWidth += item.prop.width;\n visibleButtons.push(item);\n if (item.prop.collapsable) {\n collapsableButtons.push(item);\n }\n }\n });\n\n if (!visibleButtons.length) {\n return;\n }\n\n if (availableWidth < totalWidth && collapsableButtons.length > 0) {\n collapsableButtons.forEach(item => item.collapse());\n this.collapsed = collapsableButtons;\n\n this.getButton(MenuButton.id).show(false);\n }\n else if (availableWidth >= totalWidth && this.collapsed.length > 0) {\n this.collapsed.forEach(item => item.uncollapse());\n this.collapsed = [];\n\n this.getButton(MenuButton.id).hide(false);\n }\n\n const caption = this.getButton(NavbarCaption.id, false);\n if (caption) {\n caption.refreshUi();\n }\n }\n }\n\n /**\n * @summary Ensure the buttons configuration is correct\n * @private\n */\n __cleanButtons(buttons) {\n // true becomes the default array\n if (buttons === true) {\n return clone(DEFAULTS.navbar);\n }\n // can be a space or coma separated list\n else if (typeof buttons === 'string') {\n return buttons.split(/[ ,]/);\n }\n else {\n return buttons || [];\n }\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { bound, getStyle } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Loader component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Loader extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-loader-container');\n\n /**\n * @summary Inner container for vertical center\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.loader = document.createElement('div');\n this.loader.className = 'psv-loader';\n this.container.appendChild(this.loader);\n\n /**\n * @summary Animation canvas\n * @member {HTMLCanvasElement}\n * @readonly\n * @private\n */\n this.canvas = document.createElement('canvas');\n this.canvas.className = 'psv-loader-canvas';\n\n this.canvas.width = this.loader.clientWidth * SYSTEM.pixelRatio;\n this.canvas.height = this.loader.clientWidth * SYSTEM.pixelRatio;\n this.loader.appendChild(this.canvas);\n\n /**\n * @override\n * @property {number} thickness\n * @property {string} current\n */\n this.prop = {\n ...this.prop,\n tickness: (this.loader.offsetWidth - this.loader.clientWidth) / 2 * SYSTEM.pixelRatio,\n current : null,\n };\n\n this.refreshUi();\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.loader;\n delete this.canvas;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n refreshUi() {\n if (this.prop.current !== (this.psv.config.loadingImg || this.psv.config.loadingTxt)) {\n if (this.prop.current) {\n this.loader.removeChild(this.loader.lastChild);\n }\n\n let inner;\n if (this.psv.config.loadingImg) {\n inner = document.createElement('img');\n inner.className = 'psv-loader-image';\n inner.src = this.psv.config.loadingImg;\n }\n else if (this.psv.config.loadingTxt) {\n inner = document.createElement('div');\n inner.className = 'psv-loader-text';\n inner.innerHTML = this.psv.config.loadingTxt;\n }\n if (inner) {\n const size = Math.round(Math.sqrt(2 * Math.pow((this.canvas.width / 2 - this.prop.tickness / 2) / SYSTEM.pixelRatio, 2)));\n inner.style.maxWidth = size + 'px';\n inner.style.maxHeight = size + 'px';\n this.loader.appendChild(inner);\n }\n\n this.prop.current = this.psv.config.loadingImg || this.psv.config.loadingTxt;\n }\n }\n\n /**\n * @summary Sets the loader progression\n * @param {number} value - from 0 to 100\n */\n setProgress(value) {\n const context = this.canvas.getContext('2d');\n\n context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\n context.lineWidth = this.prop.tickness;\n context.strokeStyle = getStyle(this.loader, 'color');\n\n context.beginPath();\n context.arc(\n this.canvas.width / 2, this.canvas.height / 2,\n this.canvas.width / 2 - this.prop.tickness / 2,\n -Math.PI / 2, bound(value, 0, 100) / 100 * 2 * Math.PI - Math.PI / 2\n );\n context.stroke();\n\n this.psv.trigger(EVENTS.LOAD_PROGRESS, Math.round(value));\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Notification component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Notification extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-notification');\n\n /**\n * @override\n * @property {*} timeout\n */\n this.prop = {\n ...this.prop,\n visible : false,\n contentId: undefined,\n timeout : null,\n };\n\n /**\n * Notification content\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-notification-content';\n this.container.appendChild(this.content);\n\n this.content.addEventListener('click', () => this.hide());\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @override\n * @param {string} [id]\n */\n isVisible(id) {\n return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id);\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Notification cannot be toggled');\n }\n\n /**\n * @summary Displays a notification on the viewer\n * @param {Object|string} config\n * @param {string} [config.id] - unique identifier to use with \"hide\"\n * @param {string} config.content\n * @param {number} [config.timeout]\n * @fires PSV.show-notification\n *\n * @example\n * viewer.showNotification({ content: 'Hello world', timeout: 5000 })\n * @example\n * viewer.showNotification('Hello world')\n */\n show(config) {\n if (this.prop.timeout) {\n clearTimeout(this.prop.timeout);\n this.prop.timeout = null;\n }\n\n if (typeof config === 'string') {\n config = { content: config };\n }\n\n this.prop.contentId = config.id;\n this.content.innerHTML = config.content;\n\n this.container.classList.add('psv-notification--visible');\n this.prop.visible = true;\n\n this.psv.trigger(EVENTS.SHOW_NOTIFICATION, config.id);\n\n if (config.timeout) {\n this.prop.timeout = setTimeout(() => this.hide(config.id), config.timeout);\n }\n }\n\n /**\n * @summary Hides the notification\n * @param {string} [id]\n * @fires PSV.hide-notification\n */\n hide(id) {\n if (this.isVisible(id)) {\n const contentId = this.prop.contentId;\n\n this.container.classList.remove('psv-notification--visible');\n this.prop.visible = false;\n\n this.prop.contentId = undefined;\n\n this.psv.trigger(EVENTS.HIDE_NOTIFICATION, contentId);\n }\n }\n\n}\n","import { EVENTS, KEY_CODES } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Overlay component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Overlay extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-overlay');\n\n /**\n * @override\n * @property {string} contentId\n * @property {boolean} dissmisable\n */\n this.prop = {\n ...this.prop,\n contentId : undefined,\n dissmisable: true,\n };\n\n /**\n * Image container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.image = document.createElement('div');\n this.image.className = 'psv-overlay-image';\n this.container.appendChild(this.image);\n\n /**\n * Text container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.text = document.createElement('div');\n this.text.className = 'psv-overlay-text';\n this.container.appendChild(this.text);\n\n /**\n * Subtext container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.subtext = document.createElement('div');\n this.subtext.className = 'psv-overlay-subtext';\n this.container.appendChild(this.subtext);\n\n this.psv.on(EVENTS.CLICK, this);\n this.psv.on(EVENTS.KEY_PRESS, this);\n\n super.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.CLICK, this);\n this.psv.off(EVENTS.KEY_PRESS, this);\n\n delete this.image;\n delete this.text;\n delete this.subtext;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case EVENTS.CLICK:\n if (this.isVisible() && this.prop.dissmisable) {\n this.hide();\n e.stopPropagation();\n }\n break;\n case EVENTS.KEY_PRESS:\n if (this.isVisible() && this.prop.dissmisable && e.args[0] === KEY_CODES.Escape) {\n this.hide();\n e.preventDefault();\n }\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @param {string} [id]\n */\n isVisible(id) {\n return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id);\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Overlay cannot be toggled');\n }\n\n /**\n * @summary Displays an overlay on the viewer\n * @param {Object|string} config\n * @param {string} [config.id] - unique identifier to use with \"hide\"\n * @param {string} config.image - SVG image/icon displayed above the text\n * @param {string} config.text - main message\n * @param {string} [config.subtext] - secondary message\n * @param {boolean} [config.dissmisable=true] - if the user can hide the overlay by clicking\n * @fires PSV.show-overlay\n */\n show(config) {\n if (typeof config === 'string') {\n config = { text: config };\n }\n\n this.prop.contentId = config.id;\n this.prop.dissmisable = config.dissmisable !== false;\n this.image.innerHTML = config.image || '';\n this.text.innerHTML = config.text || '';\n this.subtext.innerHTML = config.subtext || '';\n\n super.show();\n\n this.psv.trigger(EVENTS.SHOW_OVERLAY, config.id);\n }\n\n /**\n * @summary Hides the overlay\n * @param {string} [id]\n * @fires PSV.hide-overlay\n */\n hide(id) {\n if (this.isVisible(id)) {\n const contentId = this.prop.contentId;\n\n super.hide();\n\n this.prop.contentId = undefined;\n\n this.psv.trigger(EVENTS.HIDE_OVERLAY, contentId);\n }\n }\n\n}\n","import { EVENTS, KEY_CODES } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { PSVError } from '../PSVError';\nimport { toggleClass } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\n\n/**\n * @summary Minimum width of the panel\n * @type {number}\n * @constant\n * @private\n */\nconst PANEL_MIN_WIDTH = 200;\n\n/**\n * @summary Panel component\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Panel extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv, 'psv-panel');\n\n /**\n * @override\n * @property {string} contentId\n * @property {number} mouseX\n * @property {number} mouseY\n * @property {boolean} mousedown\n * @property {function} clickHandler\n * @property {function} keyHandler\n */\n this.prop = {\n ...this.prop,\n visible : false,\n contentId : undefined,\n mouseX : 0,\n mouseY : 0,\n mousedown : false,\n clickHandler: null,\n keyHandler : null,\n width : {},\n };\n\n const resizer = document.createElement('div');\n resizer.className = 'psv-panel-resizer';\n this.container.appendChild(resizer);\n\n const closeBtn = document.createElement('div');\n closeBtn.className = 'psv-panel-close-button';\n this.container.appendChild(closeBtn);\n\n /**\n * @summary Content container\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-panel-content';\n this.container.appendChild(this.content);\n\n // Stop wheel event bubbling from panel\n this.container.addEventListener(SYSTEM.mouseWheelEvent, e => e.stopPropagation());\n\n closeBtn.addEventListener('click', () => this.hide());\n\n // Event for panel resizing + stop bubling\n resizer.addEventListener('mousedown', this);\n resizer.addEventListener('touchstart', this);\n this.psv.container.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchend', this);\n this.psv.container.addEventListener('mousemove', this);\n this.psv.container.addEventListener('touchmove', this);\n\n this.psv.on(EVENTS.KEY_PRESS, this);\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(EVENTS.KEY_PRESS, this);\n\n this.psv.container.removeEventListener('mousemove', this);\n this.psv.container.removeEventListener('touchmove', this);\n this.psv.container.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchend', this);\n\n delete this.prop;\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(e); break;\n case 'touchstart': this.__onTouchStart(e); break;\n case 'mousemove': this.__onMouseMove(e); break;\n case 'touchmove': this.__onTouchMove(e); break;\n case 'mouseup': this.__onMouseUp(e); break;\n case 'touchend': this.__onMouseUp(e); break;\n case EVENTS.KEY_PRESS:\n if (this.isVisible() && e.args[0] === KEY_CODES.Escape) {\n this.hide();\n e.preventDefault();\n }\n break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @param {string} [id]\n */\n isVisible(id) {\n return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id);\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Panel cannot be toggled');\n }\n\n /**\n * @summary Shows the panel\n * @param {string|Object} config\n * @param {string} [config.id] - unique identifier to use with \"hide\" and to store the user desired width\n * @param {string} config.content - HTML content of the panel\n * @param {boolean} [config.noMargin=false] - remove the default margins\n * @param {string} [config.width] - initial width\n * @param {Function} [config.clickHandler] - called when the user clicks inside the panel or presses the Enter key while an element focused\n * @fires PSV.open-panel\n */\n show(config) {\n const wasVisible = this.isVisible(config.id);\n\n if (typeof config === 'string') {\n config = { content: config };\n }\n\n this.prop.contentId = config.id;\n this.prop.visible = true;\n\n if (this.prop.clickHandler) {\n this.content.removeEventListener('click', this.prop.clickHandler);\n this.content.removeEventListener('keydown', this.prop.keyHandler);\n this.prop.clickHandler = null;\n this.prop.keyHandler = null;\n }\n\n if (config.id && this.prop.width[config.id]) {\n this.container.style.width = this.prop.width[config.id];\n }\n else if (config.width) {\n this.container.style.width = config.width;\n }\n else {\n this.container.style.width = null;\n }\n\n this.content.innerHTML = config.content;\n this.content.scrollTop = 0;\n this.container.classList.add('psv-panel--open');\n\n toggleClass(this.content, 'psv-panel-content--no-margin', config.noMargin === true);\n\n if (config.clickHandler) {\n this.prop.clickHandler = config.clickHandler;\n this.prop.keyHandler = (e) => {\n if (e.key === KEY_CODES.Enter) {\n config.clickHandler(e);\n }\n };\n this.content.addEventListener('click', this.prop.clickHandler);\n this.content.addEventListener('keydown', this.prop.keyHandler);\n\n // focus the first element if possible, after animation ends\n if (!wasVisible) {\n setTimeout(() => {\n this.content.querySelector('a,button,[tabindex]')?.focus();\n }, 300);\n }\n }\n\n this.psv.trigger(EVENTS.OPEN_PANEL, config.id);\n }\n\n /**\n * @summary Hides the panel\n * @param {string} [id]\n * @fires PSV.close-panel\n */\n hide(id) {\n if (this.isVisible(id)) {\n const contentId = this.prop.contentId;\n\n this.prop.visible = false;\n this.prop.contentId = undefined;\n\n this.content.innerHTML = null;\n this.container.classList.remove('psv-panel--open');\n\n if (this.prop.clickHandler) {\n this.content.removeEventListener('click', this.prop.clickHandler);\n this.prop.clickHandler = null;\n }\n\n this.psv.trigger(EVENTS.CLOSE_PANEL, contentId);\n }\n }\n\n /**\n * @summary Handles mouse down events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseDown(evt) {\n evt.stopPropagation();\n this.__startResize(evt);\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchStart(evt) {\n evt.stopPropagation();\n this.__startResize(evt.changedTouches[0]);\n }\n\n /**\n * @summary Handles mouse up events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseUp(evt) {\n if (this.prop.mousedown) {\n evt.stopPropagation();\n this.prop.mousedown = false;\n this.content.classList.remove('psv-panel-content--no-interaction');\n }\n }\n\n /**\n * @summary Handles mouse move events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseMove(evt) {\n if (this.prop.mousedown) {\n evt.stopPropagation();\n this.__resize(evt);\n }\n }\n\n /**\n * @summary Handles touch move events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchMove(evt) {\n if (this.prop.mousedown) {\n this.__resize(evt.touches[0]);\n }\n }\n\n /**\n * @summary Initializes the panel resize\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __startResize(evt) {\n this.prop.mouseX = evt.clientX;\n this.prop.mouseY = evt.clientY;\n this.prop.mousedown = true;\n this.content.classList.add('psv-panel-content--no-interaction');\n }\n\n /**\n * @summary Resizes the panel\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __resize(evt) {\n const x = evt.clientX;\n const y = evt.clientY;\n const width = Math.max(PANEL_MIN_WIDTH, this.container.offsetWidth - (x - this.prop.mouseX)) + 'px';\n\n if (this.prop.contentId) {\n this.prop.width[this.prop.contentId] = width;\n }\n\n this.container.style.width = width;\n\n this.prop.mouseX = x;\n this.prop.mouseY = y;\n }\n\n}\n","/**\n * @namespace PSV.services\n */\n\n/**\n * @summary Base services class\n * @memberof PSV.services\n * @abstract\n */\nexport class AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n /**\n * @summary Reference to main controller\n * @type {PSV.Viewer}\n * @readonly\n */\n this.psv = psv;\n\n /**\n * @summary Configuration holder\n * @type {PSV.Options}\n * @readonly\n */\n this.config = psv.config;\n\n /**\n * @summary Properties holder\n * @type {Object}\n * @readonly\n */\n this.prop = psv.prop;\n }\n\n /**\n * @summary Destroys the service\n */\n destroy() {\n delete this.psv;\n delete this.config;\n delete this.prop;\n }\n\n}\n","import * as THREE from 'three';\nimport { MESH_USER_DATA, SPHERE_RADIUS } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { applyEulerInverse, parseAngle, parseSpeed } from '../utils';\nimport { AbstractService } from './AbstractService';\n\nconst vector2 = new THREE.Vector2();\nconst vector3 = new THREE.Vector3();\nconst eulerZero = new THREE.Euler(0, 0, 0, 'ZXY');\n\n/**\n * @summary Collections of data converters for the current viewer\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class DataHelper extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n }\n\n /**\n * @summary Converts vertical FOV to zoom level\n * @param {number} fov\n * @returns {number}\n */\n fovToZoomLevel(fov) {\n const temp = Math.round((fov - this.config.minFov) / (this.config.maxFov - this.config.minFov) * 100);\n return temp - 2 * (temp - 50);\n }\n\n /**\n * @summary Converts zoom level to vertical FOV\n * @param {number} level\n * @returns {number}\n */\n zoomLevelToFov(level) {\n return this.config.maxFov + (level / 100) * (this.config.minFov - this.config.maxFov);\n }\n\n /**\n * @summary Convert vertical FOV to horizontal FOV\n * @param {number} vFov\n * @returns {number}\n */\n vFovToHFov(vFov) {\n return THREE.Math.radToDeg(2 * Math.atan(Math.tan(THREE.Math.degToRad(vFov) / 2) * this.prop.aspect));\n }\n\n /**\n * @summary Converts a speed into a duration from current position to a new position\n * @param {string|number} value\n * @param {number} angle\n * @returns {number}\n */\n speedToDuration(value, angle) {\n if (!value || typeof value !== 'number') {\n // desired radial speed\n const speed = value ? parseSpeed(value) : this.config.autorotateSpeed;\n // compute duration\n return angle / Math.abs(speed) * 1000;\n }\n else {\n return Math.abs(value);\n }\n }\n\n /**\n * @summary Converts pixel texture coordinates to spherical radians coordinates\n * @param {PSV.Point} point\n * @returns {PSV.Position}\n * @throws {PSV.PSVError} when the current adapter does not support texture coordinates\n */\n textureCoordsToSphericalCoords(point) {\n const panoData = this.prop.panoData;\n if (!panoData) {\n throw new PSVError('Current adapter does not support texture coordinates.');\n }\n\n const relativeX = (point.x + panoData.croppedX) / panoData.fullWidth * Math.PI * 2;\n const relativeY = (point.y + panoData.croppedY) / panoData.fullHeight * Math.PI;\n\n const result = {\n longitude: relativeX >= Math.PI ? relativeX - Math.PI : relativeX + Math.PI,\n latitude : Math.PI / 2 - relativeY,\n };\n\n // Apply panoData pose and sphereCorrection\n if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) {\n this.sphericalCoordsToVector3(result, vector3);\n vector3.applyEuler(this.psv.renderer.mesh.rotation);\n vector3.applyEuler(this.psv.renderer.meshContainer.rotation);\n return this.vector3ToSphericalCoords(vector3);\n }\n else {\n return result;\n }\n }\n\n /**\n * @summary Converts spherical radians coordinates to pixel texture coordinates\n * @param {PSV.Position} position\n * @returns {PSV.Point}\n * @throws {PSV.PSVError} when the current adapter does not support texture coordinates\n */\n sphericalCoordsToTextureCoords(position) {\n const panoData = this.prop.panoData;\n if (!panoData) {\n throw new PSVError('Current adapter does not support texture coordinates.');\n }\n\n // Apply panoData pose and sphereCorrection\n if (!eulerZero.equals(this.psv.renderer.mesh.rotation) || !eulerZero.equals(this.psv.renderer.meshContainer.rotation)) {\n this.sphericalCoordsToVector3(position, vector3);\n applyEulerInverse(vector3, this.psv.renderer.meshContainer.rotation);\n applyEulerInverse(vector3, this.psv.renderer.mesh.rotation);\n position = this.vector3ToSphericalCoords(vector3);\n }\n\n const relativeLong = position.longitude / Math.PI / 2 * panoData.fullWidth;\n const relativeLat = position.latitude / Math.PI * panoData.fullHeight;\n\n return {\n x: Math.round(position.longitude < Math.PI ? relativeLong + panoData.fullWidth / 2 : relativeLong - panoData.fullWidth / 2) - panoData.croppedX,\n y: Math.round(panoData.fullHeight / 2 - relativeLat) - panoData.croppedY,\n };\n }\n\n /**\n * @summary Converts spherical radians coordinates to a THREE.Vector3\n * @param {PSV.Position} position\n * @param {external:THREE.Vector3} [vector]\n * @returns {external:THREE.Vector3}\n */\n sphericalCoordsToVector3(position, vector) {\n if (!vector) {\n vector = new THREE.Vector3();\n }\n vector.x = SPHERE_RADIUS * -Math.cos(position.latitude) * Math.sin(position.longitude);\n vector.y = SPHERE_RADIUS * Math.sin(position.latitude);\n vector.z = SPHERE_RADIUS * Math.cos(position.latitude) * Math.cos(position.longitude);\n return vector;\n }\n\n /**\n * @summary Converts a THREE.Vector3 to spherical radians coordinates\n * @param {external:THREE.Vector3} vector\n * @returns {PSV.Position}\n */\n vector3ToSphericalCoords(vector) {\n const phi = Math.acos(vector.y / Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z));\n const theta = Math.atan2(vector.x, vector.z);\n\n return {\n longitude: theta < 0 ? -theta : Math.PI * 2 - theta,\n latitude : Math.PI / 2 - phi,\n };\n }\n\n /**\n * @summary Converts position on the viewer to a THREE.Vector3\n * @param {PSV.Point} viewerPoint\n * @returns {external:THREE.Vector3}\n */\n viewerCoordsToVector3(viewerPoint) {\n const sphereIntersect = this.getIntersections(viewerPoint).filter(i => i.object.userData[MESH_USER_DATA]);\n\n if (sphereIntersect) {\n return sphereIntersect.point;\n }\n else {\n return null;\n }\n }\n\n /**\n * @summary Converts a THREE.Vector3 to position on the viewer\n * @param {external:THREE.Vector3} vector\n * @returns {PSV.Point}\n */\n vector3ToViewerCoords(vector) {\n const vectorClone = vector.clone();\n vectorClone.project(this.psv.renderer.camera);\n\n return {\n x: Math.round((vectorClone.x + 1) / 2 * this.prop.size.width),\n y: Math.round((1 - vectorClone.y) / 2 * this.prop.size.height),\n };\n }\n\n /**\n * @summary Converts spherical radians coordinates to position on the viewer\n * @param {PSV.Position} position\n * @returns {PSV.Point}\n */\n sphericalCoordsToViewerCoords(position) {\n return this.vector3ToViewerCoords(this.sphericalCoordsToVector3(position, vector3));\n }\n\n /**\n * @summary Returns intersections with objects in the scene\n * @param {PSV.Point} viewerPoint\n * @return {external:THREE.Intersection[]}\n */\n getIntersections(viewerPoint) {\n vector2.x = 2 * viewerPoint.x / this.prop.size.width - 1;\n vector2.y = -2 * viewerPoint.y / this.prop.size.height + 1;\n\n this.psv.renderer.raycaster.setFromCamera(vector2, this.psv.renderer.camera);\n\n return this.psv.renderer.raycaster.intersectObjects(this.psv.renderer.scene.children, true)\n .filter(i => !!i.object.userData);\n }\n\n /**\n * @summary Converts x/y to latitude/longitude if present and ensure boundaries\n * @param {PSV.ExtendedPosition} position\n * @returns {PSV.Position}\n */\n cleanPosition(position) {\n if (position.x !== undefined && position.y !== undefined) {\n return this.textureCoordsToSphericalCoords(position);\n }\n else {\n return {\n longitude: parseAngle(position.longitude),\n latitude : parseAngle(position.latitude, true),\n };\n }\n }\n\n /**\n * @summary Ensure a SphereCorrection object is valid\n * @param {PSV.SphereCorrection} sphereCorrection\n * @returns {PSV.SphereCorrection}\n */\n cleanSphereCorrection(sphereCorrection) {\n return {\n pan : parseAngle(sphereCorrection?.pan || 0),\n tilt: parseAngle(sphereCorrection?.tilt || 0, true),\n roll: parseAngle(sphereCorrection?.roll || 0, true, false),\n };\n }\n\n /**\n * @summary Parse the pose angles of the pano data\n * @param {PSV.PanoData} panoData\n * @returns {PSV.SphereCorrection}\n */\n cleanPanoramaPose(panoData) {\n return {\n pan : THREE.Math.degToRad(panoData?.poseHeading || 0),\n tilt: THREE.Math.degToRad(panoData?.posePitch || 0),\n roll: THREE.Math.degToRad(panoData?.poseRoll || 0),\n };\n }\n\n}\n","import * as THREE from 'three';\nimport {\n ACTIONS,\n CTRLZOOM_TIMEOUT,\n DBLCLICK_DELAY,\n EVENTS,\n IDS,\n INERTIA_WINDOW,\n KEY_CODES,\n LONGTOUCH_DELAY,\n MOVE_THRESHOLD,\n OBJECT_EVENTS,\n TWOFINGERSOVERLAY_DELAY\n} from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport gestureIcon from '../icons/gesture.svg';\nimport mousewheelIcon from '../icons/mousewheel.svg';\nimport { clone, distance, each, getClosest, getPosition, isEmpty, isFullscreenEnabled, normalizeWheel, throttle } from '../utils';\nimport { Animation } from '../utils/Animation';\nimport { PressHandler } from '../utils/PressHandler';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Events handler\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class EventsHandler extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @property {number} moveThreshold - computed threshold based on device pixel ratio\n * @property {boolean} moving - is the user moving\n * @property {boolean} zooming - is the user zooming\n * @property {number} startMouseX - start x position of the click/touch\n * @property {number} startMouseY - start y position of the click/touch\n * @property {number} mouseX - current x position of the cursor\n * @property {number} mouseY - current y position of the cursor\n * @property {number[][]} mouseHistory - list of latest positions of the cursor, [time, x, y]\n * @property {number} pinchDist - distance between fingers when zooming\n * @property {PressHandler} keyHandler\n * @property {boolean} ctrlKeyDown - when the Ctrl key is pressed\n * @property {PSV.ClickData} dblclickData - temporary storage of click data between two clicks\n * @property {number} dblclickTimeout - timeout id for double click\n * @property {number} twofingersTimeout - timeout id for \"two fingers\" overlay\n * @property {number} ctrlZoomTimeout - timeout id for \"ctrol zoom\" overlay\n * @protected\n */\n this.state = {\n moveThreshold : MOVE_THRESHOLD * SYSTEM.pixelRatio,\n keyboardEnabled : false,\n moving : false,\n zooming : false,\n startMouseX : 0,\n startMouseY : 0,\n mouseX : 0,\n mouseY : 0,\n mouseHistory : [],\n pinchDist : 0,\n keyHandler : new PressHandler(),\n ctrlKeyDown : false,\n dblclickData : null,\n dblclickTimeout : null,\n longtouchTimeout : null,\n twofingersTimeout: null,\n ctrlZoomTimeout : null,\n };\n\n /**\n * @summary Throttled wrapper of {@link PSV.Viewer#autoSize}\n * @type {Function}\n * @private\n */\n this.__onResize = throttle(() => this.psv.autoSize(), 50);\n }\n\n /**\n * @summary Initializes event handlers\n * @protected\n */\n init() {\n window.addEventListener('resize', this);\n window.addEventListener('keydown', this);\n window.addEventListener('keyup', this);\n this.psv.container.addEventListener('mouseenter', this);\n this.psv.container.addEventListener('mousedown', this);\n this.psv.container.addEventListener('mouseleave', this);\n this.psv.container.addEventListener('mousemove', this);\n window.addEventListener('mouseup', this);\n this.psv.container.addEventListener('touchstart', this);\n this.psv.container.addEventListener('touchmove', this);\n window.addEventListener('touchend', this);\n this.psv.container.addEventListener(SYSTEM.mouseWheelEvent, this);\n\n if (SYSTEM.fullscreenEvent) {\n document.addEventListener(SYSTEM.fullscreenEvent, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n window.removeEventListener('resize', this);\n window.removeEventListener('keydown', this);\n window.removeEventListener('keyup', this);\n this.psv.container.removeEventListener('mouseenter', this);\n this.psv.container.removeEventListener('mousedown', this);\n this.psv.container.removeEventListener('mouseleave', this);\n this.psv.container.removeEventListener('mousemove', this);\n window.removeEventListener('mouseup', this);\n this.psv.container.removeEventListener('touchstart', this);\n this.psv.container.removeEventListener('touchmove', this);\n window.removeEventListener('touchend', this);\n this.psv.container.removeEventListener(SYSTEM.mouseWheelEvent, this);\n\n if (SYSTEM.fullscreenEvent) {\n document.removeEventListener(SYSTEM.fullscreenEvent, this);\n }\n\n clearTimeout(this.state.dblclickTimeout);\n clearTimeout(this.state.longtouchTimeout);\n clearTimeout(this.state.twofingersTimeout);\n clearTimeout(this.state.ctrlZoomTimeout);\n\n delete this.state;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} evt\n * @private\n */\n handleEvent(evt) {\n /* eslint-disable */\n switch (evt.type) {\n // @formatter:off\n case 'resize': this.__onResize(); break;\n case 'keydown': this.__onKeyDown(evt); break;\n case 'keyup': this.__onKeyUp(); break;\n case 'mouseup': this.__onMouseUp(evt); break;\n case 'touchend': this.__onTouchEnd(evt); break;\n case SYSTEM.fullscreenEvent: this.__fullscreenToggled(); break;\n // @formatter:on\n }\n /* eslint-enable */\n\n if (!getClosest(evt.target, '.psv-navbar') && !getClosest(evt.target, '.psv-panel')) {\n /* eslint-disable */\n switch (evt.type) {\n // @formatter:off\n case 'mousedown': this.__onMouseDown(evt); break;\n case 'mouseenter': this.__onMouseEnter(evt); break;\n case 'mouseleave': this.__onMouseLeave(evt); break;\n case 'mousemove': this.__onMouseMove(evt); break;\n case 'touchstart': this.__onTouchStart(evt); break;\n case 'touchmove': this.__onTouchMove(evt); break;\n case SYSTEM.mouseWheelEvent: this.__onMouseWheel(evt); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n }\n\n /**\n * @summary Enables the keyboard controls\n * @protected\n */\n enableKeyboard() {\n this.state.keyboardEnabled = true;\n }\n\n /**\n * @summary Disables the keyboard controls\n * @protected\n */\n disableKeyboard() {\n this.state.keyboardEnabled = false;\n }\n\n /**\n * @summary Handles keyboard events\n * @param {KeyboardEvent} e\n * @private\n */\n __onKeyDown(e) {\n if (this.config.mousewheelCtrlKey) {\n this.state.ctrlKeyDown = e.key === KEY_CODES.Control;\n\n if (this.state.ctrlKeyDown) {\n clearTimeout(this.state.ctrlZoomTimeout);\n this.psv.overlay.hide(IDS.CTRL_ZOOM);\n }\n }\n\n const e2 = this.psv.trigger(EVENTS.KEY_PRESS, e.key);\n if (e2.isDefaultPrevented()) {\n return;\n }\n\n if (!this.state.keyboardEnabled) {\n return;\n }\n\n if (this.config.keyboard[e.key] === ACTIONS.TOGGLE_AUTOROTATE) {\n this.psv.toggleAutorotate();\n }\n else if (this.config.keyboard[e.key] && !this.state.keyHandler.time) {\n /* eslint-disable */\n switch (this.config.keyboard[e.key]) {\n // @formatter:off\n case ACTIONS.ROTATE_LAT_UP: this.psv.dynamics.position.roll({latitude: false}); break;\n case ACTIONS.ROTATE_LAT_DOWN: this.psv.dynamics.position.roll({latitude: true}); break;\n case ACTIONS.ROTATE_LONG_RIGHT: this.psv.dynamics.position.roll({longitude: false}); break;\n case ACTIONS.ROTATE_LONG_LEFT: this.psv.dynamics.position.roll({longitude: true}); break;\n case ACTIONS.ZOOM_IN: this.psv.dynamics.zoom.roll(false); break;\n case ACTIONS.ZOOM_OUT: this.psv.dynamics.zoom.roll(true); break;\n // @formatter:on\n }\n /* eslint-enable */\n\n this.state.keyHandler.down();\n }\n }\n\n /**\n * @summary Handles keyboard events\n * @private\n */\n __onKeyUp() {\n this.state.ctrlKeyDown = false;\n\n if (!this.state.keyboardEnabled) {\n return;\n }\n\n this.state.keyHandler.up(() => {\n this.psv.dynamics.position.stop();\n this.psv.dynamics.zoom.stop();\n });\n }\n\n /**\n * @summary Handles mouse down events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseDown(evt) {\n if (!this.config.mousemove || this.config.captureCursor) {\n return;\n }\n\n this.__startMove(evt);\n }\n\n /**\n * @summary Handles mouse enter events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseEnter(evt) {\n if (!this.config.mousemove || !this.config.captureCursor) {\n return;\n }\n\n this.__startMove(evt);\n }\n\n /**\n * @summary Handles mouse up events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseUp(evt) {\n if (!this.config.mousemove || this.config.captureCursor) {\n return;\n }\n\n this.__stopMove(evt);\n }\n\n /**\n * @summary Handles mouse leave events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseLeave(evt) {\n if (!this.config.mousemove || !this.config.captureCursor) {\n return;\n }\n\n this.__stopMove(evt);\n }\n\n /**\n * @summary Handles mouse move events\n * @param {MouseEvent} evt\n * @private\n */\n __onMouseMove(evt) {\n if (this.config.mousemove) {\n if (evt.buttons !== 0) {\n evt.preventDefault();\n this.__move(evt);\n }\n else if (this.config.captureCursor) {\n this.__moveAbsolute(evt);\n }\n }\n\n if (!isEmpty(this.prop.objectsObservers)) {\n const viewerPos = getPosition(this.psv.container);\n\n const viewerPoint = {\n x: evt.clientX - viewerPos.left,\n y: evt.clientY - viewerPos.top,\n };\n\n const intersections = this.psv.dataHelper.getIntersections(viewerPoint);\n\n const emit = (observer, key, type) => {\n observer.listener.handleEvent(new CustomEvent(type, {\n detail: {\n originalEvent: evt,\n object : observer.object,\n data : observer.object.userData[key],\n viewerPoint : viewerPoint,\n },\n }));\n };\n\n each(this.prop.objectsObservers, (observer, key) => {\n const intersection = intersections.find(i => i.object.userData[key]);\n\n if (intersection) {\n if (observer.object && intersection.object !== observer.object) {\n emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT);\n delete observer.object;\n }\n\n if (!observer.object) {\n observer.object = intersection.object;\n emit(observer, key, OBJECT_EVENTS.ENTER_OBJECT);\n }\n else {\n emit(observer, key, OBJECT_EVENTS.HOVER_OBJECT);\n }\n }\n else if (observer.object) {\n emit(observer, key, OBJECT_EVENTS.LEAVE_OBJECT);\n delete observer.object;\n }\n });\n }\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchStart(evt) {\n if (!this.config.mousemove) {\n return;\n }\n\n if (evt.touches.length === 1) {\n if (!this.config.touchmoveTwoFingers) {\n this.__startMove(evt.touches[0]);\n evt.preventDefault(); // prevent mouse events emulation\n }\n\n if (!this.prop.longtouchTimeout) {\n this.prop.longtouchTimeout = setTimeout(() => {\n this.__click(evt.touches[0], true);\n this.prop.longtouchTimeout = null;\n }, LONGTOUCH_DELAY);\n }\n }\n else if (evt.touches.length === 2) {\n this.__cancelLongTouch();\n this.__cancelTwoFingersOverlay();\n this.__startMoveZoom(evt);\n evt.preventDefault();\n }\n }\n\n /**\n * @summary Handles touch events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchEnd(evt) {\n if (!this.config.mousemove) {\n return;\n }\n\n this.__cancelLongTouch();\n this.__cancelTwoFingersOverlay();\n\n if (evt.touches.length === 1) {\n this.__stopMoveZoom();\n }\n else if (evt.touches.length === 0) {\n this.__stopMove(evt.changedTouches[0]);\n }\n }\n\n /**\n * @summary Handles touch move events\n * @param {TouchEvent} evt\n * @private\n */\n __onTouchMove(evt) {\n if (!this.config.mousemove) {\n return;\n }\n\n this.__cancelLongTouch();\n\n if (evt.touches.length === 1) {\n if (this.config.touchmoveTwoFingers) {\n if (!this.prop.twofingersTimeout) {\n this.prop.twofingersTimeout = setTimeout(() => {\n this.psv.overlay.show({\n id : IDS.TWO_FINGERS,\n image: gestureIcon,\n text : this.config.lang.twoFingers,\n });\n }, TWOFINGERSOVERLAY_DELAY);\n }\n }\n else {\n evt.preventDefault();\n this.__move(evt.touches[0]);\n }\n }\n else if (evt.touches.length === 2) {\n evt.preventDefault();\n this.__moveZoom(evt);\n this.__cancelTwoFingersOverlay();\n }\n }\n\n /**\n * @summary Cancel the long touch timer if any\n * @private\n */\n __cancelLongTouch() {\n if (this.prop.longtouchTimeout) {\n clearTimeout(this.prop.longtouchTimeout);\n this.prop.longtouchTimeout = null;\n }\n }\n\n /**\n * @summary Cancel the two fingers overlay timer if any\n * @private\n */\n __cancelTwoFingersOverlay() {\n if (this.prop.twofingersTimeout) {\n clearTimeout(this.prop.twofingersTimeout);\n this.prop.twofingersTimeout = null;\n }\n this.psv.overlay.hide(IDS.TWO_FINGERS);\n }\n\n /**\n * @summary Handles mouse wheel events\n * @param {WheelEvent} evt\n * @private\n */\n __onMouseWheel(evt) {\n if (!this.config.mousewheel) {\n return;\n }\n\n if (this.config.mousewheelCtrlKey && !this.state.ctrlKeyDown) {\n this.psv.overlay.show({\n id : IDS.CTRL_ZOOM,\n image: mousewheelIcon,\n text : this.config.lang.ctrlZoom,\n });\n\n clearTimeout(this.state.ctrlZoomTimeout);\n this.state.ctrlZoomTimeout = setTimeout(() => this.psv.overlay.hide(IDS.CTRL_ZOOM), CTRLZOOM_TIMEOUT);\n\n return;\n }\n\n evt.preventDefault();\n evt.stopPropagation();\n\n const delta = normalizeWheel(evt).spinY * 5 * this.config.zoomSpeed;\n if (delta !== 0) {\n this.psv.dynamics.zoom.step(-delta, 5);\n }\n }\n\n /**\n * @summary Handles fullscreen events\n * @param {boolean} [force] force state\n * @fires PSV.fullscreen-updated\n * @package\n */\n __fullscreenToggled(force) {\n this.prop.fullscreen = force !== undefined ? force : isFullscreenEnabled(this.psv.container);\n\n if (this.config.keyboard) {\n if (this.prop.fullscreen) {\n this.psv.startKeyboardControl();\n }\n else {\n this.psv.stopKeyboardControl();\n }\n }\n\n this.psv.trigger(EVENTS.FULLSCREEN_UPDATED, this.prop.fullscreen);\n }\n\n /**\n * @summary Initializes the movement\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __startMove(evt) {\n this.psv.stopAutorotate();\n this.psv.stopAnimation()\n .then(() => {\n this.state.mouseX = evt.clientX;\n this.state.mouseY = evt.clientY;\n this.state.startMouseX = this.state.mouseX;\n this.state.startMouseY = this.state.mouseY;\n this.state.moving = true;\n this.state.zooming = false;\n\n this.state.mouseHistory.length = 0;\n this.__logMouseMove(evt);\n });\n }\n\n /**\n * @summary Initializes the combines move and zoom\n * @param {TouchEvent} evt\n * @private\n */\n __startMoveZoom(evt) {\n const p1 = { x: evt.touches[0].clientX, y: evt.touches[0].clientY };\n const p2 = { x: evt.touches[1].clientX, y: evt.touches[1].clientY };\n\n this.state.pinchDist = distance(p1, p2);\n this.state.mouseX = (p1.x + p2.x) / 2;\n this.state.mouseY = (p1.y + p2.y) / 2;\n this.state.startMouseX = this.state.mouseX;\n this.state.startMouseY = this.state.mouseY;\n this.state.moving = true;\n this.state.zooming = true;\n }\n\n /**\n * @summary Stops the movement\n * @description If the move threshold was not reached a click event is triggered, otherwise an animation is launched to simulate inertia\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __stopMove(evt) {\n if (!getClosest(evt.target, '.psv-container')) {\n this.state.moving = false;\n this.state.mouseHistory.length = 0;\n return;\n }\n\n if (this.state.moving) {\n // move threshold to trigger a click\n if (Math.abs(evt.clientX - this.state.startMouseX) < this.state.moveThreshold\n && Math.abs(evt.clientY - this.state.startMouseY) < this.state.moveThreshold) {\n this.__click(evt);\n this.state.moving = false;\n }\n // inertia animation\n else if (this.config.moveInertia) {\n this.__logMouseMove(evt);\n this.__stopMoveInertia(evt);\n }\n else {\n this.state.moving = false;\n }\n\n this.state.mouseHistory.length = 0;\n }\n }\n\n /**\n * @summary Stops the combined move and zoom\n * @private\n */\n __stopMoveZoom() {\n this.state.mouseHistory.length = 0;\n this.state.moving = false;\n this.state.zooming = false;\n }\n\n /**\n * @summary Performs an animation to simulate inertia when the movement stops\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __stopMoveInertia(evt) {\n const direction = {\n x: evt.clientX - this.state.mouseHistory[0][1],\n y: evt.clientY - this.state.mouseHistory[0][2],\n };\n\n const norm = Math.sqrt(direction.x * direction.x + direction.y * direction.y);\n\n this.prop.animationPromise = new Animation({\n properties: {\n clientX: { start: evt.clientX, end: evt.clientX + direction.x },\n clientY: { start: evt.clientY, end: evt.clientY + direction.y },\n },\n duration : norm * INERTIA_WINDOW / 100,\n easing : 'outCirc',\n onTick : (properties) => {\n this.__move(properties, false);\n },\n });\n\n this.prop.animationPromise\n .then(() => {\n this.state.moving = false;\n });\n }\n\n /**\n * @summary Triggers an event with all coordinates when a simple click is performed\n * @param {MouseEvent|Touch} evt\n * @param {boolean} [longtouch=false]\n * @fires PSV.click\n * @fires PSV.dblclick\n * @private\n */\n __click(evt, longtouch = false) {\n const boundingRect = this.psv.container.getBoundingClientRect();\n\n /**\n * @type {PSV.ClickData}\n */\n const data = {\n rightclick: longtouch || evt.button === 2,\n target : evt.target,\n clientX : evt.clientX,\n clientY : evt.clientY,\n viewerX : evt.clientX - boundingRect.left,\n viewerY : evt.clientY - boundingRect.top,\n };\n\n const intersections = this.psv.dataHelper.getIntersections({\n x: data.viewerX,\n y: data.viewerY,\n });\n\n const sphereIntersection = intersections.find(i => i.object.userData.psvSphere);\n\n if (sphereIntersection) {\n const sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(sphereIntersection.point);\n data.longitude = sphericalCoords.longitude;\n data.latitude = sphericalCoords.latitude;\n\n data.objects = intersections.map(i => i.object).filter(o => !o.userData.psvSphere);\n\n try {\n const textureCoords = this.psv.dataHelper.sphericalCoordsToTextureCoords(data);\n data.textureX = textureCoords.x;\n data.textureY = textureCoords.y;\n }\n catch (e) {\n data.textureX = NaN;\n data.textureY = NaN;\n }\n\n if (!this.state.dblclickTimeout) {\n this.psv.trigger(EVENTS.CLICK, data);\n\n this.state.dblclickData = clone(data);\n this.state.dblclickTimeout = setTimeout(() => {\n this.state.dblclickTimeout = null;\n this.state.dblclickData = null;\n }, DBLCLICK_DELAY);\n }\n else {\n if (Math.abs(this.state.dblclickData.clientX - data.clientX) < this.state.moveThreshold\n && Math.abs(this.state.dblclickData.clientY - data.clientY) < this.state.moveThreshold) {\n this.psv.trigger(EVENTS.DOUBLE_CLICK, this.state.dblclickData);\n }\n\n clearTimeout(this.state.dblclickTimeout);\n this.state.dblclickTimeout = null;\n this.state.dblclickData = null;\n }\n }\n }\n\n /**\n * @summary Performs movement\n * @param {MouseEvent|Touch} evt\n * @param {boolean} [log=true]\n * @private\n */\n __move(evt, log) {\n if (this.state.moving) {\n const x = evt.clientX;\n const y = evt.clientY;\n\n const rotation = {\n longitude: (x - this.state.mouseX) / this.prop.size.width * this.config.moveSpeed * THREE.Math.degToRad(this.prop.hFov),\n latitude : (y - this.state.mouseY) / this.prop.size.height * this.config.moveSpeed * THREE.Math.degToRad(this.prop.vFov),\n };\n\n const currentPosition = this.psv.getPosition();\n this.psv.rotate({\n longitude: currentPosition.longitude - rotation.longitude,\n latitude : currentPosition.latitude + rotation.latitude,\n });\n\n this.state.mouseX = x;\n this.state.mouseY = y;\n\n if (log !== false) {\n this.__logMouseMove(evt);\n }\n }\n }\n\n /**\n * @summary Performs movement absolute to cursor position in viewer\n * @param {MouseEvent} evt\n * @private\n */\n __moveAbsolute(evt) {\n if (this.state.moving) {\n const containerRect = this.psv.container.getBoundingClientRect();\n this.psv.dynamics.position.goto({\n longitude: ((evt.clientX - containerRect.left) / containerRect.width - 0.5) * Math.PI * 2,\n latitude : -((evt.clientY - containerRect.top) / containerRect.height - 0.5) * Math.PI,\n }, 10);\n }\n }\n\n /**\n * @summary Perfoms combined move and zoom\n * @param {TouchEvent} evt\n * @private\n */\n __moveZoom(evt) {\n if (this.state.zooming && this.state.moving) {\n const p1 = { x: evt.touches[0].clientX, y: evt.touches[0].clientY };\n const p2 = { x: evt.touches[1].clientX, y: evt.touches[1].clientY };\n\n const p = distance(p1, p2);\n const delta = 80 * (p - this.state.pinchDist) / this.prop.size.width * this.config.zoomSpeed;\n\n this.psv.zoom(this.psv.getZoomLevel() + delta);\n\n this.__move({\n clientX: (p1.x + p2.x) / 2,\n clientY: (p1.y + p2.y) / 2,\n });\n\n this.state.pinchDist = p;\n }\n }\n\n /**\n * @summary Stores each mouse position during a mouse move\n * @description Positions older than \"INERTIA_WINDOW\" are removed
\n * Positions before a pause of \"INERTIA_WINDOW\" / 10 are removed\n * @param {MouseEvent|Touch} evt\n * @private\n */\n __logMouseMove(evt) {\n const now = Date.now();\n this.state.mouseHistory.push([now, evt.clientX, evt.clientY]);\n\n let previous = null;\n\n for (let i = 0; i < this.state.mouseHistory.length;) {\n if (this.state.mouseHistory[0][i] < now - INERTIA_WINDOW) {\n this.state.mouseHistory.splice(i, 1);\n }\n else if (previous && this.state.mouseHistory[0][i] - previous > INERTIA_WINDOW / 10) {\n this.state.mouseHistory.splice(0, i);\n i = 0;\n previous = this.state.mouseHistory[0][i];\n }\n else {\n i++;\n previous = this.state.mouseHistory[0][i];\n }\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { Animation } from '../utils/Animation';\nimport { EVENTS, MESH_USER_DATA, SPHERE_RADIUS } from '../data/constants';\nimport { SYSTEM } from '../data/system';\nimport { each, isExtendedPosition } from '../utils';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Viewer and renderer\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class Renderer extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @member {external:THREE.WebGLRenderer}\n * @readonly\n * @protected\n */\n this.renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });\n this.renderer.setPixelRatio(SYSTEM.pixelRatio);\n this.renderer.domElement.className = 'psv-canvas';\n\n /**\n * @member {external:THREE.Scene}\n * @readonly\n * @protected\n */\n this.scene = new THREE.Scene();\n\n /**\n * @member {external:THREE.PerspectiveCamera}\n * @readonly\n * @protected\n */\n this.camera = new THREE.PerspectiveCamera(50, 16 / 9, 1, 2 * SPHERE_RADIUS);\n\n /**\n * @member {external:THREE.Mesh}\n * @readonly\n * @protected\n */\n this.mesh = this.psv.adapter.createMesh();\n this.mesh.userData = { [MESH_USER_DATA]: true };\n\n /**\n * @member {external:THREE.Group}\n * @readonly\n * @private\n */\n this.meshContainer = new THREE.Group();\n this.meshContainer.add(this.mesh);\n this.scene.add(this.meshContainer);\n\n /**\n * @member {external:THREE.Raycaster}\n * @readonly\n * @protected\n */\n this.raycaster = new THREE.Raycaster();\n\n /**\n * @member {number}\n * @private\n */\n this.timestamp = null;\n\n /**\n * @member {boolean}\n * @private\n */\n this.ready = false;\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @package\n */\n this.canvasContainer = document.createElement('div');\n this.canvasContainer.className = 'psv-canvas-container';\n this.canvasContainer.style.background = this.psv.config.canvasBackground;\n this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n this.canvasContainer.appendChild(this.renderer.domElement);\n this.psv.container.appendChild(this.canvasContainer);\n\n psv.on(EVENTS.SIZE_UPDATED, this);\n psv.on(EVENTS.ZOOM_UPDATED, this);\n psv.on(EVENTS.POSITION_UPDATED, this);\n psv.on(EVENTS.CONFIG_CHANGED, this);\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n // cancel render loop\n this.renderer.setAnimationLoop(null);\n\n // destroy ThreeJS view\n this.__cleanTHREEScene(this.scene);\n\n // remove container\n this.psv.container.removeChild(this.canvasContainer);\n\n delete this.canvasContainer;\n delete this.renderer;\n delete this.scene;\n delete this.camera;\n delete this.mesh;\n delete this.meshContainer;\n delete this.raycaster;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} evt\n * @private\n */\n handleEvent(evt) {\n /* eslint-disable */\n switch (evt.type) {\n // @formatter:off\n case EVENTS.SIZE_UPDATED: this.__onSizeUpdated(); break;\n case EVENTS.ZOOM_UPDATED: this.__onZoomUpdated(); break;\n case EVENTS.POSITION_UPDATED: this.__onPositionUpdated(); break;\n case EVENTS.CONFIG_CHANGED:\n if (evt.args[0].includes('fisheye')) {\n this.__onPositionUpdated();\n }\n if (evt.args[0].includes('mousemove')) {\n this.canvasContainer.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n }\n break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Hides the viewer\n */\n hide() {\n this.canvasContainer.style.opacity = 0;\n }\n\n /**\n * @summary Shows the viewer\n */\n show() {\n this.canvasContainer.style.opacity = 1;\n }\n\n /**\n * @summary Updates the size of the renderer and the aspect of the camera\n * @private\n */\n __onSizeUpdated() {\n this.renderer.setSize(this.prop.size.width, this.prop.size.height);\n this.camera.aspect = this.prop.aspect;\n this.camera.updateProjectionMatrix();\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Updates the fov of the camera\n * @private\n */\n __onZoomUpdated() {\n this.camera.fov = this.prop.vFov;\n this.camera.updateProjectionMatrix();\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Updates the position of the camera\n * @private\n */\n __onPositionUpdated() {\n this.camera.position.set(0, 0, 0);\n this.camera.lookAt(this.prop.direction);\n if (this.config.fisheye) {\n this.camera.position.copy(this.prop.direction).multiplyScalar(this.config.fisheye / 2).negate();\n }\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Main event loop, calls {@link render} if `prop.needsUpdate` is true\n * @param {number} timestamp\n * @fires PSV.before-render\n * @private\n */\n __renderLoop(timestamp) {\n const elapsed = this.timestamp !== null ? timestamp - this.timestamp : 0;\n this.timestamp = timestamp;\n\n this.psv.trigger(EVENTS.BEFORE_RENDER, timestamp, elapsed);\n each(this.psv.dynamics, d => d.update(elapsed));\n\n if (this.prop.needsUpdate) {\n this.render();\n this.prop.needsUpdate = false;\n }\n }\n\n /**\n * @summary Performs a render\n * @description Do not call this method directly, instead call\n * {@link PSV.Viewer#needsUpdate} on {@link PSV.event:before-render}.\n * @fires PSV.render\n */\n render() {\n this.renderer.render(this.scene, this.camera);\n this.psv.trigger(EVENTS.RENDER);\n }\n\n /**\n * @summary Applies the texture to the scene, creates the scene if needed\n * @param {PSV.TextureData} textureData\n * @fires PSV.panorama-loaded\n * @package\n */\n setTexture(textureData) {\n this.prop.panoData = textureData.panoData;\n\n this.psv.adapter.setTexture(this.mesh, textureData);\n\n if (!this.ready) {\n this.renderer.setAnimationLoop(t => this.__renderLoop(t));\n this.ready = true;\n }\n\n this.psv.needsUpdate();\n\n this.psv.trigger(EVENTS.PANORAMA_LOADED, textureData);\n }\n\n /**\n * @summary Apply a panorama data pose to a Mesh\n * @param {PSV.PanoData} [panoData]\n * @param {external:THREE.Mesh} [mesh=this.mesh]\n * @package\n */\n setPanoramaPose(panoData, mesh = this.mesh) {\n // By Google documentation the angles are applied on the camera in order : heading, pitch, roll\n // here we apply the reverse transformation on the sphere\n const cleanCorrection = this.psv.dataHelper.cleanPanoramaPose(panoData);\n\n mesh.rotation.set(\n -cleanCorrection.tilt,\n -cleanCorrection.pan,\n -cleanCorrection.roll,\n 'ZXY'\n );\n }\n\n /**\n * @summary Apply a SphereCorrection to a Mesh\n * @param {PSV.SphereCorrection} [sphereCorrection]\n * @param {external:THREE.Mesh} [mesh=this.meshContainer]\n * @package\n */\n setSphereCorrection(sphereCorrection, mesh = this.meshContainer) {\n const cleanCorrection = this.psv.dataHelper.cleanSphereCorrection(sphereCorrection);\n\n mesh.rotation.set(\n cleanCorrection.tilt,\n cleanCorrection.pan,\n cleanCorrection.roll,\n 'ZXY'\n );\n }\n\n /**\n * @summary Performs transition between the current and a new texture\n * @param {PSV.TextureData} textureData\n * @param {PSV.PanoramaOptions} options\n * @returns {PSV.Animation}\n * @package\n */\n transition(textureData, options) {\n const positionProvided = isExtendedPosition(options);\n const zoomProvided = 'zoom' in options;\n\n // create temp group and new mesh, half size to be in \"front\" of the first one\n const group = new THREE.Group();\n const mesh = this.psv.adapter.createMesh(0.5);\n this.psv.adapter.setTexture(mesh, textureData, true);\n this.psv.adapter.setTextureOpacity(mesh, 0);\n this.setPanoramaPose(textureData.panoData, mesh);\n this.setSphereCorrection(options.sphereCorrection, group);\n\n // rotate the new sphere to make the target position face the camera\n if (positionProvided) {\n const cleanPosition = this.psv.dataHelper.cleanPosition(options);\n const currentPosition = this.psv.getPosition();\n\n // Longitude rotation along the vertical axis\n const verticalAxis = new THREE.Vector3(0, 1, 0);\n group.rotateOnWorldAxis(verticalAxis, cleanPosition.longitude - currentPosition.longitude);\n\n // Latitude rotation along the camera horizontal axis\n const horizontalAxis = new THREE.Vector3(0, 1, 0).cross(this.camera.getWorldDirection(new THREE.Vector3())).normalize();\n group.rotateOnWorldAxis(horizontalAxis, cleanPosition.latitude - currentPosition.latitude);\n }\n\n group.add(mesh);\n this.scene.add(group);\n\n const animation = new Animation({\n properties: {\n opacity: { start: 0.0, end: 1.0 },\n zoom : zoomProvided ? { start: this.psv.getZoomLevel(), end: options.zoom } : undefined,\n },\n duration : options.transition,\n easing : 'outCubic',\n onTick : (properties) => {\n this.psv.adapter.setTextureOpacity(mesh, properties.opacity);\n this.psv.adapter.setTextureOpacity(this.mesh, 1 - properties.opacity);\n\n if (zoomProvided) {\n this.psv.zoom(properties.zoom);\n }\n\n this.psv.needsUpdate();\n },\n });\n\n animation\n .then((completed) => {\n if (completed) {\n // remove temp sphere and transfer the texture to the main mesh\n this.setTexture(textureData);\n this.psv.adapter.setTextureOpacity(this.mesh, 1);\n this.setPanoramaPose(textureData.panoData);\n this.setSphereCorrection(options.sphereCorrection);\n\n // actually rotate the camera\n if (positionProvided) {\n this.psv.rotate(options);\n }\n }\n else {\n this.psv.adapter.disposeTexture(textureData);\n }\n\n this.scene.remove(group);\n mesh.geometry.dispose();\n mesh.geometry = null;\n });\n\n return animation;\n }\n\n /**\n * @summary Calls `dispose` on all objects and textures\n * @param {external:THREE.Object3D} object\n * @private\n */\n __cleanTHREEScene(object) {\n object.traverse((item) => {\n if (item.geometry) {\n item.geometry.dispose();\n }\n\n if (item.material) {\n if (Array.isArray(item.material)) {\n item.material.forEach((material) => {\n if (material.map) {\n material.map.dispose();\n }\n\n material.dispose();\n });\n }\n else {\n if (item.material.map) {\n item.material.map.dispose();\n }\n\n item.material.dispose();\n }\n }\n\n if (item.dispose && !(item instanceof THREE.Scene)) {\n item.dispose();\n }\n\n if (item !== object) {\n this.__cleanTHREEScene(item);\n }\n });\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Texture loader\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class TextureLoader extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @summary THREE file loader\n * @type {external:THREE:FileLoader}\n * @private\n */\n this.loader = new THREE.FileLoader();\n this.loader.setResponseType('blob');\n if (this.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.config.requestHeaders && typeof this.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.config.requestHeaders);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n this.abortLoading();\n super.destroy();\n }\n\n /**\n * @summary Loads the panorama texture(s)\n * @param {*} panorama\n * @param {PSV.PanoData | PSV.PanoDataProvider} [newPanoData]\n * @returns {Promise.}\n * @throws {PSV.PSVError} when the image cannot be loaded\n * @package\n * @deprecated\n */\n loadTexture(panorama, newPanoData) {\n return this.psv.adapter.loadTexture(panorama, newPanoData);\n }\n\n /**\n * @summary Cancels current HTTP requests\n * @package\n */\n abortLoading() {\n // noop implementation waiting for https://github.com/mrdoob/three.js/pull/23070\n }\n\n /**\n * @summary Loads a Blob with FileLoader\n * @param {string} url\n * @param {function(number)} [onProgress]\n * @returns {Promise}\n */\n loadFile(url, onProgress) {\n if (this.config.requestHeaders && typeof this.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.config.requestHeaders(url));\n }\n\n return new Promise((resolve, reject) => {\n let progress = 0;\n onProgress && onProgress(progress);\n\n this.loader.load(\n url,\n (result) => {\n progress = 100;\n onProgress && onProgress(progress);\n resolve(result);\n },\n (e) => {\n if (e.lengthComputable) {\n const newProgress = e.loaded / e.total * 100;\n if (newProgress > progress) {\n progress = newProgress;\n onProgress && onProgress(progress);\n }\n }\n },\n (err) => {\n reject(err);\n }\n );\n });\n }\n\n /**\n * @summary Loads an Image using FileLoader to have progress events\n * @param {string} url\n * @param {function(number)} [onProgress]\n * @returns {Promise}\n */\n loadImage(url, onProgress) {\n return this.loadFile(url, onProgress)\n .then(result => new Promise((resolve, reject) => {\n const img = document.createElementNS('http://www.w3.org/1999/xhtml', 'img');\n img.onload = () => {\n URL.revokeObjectURL(img.src);\n resolve(img);\n };\n img.onerror = reject;\n img.src = URL.createObjectURL(result);\n }));\n }\n\n /**\n * @summary Preload a panorama file without displaying it\n * @param {*} panorama\n * @returns {Promise}\n */\n preloadPanorama(panorama) {\n if (this.psv.adapter.supportsPreload(panorama)) {\n return this.psv.adapter.loadTexture(panorama);\n }\n else {\n return Promise.resolve();\n }\n }\n\n}\n","import { EVENTS } from '../data/constants';\nimport { PSVError } from '../PSVError';\nimport { addClasses, cleanPosition } from '../utils';\nimport { AbstractComponent } from './AbstractComponent';\n\nconst STATE = { NONE: 0, SHOWING: 1, HIDING: 2, READY: 3 };\n\n/**\n * @typedef {Object} PSV.components.Tooltip.Position\n * @summary Object defining the tooltip position\n * @property {number} top - Position of the tip of the arrow of the tooltip, in pixels\n * @property {number} left - Position of the tip of the arrow of the tooltip, in pixels\n * @property {string|string[]} [position='top center'] - Tooltip position toward it's arrow tip.\n * Accepted values are combinations of `top`, `center`, `bottom` and `left`, `center`, `right`\n * @property {Object} [box] - Used when displaying a tooltip on a marker\n * @property {number} [box.width=0]\n * @property {number} [box.height=0]\n */\n\n/**\n * @typedef {PSV.components.Tooltip.Position} PSV.components.Tooltip.Config\n * @summary Object defining the tooltip configuration\n * @property {string} content - HTML content of the tooltip\n * @property {string} [className] - Additional CSS class added to the tooltip\n * @property {*} [data] - Userdata associated to the tooltip\n */\n\n/**\n * @summary Tooltip component\n * @description Never instanciate tooltips directly use {@link PSV.services.TooltipRenderer} instead\n * @extends PSV.components.AbstractComponent\n * @memberof PSV.components\n */\nexport class Tooltip extends AbstractComponent {\n\n /**\n * @param {PSV.Viewer} psv\n * @param {{arrow: number, offset: number}} size\n */\n constructor(psv, size) {\n super(psv, 'psv-tooltip');\n\n /**\n * @override\n * @property {number} arrow\n * @property {number} offset\n * @property {number} width\n * @property {number} height\n * @property {string} pos\n * @property {string} state\n * @property {*} data\n */\n this.prop = {\n ...this.prop,\n ...size,\n state : STATE.NONE,\n width : 0,\n height: 0,\n pos : '',\n data : null,\n };\n\n /**\n * Tooltip content\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-tooltip-content';\n this.container.appendChild(this.content);\n\n /**\n * Tooltip arrow\n * @member {HTMLElement}\n * @readonly\n * @package\n */\n this.arrow = document.createElement('div');\n this.arrow.className = 'psv-tooltip-arrow';\n this.container.appendChild(this.arrow);\n\n this.container.addEventListener('transitionend', this);\n\n this.container.style.top = '-1000px';\n this.container.style.left = '-1000px';\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.arrow;\n delete this.content;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'transitionend': this.__onTransitionEnd(e); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @summary This method is not supported\n * @throws {PSV.PSVError} always\n */\n toggle() {\n throw new PSVError('Tooltip cannot be toggled');\n }\n\n /**\n * @summary Displays the tooltip on the viewer\n * Do not call this method directly, use {@link PSV.services.TooltipRenderer} instead.\n * @param {PSV.components.Tooltip.Config} config\n *\n * @fires PSV.show-tooltip\n * @throws {PSV.PSVError} when the configuration is incorrect\n *\n * @package\n */\n show(config) {\n if (this.prop.state !== STATE.NONE) {\n throw new PSVError('Initialized tooltip cannot be re-initialized');\n }\n\n if (config.className) {\n addClasses(this.container, config.className);\n }\n\n this.content.innerHTML = config.content;\n\n const rect = this.container.getBoundingClientRect();\n this.prop.width = rect.right - rect.left;\n this.prop.height = rect.bottom - rect.top;\n\n this.prop.state = STATE.READY;\n\n this.move(config);\n\n this.prop.data = config.data;\n this.prop.state = STATE.SHOWING;\n\n this.psv.trigger(EVENTS.SHOW_TOOLTIP, this.prop.data, this);\n }\n\n /**\n * @summary Moves the tooltip to a new position\n * @param {PSV.components.Tooltip.Position} config\n *\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n move(config) {\n if (this.prop.state !== STATE.SHOWING && this.prop.state !== STATE.READY) {\n throw new PSVError('Uninitialized tooltip cannot be moved');\n }\n\n const t = this.container;\n const a = this.arrow;\n\n // compute size\n const style = {\n posClass : cleanPosition(config.position, 'top center', false),\n width : this.prop.width,\n height : this.prop.height,\n top : 0,\n left : 0,\n arrowTop : 0,\n arrowLeft: 0,\n };\n\n // set initial position\n this.__computeTooltipPosition(style, config);\n\n // correct position if overflow\n let refresh = false;\n if (style.top < this.prop.offset) {\n style.posClass[0] = 'bottom';\n refresh = true;\n }\n else if (style.top + style.height > this.psv.prop.size.height - this.prop.offset) {\n style.posClass[0] = 'top';\n refresh = true;\n }\n if (style.left < this.prop.offset) {\n style.posClass[1] = 'right';\n refresh = true;\n }\n else if (style.left + style.width > this.psv.prop.size.width - this.prop.offset) {\n style.posClass[1] = 'left';\n refresh = true;\n }\n if (refresh) {\n this.__computeTooltipPosition(style, config);\n }\n\n // apply position\n t.style.top = style.top + 'px';\n t.style.left = style.left + 'px';\n\n a.style.top = style.arrowTop + 'px';\n a.style.left = style.arrowLeft + 'px';\n\n const newPos = style.posClass.join('-');\n if (newPos !== this.prop.pos) {\n t.classList.remove(`psv-tooltip--${this.prop.pos}`);\n\n this.prop.pos = newPos;\n t.classList.add(`psv-tooltip--${this.prop.pos}`);\n }\n }\n\n /**\n * @summary Hides the tooltip\n * @fires PSV.hide-tooltip\n */\n hide() {\n this.container.classList.remove('psv-tooltip--visible');\n this.prop.state = STATE.HIDING;\n\n this.psv.trigger(EVENTS.HIDE_TOOLTIP, this.prop.data);\n }\n\n /**\n * @summary Finalize transition\n * @param {TransitionEvent} e\n * @private\n */\n __onTransitionEnd(e) {\n if (e.propertyName === 'transform') {\n switch (this.prop.state) {\n case STATE.SHOWING:\n this.container.classList.add('psv-tooltip--visible');\n this.prop.state = STATE.READY;\n break;\n\n case STATE.HIDING:\n this.prop.state = STATE.NONE;\n this.destroy();\n break;\n\n default:\n // nothing\n }\n }\n }\n\n /**\n * @summary Computes the position of the tooltip and its arrow\n * @param {Object} style\n * @param {Object} config\n * @private\n */\n __computeTooltipPosition(style, config) {\n let topBottom = false;\n\n if (!config.box) {\n config.box = {\n width : 0,\n height: 0,\n };\n }\n\n switch (style.posClass[0]) {\n case 'bottom':\n style.top = config.top + config.box.height + this.prop.offset + this.prop.arrow;\n style.arrowTop = -this.prop.arrow * 2;\n topBottom = true;\n break;\n\n case 'center':\n style.top = config.top + config.box.height / 2 - style.height / 2;\n style.arrowTop = style.height / 2 - this.prop.arrow;\n break;\n\n case 'top':\n style.top = config.top - style.height - this.prop.offset - this.prop.arrow;\n style.arrowTop = style.height;\n topBottom = true;\n break;\n\n // no default\n }\n\n switch (style.posClass[1]) {\n case 'right':\n if (topBottom) {\n style.left = config.left + config.box.width / 2 - this.prop.offset - this.prop.arrow;\n style.arrowLeft = this.prop.offset;\n }\n else {\n style.left = config.left + config.box.width + this.prop.offset + this.prop.arrow;\n style.arrowLeft = -this.prop.arrow * 2;\n }\n break;\n\n case 'center':\n style.left = config.left + config.box.width / 2 - style.width / 2;\n style.arrowLeft = style.width / 2 - this.prop.arrow;\n break;\n\n case 'left':\n if (topBottom) {\n style.left = config.left - style.width + config.box.width / 2 + this.prop.offset + this.prop.arrow;\n style.arrowLeft = style.width - this.prop.offset - this.prop.arrow * 2;\n }\n else {\n style.left = config.left - style.width - this.prop.offset - this.prop.arrow;\n style.arrowLeft = style.width;\n }\n break;\n\n // no default\n }\n }\n\n}\n","import { Tooltip } from '../components/Tooltip';\nimport { getStyle } from '../utils';\nimport { AbstractService } from './AbstractService';\n\n/**\n * @summary Tooltip renderer\n * @extends PSV.services.AbstractService\n * @memberof PSV.services\n */\nexport class TooltipRenderer extends AbstractService {\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n const testTooltip = new Tooltip(this.psv);\n\n /**\n * @summary Computed static sizes\n * @member {Object}\n * @package\n * @property {number} arrowSize\n * @property {number} offset\n */\n this.size = {\n arrow : parseInt(getStyle(testTooltip.arrow, 'borderTopWidth'), 10),\n offset: parseInt(getStyle(testTooltip.container, 'outlineWidth'), 10),\n };\n\n testTooltip.destroy();\n }\n\n /**\n * @override\n */\n destroy() {\n delete this.size;\n\n super.destroy();\n }\n\n /**\n * @summary Displays a tooltip on the viewer\n * @param {PSV.components.Tooltip.Config} config\n * @returns {PSV.components.Tooltip}\n *\n * @fires PSV.show-tooltip\n * @throws {PSV.PSVError} when the configuration is incorrect\n *\n * @example\n * viewer.tooltip.create({ content: 'Hello world', top: 200, left: 450, position: 'center bottom'})\n */\n create(config) {\n const tooltip = new Tooltip(this.psv, this.size);\n tooltip.show(config);\n\n return tooltip;\n }\n\n}\n","import * as THREE from 'three';\nimport { EventEmitter } from 'uevent';\nimport { Loader } from './components/Loader';\nimport { Navbar } from './components/Navbar';\nimport { Notification } from './components/Notification';\nimport { Overlay } from './components/Overlay';\nimport { Panel } from './components/Panel';\nimport { CONFIG_PARSERS, DEFAULTS, DEPRECATED_OPTIONS, getConfig, READONLY_OPTIONS } from './data/config';\nimport { CHANGE_EVENTS, DEFAULT_TRANSITION, EVENTS, IDS, SPHERE_RADIUS, VIEWER_DATA } from './data/constants';\nimport { SYSTEM } from './data/system';\nimport errorIcon from './icons/error.svg';\nimport { AbstractPlugin } from './plugins/AbstractPlugin';\nimport { PSVError } from './PSVError';\nimport { DataHelper } from './services/DataHelper';\nimport { EventsHandler } from './services/EventsHandler';\nimport { Renderer } from './services/Renderer';\nimport { TextureLoader } from './services/TextureLoader';\nimport { TooltipRenderer } from './services/TooltipRenderer';\nimport {\n Animation,\n Dynamic,\n each,\n exitFullscreen,\n getAbortError,\n getAngle,\n getShortestArc,\n isAbortError,\n isExtendedPosition,\n isFullscreenEnabled,\n logWarn,\n MultiDynamic,\n pluginInterop,\n requestFullscreen,\n throttle,\n toggleClass\n} from './utils';\n\nTHREE.Cache.enabled = true;\n\n/**\n * @summary Main class\n * @memberOf PSV\n * @extends {external:uEvent.EventEmitter}\n */\nexport class Viewer extends EventEmitter {\n\n /**\n * @param {PSV.Options} options\n * @fires PSV.ready\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n constructor(options) {\n super();\n\n SYSTEM.load();\n\n // must support WebGL\n if (!SYSTEM.isWebGLSupported) {\n throw new PSVError('WebGL is not supported.');\n }\n\n if (SYSTEM.maxTextureWidth === 0) {\n throw new PSVError('Unable to detect system capabilities');\n }\n\n /**\n * @summary Internal properties\n * @member {Object}\n * @protected\n * @property {boolean} ready - when all components are loaded\n * @property {boolean} uiRefresh - if the UI needs to be renderer\n * @property {boolean} needsUpdate - if the view needs to be renderer\n * @property {boolean} fullscreen - if the viewer is currently fullscreen\n * @property {external:THREE.Vector3} direction - direction of the camera\n * @property {number} vFov - vertical FOV\n * @property {number} hFov - horizontal FOV\n * @property {number} aspect - viewer aspect ratio\n * @property {boolean} autorotateEnabled - automatic rotation is enabled\n * @property {PSV.Animation} animationPromise - promise of the current animation\n * @property {Promise} loadingPromise - promise of the setPanorama method\n * @property startTimeout - timeout id of the automatic rotation delay\n * @property {object} objectsObservers\n * @property {PSV.Size} size - size of the container\n * @property {PSV.PanoData} panoData - panorama metadata, if supported\n */\n this.prop = {\n ready : false,\n uiRefresh : false,\n needsUpdate : false,\n fullscreen : false,\n direction : new THREE.Vector3(0, 0, SPHERE_RADIUS),\n vFov : null,\n hFov : null,\n aspect : null,\n autorotateEnabled: false,\n animationPromise : null,\n loadingPromise : null,\n startTimeout : null,\n objectsObservers : {},\n size : {\n width : 0,\n height: 0,\n },\n panoData : {\n fullWidth : 0,\n fullHeight : 0,\n croppedWidth : 0,\n croppedHeight: 0,\n croppedX : 0,\n croppedY : 0,\n poseHeading : 0,\n posePitch : 0,\n poseRoll : 0,\n },\n };\n\n /**\n * @summary Configuration holder\n * @type {PSV.Options}\n * @readonly\n */\n this.config = getConfig(options);\n\n /**\n * @summary Top most parent\n * @member {HTMLElement}\n * @readonly\n */\n this.parent = (typeof options.container === 'string') ? document.getElementById(options.container) : options.container;\n this.parent[VIEWER_DATA] = this;\n\n /**\n * @summary Main container\n * @member {HTMLElement}\n * @readonly\n */\n this.container = document.createElement('div');\n this.container.classList.add('psv-container');\n this.parent.appendChild(this.container);\n\n /**\n * @summary Render adapter\n * @type {PSV.adapters.AbstractAdapter}\n * @readonly\n * @package\n */\n this.adapter = new this.config.adapter[0](this, this.config.adapter[1]); // eslint-disable-line new-cap\n\n /**\n * @summary All child components\n * @type {PSV.components.AbstractComponent[]}\n * @readonly\n * @package\n */\n this.children = [];\n\n /**\n * @summary All plugins\n * @type {Object}\n * @readonly\n * @package\n */\n this.plugins = {};\n\n /**\n * @type {PSV.services.Renderer}\n * @readonly\n */\n this.renderer = new Renderer(this);\n\n /**\n * @type {PSV.services.TextureLoader}\n * @readonly\n */\n this.textureLoader = new TextureLoader(this);\n\n /**\n * @type {PSV.services.EventsHandler}\n * @readonly\n */\n this.eventsHandler = new EventsHandler(this);\n\n /**\n * @type {PSV.services.DataHelper}\n * @readonly\n */\n this.dataHelper = new DataHelper(this);\n\n /**\n * @member {PSV.components.Loader}\n * @readonly\n */\n this.loader = new Loader(this);\n\n /**\n * @member {PSV.components.Navbar}\n * @readonly\n */\n this.navbar = new Navbar(this);\n\n /**\n * @member {PSV.components.Panel}\n * @readonly\n */\n this.panel = new Panel(this);\n\n /**\n * @member {PSV.services.TooltipRenderer}\n * @readonly\n */\n this.tooltip = new TooltipRenderer(this);\n\n /**\n * @member {PSV.components.Notification}\n * @readonly\n */\n this.notification = new Notification(this);\n\n /**\n * @member {PSV.components.Overlay}\n * @readonly\n */\n this.overlay = new Overlay(this);\n\n /**\n * @member {Record}\n * @package\n */\n this.dynamics = {\n zoom: new Dynamic((value) => {\n this.prop.vFov = this.dataHelper.zoomLevelToFov(value);\n this.prop.hFov = this.dataHelper.vFovToHFov(this.prop.vFov);\n this.trigger(EVENTS.ZOOM_UPDATED, value);\n }, this.config.defaultZoomLvl, 0, 100),\n\n position: new MultiDynamic({\n longitude: new Dynamic(null, this.config.defaultLong, 0, 2 * Math.PI, true),\n latitude : new Dynamic(null, this.config.defaultLat, -Math.PI / 2, Math.PI / 2),\n }, (position) => {\n this.dataHelper.sphericalCoordsToVector3(position, this.prop.direction);\n this.trigger(EVENTS.POSITION_UPDATED, position);\n }),\n };\n\n this.__updateSpeeds();\n\n this.eventsHandler.init();\n\n this.__resizeRefresh = throttle(() => this.refreshUi('resize'), 500);\n\n // apply container size\n this.resize(this.config.size);\n\n // init plugins\n this.config.plugins.forEach(([plugin, opts]) => {\n this.plugins[plugin.id] = new plugin(this, opts); // eslint-disable-line new-cap\n });\n each(this.plugins, plugin => plugin.init?.());\n\n // init buttons\n this.navbar.setButtons(this.config.navbar);\n\n // load panorama\n if (this.config.panorama) {\n this.setPanorama(this.config.panorama);\n }\n\n SYSTEM.isTouchEnabled.then(enabled => toggleClass(this.container, 'psv--is-touch', enabled));\n\n // enable GUI after first render\n this.once(EVENTS.RENDER, () => {\n if (this.config.navbar) {\n this.container.classList.add('psv--has-navbar');\n this.navbar.show();\n }\n\n // Queue autorotate\n if (this.config.autorotateDelay) {\n this.prop.startTimeout = setTimeout(() => this.startAutorotate(), this.config.autorotateDelay);\n }\n\n this.prop.ready = true;\n\n setTimeout(() => {\n this.refreshUi('init');\n\n this.trigger(EVENTS.READY);\n }, 0);\n });\n }\n\n /**\n * @summary Destroys the viewer\n * @description The memory used by the ThreeJS context is not totally cleared. This will be fixed as soon as possible.\n */\n destroy() {\n this.__stopAll();\n this.stopKeyboardControl();\n this.exitFullscreen();\n\n this.eventsHandler.destroy();\n this.renderer.destroy();\n this.textureLoader.destroy();\n this.dataHelper.destroy();\n this.adapter.destroy();\n\n this.children.slice().forEach(child => child.destroy());\n this.children.length = 0;\n\n each(this.plugins, plugin => plugin.destroy());\n delete this.plugins;\n\n this.parent.removeChild(this.container);\n delete this.parent[VIEWER_DATA];\n\n delete this.parent;\n delete this.container;\n\n delete this.loader;\n delete this.navbar;\n delete this.panel;\n delete this.tooltip;\n delete this.notification;\n delete this.overlay;\n\n delete this.config;\n }\n\n /**\n * @summary Refresh UI\n * @package\n */\n refreshUi(reason) {\n if (!this.prop.ready) {\n return;\n }\n\n if (!this.prop.uiRefresh) {\n // console.log(`PhotoSphereViewer: UI Refresh, ${reason}`);\n\n this.prop.uiRefresh = true;\n\n this.children.every((child) => {\n child.refreshUi();\n return this.prop.uiRefresh === true;\n });\n\n this.prop.uiRefresh = false;\n }\n else if (this.prop.uiRefresh !== 'new') {\n this.prop.uiRefresh = 'new';\n\n // wait for current refresh to cancel\n setTimeout(() => {\n this.prop.uiRefresh = false;\n this.refreshUi(reason);\n });\n }\n }\n\n /**\n * @summary Returns the instance of a plugin if it exists\n * @param {Class|string} pluginId\n * @returns {PSV.plugins.AbstractPlugin}\n */\n getPlugin(pluginId) {\n if (typeof pluginId === 'string') {\n return this.plugins[pluginId];\n }\n else {\n const pluginCtor = pluginInterop(pluginId, AbstractPlugin);\n return pluginCtor ? this.plugins[pluginCtor.id] : undefined;\n }\n }\n\n /**\n * @summary Returns the current position of the camera\n * @returns {PSV.Position}\n */\n getPosition() {\n return this.dataHelper.cleanPosition(this.dynamics.position.current);\n }\n\n /**\n * @summary Returns the current zoom level\n * @returns {number}\n */\n getZoomLevel() {\n return this.dynamics.zoom.current;\n }\n\n /**\n * @summary Returns the current viewer size\n * @returns {PSV.Size}\n */\n getSize() {\n return { ...this.prop.size };\n }\n\n /**\n * @summary Checks if the automatic rotation is enabled\n * @returns {boolean}\n */\n isAutorotateEnabled() {\n return this.prop.autorotateEnabled;\n }\n\n /**\n * @summary Checks if the viewer is in fullscreen\n * @returns {boolean}\n */\n isFullscreenEnabled() {\n if (SYSTEM.fullscreenEvent) {\n return isFullscreenEnabled(this.container);\n }\n else {\n return this.prop.fullscreen;\n }\n }\n\n /**\n * @summary Flags the view has changed for the next render\n */\n needsUpdate() {\n this.prop.needsUpdate = true;\n }\n\n /**\n * @summary Resizes the canvas when the window is resized\n * @fires PSV.size-updated\n */\n autoSize() {\n if (this.container.clientWidth !== this.prop.size.width || this.container.clientHeight !== this.prop.size.height) {\n this.prop.size.width = Math.round(this.container.clientWidth);\n this.prop.size.height = Math.round(this.container.clientHeight);\n this.prop.aspect = this.prop.size.width / this.prop.size.height;\n this.prop.hFov = this.dataHelper.vFovToHFov(this.prop.vFov);\n\n this.trigger(EVENTS.SIZE_UPDATED, this.getSize());\n this.__resizeRefresh();\n }\n }\n\n /**\n * @summary Loads a new panorama file\n * @description Loads a new panorama file, optionally changing the camera position/zoom and activating the transition animation.
\n * If the \"options\" parameter is not defined, the camera will not move and the ongoing animation will continue.
\n * If another loading is already in progress it will be aborted.\n * @param {*} path - URL of the new panorama file\n * @param {PSV.PanoramaOptions} [options]\n * @returns {Promise} resolves false if the loading was aborted by another call\n */\n setPanorama(path, options = {}) {\n this.textureLoader.abortLoading();\n this.prop.transitionAnimation?.cancel();\n\n // apply default parameters on first load\n if (!this.prop.ready) {\n if (!('sphereCorrection' in options)) {\n options.sphereCorrection = this.config.sphereCorrection;\n }\n if (!('panoData' in options)) {\n options.panoData = this.config.panoData;\n }\n }\n\n if (options.transition === undefined || options.transition === true) {\n options.transition = DEFAULT_TRANSITION;\n }\n if (options.showLoader === undefined) {\n options.showLoader = true;\n }\n if (options.caption === undefined) {\n options.caption = this.config.caption;\n }\n if (options.description === undefined) {\n options.description = this.config.description;\n }\n\n const positionProvided = isExtendedPosition(options);\n const zoomProvided = 'zoom' in options;\n\n if (positionProvided || zoomProvided) {\n this.__stopAll();\n }\n\n this.hideError();\n\n this.config.panorama = path;\n this.config.caption = options.caption;\n this.config.description = options.description;\n\n const done = (err) => {\n this.loader.hide();\n\n this.prop.loadingPromise = null;\n\n if (isAbortError(err)) {\n return false;\n }\n else if (err) {\n this.navbar.setCaption('');\n this.showError(this.config.lang.loadError);\n console.error(err);\n throw err;\n }\n else {\n this.navbar.setCaption(this.config.caption);\n return true;\n }\n };\n\n this.navbar.setCaption(`${this.config.loadingTxt || ''}`);\n if (options.showLoader || !this.prop.ready) {\n this.loader.show();\n }\n\n const loadingPromise = this.adapter.loadTexture(this.config.panorama, options.panoData)\n .then((textureData) => {\n // check if another panorama was requested\n if (textureData.panorama !== this.config.panorama) {\n this.adapter.disposeTexture(textureData);\n throw getAbortError();\n }\n return textureData;\n });\n\n if (!options.transition || !this.prop.ready || !this.adapter.supportsTransition(this.config.panorama)) {\n this.prop.loadingPromise = loadingPromise\n .then((textureData) => {\n this.renderer.show();\n this.renderer.setTexture(textureData);\n this.renderer.setPanoramaPose(textureData.panoData);\n this.renderer.setSphereCorrection(options.sphereCorrection);\n\n if (zoomProvided) {\n this.zoom(options.zoom);\n }\n if (positionProvided) {\n this.rotate(options);\n }\n })\n .then(done, done);\n }\n else {\n this.prop.loadingPromise = loadingPromise\n .then((textureData) => {\n this.loader.hide();\n\n this.prop.transitionAnimation = this.renderer.transition(textureData, options);\n return this.prop.transitionAnimation\n .then((completed) => {\n this.prop.transitionAnimation = null;\n if (!completed) {\n throw getAbortError();\n }\n });\n })\n .then(done, done);\n }\n\n return this.prop.loadingPromise;\n }\n\n /**\n * @summary Update options\n * @param {PSV.Options} options\n * @fires PSV.config-changed\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n setOptions(options) {\n each(options, (value, key) => {\n if (DEPRECATED_OPTIONS[key]) {\n logWarn(DEPRECATED_OPTIONS[key]);\n return;\n }\n\n if (!Object.prototype.hasOwnProperty.call(DEFAULTS, key)) {\n throw new PSVError(`Unknown option ${key}`);\n }\n\n if (READONLY_OPTIONS[key]) {\n throw new PSVError(READONLY_OPTIONS[key]);\n }\n\n if (CONFIG_PARSERS[key]) {\n this.config[key] = CONFIG_PARSERS[key](value, options);\n }\n else {\n this.config[key] = value;\n }\n\n switch (key) {\n case 'caption':\n case 'description':\n this.navbar.setCaption(this.config.caption);\n break;\n\n case 'size':\n this.resize(value);\n break;\n\n case 'sphereCorrection':\n this.renderer.setSphereCorrection(value);\n break;\n\n case 'navbar':\n case 'lang':\n this.navbar.setButtons(this.config.navbar);\n break;\n\n case 'moveSpeed':\n case 'zoomSpeed':\n this.__updateSpeeds();\n break;\n\n case 'minFov':\n case 'maxFov':\n this.dynamics.zoom.setValue(this.dataHelper.fovToZoomLevel(this.prop.vFov));\n this.trigger(EVENTS.ZOOM_UPDATED, this.getZoomLevel());\n break;\n\n case 'canvasBackground':\n this.renderer.canvasContainer.style.background = this.config.canvasBackground;\n break;\n\n default:\n break;\n }\n });\n\n this.needsUpdate();\n this.refreshUi('set options');\n\n this.trigger(EVENTS.CONFIG_CHANGED, Object.keys(options));\n }\n\n /**\n * @summary Update options\n * @param {string} option\n * @param {any} value\n * @fires PSV.config-changed\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n setOption(option, value) {\n this.setOptions({ [option]: value });\n }\n\n /**\n * @summary Starts the automatic rotation\n * @fires PSV.autorotate\n */\n startAutorotate(refresh = false) {\n if (refresh && !this.isAutorotateEnabled()) {\n return;\n }\n\n if (!refresh) {\n this.__stopAll();\n }\n\n this.dynamics.position.roll({\n longitude: this.config.autorotateSpeed < 0,\n }, Math.abs(this.config.autorotateSpeed / this.config.moveSpeed));\n\n this.dynamics.position.goto({\n latitude: this.config.autorotateLat,\n }, Math.abs(this.config.autorotateSpeed / this.config.moveSpeed));\n\n this.prop.autorotateEnabled = true;\n\n if (!refresh) {\n this.trigger(EVENTS.AUTOROTATE, true);\n }\n }\n\n /**\n * @summary Stops the automatic rotation\n * @fires PSV.autorotate\n */\n stopAutorotate() {\n if (this.prop.startTimeout) {\n clearTimeout(this.prop.startTimeout);\n this.prop.startTimeout = null;\n }\n\n if (this.isAutorotateEnabled()) {\n this.dynamics.position.stop();\n\n this.prop.autorotateEnabled = false;\n\n this.trigger(EVENTS.AUTOROTATE, false);\n }\n }\n\n /**\n * @summary Starts or stops the automatic rotation\n * @fires PSV.autorotate\n */\n toggleAutorotate() {\n if (this.isAutorotateEnabled()) {\n this.stopAutorotate();\n }\n else {\n this.startAutorotate();\n }\n }\n\n /**\n * @summary Displays an error message over the viewer\n * @param {string} message\n */\n showError(message) {\n this.overlay.show({\n id : IDS.ERROR,\n image : errorIcon,\n text : message,\n dissmisable: false,\n });\n }\n\n /**\n * @summary Hides the error message\n */\n hideError() {\n this.overlay.hide(IDS.ERROR);\n }\n\n /**\n * @summary Rotates the view to specific longitude and latitude\n * @param {PSV.ExtendedPosition} position\n * @fires PSV.before-rotate\n * @fires PSV.position-updated\n */\n rotate(position) {\n const e = this.trigger(EVENTS.BEFORE_ROTATE, position);\n if (e.isDefaultPrevented()) {\n return;\n }\n\n const cleanPosition = this.change(CHANGE_EVENTS.GET_ROTATE_POSITION, this.dataHelper.cleanPosition(position));\n this.dynamics.position.setValue(cleanPosition);\n }\n\n /**\n * @summary Rotates and zooms the view with a smooth animation\n * @param {PSV.AnimateOptions} options - position and/or zoom level\n * @returns {PSV.Animation}\n */\n animate(options) {\n this.__stopAll();\n\n const positionProvided = isExtendedPosition(options);\n const zoomProvided = 'zoom' in options;\n\n const animProperties = {};\n let duration;\n\n // clean/filter position and compute duration\n if (positionProvided) {\n const cleanPosition = this.change(CHANGE_EVENTS.GET_ANIMATE_POSITION, this.dataHelper.cleanPosition(options));\n const currentPosition = this.getPosition();\n\n // longitude offset for shortest arc\n const tOffset = getShortestArc(currentPosition.longitude, cleanPosition.longitude);\n\n animProperties.longitude = { start: currentPosition.longitude, end: currentPosition.longitude + tOffset };\n animProperties.latitude = { start: currentPosition.latitude, end: cleanPosition.latitude };\n\n duration = this.dataHelper.speedToDuration(options.speed, getAngle(currentPosition, cleanPosition));\n }\n\n // clean/filter zoom and compute duration\n if (zoomProvided) {\n const dZoom = Math.abs(options.zoom - this.getZoomLevel());\n\n animProperties.zoom = { start: this.getZoomLevel(), end: options.zoom };\n\n if (!duration) {\n // if animating zoom only and a speed is given, use an arbitrary PI/4 to compute the duration\n duration = this.dataHelper.speedToDuration(options.speed, Math.PI / 4 * dZoom / 100);\n }\n }\n\n // if no animation needed\n if (!duration) {\n if (positionProvided) {\n this.rotate(options);\n }\n if (zoomProvided) {\n this.zoom(options.zoom);\n }\n\n return new Animation();\n }\n\n this.prop.animationPromise = new Animation({\n properties: animProperties,\n duration : duration,\n easing : 'inOutSine',\n onTick : (properties) => {\n if (positionProvided) {\n this.rotate(properties);\n }\n if (zoomProvided) {\n this.zoom(properties.zoom);\n }\n },\n });\n\n return this.prop.animationPromise;\n }\n\n /**\n * @summary Stops the ongoing animation\n * @description The return value is a Promise because the is no guaranty the animation can be stopped synchronously.\n * @returns {Promise} Resolved when the animation has ben cancelled\n */\n stopAnimation() {\n if (this.prop.animationPromise) {\n return new Promise((resolve) => {\n this.prop.animationPromise.then(resolve);\n this.prop.animationPromise.cancel();\n this.prop.animationPromise = null;\n });\n }\n else {\n return Promise.resolve();\n }\n }\n\n /**\n * @summary Zooms to a specific level between `max_fov` and `min_fov`\n * @param {number} level - new zoom level from 0 to 100\n * @fires PSV.zoom-updated\n */\n zoom(level) {\n this.dynamics.zoom.setValue(level);\n }\n\n /**\n * @summary Increases the zoom level\n * @param {number} [step=1]\n */\n zoomIn(step = 1) {\n this.dynamics.zoom.step(step);\n }\n\n /**\n * @summary Decreases the zoom level\n * @param {number} [step=1]\n */\n zoomOut(step = 1) {\n this.dynamics.zoom.step(-step);\n }\n\n /**\n * @summary Resizes the viewer\n * @param {PSV.CssSize} size\n */\n resize(size) {\n ['width', 'height'].forEach((dim) => {\n if (size && size[dim]) {\n if (/^[0-9.]+$/.test(size[dim])) {\n size[dim] += 'px';\n }\n this.parent.style[dim] = size[dim];\n }\n });\n\n this.autoSize();\n }\n\n /**\n * @summary Enters the fullscreen mode\n * @fires PSV.fullscreen-updated\n */\n enterFullscreen() {\n if (SYSTEM.fullscreenEvent) {\n requestFullscreen(this.container);\n }\n else {\n this.container.classList.add('psv-container--fullscreen');\n this.autoSize();\n this.eventsHandler.__fullscreenToggled(true);\n }\n }\n\n /**\n * @summary Exits the fullscreen mode\n * @fires PSV.fullscreen-updated\n */\n exitFullscreen() {\n if (this.isFullscreenEnabled()) {\n if (SYSTEM.fullscreenEvent) {\n exitFullscreen();\n }\n else {\n this.container.classList.remove('psv-container--fullscreen');\n this.autoSize();\n this.eventsHandler.__fullscreenToggled(false);\n }\n }\n }\n\n /**\n * @summary Enters or exits the fullscreen mode\n * @fires PSV.fullscreen-updated\n */\n toggleFullscreen() {\n if (!this.isFullscreenEnabled()) {\n this.enterFullscreen();\n }\n else {\n this.exitFullscreen();\n }\n }\n\n /**\n * @summary Enables the keyboard controls (done automatically when entering fullscreen)\n */\n startKeyboardControl() {\n this.eventsHandler.enableKeyboard();\n }\n\n /**\n * @summary Disables the keyboard controls (done automatically when exiting fullscreen)\n */\n stopKeyboardControl() {\n this.eventsHandler.disableKeyboard();\n }\n\n /**\n * @summary Subscribes to events on objects in the scene\n * @param {string} userDataKey - only objects with the following `userData` will be emitted\n * @param {EventListener} listener - must implement `handleEvent\n * @return {function} call to stop the subscription\n * @package\n */\n observeObjects(userDataKey, listener) {\n this.prop.objectsObservers[userDataKey] = { listener };\n\n return () => {\n delete this.prop.objectsObservers[userDataKey];\n };\n }\n\n /**\n * @summary Stops all current animations\n * @package\n */\n __stopAll() {\n this.stopAutorotate();\n this.stopAnimation();\n\n this.trigger(EVENTS.STOP_ALL);\n }\n\n /**\n * @summary Recomputes dynamics speeds\n * @private\n */\n __updateSpeeds() {\n this.dynamics.zoom.setSpeed(this.config.zoomSpeed * 50);\n this.dynamics.position.setSpeed(THREE.Math.degToRad(this.config.moveSpeed * 50));\n }\n\n}\n"],"names":["PSVError","message","Error","captureStackTrace","stack","prototype","Object","create","name","constructor","AbstractAdapter","psv","destroy","supportsTransition","panorama","supportsPreload","loadTexture","newPanoData","createMesh","scale","setTexture","mesh","textureData","transition","setTextureOpacity","opacity","disposeTexture","id","supportsDownload","DEFAULT_TRANSITION","MOVE_THRESHOLD","DBLCLICK_DELAY","LONGTOUCH_DELAY","TWOFINGERSOVERLAY_DELAY","CTRLZOOM_TIMEOUT","INERTIA_WINDOW","SPHERE_RADIUS","VIEWER_DATA","MESH_USER_DATA","ACTIONS","ROTATE_LAT_UP","ROTATE_LAT_DOWN","ROTATE_LONG_RIGHT","ROTATE_LONG_LEFT","ZOOM_IN","ZOOM_OUT","TOGGLE_AUTOROTATE","EVENTS","AUTOROTATE","BEFORE_RENDER","BEFORE_ROTATE","CLICK","CLOSE_PANEL","CONFIG_CHANGED","DOUBLE_CLICK","FULLSCREEN_UPDATED","HIDE_NOTIFICATION","HIDE_OVERLAY","HIDE_TOOLTIP","KEY_PRESS","LOAD_PROGRESS","OPEN_PANEL","PANORAMA_LOADED","POSITION_UPDATED","READY","RENDER","SHOW_NOTIFICATION","SHOW_OVERLAY","SHOW_TOOLTIP","SIZE_UPDATED","STOP_ALL","ZOOM_UPDATED","CHANGE_EVENTS","GET_ANIMATE_POSITION","GET_ROTATE_POSITION","OBJECT_EVENTS","ENTER_OBJECT","HOVER_OBJECT","LEAVE_OBJECT","IDS","MENU","TWO_FINGERS","CTRL_ZOOM","ERROR","DESCRIPTION","EASINGS","linear","t","inQuad","outQuad","inOutQuad","inCubic","outCubic","inOutCubic","inQuart","outQuart","inOutQuart","inQuint","outQuint","inOutQuint","inSine","Math","cos","PI","outSine","sin","inOutSine","inExpo","pow","outExpo","inOutExpo","inCirc","sqrt","outCirc","inOutCirc","KEY_CODES","Enter","Control","Escape","Space","PageUp","PageDown","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Delete","Plus","Minus","SYSTEM","loaded","pixelRatio","isWebGLSupported","isTouchEnabled","maxTextureWidth","mouseWheelEvent","fullscreenEvent","load","ctx","getWebGLCtx","window","devicePixelRatio","getMaxTextureWidth","getMouseWheelEvent","getFullscreenEvent","maxCanvasWidth","getMaxCanvasWidth","canvas","document","createElement","names","context","getContext","some","e","Promise","resolve","listener","removeEventListener","addEventListener","setTimeout","getParameter","MAX_TEXTURE_SIZE","maxWidth","width","height","fillStyle","fillRect","getImageData","data","onmousewheel","undefined","FULLSCREEN_EVT_MAP","exitFullscreen","webkitExitFullscreen","mozCancelFullScreen","msExitFullscreen","validExits","keys","filter","exit","length","toggleClass","element","className","active","classList","toggle","contains","add","remove","addClasses","split","forEach","removeClasses","hasParent","el","parent","test","parentNode","getClosest","selector","matches","SVGElement","parentElement","getPosition","left","top","offsetLeft","scrollLeft","clientLeft","offsetTop","scrollTop","clientTop","offsetParent","isFullscreenEnabled","elt","fullscreenElement","webkitFullscreenElement","requestFullscreen","webkitRequestFullscreen","call","getStyle","prop","getComputedStyle","normalizeWheel","event","PIXEL_STEP","LINE_HEIGHT","PAGE_HEIGHT","spinX","spinY","pixelX","pixelY","detail","wheelDelta","wheelDeltaY","wheelDeltaX","axis","HORIZONTAL_AXIS","deltaY","deltaX","deltaMode","bound","x","min","max","loop","value","result","isInteger","Number","isFinite","floor","isPowerOfTwo","log","sum","array","reduce","a","b","distance","p1","p2","y","getShortestArc","from","to","tCandidates","candidate","newCandidate","abs","Infinity","getAngle","position1","position2","acos","latitude","longitude","greatArcDistance","λ1","φ1","λ2","φ2","dasherize","str","replace","s","i","toLowerCase","throttle","func","wait","self","args","timeout","previous","later","Date","now","apply","remaining","arguments","clearTimeout","isPlainObject","obj","getPrototypeOf","proto","toString","deepmerge","target","src","first","merge","Array","isArray","key","clone","isEmpty","each","object","callback","isNil","val","firstNonNull","values","pluginInterop","plugin","entries","p","getAbortError","error","isAbortError","err","logWarn","console","warn","isExtendedPosition","key1","key2","getXMPValue","attr","match","parseInt","isNaN","CSS_POSITIONS","bottom","right","center","parsePosition","tokens","toLocaleLowerCase","slice","xFirst","map","token","reverse","parsed","join","parseFloat","LEFT_MAP","TOP_MAP","cleanPosition","defaultValue","allowCenter","tempPos","parseSpeed","speed","speedStr","trim","speedValue","speedUnit","THREE","degToRad","parseAngle","angle","zeroCenter","halfCircle","unit","createTexture","img","texture","Texture","needsUpdate","minFilter","LinearFilter","generateMipmaps","quaternion","Quaternion","applyEulerInverse","vector","euler","setFromEuler","invert","applyQuaternion","Animation","options","__callbacks","easing","__start","delay","__delayTimeout","__animationFrame","requestAnimationFrame","__run","__resolved","timestamp","progress","duration","current","properties","start","end","onTick","__resolve","cb","then","onFulfilled","onRejected","__cancelled","push","cancel","cancelAnimationFrame","catch","finally","onFinally","Dynamic","fn","loopValue","mode","STOP","speedMult","currentSpeed","setSpeed","goto","position","POSITION","step","roll","INFINITE","stop","setValue","update","elapsed","dstStop","targetSpeed","next","MultiDynamic","dynamics","d","positions","steps","rolls","hasUpdates","dynamic","Slider","container","direction","onUpdate","mousedown","mouseover","handleEvent","type","stopPropagation","__onMouseDown","__onMouseEnter","__onMouseLeave","__onTouchStart","__onMouseMove","__onTouchMove","__onMouseUp","__onTouchEnd","evt","__update","changedTouches","moving","boundingClientRect","getBoundingClientRect","cursor","vertical","pos","size","click","VERTICAL","EventEmitter","HORIZONTAL","EquirectangularAdapter","config","resolution","SPHERE_SEGMENTS","SPHERE_HORIZONTAL_SEGMENTS","reject","useXmpData","textureLoader","loadImage","loader","setProgress","xmpPanoData","__loadXMP","panoData","fullWidth","fullHeight","croppedWidth","croppedHeight","croppedX","croppedY","poseHeading","posePitch","poseRoll","__createEquirectangularTexture","onProgress","loadFile","blob","__loadBlobAsString","binary","indexOf","substring","includes","reader","FileReader","onload","onerror","readAsText","ratio","resizedPanoData","buffer","drawImage","geometry","SphereGeometry","material","MeshBasicMaterial","Mesh","dispose","transparent","AbstractComponent","children","visible","appendChild","removeChild","childIdx","splice","child","refreshUi","every","uiRefresh","isVisible","hide","show","style","display","AbstractButton","navbar","collapsable","tabbable","enabled","supported","collapsed","offsetWidth","icon","__setIcon","lang","title","tabIndex","onClick","checkSupported","supportedOrObject","isSupported","initial","promise","toggleActive","iconActive","refresh","disable","enable","collapse","uncollapse","innerHTML","querySelector","groupId","AutorotateButton","on","off","toggleAutorotate","play","playActive","CustomButton","random","substr","content","NavbarCaption","caption","contentVisible","contentWidth","setCaption","html","__refreshButton","availableWidth","getButton","DescriptionButton","MODE_NOTIF","MODE_PANEL","closed","__close","captionHidden","hasDescription","description","__open","notification","panel","info","DownloadButton","adapter","downloadUrl","link","href","download","pop","FullscreenButton","toggleFullscreen","fullscreenIn","fullscreenOut","MenuButton","__hideMenu","__showMenu","MENU_TEMPLATE","BUTTON_DATA","noMargin","clickHandler","li","buttonId","dataset","menuIcon","buttons","dataKey","menu","button","PressHandler","time","down","getTime","up","getOrientedArrow","arrow","AbstractMoveButton","move","handler","__stopAll","MoveDownButton","MoveLeftButton","MoveRightButton","MoveUpButton","AbstractZoomButton","zoom","ZoomInButton","zoomIn","ZoomOutButton","zoomOut","ZoomRangeButton","mediaMinWidth","zoomRange","zoomValue","slider","__onSliderUpdate","ready","__moveZoomValue","getZoomLevel","once","level","AbstractPlugin","init","DEFAULTS","plugins","loadingImg","loadingTxt","fisheye","minFov","maxFov","defaultZoomLvl","defaultLong","defaultLat","sphereCorrection","moveSpeed","zoomSpeed","autorotateDelay","autorotateSpeed","autorotateLat","moveInertia","mousewheel","mousemove","captureCursor","mousewheelCtrlKey","touchmoveTwoFingers","requestHeaders","canvasBackground","withCredentials","autorotate","fullscreen","twoFingers","ctrlZoom","loadError","keyboard","READONLY_OPTIONS","DEPRECATED_OPTIONS","zoomButtonIncrement","mousewheelSpeed","sphereCorrectionReorder","CONFIG_PARSERS","getConfig","tempConfig","hasOwnProperty","AVAILABLE_BUTTONS","AVAILABLE_GROUPS","registerButton","defaultPosition","unshift","Navbar","setButtons","item","cleanedButtons","__cleanButtons","buttonCtor","warnNotFound","totalWidth","visibleButtons","collapsableButtons","Loader","clientWidth","tickness","lastChild","inner","round","maxHeight","clearRect","lineWidth","strokeStyle","beginPath","arc","stroke","trigger","Notification","contentId","Overlay","dissmisable","image","text","subtext","preventDefault","PANEL_MIN_WIDTH","Panel","mouseX","mouseY","keyHandler","resizer","closeBtn","wasVisible","focus","__startResize","__resize","touches","clientX","clientY","AbstractService","vector2","Vector2","vector3","Vector3","eulerZero","Euler","DataHelper","fovToZoomLevel","fov","temp","zoomLevelToFov","vFovToHFov","vFov","radToDeg","atan","tan","aspect","speedToDuration","textureCoordsToSphericalCoords","point","relativeX","relativeY","equals","renderer","rotation","meshContainer","sphericalCoordsToVector3","applyEuler","vector3ToSphericalCoords","sphericalCoordsToTextureCoords","relativeLong","relativeLat","z","phi","theta","atan2","viewerCoordsToVector3","viewerPoint","sphereIntersect","getIntersections","userData","vector3ToViewerCoords","vectorClone","project","camera","sphericalCoordsToViewerCoords","raycaster","setFromCamera","intersectObjects","scene","cleanSphereCorrection","pan","tilt","cleanPanoramaPose","EventsHandler","state","moveThreshold","keyboardEnabled","zooming","startMouseX","startMouseY","mouseHistory","pinchDist","ctrlKeyDown","dblclickData","dblclickTimeout","longtouchTimeout","twofingersTimeout","ctrlZoomTimeout","__onResize","autoSize","__onKeyDown","__onKeyUp","__fullscreenToggled","__onMouseWheel","enableKeyboard","disableKeyboard","overlay","e2","isDefaultPrevented","__startMove","__stopMove","__move","__moveAbsolute","objectsObservers","viewerPos","intersections","dataHelper","emit","observer","CustomEvent","originalEvent","intersection","find","__click","__cancelLongTouch","__cancelTwoFingersOverlay","__startMoveZoom","__stopMoveZoom","gestureIcon","__moveZoom","mousewheelIcon","delta","force","startKeyboardControl","stopKeyboardControl","stopAutorotate","stopAnimation","__logMouseMove","__stopMoveInertia","norm","animationPromise","longtouch","boundingRect","rightclick","viewerX","viewerY","sphereIntersection","psvSphere","sphericalCoords","objects","o","textureCoords","textureX","textureY","NaN","hFov","currentPosition","rotate","containerRect","Renderer","WebGLRenderer","alpha","antialias","setPixelRatio","domElement","Scene","PerspectiveCamera","Group","Raycaster","canvasContainer","background","setAnimationLoop","__cleanTHREEScene","__onSizeUpdated","__onZoomUpdated","__onPositionUpdated","setSize","updateProjectionMatrix","set","lookAt","copy","multiplyScalar","negate","__renderLoop","render","setPanoramaPose","cleanCorrection","setSphereCorrection","positionProvided","zoomProvided","group","verticalAxis","rotateOnWorldAxis","horizontalAxis","cross","getWorldDirection","normalize","animation","completed","traverse","TextureLoader","FileLoader","setResponseType","setWithCredentials","setRequestHeader","abortLoading","url","lengthComputable","newProgress","total","createElementNS","URL","revokeObjectURL","createObjectURL","preloadPanorama","STATE","NONE","SHOWING","HIDING","Tooltip","__onTransitionEnd","rect","posClass","arrowTop","arrowLeft","__computeTooltipPosition","offset","newPos","propertyName","topBottom","box","TooltipRenderer","testTooltip","tooltip","Cache","Viewer","autorotateEnabled","loadingPromise","startTimeout","getElementById","eventsHandler","__updateSpeeds","__resizeRefresh","resize","opts","setPanorama","startAutorotate","reason","getPlugin","pluginId","pluginCtor","getSize","isAutorotateEnabled","clientHeight","path","transitionAnimation","showLoader","hideError","done","showError","setOptions","setOption","option","errorIcon","change","animate","animProperties","tOffset","dZoom","dim","enterFullscreen","observeObjects","userDataKey"],"mappings":";;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;EACA,SAASA,QAAT,CAAkBC,OAAlB,EAA2B;EACzB,OAAKA,OAAL,GAAeA,OAAf,CADyB;;EAIzB,MAAI,uBAAuBC,KAA3B,EAAkC;EAChCA,IAAAA,KAAK,CAACC,iBAAN,CAAwB,IAAxB,EAA8BH,QAA9B;EACD,GAFD,MAGK;EACH,SAAKI,KAAL,GAAc,IAAIF,KAAJ,EAAD,CAAcE,KAA3B;EACD;EACF;;EAEDJ,QAAQ,CAACK,SAAT,GAAqBC,MAAM,CAACC,MAAP,CAAcL,KAAK,CAACG,SAApB,CAArB;EACAL,QAAQ,CAACK,SAAT,CAAmBG,IAAnB,GAA0B,UAA1B;EACAR,QAAQ,CAACK,SAAT,CAAmBI,WAAnB,GAAiCT,QAAjC;;EClBA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;MACaU,eAAb;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EACA;EACA;EACA;EACA;EACEC,EAAAA,UAAU,EAAU,YAPA;;EAQpB;EACF;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,aAAa,EAAO,eAfA;;EAgBpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,aAAa,EAAO,eAtBA;;EAuBpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,KAAK,EAAe,OA7BA;;EA8BpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,WAAW,EAAS,aApCA;;EAqCpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,cAAc,EAAM,gBA3CA;;EA4CpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,UAlDA;;EAmDpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,kBAAkB,EAAE,oBAzDA;;EA0DpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,iBAAiB,EAAG,mBAhEA;;EAiEpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cAvEA;;EAwEpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAQ,cA9EA;;EA+EpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,SAAS,EAAW,WArFA;;EAsFpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,aAAa,EAAO,eA5FA;;EA6FpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,UAAU,EAAU,YAnGA;;EAoGpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,eAAe,EAAK,iBA1GA;;EA2GpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,gBAAgB,EAAI,kBAjHA;;EAkHpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,KAAK,EAAe,OAvHA;;EAwHpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,MAAM,EAAc,QA7HA;;EA8HpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,iB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mB,gBAAV,CAA2B+J,WAA3B,CAAP;EACD,KAFD;EAGD;EAED;EACF;EACA;EACA;EA14BA;;EAAA,SA24BEvW,SA34BF,GA24BE,qBAAY;EACV,SAAK8N,cAAL;EACA,SAAKC,aAAL;EAEA,SAAKnI,OAAL,CAAanrB,MAAM,CAACuB,QAApB;EACD;EAED;EACF;EACA;EACA;EAr5BA;;EAAA,SAs5BEw4B,cAt5BF,GAs5BE,0BAAiB;EACf,SAAK9gB,QAAL,CAAc4M,IAAd,CAAmB3N,QAAnB,CAA4B,KAAKsD,MAAL,CAAYmM,SAAZ,GAAwB,EAApD;EACA,SAAK1O,QAAL,CAAcb,QAAd,CAAuBF,QAAvB,CAAgC7D,KAAK,CAAC/Q,IAAN,CAAWgR,QAAX,CAAoB,KAAKkH,MAAL,CAAYkM,SAAZ,GAAwB,EAA5C,CAAhC;EACD,GAz5BH;;EAAA;EAAA,EAA4BrM,mBAA5B;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/autorotate-keypoints.js b/dist/plugins/autorotate-keypoints.js index 6a0772f3d..17b20fb3d 100644 --- a/dist/plugins/autorotate-keypoints.js +++ b/dist/plugins/autorotate-keypoints.js @@ -1,14 +1,14 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('photo-sphere-viewer')) : - typeof define === 'function' && define.amd ? define(['exports', 'photo-sphere-viewer'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.PhotoSphereViewer = global.PhotoSphereViewer || {}, global.PhotoSphereViewer.AutorotateKeypointsPlugin = {}), global.PhotoSphereViewer)); -})(this, (function (exports, photoSphereViewer) { '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.AutorotateKeypointsPlugin = {}), global.THREE, global.PhotoSphereViewer)); +})(this, (function (exports, THREE, photoSphereViewer) { 'use strict'; function _extends() { _extends = Object.assign || function (target) { @@ -45,18 +45,22 @@ } /** - * @typedef {PSV.ExtendedPosition|string|Object} PSV.plugins.AutorotateKeypointsPlugin.Keypoints - * @summary Definition of keypoints for automatic rotation, can be a position object, a marker id or an object with the following properties - * @property {string} [markerId] + * @typedef {Object} PSV.plugins.AutorotateKeypointsPlugin.KeypointObject * @property {PSV.ExtendedPosition} [position] + * @property {string} [markerId] - use the position and tooltip of a marker + * @property {number} [pause=0] - pause the animation when reaching this point, will display the tooltip if available * @property {string|{content: string, position: string}} [tooltip] - * @property {number} [pause=0] + */ + + /** + * @typedef {PSV.ExtendedPosition|string|PSV.plugins.AutorotateKeypointsPlugin.KeypointObject} PSV.plugins.AutorotateKeypointsPlugin.Keypoint + * @summary Definition of keypoints for automatic rotation, can be a position object, a marker id or an keypoint object */ /** * @typedef {Object} PSV.plugins.AutorotateKeypointsPlugin.Options * @property {boolean} [startFromClosest=true] - start from the closest keypoint instead of the first keypoint - * @property {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints + * @property {PSV.plugins.AutorotateKeypointsPlugin.Keypoint[]} keypoints */ var NUM_STEPS = 16; @@ -86,8 +90,8 @@ * @member {Object} * @property {number} idx - current index in keypoints * @property {number[][]} curve - curve between idx and idx + 1 - * @property {number[]} startPt - start point of the current step - * @property {number[]} endPt - end point of the current step + * @property {number[]} startStep - start point of the current step + * @property {number[]} endStep - end point of the current step * @property {number} startTime - start time of the current step * @property {number} stepDuration - expected duration of the step * @property {number} remainingPause - time remaining for the pause @@ -106,7 +110,7 @@ startFromClosest: true }, options); /** - * @type {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints + * @type {PSV.plugins.AutorotateKeypointsPlugin.Keypoint[]} keypoints */ _this.keypoints = null; @@ -165,7 +169,7 @@ } /** * @summary Changes the keypoints - * @param {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints + * @param {PSV.plugins.AutorotateKeypointsPlugin.Keypoint[]} keypoints */ ; @@ -192,7 +196,7 @@ if (pt.markerId) { if (!_this2.markers) { - throw new photoSphereViewer.PSVError("Keypoint #" + i + " references a marker but markers plugin is not loaded"); + throw new photoSphereViewer.PSVError("Keypoint #" + i + " references a marker but the markers plugin is not loaded"); } var marker = _this2.markers.getMarker(pt.markerId); @@ -234,8 +238,8 @@ this.state = { idx: -1, curve: [], - startPt: null, - endPt: null, + startStep: null, + endStep: null, startTime: null, stepDuration: null, remainingPause: null, @@ -264,7 +268,7 @@ if (this.psv.isAutorotateEnabled()) { // initialisation if (!this.state.startTime) { - this.state.endPt = serializePt(this.psv.getPosition()); + this.state.endStep = serializePt(this.psv.getPosition()); this.__nextStep(); @@ -335,7 +339,7 @@ _proto.__nextPoint = function __nextPoint() { // get the 4 points necessary to compute the current movement - // one point before and two points after the current + // the two points of the current segments and one point before and after var workPoints = []; if (this.state.idx === -1) { @@ -349,7 +353,7 @@ } // apply offsets to avoid crossing the origin - var workPoints2 = [workPoints[0].slice(0)]; + var workVectors = [new THREE.Vector2(workPoints[0][0], workPoints[0][1])]; var k = 0; for (var _i = 1; _i <= 3; _i++) { @@ -365,18 +369,19 @@ if (k !== 0 && _i === 1) { // do not modify first point, apply the reverse offset the the previous point instead - workPoints2[0][0] -= k * 2 * Math.PI; + workVectors[0].x -= k * 2 * Math.PI; k = 0; } - workPoints2.push([workPoints[_i][0] + k * 2 * Math.PI, workPoints[_i][1]]); + workVectors.push(new THREE.Vector2(workPoints[_i][0] + k * 2 * Math.PI, workPoints[_i][1])); } - var curve = this.__getCurvePoints(workPoints2, 0.6, NUM_STEPS); // __debugCurve(this.markers, curve); + var curve = new THREE.SplineCurve(workVectors).getPoints(NUM_STEPS * 3).map(function (p) { + return [p.x, p.y]; + }); // debugCurve(this.markers, curve, NUM_STEPS); // only keep the curve for the current movement - - this.state.curve = curve.slice(NUM_STEPS, NUM_STEPS * 2); + this.state.curve = curve.slice(NUM_STEPS + 1, NUM_STEPS * 2 + 1); if (this.state.idx !== -1) { this.state.remainingPause = this.keypoints[this.state.idx].pause; @@ -400,14 +405,14 @@ this.__nextPoint(); // reset transformation made to the previous point - this.state.endPt[0] = photoSphereViewer.utils.parseAngle(this.state.endPt[0]); + this.state.endStep[0] = photoSphereViewer.utils.parseAngle(this.state.endStep[0]); } // target next point - this.state.startPt = this.state.endPt; - this.state.endPt = this.state.curve.shift(); // compute duration from distance and speed + this.state.startStep = this.state.endStep; + this.state.endStep = this.state.curve.shift(); // compute duration from distance and speed - var distance = photoSphereViewer.utils.greatArcDistance(this.state.startPt, this.state.endPt); + var distance = photoSphereViewer.utils.greatArcDistance(this.state.startStep, this.state.endStep); this.state.stepDuration = distance * 1000 / Math.abs(this.psv.config.autorotateSpeed); if (distance === 0) { @@ -448,68 +453,15 @@ } this.psv.rotate({ - longitude: this.state.startPt[0] + (this.state.endPt[0] - this.state.startPt[0]) * progress, - latitude: this.state.startPt[1] + (this.state.endPt[1] - this.state.startPt[1]) * progress + longitude: this.state.startStep[0] + (this.state.endStep[0] - this.state.startStep[0]) * progress, + latitude: this.state.startStep[1] + (this.state.endStep[1] - this.state.startStep[1]) * progress }); } /** - * @summary Interpolate curvature points using cardinal spline - * {@link https://stackoverflow.com/a/15528789/1207670} - * @param {number[][]} pts - * @param {number} [tension=0.5] - * @param {number} [numOfSegments=16] - * @returns {number[][]} * @private */ ; - _proto.__getCurvePoints = function __getCurvePoints(pts, tension, numOfSegments) { - if (tension === void 0) { - tension = 0.5; - } - - if (numOfSegments === void 0) { - numOfSegments = 16; - } - - var res = []; // The algorithm require a previous and next point to the actual point array. - - var _pts = pts.slice(0); - - _pts.unshift(pts[0]); - - _pts.push(pts[pts.length - 1]); // 1. loop through each point - // 2. loop through each segment - - - for (var i = 1; i < _pts.length - 2; i++) { - // calc tension vectors - var t1x = (_pts[i + 1][0] - _pts[i - 1][0]) * tension; - var t2x = (_pts[i + 2][0] - _pts[i][0]) * tension; - var t1y = (_pts[i + 1][1] - _pts[i - 1][1]) * tension; - var t2y = (_pts[i + 2][1] - _pts[i][1]) * tension; - - for (var t = 1; t <= numOfSegments; t++) { - // calc step - var st = t / numOfSegments; - var st3 = Math.pow(st, 3); - var st2 = Math.pow(st, 2); // calc cardinals - - var c1 = 2 * st3 - 3 * st2 + 1; - var c2 = -2 * st3 + 3 * st2; - var c3 = st3 - 2 * st2 + st; - var c4 = st3 - st2; // calc x and y cords with common control vectors - - var x = c1 * _pts[i][0] + c2 * _pts[i + 1][0] + c3 * t1x + c4 * t2x; - var y = c1 * _pts[i][1] + c2 * _pts[i + 1][1] + c3 * t1y + c4 * t2y; // store points in array - - res.push([x, y]); - } - } - - return res; - }; - _proto.__findMinIndex = function __findMinIndex(array, mapper) { var idx = 0; var current = Number.MAX_VALUE; diff --git a/dist/plugins/autorotate-keypoints.js.map b/dist/plugins/autorotate-keypoints.js.map index eee5663c5..490b26a06 100644 --- a/dist/plugins/autorotate-keypoints.js.map +++ b/dist/plugins/autorotate-keypoints.js.map @@ -1 +1 @@ -{"version":3,"file":"autorotate-keypoints.js","sources":["../../src/plugins/autorotate-keypoints/index.js"],"sourcesContent":["import { AbstractPlugin, CONSTANTS, PSVError, utils } from '../..';\n\n\n/**\n * @typedef {PSV.ExtendedPosition|string|Object} PSV.plugins.AutorotateKeypointsPlugin.Keypoints\n * @summary Definition of keypoints for automatic rotation, can be a position object, a marker id or an object with the following properties\n * @property {string} [markerId]\n * @property {PSV.ExtendedPosition} [position]\n * @property {string|{content: string, position: string}} [tooltip]\n * @property {number} [pause=0]\n */\n\n/**\n * @typedef {Object} PSV.plugins.AutorotateKeypointsPlugin.Options\n * @property {boolean} [startFromClosest=true] - start from the closest keypoint instead of the first keypoint\n * @property {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints\n */\n\n\nconst NUM_STEPS = 16;\n\nfunction serializePt(position) {\n return [position.longitude, position.latitude];\n}\n\n\n/**\n * @summary Replaces the standard autorotate animation by a smooth transition between multiple points\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class AutorotateKeypointsPlugin extends AbstractPlugin {\n\n static id = 'autorotate-keypoints';\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.AutorotateKeypointsPlugin.Options} [options]\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {Object}\n * @property {number} idx - current index in keypoints\n * @property {number[][]} curve - curve between idx and idx + 1\n * @property {number[]} startPt - start point of the current step\n * @property {number[]} endPt - end point of the current step\n * @property {number} startTime - start time of the current step\n * @property {number} stepDuration - expected duration of the step\n * @property {number} remainingPause - time remaining for the pause\n * @property {number} lastTime - previous timestamp in render loop\n * @property {PSV.components.Tooltip} tooltip - currently displayed tooltip\n * @private\n */\n this.state = {};\n\n /**\n * @member {PSV.plugins.AutorotateKeypointsPlugin.Options}\n * @private\n */\n this.config = {\n startFromClosest: true,\n ...options,\n };\n\n /**\n * @type {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints\n */\n this.keypoints = null;\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @private\n */\n this.markers = null;\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n\n if (this.config.keypoints) {\n this.setKeypoints(this.config.keypoints);\n delete this.config.keypoints;\n }\n\n this.psv.on(CONSTANTS.EVENTS.AUTOROTATE, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.AUTOROTATE, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n\n delete this.markers;\n delete this.keypoints;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n if (e.type === CONSTANTS.EVENTS.AUTOROTATE) {\n this.__configure();\n }\n else if (e.type === CONSTANTS.EVENTS.BEFORE_RENDER) {\n this.__beforeRender(e.args[0]);\n }\n }\n\n /**\n * @summary Changes the keypoints\n * @param {PSV.plugins.AutorotateKeypointsPlugin.Keypoints[]} keypoints\n */\n setKeypoints(keypoints) {\n if (keypoints?.length < 2) {\n throw new PSVError('At least two points are required');\n }\n\n this.keypoints = utils.clone(keypoints);\n\n if (this.keypoints) {\n this.keypoints.forEach((pt, i) => {\n if (typeof pt === 'string') {\n pt = { markerId: pt };\n }\n else if (utils.isExtendedPosition(pt)) {\n pt = { position: pt };\n }\n if (pt.markerId) {\n if (!this.markers) {\n throw new PSVError(`Keypoint #${i} references a marker but markers plugin is not loaded`);\n }\n const marker = this.markers.getMarker(pt.markerId);\n pt.position = serializePt(marker.props.position);\n }\n else if (pt.position) {\n pt.position = serializePt(this.psv.dataHelper.cleanPosition(pt.position));\n }\n else {\n throw new PSVError(`Keypoint #${i} is missing marker or position`);\n }\n\n if (typeof pt.tooltip === 'string') {\n pt.tooltip = { content: pt.tooltip };\n }\n\n this.keypoints[i] = pt;\n });\n }\n\n this.__configure();\n }\n\n /**\n * @private\n */\n __configure() {\n if (!this.psv.isAutorotateEnabled() || !this.keypoints) {\n this.__hideTooltip();\n this.state = {};\n return;\n }\n\n // cancel core rotation\n this.psv.dynamics.position.stop();\n\n this.state = {\n idx : -1,\n curve : [],\n startPt : null,\n endPt : null,\n startTime : null,\n stepDuration : null,\n remainingPause: null,\n lastTime : null,\n tooltip : null,\n };\n\n if (this.config.startFromClosest) {\n const currentPosition = serializePt(this.psv.getPosition());\n const index = this.__findMinIndex(this.keypoints, (keypoint) => {\n return utils.greatArcDistance(keypoint.position, currentPosition);\n });\n\n this.keypoints.push(...this.keypoints.splice(0, index));\n }\n }\n\n /**\n * @private\n */\n __beforeRender(timestamp) {\n if (this.psv.isAutorotateEnabled()) {\n // initialisation\n if (!this.state.startTime) {\n this.state.endPt = serializePt(this.psv.getPosition());\n this.__nextStep();\n\n this.state.startTime = timestamp;\n this.state.lastTime = timestamp;\n }\n\n this.__nextFrame(timestamp);\n }\n }\n\n /**\n * @private\n */\n __incrementIdx() {\n this.state.idx++;\n if (this.state.idx === this.keypoints.length) {\n this.state.idx = 0;\n }\n }\n\n /**\n * @private\n */\n __showTooltip() {\n const keypoint = this.keypoints[this.state.idx];\n\n if (keypoint.tooltip) {\n const position = this.psv.dataHelper.vector3ToViewerCoords(this.psv.prop.direction);\n\n this.state.tooltip = this.psv.tooltip.create({\n content : keypoint.tooltip.content,\n position: keypoint.tooltip.position,\n top : position.y,\n left : position.x,\n });\n }\n else if (keypoint.markerId) {\n const marker = this.markers.getMarker(keypoint.markerId);\n marker.showTooltip();\n this.state.tooltip = marker.tooltip;\n }\n }\n\n /**\n * @private\n */\n __hideTooltip() {\n if (this.state.tooltip) {\n const keypoint = this.keypoints[this.state.idx];\n\n if (keypoint.tooltip) {\n this.state.tooltip.hide();\n }\n else if (keypoint.markerId) {\n const marker = this.markers.getMarker(keypoint.markerId);\n marker.hideTooltip();\n }\n\n this.state.tooltip = null;\n }\n }\n\n /**\n * @private\n */\n __nextPoint() {\n // get the 4 points necessary to compute the current movement\n // one point before and two points after the current\n const workPoints = [];\n if (this.state.idx === -1) {\n const currentPosition = serializePt(this.psv.getPosition());\n workPoints.push(\n currentPosition,\n currentPosition,\n this.keypoints[0].position,\n this.keypoints[1].position\n );\n }\n else {\n for (let i = -1; i < 3; i++) {\n const keypoint = this.state.idx + i < 0\n ? this.keypoints[this.keypoints.length - 1]\n : this.keypoints[(this.state.idx + i) % this.keypoints.length];\n workPoints.push(keypoint.position);\n }\n }\n\n // apply offsets to avoid crossing the origin\n const workPoints2 = [workPoints[0].slice(0)];\n\n let k = 0;\n for (let i = 1; i <= 3; i++) {\n const d = workPoints[i - 1][0] - workPoints[i][0];\n if (d > Math.PI) { // crossed the origin left to right\n k += 1;\n }\n else if (d < -Math.PI) { // crossed the origin right to left\n k -= 1;\n }\n if (k !== 0 && i === 1) {\n // do not modify first point, apply the reverse offset the the previous point instead\n workPoints2[0][0] -= k * 2 * Math.PI;\n k = 0;\n }\n workPoints2.push([workPoints[i][0] + k * 2 * Math.PI, workPoints[i][1]]);\n }\n\n const curve = this.__getCurvePoints(workPoints2, 0.6, NUM_STEPS);\n // __debugCurve(this.markers, curve);\n\n // only keep the curve for the current movement\n this.state.curve = curve.slice(NUM_STEPS, NUM_STEPS * 2);\n\n if (this.state.idx !== -1) {\n this.state.remainingPause = this.keypoints[this.state.idx].pause;\n\n if (this.state.remainingPause) {\n this.__showTooltip();\n }\n else {\n this.__incrementIdx();\n }\n }\n else {\n this.__incrementIdx();\n }\n }\n\n /**\n * @private\n */\n __nextStep() {\n if (this.state.curve.length === 0) {\n this.__nextPoint();\n\n // reset transformation made to the previous point\n this.state.endPt[0] = utils.parseAngle(this.state.endPt[0]);\n }\n\n // target next point\n this.state.startPt = this.state.endPt;\n this.state.endPt = this.state.curve.shift();\n\n // compute duration from distance and speed\n const distance = utils.greatArcDistance(this.state.startPt, this.state.endPt);\n this.state.stepDuration = distance * 1000 / Math.abs(this.psv.config.autorotateSpeed);\n\n if (distance === 0) { // edge case\n this.__nextStep();\n }\n }\n\n /**\n * @private\n */\n __nextFrame(timestamp) {\n const ellapsed = timestamp - this.state.lastTime;\n this.state.lastTime = timestamp;\n\n // currently paused\n if (this.state.remainingPause) {\n this.state.remainingPause = Math.max(0, this.state.remainingPause - ellapsed);\n if (this.state.remainingPause > 0) {\n return;\n }\n else {\n this.__hideTooltip();\n this.__incrementIdx();\n this.state.startTime = timestamp;\n }\n }\n\n let progress = (timestamp - this.state.startTime) / this.state.stepDuration;\n if (progress >= 1) {\n this.__nextStep();\n progress = 0;\n this.state.startTime = timestamp;\n }\n\n this.psv.rotate({\n longitude: this.state.startPt[0] + (this.state.endPt[0] - this.state.startPt[0]) * progress,\n latitude : this.state.startPt[1] + (this.state.endPt[1] - this.state.startPt[1]) * progress,\n });\n }\n\n /**\n * @summary Interpolate curvature points using cardinal spline\n * {@link https://stackoverflow.com/a/15528789/1207670}\n * @param {number[][]} pts\n * @param {number} [tension=0.5]\n * @param {number} [numOfSegments=16]\n * @returns {number[][]}\n * @private\n */\n __getCurvePoints(pts, tension = 0.5, numOfSegments = 16) {\n const res = [];\n\n // The algorithm require a previous and next point to the actual point array.\n const _pts = pts.slice(0);\n _pts.unshift(pts[0]);\n _pts.push(pts[pts.length - 1]);\n\n // 1. loop through each point\n // 2. loop through each segment\n for (let i = 1; i < _pts.length - 2; i++) {\n // calc tension vectors\n const t1x = (_pts[i + 1][0] - _pts[i - 1][0]) * tension;\n const t2x = (_pts[i + 2][0] - _pts[i][0]) * tension;\n\n const t1y = (_pts[i + 1][1] - _pts[i - 1][1]) * tension;\n const t2y = (_pts[i + 2][1] - _pts[i][1]) * tension;\n\n for (let t = 1; t <= numOfSegments; t++) {\n // calc step\n const st = t / numOfSegments;\n\n const st3 = Math.pow(st, 3);\n const st2 = Math.pow(st, 2);\n\n // calc cardinals\n const c1 = 2 * st3 - 3 * st2 + 1;\n const c2 = -2 * st3 + 3 * st2;\n const c3 = st3 - 2 * st2 + st;\n const c4 = st3 - st2;\n\n // calc x and y cords with common control vectors\n const x = c1 * _pts[i][0] + c2 * _pts[i + 1][0] + c3 * t1x + c4 * t2x;\n const y = c1 * _pts[i][1] + c2 * _pts[i + 1][1] + c3 * t1y + c4 * t2y;\n\n // store points in array\n res.push([x, y]);\n }\n }\n\n return res;\n }\n\n __findMinIndex(array, mapper) {\n let idx = 0;\n let current = Number.MAX_VALUE;\n\n array.forEach((item, i) => {\n const value = mapper ? mapper(item) : item;\n if (value < current) {\n current = value;\n idx = i;\n }\n });\n\n return idx;\n }\n\n}\n\nlet debugMarkers = [];\n\nfunction __debugCurve(markers, curve) { // eslint-disable-line no-unused-vars\n debugMarkers.forEach((marker) => {\n try {\n markers.removeMarker(marker.id);\n }\n catch (e) {\n // noop\n }\n });\n\n debugMarkers = [\n markers.addMarker({\n id : 'autorotate-path',\n polylineRad: curve,\n svgStyle : {\n stroke : 'white',\n strokeWidth: '2px',\n },\n }),\n ];\n\n curve.forEach((pos, i) => {\n debugMarkers.push(markers.addMarker({\n id : 'autorotate-path-' + i,\n circle : 5,\n longitude: pos[0],\n latitude : pos[1],\n svgStyle : {\n fill: 'black',\n },\n }));\n });\n}\n"],"names":["NUM_STEPS","serializePt","position","longitude","latitude","AutorotateKeypointsPlugin","psv","options","state","config","startFromClosest","keypoints","markers","init","getPlugin","setKeypoints","on","CONSTANTS","EVENTS","AUTOROTATE","BEFORE_RENDER","destroy","off","handleEvent","e","type","__configure","__beforeRender","args","length","PSVError","utils","clone","forEach","pt","i","markerId","isExtendedPosition","marker","getMarker","props","dataHelper","cleanPosition","tooltip","content","isAutorotateEnabled","__hideTooltip","dynamics","stop","idx","curve","startPt","endPt","startTime","stepDuration","remainingPause","lastTime","currentPosition","getPosition","index","__findMinIndex","keypoint","greatArcDistance","push","splice","timestamp","__nextStep","__nextFrame","__incrementIdx","__showTooltip","vector3ToViewerCoords","prop","direction","create","top","y","left","x","showTooltip","hide","hideTooltip","__nextPoint","workPoints","workPoints2","slice","k","d","Math","PI","__getCurvePoints","pause","parseAngle","shift","distance","abs","autorotateSpeed","ellapsed","max","progress","rotate","pts","tension","numOfSegments","res","_pts","unshift","t1x","t2x","t1y","t2y","t","st","st3","pow","st2","c1","c2","c3","c4","array","mapper","current","Number","MAX_VALUE","item","value","AbstractPlugin","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAGA,IAAMA,SAAS,GAAG,EAAlB;;EAEA,SAASC,WAAT,CAAqBC,QAArB,EAA+B;EAC7B,SAAO,CAACA,QAAQ,CAACC,SAAV,EAAqBD,QA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AC2F,IAAD,EAAOzF,CAAP,EAAa;EACzB,UAAM0F,KAAK,GAAGL,MAAM,GAAGA,MAAM,CAACI,IAAD,CAAT,GAAkBA,IAAtC;;EACA,UAAIC,KAAK,GAAGJ,OAAZ,EAAqB;EACnBA,QAAAA,OAAO,GAAGI,KAAV;EACA5E,QAAAA,GAAG,GAAGd,CAAN;EACD;EACF,KAND;EAQA,WAAOc,GAAP;EACD,GA1aH;;EAAA;EAAA,EAA+C6E,gCAA/C;EAAazH,0BAEJ0H,KAAK;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"autorotate-keypoints.js","sources":["../../src/plugins/autorotate-keypoints/index.js"],"sourcesContent":["import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, PSVError, utils } from '../..';\n\n/**\n * @typedef {Object} PSV.plugins.AutorotateKeypointsPlugin.KeypointObject\n * @property {PSV.ExtendedPosition} [position]\n * @property {string} [markerId] - use the position and tooltip of a marker\n * @property {number} [pause=0] - pause the animation when reaching this point, will display the tooltip if available\n * @property {string|{content: string, position: string}} [tooltip]\n */\n\n/**\n * @typedef {PSV.ExtendedPosition|string|PSV.plugins.AutorotateKeypointsPlugin.KeypointObject} PSV.plugins.AutorotateKeypointsPlugin.Keypoint\n * @summary Definition of keypoints for automatic rotation, can be a position object, a marker id or an keypoint object\n */\n\n/**\n * @typedef {Object} PSV.plugins.AutorotateKeypointsPlugin.Options\n * @property {boolean} [startFromClosest=true] - start from the closest keypoint instead of the first keypoint\n * @property {PSV.plugins.AutorotateKeypointsPlugin.Keypoint[]} keypoints\n */\n\n\nconst NUM_STEPS = 16;\n\nfunction serializePt(position) {\n return [position.longitude, position.latitude];\n}\n\n\n/**\n * @summary Replaces the standard autorotate animation by a smooth transition between multiple points\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class AutorotateKeypointsPlugin extends AbstractPlugin {\n\n static id = 'autorotate-keypoints';\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.AutorotateKeypointsPlugin.Options} [options]\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {Object}\n * @property {number} idx - current index in keypoints\n * @property {number[][]} curve - curve between idx and idx + 1\n * @property {number[]} startStep - start point of the current step\n * @property {number[]} endStep - end point of the current step\n * @property {number} startTime - start time of the current step\n * @property {number} stepDuration - expected duration of the step\n * @property {number} remainingPause - time remaining for the pause\n * @property {number} lastTime - previous timestamp in render loop\n * @property {PSV.components.Tooltip} tooltip - currently displayed tooltip\n * @private\n */\n this.state = {};\n\n /**\n * @member {PSV.plugins.AutorotateKeypointsPlugin.Options}\n * @private\n */\n this.config = {\n startFromClosest: true,\n ...options,\n };\n\n /**\n * @type {PSV.plugins.AutorotateKeypointsPlugin.Keypoint[]} keypoints\n */\n this.keypoints = null;\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @private\n */\n this.markers = null;\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n\n if (this.config.keypoints) {\n this.setKeypoints(this.config.keypoints);\n delete this.config.keypoints;\n }\n\n this.psv.on(CONSTANTS.EVENTS.AUTOROTATE, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.AUTOROTATE, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n\n delete this.markers;\n delete this.keypoints;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n if (e.type === CONSTANTS.EVENTS.AUTOROTATE) {\n this.__configure();\n }\n else if (e.type === CONSTANTS.EVENTS.BEFORE_RENDER) {\n this.__beforeRender(e.args[0]);\n }\n }\n\n /**\n * @summary Changes the keypoints\n * @param {PSV.plugins.AutorotateKeypointsPlugin.Keypoint[]} keypoints\n */\n setKeypoints(keypoints) {\n if (keypoints?.length < 2) {\n throw new PSVError('At least two points are required');\n }\n\n this.keypoints = utils.clone(keypoints);\n\n if (this.keypoints) {\n this.keypoints.forEach((pt, i) => {\n if (typeof pt === 'string') {\n pt = { markerId: pt };\n }\n else if (utils.isExtendedPosition(pt)) {\n pt = { position: pt };\n }\n if (pt.markerId) {\n if (!this.markers) {\n throw new PSVError(`Keypoint #${i} references a marker but the markers plugin is not loaded`);\n }\n const marker = this.markers.getMarker(pt.markerId);\n pt.position = serializePt(marker.props.position);\n }\n else if (pt.position) {\n pt.position = serializePt(this.psv.dataHelper.cleanPosition(pt.position));\n }\n else {\n throw new PSVError(`Keypoint #${i} is missing marker or position`);\n }\n\n if (typeof pt.tooltip === 'string') {\n pt.tooltip = { content: pt.tooltip };\n }\n\n this.keypoints[i] = pt;\n });\n }\n\n this.__configure();\n }\n\n /**\n * @private\n */\n __configure() {\n if (!this.psv.isAutorotateEnabled() || !this.keypoints) {\n this.__hideTooltip();\n this.state = {};\n return;\n }\n\n // cancel core rotation\n this.psv.dynamics.position.stop();\n\n this.state = {\n idx : -1,\n curve : [],\n startStep : null,\n endStep : null,\n startTime : null,\n stepDuration : null,\n remainingPause: null,\n lastTime : null,\n tooltip : null,\n };\n\n if (this.config.startFromClosest) {\n const currentPosition = serializePt(this.psv.getPosition());\n const index = this.__findMinIndex(this.keypoints, (keypoint) => {\n return utils.greatArcDistance(keypoint.position, currentPosition);\n });\n\n this.keypoints.push(...this.keypoints.splice(0, index));\n }\n }\n\n /**\n * @private\n */\n __beforeRender(timestamp) {\n if (this.psv.isAutorotateEnabled()) {\n // initialisation\n if (!this.state.startTime) {\n this.state.endStep = serializePt(this.psv.getPosition());\n this.__nextStep();\n\n this.state.startTime = timestamp;\n this.state.lastTime = timestamp;\n }\n\n this.__nextFrame(timestamp);\n }\n }\n\n /**\n * @private\n */\n __incrementIdx() {\n this.state.idx++;\n if (this.state.idx === this.keypoints.length) {\n this.state.idx = 0;\n }\n }\n\n /**\n * @private\n */\n __showTooltip() {\n const keypoint = this.keypoints[this.state.idx];\n\n if (keypoint.tooltip) {\n const position = this.psv.dataHelper.vector3ToViewerCoords(this.psv.prop.direction);\n\n this.state.tooltip = this.psv.tooltip.create({\n content : keypoint.tooltip.content,\n position: keypoint.tooltip.position,\n top : position.y,\n left : position.x,\n });\n }\n else if (keypoint.markerId) {\n const marker = this.markers.getMarker(keypoint.markerId);\n marker.showTooltip();\n this.state.tooltip = marker.tooltip;\n }\n }\n\n /**\n * @private\n */\n __hideTooltip() {\n if (this.state.tooltip) {\n const keypoint = this.keypoints[this.state.idx];\n\n if (keypoint.tooltip) {\n this.state.tooltip.hide();\n }\n else if (keypoint.markerId) {\n const marker = this.markers.getMarker(keypoint.markerId);\n marker.hideTooltip();\n }\n\n this.state.tooltip = null;\n }\n }\n\n /**\n * @private\n */\n __nextPoint() {\n // get the 4 points necessary to compute the current movement\n // the two points of the current segments and one point before and after\n const workPoints = [];\n if (this.state.idx === -1) {\n const currentPosition = serializePt(this.psv.getPosition());\n workPoints.push(\n currentPosition,\n currentPosition,\n this.keypoints[0].position,\n this.keypoints[1].position\n );\n }\n else {\n for (let i = -1; i < 3; i++) {\n const keypoint = this.state.idx + i < 0\n ? this.keypoints[this.keypoints.length - 1]\n : this.keypoints[(this.state.idx + i) % this.keypoints.length];\n workPoints.push(keypoint.position);\n }\n }\n\n // apply offsets to avoid crossing the origin\n const workVectors = [new THREE.Vector2(workPoints[0][0], workPoints[0][1])];\n\n let k = 0;\n for (let i = 1; i <= 3; i++) {\n const d = workPoints[i - 1][0] - workPoints[i][0];\n if (d > Math.PI) { // crossed the origin left to right\n k += 1;\n }\n else if (d < -Math.PI) { // crossed the origin right to left\n k -= 1;\n }\n if (k !== 0 && i === 1) {\n // do not modify first point, apply the reverse offset the the previous point instead\n workVectors[0].x -= k * 2 * Math.PI;\n k = 0;\n }\n workVectors.push(new THREE.Vector2(workPoints[i][0] + k * 2 * Math.PI, workPoints[i][1]));\n }\n\n const curve = new THREE.SplineCurve(workVectors)\n .getPoints(NUM_STEPS * 3)\n .map(p => ([p.x, p.y]));\n\n // debugCurve(this.markers, curve, NUM_STEPS);\n\n // only keep the curve for the current movement\n this.state.curve = curve.slice(NUM_STEPS + 1, NUM_STEPS * 2 + 1);\n\n if (this.state.idx !== -1) {\n this.state.remainingPause = this.keypoints[this.state.idx].pause;\n\n if (this.state.remainingPause) {\n this.__showTooltip();\n }\n else {\n this.__incrementIdx();\n }\n }\n else {\n this.__incrementIdx();\n }\n }\n\n /**\n * @private\n */\n __nextStep() {\n if (this.state.curve.length === 0) {\n this.__nextPoint();\n\n // reset transformation made to the previous point\n this.state.endStep[0] = utils.parseAngle(this.state.endStep[0]);\n }\n\n // target next point\n this.state.startStep = this.state.endStep;\n this.state.endStep = this.state.curve.shift();\n\n // compute duration from distance and speed\n const distance = utils.greatArcDistance(this.state.startStep, this.state.endStep);\n this.state.stepDuration = distance * 1000 / Math.abs(this.psv.config.autorotateSpeed);\n\n if (distance === 0) { // edge case\n this.__nextStep();\n }\n }\n\n /**\n * @private\n */\n __nextFrame(timestamp) {\n const ellapsed = timestamp - this.state.lastTime;\n this.state.lastTime = timestamp;\n\n // currently paused\n if (this.state.remainingPause) {\n this.state.remainingPause = Math.max(0, this.state.remainingPause - ellapsed);\n if (this.state.remainingPause > 0) {\n return;\n }\n else {\n this.__hideTooltip();\n this.__incrementIdx();\n this.state.startTime = timestamp;\n }\n }\n\n let progress = (timestamp - this.state.startTime) / this.state.stepDuration;\n if (progress >= 1) {\n this.__nextStep();\n progress = 0;\n this.state.startTime = timestamp;\n }\n\n this.psv.rotate({\n longitude: this.state.startStep[0] + (this.state.endStep[0] - this.state.startStep[0]) * progress,\n latitude : this.state.startStep[1] + (this.state.endStep[1] - this.state.startStep[1]) * progress,\n });\n }\n\n /**\n * @private\n */\n __findMinIndex(array, mapper) {\n let idx = 0;\n let current = Number.MAX_VALUE;\n\n array.forEach((item, i) => {\n const value = mapper ? mapper(item) : item;\n if (value < current) {\n current = value;\n idx = i;\n }\n });\n\n return idx;\n }\n\n}\n"],"names":["NUM_STEPS","serializePt","position","longitude","latitude","AutorotateKeypointsPlugin","psv","options","state","config","startFromClosest","keypoints","markers","init","getPlugin","setKeypoints","on","CONSTANTS","EVENTS","AUTOROTATE","BEFORE_RENDER","destroy","off","handleEvent","e","type","__configure","__beforeRender","args","length","PSVError","utils","clone","forEach","pt","i","markerId","isExtendedPosition","marker","getMarker","props","dataHelper","cleanPosition","tooltip","content","isAutorotateEnabled","__hideTooltip","dynamics","stop","idx","curve","startStep","endStep","startTime","stepDuration","remainingPause","lastTime","currentPosition","getPosition","index","__findMinIndex","keypoint","greatArcDistance","push","splice","timestamp","__nextStep","__nextFrame","__incrementIdx","__showTooltip","vector3ToViewerCoords","prop","direction","create","top","y","left","x","showTooltip","hide","hideTooltip","__nextPoint","workPoints","workVectors","THREE","Vector2","k","d","Math","PI","SplineCurve","getPoints","map","p","slice","pause","parseAngle","shift","distance","abs","autorotateSpeed","ellapsed","max","progress","rotate","array","mapper","current","Number","MAX_VALUE","item","value","AbstractPlugin","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAGA,IAAMA,SAAS,GAAG,EAAlB;;EAEA,SAASC,WAAT,CAAqBC,QAArB,EAA+B;EAC7B,SAAO,CAACA,QAAQ,CAACC,SAAV,EAAqBD,QAAQ,CAACE,QAA9B,CAAP;EACD;EAGD;EACA;EACA;EACA;EACA;;;MACaC,yBAAb;EAAA;;EAIE;EACF;EACA;EACA;EACE,qCAAYC,GAAZ,EAAiBC,OAAjB,EAA0B;EAAA;;EACxB,uCAAMD,GAAN;EAEA;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EACI,UAAKE,KAAL,GAAa,EAAb;EAEA;EACJ;EACA;EACA;;EACI,UAAKC,MAAL;EACEC,MAAAA,gBAAgB,EAAE;EADpB,OAEKH,OAFL;EAKA;EACJ;EACA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EACA,UAAIC,KAAK,GAAGJ,OAAZ,EAAqB;EACnBA,QAAAA,OAAO,GAAGI,KAAV;EACA9D,QAAAA,GAAG,GAAGd,CAAN;EACD;EACF,KAND;EAQA,WAAOc,GAAP;EACD,GA5XH;;EAAA;EAAA,EAA+C+D,gCAA/C;EAAa3G,0BAEJ4G,KAAK;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/compass.css b/dist/plugins/compass.css index b3fa021ab..7fa74e917 100644 --- a/dist/plugins/compass.css +++ b/dist/plugins/compass.css @@ -1,5 +1,5 @@ /*! - * Photo Sphere Viewer 4.5.3 + * Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) diff --git a/dist/plugins/compass.js b/dist/plugins/compass.js index 2cc8e242c..167341c76 100644 --- a/dist/plugins/compass.js +++ b/dist/plugins/compass.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) diff --git a/dist/plugins/gyroscope.d.ts b/dist/plugins/gyroscope.d.ts index 89d8c0d63..877450ef2 100644 --- a/dist/plugins/gyroscope.d.ts +++ b/dist/plugins/gyroscope.d.ts @@ -15,6 +15,8 @@ declare const EVENTS: { */ declare class GyroscopePlugin extends AbstractPlugin { + static EVENTS: typeof EVENTS; + constructor(psv: Viewer, options: GyroscopePluginOptions); /** diff --git a/dist/plugins/gyroscope.js b/dist/plugins/gyroscope.js index ca951296e..5b2fffec3 100644 --- a/dist/plugins/gyroscope.js +++ b/dist/plugins/gyroscope.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -278,10 +278,6 @@ var GyroscopePlugin = /*#__PURE__*/function (_AbstractPlugin) { _inheritsLoose(GyroscopePlugin, _AbstractPlugin); - /** - * @deprecated use the EVENTS constants of the module - */ - /** * @param {PSV.Viewer} psv * @param {PSV.plugins.GyroscopePlugin.Options} options @@ -468,26 +464,28 @@ if (!this.controls.deviceOrientation) { return; - } // on first run compute the offset depending on the current viewer position and device orientation + } + var position = this.psv.getPosition(); // on first run compute the offset depending on the current viewer position and device orientation if (this.prop.alphaOffset === null) { this.controls.update(); this.controls.object.getWorldDirection(direction); var sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction); - this.prop.alphaOffset = sphericalCoords.longitude - this.psv.getPosition().longitude; + this.prop.alphaOffset = sphericalCoords.longitude - position.longitude; } else { this.controls.alphaOffset = this.prop.alphaOffset; this.controls.update(); this.controls.object.getWorldDirection(direction); - var _sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction); // TODO use dynamic goto for smooth movement + var _sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction); - - this.psv.dynamics.position.setValue({ + var target = { longitude: _sphericalCoords.longitude, latitude: -_sphericalCoords.latitude - }); + }; // having a slow speed on smalls movements allows to absorb the device/hand vibrations + + this.psv.dynamics.position.goto(target, photoSphereViewer.utils.getAngle(position, target) < 0.01 ? 1 : 3); } } /** diff --git a/dist/plugins/gyroscope.js.map b/dist/plugins/gyroscope.js.map index 3646c779f..1fa08609f 100644 --- a/dist/plugins/gyroscope.js.map +++ b/dist/plugins/gyroscope.js.map @@ -1 +1 @@ -{"version":3,"file":"gyroscope.js","sources":["../../src/plugins/gyroscope/constants.js","../../src/plugins/gyroscope/DeviceOrientationControls.js","../../src/plugins/gyroscope/GyroscopeButton.js","../../src/plugins/gyroscope/index.js"],"sourcesContent":["/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.GyroscopePlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event gyroscope-updated\n * @memberof PSV.plugins.GyroscopePlugin\n * @summary Triggered when the gyroscope mode is enabled/disabled\n * @param {boolean} enabled\n */\n GYROSCOPE_UPDATED: 'gyroscope-updated',\n};\n","import {\n Euler,\n MathUtils,\n Quaternion,\n Vector3\n} from 'three';\n\nconst _zee = new Vector3( 0, 0, 1 );\nconst _euler = new Euler();\nconst _q0 = new Quaternion();\nconst _q1 = new Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis\n\n/**\n * Copied from three.js examples before deletion in r134\n * (deleted because of constructors/OS inconsistencies)\n * @private\n */\nclass DeviceOrientationControls {\n\n constructor( object ) {\n\n if ( window.isSecureContext === false ) {\n\n console.error( 'THREE.DeviceOrientationControls: DeviceOrientationEvent is only available in secure contexts (https)' );\n\n }\n\n const scope = this;\n\n const EPS = 0.000001;\n const lastQuaternion = new Quaternion();\n\n this.object = object;\n this.object.rotation.reorder( 'YXZ' );\n\n this.enabled = true;\n\n this.deviceOrientation = {};\n this.screenOrientation = 0;\n\n this.alphaOffset = 0; // radians\n\n const onDeviceOrientationChangeEvent = function ( event ) {\n\n scope.deviceOrientation = event;\n\n };\n\n const onScreenOrientationChangeEvent = function () {\n\n scope.screenOrientation = window.orientation || 0;\n\n };\n\n // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''\n\n const setObjectQuaternion = function ( quaternion, alpha, beta, gamma, orient ) {\n\n _euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us\n\n quaternion.setFromEuler( _euler ); // orient the device\n\n quaternion.multiply( _q1 ); // camera looks out the back of the device, not the top\n\n quaternion.multiply( _q0.setFromAxisAngle( _zee, - orient ) ); // adjust for screen orientation\n\n };\n\n this.connect = function () {\n\n onScreenOrientationChangeEvent(); // run once on load\n\n // iOS 13+\n\n if ( window.DeviceOrientationEvent !== undefined && typeof window.DeviceOrientationEvent.requestPermission === 'function' ) {\n\n window.DeviceOrientationEvent.requestPermission().then( function ( response ) {\n\n if ( response == 'granted' ) {\n\n window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );\n window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );\n\n }\n\n } ).catch( function ( error ) {\n\n console.error( 'THREE.DeviceOrientationControls: Unable to use DeviceOrientation API:', error );\n\n } );\n\n } else {\n\n window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );\n window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );\n\n }\n\n scope.enabled = true;\n\n };\n\n this.disconnect = function () {\n\n window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent );\n window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );\n\n scope.enabled = false;\n\n };\n\n this.update = function () {\n\n if ( scope.enabled === false ) return;\n\n const device = scope.deviceOrientation;\n\n if ( device ) {\n\n const alpha = device.alpha ? MathUtils.degToRad( device.alpha ) + scope.alphaOffset : 0; // Z\n\n const beta = device.beta ? MathUtils.degToRad( device.beta ) : 0; // X'\n\n const gamma = device.gamma ? MathUtils.degToRad( device.gamma ) : 0; // Y''\n\n const orient = scope.screenOrientation ? MathUtils.degToRad( scope.screenOrientation ) : 0; // O\n\n setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );\n\n if ( 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {\n\n lastQuaternion.copy( scope.object.quaternion );\n\n }\n\n }\n\n };\n\n this.dispose = function () {\n\n scope.disconnect();\n\n };\n\n this.connect();\n\n }\n\n}\n\nexport { DeviceOrientationControls };\n","import { AbstractButton } from '../..';\nimport compass from './compass.svg';\nimport { EVENTS } from './constants';\n\n/**\n * @summary Navigation bar gyroscope button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class GyroscopeButton extends AbstractButton {\n\n static id = 'gyroscope';\n static icon = compass;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-gyroscope-button', true);\n\n /**\n * @type {PSV.plugins.GyroscopePlugin}\n * @readonly\n * @private\n */\n this.plugin = this.psv.getPlugin('gyroscope');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.GYROSCOPE_UPDATED, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.GYROSCOPE_UPDATED, this);\n }\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !this.plugin ? false : { initial: false, promise: this.plugin.prop.isSupported };\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (e.type === EVENTS.GYROSCOPE_UPDATED) {\n this.toggleActive(e.args[0]);\n }\n }\n\n /**\n * @override\n * @description Toggles gyroscope control\n */\n onClick() {\n this.plugin.toggle();\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, registerButton, utils } from '../..';\nimport { EVENTS } from './constants';\nimport { DeviceOrientationControls } from './DeviceOrientationControls';\nimport { GyroscopeButton } from './GyroscopeButton';\n\n\n/**\n * @typedef {Object} PSV.plugins.GyroscopePlugin.Options\n * @property {boolean} [touchmove=true] - allows to pan horizontally when the gyroscope is enabled (requires global `mousemove=true`)\n * @property {boolean} [absolutePosition=false] - when true the view will ignore the current direction when enabling gyroscope control\n */\n\n\n// add gyroscope button\nDEFAULTS.lang[GyroscopeButton.id] = 'Gyroscope';\nregisterButton(GyroscopeButton, 'caption:right');\n\n\nexport { EVENTS } from './constants';\n\n\nconst direction = new THREE.Vector3();\n\n\n/**\n * @summary Adds gyroscope controls on mobile devices\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class GyroscopePlugin extends AbstractPlugin {\n\n static id = 'gyroscope';\n\n /**\n * @deprecated use the EVENTS constants of the module\n */\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.GyroscopePlugin.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {Object}\n * @private\n * @property {Promise} isSupported - indicates of the gyroscope API is available\n * @property {number} alphaOffset - current alpha offset for gyroscope controls\n * @property {boolean} enabled\n * @property {boolean} config_moveInertia - original config \"moveInertia\"\n */\n this.prop = {\n isSupported : this.__checkSupport(),\n alphaOffset : 0,\n enabled : false,\n config_moveInertia: true,\n };\n\n /**\n * @member {PSV.plugins.GyroscopePlugin.Options}\n * @private\n */\n this.config = {\n touchmove : true,\n absolutePosition: false,\n ...options,\n };\n\n /**\n * @member {DeviceOrientationControls}\n * @private\n */\n this.controls = null;\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.psv.on(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_ROTATE, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_ROTATE, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n\n this.stop();\n\n delete this.controls;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n switch (e.type) {\n case CONSTANTS.EVENTS.STOP_ALL:\n this.stop();\n break;\n case CONSTANTS.EVENTS.BEFORE_RENDER:\n this.__onBeforeRender();\n break;\n case CONSTANTS.EVENTS.BEFORE_ROTATE:\n this.__onBeforeRotate(e);\n break;\n default:\n break;\n }\n }\n\n /**\n * @summary Checks if the gyroscope is enabled\n * @returns {boolean}\n */\n isEnabled() {\n return this.prop.enabled;\n }\n\n /**\n * @summary Enables the gyroscope navigation if available\n * @returns {Promise}\n * @fires PSV.plugins.GyroscopePlugin.gyroscope-updated\n * @throws {PSV.PSVError} if the gyroscope API is not available/granted\n */\n start() {\n return this.prop.isSupported\n .then((supported) => {\n if (supported) {\n return this.__requestPermission();\n }\n else {\n utils.logWarn('gyroscope not available');\n return Promise.reject();\n }\n })\n .then((granted) => {\n if (granted) {\n return Promise.resolve();\n }\n else {\n utils.logWarn('gyroscope not allowed');\n return Promise.reject();\n }\n })\n .then(() => {\n this.psv.__stopAll();\n\n // disable inertia\n this.prop.config_moveInertia = this.psv.config.moveInertia;\n this.psv.config.moveInertia = false;\n\n // enable gyro controls\n if (!this.controls) {\n this.controls = new DeviceOrientationControls(new THREE.Object3D());\n }\n else {\n this.controls.connect();\n }\n\n // force reset\n this.controls.deviceOrientation = null;\n this.controls.screenOrientation = 0;\n this.controls.alphaOffset = 0;\n\n this.prop.alphaOffset = this.config.absolutePosition ? 0 : null;\n this.prop.enabled = true;\n\n this.trigger(EVENTS.GYROSCOPE_UPDATED, true);\n });\n }\n\n /**\n * @summary Disables the gyroscope navigation\n * @fires PSV.plugins.GyroscopePlugin.gyroscope-updated\n */\n stop() {\n if (this.isEnabled()) {\n this.controls.disconnect();\n\n this.prop.enabled = false;\n this.psv.config.moveInertia = this.prop.config_moveInertia;\n\n this.trigger(EVENTS.GYROSCOPE_UPDATED, false);\n }\n }\n\n /**\n * @summary Enables or disables the gyroscope navigation\n */\n toggle() {\n if (this.isEnabled()) {\n this.stop();\n }\n else {\n this.start();\n }\n }\n\n /**\n * @summary Handles gyro movements\n * @private\n */\n __onBeforeRender() {\n if (!this.isEnabled()) {\n return;\n }\n\n if (!this.controls.deviceOrientation) {\n return;\n }\n\n // on first run compute the offset depending on the current viewer position and device orientation\n if (this.prop.alphaOffset === null) {\n this.controls.update();\n this.controls.object.getWorldDirection(direction);\n\n const sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction);\n this.prop.alphaOffset = sphericalCoords.longitude - this.psv.getPosition().longitude;\n }\n else {\n this.controls.alphaOffset = this.prop.alphaOffset;\n this.controls.update();\n this.controls.object.getWorldDirection(direction);\n\n const sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction);\n // TODO use dynamic goto for smooth movement\n this.psv.dynamics.position.setValue({\n longitude: sphericalCoords.longitude,\n latitude : -sphericalCoords.latitude,\n });\n }\n }\n\n /**\n * @summary Intercepts moves and offsets the alpha angle\n * @param {external:uEvent.Event} e\n * @private\n */\n __onBeforeRotate(e) {\n if (this.isEnabled()) {\n e.preventDefault();\n\n if (this.config.touchmove) {\n this.prop.alphaOffset -= e.args[0].longitude - this.psv.getPosition().longitude;\n }\n }\n }\n\n /**\n * @summary Detects if device orientation is supported\n * @returns {Promise}\n * @private\n */\n __checkSupport() {\n if ('DeviceMotionEvent' in window && typeof DeviceMotionEvent.requestPermission === 'function') {\n return Promise.resolve(true);\n }\n else if ('DeviceOrientationEvent' in window) {\n return new Promise((resolve) => {\n const listener = (e) => {\n resolve(e && e.alpha !== null && !isNaN(e.alpha));\n\n window.removeEventListener('deviceorientation', listener);\n };\n\n window.addEventListener('deviceorientation', listener, false);\n\n // after 2 secs, auto-reject the promise\n setTimeout(listener, 2000);\n });\n }\n else {\n return Promise.resolve(false);\n }\n }\n\n /**\n * @summary Request permission to the motion API\n * @returns {Promise}\n * @private\n */\n __requestPermission() {\n if ('DeviceMotionEvent' in window && typeof DeviceMotionEvent.requestPermission === 'function') {\n return DeviceOrientationEvent.requestPermission()\n .then(response => response === 'granted')\n .catch(() => false);\n }\n else {\n return Promise.resolve(true);\n }\n }\n\n}\n"],"names":["EVENTS","GYROSCOPE_UPDATED","_zee","Vector3","_euler","Euler","_q0","Quaternion","_q1","Math","sqrt","DeviceOrientationControls","object","window","isSecureContext","console","error","scope","EPS","lastQuaternion","rotation","reorder","enabled","deviceOrientation","screenOrientation","alphaOffset","onDeviceOrientationChangeEvent","event","onScreenOrientationChangeEvent","orientation","setObjectQuaternion","quaternion","alpha","beta","gamma","orient","set","setFromEuler","multiply","setFromAxisAngle","connect","DeviceOrientationEvent","undefined","requestPermission","then","response","addEventListener","catch","disconnect","removeEventListener","update","device","MathUtils","degToRad","dot","copy","dispose","GyroscopeButton","navbar","plugin","psv","getPlugin","on","destroy","off","isSupported","initial","promise","prop","handleEvent","e","type","toggleActive","args","onClick","toggle","AbstractButton","id","icon","compass","DEFAULTS","lang","registerButton","direction","THREE","GyroscopePlugin","options","__checkSupport","config_moveInertia","config","touchmove","absolutePosition","controls","init","CONSTANTS","STOP_ALL","BEFORE_ROTATE","BEFORE_RENDER","stop","__onBeforeRender","__onBeforeRotate","isEnabled","start","supported","__requestPermission","utils","logWarn","Promise","reject","granted","resolve","__stopAll","moveInertia","Object3D","trigger","getWorldDirection","sphericalCoords","dataHelper","vector3ToSphericalCoords","longitude","getPosition","dynamics","position","setValue","latitude","preventDefault","DeviceMotionEvent","listener","isNaN","setTimeout","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,iBAAiB,EAAE;EAPC;;ECCtB,IAAMC,IAAI,GAAG,IAAIC,aAAJ,CAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,CAAb;;EACA,IAAMC,MAAM,GAAG,IAAIC,WAAJ,EAAf;;EACA,IAAMC,GAAG,GAAG,IAAIC,gBAAJ,EAAZ;;EACA,IAAMC,GAAG,GAAG,IAAID,gBAAJ,CAAgB,CAAEE,IAAI,CAACC,IAAL,CAAW,GAAX,CAAlB,EAAoC,CAApC,EAAuC,CAAvC,EAA0CD,IAAI,CAACC,IAAL,CAAW,GAAX,CAA1C,CAAZ;;EAEA;EACA;EACA;EACA;EACA;;;MACMC,4BAEJ,mCAAaC,MAAb,EAAsB;EAEpB,MAAKC,MAAM,CAACC,eAAP,KAA2B,KAAhC,EAAwC;EAEtCC,IAAAA,OAAO,CAACC,KAAR,CAAe,sGAAf;EAED;;EAED,MAAMC,KAAK,GAAG,IAAd;EAEA,MAAMC,GAAG,GAAG,QAAZ;EACA,MAAMC,cAAc,GAAG,IAAIZ,gBAAJ,EAAvB;E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,KAJD,MAKK;EACH,aAAO4D,OAAO,CAACG,OAAR,CAAgB,IAAhB,CAAP;EACD;EACF,GAjRH;;EAAA;EAAA,EAAqCoB,gCAArC;EAAa7C,gBAEJR,KAAK;EAFDQ,gBAOJrF,SAASA;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"gyroscope.js","sources":["../../src/plugins/gyroscope/constants.js","../../src/plugins/gyroscope/DeviceOrientationControls.js","../../src/plugins/gyroscope/GyroscopeButton.js","../../src/plugins/gyroscope/index.js"],"sourcesContent":["/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.GyroscopePlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event gyroscope-updated\n * @memberof PSV.plugins.GyroscopePlugin\n * @summary Triggered when the gyroscope mode is enabled/disabled\n * @param {boolean} enabled\n */\n GYROSCOPE_UPDATED: 'gyroscope-updated',\n};\n","import {\n Euler,\n MathUtils,\n Quaternion,\n Vector3\n} from 'three';\n\nconst _zee = new Vector3( 0, 0, 1 );\nconst _euler = new Euler();\nconst _q0 = new Quaternion();\nconst _q1 = new Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis\n\n/**\n * Copied from three.js examples before deletion in r134\n * (deleted because of constructors/OS inconsistencies)\n * @private\n */\nclass DeviceOrientationControls {\n\n constructor( object ) {\n\n if ( window.isSecureContext === false ) {\n\n console.error( 'THREE.DeviceOrientationControls: DeviceOrientationEvent is only available in secure contexts (https)' );\n\n }\n\n const scope = this;\n\n const EPS = 0.000001;\n const lastQuaternion = new Quaternion();\n\n this.object = object;\n this.object.rotation.reorder( 'YXZ' );\n\n this.enabled = true;\n\n this.deviceOrientation = {};\n this.screenOrientation = 0;\n\n this.alphaOffset = 0; // radians\n\n const onDeviceOrientationChangeEvent = function ( event ) {\n\n scope.deviceOrientation = event;\n\n };\n\n const onScreenOrientationChangeEvent = function () {\n\n scope.screenOrientation = window.orientation || 0;\n\n };\n\n // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''\n\n const setObjectQuaternion = function ( quaternion, alpha, beta, gamma, orient ) {\n\n _euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us\n\n quaternion.setFromEuler( _euler ); // orient the device\n\n quaternion.multiply( _q1 ); // camera looks out the back of the device, not the top\n\n quaternion.multiply( _q0.setFromAxisAngle( _zee, - orient ) ); // adjust for screen orientation\n\n };\n\n this.connect = function () {\n\n onScreenOrientationChangeEvent(); // run once on load\n\n // iOS 13+\n\n if ( window.DeviceOrientationEvent !== undefined && typeof window.DeviceOrientationEvent.requestPermission === 'function' ) {\n\n window.DeviceOrientationEvent.requestPermission().then( function ( response ) {\n\n if ( response == 'granted' ) {\n\n window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );\n window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );\n\n }\n\n } ).catch( function ( error ) {\n\n console.error( 'THREE.DeviceOrientationControls: Unable to use DeviceOrientation API:', error );\n\n } );\n\n } else {\n\n window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent );\n window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );\n\n }\n\n scope.enabled = true;\n\n };\n\n this.disconnect = function () {\n\n window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent );\n window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent );\n\n scope.enabled = false;\n\n };\n\n this.update = function () {\n\n if ( scope.enabled === false ) return;\n\n const device = scope.deviceOrientation;\n\n if ( device ) {\n\n const alpha = device.alpha ? MathUtils.degToRad( device.alpha ) + scope.alphaOffset : 0; // Z\n\n const beta = device.beta ? MathUtils.degToRad( device.beta ) : 0; // X'\n\n const gamma = device.gamma ? MathUtils.degToRad( device.gamma ) : 0; // Y''\n\n const orient = scope.screenOrientation ? MathUtils.degToRad( scope.screenOrientation ) : 0; // O\n\n setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );\n\n if ( 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {\n\n lastQuaternion.copy( scope.object.quaternion );\n\n }\n\n }\n\n };\n\n this.dispose = function () {\n\n scope.disconnect();\n\n };\n\n this.connect();\n\n }\n\n}\n\nexport { DeviceOrientationControls };\n","import { AbstractButton } from '../..';\nimport compass from './compass.svg';\nimport { EVENTS } from './constants';\n\n/**\n * @summary Navigation bar gyroscope button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class GyroscopeButton extends AbstractButton {\n\n static id = 'gyroscope';\n static icon = compass;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-gyroscope-button', true);\n\n /**\n * @type {PSV.plugins.GyroscopePlugin}\n * @readonly\n * @private\n */\n this.plugin = this.psv.getPlugin('gyroscope');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.GYROSCOPE_UPDATED, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.GYROSCOPE_UPDATED, this);\n }\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !this.plugin ? false : { initial: false, promise: this.plugin.prop.isSupported };\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (e.type === EVENTS.GYROSCOPE_UPDATED) {\n this.toggleActive(e.args[0]);\n }\n }\n\n /**\n * @override\n * @description Toggles gyroscope control\n */\n onClick() {\n this.plugin.toggle();\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, registerButton, utils } from '../..';\nimport { EVENTS } from './constants';\nimport { DeviceOrientationControls } from './DeviceOrientationControls';\nimport { GyroscopeButton } from './GyroscopeButton';\n\n\n/**\n * @typedef {Object} PSV.plugins.GyroscopePlugin.Options\n * @property {boolean} [touchmove=true] - allows to pan horizontally when the gyroscope is enabled (requires global `mousemove=true`)\n * @property {boolean} [absolutePosition=false] - when true the view will ignore the current direction when enabling gyroscope control\n */\n\n\n// add gyroscope button\nDEFAULTS.lang[GyroscopeButton.id] = 'Gyroscope';\nregisterButton(GyroscopeButton, 'caption:right');\n\n\nexport { EVENTS } from './constants';\n\n\nconst direction = new THREE.Vector3();\n\n\n/**\n * @summary Adds gyroscope controls on mobile devices\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class GyroscopePlugin extends AbstractPlugin {\n\n static id = 'gyroscope';\n\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.GyroscopePlugin.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {Object}\n * @private\n * @property {Promise} isSupported - indicates of the gyroscope API is available\n * @property {number} alphaOffset - current alpha offset for gyroscope controls\n * @property {boolean} enabled\n * @property {boolean} config_moveInertia - original config \"moveInertia\"\n */\n this.prop = {\n isSupported : this.__checkSupport(),\n alphaOffset : 0,\n enabled : false,\n config_moveInertia: true,\n };\n\n /**\n * @member {PSV.plugins.GyroscopePlugin.Options}\n * @private\n */\n this.config = {\n touchmove : true,\n absolutePosition: false,\n ...options,\n };\n\n /**\n * @member {DeviceOrientationControls}\n * @private\n */\n this.controls = null;\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.psv.on(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_ROTATE, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_ROTATE, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n\n this.stop();\n\n delete this.controls;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n switch (e.type) {\n case CONSTANTS.EVENTS.STOP_ALL:\n this.stop();\n break;\n case CONSTANTS.EVENTS.BEFORE_RENDER:\n this.__onBeforeRender();\n break;\n case CONSTANTS.EVENTS.BEFORE_ROTATE:\n this.__onBeforeRotate(e);\n break;\n default:\n break;\n }\n }\n\n /**\n * @summary Checks if the gyroscope is enabled\n * @returns {boolean}\n */\n isEnabled() {\n return this.prop.enabled;\n }\n\n /**\n * @summary Enables the gyroscope navigation if available\n * @returns {Promise}\n * @fires PSV.plugins.GyroscopePlugin.gyroscope-updated\n * @throws {PSV.PSVError} if the gyroscope API is not available/granted\n */\n start() {\n return this.prop.isSupported\n .then((supported) => {\n if (supported) {\n return this.__requestPermission();\n }\n else {\n utils.logWarn('gyroscope not available');\n return Promise.reject();\n }\n })\n .then((granted) => {\n if (granted) {\n return Promise.resolve();\n }\n else {\n utils.logWarn('gyroscope not allowed');\n return Promise.reject();\n }\n })\n .then(() => {\n this.psv.__stopAll();\n\n // disable inertia\n this.prop.config_moveInertia = this.psv.config.moveInertia;\n this.psv.config.moveInertia = false;\n\n // enable gyro controls\n if (!this.controls) {\n this.controls = new DeviceOrientationControls(new THREE.Object3D());\n }\n else {\n this.controls.connect();\n }\n\n // force reset\n this.controls.deviceOrientation = null;\n this.controls.screenOrientation = 0;\n this.controls.alphaOffset = 0;\n\n this.prop.alphaOffset = this.config.absolutePosition ? 0 : null;\n this.prop.enabled = true;\n\n this.trigger(EVENTS.GYROSCOPE_UPDATED, true);\n });\n }\n\n /**\n * @summary Disables the gyroscope navigation\n * @fires PSV.plugins.GyroscopePlugin.gyroscope-updated\n */\n stop() {\n if (this.isEnabled()) {\n this.controls.disconnect();\n\n this.prop.enabled = false;\n this.psv.config.moveInertia = this.prop.config_moveInertia;\n\n this.trigger(EVENTS.GYROSCOPE_UPDATED, false);\n }\n }\n\n /**\n * @summary Enables or disables the gyroscope navigation\n */\n toggle() {\n if (this.isEnabled()) {\n this.stop();\n }\n else {\n this.start();\n }\n }\n\n /**\n * @summary Handles gyro movements\n * @private\n */\n __onBeforeRender() {\n if (!this.isEnabled()) {\n return;\n }\n\n if (!this.controls.deviceOrientation) {\n return;\n }\n\n const position = this.psv.getPosition();\n\n // on first run compute the offset depending on the current viewer position and device orientation\n if (this.prop.alphaOffset === null) {\n this.controls.update();\n this.controls.object.getWorldDirection(direction);\n\n const sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction);\n this.prop.alphaOffset = sphericalCoords.longitude - position.longitude;\n }\n else {\n this.controls.alphaOffset = this.prop.alphaOffset;\n this.controls.update();\n this.controls.object.getWorldDirection(direction);\n\n const sphericalCoords = this.psv.dataHelper.vector3ToSphericalCoords(direction);\n\n const target = {\n longitude: sphericalCoords.longitude,\n latitude : -sphericalCoords.latitude,\n };\n\n // having a slow speed on smalls movements allows to absorb the device/hand vibrations\n this.psv.dynamics.position.goto(target, utils.getAngle(position, target) < 0.01 ? 1 : 3);\n }\n }\n\n /**\n * @summary Intercepts moves and offsets the alpha angle\n * @param {external:uEvent.Event} e\n * @private\n */\n __onBeforeRotate(e) {\n if (this.isEnabled()) {\n e.preventDefault();\n\n if (this.config.touchmove) {\n this.prop.alphaOffset -= e.args[0].longitude - this.psv.getPosition().longitude;\n }\n }\n }\n\n /**\n * @summary Detects if device orientation is supported\n * @returns {Promise}\n * @private\n */\n __checkSupport() {\n if ('DeviceMotionEvent' in window && typeof DeviceMotionEvent.requestPermission === 'function') {\n return Promise.resolve(true);\n }\n else if ('DeviceOrientationEvent' in window) {\n return new Promise((resolve) => {\n const listener = (e) => {\n resolve(e && e.alpha !== null && !isNaN(e.alpha));\n\n window.removeEventListener('deviceorientation', listener);\n };\n\n window.addEventListener('deviceorientation', listener, false);\n\n // after 2 secs, auto-reject the promise\n setTimeout(listener, 2000);\n });\n }\n else {\n return Promise.resolve(false);\n }\n }\n\n /**\n * @summary Request permission to the motion API\n * @returns {Promise}\n * @private\n */\n __requestPermission() {\n if ('DeviceMotionEvent' in window && typeof DeviceMotionEvent.requestPermission === 'function') {\n return DeviceOrientationEvent.requestPermission()\n .then(response => response === 'granted')\n .catch(() => false);\n }\n else {\n return Promise.resolve(true);\n }\n }\n\n}\n"],"names":["EVENTS","GYROSCOPE_UPDATED","_zee","Vector3","_euler","Euler","_q0","Quaternion","_q1","Math","sqrt","DeviceOrientationControls","object","window","isSecureContext","console","error","scope","EPS","lastQuaternion","rotation","reorder","enabled","deviceOrientation","screenOrientation","alphaOffset","onDeviceOrientationChangeEvent","event","onScreenOrientationChangeEvent","orientation","setObjectQuaternion","quaternion","alpha","beta","gamma","orient","set","setFromEuler","multiply","setFromAxisAngle","connect","DeviceOrientationEvent","undefined","requestPermission","then","response","addEventListener","catch","disconnect","removeEventListener","update","device","MathUtils","degToRad","dot","copy","dispose","GyroscopeButton","navbar","plugin","psv","getPlugin","on","destroy","off","isSupported","initial","promise","prop","handleEvent","e","type","toggleActive","args","onClick","toggle","AbstractButton","id","icon","compass","DEFAULTS","lang","registerButton","direction","THREE","GyroscopePlugin","options","__checkSupport","config_moveInertia","config","touchmove","absolutePosition","controls","init","CONSTANTS","STOP_ALL","BEFORE_ROTATE","BEFORE_RENDER","stop","__onBeforeRender","__onBeforeRotate","isEnabled","start","supported","__requestPermission","utils","logWarn","Promise","reject","granted","resolve","__stopAll","moveInertia","Object3D","trigger","position","getPosition","getWorldDirection","sphericalCoords","dataHelper","vector3ToSphericalCoords","longitude","target","latitude","dynamics","goto","getAngle","preventDefault","DeviceMotionEvent","listener","isNaN","setTimeout","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,iBAAiB,EAAE;EAPC;;ECCtB,IAAMC,IAAI,GAAG,IAAIC,aAAJ,CAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,CAAb;;EACA,IAAMC,MAAM,GAAG,IAAIC,WAAJ,EAAf;;EACA,IAAMC,GAAG,GAA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,CAACoC,mBAAP,CAA2B,mBAA3B,EAAgDgF,QAAhD;EACD,SAJD;;EAMApH,QAAAA,MAAM,CAACiC,gBAAP,CAAwB,mBAAxB,EAA6CmF,QAA7C,EAAuD,KAAvD,EAP8B;;EAU9BE,QAAAA,UAAU,CAACF,QAAD,EAAW,IAAX,CAAV;EACD,OAXM,CAAP;EAYD,KAbI,MAcA;EACH,aAAOtB,OAAO,CAACG,OAAR,CAAgB,KAAhB,CAAP;EACD;EACF;EAED;EACF;EACA;EACA;EACA;EAzQA;;EAAA,SA0QEN,mBA1QF,GA0QE,+BAAsB;EACpB,QAAI,uBAAuB3F,MAAvB,IAAiC,OAAOmH,iBAAiB,CAACrF,iBAAzB,KAA+C,UAApF,EAAgG;EAC9F,aAAOF,sBAAsB,CAACE,iBAAvB,GACJC,IADI,CACC,UAAAC,QAAQ;EAAA,eAAIA,QAAQ,KAAK,SAAjB;EAAA,OADT,EAEJE,KAFI,CAEE;EAAA,eAAM,KAAN;EAAA,OAFF,CAAP;EAGD,KAJD,MAKK;EACH,aAAO4D,OAAO,CAACG,OAAR,CAAgB,IAAhB,CAAP;EACD;EACF,GAnRH;;EAAA;EAAA,EAAqCsB,gCAArC;EAAa/C,gBAEJR,KAAK;EAFDQ,gBAIJrF,SAASA;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/markers.css b/dist/plugins/markers.css index 39f007b4d..62db266f7 100644 --- a/dist/plugins/markers.css +++ b/dist/plugins/markers.css @@ -1,5 +1,5 @@ /*! - * Photo Sphere Viewer 4.5.3 + * Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) diff --git a/dist/plugins/markers.d.ts b/dist/plugins/markers.d.ts index 88d2b3f2b..4cbea0591 100644 --- a/dist/plugins/markers.d.ts +++ b/dist/plugins/markers.d.ts @@ -135,6 +135,8 @@ declare const EVENTS: { */ declare class MarkersPlugin extends AbstractPlugin { + static EVENTS: typeof EVENTS; + constructor(psv: Viewer, options: MarkersPluginOptions); /** diff --git a/dist/plugins/markers.js b/dist/plugins/markers.js index ab7e21fac..2351a7783 100644 --- a/dist/plugins/markers.js +++ b/dist/plugins/markers.js @@ -1,12 +1,12 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) */ (function (global, factory) { - 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) : + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('photo-sphere-viewer'), require('uevent')) : + typeof define === 'function' && define.amd ? define(['exports', 'three', 'photo-sphere-viewer', 'uevent'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.PhotoSphereViewer = global.PhotoSphereViewer || {}, global.PhotoSphereViewer.MarkersPlugin = {}), global.THREE, global.PhotoSphereViewer)); })(this, (function (exports, THREE, photoSphereViewer) { 'use strict'; @@ -1322,10 +1322,6 @@ var MarkersPlugin = /*#__PURE__*/function (_AbstractPlugin) { _inheritsLoose(MarkersPlugin, _AbstractPlugin); - /** - * @deprecated use the EVENTS constants of the module - */ - /** * @param {PSV.Viewer} psv * @param {PSV.plugins.MarkersPlugin.Options} [options] diff --git a/dist/plugins/markers.js.map b/dist/plugins/markers.js.map index 48c847172..83385db28 100644 --- a/dist/plugins/markers.js.map +++ b/dist/plugins/markers.js.map @@ -1 +1 @@ -{"version":3,"file":"markers.js","sources":["../../src/plugins/markers/constants.js","../../src/utils/math.js","../../src/PSVError.js","../../src/utils/psv.js","../../src/plugins/markers/utils.js","../../src/plugins/markers/Marker.js","../../src/plugins/markers/MarkersButton.js","../../src/plugins/markers/MarkersListButton.js","../../src/plugins/markers/index.js"],"sourcesContent":["import icon from './pin-list.svg';\n\n/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.MarkersPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event goto-marker-done\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the animation to a marker is done\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n GOTO_MARKER_DONE : 'goto-marker-done',\n /**\n * @event leave-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the user puts the cursor away from a marker\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n LEAVE_MARKER : 'leave-marker',\n /**\n * @event over-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the user puts the cursor hover a marker\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n OVER_MARKER : 'over-marker',\n /**\n * @event filter:render-markers-list\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Used to alter the list of markers displayed on the side-panel\n * @param {PSV.plugins.MarkersPlugin.Marker[]} markers\n * @returns {PSV.plugins.MarkersPlugin.Marker[]}\n */\n RENDER_MARKERS_LIST: 'render-markers-list',\n /**\n * @event select-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the user clicks on a marker. The marker can be retrieved from outside the event handler\n * with {@link PSV.plugins.MarkersPlugin.getCurrentMarker}\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @param {PSV.plugins.MarkersPlugin.SelectMarkerData} data\n */\n SELECT_MARKER : 'select-marker',\n /**\n * @event select-marker-list\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when a marker is selected from the side panel\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n SELECT_MARKER_LIST : 'select-marker-list',\n /**\n * @event unselect-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when a marker was selected and the user clicks elsewhere\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n UNSELECT_MARKER : 'unselect-marker',\n /**\n * @event hide-markers\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the markers are hidden\n */\n HIDE_MARKERS : 'hide-markers',\n /**\n * @event set-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the list of markers changes\n * @param {PSV.plugins.MarkersPlugin.Marker[]} markers\n */\n SET_MARKERS : 'set-markers',\n /**\n * @event show-markers\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the markers are shown\n */\n SHOW_MARKERS : 'show-markers',\n};\n\n/**\n * @summary Namespace for SVG creation\n * @type {string}\n * @constant\n * @private\n */\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @summary Property name added to marker elements\n * @type {string}\n * @constant\n * @private\n */\nexport const MARKER_DATA = 'psvMarker';\n\n/**\n * @summary Panel identifier for marker content\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL_MARKER = 'marker';\n\n/**\n * @summary Panel identifier for markers list\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL_MARKERS_LIST = 'markersList';\n\n/**\n * @summary Markers list template\n * @param {PSV.plugins.MarkersPlugin.Marker[]} markers\n * @param {string} title\n * @param {string} dataKey\n * @returns {string}\n * @constant\n * @private\n */\nexport const MARKERS_LIST_TEMPLATE = (markers, title, dataKey) => `\n
\n

${icon} ${title}

\n
    \n ${markers.map(marker => `\n
  • \n ${marker.type === 'image' ? `` : ''}\n ${marker.getListContent()}\n
  • \n `).join('')}\n
\n
\n`;\n","/**\n * @summary Ensures that a number is in a given interval\n * @memberOf PSV.utils\n * @param {number} x\n * @param {number} min\n * @param {number} max\n * @returns {number}\n */\nexport function bound(x, min, max) {\n return Math.max(min, Math.min(max, x));\n}\n\n/**\n * @summary Checks if a value is an integer\n * @memberOf PSV.utils\n * @param {*} value\n * @returns {boolean}\n */\nexport function isInteger(value) {\n if (Number.isInteger) {\n return Number.isInteger(value);\n }\n return typeof value === 'number' && Number.isFinite(value) && Math.floor(value) === value;\n}\n\n/**\n * @summary Tests if a number is power of two\n * @memberOf PSV.utils\n * @param {number} x\n * @return {boolean}\n */\nexport function isPowerOfTwo(x) {\n return (Math.log(x) / Math.log(2)) % 1 === 0;\n}\n\n/**\n * @summary Computes the sum of an array\n * @memberOf PSV.utils\n * @param {number[]} array\n * @returns {number}\n */\nexport function sum(array) {\n return array.reduce((a, b) => a + b, 0);\n}\n\n/**\n * @summary Computes the distance between two points\n * @memberOf PSV.utils\n * @param {PSV.Point} p1\n * @param {PSV.Point} p2\n * @returns {number}\n */\nexport function distance(p1, p2) {\n return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));\n}\n\n/**\n * @summary Compute the shortest offset between two longitudes\n * @memberOf PSV.utils\n * @param {number} from\n * @param {number} to\n * @returns {number}\n */\nexport function getShortestArc(from, to) {\n const tCandidates = [\n 0, // direct\n Math.PI * 2, // clock-wise cross zero\n -Math.PI * 2, // counter-clock-wise cross zero\n ];\n\n return tCandidates.reduce((value, candidate) => {\n const newCandidate = to - from + candidate;\n return Math.abs(newCandidate) < Math.abs(value) ? newCandidate : value;\n }, Infinity);\n}\n\n/**\n * @summary Computes the angle between the current position and a target position\n * @memberOf PSV.utils\n * @param {PSV.Position} position1\n * @param {PSV.Position} position2\n * @returns {number}\n */\nexport function getAngle(position1, position2) {\n return Math.acos(\n Math.cos(position1.latitude)\n * Math.cos(position2.latitude)\n * Math.cos(position1.longitude - position2.longitude)\n + Math.sin(position1.latitude)\n * Math.sin(position2.latitude)\n );\n}\n\n/**\n * @summary Returns the distance between two points on a sphere of radius one\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @memberOf PSV.utils\n * @param {number[]} p1\n * @param {number[]} p2\n * @returns {number}\n */\nexport function greatArcDistance(p1, p2) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const x = (λ2 - λ1) * Math.cos((φ1 + φ2) / 2);\n const y = (φ2 - φ1);\n return Math.sqrt(x * x + y * y);\n}\n","/**\n * @summary Custom error used in the lib\n * @param {string} message\n * @constructor\n * @memberOf PSV\n */\nfunction PSVError(message) {\n this.message = message;\n\n // Use V8's native method if available, otherwise fallback\n if ('captureStackTrace' in Error) {\n Error.captureStackTrace(this, PSVError);\n }\n else {\n this.stack = (new Error()).stack;\n }\n}\n\nPSVError.prototype = Object.create(Error.prototype);\nPSVError.prototype.name = 'PSVError';\nPSVError.prototype.constructor = PSVError;\n\nexport { PSVError };\n","import * as THREE from 'three';\nimport { PSVError } from '../PSVError';\nimport { bound } from './math';\n\n/**\n * @summary Returns the plugin constructor from the imported object\n * For retrocompatibility with previous default exports\n * @memberOf PSV.utils\n * @package\n */\nexport function pluginInterop(plugin, target) {\n if (plugin) {\n for (const [, p] of [['_', plugin], ...Object.entries(plugin)]) {\n if (p.prototype instanceof target) {\n return p;\n }\n }\n }\n return null;\n}\n\n/**\n * @summary Builds an Error with name 'AbortError'\n * @memberOf PSV.utils\n * @return {Error}\n */\nexport function getAbortError() {\n const error = new Error('Loading was aborted.');\n error.name = 'AbortError';\n return error;\n}\n\n/**\n * @summary Tests if an Error has name 'AbortError'\n * @memberOf PSV.utils\n * @param {Error} err\n * @return {boolean}\n */\nexport function isAbortError(err) {\n return err?.name === 'AbortError';\n}\n\n/**\n * @summary Displays a warning in the console\n * @memberOf PSV.utils\n * @param {string} message\n */\nexport function logWarn(message) {\n console.warn(`PhotoSphereViewer: ${message}`);\n}\n\n/**\n * @summary Checks if an object is a {PSV.ExtendedPosition}, ie has x/y or longitude/latitude\n * @memberOf PSV.utils\n * @param {object} object\n * @returns {boolean}\n */\nexport function isExtendedPosition(object) {\n return [['x', 'y'], ['longitude', 'latitude']].some(([key1, key2]) => {\n return object[key1] !== undefined && object[key2] !== undefined;\n });\n}\n\n/**\n * @summary Returns the value of a given attribute in the panorama metadata\n * @memberOf PSV.utils\n * @param {string} data\n * @param {string} attr\n * @returns (number)\n */\nexport function getXMPValue(data, attr) {\n // XMP data are stored in children\n let result = data.match('(.*)');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n // XMP data are stored in attributes\n result = data.match('GPano:' + attr + '=\"(.*?)\"');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n return null;\n}\n\n/**\n * @readonly\n * @private\n * @type {{top: string, left: string, bottom: string, center: string, right: string}}\n */\nconst CSS_POSITIONS = {\n top : '0%',\n bottom: '100%',\n left : '0%',\n right : '100%',\n center: '50%',\n};\n\n/**\n * @summary Translate CSS values like \"top center\" or \"10% 50%\" as top and left positions\n * @memberOf PSV.utils\n * @description The implementation is as close as possible to the \"background-position\" specification\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/background-position}\n * @param {string|PSV.Point} value\n * @returns {PSV.Point}\n */\nexport function parsePosition(value) {\n if (!value) {\n return { x: 0.5, y: 0.5 };\n }\n\n if (typeof value === 'object') {\n return value;\n }\n\n let tokens = value.toLocaleLowerCase().split(' ').slice(0, 2);\n\n if (tokens.length === 1) {\n if (CSS_POSITIONS[tokens[0]] !== undefined) {\n tokens = [tokens[0], 'center'];\n }\n else {\n tokens = [tokens[0], tokens[0]];\n }\n }\n\n const xFirst = tokens[1] !== 'left' && tokens[1] !== 'right' && tokens[0] !== 'top' && tokens[0] !== 'bottom';\n\n tokens = tokens.map(token => CSS_POSITIONS[token] || token);\n\n if (!xFirst) {\n tokens.reverse();\n }\n\n const parsed = tokens.join(' ').match(/^([0-9.]+)% ([0-9.]+)%$/);\n\n if (parsed) {\n return {\n x: parseFloat(parsed[1]) / 100,\n y: parseFloat(parsed[2]) / 100,\n };\n }\n else {\n return { x: 0.5, y: 0.5 };\n }\n}\n\n/**\n * @readonly\n * @private\n */\nconst LEFT_MAP = { 0: 'left', 0.5: 'center', 1: 'right' };\n/**\n * @readonly\n * @private\n */\nconst TOP_MAP = { 0: 'top', 0.5: 'center', 1: 'bottom' };\n\n/**\n * @summary Parse a CSS-like position into an array of position keywords among top, bottom, left, right and center\n * @memberOf PSV.utils\n * @param {string | string[]} value\n * @param {string} defaultValue\n * @param {boolean} [allowCenter=true]\n * @return {string[]}\n */\nexport function cleanPosition(value, defaultValue, allowCenter = true) {\n if (!value) {\n return defaultValue.split(' ');\n }\n\n if (typeof value === 'string') {\n const tempPos = parsePosition(value);\n\n if (!(tempPos.x in LEFT_MAP) || !(tempPos.y in TOP_MAP)) {\n throw new PSVError(`Unable to parse position \"${value}\"`);\n }\n\n value = [TOP_MAP[tempPos.y], LEFT_MAP[tempPos.x]];\n }\n\n if (!allowCenter && value[0] === 'center' && value[1] === 'center') {\n throw new PSVError('Unable to parse position \"center center\"');\n }\n\n return value;\n}\n\n/**\n * @summary Parses an speed\n * @memberOf PSV.utils\n * @param {string|number} speed - The speed, in radians/degrees/revolutions per second/minute\n * @returns {number} radians per second\n * @throws {PSV.PSVError} when the speed cannot be parsed\n */\nexport function parseSpeed(speed) {\n let parsed;\n\n if (typeof speed === 'string') {\n const speedStr = speed.toString().trim();\n\n // Speed extraction\n let speedValue = parseFloat(speedStr.replace(/^(-?[0-9]+(?:\\.[0-9]*)?).*$/, '$1'));\n const speedUnit = speedStr.replace(/^-?[0-9]+(?:\\.[0-9]*)?(.*)$/, '$1').trim();\n\n // \"per minute\" -> \"per second\"\n if (speedUnit.match(/(pm|per minute)$/)) {\n speedValue /= 60;\n }\n\n // Which unit?\n switch (speedUnit) {\n // Degrees per minute / second\n case 'dpm':\n case 'degrees per minute':\n case 'dps':\n case 'degrees per second':\n parsed = THREE.Math.degToRad(speedValue);\n break;\n\n // Radians per minute / second\n case 'rdpm':\n case 'radians per minute':\n case 'rdps':\n case 'radians per second':\n parsed = speedValue;\n break;\n\n // Revolutions per minute / second\n case 'rpm':\n case 'revolutions per minute':\n case 'rps':\n case 'revolutions per second':\n parsed = speedValue * Math.PI * 2;\n break;\n\n // Unknown unit\n default:\n throw new PSVError('Unknown speed unit \"' + speedUnit + '\"');\n }\n }\n else {\n parsed = speed;\n }\n\n return parsed;\n}\n\n/**\n * @summary Parses an angle value in radians or degrees and returns a normalized value in radians\n * @memberOf PSV.utils\n * @param {string|number} angle - eg: 3.14, 3.14rad, 180deg\n * @param {boolean} [zeroCenter=false] - normalize between -Pi - Pi instead of 0 - 2*Pi\n * @param {boolean} [halfCircle=zeroCenter] - normalize between -Pi/2 - Pi/2 instead of -Pi - Pi\n * @returns {number}\n * @throws {PSV.PSVError} when the angle cannot be parsed\n */\nexport function parseAngle(angle, zeroCenter = false, halfCircle = zeroCenter) {\n let parsed;\n\n if (typeof angle === 'string') {\n const match = angle.toLowerCase().trim().match(/^(-?[0-9]+(?:\\.[0-9]*)?)(.*)$/);\n\n if (!match) {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n const value = parseFloat(match[1]);\n const unit = match[2];\n\n if (unit) {\n switch (unit) {\n case 'deg':\n case 'degs':\n parsed = THREE.Math.degToRad(value);\n break;\n case 'rad':\n case 'rads':\n parsed = value;\n break;\n default:\n throw new PSVError('Unknown angle unit \"' + unit + '\"');\n }\n }\n else {\n parsed = value;\n }\n }\n else if (typeof angle === 'number' && !isNaN(angle)) {\n parsed = angle;\n }\n else {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n parsed = (zeroCenter ? parsed + Math.PI : parsed) % (Math.PI * 2);\n\n if (parsed < 0) {\n parsed += Math.PI * 2;\n }\n\n return zeroCenter ? bound(parsed - Math.PI, -Math.PI / (halfCircle ? 2 : 1), Math.PI / (halfCircle ? 2 : 1)) : parsed;\n}\n\n/**\n * @summary Creates a THREE texture from an image\n * @memberOf PSV.utils\n * @param {HTMLImageElement | HTMLCanvasElement} img\n * @return {external:THREE.Texture}\n */\nexport function createTexture(img) {\n const texture = new THREE.Texture(img);\n texture.needsUpdate = true;\n texture.minFilter = THREE.LinearFilter;\n texture.generateMipmaps = false;\n return texture;\n}\n\nconst quaternion = new THREE.Quaternion();\n\n/**\n * @summary Applies the inverse of Euler angles to a vector\n * @memberOf PSV.utils\n * @param {external:THREE.Vector3} vector\n * @param {external:THREE.Euler} euler\n */\nexport function applyEulerInverse(vector, euler) {\n quaternion.setFromEuler(euler).invert();\n vector.applyQuaternion(quaternion);\n}\n","import { CONSTANTS, utils } from '../..';\n\n/**\n * Returns intermediary point between two points on the sphere\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @param {number[]} p1\n * @param {number[]} p2\n * @param {number} f\n * @returns {number[]}\n * @private\n */\nexport function greatArcIntermediaryPoint(p1, p2, f) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const r = utils.greatArcDistance(p1, p2);\n const a = Math.sin((1 - f) * r) / Math.sin(r);\n const b = Math.sin(f * r) / Math.sin(r);\n const x = a * Math.cos(φ1) * Math.cos(λ1) + b * Math.cos(φ2) * Math.cos(λ2);\n const y = a * Math.cos(φ1) * Math.sin(λ1) + b * Math.cos(φ2) * Math.sin(λ2);\n const z = a * Math.sin(φ1) + b * Math.sin(φ2);\n\n return [\n Math.atan2(y, x),\n Math.atan2(z, Math.sqrt(x * x + y * y)),\n ];\n}\n\n/**\n * @summary Computes the center point of a polygon\n * @todo Get \"visual center\" (https://blog.mapbox.com/a-new-algorithm-for-finding-a-visual-center-of-a-polygon-7c77e6492fbc)\n * @param {number[][]} polygon\n * @returns {number[]}\n * @private\n */\nexport function getPolygonCenter(polygon) {\n // apply offsets to avoid crossing the origin\n const workPoints = [polygon[0]];\n\n let k = 0;\n for (let i = 1; i < polygon.length; i++) {\n const d = polygon[i - 1][0] - polygon[i][0];\n if (d > Math.PI) { // crossed the origin left to right\n k += 1;\n }\n else if (d < -Math.PI) { // crossed the origin right to left\n k -= 1;\n }\n workPoints.push([polygon[i][0] + k * 2 * Math.PI, polygon[i][1]]);\n }\n\n const sum = workPoints.reduce((intermediary, point) => [intermediary[0] + point[0], intermediary[1] + point[1]]);\n return [utils.parseAngle(sum[0] / polygon.length), sum[1] / polygon.length];\n}\n\n/**\n * @summary Computes the middle point of a polyline\n * @param {number[][]} polyline\n * @returns {number[]}\n * @private\n */\nexport function getPolylineCenter(polyline) {\n // compute each segment length + total length\n let length = 0;\n const lengths = [];\n\n for (let i = 0; i < polyline.length - 1; i++) {\n const l = utils.greatArcDistance(polyline[i], polyline[i + 1]) * CONSTANTS.SPHERE_RADIUS;\n\n lengths.push(l);\n length += l;\n }\n\n // iterate until length / 2\n let consumed = 0;\n\n for (let j = 0; j < polyline.length - 1; j++) {\n // once the segment containing the middle point is found, computes the intermediary point\n if (consumed + lengths[j] > length / 2) {\n const r = (length / 2 - consumed) / lengths[j];\n return greatArcIntermediaryPoint(polyline[j], polyline[j + 1], r);\n }\n\n consumed += lengths[j];\n }\n\n // this never happens\n return polyline[Math.round(polyline.length / 2)];\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, PSVError, SYSTEM, utils } from '../..';\nimport { getShortestArc, logWarn } from '../../utils';\nimport { MARKER_DATA, SVG_NS } from './constants';\nimport { getPolygonCenter, getPolylineCenter } from './utils';\n\n/**\n * @summary Types of marker\n * @memberOf PSV.plugins.MarkersPlugin\n * @enum {string}\n * @constant\n * @private\n */\nconst MARKER_TYPES = {\n image : 'image',\n imageLayer : 'imageLayer',\n html : 'html',\n polygonPx : 'polygonPx',\n polygonRad : 'polygonRad',\n polylinePx : 'polylinePx',\n polylineRad: 'polylineRad',\n square : 'square',\n rect : 'rect',\n circle : 'circle',\n ellipse : 'ellipse',\n path : 'path',\n};\n\n/**\n * @typedef {Object} PSV.plugins.MarkersPlugin.Properties\n * @summary Marker properties, see {@link https://photo-sphere-viewer.js.org/plugins/plugin-markers.html#markers-options}\n */\n\n/**\n * @summary Object representing a marker\n * @memberOf PSV.plugins.MarkersPlugin\n */\nexport class Marker {\n\n /**\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @param {PSV.Viewer} psv\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n constructor(properties, psv) {\n if (!properties.id) {\n throw new PSVError('missing marker id');\n }\n\n /**\n * @member {PSV.Viewer}\n * @readonly\n * @protected\n */\n this.psv = psv;\n\n /**\n * @member {string}\n * @readonly\n */\n this.id = properties.id;\n\n /**\n * @member {string}\n * @readonly\n */\n this.type = Marker.getType(properties, false);\n\n /**\n * @member {boolean}\n * @protected\n */\n this.visible = true;\n\n /**\n * @member {HTMLElement|SVGElement|THREE.Object3D}\n * @readonly\n */\n this.$el = null;\n\n /**\n * @summary Original configuration of the marker\n * @member {PSV.plugins.MarkersPlugin.Properties}\n * @readonly\n */\n this.config = {};\n\n /**\n * @summary User data associated to the marker\n * @member {any}\n */\n this.data = undefined;\n\n /**\n * @summary Tooltip instance for this marker\n * @member {PSV.components.Tooltip}\n */\n this.tooltip = null;\n\n /**\n * @summary Computed properties\n * @member {Object}\n * @protected\n * @property {boolean} dynamicSize\n * @property {PSV.Point} anchor\n * @property {PSV.Position} position - position in spherical coordinates\n * @property {PSV.Point} position2D - position in viewer coordinates\n * @property {external:THREE.Vector3[]} positions3D - positions in 3D space\n * @property {number} width\n * @property {number} height\n * @property {*} def\n */\n this.props = {\n dynamicSize: false,\n anchor : null,\n position : null,\n position2D : null,\n positions3D: null,\n width : null,\n height : null,\n def : null,\n };\n\n /**\n * @summary THREE file loader\n * @type {THREE:TextureLoader}\n * @private\n */\n this.loader = null;\n\n if (this.is3d()) {\n this.loader = new THREE.TextureLoader();\n if (this.psv.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders);\n }\n }\n\n // create element\n if (this.isNormal()) {\n this.$el = document.createElement('div');\n }\n else if (this.isPolygon()) {\n this.$el = document.createElementNS(SVG_NS, 'polygon');\n }\n else if (this.isPolyline()) {\n this.$el = document.createElementNS(SVG_NS, 'polyline');\n }\n else if (this.isSvg()) {\n this.$el = document.createElementNS(SVG_NS, this.type);\n }\n\n if (!this.is3d()) {\n this.$el.id = `psv-marker-${this.id}`;\n this.$el[MARKER_DATA] = this;\n }\n\n this.update(properties);\n }\n\n /**\n * @summary Destroys the marker\n */\n destroy() {\n delete this.$el[MARKER_DATA];\n delete this.$el;\n delete this.config;\n delete this.props;\n delete this.psv;\n }\n\n /**\n * @summary Checks if it is a 3D marker (imageLayer)\n * @returns {boolean}\n */\n is3d() {\n return this.type === MARKER_TYPES.imageLayer;\n }\n\n /**\n * @summary Checks if it is a normal marker (image or html)\n * @returns {boolean}\n */\n isNormal() {\n return this.type === MARKER_TYPES.image\n || this.type === MARKER_TYPES.html;\n }\n\n /**\n * @summary Checks if it is a polygon/polyline marker\n * @returns {boolean}\n */\n isPoly() {\n return this.isPolygon()\n || this.isPolyline();\n }\n\n /**\n * @summary Checks if it is a polygon/polyline using pixel coordinates\n * @returns {boolean}\n */\n isPolyPx() {\n return this.type === MARKER_TYPES.polygonPx\n || this.type === MARKER_TYPES.polylinePx;\n }\n\n /**\n * @summary Checks if it is a polygon/polyline using radian coordinates\n * @returns {boolean}\n */\n isPolyRad() {\n return this.type === MARKER_TYPES.polygonRad\n || this.type === MARKER_TYPES.polylineRad;\n }\n\n /**\n * @summary Checks if it is a polygon marker\n * @returns {boolean}\n */\n isPolygon() {\n return this.type === MARKER_TYPES.polygonPx\n || this.type === MARKER_TYPES.polygonRad;\n }\n\n /**\n * @summary Checks if it is a polyline marker\n * @returns {boolean}\n */\n isPolyline() {\n return this.type === MARKER_TYPES.polylinePx\n || this.type === MARKER_TYPES.polylineRad;\n }\n\n /**\n * @summary Checks if it is an SVG marker\n * @returns {boolean}\n */\n isSvg() {\n return this.type === MARKER_TYPES.square\n || this.type === MARKER_TYPES.rect\n || this.type === MARKER_TYPES.circle\n || this.type === MARKER_TYPES.ellipse\n || this.type === MARKER_TYPES.path;\n }\n\n /**\n * @summary Computes marker scale from zoom level\n * @param {number} zoomLevel\n * @param {PSV.Position} position\n * @returns {number}\n */\n getScale(zoomLevel, position) {\n if (!this.config.scale) {\n return 1;\n }\n if (typeof this.config.scale === 'function') {\n return this.config.scale(zoomLevel, position);\n }\n\n let scale = 1;\n if (Array.isArray(this.config.scale.zoom)) {\n const bounds = this.config.scale.zoom;\n scale *= bounds[0] + (bounds[1] - bounds[0]) * CONSTANTS.EASINGS.inQuad(zoomLevel / 100);\n }\n if (Array.isArray(this.config.scale.longitude)) {\n const bounds = this.config.scale.longitude;\n const halfFov = THREE.Math.degToRad(this.psv.prop.hFov) / 2;\n const arc = Math.abs(getShortestArc(this.props.position.longitude, position.longitude));\n scale *= bounds[1] + (bounds[0] - bounds[1]) * CONSTANTS.EASINGS.outQuad(Math.max(0, (halfFov - arc) / halfFov));\n }\n return scale;\n }\n\n /**\n * @summary Returns the markers list content for the marker, it can be either :\n * - the `listContent`\n * - the `tooltip.content`\n * - the `html`\n * - the `id`\n * @returns {*}\n */\n getListContent() {\n if (this.config.listContent) {\n return this.config.listContent;\n }\n else if (this.config.tooltip?.content) {\n return this.config.tooltip.content;\n }\n else if (this.config.html) {\n return this.config.html;\n }\n else {\n return this.id;\n }\n }\n\n /**\n * @summary Display the tooltip of this marker\n * @param {{clientX: number, clientY: number}} [mousePosition]\n */\n showTooltip(mousePosition) {\n if (this.visible && this.config.tooltip?.content && this.props.position2D) {\n const config = {\n content : this.config.tooltip.content,\n position: this.config.tooltip.position,\n data : this,\n };\n\n if (this.isPoly()) {\n const viewerPos = utils.getPosition(this.psv.container);\n\n config.box = { // separate the tooltip from the cursor\n width : this.psv.tooltip.size.arrow * 2,\n height: this.psv.tooltip.size.arrow * 2,\n };\n\n if (mousePosition) {\n config.top = mousePosition.clientY - viewerPos.top - this.psv.tooltip.size.arrow / 2;\n config.left = mousePosition.clientX - viewerPos.left - this.psv.tooltip.size.arrow;\n }\n else {\n config.top = this.props.position2D.y;\n config.left = this.props.position2D.x;\n }\n }\n else {\n config.top = this.props.position2D.y;\n config.left = this.props.position2D.x;\n config.box = {\n width : this.props.width,\n height: this.props.height,\n };\n }\n\n if (this.tooltip) {\n this.tooltip.move(config);\n }\n else {\n this.tooltip = this.psv.tooltip.create(config);\n }\n }\n }\n\n /**\n * @summary Hides the tooltip of this marker\n */\n hideTooltip() {\n if (this.tooltip) {\n this.tooltip.hide();\n this.tooltip = null;\n }\n }\n\n /**\n * @summary Updates the marker with new properties\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n update(properties) {\n const newType = Marker.getType(properties, true);\n\n if (newType !== undefined && newType !== this.type) {\n throw new PSVError('cannot change marker type');\n }\n\n utils.deepmerge(this.config, properties);\n if (typeof this.config.tooltip === 'string') {\n this.config.tooltip = { content: this.config.tooltip };\n }\n\n this.data = this.config.data;\n this.visible = this.config.visible !== false;\n\n if (!this.is3d()) {\n // reset CSS class\n if (this.isNormal()) {\n this.$el.setAttribute('class', 'psv-marker psv-marker--normal');\n }\n else {\n this.$el.setAttribute('class', 'psv-marker psv-marker--svg');\n }\n\n // add CSS classes\n if (this.config.className) {\n utils.addClasses(this.$el, this.config.className);\n }\n\n if (this.config.tooltip) {\n utils.addClasses(this.$el, 'psv-marker--has-tooltip');\n }\n if (this.config.content) {\n utils.addClasses(this.$el, 'psv-marler--has-content');\n }\n\n // apply style\n this.$el.style.opacity = this.config.opacity ?? 1;\n if (this.config.style) {\n utils.deepmerge(this.$el.style, this.config.style);\n }\n }\n\n // parse anchor\n this.props.anchor = utils.parsePosition(this.config.anchor);\n\n // clean scale\n if (this.config.scale) {\n if (typeof this.config.scale === 'number') {\n logWarn('Single value marker scale is deprecated, please use an array of two values.');\n this.config.scale = { zoom: [0, this.config.scale] };\n }\n if (Array.isArray(this.config.scale)) {\n this.config.scale = { zoom: this.config.scale };\n }\n }\n\n if (this.isNormal()) {\n this.__updateNormal();\n }\n else if (this.isPoly()) {\n this.__updatePoly();\n }\n else if (this.isSvg()) {\n this.__updateSvg();\n }\n else if (this.is3d()) {\n this.__update3d();\n }\n }\n\n /**\n * @summary Updates a normal marker\n * @private\n */\n __updateNormal() {\n if (!utils.isExtendedPosition(this.config)) {\n throw new PSVError('missing marker position, latitude/longitude or x/y');\n }\n\n if (this.config.image && (!this.config.width || !this.config.height)) {\n throw new PSVError('missing marker width/height');\n }\n\n if (this.config.width && this.config.height) {\n this.props.dynamicSize = false;\n this.props.width = this.config.width;\n this.props.height = this.config.height;\n this.$el.style.width = this.config.width + 'px';\n this.$el.style.height = this.config.height + 'px';\n }\n else {\n this.props.dynamicSize = true;\n }\n\n if (this.config.image) {\n this.props.def = this.config.image;\n this.$el.style.backgroundImage = `url(${this.config.image})`;\n }\n else if (this.config.html) {\n this.props.def = this.config.html;\n this.$el.innerHTML = this.config.html;\n }\n\n // set anchor\n this.$el.style.transformOrigin = `${this.props.anchor.x * 100}% ${this.props.anchor.y * 100}%`;\n\n // convert texture coordinates to spherical coordinates\n this.props.position = this.psv.dataHelper.cleanPosition(this.config);\n\n // compute x/y/z position\n this.props.positions3D = [this.psv.dataHelper.sphericalCoordsToVector3(this.props.position)];\n }\n\n /**\n * @summary Updates an SVG marker\n * @private\n */\n __updateSvg() {\n if (!utils.isExtendedPosition(this.config)) {\n throw new PSVError('missing marker position, latitude/longitude or x/y');\n }\n\n this.props.dynamicSize = true;\n\n // set content\n switch (this.type) {\n case MARKER_TYPES.square:\n this.props.def = {\n x : 0,\n y : 0,\n width : this.config.square,\n height: this.config.square,\n };\n break;\n\n case MARKER_TYPES.rect:\n if (Array.isArray(this.config.rect)) {\n this.props.def = {\n x : 0,\n y : 0,\n width : this.config.rect[0],\n height: this.config.rect[1],\n };\n }\n else {\n this.props.def = {\n x : 0,\n y : 0,\n width : this.config.rect.width,\n height: this.config.rect.height,\n };\n }\n break;\n\n case MARKER_TYPES.circle:\n this.props.def = {\n cx: this.config.circle,\n cy: this.config.circle,\n r : this.config.circle,\n };\n break;\n\n case MARKER_TYPES.ellipse:\n if (Array.isArray(this.config.ellipse)) {\n this.props.def = {\n cx: this.config.ellipse[0],\n cy: this.config.ellipse[1],\n rx: this.config.ellipse[0],\n ry: this.config.ellipse[1],\n };\n }\n else {\n this.props.def = {\n cx: this.config.ellipse.rx,\n cy: this.config.ellipse.ry,\n rx: this.config.ellipse.rx,\n ry: this.config.ellipse.ry,\n };\n }\n break;\n\n case MARKER_TYPES.path:\n this.props.def = {\n d: this.config.path,\n };\n break;\n\n // no default\n }\n\n utils.each(this.props.def, (value, prop) => {\n this.$el.setAttributeNS(null, prop, value);\n });\n\n // set style\n if (this.config.svgStyle) {\n utils.each(this.config.svgStyle, (value, prop) => {\n this.$el.setAttributeNS(null, utils.dasherize(prop), value);\n });\n }\n else {\n this.$el.setAttributeNS(null, 'fill', 'rgba(0,0,0,0.5)');\n }\n\n // convert texture coordinates to spherical coordinates\n this.props.position = this.psv.dataHelper.cleanPosition(this.config);\n\n // compute x/y/z position\n this.props.positions3D = [this.psv.dataHelper.sphericalCoordsToVector3(this.props.position)];\n }\n\n /**\n * @summary Updates a polygon marker\n * @private\n */\n __updatePoly() {\n this.props.dynamicSize = true;\n\n // set style\n if (this.config.svgStyle) {\n utils.each(this.config.svgStyle, (value, prop) => {\n this.$el.setAttributeNS(null, utils.dasherize(prop), value);\n });\n\n if (this.isPolyline() && !this.config.svgStyle.fill) {\n this.$el.setAttributeNS(null, 'fill', 'none');\n }\n }\n else if (this.isPolygon()) {\n this.$el.setAttributeNS(null, 'fill', 'rgba(0,0,0,0.5)');\n }\n else if (this.isPolyline()) {\n this.$el.setAttributeNS(null, 'fill', 'none');\n this.$el.setAttributeNS(null, 'stroke', 'rgb(0,0,0)');\n }\n\n // fold arrays: [1,2,3,4] => [[1,2],[3,4]]\n const actualPoly = this.config.polygonPx || this.config.polygonRad || this.config.polylinePx || this.config.polylineRad;\n if (!Array.isArray(actualPoly[0])) {\n for (let i = 0; i < actualPoly.length; i++) {\n actualPoly.splice(i, 2, [actualPoly[i], actualPoly[i + 1]]);\n }\n }\n\n // convert texture coordinates to spherical coordinates\n if (this.isPolyPx()) {\n this.props.def = actualPoly.map((coord) => {\n const sphericalCoords = this.psv.dataHelper.textureCoordsToSphericalCoords({ x: coord[0], y: coord[1] });\n return [sphericalCoords.longitude, sphericalCoords.latitude];\n });\n }\n // clean angles\n else {\n this.props.def = actualPoly.map((coord) => {\n return [utils.parseAngle(coord[0]), utils.parseAngle(coord[1], true)];\n });\n }\n\n const centroid = this.isPolygon()\n ? getPolygonCenter(this.props.def)\n : getPolylineCenter(this.props.def);\n\n this.props.position = {\n longitude: centroid[0],\n latitude : centroid[1],\n };\n\n // compute x/y/z positions\n this.props.positions3D = this.props.def.map((coord) => {\n return this.psv.dataHelper.sphericalCoordsToVector3({ longitude: coord[0], latitude : coord[1] });\n });\n }\n\n /**\n * @summary Updates a 3D marker\n * @private\n */\n __update3d() {\n if (!this.config.width || !this.config.height) {\n throw new PSVError('missing marker width/height');\n }\n\n this.props.dynamicSize = false;\n this.props.width = this.config.width;\n this.props.height = this.config.height;\n\n // convert texture coordinates to spherical coordinates\n this.props.position = this.psv.dataHelper.cleanPosition(this.config);\n\n // compute x/y/z position\n this.props.positions3D = [this.psv.dataHelper.sphericalCoordsToVector3(this.props.position)];\n\n switch (this.type) {\n case MARKER_TYPES.imageLayer:\n if (!this.$el) {\n const material = new THREE.MeshBasicMaterial({\n transparent: true,\n opacity : this.config.opacity ?? 1,\n depthTest : false,\n });\n const geometry = new THREE.PlaneGeometry(1, 1);\n const mesh = new THREE.Mesh(geometry, material);\n mesh.userData = { [MARKER_DATA]: this };\n this.$el = new THREE.Group().add(mesh);\n\n // overwrite the visible property to be tied to the Marker instance\n // and do it without context bleed\n Object.defineProperty(this.$el, 'visible', {\n enumerable: true,\n get : function () {\n return this.children[0].userData[MARKER_DATA].visible;\n },\n set : function (visible) {\n this.children[0].userData[MARKER_DATA].visible = visible;\n },\n });\n }\n\n if (this.props.def !== this.config.imageLayer) {\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders(this.config.imageLayer));\n }\n this.$el.children[0].material.map = this.loader.load(this.config.imageLayer, (texture) => {\n texture.anisotropy = 4;\n this.psv.needsUpdate();\n });\n this.props.def = this.config.imageLayer;\n }\n\n this.$el.children[0].position.set(\n this.props.anchor.x - 0.5,\n this.props.anchor.y - 0.5,\n 0\n );\n\n this.$el.position.copy(this.props.positions3D[0]);\n\n switch (this.config.orientation) {\n case 'horizontal':\n this.$el.lookAt(0, this.$el.position.y, 0);\n this.$el.rotateX(this.props.position.latitude < 0 ? -Math.PI / 2 : Math.PI / 2);\n break;\n case 'vertical-left':\n this.$el.lookAt(0, 0, 0);\n this.$el.rotateY(-Math.PI * 0.4);\n break;\n case 'vertical-right':\n this.$el.lookAt(0, 0, 0);\n this.$el.rotateY(Math.PI * 0.4);\n break;\n default:\n this.$el.lookAt(0, 0, 0);\n break;\n }\n\n // 100 is magic number that gives a coherent size at default zoom level\n this.$el.scale.set(this.config.width / 100 * SYSTEM.pixelRatio, this.config.height / 100 * SYSTEM.pixelRatio, 1);\n break;\n\n // no default\n }\n }\n\n /**\n * @summary Determines the type of a marker by the available properties\n * @param {Marker.Properties} properties\n * @param {boolean} [allowNone=false]\n * @returns {string}\n * @throws {PSV.PSVError} when the marker's type cannot be found\n */\n static getType(properties, allowNone = false) {\n const found = [];\n\n utils.each(MARKER_TYPES, (type) => {\n if (properties[type]) {\n found.push(type);\n }\n });\n\n if (found.length === 0 && !allowNone) {\n throw new PSVError(`missing marker content, either ${Object.keys(MARKER_TYPES).join(', ')}`);\n }\n else if (found.length > 1) {\n throw new PSVError(`multiple marker content, either ${Object.keys(MARKER_TYPES).join(', ')}`);\n }\n\n return found[0];\n }\n\n}\n","import { AbstractButton } from '../..';\nimport { EVENTS } from './constants';\nimport pin from './pin.svg';\n\n/**\n * @summary Navigation bar markers button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class MarkersButton extends AbstractButton {\n\n static id = 'markers';\n static icon = pin;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-markers-button', true);\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n */\n this.plugin = this.psv.getPlugin('markers');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.SHOW_MARKERS, this);\n this.plugin.on(EVENTS.HIDE_MARKERS, this);\n\n this.toggleActive(true);\n }\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.SHOW_MARKERS, this);\n this.plugin.off(EVENTS.HIDE_MARKERS, this);\n }\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.SHOW_MARKERS: this.toggleActive(true); break;\n case EVENTS.HIDE_MARKERS: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles markers\n */\n onClick() {\n if (this.plugin.prop.visible) {\n this.plugin.hide();\n }\n else {\n this.plugin.show();\n }\n }\n\n}\n","import { AbstractButton, CONSTANTS } from '../..';\nimport { ID_PANEL_MARKERS_LIST } from './constants';\nimport pinList from './pin-list.svg';\n\n/**\n * @summary Navigation bar markers list button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class MarkersListButton extends AbstractButton {\n\n static id = 'markersList';\n static icon = pinList;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-markers-list-button', true);\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n */\n this.plugin = this.psv.getPlugin('markers');\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.on(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n }\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.off(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case CONSTANTS.EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === ID_PANEL_MARKERS_LIST); break;\n case CONSTANTS.EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles markers list\n */\n onClick() {\n this.plugin.toggleMarkersList();\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport {\n EVENTS,\n ID_PANEL_MARKER,\n ID_PANEL_MARKERS_LIST,\n MARKER_DATA,\n MARKERS_LIST_TEMPLATE,\n SVG_NS\n} from './constants';\nimport { Marker } from './Marker';\nimport { MarkersButton } from './MarkersButton';\nimport { MarkersListButton } from './MarkersListButton';\nimport './style.scss';\n\n\n/**\n * @typedef {Object} PSV.plugins.MarkersPlugin.Options\n * @property {boolean} [clickEventOnMarker=false] If a `click` event is triggered on the viewer additionally to the `select-marker` event.\n * @property {PSV.plugins.MarkersPlugin.Properties[]} [markers]\n */\n\n/**\n * @typedef {Object} PSV.plugins.MarkersPlugin.SelectMarkerData\n * @summary Data of the `select-marker` event\n * @property {boolean} dblclick - if the selection originated from a double click, the simple click is always fired before the double click\n * @property {boolean} rightclick - if the selection originated from a right click\n */\n\n\n// add markers buttons\nDEFAULTS.lang[MarkersButton.id] = 'Markers';\nDEFAULTS.lang[MarkersListButton.id] = 'Markers list';\nregisterButton(MarkersButton, 'caption:left');\nregisterButton(MarkersListButton, 'caption:left');\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Displays various markers on the viewer\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class MarkersPlugin extends AbstractPlugin {\n\n static id = 'markers';\n\n /**\n * @deprecated use the EVENTS constants of the module\n */\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.MarkersPlugin.Options} [options]\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @summary All registered markers\n * @member {Object}\n */\n this.markers = {};\n\n /**\n * @type {Object}\n * @property {boolean} visible - Visibility of the component\n * @property {PSV.plugins.MarkersPlugin.Marker} currentMarker - Last selected marker\n * @property {PSV.plugins.MarkersPlugin.Marker} hoveringMarker - Marker under the cursor\n * @private\n */\n this.prop = {\n visible : true,\n currentMarker : null,\n hoveringMarker: null,\n stopObserver : null,\n };\n\n /**\n * @type {PSV.plugins.MarkersPlugin.Options}\n */\n this.config = {\n clickEventOnMarker: false,\n ...options,\n };\n\n if (options?.listButton === false || options?.hideButton === false) {\n utils.logWarn('MarkersPlugin: listButton and hideButton options are deprecated. '\n + 'Please define the global navbar options according to your needs.');\n }\n\n /**\n * @member {HTMLElement}\n * @readonly\n */\n this.container = document.createElement('div');\n this.container.className = 'psv-markers';\n this.container.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n\n /**\n * @member {SVGElement}\n * @readonly\n */\n this.svgContainer = document.createElementNS(SVG_NS, 'svg');\n this.svgContainer.setAttribute('class', 'psv-markers-svg-container');\n this.container.appendChild(this.svgContainer);\n\n // Markers events via delegation\n this.container.addEventListener('mouseenter', this, true);\n this.container.addEventListener('mouseleave', this, true);\n this.container.addEventListener('mousemove', this, true);\n this.container.addEventListener('contextmenu', this);\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.psv.container.appendChild(this.container);\n\n // Viewer events\n this.psv.on(CONSTANTS.EVENTS.CLICK, this);\n this.psv.on(CONSTANTS.EVENTS.DOUBLE_CLICK, this);\n this.psv.on(CONSTANTS.EVENTS.RENDER, this);\n this.psv.on(CONSTANTS.EVENTS.CONFIG_CHANGED, this);\n\n if (this.config.markers) {\n this.psv.once(CONSTANTS.EVENTS.READY, () => {\n this.setMarkers(this.config.markers);\n delete this.config.markers;\n });\n }\n }\n\n /**\n * @package\n */\n destroy() {\n this.clearMarkers(false);\n\n this.prop.stopObserver?.();\n\n this.psv.off(CONSTANTS.EVENTS.CLICK, this);\n this.psv.off(CONSTANTS.EVENTS.DOUBLE_CLICK, this);\n this.psv.off(CONSTANTS.EVENTS.RENDER, this);\n this.psv.off(CONSTANTS.EVENTS.CONFIG_CHANGED, this);\n\n this.psv.container.removeChild(this.container);\n\n delete this.svgContainer;\n delete this.markers;\n delete this.container;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mouseenter': this.__onMouseEnter(e, this.__getTargetMarker(e.target)); break;\n case 'mouseleave': this.__onMouseLeave(e, this.__getTargetMarker(e.target)); break;\n case 'mousemove': this.__onMouseMove(e, this.__getTargetMarker(e.target)); break;\n case 'contextmenu': e.preventDefault(); break;\n case CONSTANTS.EVENTS.CLICK: this.__onClick(e, e.args[0], false); break;\n case CONSTANTS.EVENTS.DOUBLE_CLICK: this.__onClick(e, e.args[0], true); break;\n case CONSTANTS.EVENTS.RENDER: this.renderMarkers(); break;\n case CONSTANTS.OBJECT_EVENTS.ENTER_OBJECT: this.__onMouseEnter(e.detail.originalEvent, e.detail.data); break;\n case CONSTANTS.OBJECT_EVENTS.LEAVE_OBJECT: this.__onMouseLeave(e.detail.originalEvent, e.detail.data); break;\n case CONSTANTS.OBJECT_EVENTS.HOVER_OBJECT: this.__onMouseMove(e.detail.originalEvent, e.detail.data); break;\n case CONSTANTS.EVENTS.CONFIG_CHANGED:\n this.container.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Shows all markers\n * @fires PSV.plugins.MarkersPlugin.show-markers\n */\n show() {\n this.prop.visible = true;\n\n this.renderMarkers();\n\n this.trigger(EVENTS.SHOW_MARKERS);\n }\n\n /**\n * @summary Hides all markers\n * @fires PSV.plugins.MarkersPlugin.hide-markers\n */\n hide() {\n this.prop.visible = false;\n\n this.renderMarkers();\n\n this.trigger(EVENTS.HIDE_MARKERS);\n }\n\n /**\n * @summary Toggles the visibility of all tooltips\n */\n toggleAllTooltips() {\n this.prop.showAllTooltips = !this.prop.showAllTooltips;\n this.renderMarkers();\n }\n\n /**\n * @summary Displays all tooltips\n */\n showAllTooltips() {\n this.prop.showAllTooltips = true;\n this.renderMarkers();\n }\n\n /**\n * @summary Hides all tooltips\n */\n hideAllTooltips() {\n this.prop.showAllTooltips = false;\n this.renderMarkers();\n }\n\n /**\n * @summary Returns the total number of markers\n * @returns {number}\n */\n getNbMarkers() {\n return Object.keys(this.markers).length;\n }\n\n /**\n * @summary Returns all the markers\n * @return {PSV.plugins.MarkersPlugin.Marker[]}\n */\n getMarkers() {\n return Object.values(this.markers);\n }\n\n /**\n * @summary Adds a new marker to viewer\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @param {boolean} [render=true] - renders the marker immediately\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n * @throws {PSV.PSVError} when the marker's id is missing or already exists\n */\n addMarker(properties, render = true) {\n if (this.markers[properties.id]) {\n throw new PSVError(`marker \"${properties.id}\" already exists`);\n }\n\n const marker = new Marker(properties, this.psv);\n\n if (marker.isNormal()) {\n this.container.appendChild(marker.$el);\n }\n else if (marker.isPoly() || marker.isSvg()) {\n this.svgContainer.appendChild(marker.$el);\n }\n else if (marker.is3d()) {\n this.psv.renderer.scene.add(marker.$el);\n }\n\n this.markers[marker.id] = marker;\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n\n return marker;\n }\n\n /**\n * @summary Returns the internal marker object for a marker id\n * @param {string} markerId\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n * @throws {PSV.PSVError} when the marker cannot be found\n */\n getMarker(markerId) {\n const id = typeof markerId === 'object' ? markerId.id : markerId;\n\n if (!this.markers[id]) {\n throw new PSVError(`cannot find marker \"${id}\"`);\n }\n\n return this.markers[id];\n }\n\n /**\n * @summary Returns the last marker selected by the user\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n */\n getCurrentMarker() {\n return this.prop.currentMarker;\n }\n\n /**\n * @summary Updates the existing marker with the same id\n * @description Every property can be changed but you can't change its type (Eg: `image` to `html`).\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @param {boolean} [render=true] - renders the marker immediately\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n */\n updateMarker(properties, render = true) {\n const marker = this.getMarker(properties.id);\n\n marker.update(properties);\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n\n if (marker.is3d()) {\n this.psv.needsUpdate();\n }\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n\n return marker;\n }\n\n /**\n * @summary Removes a marker from the viewer\n * @param {string} markerId\n * @param {boolean} [render=true] - renders the marker immediately\n */\n removeMarker(markerId, render = true) {\n const marker = this.getMarker(markerId);\n\n if (marker.isNormal()) {\n this.container.removeChild(marker.$el);\n }\n else if (marker.isPoly() || marker.isSvg()) {\n this.svgContainer.removeChild(marker.$el);\n }\n else if (marker.is3d()) {\n this.psv.renderer.scene.remove(marker.$el);\n this.psv.needsUpdate();\n }\n\n if (this.prop.hoveringMarker === marker) {\n this.prop.hoveringMarker = null;\n }\n\n if (this.prop.currentMarker === marker) {\n this.prop.currentMarker = null;\n }\n\n marker.hideTooltip();\n\n marker.destroy();\n delete this.markers[marker.id];\n\n if (render) {\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Removes multiple markers\n * @param {string[]} markerIds\n * @param {boolean} [render=true] - renders the markers immediately\n */\n removeMarkers(markerIds, render = true) {\n markerIds.forEach(markerId => this.removeMarker(markerId, false));\n\n if (render) {\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Replaces all markers\n * @param {PSV.plugins.MarkersPlugin.Properties[]} markers\n * @param {boolean} [render=true] - renders the marker immediately\n */\n setMarkers(markers, render = true) {\n this.clearMarkers(false);\n\n utils.each(markers, marker => this.addMarker(marker, false));\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Removes all markers\n * @param {boolean} [render=true] - renders the markers immediately\n */\n clearMarkers(render = true) {\n utils.each(this.markers, marker => this.removeMarker(marker, false));\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Rotate the view to face the marker\n * @param {string} markerId\n * @param {string|number} [speed] - rotates smoothy, see {@link PSV.Viewer#animate}\n * @fires PSV.plugins.MarkersPlugin.goto-marker-done\n * @return {PSV.Animation} A promise that will be resolved when the animation finishes\n */\n gotoMarker(markerId, speed) {\n const marker = this.getMarker(markerId);\n\n return this.psv.animate({\n ...marker.props.position,\n speed,\n })\n .then(() => {\n this.trigger(EVENTS.GOTO_MARKER_DONE, marker);\n });\n }\n\n /**\n * @summary Hides a marker\n * @param {string} markerId\n */\n hideMarker(markerId) {\n this.toggleMarker(markerId, false);\n }\n\n /**\n * @summary Shows a marker\n * @param {string} markerId\n */\n showMarker(markerId) {\n this.toggleMarker(markerId, true);\n }\n\n /**\n * @summary Toggles a marker\n * @param {string} markerId\n * @param {boolean} [visible]\n */\n toggleMarker(markerId, visible = null) {\n const marker = this.getMarker(markerId);\n marker.visible = visible === null ? !marker.visible : visible;\n if (marker.is3d()) {\n this.psv.needsUpdate();\n }\n else {\n this.renderMarkers();\n }\n }\n\n /**\n * @summary Opens the panel with the content of the marker\n * @param {string} markerId\n */\n showMarkerPanel(markerId) {\n const marker = this.getMarker(markerId);\n\n if (marker?.config?.content) {\n this.psv.panel.show({\n id : ID_PANEL_MARKER,\n content: marker.config.content,\n });\n }\n else {\n this.psv.panel.hide(ID_PANEL_MARKER);\n }\n }\n\n /**\n * @summary Toggles the visibility of the list of markers\n */\n toggleMarkersList() {\n if (this.psv.panel.prop.contentId === ID_PANEL_MARKERS_LIST) {\n this.hideMarkersList();\n }\n else {\n this.showMarkersList();\n }\n }\n\n /**\n * @summary Opens side panel with the list of markers\n * @fires PSV.plugins.MarkersPlugin.filter:render-markers-list\n */\n showMarkersList() {\n let markers = [];\n utils.each(this.markers, (marker) => {\n if (marker.visible && !marker.config.hideList) {\n markers.push(marker);\n }\n });\n\n markers = this.change(EVENTS.RENDER_MARKERS_LIST, markers);\n\n this.psv.panel.show({\n id : ID_PANEL_MARKERS_LIST,\n content : MARKERS_LIST_TEMPLATE(\n markers,\n this.psv.config.lang[MarkersButton.id],\n utils.dasherize(MARKER_DATA)\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const markerId = li ? li.dataset[MARKER_DATA] : undefined;\n\n if (markerId) {\n const marker = this.getMarker(markerId);\n\n this.trigger(EVENTS.SELECT_MARKER_LIST, marker);\n\n this.gotoMarker(marker, 1000);\n this.hideMarkersList();\n }\n },\n });\n }\n\n /**\n * @summary Closes side panel if it contains the list of markers\n */\n hideMarkersList() {\n this.psv.panel.hide(ID_PANEL_MARKERS_LIST);\n }\n\n /**\n * @summary Updates the visibility and the position of all markers\n */\n renderMarkers() {\n const zoomLevel = this.psv.getZoomLevel();\n const viewerPosition = this.psv.getPosition();\n\n utils.each(this.markers, (marker) => {\n let isVisible = this.prop.visible && marker.visible;\n let position = null;\n\n if (isVisible && marker.is3d()) {\n position = this.__getMarkerPosition(marker);\n isVisible = this.__isMarkerVisible(marker, position);\n }\n else if (isVisible && marker.isPoly()) {\n const positions = this.__getPolyPositions(marker);\n isVisible = positions.length > (marker.isPolygon() ? 2 : 1);\n\n if (isVisible) {\n position = this.__getMarkerPosition(marker);\n\n const points = positions.map(pos => (pos.x - position.x) + ',' + (pos.y - position.y)).join(' ');\n\n marker.$el.setAttributeNS(null, 'points', points);\n marker.$el.setAttributeNS(null, 'transform', `translate(${position.x} ${position.y})`);\n }\n }\n else if (isVisible) {\n if (marker.props.dynamicSize) {\n this.__updateMarkerSize(marker);\n }\n\n position = this.__getMarkerPosition(marker);\n isVisible = this.__isMarkerVisible(marker, position);\n\n if (isVisible) {\n const scale = marker.getScale(zoomLevel, viewerPosition);\n\n if (marker.isSvg()) {\n // simulate transform-origin relative to SVG element\n const x = position.x + marker.props.width * marker.props.anchor.x * (1 - scale);\n const y = position.y + marker.props.width * marker.props.anchor.y * (1 - scale);\n marker.$el.setAttributeNS(null, 'transform', `translate(${x}, ${y}) scale(${scale}, ${scale})`);\n }\n else {\n marker.$el.style.transform = `translate3D(${position.x}px, ${position.y}px, 0px) scale(${scale}, ${scale})`;\n }\n }\n }\n\n marker.props.position2D = isVisible ? position : null;\n\n if (!marker.is3d()) {\n utils.toggleClass(marker.$el, 'psv-marker--visible', isVisible);\n }\n\n if (isVisible && (this.prop.showAllTooltips || (marker === this.prop.hoveringMarker && !marker.isPoly()))) {\n marker.showTooltip();\n }\n else if (!isVisible || marker !== this.prop.hoveringMarker) {\n marker.hideTooltip();\n }\n });\n }\n\n /**\n * @summary Determines if a point marker is visible
\n * It tests if the point is in the general direction of the camera, then check if it's in the viewport\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @param {PSV.Point} position\n * @returns {boolean}\n * @private\n */\n __isMarkerVisible(marker, position) {\n return marker.props.positions3D[0].dot(this.psv.prop.direction) > 0\n && position.x + marker.props.width >= 0\n && position.x - marker.props.width <= this.psv.prop.size.width\n && position.y + marker.props.height >= 0\n && position.y - marker.props.height <= this.psv.prop.size.height;\n }\n\n /**\n * @summary Computes the real size of a marker\n * @description This is done by removing all it's transformations (if any) and making it visible\n * before querying its bounding rect\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @private\n */\n __updateMarkerSize(marker) {\n utils.addClasses(marker.$el, 'psv-marker--transparent');\n\n let transform;\n if (marker.isSvg()) {\n transform = marker.$el.getAttributeNS(null, 'transform');\n marker.$el.removeAttributeNS(null, 'transform');\n }\n else {\n transform = marker.$el.style.transform;\n marker.$el.style.transform = '';\n }\n\n const rect = marker.$el.getBoundingClientRect();\n marker.props.width = rect.width;\n marker.props.height = rect.height;\n\n utils.removeClasses(marker.$el, 'psv-marker--transparent');\n\n if (transform) {\n if (marker.isSvg()) {\n marker.$el.setAttributeNS(null, 'transform', transform);\n }\n else {\n marker.$el.style.transform = transform;\n }\n }\n\n // the size is no longer dynamic once known\n marker.props.dynamicSize = false;\n }\n\n /**\n * @summary Computes viewer coordinates of a marker\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @returns {PSV.Point}\n * @private\n */\n __getMarkerPosition(marker) {\n if (marker.isPoly()) {\n return this.psv.dataHelper.sphericalCoordsToViewerCoords(marker.props.position);\n }\n else {\n const position = this.psv.dataHelper.vector3ToViewerCoords(marker.props.positions3D[0]);\n\n position.x -= marker.props.width * marker.props.anchor.x;\n position.y -= marker.props.height * marker.props.anchor.y;\n\n return position;\n }\n }\n\n /**\n * @summary Computes viewer coordinates of each point of a polygon/polyline
\n * It handles points behind the camera by creating intermediary points suitable for the projector\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @returns {PSV.Point[]}\n * @private\n */\n __getPolyPositions(marker) {\n const nbVectors = marker.props.positions3D.length;\n\n // compute if each vector is visible\n const positions3D = marker.props.positions3D.map((vector) => {\n return {\n vector : vector,\n visible: vector.dot(this.psv.prop.direction) > 0,\n };\n });\n\n // get pairs of visible/invisible vectors for each invisible vector connected to a visible vector\n const toBeComputed = [];\n positions3D.forEach((pos, i) => {\n if (!pos.visible) {\n const neighbours = [\n i === 0 ? positions3D[nbVectors - 1] : positions3D[i - 1],\n i === nbVectors - 1 ? positions3D[0] : positions3D[i + 1],\n ];\n\n neighbours.forEach((neighbour) => {\n if (neighbour.visible) {\n toBeComputed.push({\n visible : neighbour,\n invisible: pos,\n index : i,\n });\n }\n });\n }\n });\n\n // compute intermediary vector for each pair (the loop is reversed for splice to insert at the right place)\n toBeComputed.reverse().forEach((pair) => {\n positions3D.splice(pair.index, 0, {\n vector : this.__getPolyIntermediaryPoint(pair.visible.vector, pair.invisible.vector),\n visible: true,\n });\n });\n\n // translate vectors to screen pos\n return positions3D\n .filter(pos => pos.visible)\n .map(pos => this.psv.dataHelper.vector3ToViewerCoords(pos.vector));\n }\n\n /**\n * Given one point in the same direction of the camera and one point behind the camera,\n * computes an intermediary point on the great circle delimiting the half sphere visible by the camera.\n * The point is shifted by .01 rad because the projector cannot handle points exactly on this circle.\n * TODO : does not work with fisheye view (must not use the great circle)\n * {@link http://math.stackexchange.com/a/1730410/327208}\n * @param P1 {external:THREE.Vector3}\n * @param P2 {external:THREE.Vector3}\n * @returns {external:THREE.Vector3}\n * @private\n */\n __getPolyIntermediaryPoint(P1, P2) {\n const C = this.psv.prop.direction.clone().normalize();\n const N = new THREE.Vector3().crossVectors(P1, P2).normalize();\n const V = new THREE.Vector3().crossVectors(N, P1).normalize();\n const X = P1.clone().multiplyScalar(-C.dot(V));\n const Y = V.clone().multiplyScalar(C.dot(P1));\n const H = new THREE.Vector3().addVectors(X, Y).normalize();\n const a = new THREE.Vector3().crossVectors(H, C);\n return H.applyAxisAngle(a, 0.01).multiplyScalar(CONSTANTS.SPHERE_RADIUS);\n }\n\n /**\n * @summary Returns the marker associated to an event target\n * @param {EventTarget} target\n * @param {boolean} [closest=false]\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n * @private\n */\n __getTargetMarker(target, closest = false) {\n const target2 = closest ? utils.getClosest(target, '.psv-marker') : target;\n return target2 ? target2[MARKER_DATA] : undefined;\n }\n\n /**\n * @summary Checks if an event target is in the tooltip\n * @param {EventTarget} target\n * @param {PSV.components.Tooltip} tooltip\n * @returns {boolean}\n * @private\n */\n __targetOnTooltip(target, tooltip) {\n return target && tooltip ? utils.hasParent(target, tooltip.container) : false;\n }\n\n /**\n * @summary Handles mouse enter events, show the tooltip for non polygon markers\n * @param {MouseEvent} e\n * @param {PSV.plugins.MarkersPlugin.Marker} [marker]\n * @fires PSV.plugins.MarkersPlugin.over-marker\n * @private\n */\n __onMouseEnter(e, marker) {\n if (marker && !marker.isPoly()) {\n this.prop.hoveringMarker = marker;\n\n this.trigger(EVENTS.OVER_MARKER, marker);\n\n if (!this.prop.showAllTooltips) {\n marker.showTooltip(e);\n }\n }\n }\n\n /**\n * @summary Handles mouse leave events, hide the tooltip\n * @param {MouseEvent} e\n * @param {PSV.plugins.MarkersPlugin.Marker} [marker]\n * @fires PSV.plugins.MarkersPlugin.leave-marker\n * @private\n */\n __onMouseLeave(e, marker) {\n // do not hide if we enter the tooltip itself while hovering a polygon\n if (marker && !(marker.isPoly() && this.__targetOnTooltip(e.relatedTarget, marker.tooltip))) {\n this.trigger(EVENTS.LEAVE_MARKER, marker);\n\n this.prop.hoveringMarker = null;\n\n if (!this.prop.showAllTooltips) {\n marker.hideTooltip();\n }\n }\n }\n\n /**\n * @summary Handles mouse move events, refreshUi the tooltip for polygon markers\n * @param {MouseEvent} e\n * @param {PSV.plugins.MarkersPlugin.Marker} [targetMarker]\n * @fires PSV.plugins.MarkersPlugin.leave-marker\n * @fires PSV.plugins.MarkersPlugin.over-marker\n * @private\n */\n __onMouseMove(e, targetMarker) {\n let marker;\n\n if (targetMarker?.isPoly()) {\n marker = targetMarker;\n }\n // do not hide if we enter the tooltip itself while hovering a polygon\n else if (this.prop.hoveringMarker && this.__targetOnTooltip(e.target, this.prop.hoveringMarker.tooltip)) {\n marker = this.prop.hoveringMarker;\n }\n\n if (marker) {\n if (!this.prop.hoveringMarker) {\n this.trigger(EVENTS.OVER_MARKER, marker);\n\n this.prop.hoveringMarker = marker;\n }\n\n if (!this.prop.showAllTooltips) {\n marker.showTooltip(e);\n }\n }\n else if (this.prop.hoveringMarker?.isPoly()) {\n this.trigger(EVENTS.LEAVE_MARKER, this.prop.hoveringMarker);\n\n if (!this.prop.showAllTooltips) {\n this.prop.hoveringMarker.hideTooltip();\n }\n\n this.prop.hoveringMarker = null;\n }\n }\n\n /**\n * @summary Handles mouse click events, select the marker and open the panel if necessary\n * @param {Event} e\n * @param {Object} data\n * @param {boolean} dblclick\n * @fires PSV.plugins.MarkersPlugin.select-marker\n * @fires PSV.plugins.MarkersPlugin.unselect-marker\n * @private\n */\n __onClick(e, data, dblclick) {\n let marker = data.objects.find(o => o.userData[MARKER_DATA])?.userData[MARKER_DATA];\n\n if (!marker) {\n marker = this.__getTargetMarker(data.target, true);\n }\n\n if (marker) {\n this.prop.currentMarker = marker;\n\n this.trigger(EVENTS.SELECT_MARKER, marker, {\n dblclick : dblclick,\n rightclick: data.rightclick,\n });\n\n if (this.config.clickEventOnMarker) {\n // add the marker to event data\n data.marker = marker;\n }\n else {\n e.stopPropagation();\n }\n\n // the marker could have been deleted in an event handler\n if (this.markers[marker.id]) {\n this.showMarkerPanel(marker.id);\n }\n }\n else if (this.prop.currentMarker) {\n this.trigger(EVENTS.UNSELECT_MARKER, this.prop.currentMarker);\n\n this.psv.panel.hide(ID_PANEL_MARKER);\n\n this.prop.currentMarker = null;\n }\n }\n\n /**\n * @summary Updates the visiblity of the panel and the buttons\n * @private\n */\n __refreshUi() {\n const nbMarkers = Object.values(this.markers).filter(m => !m.config.hideList).length;\n const markersButton = this.psv.navbar.getButton(MarkersButton.id, false);\n const markersListButton = this.psv.navbar.getButton(MarkersListButton.id, false);\n\n if (nbMarkers === 0) {\n markersButton?.hide();\n markersListButton?.hide();\n\n if (this.psv.panel.isVisible(ID_PANEL_MARKERS_LIST)) {\n this.psv.panel.hide();\n }\n else if (this.psv.panel.isVisible(ID_PANEL_MARKER)) {\n this.psv.panel.hide();\n }\n }\n else {\n markersButton?.show();\n markersListButton?.show();\n\n if (this.psv.panel.isVisible(ID_PANEL_MARKERS_LIST)) {\n this.showMarkersList();\n }\n else if (this.psv.panel.isVisible(ID_PANEL_MARKER)) {\n this.prop.currentMarker ? this.showMarkerPanel(this.prop.currentMarker) : this.psv.panel.hide();\n }\n }\n }\n\n /**\n * @summary Adds or remove the objects observer if there are 3D markers\n * @private\n */\n __checkObjectsObserver() {\n const has3d = Object.values(this.markers).some(marker => marker.is3d());\n\n if (!has3d && this.prop.stopObserver) {\n this.prop.stopObserver();\n this.prop.stopObserver = null;\n }\n else if (has3d && !this.prop.stopObserver) {\n this.prop.stopObserver = this.psv.observeObjects(MARKER_DATA, this);\n }\n }\n\n}\n"],"names":["EVENTS","GOTO_MARKER_DONE","LEAVE_MARKER","OVER_MARKER","RENDER_MARKERS_LIST","SELECT_MARKER","SELECT_MARKER_LIST","UNSELECT_MARKER","HIDE_MARKERS","SET_MARKERS","SHOW_MARKERS","SVG_NS","MARKER_DATA","ID_PANEL_MARKER","ID_PANEL_MARKERS_LIST","MARKERS_LIST_TEMPLATE","markers","title","dataKey","icon","map","marker","config","id","type","image","getListContent","join","getShortestArc","from","to","tCandidates","Math","PI","reduce","value","candidate","newCandidate","abs","Infinity","PSVError","message","Error","captureStackTrace","stack","prototype","Object","create","name","constructor","logWarn","console","warn","THREE","Quaternion","greatArcIntermediaryPoint","p1","p2","f","λ1","φ1","λ2","φ2","r","utils","greatArcDistance","a","sin","b","x","cos","y","z","atan2","sqrt","getPolygonCenter","polygon","workPoints","k","i","length","d","push","sum","intermediary","point","parseAngle","getPolylineCenter","polyline","lengths","l","CONSTANTS","SPHERE_RADIUS","consumed","j","round","MARKER_TYPES","imageLayer","html","polygonPx","polygonRad","polylinePx","polylineRad","square","rect","circle","ellipse","path","Marker","properties","psv","getType","visible","$el","data","undefined","tooltip","props","dynamicSize","anchor","position","position2D","positions3D","width","height","def","loader","is3d","TextureLoader","withCredentials","setWithCredentials","requestHeaders","setRequestHeader","isNormal","document","createElement","isPolygon","createElementNS","isPolyline","isSvg","update","destroy","isPoly","isPolyPx","isPolyRad","getScale","zoomLevel","scale","Array","isArray","zoom","bounds","EASINGS","inQuad","longitude","halfFov","degToRad","prop","hFov","arc","outQuad","max","listContent","content","showTooltip","mousePosition","viewerPos","getPosition","container","box","size","arrow","top","clientY","left","clientX","move","hideTooltip","hide","newType","deepmerge","setAttribute","className","addClasses","style","opacity","parsePosition","__updateNormal","__updatePoly","__updateSvg","__update3d","isExtendedPosition","backgroundImage","innerHTML","transformOrigin","dataHelper","cleanPosition","sphericalCoordsToVector3","cx","cy","rx","ry","each","setAttributeNS","svgStyle","dasherize","fill","actualPoly","splice","coord","sphericalCoords","textureCoordsToSphericalCoords","latitude","centroid","material","MeshBasicMaterial","transparent","depthTest","geometry","PlaneGeometry","mesh","Mesh","userData","Group","add","defineProperty","enumerable","get","children","set","load","texture","anisotropy","needsUpdate","copy","orientation","lookAt","rotateX","rotateY","SYSTEM","pixelRatio","allowNone","found","keys","MarkersButton","navbar","plugin","getPlugin","on","toggleActive","off","isSupported","handleEvent","e","onClick","show","AbstractButton","pin","MarkersListButton","OPEN_PANEL","CLOSE_PANEL","args","toggleMarkersList","pinList","DEFAULTS","lang","registerButton","MarkersPlugin","options","currentMarker","hoveringMarker","stopObserver","clickEventOnMarker","listButton","hideButton","cursor","mousemove","svgContainer","appendChild","addEventListener","init","CLICK","DOUBLE_CLICK","RENDER","CONFIG_CHANGED","once","READY","setMarkers","clearMarkers","removeChild","__onMouseEnter","__getTargetMarker","target","__onMouseLeave","__onMouseMove","preventDefault","__onClick","renderMarkers","OBJECT_EVENTS","ENTER_OBJECT","detail","originalEvent","LEAVE_OBJECT","HOVER_OBJECT","trigger","toggleAllTooltips","showAllTooltips","hideAllTooltips","getNbMarkers","getMarkers","values","addMarker","render","renderer","scene","__refreshUi","__checkObjectsObserver","getMarker","markerId","getCurrentMarker","updateMarker","removeMarker","remove","removeMarkers","markerIds","forEach","gotoMarker","speed","animate","then","hideMarker","toggleMarker","showMarker","showMarkerPanel","panel","contentId","hideMarkersList","showMarkersList","hideList","change","noMargin","clickHandler","li","getClosest","dataset","getZoomLevel","viewerPosition","isVisible","__getMarkerPosition","__isMarkerVisible","positions","__getPolyPositions","points","pos","__updateMarkerSize","transform","toggleClass","dot","direction","getAttributeNS","removeAttributeNS","getBoundingClientRect","removeClasses","sphericalCoordsToViewerCoords","vector3ToViewerCoords","nbVectors","vector","toBeComputed","neighbours","neighbour","invisible","index","reverse","pair","__getPolyIntermediaryPoint","filter","P1","P2","C","clone","normalize","N","Vector3","crossVectors","V","X","multiplyScalar","Y","H","addVectors","applyAxisAngle","closest","target2","__targetOnTooltip","hasParent","relatedTarget","targetMarker","dblclick","objects","find","o","rightclick","stopPropagation","nbMarkers","m","markersButton","getButton","markersListButton","has3d","some","observeObjects","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,gBAAgB,EAAK,kBAPD;;EAQpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAS,cAdD;;EAepB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,WAAW,EAAU,aArBD;;EAsBpB;EACF;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,mBAAmB,EAAE,qBA7BD;;EA8BpB;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,aAAa,EAAQ,eAtCD;;EAuCpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,kBAAkB,EAAG,oBA7CD;;EA8CpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,eAAe,EAAM,iBApDD;;EAqDpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAS,cA1DD;;EA2DpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,WAAW,EAAU,aAjED;;EAkEpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,YAAY,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qC,IAArC,CAAzB;EACD;EACF,GA35BH;;EAAA;EAAA,EAAmC+Y,gCAAnC;EAAahJ,cAEJpP,KAAK;EAFDoP,cAOJ3Q,SAASA;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"markers.js","sources":["../../src/plugins/markers/constants.js","../../src/utils/math.js","../../src/PSVError.js","../../src/utils/psv.js","../../src/plugins/markers/utils.js","../../src/plugins/markers/Marker.js","../../src/plugins/markers/MarkersButton.js","../../src/plugins/markers/MarkersListButton.js","../../src/plugins/markers/index.js"],"sourcesContent":["import icon from './pin-list.svg';\n\n/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.MarkersPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event goto-marker-done\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the animation to a marker is done\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n GOTO_MARKER_DONE : 'goto-marker-done',\n /**\n * @event leave-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the user puts the cursor away from a marker\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n LEAVE_MARKER : 'leave-marker',\n /**\n * @event over-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the user puts the cursor hover a marker\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n OVER_MARKER : 'over-marker',\n /**\n * @event filter:render-markers-list\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Used to alter the list of markers displayed on the side-panel\n * @param {PSV.plugins.MarkersPlugin.Marker[]} markers\n * @returns {PSV.plugins.MarkersPlugin.Marker[]}\n */\n RENDER_MARKERS_LIST: 'render-markers-list',\n /**\n * @event select-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the user clicks on a marker. The marker can be retrieved from outside the event handler\n * with {@link PSV.plugins.MarkersPlugin.getCurrentMarker}\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @param {PSV.plugins.MarkersPlugin.SelectMarkerData} data\n */\n SELECT_MARKER : 'select-marker',\n /**\n * @event select-marker-list\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when a marker is selected from the side panel\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n SELECT_MARKER_LIST : 'select-marker-list',\n /**\n * @event unselect-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when a marker was selected and the user clicks elsewhere\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n */\n UNSELECT_MARKER : 'unselect-marker',\n /**\n * @event hide-markers\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the markers are hidden\n */\n HIDE_MARKERS : 'hide-markers',\n /**\n * @event set-marker\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the list of markers changes\n * @param {PSV.plugins.MarkersPlugin.Marker[]} markers\n */\n SET_MARKERS : 'set-markers',\n /**\n * @event show-markers\n * @memberof PSV.plugins.MarkersPlugin\n * @summary Triggered when the markers are shown\n */\n SHOW_MARKERS : 'show-markers',\n};\n\n/**\n * @summary Namespace for SVG creation\n * @type {string}\n * @constant\n * @private\n */\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @summary Property name added to marker elements\n * @type {string}\n * @constant\n * @private\n */\nexport const MARKER_DATA = 'psvMarker';\n\n/**\n * @summary Panel identifier for marker content\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL_MARKER = 'marker';\n\n/**\n * @summary Panel identifier for markers list\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL_MARKERS_LIST = 'markersList';\n\n/**\n * @summary Markers list template\n * @param {PSV.plugins.MarkersPlugin.Marker[]} markers\n * @param {string} title\n * @param {string} dataKey\n * @returns {string}\n * @constant\n * @private\n */\nexport const MARKERS_LIST_TEMPLATE = (markers, title, dataKey) => `\n
\n

${icon} ${title}

\n
    \n ${markers.map(marker => `\n
  • \n ${marker.type === 'image' ? `` : ''}\n ${marker.getListContent()}\n
  • \n `).join('')}\n
\n
\n`;\n","/**\n * @summary Ensures that a number is in a given interval\n * @memberOf PSV.utils\n * @param {number} x\n * @param {number} min\n * @param {number} max\n * @returns {number}\n */\nexport function bound(x, min, max) {\n return Math.max(min, Math.min(max, x));\n}\n\n/**\n * @summary Ensure a value is within 0 and `max`\n * @param {number} value\n * @param {number} max\n * @return {number}\n */\nexport function loop(value, max) {\n let result = value % max;\n\n if (result < 0) {\n result += max;\n }\n\n return result;\n}\n\n/**\n * @summary Checks if a value is an integer\n * @memberOf PSV.utils\n * @param {*} value\n * @returns {boolean}\n */\nexport function isInteger(value) {\n if (Number.isInteger) {\n return Number.isInteger(value);\n }\n return typeof value === 'number' && Number.isFinite(value) && Math.floor(value) === value;\n}\n\n/**\n * @summary Tests if a number is power of two\n * @memberOf PSV.utils\n * @param {number} x\n * @return {boolean}\n */\nexport function isPowerOfTwo(x) {\n return (Math.log(x) / Math.log(2)) % 1 === 0;\n}\n\n/**\n * @summary Computes the sum of an array\n * @memberOf PSV.utils\n * @param {number[]} array\n * @returns {number}\n */\nexport function sum(array) {\n return array.reduce((a, b) => a + b, 0);\n}\n\n/**\n * @summary Computes the distance between two points\n * @memberOf PSV.utils\n * @param {PSV.Point} p1\n * @param {PSV.Point} p2\n * @returns {number}\n */\nexport function distance(p1, p2) {\n return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));\n}\n\n/**\n * @summary Compute the shortest offset between two longitudes\n * @memberOf PSV.utils\n * @param {number} from\n * @param {number} to\n * @returns {number}\n */\nexport function getShortestArc(from, to) {\n const tCandidates = [\n 0, // direct\n Math.PI * 2, // clock-wise cross zero\n -Math.PI * 2, // counter-clock-wise cross zero\n ];\n\n return tCandidates.reduce((value, candidate) => {\n const newCandidate = to - from + candidate;\n return Math.abs(newCandidate) < Math.abs(value) ? newCandidate : value;\n }, Infinity);\n}\n\n/**\n * @summary Computes the angle between the current position and a target position\n * @memberOf PSV.utils\n * @param {PSV.Position} position1\n * @param {PSV.Position} position2\n * @returns {number}\n */\nexport function getAngle(position1, position2) {\n return Math.acos(\n Math.cos(position1.latitude)\n * Math.cos(position2.latitude)\n * Math.cos(position1.longitude - position2.longitude)\n + Math.sin(position1.latitude)\n * Math.sin(position2.latitude)\n );\n}\n\n/**\n * @summary Returns the distance between two points on a sphere of radius one\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @memberOf PSV.utils\n * @param {number[]} p1\n * @param {number[]} p2\n * @returns {number}\n */\nexport function greatArcDistance(p1, p2) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const x = (λ2 - λ1) * Math.cos((φ1 + φ2) / 2);\n const y = (φ2 - φ1);\n return Math.sqrt(x * x + y * y);\n}\n","/**\n * @summary Custom error used in the lib\n * @param {string} message\n * @constructor\n * @memberOf PSV\n */\nfunction PSVError(message) {\n this.message = message;\n\n // Use V8's native method if available, otherwise fallback\n if ('captureStackTrace' in Error) {\n Error.captureStackTrace(this, PSVError);\n }\n else {\n this.stack = (new Error()).stack;\n }\n}\n\nPSVError.prototype = Object.create(Error.prototype);\nPSVError.prototype.name = 'PSVError';\nPSVError.prototype.constructor = PSVError;\n\nexport { PSVError };\n","import * as THREE from 'three';\nimport { PSVError } from '../PSVError';\nimport { bound, loop } from './math';\n\n/**\n * @summary Returns the plugin constructor from the imported object\n * For retrocompatibility with previous default exports\n * @memberOf PSV.utils\n * @package\n */\nexport function pluginInterop(plugin, target) {\n if (plugin) {\n for (const [, p] of [['_', plugin], ...Object.entries(plugin)]) {\n if (p.prototype instanceof target) {\n return p;\n }\n }\n }\n return null;\n}\n\n/**\n * @summary Builds an Error with name 'AbortError'\n * @memberOf PSV.utils\n * @return {Error}\n */\nexport function getAbortError() {\n const error = new Error('Loading was aborted.');\n error.name = 'AbortError';\n return error;\n}\n\n/**\n * @summary Tests if an Error has name 'AbortError'\n * @memberOf PSV.utils\n * @param {Error} err\n * @return {boolean}\n */\nexport function isAbortError(err) {\n return err?.name === 'AbortError';\n}\n\n/**\n * @summary Displays a warning in the console\n * @memberOf PSV.utils\n * @param {string} message\n */\nexport function logWarn(message) {\n console.warn(`PhotoSphereViewer: ${message}`);\n}\n\n/**\n * @summary Checks if an object is a {PSV.ExtendedPosition}, ie has x/y or longitude/latitude\n * @memberOf PSV.utils\n * @param {object} object\n * @returns {boolean}\n */\nexport function isExtendedPosition(object) {\n return [['x', 'y'], ['longitude', 'latitude']].some(([key1, key2]) => {\n return object[key1] !== undefined && object[key2] !== undefined;\n });\n}\n\n/**\n * @summary Returns the value of a given attribute in the panorama metadata\n * @memberOf PSV.utils\n * @param {string} data\n * @param {string} attr\n * @returns (number)\n */\nexport function getXMPValue(data, attr) {\n // XMP data are stored in children\n let result = data.match('(.*)');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n // XMP data are stored in attributes\n result = data.match('GPano:' + attr + '=\"(.*?)\"');\n if (result !== null) {\n const val = parseInt(result[1], 10);\n return isNaN(val) ? null : val;\n }\n\n return null;\n}\n\n/**\n * @readonly\n * @private\n * @type {{top: string, left: string, bottom: string, center: string, right: string}}\n */\nconst CSS_POSITIONS = {\n top : '0%',\n bottom: '100%',\n left : '0%',\n right : '100%',\n center: '50%',\n};\n\n/**\n * @summary Translate CSS values like \"top center\" or \"10% 50%\" as top and left positions\n * @memberOf PSV.utils\n * @description The implementation is as close as possible to the \"background-position\" specification\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/background-position}\n * @param {string|PSV.Point} value\n * @returns {PSV.Point}\n */\nexport function parsePosition(value) {\n if (!value) {\n return { x: 0.5, y: 0.5 };\n }\n\n if (typeof value === 'object') {\n return value;\n }\n\n let tokens = value.toLocaleLowerCase().split(' ').slice(0, 2);\n\n if (tokens.length === 1) {\n if (CSS_POSITIONS[tokens[0]] !== undefined) {\n tokens = [tokens[0], 'center'];\n }\n else {\n tokens = [tokens[0], tokens[0]];\n }\n }\n\n const xFirst = tokens[1] !== 'left' && tokens[1] !== 'right' && tokens[0] !== 'top' && tokens[0] !== 'bottom';\n\n tokens = tokens.map(token => CSS_POSITIONS[token] || token);\n\n if (!xFirst) {\n tokens.reverse();\n }\n\n const parsed = tokens.join(' ').match(/^([0-9.]+)% ([0-9.]+)%$/);\n\n if (parsed) {\n return {\n x: parseFloat(parsed[1]) / 100,\n y: parseFloat(parsed[2]) / 100,\n };\n }\n else {\n return { x: 0.5, y: 0.5 };\n }\n}\n\n/**\n * @readonly\n * @private\n */\nconst LEFT_MAP = { 0: 'left', 0.5: 'center', 1: 'right' };\n/**\n * @readonly\n * @private\n */\nconst TOP_MAP = { 0: 'top', 0.5: 'center', 1: 'bottom' };\n\n/**\n * @summary Parse a CSS-like position into an array of position keywords among top, bottom, left, right and center\n * @memberOf PSV.utils\n * @param {string | string[]} value\n * @param {string} defaultValue\n * @param {boolean} [allowCenter=true]\n * @return {string[]}\n */\nexport function cleanPosition(value, defaultValue, allowCenter = true) {\n if (!value) {\n return defaultValue.split(' ');\n }\n\n if (typeof value === 'string') {\n const tempPos = parsePosition(value);\n\n if (!(tempPos.x in LEFT_MAP) || !(tempPos.y in TOP_MAP)) {\n throw new PSVError(`Unable to parse position \"${value}\"`);\n }\n\n value = [TOP_MAP[tempPos.y], LEFT_MAP[tempPos.x]];\n }\n\n if (!allowCenter && value[0] === 'center' && value[1] === 'center') {\n throw new PSVError('Unable to parse position \"center center\"');\n }\n\n return value;\n}\n\n/**\n * @summary Parses an speed\n * @memberOf PSV.utils\n * @param {string|number} speed - The speed, in radians/degrees/revolutions per second/minute\n * @returns {number} radians per second\n * @throws {PSV.PSVError} when the speed cannot be parsed\n */\nexport function parseSpeed(speed) {\n let parsed;\n\n if (typeof speed === 'string') {\n const speedStr = speed.toString().trim();\n\n // Speed extraction\n let speedValue = parseFloat(speedStr.replace(/^(-?[0-9]+(?:\\.[0-9]*)?).*$/, '$1'));\n const speedUnit = speedStr.replace(/^-?[0-9]+(?:\\.[0-9]*)?(.*)$/, '$1').trim();\n\n // \"per minute\" -> \"per second\"\n if (speedUnit.match(/(pm|per minute)$/)) {\n speedValue /= 60;\n }\n\n // Which unit?\n switch (speedUnit) {\n // Degrees per minute / second\n case 'dpm':\n case 'degrees per minute':\n case 'dps':\n case 'degrees per second':\n parsed = THREE.Math.degToRad(speedValue);\n break;\n\n // Radians per minute / second\n case 'rdpm':\n case 'radians per minute':\n case 'rdps':\n case 'radians per second':\n parsed = speedValue;\n break;\n\n // Revolutions per minute / second\n case 'rpm':\n case 'revolutions per minute':\n case 'rps':\n case 'revolutions per second':\n parsed = speedValue * Math.PI * 2;\n break;\n\n // Unknown unit\n default:\n throw new PSVError('Unknown speed unit \"' + speedUnit + '\"');\n }\n }\n else {\n parsed = speed;\n }\n\n return parsed;\n}\n\n/**\n * @summary Parses an angle value in radians or degrees and returns a normalized value in radians\n * @memberOf PSV.utils\n * @param {string|number} angle - eg: 3.14, 3.14rad, 180deg\n * @param {boolean} [zeroCenter=false] - normalize between -Pi - Pi instead of 0 - 2*Pi\n * @param {boolean} [halfCircle=zeroCenter] - normalize between -Pi/2 - Pi/2 instead of -Pi - Pi\n * @returns {number}\n * @throws {PSV.PSVError} when the angle cannot be parsed\n */\nexport function parseAngle(angle, zeroCenter = false, halfCircle = zeroCenter) {\n let parsed;\n\n if (typeof angle === 'string') {\n const match = angle.toLowerCase().trim().match(/^(-?[0-9]+(?:\\.[0-9]*)?)(.*)$/);\n\n if (!match) {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n const value = parseFloat(match[1]);\n const unit = match[2];\n\n if (unit) {\n switch (unit) {\n case 'deg':\n case 'degs':\n parsed = THREE.Math.degToRad(value);\n break;\n case 'rad':\n case 'rads':\n parsed = value;\n break;\n default:\n throw new PSVError('Unknown angle unit \"' + unit + '\"');\n }\n }\n else {\n parsed = value;\n }\n }\n else if (typeof angle === 'number' && !isNaN(angle)) {\n parsed = angle;\n }\n else {\n throw new PSVError('Unknown angle \"' + angle + '\"');\n }\n\n parsed = loop(zeroCenter ? parsed + Math.PI : parsed, Math.PI * 2);\n\n return zeroCenter ? bound(parsed - Math.PI, -Math.PI / (halfCircle ? 2 : 1), Math.PI / (halfCircle ? 2 : 1)) : parsed;\n}\n\n/**\n * @summary Creates a THREE texture from an image\n * @memberOf PSV.utils\n * @param {HTMLImageElement | HTMLCanvasElement} img\n * @return {external:THREE.Texture}\n */\nexport function createTexture(img) {\n const texture = new THREE.Texture(img);\n texture.needsUpdate = true;\n texture.minFilter = THREE.LinearFilter;\n texture.generateMipmaps = false;\n return texture;\n}\n\nconst quaternion = new THREE.Quaternion();\n\n/**\n * @summary Applies the inverse of Euler angles to a vector\n * @memberOf PSV.utils\n * @param {external:THREE.Vector3} vector\n * @param {external:THREE.Euler} euler\n */\nexport function applyEulerInverse(vector, euler) {\n quaternion.setFromEuler(euler).invert();\n vector.applyQuaternion(quaternion);\n}\n","import { CONSTANTS, utils } from '../..';\n\n/**\n * Returns intermediary point between two points on the sphere\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @param {number[]} p1\n * @param {number[]} p2\n * @param {number} f\n * @returns {number[]}\n * @private\n */\nexport function greatArcIntermediaryPoint(p1, p2, f) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const r = utils.greatArcDistance(p1, p2);\n const a = Math.sin((1 - f) * r) / Math.sin(r);\n const b = Math.sin(f * r) / Math.sin(r);\n const x = a * Math.cos(φ1) * Math.cos(λ1) + b * Math.cos(φ2) * Math.cos(λ2);\n const y = a * Math.cos(φ1) * Math.sin(λ1) + b * Math.cos(φ2) * Math.sin(λ2);\n const z = a * Math.sin(φ1) + b * Math.sin(φ2);\n\n return [\n Math.atan2(y, x),\n Math.atan2(z, Math.sqrt(x * x + y * y)),\n ];\n}\n\n/**\n * @summary Computes the center point of a polygon\n * @todo Get \"visual center\" (https://blog.mapbox.com/a-new-algorithm-for-finding-a-visual-center-of-a-polygon-7c77e6492fbc)\n * @param {number[][]} polygon\n * @returns {number[]}\n * @private\n */\nexport function getPolygonCenter(polygon) {\n // apply offsets to avoid crossing the origin\n const workPoints = [polygon[0]];\n\n let k = 0;\n for (let i = 1; i < polygon.length; i++) {\n const d = polygon[i - 1][0] - polygon[i][0];\n if (d > Math.PI) { // crossed the origin left to right\n k += 1;\n }\n else if (d < -Math.PI) { // crossed the origin right to left\n k -= 1;\n }\n workPoints.push([polygon[i][0] + k * 2 * Math.PI, polygon[i][1]]);\n }\n\n const sum = workPoints.reduce((intermediary, point) => [intermediary[0] + point[0], intermediary[1] + point[1]]);\n return [utils.parseAngle(sum[0] / polygon.length), sum[1] / polygon.length];\n}\n\n/**\n * @summary Computes the middle point of a polyline\n * @param {number[][]} polyline\n * @returns {number[]}\n * @private\n */\nexport function getPolylineCenter(polyline) {\n // compute each segment length + total length\n let length = 0;\n const lengths = [];\n\n for (let i = 0; i < polyline.length - 1; i++) {\n const l = utils.greatArcDistance(polyline[i], polyline[i + 1]) * CONSTANTS.SPHERE_RADIUS;\n\n lengths.push(l);\n length += l;\n }\n\n // iterate until length / 2\n let consumed = 0;\n\n for (let j = 0; j < polyline.length - 1; j++) {\n // once the segment containing the middle point is found, computes the intermediary point\n if (consumed + lengths[j] > length / 2) {\n const r = (length / 2 - consumed) / lengths[j];\n return greatArcIntermediaryPoint(polyline[j], polyline[j + 1], r);\n }\n\n consumed += lengths[j];\n }\n\n // this never happens\n return polyline[Math.round(polyline.length / 2)];\n}\n","import * as THREE from 'three';\nimport { CONSTANTS, PSVError, SYSTEM, utils } from '../..';\nimport { getShortestArc, logWarn } from '../../utils';\nimport { MARKER_DATA, SVG_NS } from './constants';\nimport { getPolygonCenter, getPolylineCenter } from './utils';\n\n/**\n * @summary Types of marker\n * @memberOf PSV.plugins.MarkersPlugin\n * @enum {string}\n * @constant\n * @private\n */\nconst MARKER_TYPES = {\n image : 'image',\n imageLayer : 'imageLayer',\n html : 'html',\n polygonPx : 'polygonPx',\n polygonRad : 'polygonRad',\n polylinePx : 'polylinePx',\n polylineRad: 'polylineRad',\n square : 'square',\n rect : 'rect',\n circle : 'circle',\n ellipse : 'ellipse',\n path : 'path',\n};\n\n/**\n * @typedef {Object} PSV.plugins.MarkersPlugin.Properties\n * @summary Marker properties, see {@link https://photo-sphere-viewer.js.org/plugins/plugin-markers.html#markers-options}\n */\n\n/**\n * @summary Object representing a marker\n * @memberOf PSV.plugins.MarkersPlugin\n */\nexport class Marker {\n\n /**\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @param {PSV.Viewer} psv\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n constructor(properties, psv) {\n if (!properties.id) {\n throw new PSVError('missing marker id');\n }\n\n /**\n * @member {PSV.Viewer}\n * @readonly\n * @protected\n */\n this.psv = psv;\n\n /**\n * @member {string}\n * @readonly\n */\n this.id = properties.id;\n\n /**\n * @member {string}\n * @readonly\n */\n this.type = Marker.getType(properties, false);\n\n /**\n * @member {boolean}\n * @protected\n */\n this.visible = true;\n\n /**\n * @member {HTMLElement|SVGElement|THREE.Object3D}\n * @readonly\n */\n this.$el = null;\n\n /**\n * @summary Original configuration of the marker\n * @member {PSV.plugins.MarkersPlugin.Properties}\n * @readonly\n */\n this.config = {};\n\n /**\n * @summary User data associated to the marker\n * @member {any}\n */\n this.data = undefined;\n\n /**\n * @summary Tooltip instance for this marker\n * @member {PSV.components.Tooltip}\n */\n this.tooltip = null;\n\n /**\n * @summary Computed properties\n * @member {Object}\n * @protected\n * @property {boolean} dynamicSize\n * @property {PSV.Point} anchor\n * @property {PSV.Position} position - position in spherical coordinates\n * @property {PSV.Point} position2D - position in viewer coordinates\n * @property {external:THREE.Vector3[]} positions3D - positions in 3D space\n * @property {number} width\n * @property {number} height\n * @property {*} def\n */\n this.props = {\n dynamicSize: false,\n anchor : null,\n position : null,\n position2D : null,\n positions3D: null,\n width : null,\n height : null,\n def : null,\n };\n\n /**\n * @summary THREE file loader\n * @type {THREE:TextureLoader}\n * @private\n */\n this.loader = null;\n\n if (this.is3d()) {\n this.loader = new THREE.TextureLoader();\n if (this.psv.config.withCredentials) {\n this.loader.setWithCredentials(true);\n }\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'object') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders);\n }\n }\n\n // create element\n if (this.isNormal()) {\n this.$el = document.createElement('div');\n }\n else if (this.isPolygon()) {\n this.$el = document.createElementNS(SVG_NS, 'polygon');\n }\n else if (this.isPolyline()) {\n this.$el = document.createElementNS(SVG_NS, 'polyline');\n }\n else if (this.isSvg()) {\n this.$el = document.createElementNS(SVG_NS, this.type);\n }\n\n if (!this.is3d()) {\n this.$el.id = `psv-marker-${this.id}`;\n this.$el[MARKER_DATA] = this;\n }\n\n this.update(properties);\n }\n\n /**\n * @summary Destroys the marker\n */\n destroy() {\n delete this.$el[MARKER_DATA];\n delete this.$el;\n delete this.config;\n delete this.props;\n delete this.psv;\n }\n\n /**\n * @summary Checks if it is a 3D marker (imageLayer)\n * @returns {boolean}\n */\n is3d() {\n return this.type === MARKER_TYPES.imageLayer;\n }\n\n /**\n * @summary Checks if it is a normal marker (image or html)\n * @returns {boolean}\n */\n isNormal() {\n return this.type === MARKER_TYPES.image\n || this.type === MARKER_TYPES.html;\n }\n\n /**\n * @summary Checks if it is a polygon/polyline marker\n * @returns {boolean}\n */\n isPoly() {\n return this.isPolygon()\n || this.isPolyline();\n }\n\n /**\n * @summary Checks if it is a polygon/polyline using pixel coordinates\n * @returns {boolean}\n */\n isPolyPx() {\n return this.type === MARKER_TYPES.polygonPx\n || this.type === MARKER_TYPES.polylinePx;\n }\n\n /**\n * @summary Checks if it is a polygon/polyline using radian coordinates\n * @returns {boolean}\n */\n isPolyRad() {\n return this.type === MARKER_TYPES.polygonRad\n || this.type === MARKER_TYPES.polylineRad;\n }\n\n /**\n * @summary Checks if it is a polygon marker\n * @returns {boolean}\n */\n isPolygon() {\n return this.type === MARKER_TYPES.polygonPx\n || this.type === MARKER_TYPES.polygonRad;\n }\n\n /**\n * @summary Checks if it is a polyline marker\n * @returns {boolean}\n */\n isPolyline() {\n return this.type === MARKER_TYPES.polylinePx\n || this.type === MARKER_TYPES.polylineRad;\n }\n\n /**\n * @summary Checks if it is an SVG marker\n * @returns {boolean}\n */\n isSvg() {\n return this.type === MARKER_TYPES.square\n || this.type === MARKER_TYPES.rect\n || this.type === MARKER_TYPES.circle\n || this.type === MARKER_TYPES.ellipse\n || this.type === MARKER_TYPES.path;\n }\n\n /**\n * @summary Computes marker scale from zoom level\n * @param {number} zoomLevel\n * @param {PSV.Position} position\n * @returns {number}\n */\n getScale(zoomLevel, position) {\n if (!this.config.scale) {\n return 1;\n }\n if (typeof this.config.scale === 'function') {\n return this.config.scale(zoomLevel, position);\n }\n\n let scale = 1;\n if (Array.isArray(this.config.scale.zoom)) {\n const bounds = this.config.scale.zoom;\n scale *= bounds[0] + (bounds[1] - bounds[0]) * CONSTANTS.EASINGS.inQuad(zoomLevel / 100);\n }\n if (Array.isArray(this.config.scale.longitude)) {\n const bounds = this.config.scale.longitude;\n const halfFov = THREE.Math.degToRad(this.psv.prop.hFov) / 2;\n const arc = Math.abs(getShortestArc(this.props.position.longitude, position.longitude));\n scale *= bounds[1] + (bounds[0] - bounds[1]) * CONSTANTS.EASINGS.outQuad(Math.max(0, (halfFov - arc) / halfFov));\n }\n return scale;\n }\n\n /**\n * @summary Returns the markers list content for the marker, it can be either :\n * - the `listContent`\n * - the `tooltip.content`\n * - the `html`\n * - the `id`\n * @returns {*}\n */\n getListContent() {\n if (this.config.listContent) {\n return this.config.listContent;\n }\n else if (this.config.tooltip?.content) {\n return this.config.tooltip.content;\n }\n else if (this.config.html) {\n return this.config.html;\n }\n else {\n return this.id;\n }\n }\n\n /**\n * @summary Display the tooltip of this marker\n * @param {{clientX: number, clientY: number}} [mousePosition]\n */\n showTooltip(mousePosition) {\n if (this.visible && this.config.tooltip?.content && this.props.position2D) {\n const config = {\n content : this.config.tooltip.content,\n position: this.config.tooltip.position,\n data : this,\n };\n\n if (this.isPoly()) {\n const viewerPos = utils.getPosition(this.psv.container);\n\n config.box = { // separate the tooltip from the cursor\n width : this.psv.tooltip.size.arrow * 2,\n height: this.psv.tooltip.size.arrow * 2,\n };\n\n if (mousePosition) {\n config.top = mousePosition.clientY - viewerPos.top - this.psv.tooltip.size.arrow / 2;\n config.left = mousePosition.clientX - viewerPos.left - this.psv.tooltip.size.arrow;\n }\n else {\n config.top = this.props.position2D.y;\n config.left = this.props.position2D.x;\n }\n }\n else {\n config.top = this.props.position2D.y;\n config.left = this.props.position2D.x;\n config.box = {\n width : this.props.width,\n height: this.props.height,\n };\n }\n\n if (this.tooltip) {\n this.tooltip.move(config);\n }\n else {\n this.tooltip = this.psv.tooltip.create(config);\n }\n }\n }\n\n /**\n * @summary Hides the tooltip of this marker\n */\n hideTooltip() {\n if (this.tooltip) {\n this.tooltip.hide();\n this.tooltip = null;\n }\n }\n\n /**\n * @summary Updates the marker with new properties\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n update(properties) {\n const newType = Marker.getType(properties, true);\n\n if (newType !== undefined && newType !== this.type) {\n throw new PSVError('cannot change marker type');\n }\n\n utils.deepmerge(this.config, properties);\n if (typeof this.config.tooltip === 'string') {\n this.config.tooltip = { content: this.config.tooltip };\n }\n\n this.data = this.config.data;\n this.visible = this.config.visible !== false;\n\n if (!this.is3d()) {\n // reset CSS class\n if (this.isNormal()) {\n this.$el.setAttribute('class', 'psv-marker psv-marker--normal');\n }\n else {\n this.$el.setAttribute('class', 'psv-marker psv-marker--svg');\n }\n\n // add CSS classes\n if (this.config.className) {\n utils.addClasses(this.$el, this.config.className);\n }\n\n if (this.config.tooltip) {\n utils.addClasses(this.$el, 'psv-marker--has-tooltip');\n }\n if (this.config.content) {\n utils.addClasses(this.$el, 'psv-marler--has-content');\n }\n\n // apply style\n this.$el.style.opacity = this.config.opacity ?? 1;\n if (this.config.style) {\n utils.deepmerge(this.$el.style, this.config.style);\n }\n }\n\n // parse anchor\n this.props.anchor = utils.parsePosition(this.config.anchor);\n\n // clean scale\n if (this.config.scale) {\n if (typeof this.config.scale === 'number') {\n logWarn('Single value marker scale is deprecated, please use an array of two values.');\n this.config.scale = { zoom: [0, this.config.scale] };\n }\n if (Array.isArray(this.config.scale)) {\n this.config.scale = { zoom: this.config.scale };\n }\n }\n\n if (this.isNormal()) {\n this.__updateNormal();\n }\n else if (this.isPoly()) {\n this.__updatePoly();\n }\n else if (this.isSvg()) {\n this.__updateSvg();\n }\n else if (this.is3d()) {\n this.__update3d();\n }\n }\n\n /**\n * @summary Updates a normal marker\n * @private\n */\n __updateNormal() {\n if (!utils.isExtendedPosition(this.config)) {\n throw new PSVError('missing marker position, latitude/longitude or x/y');\n }\n\n if (this.config.image && (!this.config.width || !this.config.height)) {\n throw new PSVError('missing marker width/height');\n }\n\n if (this.config.width && this.config.height) {\n this.props.dynamicSize = false;\n this.props.width = this.config.width;\n this.props.height = this.config.height;\n this.$el.style.width = this.config.width + 'px';\n this.$el.style.height = this.config.height + 'px';\n }\n else {\n this.props.dynamicSize = true;\n }\n\n if (this.config.image) {\n this.props.def = this.config.image;\n this.$el.style.backgroundImage = `url(${this.config.image})`;\n }\n else if (this.config.html) {\n this.props.def = this.config.html;\n this.$el.innerHTML = this.config.html;\n }\n\n // set anchor\n this.$el.style.transformOrigin = `${this.props.anchor.x * 100}% ${this.props.anchor.y * 100}%`;\n\n // convert texture coordinates to spherical coordinates\n this.props.position = this.psv.dataHelper.cleanPosition(this.config);\n\n // compute x/y/z position\n this.props.positions3D = [this.psv.dataHelper.sphericalCoordsToVector3(this.props.position)];\n }\n\n /**\n * @summary Updates an SVG marker\n * @private\n */\n __updateSvg() {\n if (!utils.isExtendedPosition(this.config)) {\n throw new PSVError('missing marker position, latitude/longitude or x/y');\n }\n\n this.props.dynamicSize = true;\n\n // set content\n switch (this.type) {\n case MARKER_TYPES.square:\n this.props.def = {\n x : 0,\n y : 0,\n width : this.config.square,\n height: this.config.square,\n };\n break;\n\n case MARKER_TYPES.rect:\n if (Array.isArray(this.config.rect)) {\n this.props.def = {\n x : 0,\n y : 0,\n width : this.config.rect[0],\n height: this.config.rect[1],\n };\n }\n else {\n this.props.def = {\n x : 0,\n y : 0,\n width : this.config.rect.width,\n height: this.config.rect.height,\n };\n }\n break;\n\n case MARKER_TYPES.circle:\n this.props.def = {\n cx: this.config.circle,\n cy: this.config.circle,\n r : this.config.circle,\n };\n break;\n\n case MARKER_TYPES.ellipse:\n if (Array.isArray(this.config.ellipse)) {\n this.props.def = {\n cx: this.config.ellipse[0],\n cy: this.config.ellipse[1],\n rx: this.config.ellipse[0],\n ry: this.config.ellipse[1],\n };\n }\n else {\n this.props.def = {\n cx: this.config.ellipse.rx,\n cy: this.config.ellipse.ry,\n rx: this.config.ellipse.rx,\n ry: this.config.ellipse.ry,\n };\n }\n break;\n\n case MARKER_TYPES.path:\n this.props.def = {\n d: this.config.path,\n };\n break;\n\n // no default\n }\n\n utils.each(this.props.def, (value, prop) => {\n this.$el.setAttributeNS(null, prop, value);\n });\n\n // set style\n if (this.config.svgStyle) {\n utils.each(this.config.svgStyle, (value, prop) => {\n this.$el.setAttributeNS(null, utils.dasherize(prop), value);\n });\n }\n else {\n this.$el.setAttributeNS(null, 'fill', 'rgba(0,0,0,0.5)');\n }\n\n // convert texture coordinates to spherical coordinates\n this.props.position = this.psv.dataHelper.cleanPosition(this.config);\n\n // compute x/y/z position\n this.props.positions3D = [this.psv.dataHelper.sphericalCoordsToVector3(this.props.position)];\n }\n\n /**\n * @summary Updates a polygon marker\n * @private\n */\n __updatePoly() {\n this.props.dynamicSize = true;\n\n // set style\n if (this.config.svgStyle) {\n utils.each(this.config.svgStyle, (value, prop) => {\n this.$el.setAttributeNS(null, utils.dasherize(prop), value);\n });\n\n if (this.isPolyline() && !this.config.svgStyle.fill) {\n this.$el.setAttributeNS(null, 'fill', 'none');\n }\n }\n else if (this.isPolygon()) {\n this.$el.setAttributeNS(null, 'fill', 'rgba(0,0,0,0.5)');\n }\n else if (this.isPolyline()) {\n this.$el.setAttributeNS(null, 'fill', 'none');\n this.$el.setAttributeNS(null, 'stroke', 'rgb(0,0,0)');\n }\n\n // fold arrays: [1,2,3,4] => [[1,2],[3,4]]\n const actualPoly = this.config.polygonPx || this.config.polygonRad || this.config.polylinePx || this.config.polylineRad;\n if (!Array.isArray(actualPoly[0])) {\n for (let i = 0; i < actualPoly.length; i++) {\n actualPoly.splice(i, 2, [actualPoly[i], actualPoly[i + 1]]);\n }\n }\n\n // convert texture coordinates to spherical coordinates\n if (this.isPolyPx()) {\n this.props.def = actualPoly.map((coord) => {\n const sphericalCoords = this.psv.dataHelper.textureCoordsToSphericalCoords({ x: coord[0], y: coord[1] });\n return [sphericalCoords.longitude, sphericalCoords.latitude];\n });\n }\n // clean angles\n else {\n this.props.def = actualPoly.map((coord) => {\n return [utils.parseAngle(coord[0]), utils.parseAngle(coord[1], true)];\n });\n }\n\n const centroid = this.isPolygon()\n ? getPolygonCenter(this.props.def)\n : getPolylineCenter(this.props.def);\n\n this.props.position = {\n longitude: centroid[0],\n latitude : centroid[1],\n };\n\n // compute x/y/z positions\n this.props.positions3D = this.props.def.map((coord) => {\n return this.psv.dataHelper.sphericalCoordsToVector3({ longitude: coord[0], latitude : coord[1] });\n });\n }\n\n /**\n * @summary Updates a 3D marker\n * @private\n */\n __update3d() {\n if (!this.config.width || !this.config.height) {\n throw new PSVError('missing marker width/height');\n }\n\n this.props.dynamicSize = false;\n this.props.width = this.config.width;\n this.props.height = this.config.height;\n\n // convert texture coordinates to spherical coordinates\n this.props.position = this.psv.dataHelper.cleanPosition(this.config);\n\n // compute x/y/z position\n this.props.positions3D = [this.psv.dataHelper.sphericalCoordsToVector3(this.props.position)];\n\n switch (this.type) {\n case MARKER_TYPES.imageLayer:\n if (!this.$el) {\n const material = new THREE.MeshBasicMaterial({\n transparent: true,\n opacity : this.config.opacity ?? 1,\n depthTest : false,\n });\n const geometry = new THREE.PlaneGeometry(1, 1);\n const mesh = new THREE.Mesh(geometry, material);\n mesh.userData = { [MARKER_DATA]: this };\n this.$el = new THREE.Group().add(mesh);\n\n // overwrite the visible property to be tied to the Marker instance\n // and do it without context bleed\n Object.defineProperty(this.$el, 'visible', {\n enumerable: true,\n get : function () {\n return this.children[0].userData[MARKER_DATA].visible;\n },\n set : function (visible) {\n this.children[0].userData[MARKER_DATA].visible = visible;\n },\n });\n }\n\n if (this.props.def !== this.config.imageLayer) {\n if (this.psv.config.requestHeaders && typeof this.psv.config.requestHeaders === 'function') {\n this.loader.setRequestHeader(this.psv.config.requestHeaders(this.config.imageLayer));\n }\n this.$el.children[0].material.map = this.loader.load(this.config.imageLayer, (texture) => {\n texture.anisotropy = 4;\n this.psv.needsUpdate();\n });\n this.props.def = this.config.imageLayer;\n }\n\n this.$el.children[0].position.set(\n this.props.anchor.x - 0.5,\n this.props.anchor.y - 0.5,\n 0\n );\n\n this.$el.position.copy(this.props.positions3D[0]);\n\n switch (this.config.orientation) {\n case 'horizontal':\n this.$el.lookAt(0, this.$el.position.y, 0);\n this.$el.rotateX(this.props.position.latitude < 0 ? -Math.PI / 2 : Math.PI / 2);\n break;\n case 'vertical-left':\n this.$el.lookAt(0, 0, 0);\n this.$el.rotateY(-Math.PI * 0.4);\n break;\n case 'vertical-right':\n this.$el.lookAt(0, 0, 0);\n this.$el.rotateY(Math.PI * 0.4);\n break;\n default:\n this.$el.lookAt(0, 0, 0);\n break;\n }\n\n // 100 is magic number that gives a coherent size at default zoom level\n this.$el.scale.set(this.config.width / 100 * SYSTEM.pixelRatio, this.config.height / 100 * SYSTEM.pixelRatio, 1);\n break;\n\n // no default\n }\n }\n\n /**\n * @summary Determines the type of a marker by the available properties\n * @param {Marker.Properties} properties\n * @param {boolean} [allowNone=false]\n * @returns {string}\n * @throws {PSV.PSVError} when the marker's type cannot be found\n */\n static getType(properties, allowNone = false) {\n const found = [];\n\n utils.each(MARKER_TYPES, (type) => {\n if (properties[type]) {\n found.push(type);\n }\n });\n\n if (found.length === 0 && !allowNone) {\n throw new PSVError(`missing marker content, either ${Object.keys(MARKER_TYPES).join(', ')}`);\n }\n else if (found.length > 1) {\n throw new PSVError(`multiple marker content, either ${Object.keys(MARKER_TYPES).join(', ')}`);\n }\n\n return found[0];\n }\n\n}\n","import { AbstractButton } from '../..';\nimport { EVENTS } from './constants';\nimport pin from './pin.svg';\n\n/**\n * @summary Navigation bar markers button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class MarkersButton extends AbstractButton {\n\n static id = 'markers';\n static icon = pin;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-markers-button', true);\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n */\n this.plugin = this.psv.getPlugin('markers');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.SHOW_MARKERS, this);\n this.plugin.on(EVENTS.HIDE_MARKERS, this);\n\n this.toggleActive(true);\n }\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.SHOW_MARKERS, this);\n this.plugin.off(EVENTS.HIDE_MARKERS, this);\n }\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case EVENTS.SHOW_MARKERS: this.toggleActive(true); break;\n case EVENTS.HIDE_MARKERS: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles markers\n */\n onClick() {\n if (this.plugin.prop.visible) {\n this.plugin.hide();\n }\n else {\n this.plugin.show();\n }\n }\n\n}\n","import { AbstractButton, CONSTANTS } from '../..';\nimport { ID_PANEL_MARKERS_LIST } from './constants';\nimport pinList from './pin-list.svg';\n\n/**\n * @summary Navigation bar markers list button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class MarkersListButton extends AbstractButton {\n\n static id = 'markersList';\n static icon = pinList;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-markers-list-button', true);\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n */\n this.plugin = this.psv.getPlugin('markers');\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.on(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n }\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.off(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case CONSTANTS.EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === ID_PANEL_MARKERS_LIST); break;\n case CONSTANTS.EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles markers list\n */\n onClick() {\n this.plugin.toggleMarkersList();\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport {\n EVENTS,\n ID_PANEL_MARKER,\n ID_PANEL_MARKERS_LIST,\n MARKER_DATA,\n MARKERS_LIST_TEMPLATE,\n SVG_NS\n} from './constants';\nimport { Marker } from './Marker';\nimport { MarkersButton } from './MarkersButton';\nimport { MarkersListButton } from './MarkersListButton';\nimport './style.scss';\n\n\n/**\n * @typedef {Object} PSV.plugins.MarkersPlugin.Options\n * @property {boolean} [clickEventOnMarker=false] If a `click` event is triggered on the viewer additionally to the `select-marker` event.\n * @property {PSV.plugins.MarkersPlugin.Properties[]} [markers]\n */\n\n/**\n * @typedef {Object} PSV.plugins.MarkersPlugin.SelectMarkerData\n * @summary Data of the `select-marker` event\n * @property {boolean} dblclick - if the selection originated from a double click, the simple click is always fired before the double click\n * @property {boolean} rightclick - if the selection originated from a right click\n */\n\n\n// add markers buttons\nDEFAULTS.lang[MarkersButton.id] = 'Markers';\nDEFAULTS.lang[MarkersListButton.id] = 'Markers list';\nregisterButton(MarkersButton, 'caption:left');\nregisterButton(MarkersListButton, 'caption:left');\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Displays various markers on the viewer\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class MarkersPlugin extends AbstractPlugin {\n\n static id = 'markers';\n\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.MarkersPlugin.Options} [options]\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @summary All registered markers\n * @member {Object}\n */\n this.markers = {};\n\n /**\n * @type {Object}\n * @property {boolean} visible - Visibility of the component\n * @property {PSV.plugins.MarkersPlugin.Marker} currentMarker - Last selected marker\n * @property {PSV.plugins.MarkersPlugin.Marker} hoveringMarker - Marker under the cursor\n * @private\n */\n this.prop = {\n visible : true,\n currentMarker : null,\n hoveringMarker: null,\n stopObserver : null,\n };\n\n /**\n * @type {PSV.plugins.MarkersPlugin.Options}\n */\n this.config = {\n clickEventOnMarker: false,\n ...options,\n };\n\n if (options?.listButton === false || options?.hideButton === false) {\n utils.logWarn('MarkersPlugin: listButton and hideButton options are deprecated. '\n + 'Please define the global navbar options according to your needs.');\n }\n\n /**\n * @member {HTMLElement}\n * @readonly\n */\n this.container = document.createElement('div');\n this.container.className = 'psv-markers';\n this.container.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n\n /**\n * @member {SVGElement}\n * @readonly\n */\n this.svgContainer = document.createElementNS(SVG_NS, 'svg');\n this.svgContainer.setAttribute('class', 'psv-markers-svg-container');\n this.container.appendChild(this.svgContainer);\n\n // Markers events via delegation\n this.container.addEventListener('mouseenter', this, true);\n this.container.addEventListener('mouseleave', this, true);\n this.container.addEventListener('mousemove', this, true);\n this.container.addEventListener('contextmenu', this);\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.psv.container.appendChild(this.container);\n\n // Viewer events\n this.psv.on(CONSTANTS.EVENTS.CLICK, this);\n this.psv.on(CONSTANTS.EVENTS.DOUBLE_CLICK, this);\n this.psv.on(CONSTANTS.EVENTS.RENDER, this);\n this.psv.on(CONSTANTS.EVENTS.CONFIG_CHANGED, this);\n\n if (this.config.markers) {\n this.psv.once(CONSTANTS.EVENTS.READY, () => {\n this.setMarkers(this.config.markers);\n delete this.config.markers;\n });\n }\n }\n\n /**\n * @package\n */\n destroy() {\n this.clearMarkers(false);\n\n this.prop.stopObserver?.();\n\n this.psv.off(CONSTANTS.EVENTS.CLICK, this);\n this.psv.off(CONSTANTS.EVENTS.DOUBLE_CLICK, this);\n this.psv.off(CONSTANTS.EVENTS.RENDER, this);\n this.psv.off(CONSTANTS.EVENTS.CONFIG_CHANGED, this);\n\n this.psv.container.removeChild(this.container);\n\n delete this.svgContainer;\n delete this.markers;\n delete this.container;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case 'mouseenter': this.__onMouseEnter(e, this.__getTargetMarker(e.target)); break;\n case 'mouseleave': this.__onMouseLeave(e, this.__getTargetMarker(e.target)); break;\n case 'mousemove': this.__onMouseMove(e, this.__getTargetMarker(e.target)); break;\n case 'contextmenu': e.preventDefault(); break;\n case CONSTANTS.EVENTS.CLICK: this.__onClick(e, e.args[0], false); break;\n case CONSTANTS.EVENTS.DOUBLE_CLICK: this.__onClick(e, e.args[0], true); break;\n case CONSTANTS.EVENTS.RENDER: this.renderMarkers(); break;\n case CONSTANTS.OBJECT_EVENTS.ENTER_OBJECT: this.__onMouseEnter(e.detail.originalEvent, e.detail.data); break;\n case CONSTANTS.OBJECT_EVENTS.LEAVE_OBJECT: this.__onMouseLeave(e.detail.originalEvent, e.detail.data); break;\n case CONSTANTS.OBJECT_EVENTS.HOVER_OBJECT: this.__onMouseMove(e.detail.originalEvent, e.detail.data); break;\n case CONSTANTS.EVENTS.CONFIG_CHANGED:\n this.container.style.cursor = this.psv.config.mousemove ? 'move' : 'default';\n break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @summary Shows all markers\n * @fires PSV.plugins.MarkersPlugin.show-markers\n */\n show() {\n this.prop.visible = true;\n\n this.renderMarkers();\n\n this.trigger(EVENTS.SHOW_MARKERS);\n }\n\n /**\n * @summary Hides all markers\n * @fires PSV.plugins.MarkersPlugin.hide-markers\n */\n hide() {\n this.prop.visible = false;\n\n this.renderMarkers();\n\n this.trigger(EVENTS.HIDE_MARKERS);\n }\n\n /**\n * @summary Toggles the visibility of all tooltips\n */\n toggleAllTooltips() {\n this.prop.showAllTooltips = !this.prop.showAllTooltips;\n this.renderMarkers();\n }\n\n /**\n * @summary Displays all tooltips\n */\n showAllTooltips() {\n this.prop.showAllTooltips = true;\n this.renderMarkers();\n }\n\n /**\n * @summary Hides all tooltips\n */\n hideAllTooltips() {\n this.prop.showAllTooltips = false;\n this.renderMarkers();\n }\n\n /**\n * @summary Returns the total number of markers\n * @returns {number}\n */\n getNbMarkers() {\n return Object.keys(this.markers).length;\n }\n\n /**\n * @summary Returns all the markers\n * @return {PSV.plugins.MarkersPlugin.Marker[]}\n */\n getMarkers() {\n return Object.values(this.markers);\n }\n\n /**\n * @summary Adds a new marker to viewer\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @param {boolean} [render=true] - renders the marker immediately\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n * @throws {PSV.PSVError} when the marker's id is missing or already exists\n */\n addMarker(properties, render = true) {\n if (this.markers[properties.id]) {\n throw new PSVError(`marker \"${properties.id}\" already exists`);\n }\n\n const marker = new Marker(properties, this.psv);\n\n if (marker.isNormal()) {\n this.container.appendChild(marker.$el);\n }\n else if (marker.isPoly() || marker.isSvg()) {\n this.svgContainer.appendChild(marker.$el);\n }\n else if (marker.is3d()) {\n this.psv.renderer.scene.add(marker.$el);\n }\n\n this.markers[marker.id] = marker;\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n\n return marker;\n }\n\n /**\n * @summary Returns the internal marker object for a marker id\n * @param {string} markerId\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n * @throws {PSV.PSVError} when the marker cannot be found\n */\n getMarker(markerId) {\n const id = typeof markerId === 'object' ? markerId.id : markerId;\n\n if (!this.markers[id]) {\n throw new PSVError(`cannot find marker \"${id}\"`);\n }\n\n return this.markers[id];\n }\n\n /**\n * @summary Returns the last marker selected by the user\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n */\n getCurrentMarker() {\n return this.prop.currentMarker;\n }\n\n /**\n * @summary Updates the existing marker with the same id\n * @description Every property can be changed but you can't change its type (Eg: `image` to `html`).\n * @param {PSV.plugins.MarkersPlugin.Properties} properties\n * @param {boolean} [render=true] - renders the marker immediately\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n */\n updateMarker(properties, render = true) {\n const marker = this.getMarker(properties.id);\n\n marker.update(properties);\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n\n if (marker.is3d()) {\n this.psv.needsUpdate();\n }\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n\n return marker;\n }\n\n /**\n * @summary Removes a marker from the viewer\n * @param {string} markerId\n * @param {boolean} [render=true] - renders the marker immediately\n */\n removeMarker(markerId, render = true) {\n const marker = this.getMarker(markerId);\n\n if (marker.isNormal()) {\n this.container.removeChild(marker.$el);\n }\n else if (marker.isPoly() || marker.isSvg()) {\n this.svgContainer.removeChild(marker.$el);\n }\n else if (marker.is3d()) {\n this.psv.renderer.scene.remove(marker.$el);\n this.psv.needsUpdate();\n }\n\n if (this.prop.hoveringMarker === marker) {\n this.prop.hoveringMarker = null;\n }\n\n if (this.prop.currentMarker === marker) {\n this.prop.currentMarker = null;\n }\n\n marker.hideTooltip();\n\n marker.destroy();\n delete this.markers[marker.id];\n\n if (render) {\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Removes multiple markers\n * @param {string[]} markerIds\n * @param {boolean} [render=true] - renders the markers immediately\n */\n removeMarkers(markerIds, render = true) {\n markerIds.forEach(markerId => this.removeMarker(markerId, false));\n\n if (render) {\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Replaces all markers\n * @param {PSV.plugins.MarkersPlugin.Properties[]} markers\n * @param {boolean} [render=true] - renders the marker immediately\n */\n setMarkers(markers, render = true) {\n this.clearMarkers(false);\n\n utils.each(markers, marker => this.addMarker(marker, false));\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Removes all markers\n * @param {boolean} [render=true] - renders the markers immediately\n */\n clearMarkers(render = true) {\n utils.each(this.markers, marker => this.removeMarker(marker, false));\n\n if (render) {\n this.renderMarkers();\n this.__refreshUi();\n this.__checkObjectsObserver();\n\n this.trigger(EVENTS.SET_MARKERS, this.getMarkers());\n }\n }\n\n /**\n * @summary Rotate the view to face the marker\n * @param {string} markerId\n * @param {string|number} [speed] - rotates smoothy, see {@link PSV.Viewer#animate}\n * @fires PSV.plugins.MarkersPlugin.goto-marker-done\n * @return {PSV.Animation} A promise that will be resolved when the animation finishes\n */\n gotoMarker(markerId, speed) {\n const marker = this.getMarker(markerId);\n\n return this.psv.animate({\n ...marker.props.position,\n speed,\n })\n .then(() => {\n this.trigger(EVENTS.GOTO_MARKER_DONE, marker);\n });\n }\n\n /**\n * @summary Hides a marker\n * @param {string} markerId\n */\n hideMarker(markerId) {\n this.toggleMarker(markerId, false);\n }\n\n /**\n * @summary Shows a marker\n * @param {string} markerId\n */\n showMarker(markerId) {\n this.toggleMarker(markerId, true);\n }\n\n /**\n * @summary Toggles a marker\n * @param {string} markerId\n * @param {boolean} [visible]\n */\n toggleMarker(markerId, visible = null) {\n const marker = this.getMarker(markerId);\n marker.visible = visible === null ? !marker.visible : visible;\n if (marker.is3d()) {\n this.psv.needsUpdate();\n }\n else {\n this.renderMarkers();\n }\n }\n\n /**\n * @summary Opens the panel with the content of the marker\n * @param {string} markerId\n */\n showMarkerPanel(markerId) {\n const marker = this.getMarker(markerId);\n\n if (marker?.config?.content) {\n this.psv.panel.show({\n id : ID_PANEL_MARKER,\n content: marker.config.content,\n });\n }\n else {\n this.psv.panel.hide(ID_PANEL_MARKER);\n }\n }\n\n /**\n * @summary Toggles the visibility of the list of markers\n */\n toggleMarkersList() {\n if (this.psv.panel.prop.contentId === ID_PANEL_MARKERS_LIST) {\n this.hideMarkersList();\n }\n else {\n this.showMarkersList();\n }\n }\n\n /**\n * @summary Opens side panel with the list of markers\n * @fires PSV.plugins.MarkersPlugin.filter:render-markers-list\n */\n showMarkersList() {\n let markers = [];\n utils.each(this.markers, (marker) => {\n if (marker.visible && !marker.config.hideList) {\n markers.push(marker);\n }\n });\n\n markers = this.change(EVENTS.RENDER_MARKERS_LIST, markers);\n\n this.psv.panel.show({\n id : ID_PANEL_MARKERS_LIST,\n content : MARKERS_LIST_TEMPLATE(\n markers,\n this.psv.config.lang[MarkersButton.id],\n utils.dasherize(MARKER_DATA)\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const markerId = li ? li.dataset[MARKER_DATA] : undefined;\n\n if (markerId) {\n const marker = this.getMarker(markerId);\n\n this.trigger(EVENTS.SELECT_MARKER_LIST, marker);\n\n this.gotoMarker(marker, 1000);\n this.hideMarkersList();\n }\n },\n });\n }\n\n /**\n * @summary Closes side panel if it contains the list of markers\n */\n hideMarkersList() {\n this.psv.panel.hide(ID_PANEL_MARKERS_LIST);\n }\n\n /**\n * @summary Updates the visibility and the position of all markers\n */\n renderMarkers() {\n const zoomLevel = this.psv.getZoomLevel();\n const viewerPosition = this.psv.getPosition();\n\n utils.each(this.markers, (marker) => {\n let isVisible = this.prop.visible && marker.visible;\n let position = null;\n\n if (isVisible && marker.is3d()) {\n position = this.__getMarkerPosition(marker);\n isVisible = this.__isMarkerVisible(marker, position);\n }\n else if (isVisible && marker.isPoly()) {\n const positions = this.__getPolyPositions(marker);\n isVisible = positions.length > (marker.isPolygon() ? 2 : 1);\n\n if (isVisible) {\n position = this.__getMarkerPosition(marker);\n\n const points = positions.map(pos => (pos.x - position.x) + ',' + (pos.y - position.y)).join(' ');\n\n marker.$el.setAttributeNS(null, 'points', points);\n marker.$el.setAttributeNS(null, 'transform', `translate(${position.x} ${position.y})`);\n }\n }\n else if (isVisible) {\n if (marker.props.dynamicSize) {\n this.__updateMarkerSize(marker);\n }\n\n position = this.__getMarkerPosition(marker);\n isVisible = this.__isMarkerVisible(marker, position);\n\n if (isVisible) {\n const scale = marker.getScale(zoomLevel, viewerPosition);\n\n if (marker.isSvg()) {\n // simulate transform-origin relative to SVG element\n const x = position.x + marker.props.width * marker.props.anchor.x * (1 - scale);\n const y = position.y + marker.props.width * marker.props.anchor.y * (1 - scale);\n marker.$el.setAttributeNS(null, 'transform', `translate(${x}, ${y}) scale(${scale}, ${scale})`);\n }\n else {\n marker.$el.style.transform = `translate3D(${position.x}px, ${position.y}px, 0px) scale(${scale}, ${scale})`;\n }\n }\n }\n\n marker.props.position2D = isVisible ? position : null;\n\n if (!marker.is3d()) {\n utils.toggleClass(marker.$el, 'psv-marker--visible', isVisible);\n }\n\n if (isVisible && (this.prop.showAllTooltips || (marker === this.prop.hoveringMarker && !marker.isPoly()))) {\n marker.showTooltip();\n }\n else if (!isVisible || marker !== this.prop.hoveringMarker) {\n marker.hideTooltip();\n }\n });\n }\n\n /**\n * @summary Determines if a point marker is visible
\n * It tests if the point is in the general direction of the camera, then check if it's in the viewport\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @param {PSV.Point} position\n * @returns {boolean}\n * @private\n */\n __isMarkerVisible(marker, position) {\n return marker.props.positions3D[0].dot(this.psv.prop.direction) > 0\n && position.x + marker.props.width >= 0\n && position.x - marker.props.width <= this.psv.prop.size.width\n && position.y + marker.props.height >= 0\n && position.y - marker.props.height <= this.psv.prop.size.height;\n }\n\n /**\n * @summary Computes the real size of a marker\n * @description This is done by removing all it's transformations (if any) and making it visible\n * before querying its bounding rect\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @private\n */\n __updateMarkerSize(marker) {\n utils.addClasses(marker.$el, 'psv-marker--transparent');\n\n let transform;\n if (marker.isSvg()) {\n transform = marker.$el.getAttributeNS(null, 'transform');\n marker.$el.removeAttributeNS(null, 'transform');\n }\n else {\n transform = marker.$el.style.transform;\n marker.$el.style.transform = '';\n }\n\n const rect = marker.$el.getBoundingClientRect();\n marker.props.width = rect.width;\n marker.props.height = rect.height;\n\n utils.removeClasses(marker.$el, 'psv-marker--transparent');\n\n if (transform) {\n if (marker.isSvg()) {\n marker.$el.setAttributeNS(null, 'transform', transform);\n }\n else {\n marker.$el.style.transform = transform;\n }\n }\n\n // the size is no longer dynamic once known\n marker.props.dynamicSize = false;\n }\n\n /**\n * @summary Computes viewer coordinates of a marker\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @returns {PSV.Point}\n * @private\n */\n __getMarkerPosition(marker) {\n if (marker.isPoly()) {\n return this.psv.dataHelper.sphericalCoordsToViewerCoords(marker.props.position);\n }\n else {\n const position = this.psv.dataHelper.vector3ToViewerCoords(marker.props.positions3D[0]);\n\n position.x -= marker.props.width * marker.props.anchor.x;\n position.y -= marker.props.height * marker.props.anchor.y;\n\n return position;\n }\n }\n\n /**\n * @summary Computes viewer coordinates of each point of a polygon/polyline
\n * It handles points behind the camera by creating intermediary points suitable for the projector\n * @param {PSV.plugins.MarkersPlugin.Marker} marker\n * @returns {PSV.Point[]}\n * @private\n */\n __getPolyPositions(marker) {\n const nbVectors = marker.props.positions3D.length;\n\n // compute if each vector is visible\n const positions3D = marker.props.positions3D.map((vector) => {\n return {\n vector : vector,\n visible: vector.dot(this.psv.prop.direction) > 0,\n };\n });\n\n // get pairs of visible/invisible vectors for each invisible vector connected to a visible vector\n const toBeComputed = [];\n positions3D.forEach((pos, i) => {\n if (!pos.visible) {\n const neighbours = [\n i === 0 ? positions3D[nbVectors - 1] : positions3D[i - 1],\n i === nbVectors - 1 ? positions3D[0] : positions3D[i + 1],\n ];\n\n neighbours.forEach((neighbour) => {\n if (neighbour.visible) {\n toBeComputed.push({\n visible : neighbour,\n invisible: pos,\n index : i,\n });\n }\n });\n }\n });\n\n // compute intermediary vector for each pair (the loop is reversed for splice to insert at the right place)\n toBeComputed.reverse().forEach((pair) => {\n positions3D.splice(pair.index, 0, {\n vector : this.__getPolyIntermediaryPoint(pair.visible.vector, pair.invisible.vector),\n visible: true,\n });\n });\n\n // translate vectors to screen pos\n return positions3D\n .filter(pos => pos.visible)\n .map(pos => this.psv.dataHelper.vector3ToViewerCoords(pos.vector));\n }\n\n /**\n * Given one point in the same direction of the camera and one point behind the camera,\n * computes an intermediary point on the great circle delimiting the half sphere visible by the camera.\n * The point is shifted by .01 rad because the projector cannot handle points exactly on this circle.\n * TODO : does not work with fisheye view (must not use the great circle)\n * {@link http://math.stackexchange.com/a/1730410/327208}\n * @param P1 {external:THREE.Vector3}\n * @param P2 {external:THREE.Vector3}\n * @returns {external:THREE.Vector3}\n * @private\n */\n __getPolyIntermediaryPoint(P1, P2) {\n const C = this.psv.prop.direction.clone().normalize();\n const N = new THREE.Vector3().crossVectors(P1, P2).normalize();\n const V = new THREE.Vector3().crossVectors(N, P1).normalize();\n const X = P1.clone().multiplyScalar(-C.dot(V));\n const Y = V.clone().multiplyScalar(C.dot(P1));\n const H = new THREE.Vector3().addVectors(X, Y).normalize();\n const a = new THREE.Vector3().crossVectors(H, C);\n return H.applyAxisAngle(a, 0.01).multiplyScalar(CONSTANTS.SPHERE_RADIUS);\n }\n\n /**\n * @summary Returns the marker associated to an event target\n * @param {EventTarget} target\n * @param {boolean} [closest=false]\n * @returns {PSV.plugins.MarkersPlugin.Marker}\n * @private\n */\n __getTargetMarker(target, closest = false) {\n const target2 = closest ? utils.getClosest(target, '.psv-marker') : target;\n return target2 ? target2[MARKER_DATA] : undefined;\n }\n\n /**\n * @summary Checks if an event target is in the tooltip\n * @param {EventTarget} target\n * @param {PSV.components.Tooltip} tooltip\n * @returns {boolean}\n * @private\n */\n __targetOnTooltip(target, tooltip) {\n return target && tooltip ? utils.hasParent(target, tooltip.container) : false;\n }\n\n /**\n * @summary Handles mouse enter events, show the tooltip for non polygon markers\n * @param {MouseEvent} e\n * @param {PSV.plugins.MarkersPlugin.Marker} [marker]\n * @fires PSV.plugins.MarkersPlugin.over-marker\n * @private\n */\n __onMouseEnter(e, marker) {\n if (marker && !marker.isPoly()) {\n this.prop.hoveringMarker = marker;\n\n this.trigger(EVENTS.OVER_MARKER, marker);\n\n if (!this.prop.showAllTooltips) {\n marker.showTooltip(e);\n }\n }\n }\n\n /**\n * @summary Handles mouse leave events, hide the tooltip\n * @param {MouseEvent} e\n * @param {PSV.plugins.MarkersPlugin.Marker} [marker]\n * @fires PSV.plugins.MarkersPlugin.leave-marker\n * @private\n */\n __onMouseLeave(e, marker) {\n // do not hide if we enter the tooltip itself while hovering a polygon\n if (marker && !(marker.isPoly() && this.__targetOnTooltip(e.relatedTarget, marker.tooltip))) {\n this.trigger(EVENTS.LEAVE_MARKER, marker);\n\n this.prop.hoveringMarker = null;\n\n if (!this.prop.showAllTooltips) {\n marker.hideTooltip();\n }\n }\n }\n\n /**\n * @summary Handles mouse move events, refreshUi the tooltip for polygon markers\n * @param {MouseEvent} e\n * @param {PSV.plugins.MarkersPlugin.Marker} [targetMarker]\n * @fires PSV.plugins.MarkersPlugin.leave-marker\n * @fires PSV.plugins.MarkersPlugin.over-marker\n * @private\n */\n __onMouseMove(e, targetMarker) {\n let marker;\n\n if (targetMarker?.isPoly()) {\n marker = targetMarker;\n }\n // do not hide if we enter the tooltip itself while hovering a polygon\n else if (this.prop.hoveringMarker && this.__targetOnTooltip(e.target, this.prop.hoveringMarker.tooltip)) {\n marker = this.prop.hoveringMarker;\n }\n\n if (marker) {\n if (!this.prop.hoveringMarker) {\n this.trigger(EVENTS.OVER_MARKER, marker);\n\n this.prop.hoveringMarker = marker;\n }\n\n if (!this.prop.showAllTooltips) {\n marker.showTooltip(e);\n }\n }\n else if (this.prop.hoveringMarker?.isPoly()) {\n this.trigger(EVENTS.LEAVE_MARKER, this.prop.hoveringMarker);\n\n if (!this.prop.showAllTooltips) {\n this.prop.hoveringMarker.hideTooltip();\n }\n\n this.prop.hoveringMarker = null;\n }\n }\n\n /**\n * @summary Handles mouse click events, select the marker and open the panel if necessary\n * @param {Event} e\n * @param {Object} data\n * @param {boolean} dblclick\n * @fires PSV.plugins.MarkersPlugin.select-marker\n * @fires PSV.plugins.MarkersPlugin.unselect-marker\n * @private\n */\n __onClick(e, data, dblclick) {\n let marker = data.objects.find(o => o.userData[MARKER_DATA])?.userData[MARKER_DATA];\n\n if (!marker) {\n marker = this.__getTargetMarker(data.target, true);\n }\n\n if (marker) {\n this.prop.currentMarker = marker;\n\n this.trigger(EVENTS.SELECT_MARKER, marker, {\n dblclick : dblclick,\n rightclick: data.rightclick,\n });\n\n if (this.config.clickEventOnMarker) {\n // add the marker to event data\n data.marker = marker;\n }\n else {\n e.stopPropagation();\n }\n\n // the marker could have been deleted in an event handler\n if (this.markers[marker.id]) {\n this.showMarkerPanel(marker.id);\n }\n }\n else if (this.prop.currentMarker) {\n this.trigger(EVENTS.UNSELECT_MARKER, this.prop.currentMarker);\n\n this.psv.panel.hide(ID_PANEL_MARKER);\n\n this.prop.currentMarker = null;\n }\n }\n\n /**\n * @summary Updates the visiblity of the panel and the buttons\n * @private\n */\n __refreshUi() {\n const nbMarkers = Object.values(this.markers).filter(m => !m.config.hideList).length;\n const markersButton = this.psv.navbar.getButton(MarkersButton.id, false);\n const markersListButton = this.psv.navbar.getButton(MarkersListButton.id, false);\n\n if (nbMarkers === 0) {\n markersButton?.hide();\n markersListButton?.hide();\n\n if (this.psv.panel.isVisible(ID_PANEL_MARKERS_LIST)) {\n this.psv.panel.hide();\n }\n else if (this.psv.panel.isVisible(ID_PANEL_MARKER)) {\n this.psv.panel.hide();\n }\n }\n else {\n markersButton?.show();\n markersListButton?.show();\n\n if (this.psv.panel.isVisible(ID_PANEL_MARKERS_LIST)) {\n this.showMarkersList();\n }\n else if (this.psv.panel.isVisible(ID_PANEL_MARKER)) {\n this.prop.currentMarker ? this.showMarkerPanel(this.prop.currentMarker) : this.psv.panel.hide();\n }\n }\n }\n\n /**\n * @summary Adds or remove the objects observer if there are 3D markers\n * @private\n */\n __checkObjectsObserver() {\n const has3d = Object.values(this.markers).some(marker => marker.is3d());\n\n if (!has3d && this.prop.stopObserver) {\n this.prop.stopObserver();\n this.prop.stopObserver = null;\n }\n else if (has3d && !this.prop.stopObserver) {\n this.prop.stopObserver = this.psv.observeObjects(MARKER_DATA, this);\n }\n }\n\n}\n"],"names":["EVENTS","GOTO_MARKER_DONE","LEAVE_MARKER","OVER_MARKER","RENDER_MARKERS_LIST","SELECT_MARKER","SELECT_MARKER_LIST","UNSELECT_MARKER","HIDE_MARKERS","SET_MARKERS","SHOW_MARKERS","SVG_NS","MARKER_DATA","ID_PANEL_MARKER","ID_PANEL_MARKERS_LIST","MARKERS_LIST_TEMPLATE","markers","title","dataKey","icon","map","marker","config","id","type","image","getListContent","join","getShortestArc","from","to","tCandidates","Math","PI","reduce","value","candidate","newCandidate","abs","Infinity","PSVError","message","Error","captureStackTrace","stack","prototype","Object","create","name","constructor","logWarn","console","warn","THREE","Quaternion","greatArcIntermediaryPoint","p1","p2","f","λ1","φ1","λ2","φ2","r","utils","greatArcDistance","a","sin","b","x","cos","y","z","atan2","sqrt","getPolygonCenter","polygon","workPoints","k","i","length","d","push","sum","intermediary","point","parseAngle","getPolylineCenter","polyline","lengths","l","CONSTANTS","SPHERE_RADIUS","consumed","j","round","MARKER_TYPES","imageLayer","html","polygonPx","polygonRad","polylinePx","polylineRad","square","rect","circle","ellipse","path","Marker","properties","psv","getType","visible","$el","data","undefined","tooltip","props","dynamicSize","anchor","position","position2D","positions3D","width","height","def","loader","is3d","TextureLoader","withCredentials","setWithCredentials","requestHeaders","setRequestHeader","isNormal","document","createElement","isPolygon","createElementNS","isPolyline","isSvg","update","destroy","isPoly","isPolyPx","isPolyRad","getScale","zoomLevel","scale","Array","isArray","zoom","bounds","EASINGS","inQuad","longitude","halfFov","degToRad","prop","hFov","arc","outQuad","max","listContent","content","showTooltip","mousePosition","viewerPos","getPosition","container","box","size","arrow","top","clientY","left","clientX","move","hideTooltip","hide","newType","deepmerge","setAttribute","className","addClasses","style","opacity","parsePosition","__updateNormal","__updatePoly","__updateSvg","__update3d","isExtendedPosition","backgroundImage","innerHTML","transformOrigin","dataHelper","cleanPosition","sphericalCoordsToVector3","cx","cy","rx","ry","each","setAttributeNS","svgStyle","dasherize","fill","actualPoly","splice","coord","sphericalCoords","textureCoordsToSphericalCoords","latitude","centroid","material","MeshBasicMaterial","transparent","depthTest","geometry","PlaneGeometry","mesh","Mesh","userData","Group","add","defineProperty","enumerable","get","children","set","load","texture","anisotropy","needsUpdate","copy","orientation","lookAt","rotateX","rotateY","SYSTEM","pixelRatio","allowNone","found","keys","MarkersButton","navbar","plugin","getPlugin","on","toggleActive","off","isSupported","handleEvent","e","onClick","show","AbstractButton","pin","MarkersListButton","OPEN_PANEL","CLOSE_PANEL","args","toggleMarkersList","pinList","DEFAULTS","lang","registerButton","MarkersPlugin","options","currentMarker","hoveringMarker","stopObserver","clickEventOnMarker","listButton","hideButton","cursor","mousemove","svgContainer","appendChild","addEventListener","init","CLICK","DOUBLE_CLICK","RENDER","CONFIG_CHANGED","once","READY","setMarkers","clearMarkers","removeChild","__onMouseEnter","__getTargetMarker","target","__onMouseLeave","__onMouseMove","preventDefault","__onClick","renderMarkers","OBJECT_EVENTS","ENTER_OBJECT","detail","originalEvent","LEAVE_OBJECT","HOVER_OBJECT","trigger","toggleAllTooltips","showAllTooltips","hideAllTooltips","getNbMarkers","getMarkers","values","addMarker","render","renderer","scene","__refreshUi","__checkObjectsObserver","getMarker","markerId","getCurrentMarker","updateMarker","removeMarker","remove","removeMarkers","markerIds","forEach","gotoMarker","speed","animate","then","hideMarker","toggleMarker","showMarker","showMarkerPanel","panel","contentId","hideMarkersList","showMarkersList","hideList","change","noMargin","clickHandler","li","getClosest","dataset","getZoomLevel","viewerPosition","isVisible","__getMarkerPosition","__isMarkerVisible","positions","__getPolyPositions","points","pos","__updateMarkerSize","transform","toggleClass","dot","direction","getAttributeNS","removeAttributeNS","getBoundingClientRect","removeClasses","sphericalCoordsToViewerCoords","vector3ToViewerCoords","nbVectors","vector","toBeComputed","neighbours","neighbour","invisible","index","reverse","pair","__getPolyIntermediaryPoint","filter","P1","P2","C","clone","normalize","N","Vector3","crossVectors","V","X","multiplyScalar","Y","H","addVectors","applyAxisAngle","closest","target2","__targetOnTooltip","hasParent","relatedTarget","targetMarker","dblclick","objects","find","o","rightclick","stopPropagation","nbMarkers","m","markersButton","getButton","markersListButton","has3d","some","observeObjects","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,gBAAgB,EAAK,kBAPD;;EAQpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,YAAY,EAAS,cAdD;;EAepB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,WAAW,EAAU,aArBD;;EAsBpB;EACF;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,mBAAmB,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P,EAAJ;EAAA,KAAvC,CAAd;;EAEA,QAAI,CAACyR,KAAD,IAAU,KAAK3P,IAAL,CAAUkH,YAAxB,EAAsC;EACpC,WAAKlH,IAAL,CAAUkH,YAAV;EACA,WAAKlH,IAAL,CAAUkH,YAAV,GAAyB,IAAzB;EACD,KAHD,MAIK,IAAIyI,KAAK,IAAI,CAAC,KAAK3P,IAAL,CAAUkH,YAAxB,EAAsC;EACzC,WAAKlH,IAAL,CAAUkH,YAAV,GAAyB,KAAKjK,GAAL,CAAS4S,cAAT,CAAwB9Y,WAAxB,EAAqC,IAArC,CAAzB;EACD;EACF,GAx5BH;;EAAA;EAAA,EAAmC+Y,gCAAnC;EAAahJ,cAEJpP,KAAK;EAFDoP,cAIJ3Q,SAASA;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/resolution.d.ts b/dist/plugins/resolution.d.ts index 0daced467..eed07fc23 100644 --- a/dist/plugins/resolution.d.ts +++ b/dist/plugins/resolution.d.ts @@ -21,6 +21,8 @@ declare const EVENTS: { */ declare class ResolutionPlugin extends AbstractPlugin { + static EVENTS: typeof EVENTS; + constructor(psv: Viewer, options: ResolutionPluginOptions); /** diff --git a/dist/plugins/resolution.js b/dist/plugins/resolution.js index b263f1ff9..a9952e8dc 100644 --- a/dist/plugins/resolution.js +++ b/dist/plugins/resolution.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -117,10 +117,6 @@ var ResolutionPlugin = /*#__PURE__*/function (_AbstractPlugin) { _inheritsLoose(ResolutionPlugin, _AbstractPlugin); - /** - * @deprecated use the EVENTS constants of the module - */ - /** * @param {PSV.Viewer} psv * @param {PSV.plugins.ResolutionPlugin.Options} options diff --git a/dist/plugins/resolution.js.map b/dist/plugins/resolution.js.map index 7682aa0bc..57a218482 100644 --- a/dist/plugins/resolution.js.map +++ b/dist/plugins/resolution.js.map @@ -1 +1 @@ -{"version":3,"file":"resolution.js","sources":["../../src/plugins/resolution/constants.js","../../src/plugins/resolution/utils.js","../../src/plugins/resolution/index.js"],"sourcesContent":["/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.ResolutionPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event resolution-changed\n * @memberof PSV.plugins.ResolutionPlugin\n * @summary Triggered when the resolution is changed\n * @param {string} resolutionId\n */\n RESOLUTION_CHANGED: 'resolution-changed',\n};\n","/**\n * @summary Returns deep equality between objects\n * {@link https://gist.github.com/egardner/efd34f270cc33db67c0246e837689cb9}\n * @param obj1\n * @param obj2\n * @return {boolean}\n * @private\n */\nexport function deepEqual(obj1, obj2) {\n if (obj1 === obj2) {\n return true;\n }\n else if (isObject(obj1) && isObject(obj2)) {\n if (Object.keys(obj1).length !== Object.keys(obj2).length) {\n return false;\n }\n for (const prop of Object.keys(obj1)) {\n if (!deepEqual(obj1[prop], obj2[prop])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\n\nfunction isObject(obj) {\n return typeof obj === 'object' && obj != null;\n}\n","import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError } from '../..';\nimport { EVENTS } from './constants';\nimport { deepEqual } from './utils';\n\n\n/**\n * @typedef {Object} PSV.plugins.ResolutionPlugin.Resolution\n * @property {string} id\n * @property {string} label\n * @property {*} panorama\n */\n\n/**\n * @typedef {Object} PSV.plugins.ResolutionPlugin.Options\n * @property {PSV.plugins.ResolutionPlugin.Resolution[]} resolutions - list of available resolutions\n * @property {boolean} [showBadge=true] - show the resolution id as a badge on the settings button\n */\n\n\nDEFAULTS.lang.resolution = 'Quality';\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Adds a setting to choose between multiple resolutions of the panorama.\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class ResolutionPlugin extends AbstractPlugin {\n\n static id = 'resolution';\n\n /**\n * @deprecated use the EVENTS constants of the module\n */\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.ResolutionPlugin.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @type {PSV.plugins.SettingsPlugin}\n * @readonly\n * @private\n */\n this.settings = null;\n\n /**\n * @summary Available resolutions\n * @member {PSV.plugins.ResolutionPlugin.Resolution[]}\n */\n this.resolutions = [];\n\n /**\n * @summary Available resolutions\n * @member {Object.}\n * @private\n */\n this.resolutionsById = {};\n\n /**\n * @type {Object}\n * @property {string} resolution - Current resolution\n * @private\n */\n this.prop = {\n resolution: null,\n };\n\n /**\n * @type {PSV.plugins.ResolutionPlugin.Options}\n */\n this.config = {\n showBadge: true,\n ...options,\n };\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.settings = this.psv.getPlugin('settings');\n\n if (!this.settings) {\n throw new PSVError('Resolution plugin requires the Settings plugin');\n }\n\n this.settings.addSetting({\n id : ResolutionPlugin.id,\n type : 'options',\n label : this.psv.config.lang.resolution,\n current: () => this.prop.resolution,\n options: () => this.__getSettingsOptions(),\n apply : resolution => this.setResolution(resolution),\n badge : !this.config.showBadge ? null : () => this.prop.resolution,\n });\n\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n\n if (this.config.resolutions) {\n this.setResolutions(this.config.resolutions);\n delete this.config.resolutions;\n }\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n\n this.settings.removeSetting(ResolutionPlugin.id);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (e.type === CONSTANTS.EVENTS.PANORAMA_LOADED) {\n this.__refreshResolution();\n }\n }\n\n /**\n * @summary Changes the available resolutions\n * @param {PSV.plugins.ResolutionPlugin.Resolution[]} resolutions\n */\n setResolutions(resolutions) {\n this.resolutions = resolutions;\n this.resolutionsById = {};\n\n resolutions.forEach((resolution) => {\n if (!resolution.id) {\n throw new PSVError('Missing resolution id');\n }\n this.resolutionsById[resolution.id] = resolution;\n });\n\n this.__refreshResolution();\n }\n\n /**\n * @summary Changes the current resolution\n * @param {string} id\n */\n setResolution(id) {\n if (!this.resolutionsById[id]) {\n throw new PSVError(`Resolution ${id} unknown`);\n }\n\n return this.psv.setPanorama(this.resolutionsById[id].panorama, { transition: false, showLoader: false });\n }\n\n /**\n * @summary Returns the current resolution\n * @return {string}\n */\n getResolution() {\n return this.prop.resolution;\n }\n\n /**\n * @summary Updates current resolution on panorama load\n * @private\n */\n __refreshResolution() {\n const resolution = this.resolutions.find(r => deepEqual(this.psv.config.panorama, r.panorama));\n if (this.prop.resolution !== resolution?.id) {\n this.prop.resolution = resolution?.id;\n this.settings?.updateBadge();\n this.trigger(EVENTS.RESOLUTION_CHANGED, this.prop.resolution);\n }\n }\n\n /**\n * @summary Returns options for Settings plugin\n * @return {PSV.plugins.SettingsPlugin.Option[]}\n * @private\n */\n __getSettingsOptions() {\n return this.resolutions\n .map(resolution => ({\n id : resolution.id,\n label: resolution.label,\n }));\n }\n\n}\n"],"names":["EVENTS","RESOLUTION_CHANGED","deepEqual","obj1","obj2","isObject","Object","keys","length","prop","obj","DEFAULTS","lang","resolution","ResolutionPlugin","psv","options","settings","resolutions","resolutionsById","config","showBadge","init","getPlugin","PSVError","addSetting","id","type","label","current","__getSettingsOptions","apply","setResolution","badge","on","CONSTANTS","PANORAMA_LOADED","setResolutions","destroy","off","removeSetting","handleEvent","e","__refreshResolution","forEach","setPanorama","panorama","transition","showLoader","getResolution","find","r","updateBadge","trigger","map","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,kBAAkB,EAAE;EAPA;;ECNtB;EACA;EACA;E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MAAAA,UAAU,EAAE,KAAd;EAAqBC,MAAAA,UAAU,EAAE;EAAjC,KAAxD,CAAP;EACD;EAED;EACF;EACA;EACA;EA3IA;;EAAA,SA4IEC,aA5IF,GA4IE,yBAAgB;EACd,WAAO,KAAKxC,IAAL,CAAUI,UAAjB;EACD;EAED;EACF;EACA;EACA;EAnJA;;EAAA,SAoJE8B,mBApJF,GAoJE,+BAAsB;EAAA;;EACpB,QAAM9B,UAAU,GAAG,KAAKK,WAAL,CAAiBgC,IAAjB,CAAsB,UAAAC,CAAC;EAAA,aAAIjD,SAAS,CAAC,MAAI,CAACa,GAAL,CAASK,MAAT,CAAgB0B,QAAjB,EAA2BK,CAAC,CAACL,QAA7B,CAAb;EAAA,KAAvB,CAAnB;;EACA,QAAI,KAAKrC,IAAL,CAAUI,UAAV,MAAyBA,UAAzB,oBAAyBA,UAAU,CAAEa,EAArC,CAAJ,EAA6C;EAAA;;EAC3C,WAAKjB,IAAL,CAAUI,UAAV,GAAuBA,UAAvB,oBAAuBA,UAAU,CAAEa,EAAnC;EACA,6BAAKT,QAAL,oCAAemC,WAAf;EACA,WAAKC,OAAL,CAAarD,MAAM,CAACC,kBAApB,EAAwC,KAAKQ,IAAL,CAAUI,UAAlD;EACD;EACF;EAED;EACF;EACA;EACA;EACA;EAjKA;;EAAA,SAkKEiB,oBAlKF,GAkKE,gCAAuB;EACrB,WAAO,KAAKZ,WAAL,CACJoC,GADI,CACA,UAAAzC,UAAU;EAAA,aAAK;EAClBa,QAAAA,EAAE,EAAKb,UAAU,CAACa,EADA;EAElBE,QAAAA,KAAK,EAAEf,UAAU,CAACe;EAFA,OAAL;EAAA,KADV,CAAP;EAKD,GAxKH;;EAAA;EAAA,EAAsC2B,gCAAtC;EAAazC,iBAEJY,KAAK;EAFDZ,iBAOJd,SAASA;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"resolution.js","sources":["../../src/plugins/resolution/constants.js","../../src/plugins/resolution/utils.js","../../src/plugins/resolution/index.js"],"sourcesContent":["/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.ResolutionPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event resolution-changed\n * @memberof PSV.plugins.ResolutionPlugin\n * @summary Triggered when the resolution is changed\n * @param {string} resolutionId\n */\n RESOLUTION_CHANGED: 'resolution-changed',\n};\n","/**\n * @summary Returns deep equality between objects\n * {@link https://gist.github.com/egardner/efd34f270cc33db67c0246e837689cb9}\n * @param obj1\n * @param obj2\n * @return {boolean}\n * @private\n */\nexport function deepEqual(obj1, obj2) {\n if (obj1 === obj2) {\n return true;\n }\n else if (isObject(obj1) && isObject(obj2)) {\n if (Object.keys(obj1).length !== Object.keys(obj2).length) {\n return false;\n }\n for (const prop of Object.keys(obj1)) {\n if (!deepEqual(obj1[prop], obj2[prop])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\n\nfunction isObject(obj) {\n return typeof obj === 'object' && obj != null;\n}\n","import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError } from '../..';\nimport { EVENTS } from './constants';\nimport { deepEqual } from './utils';\n\n\n/**\n * @typedef {Object} PSV.plugins.ResolutionPlugin.Resolution\n * @property {string} id\n * @property {string} label\n * @property {*} panorama\n */\n\n/**\n * @typedef {Object} PSV.plugins.ResolutionPlugin.Options\n * @property {PSV.plugins.ResolutionPlugin.Resolution[]} resolutions - list of available resolutions\n * @property {boolean} [showBadge=true] - show the resolution id as a badge on the settings button\n */\n\n\nDEFAULTS.lang.resolution = 'Quality';\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Adds a setting to choose between multiple resolutions of the panorama.\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class ResolutionPlugin extends AbstractPlugin {\n\n static id = 'resolution';\n\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.ResolutionPlugin.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @type {PSV.plugins.SettingsPlugin}\n * @readonly\n * @private\n */\n this.settings = null;\n\n /**\n * @summary Available resolutions\n * @member {PSV.plugins.ResolutionPlugin.Resolution[]}\n */\n this.resolutions = [];\n\n /**\n * @summary Available resolutions\n * @member {Object.}\n * @private\n */\n this.resolutionsById = {};\n\n /**\n * @type {Object}\n * @property {string} resolution - Current resolution\n * @private\n */\n this.prop = {\n resolution: null,\n };\n\n /**\n * @type {PSV.plugins.ResolutionPlugin.Options}\n */\n this.config = {\n showBadge: true,\n ...options,\n };\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.settings = this.psv.getPlugin('settings');\n\n if (!this.settings) {\n throw new PSVError('Resolution plugin requires the Settings plugin');\n }\n\n this.settings.addSetting({\n id : ResolutionPlugin.id,\n type : 'options',\n label : this.psv.config.lang.resolution,\n current: () => this.prop.resolution,\n options: () => this.__getSettingsOptions(),\n apply : resolution => this.setResolution(resolution),\n badge : !this.config.showBadge ? null : () => this.prop.resolution,\n });\n\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n\n if (this.config.resolutions) {\n this.setResolutions(this.config.resolutions);\n delete this.config.resolutions;\n }\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n\n this.settings.removeSetting(ResolutionPlugin.id);\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (e.type === CONSTANTS.EVENTS.PANORAMA_LOADED) {\n this.__refreshResolution();\n }\n }\n\n /**\n * @summary Changes the available resolutions\n * @param {PSV.plugins.ResolutionPlugin.Resolution[]} resolutions\n */\n setResolutions(resolutions) {\n this.resolutions = resolutions;\n this.resolutionsById = {};\n\n resolutions.forEach((resolution) => {\n if (!resolution.id) {\n throw new PSVError('Missing resolution id');\n }\n this.resolutionsById[resolution.id] = resolution;\n });\n\n this.__refreshResolution();\n }\n\n /**\n * @summary Changes the current resolution\n * @param {string} id\n */\n setResolution(id) {\n if (!this.resolutionsById[id]) {\n throw new PSVError(`Resolution ${id} unknown`);\n }\n\n return this.psv.setPanorama(this.resolutionsById[id].panorama, { transition: false, showLoader: false });\n }\n\n /**\n * @summary Returns the current resolution\n * @return {string}\n */\n getResolution() {\n return this.prop.resolution;\n }\n\n /**\n * @summary Updates current resolution on panorama load\n * @private\n */\n __refreshResolution() {\n const resolution = this.resolutions.find(r => deepEqual(this.psv.config.panorama, r.panorama));\n if (this.prop.resolution !== resolution?.id) {\n this.prop.resolution = resolution?.id;\n this.settings?.updateBadge();\n this.trigger(EVENTS.RESOLUTION_CHANGED, this.prop.resolution);\n }\n }\n\n /**\n * @summary Returns options for Settings plugin\n * @return {PSV.plugins.SettingsPlugin.Option[]}\n * @private\n */\n __getSettingsOptions() {\n return this.resolutions\n .map(resolution => ({\n id : resolution.id,\n label: resolution.label,\n }));\n }\n\n}\n"],"names":["EVENTS","RESOLUTION_CHANGED","deepEqual","obj1","obj2","isObject","Object","keys","length","prop","obj","DEFAULTS","lang","resolution","ResolutionPlugin","psv","options","settings","resolutions","resolutionsById","config","showBadge","init","getPlugin","PSVError","addSetting","id","type","label","current","__getSettingsOptions","apply","setResolution","badge","on","CONSTANTS","PANORAMA_LOADED","setResolutions","destroy","off","removeSetting","handleEvent","e","__refreshResolution","forEach","setPanorama","panorama","transition","showLoader","getResolution","find","r","updateBadge","trigger","map","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,kBAAkB,EAAE;EAPA;;ECNtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,SAASC,SAAT,CAAmBC,IAAnB,EAAyBC,IAAzB,EAA+B;EACpC,MAAID,IAAI,KAAKC,IAAb,EAAmB;EACjB,WAAO,IAAP;EACD,GAFD,MAGK,IAAIC,QAAQ,CAACF,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;EACF;EACA;EACA;EAhJA;;EAAA,SAiJE8B,mBAjJF,GAiJE,+BAAsB;EAAA;;EACpB,QAAM9B,UAAU,GAAG,KAAKK,WAAL,CAAiBgC,IAAjB,CAAsB,UAAAC,CAAC;EAAA,aAAIjD,SAAS,CAAC,MAAI,CAACa,GAAL,CAASK,MAAT,CAAgB0B,QAAjB,EAA2BK,CAAC,CAACL,QAA7B,CAAb;EAAA,KAAvB,CAAnB;;EACA,QAAI,KAAKrC,IAAL,CAAUI,UAAV,MAAyBA,UAAzB,oBAAyBA,UAAU,CAAEa,EAArC,CAAJ,EAA6C;EAAA;;EAC3C,WAAKjB,IAAL,CAAUI,UAAV,GAAuBA,UAAvB,oBAAuBA,UAAU,CAAEa,EAAnC;EACA,6BAAKT,QAAL,oCAAemC,WAAf;EACA,WAAKC,OAAL,CAAarD,MAAM,CAACC,kBAApB,EAAwC,KAAKQ,IAAL,CAAUI,UAAlD;EACD;EACF;EAED;EACF;EACA;EACA;EACA;EA9JA;;EAAA,SA+JEiB,oBA/JF,GA+JE,gCAAuB;EACrB,WAAO,KAAKZ,WAAL,CACJoC,GADI,CACA,UAAAzC,UAAU;EAAA,aAAK;EAClBa,QAAAA,EAAE,EAAKb,UAAU,CAACa,EADA;EAElBE,QAAAA,KAAK,EAAEf,UAAU,CAACe;EAFA,OAAL;EAAA,KADV,CAAP;EAKD,GArKH;;EAAA;EAAA,EAAsC2B,gCAAtC;EAAazC,iBAEJY,KAAK;EAFDZ,iBAIJd,SAASA;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/settings.css b/dist/plugins/settings.css index 53f78a372..a72bcfebf 100644 --- a/dist/plugins/settings.css +++ b/dist/plugins/settings.css @@ -1,5 +1,5 @@ /*! - * Photo Sphere Viewer 4.5.3 + * Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -51,4 +51,16 @@ color: white; font: 10px/0.9 monospace; } + +.psv-settings-menu { + -webkit-box-pack: end; + -ms-flex-pack: end; + justify-content: flex-end; +} +.psv-settings-menu .psv-panel-menu-list { + -webkit-box-flex: 0; + -ms-flex: none; + flex: none; + margin-bottom: 20px; +} /*# sourceMappingURL=settings.css.map */ \ No newline at end of file diff --git a/dist/plugins/settings.css.map b/dist/plugins/settings.css.map index 724fc4eaa..d4b04df91 100644 --- a/dist/plugins/settings.css.map +++ b/dist/plugins/settings.css.map @@ -1 +1 @@ -{"version":3,"sources":["","style.scss"],"names":[],"mappings":"AAAA;;;;;GAAA;ACAA;EACE,mBAAO;MAAP,WAAO;UAAP,OAAO;EACP,iBAAiB;AACnB;AACA;EACE,mBAAU;MAAV,cAAU;UAAV,UAAU;AACZ;AACA;EACE,mBAAU;MAAV,cAAU;UAAV,UAAU;EACV,WAAW;EACX,UAAU;AACZ;AACA;EACE,UAAU;EACV,WAAW;AACb;AACA;EACE,iBAAiB;AACnB;AACA;EACE,gBAAgB;AAClB;AACA;EACE,qCAAqC;EACrC,kBAAkB;AACpB;AACA;EACE,6BAAqB;UAArB,qBAAqB;AACvB;;AAEA;EACE,kBAAkB;EAClB,QAAQ;EACR,UAAU;EACV,oBAAoB;EACpB,cAAc;EACd,gBAAgB;EAChB,YAAY;EACZ,wBAAwB;AAC1B","file":"settings.css","sourcesContent":[null,".psv-settings-item-label {\n flex: 1;\n font-weight: bold;\n}\n.psv-settings-item-value {\n flex: none;\n}\n.psv-settings-item-icon {\n flex: none;\n height: 1em;\n width: 1em;\n}\n.psv-settings-item-icon svg {\n width: 1em;\n height: 1em;\n}\n.psv-settings-item-icon:first-child {\n margin-right: 1em;\n}\n.psv-settings-item-icon:last-child {\n margin-left: 1em;\n}\n.psv-settings-item--header {\n border-bottom: 1px solid currentcolor;\n margin-bottom: 1em;\n}\n.psv-settings-item--header svg {\n transform: scaleX(-1);\n}\n\n.psv-settings-badge {\n position: absolute;\n top: 10%;\n right: 10%;\n border-radius: 0.2em;\n padding: 0.2em;\n background: #111;\n color: white;\n font: 10px/0.9 monospace;\n}"]} \ No newline at end of file +{"version":3,"sources":["","style.scss"],"names":[],"mappings":"AAAA;;;;;GAAA;ACAA;EACE,mBAAO;MAAP,WAAO;UAAP,OAAO;EACP,iBAAiB;AACnB;AACA;EACE,mBAAU;MAAV,cAAU;UAAV,UAAU;AACZ;AACA;EACE,mBAAU;MAAV,cAAU;UAAV,UAAU;EACV,WAAW;EACX,UAAU;AACZ;AACA;EACE,UAAU;EACV,WAAW;AACb;AACA;EACE,iBAAiB;AACnB;AACA;EACE,gBAAgB;AAClB;AACA;EACE,qCAAqC;EACrC,kBAAkB;AACpB;AACA;EACE,6BAAqB;UAArB,qBAAqB;AACvB;;AAEA;EACE,kBAAkB;EAClB,QAAQ;EACR,UAAU;EACV,oBAAoB;EACpB,cAAc;EACd,gBAAgB;EAChB,YAAY;EACZ,wBAAwB;AAC1B;;AAEA;EACE,qBAAyB;MAAzB,kBAAyB;UAAzB,yBAAyB;AAC3B;AACA;EACE,mBAAU;MAAV,cAAU;UAAV,UAAU;EACV,mBAAmB;AACrB","file":"settings.css","sourcesContent":[null,".psv-settings-item-label {\n flex: 1;\n font-weight: bold;\n}\n.psv-settings-item-value {\n flex: none;\n}\n.psv-settings-item-icon {\n flex: none;\n height: 1em;\n width: 1em;\n}\n.psv-settings-item-icon svg {\n width: 1em;\n height: 1em;\n}\n.psv-settings-item-icon:first-child {\n margin-right: 1em;\n}\n.psv-settings-item-icon:last-child {\n margin-left: 1em;\n}\n.psv-settings-item--header {\n border-bottom: 1px solid currentcolor;\n margin-bottom: 1em;\n}\n.psv-settings-item--header svg {\n transform: scaleX(-1);\n}\n\n.psv-settings-badge {\n position: absolute;\n top: 10%;\n right: 10%;\n border-radius: 0.2em;\n padding: 0.2em;\n background: #111;\n color: white;\n font: 10px/0.9 monospace;\n}\n\n.psv-settings-menu {\n justify-content: flex-end;\n}\n.psv-settings-menu .psv-panel-menu-list {\n flex: none;\n margin-bottom: 20px;\n}"]} \ No newline at end of file diff --git a/dist/plugins/settings.d.ts b/dist/plugins/settings.d.ts index 83bbc0899..96fc8f3ed 100644 --- a/dist/plugins/settings.d.ts +++ b/dist/plugins/settings.d.ts @@ -48,6 +48,8 @@ declare const EVENTS: { */ declare class SettingsPlugin extends AbstractPlugin { + static EVENTS: typeof EVENTS; + constructor(psv: Viewer); /** diff --git a/dist/plugins/settings.js b/dist/plugins/settings.js index 3200b7bd0..b5466ab80 100644 --- a/dist/plugins/settings.js +++ b/dist/plugins/settings.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -38,8 +38,6 @@ var chevron = "\n"; - var icon = "\n"; - var switchOff = "\n"; var switchOn = "\n"; @@ -94,7 +92,6 @@ /** * @summary Settings list template * @param {PSV.plugins.SettingsPlugin.Setting[]} settings - * @param {string} title * @param {string} dataKey * @param {function} optionsCurrent * @returns {string} @@ -102,15 +99,14 @@ * @private */ - var SETTINGS_TEMPLATE = function SETTINGS_TEMPLATE(settings, title, dataKey, optionsCurrent) { - return "\n
\n

" + icon + " " + title + "

\n
    \n " + settings.map(function (s) { + var SETTINGS_TEMPLATE = function SETTINGS_TEMPLATE(settings, dataKey, optionsCurrent) { + return "\n
    \n
      \n " + settings.map(function (s) { return "\n
    • \n " + SETTINGS_TEMPLATE_[s.type](s, optionsCurrent) + "\n
    • \n "; }).join('') + "\n
    \n
    \n"; }; /** * @summary Settings options template * @param {PSV.plugins.SettingsPlugin.OptionsSetting} setting - * @param {string} title * @param {string} dataKey * @param {function} optionActive * @returns {string} @@ -118,12 +114,14 @@ * @private */ - var SETTING_OPTIONS_TEMPLATE = function SETTING_OPTIONS_TEMPLATE(setting, title, dataKey, optionActive) { - return "\n
    \n

    " + icon + " " + title + "

    \n
      \n
    • \n " + chevron + "\n " + setting.label + "\n
    • \n " + setting.options().map(function (s) { + var SETTING_OPTIONS_TEMPLATE = function SETTING_OPTIONS_TEMPLATE(setting, dataKey, optionActive) { + return "\n
      \n
        \n
      • \n " + chevron + "\n " + setting.label + "\n
      • \n " + setting.options().map(function (s) { return "\n
      • \n " + (optionActive(s) ? check : '') + "\n " + s.label + "\n
      • \n "; }).join('') + "\n
      \n
      \n"; }; + var icon = "\n"; + /** * @summary Navigation bar settings button class * @extends PSV.buttons.AbstractButton @@ -320,7 +318,7 @@ ; _proto.destroy = function destroy() { - delete this.settings; + this.settings.length = 0; _AbstractPlugin.prototype.destroy.call(this); } @@ -364,15 +362,8 @@ ; _proto.removeSetting = function removeSetting(id) { - var idx = -1; // FIXME use findIndex, one day, when IE11 is totally dead - - this.settings.some(function (setting, i) { - if (setting.id === id) { - idx = i; - return true; - } - - return false; + var idx = this.settings.findIndex(function (setting) { + return setting.id === id; }); if (idx !== -1) { @@ -415,7 +406,7 @@ this.psv.panel.show({ id: ID_PANEL, - content: SETTINGS_TEMPLATE(this.settings, this.psv.config.lang[SettingsButton.id], photoSphereViewer.utils.dasherize(SETTING_DATA), function (setting) { + content: SETTINGS_TEMPLATE(this.settings, photoSphereViewer.utils.dasherize(SETTING_DATA), function (setting) { // retrocompatibility with "current" returning a label var current = setting.current(); var option = setting.options().find(function (opt) { @@ -468,7 +459,7 @@ var current = setting.current(); this.psv.panel.show({ id: ID_PANEL, - content: SETTING_OPTIONS_TEMPLATE(setting, this.psv.config.lang[SettingsButton.id], photoSphereViewer.utils.dasherize(SETTING_DATA), function (option) { + content: SETTING_OPTIONS_TEMPLATE(setting, photoSphereViewer.utils.dasherize(SETTING_DATA), function (option) { // retrocompatibility with options having an "active" flag return 'active' in option ? option.active : option.id === current; }), @@ -508,6 +499,7 @@ return SettingsPlugin; }(photoSphereViewer.AbstractPlugin); SettingsPlugin.id = 'settings'; + SettingsPlugin.EVENTS = EVENTS; exports.EVENTS = EVENTS; exports.SettingsPlugin = SettingsPlugin; diff --git a/dist/plugins/settings.js.map b/dist/plugins/settings.js.map index 31ca85fde..430dbec32 100644 --- a/dist/plugins/settings.js.map +++ b/dist/plugins/settings.js.map @@ -1 +1 @@ -{"version":3,"file":"settings.js","sources":["../../src/plugins/settings/constants.js","../../src/plugins/settings/SettingsButton.js","../../src/plugins/settings/index.js"],"sourcesContent":["import check from './check.svg';\nimport chevron from './chevron.svg';\nimport icon from './settings.svg';\nimport switchOff from './switch-off.svg';\nimport switchOn from './switch-on.svg';\n\n/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.ResolutionPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event setting-changed\n * @memberof PSV.plugins.SettingsPlugin\n * @summary Triggered when a setting is changed\n * @param {string} settingId\n * @param {any} value\n */\n SETTING_CHANGED: 'setting-changed',\n};\n\n\n/**\n * @summary Panel identifier for settings content\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL = 'settings';\n\n/**\n * @summary Property name added to settings items\n * @type {string}\n * @constant\n * @private\n */\nexport const SETTING_DATA = 'settingId';\n\n/**\n * @summary Setting item template, by type\n * @constant\n * @private\n */\nexport const SETTINGS_TEMPLATE_ = {\n options: (setting, optionsCurrent) => `\n ${setting.label}\n ${optionsCurrent(setting)}\n ${chevron}\n `,\n toggle : setting => `\n ${setting.label}\n ${setting.active() ? switchOn : switchOff}\n `,\n};\n\n/**\n * @summary Settings list template\n * @param {PSV.plugins.SettingsPlugin.Setting[]} settings\n * @param {string} title\n * @param {string} dataKey\n * @param {function} optionsCurrent\n * @returns {string}\n * @constant\n * @private\n */\nexport const SETTINGS_TEMPLATE = (settings, title, dataKey, optionsCurrent) => `\n
      \n

      ${icon} ${title}

      \n
        \n ${settings.map(s => `\n
      • \n ${SETTINGS_TEMPLATE_[s.type](s, optionsCurrent)}\n
      • \n `).join('')}\n
      \n
      \n`;\n\n/**\n * @summary Settings options template\n * @param {PSV.plugins.SettingsPlugin.OptionsSetting} setting\n * @param {string} title\n * @param {string} dataKey\n * @param {function} optionActive\n * @returns {string}\n * @constant\n * @private\n */\nexport const SETTING_OPTIONS_TEMPLATE = (setting, title, dataKey, optionActive) => `\n
      \n

      ${icon} ${title}

      \n
        \n
      • \n ${chevron}\n ${setting.label}\n
      • \n ${setting.options().map(s => `\n
      • \n ${optionActive(s) ? check : ''}\n ${s.label}\n
      • \n `).join('')}\n
      \n
      \n`;\n","import { AbstractButton, CONSTANTS } from '../..';\nimport { ID_PANEL } from './constants';\nimport icon from './settings.svg';\n\n/**\n * @summary Navigation bar settings button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class SettingsButton extends AbstractButton {\n\n static id = 'settings';\n static icon = icon;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-settings-button', true);\n\n /**\n * @type {PSV.plugins.SettingsPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('settings');\n\n /**\n * @member {HTMLElement}\n * @private\n * @readonly\n */\n this.badge = document.createElement('div');\n this.badge.className = 'psv-settings-badge';\n this.badge.style.display = 'none';\n this.container.appendChild(this.badge);\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.on(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.off(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case CONSTANTS.EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === ID_PANEL); break;\n case CONSTANTS.EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles settings\n */\n onClick() {\n this.plugin.toggleSettings();\n }\n\n /**\n * @summary Changes the badge value\n * @param {string} value\n */\n setBadge(value) {\n this.badge.innerText = value;\n this.badge.style.display = value ? '' : 'none';\n }\n\n}\n","import { AbstractPlugin, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport {\n EVENTS,\n ID_PANEL,\n SETTING_DATA,\n SETTING_OPTIONS_TEMPLATE,\n SETTINGS_TEMPLATE,\n SETTINGS_TEMPLATE_\n} from './constants';\nimport { SettingsButton } from './SettingsButton';\nimport './style.scss';\n\n\n/**\n * @typedef {Object} PSV.plugins.SettingsPlugin.Setting\n * @summary Description of a setting\n * @property {string} id - identifier of the setting\n * @property {string} label - label of the setting\n * @property {'options' | 'toggle'} type - type of the setting\n * @property {function} [badge] - function which returns the value of the button badge\n */\n\n/**\n * @typedef {PSV.plugins.SettingsPlugin.Setting} PSV.plugins.SettingsPlugin.OptionsSetting\n * @summary Description of a 'options' setting\n * @property {'options'} type - type of the setting\n * @property {function} current - function which returns the current option id\n * @property {function} options - function which the possible options as an array of {@link PSV.plugins.SettingsPlugin.Option}\n * @property {function} apply - function called with the id of the selected option\n */\n\n/**\n * @typedef {PSV.plugins.SettingsPlugin.Setting} PSV.plugins.SettingsPlugin.ToggleSetting\n * @summary Description of a 'toggle' setting\n * @property {'toggle'} type - type of the setting\n * @property {function} active - function which return whereas the setting is active or not\n * @property {function} toggle - function called when the setting is toggled\n */\n\n/**\n * @typedef {Object} PSV.plugins.SettingsPlugin.Option\n * @summary Option of an 'option' setting\n * @property {string} id - identifier of the option\n * @property {string} label - label of the option\n */\n\n\n// add settings button\nDEFAULTS.lang[SettingsButton.id] = 'Settings';\nregisterButton(SettingsButton, 'fullscreen:left');\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Adds a button to access various settings.\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class SettingsPlugin extends AbstractPlugin {\n\n static id = 'settings';\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @type {PSV.plugins.SettingsPlugin.Setting[]}\n * @private\n */\n this.settings = [];\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n // buttons are initialized just after plugins\n setTimeout(() => this.updateBadge());\n }\n\n /**\n * @package\n */\n destroy() {\n delete this.settings;\n\n super.destroy();\n }\n\n /**\n * @summary Registers a new setting\n * @param {PSV.plugins.SettingsPlugin.Setting} setting\n */\n addSetting(setting) {\n if (!setting.id) {\n throw new PSVError('Missing setting id');\n }\n if (!setting.type) {\n throw new PSVError('Missing setting type');\n }\n if (!SETTINGS_TEMPLATE_[setting.type]) {\n throw new PSVError('Unsupported setting type');\n }\n\n if (setting.badge && this.settings.some(s => s.badge)) {\n utils.logWarn('More than one setting with a badge are declared, the result is unpredictable.');\n }\n\n this.settings.push(setting);\n\n if (this.psv.panel.prop.contentId === ID_PANEL) {\n this.showSettings();\n }\n\n this.updateBadge();\n }\n\n /**\n * @summary Removes a setting\n * @param {string} id\n */\n removeSetting(id) {\n let idx = -1;\n // FIXME use findIndex, one day, when IE11 is totally dead\n this.settings.some((setting, i) => {\n if (setting.id === id) {\n idx = i;\n return true;\n }\n return false;\n });\n if (idx !== -1) {\n this.settings.splice(idx, 1);\n\n if (this.psv.panel.prop.contentId === ID_PANEL) {\n this.showSettings();\n }\n\n this.updateBadge();\n }\n }\n\n /**\n * @summary Toggles the settings panel\n */\n toggleSettings() {\n if (this.psv.panel.prop.contentId === ID_PANEL) {\n this.hideSettings();\n }\n else {\n this.showSettings();\n }\n }\n\n /**\n * @summary Hides the settings panel\n */\n hideSettings() {\n this.psv.panel.hide(ID_PANEL);\n }\n\n /**\n * @summary Shows the settings panel\n */\n showSettings() {\n this.psv.panel.show({\n id : ID_PANEL,\n content : SETTINGS_TEMPLATE(\n this.settings,\n this.psv.config.lang[SettingsButton.id],\n utils.dasherize(SETTING_DATA),\n (setting) => { // retrocompatibility with \"current\" returning a label\n const current = setting.current();\n const option = setting.options().find(opt => opt.id === current);\n return option?.label || current;\n }\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const settingId = li ? li.dataset[SETTING_DATA] : undefined;\n const setting = this.settings.find(s => s.id === settingId);\n\n if (setting) {\n switch (setting.type) {\n case 'toggle':\n setting.toggle();\n this.trigger(EVENTS.SETTING_CHANGED, setting.id, setting.active());\n this.showSettings();\n this.updateBadge();\n break;\n\n case 'options':\n this.__showOptions(setting);\n break;\n\n default:\n // noop\n }\n }\n },\n });\n }\n\n /**\n * @summary Shows setting options panel\n * @param {PSV.plugins.SettingsPlugin.OptionsSetting} setting\n * @private\n */\n __showOptions(setting) {\n const current = setting.current();\n\n this.psv.panel.show({\n id : ID_PANEL,\n content : SETTING_OPTIONS_TEMPLATE(\n setting,\n this.psv.config.lang[SettingsButton.id],\n utils.dasherize(SETTING_DATA),\n (option) => { // retrocompatibility with options having an \"active\" flag\n return 'active' in option ? option.active : option.id === current;\n }\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const optionId = li ? li.dataset[SETTING_DATA] : undefined;\n\n if (optionId === '__back') {\n this.showSettings();\n }\n else {\n setting.apply(optionId);\n this.trigger(EVENTS.SETTING_CHANGED, setting.id, setting.current());\n this.hideSettings();\n this.updateBadge();\n }\n },\n });\n }\n\n /**\n * @summary Updates the badge in the button\n */\n updateBadge() {\n const value = this.settings.find(s => s.badge)?.badge();\n this.psv.navbar.getButton(SettingsButton.id, false)?.setBadge(value);\n }\n\n}\n"],"names":["EVENTS","SETTING_CHANGED","ID_PANEL","SETTING_DATA","SETTINGS_TEMPLATE_","options","setting","optionsCurrent","label","chevron","toggle","active","switchOn","switchOff","SETTINGS_TEMPLATE","settings","title","dataKey","icon","map","s","id","type","join","SETTING_OPTIONS_TEMPLATE","optionActive","check","SettingsButton","navbar","plugin","psv","getPlugin","badge","document","createElement","className","style","display","container","appendChild","on","CONSTANTS","OPEN_PANEL","CLOSE_PANEL","destroy","off","isSupported","handleEvent","e","toggleActive","args","onClick","toggleSettings","setBadge","value","innerText","AbstractButton","DEFAULTS","lang","registerButton","SettingsPlugin","init","setTimeout","updateBadge","addSetting","PSVError","some","utils","logWarn","push","panel","prop","contentId","showSettings","removeSetting","idx","i","splice","hideSettings","hide","show","content","config","dasherize","current","option","find","opt","noMargin","clickHandler","li","target","getClosest","undefined","settingId","dataset","trigger","__showOptions","optionId","apply","getButton","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMA;EACA;EACA;EACA;EACA;EACA;;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,eAAe,EAAE;EARG;EAYtB;EACA;EACA;EACA;EACA;EACA;;EACO,IAAMC,QAAQ,GAAG,UAAjB;EAEP;EACA;EACA;EACA;EACA;EACA;;EACO,IAAMC,YAAY,GAAG,WAArB;EAEP;EACA;EACA;EACA;EACA;;EACO,IAAMC,kBAAkB,GAAG;EAChCC,EAAAA,OAAO,EAAE,iBAACC,OAAD,EAAUC,cAAV;EAAA,gEACmCD,OAAO,CAACE,KAD3C,+DAEmCD,cAAc,CAACD,OAAD,CAFjD,8DAGkCG,OAHlC;EAAA,GADuB;EAMhCC,EAAAA,MAAM,EAAG,gBAAAJ,OAAO;EAAA,gEAC4BA,OAAO,CAACE,KADpC,gEAE4BF,OAAO,CAACK,MAAR,KAAmBC,QAAnB,GAA8BC,SAF1D;EAAA;EANgB,CAA3B;EAYP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EACO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,KAAX,EAAkBC,OAAlB,EAA2BV,cAA3B;EAAA,qFAEIW,IAFJ,SAEYF,KAFZ,yDAI3BD,QAAQ,CAACI,GAAT,CAAa,UAAAC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B5C,CAAC,CAAC2C,MAAnB,EAA2B,IAA3B,CAAX,GAA8CE,SAAzD;EACA,YAAMK,QAAQ,GAAGR,EAAE,GAAGA,EAAE,CAACK,OAAH,CAAW5F,YAAX,CAAH,GAA8B0F,SAAjD;;EAEA,YAAIK,QAAQ,KAAK,QAAjB,EAA2B;EACzB,UAAA,MAAI,CAACzB,YAAL;EACD,SAFD,MAGK;EACHnE,UAAAA,OAAO,CAAC6F,KAAR,CAAcD,QAAd;;EACA,UAAA,MAAI,CAACF,OAAL,CAAahG,MAAM,CAACC,eAApB,EAAqCK,OAAO,CAACe,EAA7C,EAAiDf,OAAO,CAAC8E,OAAR,EAAjD;;EACA,UAAA,MAAI,CAACN,YAAL;;EACA,UAAA,MAAI,CAACf,WAAL;EACD;EACF;EAxBiB,KAApB;EA0BD;EAED;EACF;EACA;EA7LA;;EAAA,SA8LEA,WA9LF,GA8LE,uBAAc;EAAA;;EACZ,QAAMT,KAAK,0BAAG,KAAKvC,QAAL,CAAcuE,IAAd,CAAmB,UAAAlE,CAAC;EAAA,aAAIA,CAAC,CAACY,KAAN;EAAA,KAApB,CAAH,qBAAG,oBAAkCA,KAAlC,EAAd;EACA,kCAAKF,GAAL,CAASF,MAAT,CAAgBwE,SAAhB,CAA0BzE,cAAc,CAACN,EAAzC,EAA6C,KAA7C,4CAAqDgC,QAArD,CAA8DC,KAA9D;EACD,GAjMH;;EAAA;EAAA,EAAoC+C,gCAApC;EAAazC,eAEJvC,KAAK;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"settings.js","sources":["../../src/plugins/settings/constants.js","../../src/plugins/settings/SettingsButton.js","../../src/plugins/settings/index.js"],"sourcesContent":["import check from './check.svg';\nimport chevron from './chevron.svg';\nimport switchOff from './switch-off.svg';\nimport switchOn from './switch-on.svg';\n\n/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.ResolutionPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event setting-changed\n * @memberof PSV.plugins.SettingsPlugin\n * @summary Triggered when a setting is changed\n * @param {string} settingId\n * @param {any} value\n */\n SETTING_CHANGED: 'setting-changed',\n};\n\n\n/**\n * @summary Panel identifier for settings content\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL = 'settings';\n\n/**\n * @summary Property name added to settings items\n * @type {string}\n * @constant\n * @private\n */\nexport const SETTING_DATA = 'settingId';\n\n/**\n * @summary Setting item template, by type\n * @constant\n * @private\n */\nexport const SETTINGS_TEMPLATE_ = {\n options: (setting, optionsCurrent) => `\n ${setting.label}\n ${optionsCurrent(setting)}\n ${chevron}\n `,\n toggle : setting => `\n ${setting.label}\n ${setting.active() ? switchOn : switchOff}\n `,\n};\n\n/**\n * @summary Settings list template\n * @param {PSV.plugins.SettingsPlugin.Setting[]} settings\n * @param {string} dataKey\n * @param {function} optionsCurrent\n * @returns {string}\n * @constant\n * @private\n */\nexport const SETTINGS_TEMPLATE = (settings, dataKey, optionsCurrent) => `\n
      \n
        \n ${settings.map(s => `\n
      • \n ${SETTINGS_TEMPLATE_[s.type](s, optionsCurrent)}\n
      • \n `).join('')}\n
      \n
      \n`;\n\n/**\n * @summary Settings options template\n * @param {PSV.plugins.SettingsPlugin.OptionsSetting} setting\n * @param {string} dataKey\n * @param {function} optionActive\n * @returns {string}\n * @constant\n * @private\n */\nexport const SETTING_OPTIONS_TEMPLATE = (setting, dataKey, optionActive) => `\n
      \n
        \n
      • \n ${chevron}\n ${setting.label}\n
      • \n ${setting.options().map(s => `\n
      • \n ${optionActive(s) ? check : ''}\n ${s.label}\n
      • \n `).join('')}\n
      \n
      \n`;\n","import { AbstractButton, CONSTANTS } from '../..';\nimport { ID_PANEL } from './constants';\nimport icon from './settings.svg';\n\n/**\n * @summary Navigation bar settings button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class SettingsButton extends AbstractButton {\n\n static id = 'settings';\n static icon = icon;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-settings-button', true);\n\n /**\n * @type {PSV.plugins.SettingsPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('settings');\n\n /**\n * @member {HTMLElement}\n * @private\n * @readonly\n */\n this.badge = document.createElement('div');\n this.badge.className = 'psv-settings-badge';\n this.badge.style.display = 'none';\n this.container.appendChild(this.badge);\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.on(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.off(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case CONSTANTS.EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === ID_PANEL); break;\n case CONSTANTS.EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles settings\n */\n onClick() {\n this.plugin.toggleSettings();\n }\n\n /**\n * @summary Changes the badge value\n * @param {string} value\n */\n setBadge(value) {\n this.badge.innerText = value;\n this.badge.style.display = value ? '' : 'none';\n }\n\n}\n","import { AbstractPlugin, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport {\n EVENTS,\n ID_PANEL,\n SETTING_DATA,\n SETTING_OPTIONS_TEMPLATE,\n SETTINGS_TEMPLATE,\n SETTINGS_TEMPLATE_\n} from './constants';\nimport { SettingsButton } from './SettingsButton';\nimport './style.scss';\n\n\n/**\n * @typedef {Object} PSV.plugins.SettingsPlugin.Setting\n * @summary Description of a setting\n * @property {string} id - identifier of the setting\n * @property {string} label - label of the setting\n * @property {'options' | 'toggle'} type - type of the setting\n * @property {function} [badge] - function which returns the value of the button badge\n */\n\n/**\n * @typedef {PSV.plugins.SettingsPlugin.Setting} PSV.plugins.SettingsPlugin.OptionsSetting\n * @summary Description of a 'options' setting\n * @property {'options'} type - type of the setting\n * @property {function} current - function which returns the current option id\n * @property {function} options - function which the possible options as an array of {@link PSV.plugins.SettingsPlugin.Option}\n * @property {function} apply - function called with the id of the selected option\n */\n\n/**\n * @typedef {PSV.plugins.SettingsPlugin.Setting} PSV.plugins.SettingsPlugin.ToggleSetting\n * @summary Description of a 'toggle' setting\n * @property {'toggle'} type - type of the setting\n * @property {function} active - function which return whereas the setting is active or not\n * @property {function} toggle - function called when the setting is toggled\n */\n\n/**\n * @typedef {Object} PSV.plugins.SettingsPlugin.Option\n * @summary Option of an 'option' setting\n * @property {string} id - identifier of the option\n * @property {string} label - label of the option\n */\n\n\n// add settings button\nDEFAULTS.lang[SettingsButton.id] = 'Settings';\nregisterButton(SettingsButton, 'fullscreen:left');\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Adds a button to access various settings.\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class SettingsPlugin extends AbstractPlugin {\n\n static id = 'settings';\n\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @type {PSV.plugins.SettingsPlugin.Setting[]}\n * @private\n */\n this.settings = [];\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n // buttons are initialized just after plugins\n setTimeout(() => this.updateBadge());\n }\n\n /**\n * @package\n */\n destroy() {\n this.settings.length = 0;\n\n super.destroy();\n }\n\n /**\n * @summary Registers a new setting\n * @param {PSV.plugins.SettingsPlugin.Setting} setting\n */\n addSetting(setting) {\n if (!setting.id) {\n throw new PSVError('Missing setting id');\n }\n if (!setting.type) {\n throw new PSVError('Missing setting type');\n }\n if (!SETTINGS_TEMPLATE_[setting.type]) {\n throw new PSVError('Unsupported setting type');\n }\n\n if (setting.badge && this.settings.some(s => s.badge)) {\n utils.logWarn('More than one setting with a badge are declared, the result is unpredictable.');\n }\n\n this.settings.push(setting);\n\n if (this.psv.panel.prop.contentId === ID_PANEL) {\n this.showSettings();\n }\n\n this.updateBadge();\n }\n\n /**\n * @summary Removes a setting\n * @param {string} id\n */\n removeSetting(id) {\n const idx = this.settings.findIndex(setting => setting.id === id);\n if (idx !== -1) {\n this.settings.splice(idx, 1);\n\n if (this.psv.panel.prop.contentId === ID_PANEL) {\n this.showSettings();\n }\n\n this.updateBadge();\n }\n }\n\n /**\n * @summary Toggles the settings panel\n */\n toggleSettings() {\n if (this.psv.panel.prop.contentId === ID_PANEL) {\n this.hideSettings();\n }\n else {\n this.showSettings();\n }\n }\n\n /**\n * @summary Hides the settings panel\n */\n hideSettings() {\n this.psv.panel.hide(ID_PANEL);\n }\n\n /**\n * @summary Shows the settings panel\n */\n showSettings() {\n this.psv.panel.show({\n id : ID_PANEL,\n content : SETTINGS_TEMPLATE(\n this.settings,\n utils.dasherize(SETTING_DATA),\n (setting) => { // retrocompatibility with \"current\" returning a label\n const current = setting.current();\n const option = setting.options().find(opt => opt.id === current);\n return option?.label || current;\n }\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const settingId = li ? li.dataset[SETTING_DATA] : undefined;\n const setting = this.settings.find(s => s.id === settingId);\n\n if (setting) {\n switch (setting.type) {\n case 'toggle':\n setting.toggle();\n this.trigger(EVENTS.SETTING_CHANGED, setting.id, setting.active());\n this.showSettings();\n this.updateBadge();\n break;\n\n case 'options':\n this.__showOptions(setting);\n break;\n\n default:\n // noop\n }\n }\n },\n });\n }\n\n /**\n * @summary Shows setting options panel\n * @param {PSV.plugins.SettingsPlugin.OptionsSetting} setting\n * @private\n */\n __showOptions(setting) {\n const current = setting.current();\n\n this.psv.panel.show({\n id : ID_PANEL,\n content : SETTING_OPTIONS_TEMPLATE(\n setting,\n utils.dasherize(SETTING_DATA),\n (option) => { // retrocompatibility with options having an \"active\" flag\n return 'active' in option ? option.active : option.id === current;\n }\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const optionId = li ? li.dataset[SETTING_DATA] : undefined;\n\n if (optionId === '__back') {\n this.showSettings();\n }\n else {\n setting.apply(optionId);\n this.trigger(EVENTS.SETTING_CHANGED, setting.id, setting.current());\n this.hideSettings();\n this.updateBadge();\n }\n },\n });\n }\n\n /**\n * @summary Updates the badge in the button\n */\n updateBadge() {\n const value = this.settings.find(s => s.badge)?.badge();\n this.psv.navbar.getButton(SettingsButton.id, false)?.setBadge(value);\n }\n\n}\n"],"names":["EVENTS","SETTING_CHANGED","ID_PANEL","SETTING_DATA","SETTINGS_TEMPLATE_","options","setting","optionsCurrent","label","chevron","toggle","active","switchOn","switchOff","SETTINGS_TEMPLATE","settings","dataKey","map","s","id","type","join","SETTING_OPTIONS_TEMPLATE","optionActive","check","SettingsButton","navbar","plugin","psv","getPlugin","badge","document","createElement","className","style","display","container","appendChild","on","CONSTANTS","OPEN_PANEL","CLOSE_PANEL","destroy","off","isSupported","handleEvent","e","toggleActive","args","onClick","toggleSettings","setBadge","value","innerText","AbstractButton","icon","DEFAULTS","lang","registerButton","SettingsPlugin","init","setTimeout","updateBadge","length","addSetting","PSVError","some","utils","logWarn","push","panel","prop","contentId","showSettings","removeSetting","idx","findIndex","splice","hideSettings","hide","show","content","dasherize","current","option","find","opt","noMargin","clickHandler","li","target","getClosest","undefined","settingId","dataset","trigger","__showOptions","optionId","apply","getButton","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKA;EACA;EACA;EACA;EACA;EACA;;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,eAAe,EAAE;EARG;EAYtB;EACA;EACA;EACA;EACA;EACA;;EACO,IAAMC,QAAQ,GAAG,UAAjB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file diff --git a/dist/plugins/stereo.d.ts b/dist/plugins/stereo.d.ts index c0bd6d77e..7bc247209 100644 --- a/dist/plugins/stereo.d.ts +++ b/dist/plugins/stereo.d.ts @@ -10,6 +10,8 @@ declare const EVENTS: { */ declare class StereoPlugin extends AbstractPlugin { + static EVENTS: typeof EVENTS; + constructor(psv: Viewer); /** diff --git a/dist/plugins/stereo.js b/dist/plugins/stereo.js index 54d145944..518f48e2d 100644 --- a/dist/plugins/stereo.js +++ b/dist/plugins/stereo.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -203,10 +203,6 @@ var StereoPlugin = /*#__PURE__*/function (_AbstractPlugin) { _inheritsLoose(StereoPlugin, _AbstractPlugin); - /** - * @deprecated use the EVENTS constants of the module - */ - /** * @param {PSV.Viewer} psv */ @@ -442,7 +438,7 @@ var displayRotateMessageTimeout; var displayRotateMessage = function displayRotateMessage() { - if (_this4.isEnabled() && window.innerHeight > window.innerWidth) { + if (window.innerHeight > window.innerWidth) { _this4.psv.overlay.show({ id: ID_OVERLAY_PLEASE_ROTATE, image: mobileRotateIcon, diff --git a/dist/plugins/stereo.js.map b/dist/plugins/stereo.js.map index 599fea1bc..7361e5fab 100644 --- a/dist/plugins/stereo.js.map +++ b/dist/plugins/stereo.js.map @@ -1 +1 @@ -{"version":3,"file":"stereo.js","sources":["../../src/plugins/stereo/constants.js","../../src/plugins/stereo/StereoButton.js","../../src/plugins/stereo/StereoEffect.js","../../src/plugins/stereo/index.js"],"sourcesContent":["/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.StereoPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event stereo-updated\n * @memberof PSV.plugins.StereoPlugin\n * @summary Triggered when the stereo view is enabled/disabled\n * @param {boolean} enabled\n */\n STEREO_UPDATED: 'stereo-updated',\n};\n\n/**\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_OVERLAY_PLEASE_ROTATE = 'pleaseRotate';\n","import { AbstractButton } from '../..';\nimport { EVENTS } from './constants';\nimport stereo from './stereo.svg';\n\n/**\n * @summary Navigation bar stereo button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class StereoButton extends AbstractButton {\n\n static id = 'stereo';\n static icon = stereo;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-stereo-button', true);\n\n /**\n * @type {PSV.plugins.StereoPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('stereo');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.STEREO_UPDATED, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.STEREO_UPDATED, this);\n }\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !this.plugin ? false : { initial: false, promise: this.plugin.prop.isSupported };\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (e.type === EVENTS.STEREO_UPDATED) {\n this.toggleActive(e.args[0]);\n }\n }\n\n /**\n * @override\n * @description Toggles stereo control\n */\n onClick() {\n this.plugin.toggle();\n }\n\n}\n","import {\n\tStereoCamera,\n\tVector2\n} from 'three';\n\n/**\n * Copied from three.js examples\n * @private\n */\nclass StereoEffect {\n\n\tconstructor( renderer ) {\n\n\t\tconst _stereo = new StereoCamera();\n\t\t_stereo.aspect = 0.5;\n\t\tconst size = new Vector2();\n\n\t\tthis.setEyeSeparation = function ( eyeSep ) {\n\n\t\t\t_stereo.eyeSep = eyeSep;\n\n\t\t};\n\n\t\tthis.setSize = function ( width, height ) {\n\n\t\t\trenderer.setSize( width, height );\n\n\t\t};\n\n\t\tthis.render = function ( scene, camera ) {\n\n\t\t\tscene.updateMatrixWorld();\n\n\t\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\t\t_stereo.update( camera );\n\n\t\t\trenderer.getSize( size );\n\n\t\t\tif ( renderer.autoClear ) renderer.clear();\n\t\t\trenderer.setScissorTest( true );\n\n\t\t\trenderer.setScissor( 0, 0, size.width / 2, size.height );\n\t\t\trenderer.setViewport( 0, 0, size.width / 2, size.height );\n\t\t\trenderer.render( scene, _stereo.cameraL );\n\n\t\t\trenderer.setScissor( size.width / 2, 0, size.width / 2, size.height );\n\t\t\trenderer.setViewport( size.width / 2, 0, size.width / 2, size.height );\n\t\t\trenderer.render( scene, _stereo.cameraR );\n\n\t\t\trenderer.setScissorTest( false );\n\n\t\t};\n\n\t}\n\n}\n\nexport { StereoEffect };\n","import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport { EVENTS, ID_OVERLAY_PLEASE_ROTATE } from './constants';\nimport mobileRotateIcon from './mobile-rotate.svg';\nimport { StereoButton } from './StereoButton';\nimport { StereoEffect } from './StereoEffect';\n\n\n/**\n * @external NoSleep\n * @description {@link https://github.com/richtr/NoSleep.js}\n */\n\n\n// add stereo button\nDEFAULTS.lang[StereoButton.id] = 'Stereo view';\nregisterButton(StereoButton, 'caption:right');\n\n// other lang strings\nDEFAULTS.lang.stereoNotification = 'Click anywhere to exit stereo view.';\nDEFAULTS.lang.pleaseRotate = ['Please rotate your device', '(or tap to continue)'];\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Adds stereo view on mobile devices\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class StereoPlugin extends AbstractPlugin {\n\n static id = 'stereo';\n\n /**\n * @deprecated use the EVENTS constants of the module\n */\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @type {PSV.plugins.GyroscopePlugin}\n * @readonly\n * @private\n */\n this.gyroscope = null;\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @readonly\n * @private\n */\n this.markers = null;\n\n /**\n * @member {Object}\n * @protected\n * @property {Promise} isSupported - indicates of the gyroscope API is available\n * @property {external:THREE.WebGLRenderer} renderer - original renderer\n * @property {external:NoSleep} noSleep\n * @property {WakeLockSentinel} wakeLock\n */\n this.prop = {\n isSupported: false,\n renderer : null,\n noSleep : null,\n wakeLock : null,\n };\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n this.gyroscope = this.psv.getPlugin('gyroscope');\n\n if (!this.gyroscope) {\n throw new PSVError('Stereo plugin requires the Gyroscope plugin');\n }\n\n this.prop.isSupported = this.gyroscope.prop.isSupported;\n\n this.psv.on(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.on(CONSTANTS.EVENTS.CLICK, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.off(CONSTANTS.EVENTS.CLICK, this);\n\n this.stop();\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n switch (e.type) {\n case CONSTANTS.EVENTS.STOP_ALL:\n case CONSTANTS.EVENTS.CLICK:\n this.stop();\n break;\n default:\n break;\n }\n }\n\n /**\n * @summary Checks if the stereo view is enabled\n * @returns {boolean}\n */\n isEnabled() {\n return !!this.prop.renderer;\n }\n\n /**\n * @summary Enables the stereo view\n * @description\n * - enables NoSleep.js\n * - enables full screen\n * - starts gyroscope controle\n * - hides markers, navbar and panel\n * - instanciate {@link external:THREE.StereoEffect}\n * @returns {Promise}\n * @fires PSV.plugins.StereoPlugin.stereo-updated\n * @throws {PSV.PSVError} if the gyroscope API is not available/granted\n */\n start() {\n // Need to be in the main event queue\n this.psv.enterFullscreen();\n this.__startNoSleep();\n this.__lockOrientation();\n\n return this.gyroscope.start().then(() => {\n // switch renderer\n this.prop.renderer = this.psv.renderer.renderer;\n this.psv.renderer.renderer = new StereoEffect(this.psv.renderer.renderer);\n\n this.psv.needsUpdate();\n\n this.markers?.hide();\n this.psv.navbar.hide();\n this.psv.panel.hide();\n\n this.trigger(EVENTS.STEREO_UPDATED, true);\n\n this.psv.notification.show({\n content: this.psv.config.lang.stereoNotification,\n timeout: 3000,\n });\n }, () => {\n this.__unlockOrientation();\n this.__stopNoSleep();\n this.psv.exitFullscreen();\n });\n }\n\n /**\n * @summary Disables the stereo view\n * @fires PSV.plugins.StereoPlugin.stereo-updated\n */\n stop() {\n if (this.isEnabled()) {\n this.psv.renderer.renderer = this.prop.renderer;\n this.prop.renderer = null;\n\n this.psv.needsUpdate();\n\n this.markers?.show();\n this.psv.navbar.show();\n\n this.__unlockOrientation();\n this.__stopNoSleep();\n this.psv.exitFullscreen();\n this.gyroscope.stop();\n\n this.trigger(EVENTS.STEREO_UPDATED, false);\n }\n }\n\n /**\n * @summary Enables or disables the stereo view\n */\n toggle() {\n if (this.isEnabled()) {\n this.stop();\n }\n else {\n this.start();\n }\n }\n\n /**\n * @summary Enables WakeLock or NoSleep.js\n * @private\n */\n __startNoSleep() {\n if ('wakeLock' in navigator) {\n navigator.wakeLock.request('screen')\n .then((wakeLock) => {\n this.prop.wakeLock = wakeLock;\n })\n .catch(() => utils.logWarn('Cannot acquire WakeLock'));\n }\n else if ('NoSleep' in window) {\n if (!this.prop.noSleep) {\n this.prop.noSleep = new window.NoSleep();\n }\n this.prop.noSleep.enable();\n }\n else {\n utils.logWarn('NoSleep is not available');\n }\n }\n\n /**\n * @summary Disables WakeLock or NoSleep.js\n * @private\n */\n __stopNoSleep() {\n if (this.prop.wakeLock) {\n this.prop.wakeLock.release();\n this.prop.wakeLock = null;\n }\n else if (this.prop.noSleep) {\n this.prop.noSleep.disable();\n }\n }\n\n /**\n * @summary Tries to lock the device in landscape or display a message\n * @private\n */\n __lockOrientation() {\n let displayRotateMessageTimeout;\n\n const displayRotateMessage = () => {\n if (this.isEnabled() && window.innerHeight > window.innerWidth) {\n this.psv.overlay.show({\n id : ID_OVERLAY_PLEASE_ROTATE,\n image : mobileRotateIcon,\n text : this.psv.config.lang.pleaseRotate[0],\n subtext: this.psv.config.lang.pleaseRotate[1],\n });\n }\n\n if (displayRotateMessageTimeout) {\n clearTimeout(displayRotateMessageTimeout);\n displayRotateMessageTimeout = null;\n }\n };\n\n if (window.screen?.orientation) {\n window.screen.orientation.lock('landscape').then(null, () => displayRotateMessage());\n displayRotateMessageTimeout = setTimeout(() => displayRotateMessage(), 500);\n }\n else {\n displayRotateMessage();\n }\n }\n\n /**\n * @summary Unlock the device orientation\n * @private\n */\n __unlockOrientation() {\n if (window.screen?.orientation) {\n window.screen.orientation.unlock();\n }\n else {\n this.psv.overlay.hide(ID_OVERLAY_PLEASE_ROTATE);\n }\n }\n\n}\n"],"names":["EVENTS","STEREO_UPDATED","ID_OVERLAY_PLEASE_ROTATE","StereoButton","navbar","plugin","psv","getPlugin","on","destroy","off","isSupported","initial","promise","prop","handleEvent","e","type","toggleActive","args","onClick","toggle","AbstractButton","id","icon","stereo","StereoEffect","renderer","_stereo","StereoCamera","aspect","size","Vector2","setEyeSeparation","eyeSep","setSize","width","height","render","scene","camera","updateMatrixWorld","parent","update","getSize","autoClear","clear","setScissorTest","setScissor","setViewport","cameraL","cameraR","DEFAULTS","lang","registerButton","stereoNotification","pleaseRotate","StereoPlugin","gyroscope","markers","noSleep","wakeLock","init","PSVError","CONSTANTS","STOP_ALL","CLICK","stop","isEnabled","start","enterFullscreen","__startNoSleep","__lockOrientation","then","needsUpdate","hide","panel","trigger","notification","show","content","config","timeout","__unlockOrientation","__stopNoSleep","exitFullscreen","navigator","request","catch","utils","logWarn","window","NoSleep","enable","release","disable","displayRotateMessageTimeout","displayRotateMessage","innerHeight","innerWidth","overlay","image","mobileRotateIcon","text","subtext","clearTimeout","screen","orientation","lock","setTimeout","unlock","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;MACaA,MAAM,GAAG;EACpB;EACF;E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AAeC,WAAnB,EAAgC;EAC9BhB,MAAAA,MAAM,CAACe,MAAP,CAAcC,WAAd,CAA0BC,IAA1B,CAA+B,WAA/B,EAA4CnC,IAA5C,CAAiD,IAAjD,EAAuD;EAAA,eAAMwB,oBAAoB,EAA1B;EAAA,OAAvD;EACAD,MAAAA,2BAA2B,GAAGa,UAAU,CAAC;EAAA,eAAMZ,oBAAoB,EAA1B;EAAA,OAAD,EAA+B,GAA/B,CAAxC;EACD,KAHD,MAIK;EACHA,MAAAA,oBAAoB;EACrB;EACF;EAED;EACF;EACA;EACA;EAvPA;;EAAA,SAwPEd,mBAxPF,GAwPE,+BAAsB;EAAA;;EACpB,2BAAIQ,MAAM,CAACe,MAAX,aAAI,gBAAeC,WAAnB,EAAgC;EAC9BhB,MAAAA,MAAM,CAACe,MAAP,CAAcC,WAAd,CAA0BG,MAA1B;EACD,KAFD,MAGK;EACH,WAAKxG,GAAL,CAAS8F,OAAT,CAAiBzB,IAAjB,CAAsBzE,wBAAtB;EACD;EACF,GA/PH;;EAAA;EAAA,EAAkC6G,gCAAlC;EAAatD,aAEJlC,KAAK;EAFDkC,aAOJzD,SAASA;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"stereo.js","sources":["../../src/plugins/stereo/constants.js","../../src/plugins/stereo/StereoButton.js","../../src/plugins/stereo/StereoEffect.js","../../src/plugins/stereo/index.js"],"sourcesContent":["/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.StereoPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event stereo-updated\n * @memberof PSV.plugins.StereoPlugin\n * @summary Triggered when the stereo view is enabled/disabled\n * @param {boolean} enabled\n */\n STEREO_UPDATED: 'stereo-updated',\n};\n\n/**\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_OVERLAY_PLEASE_ROTATE = 'pleaseRotate';\n","import { AbstractButton } from '../..';\nimport { EVENTS } from './constants';\nimport stereo from './stereo.svg';\n\n/**\n * @summary Navigation bar stereo button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class StereoButton extends AbstractButton {\n\n static id = 'stereo';\n static icon = stereo;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-stereo-button', true);\n\n /**\n * @type {PSV.plugins.StereoPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('stereo');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.STEREO_UPDATED, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.STEREO_UPDATED, this);\n }\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !this.plugin ? false : { initial: false, promise: this.plugin.prop.isSupported };\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n if (e.type === EVENTS.STEREO_UPDATED) {\n this.toggleActive(e.args[0]);\n }\n }\n\n /**\n * @override\n * @description Toggles stereo control\n */\n onClick() {\n this.plugin.toggle();\n }\n\n}\n","import {\n\tStereoCamera,\n\tVector2\n} from 'three';\n\n/**\n * Copied from three.js examples\n * @private\n */\nclass StereoEffect {\n\n\tconstructor( renderer ) {\n\n\t\tconst _stereo = new StereoCamera();\n\t\t_stereo.aspect = 0.5;\n\t\tconst size = new Vector2();\n\n\t\tthis.setEyeSeparation = function ( eyeSep ) {\n\n\t\t\t_stereo.eyeSep = eyeSep;\n\n\t\t};\n\n\t\tthis.setSize = function ( width, height ) {\n\n\t\t\trenderer.setSize( width, height );\n\n\t\t};\n\n\t\tthis.render = function ( scene, camera ) {\n\n\t\t\tscene.updateMatrixWorld();\n\n\t\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\t\t_stereo.update( camera );\n\n\t\t\trenderer.getSize( size );\n\n\t\t\tif ( renderer.autoClear ) renderer.clear();\n\t\t\trenderer.setScissorTest( true );\n\n\t\t\trenderer.setScissor( 0, 0, size.width / 2, size.height );\n\t\t\trenderer.setViewport( 0, 0, size.width / 2, size.height );\n\t\t\trenderer.render( scene, _stereo.cameraL );\n\n\t\t\trenderer.setScissor( size.width / 2, 0, size.width / 2, size.height );\n\t\t\trenderer.setViewport( size.width / 2, 0, size.width / 2, size.height );\n\t\t\trenderer.render( scene, _stereo.cameraR );\n\n\t\t\trenderer.setScissorTest( false );\n\n\t\t};\n\n\t}\n\n}\n\nexport { StereoEffect };\n","import { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport { EVENTS, ID_OVERLAY_PLEASE_ROTATE } from './constants';\nimport mobileRotateIcon from './mobile-rotate.svg';\nimport { StereoButton } from './StereoButton';\nimport { StereoEffect } from './StereoEffect';\n\n\n/**\n * @external NoSleep\n * @description {@link https://github.com/richtr/NoSleep.js}\n */\n\n\n// add stereo button\nDEFAULTS.lang[StereoButton.id] = 'Stereo view';\nregisterButton(StereoButton, 'caption:right');\n\n// other lang strings\nDEFAULTS.lang.stereoNotification = 'Click anywhere to exit stereo view.';\nDEFAULTS.lang.pleaseRotate = ['Please rotate your device', '(or tap to continue)'];\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Adds stereo view on mobile devices\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class StereoPlugin extends AbstractPlugin {\n\n static id = 'stereo';\n\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n */\n constructor(psv) {\n super(psv);\n\n /**\n * @type {PSV.plugins.GyroscopePlugin}\n * @readonly\n * @private\n */\n this.gyroscope = null;\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @readonly\n * @private\n */\n this.markers = null;\n\n /**\n * @member {Object}\n * @protected\n * @property {Promise} isSupported - indicates of the gyroscope API is available\n * @property {external:THREE.WebGLRenderer} renderer - original renderer\n * @property {external:NoSleep} noSleep\n * @property {WakeLockSentinel} wakeLock\n */\n this.prop = {\n isSupported: false,\n renderer : null,\n noSleep : null,\n wakeLock : null,\n };\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n this.gyroscope = this.psv.getPlugin('gyroscope');\n\n if (!this.gyroscope) {\n throw new PSVError('Stereo plugin requires the Gyroscope plugin');\n }\n\n this.prop.isSupported = this.gyroscope.prop.isSupported;\n\n this.psv.on(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.on(CONSTANTS.EVENTS.CLICK, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.STOP_ALL, this);\n this.psv.off(CONSTANTS.EVENTS.CLICK, this);\n\n this.stop();\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n switch (e.type) {\n case CONSTANTS.EVENTS.STOP_ALL:\n case CONSTANTS.EVENTS.CLICK:\n this.stop();\n break;\n default:\n break;\n }\n }\n\n /**\n * @summary Checks if the stereo view is enabled\n * @returns {boolean}\n */\n isEnabled() {\n return !!this.prop.renderer;\n }\n\n /**\n * @summary Enables the stereo view\n * @description\n * - enables NoSleep.js\n * - enables full screen\n * - starts gyroscope controle\n * - hides markers, navbar and panel\n * - instanciate {@link external:THREE.StereoEffect}\n * @returns {Promise}\n * @fires PSV.plugins.StereoPlugin.stereo-updated\n * @throws {PSV.PSVError} if the gyroscope API is not available/granted\n */\n start() {\n // Need to be in the main event queue\n this.psv.enterFullscreen();\n this.__startNoSleep();\n this.__lockOrientation();\n\n return this.gyroscope.start().then(() => {\n // switch renderer\n this.prop.renderer = this.psv.renderer.renderer;\n this.psv.renderer.renderer = new StereoEffect(this.psv.renderer.renderer);\n\n this.psv.needsUpdate();\n\n this.markers?.hide();\n this.psv.navbar.hide();\n this.psv.panel.hide();\n\n this.trigger(EVENTS.STEREO_UPDATED, true);\n\n this.psv.notification.show({\n content: this.psv.config.lang.stereoNotification,\n timeout: 3000,\n });\n }, () => {\n this.__unlockOrientation();\n this.__stopNoSleep();\n this.psv.exitFullscreen();\n });\n }\n\n /**\n * @summary Disables the stereo view\n * @fires PSV.plugins.StereoPlugin.stereo-updated\n */\n stop() {\n if (this.isEnabled()) {\n this.psv.renderer.renderer = this.prop.renderer;\n this.prop.renderer = null;\n\n this.psv.needsUpdate();\n\n this.markers?.show();\n this.psv.navbar.show();\n\n this.__unlockOrientation();\n this.__stopNoSleep();\n this.psv.exitFullscreen();\n this.gyroscope.stop();\n\n this.trigger(EVENTS.STEREO_UPDATED, false);\n }\n }\n\n /**\n * @summary Enables or disables the stereo view\n */\n toggle() {\n if (this.isEnabled()) {\n this.stop();\n }\n else {\n this.start();\n }\n }\n\n /**\n * @summary Enables WakeLock or NoSleep.js\n * @private\n */\n __startNoSleep() {\n if ('wakeLock' in navigator) {\n navigator.wakeLock.request('screen')\n .then((wakeLock) => {\n this.prop.wakeLock = wakeLock;\n })\n .catch(() => utils.logWarn('Cannot acquire WakeLock'));\n }\n else if ('NoSleep' in window) {\n if (!this.prop.noSleep) {\n this.prop.noSleep = new window.NoSleep();\n }\n this.prop.noSleep.enable();\n }\n else {\n utils.logWarn('NoSleep is not available');\n }\n }\n\n /**\n * @summary Disables WakeLock or NoSleep.js\n * @private\n */\n __stopNoSleep() {\n if (this.prop.wakeLock) {\n this.prop.wakeLock.release();\n this.prop.wakeLock = null;\n }\n else if (this.prop.noSleep) {\n this.prop.noSleep.disable();\n }\n }\n\n /**\n * @summary Tries to lock the device in landscape or display a message\n * @private\n */\n __lockOrientation() {\n let displayRotateMessageTimeout;\n\n const displayRotateMessage = () => {\n if (window.innerHeight > window.innerWidth) {\n this.psv.overlay.show({\n id : ID_OVERLAY_PLEASE_ROTATE,\n image : mobileRotateIcon,\n text : this.psv.config.lang.pleaseRotate[0],\n subtext: this.psv.config.lang.pleaseRotate[1],\n });\n }\n\n if (displayRotateMessageTimeout) {\n clearTimeout(displayRotateMessageTimeout);\n displayRotateMessageTimeout = null;\n }\n };\n\n if (window.screen?.orientation) {\n window.screen.orientation.lock('landscape').then(null, () => displayRotateMessage());\n displayRotateMessageTimeout = setTimeout(() => displayRotateMessage(), 500);\n }\n else {\n displayRotateMessage();\n }\n }\n\n /**\n * @summary Unlock the device orientation\n * @private\n */\n __unlockOrientation() {\n if (window.screen?.orientation) {\n window.screen.orientation.unlock();\n }\n else {\n this.psv.overlay.hide(ID_OVERLAY_PLEASE_ROTATE);\n }\n }\n\n}\n"],"names":["EVENTS","STEREO_UPDATED","ID_OVERLAY_PLEASE_ROTATE","StereoButton","navbar","plugin","psv","getPlugin","on","destroy","off","isSupported","initial","promise","prop","handleEvent","e","type","toggleActive","args","onClick","toggle","AbstractButton","id","icon","stereo","StereoEffect","renderer","_stereo","StereoCamera","aspect","size","Vector2","setEyeSeparation","eyeSep","setSize","width","height","render","scene","camera","updateMatrixWorld","parent","update","getSize","autoClear","clear","setScissorTest","setScissor","setViewport","cameraL","cameraR","DEFAULTS","lang","registerButton","stereoNotification","pleaseRotate","StereoPlugin","gyroscope","markers","noSleep","wakeLock","init","PSVError","CONSTANTS","STOP_ALL","CLICK","stop","isEnabled","start","enterFullscreen","__startNoSleep","__lockOrientation","then","needsUpdate","hide","panel","trigger","notification","show","content","config","timeout","__unlockOrientation","__stopNoSleep","exitFullscreen","navigator","request","catch","utils","logWarn","window","NoSleep","enable","release","disable","displayRotateMessageTimeout","displayRotateMessage","innerHeight","innerWidth","overlay","image","mobileRotateIcon","text","subtext","clearTimeout","screen","orientation","lock","setTimeout","unlock","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;MACaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,cAAc,EAAE;EAPI;EAUtB;EACA;EACA;EACA;EACA;;EACO,IAAMC,wBAAwB,GAAG,cAAjC;;;;;;ECjBP;EACA;EACA;EACA;EACA;;MACaC,YAAb;EAAA;;EAKE;EACF;EACA;EACE,wBAAYC,MAAZ,EAAoB;EAAA;;EAClB,uCAAM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/B,CAAxC;EACD,KAHD,MAIK;EACHA,MAAAA,oBAAoB;EACrB;EACF;EAED;EACF;EACA;EACA;EApPA;;EAAA,SAqPEd,mBArPF,GAqPE,+BAAsB;EAAA;;EACpB,2BAAIQ,MAAM,CAACe,MAAX,aAAI,gBAAeC,WAAnB,EAAgC;EAC9BhB,MAAAA,MAAM,CAACe,MAAP,CAAcC,WAAd,CAA0BG,MAA1B;EACD,KAFD,MAGK;EACH,WAAKxG,GAAL,CAAS8F,OAAT,CAAiBzB,IAAjB,CAAsBzE,wBAAtB;EACD;EACF,GA5PH;;EAAA;EAAA,EAAkC6G,gCAAlC;EAAatD,aAEJlC,KAAK;EAFDkC,aAIJzD,SAASA;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/video.css b/dist/plugins/video.css new file mode 100644 index 000000000..b0a3a3115 --- /dev/null +++ b/dist/plugins/video.css @@ -0,0 +1,166 @@ +/*! + * Photo Sphere Viewer 4.6.0 + * @copyright 2014-2015 Jérémy Heleine + * @copyright 2015-2022 Damien "Mistic" Sorel + * @licence MIT (https://opensource.org/licenses/MIT) + */ +.psv-video-progressbar { + position: absolute; + left: 0; + bottom: 0; + width: 100%; + height: 20px; + cursor: pointer; + z-index: 89; +} +.psv--has-navbar .psv-video-progressbar { + bottom: 40px; +} + +.psv-video-progressbar > * { + position: absolute; + left: 0; + bottom: 0; + width: 100%; + height: 3px; + -webkit-transition: height 0.2s linear; + transition: height 0.2s linear; +} +.psv-video-progressbar:hover > * { + height: 5px; +} +.psv-video-progressbar__progress { + background-color: rgba(255, 255, 255, 0.7); +} +.psv-video-progressbar__buffer { + background-color: rgba(255, 255, 255, 0.2); +} +.psv-video-progressbar__handle { + display: none; + height: 9px !important; + width: 9px; + border-radius: 50%; + margin-bottom: -2px; + margin-left: -4.5px; + background: white; +} +.psv-video-time { + -webkit-box-flex: 0; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +.psv-video-time .psv-caption-content { + min-width: 6em; + text-align: center; +} +.psv-video-volume__container { + position: absolute; + left: 0; + bottom: 40px; + padding: 20px 0; + width: 40px; + height: 0; + opacity: 0; + background: rgba(61, 61, 61, 0.5); + -webkit-transition: opacity 0.2s linear, height 0.3s step-end; + transition: opacity 0.2s linear, height 0.3s step-end; +} +.psv-video-volume__range { + position: relative; + height: 80px; +} +.psv-video-volume__progress, .psv-video-volume__track { + position: absolute; + bottom: 0; + left: 17.5px; + width: 5px; + background: rgba(255, 255, 255, 0.7); +} +.psv-video-volume__track { + height: 100%; + background: rgba(255, 255, 255, 0.2); +} +.psv-video-volume__handle { + position: absolute; + left: 17.5px; + height: 9px; + width: 9px; + border-radius: 50%; + margin-left: -2px; + margin-bottom: -4.5px; + background: white; +} +.psv-video-volume-button { + position: relative; +} +.psv-video-volume-button:hover .psv-video-volume__container { + height: 80px; + opacity: 1; + -webkit-transition-timing-function: linear, step-start; + transition-timing-function: linear, step-start; + -webkit-transition-delay: 0.3s; + transition-delay: 0.3s; +} +.psv-video-volume-button--0 .psv-button-svg #lvl1, +.psv-video-volume-button--0 .psv-button-svg #lvl2, +.psv-video-volume-button--0 .psv-button-svg #lvl3 { + fill: none; +} +.psv-video-volume-button--1 .psv-button-svg #lvl0, +.psv-video-volume-button--1 .psv-button-svg #lvl2, +.psv-video-volume-button--1 .psv-button-svg #lvl3 { + fill: none; +} +.psv-video-volume-button--2 .psv-button-svg #lvl0, +.psv-video-volume-button--2 .psv-button-svg #lvl3 { + fill: none; +} +.psv-video-volume-button--3 .psv-button-svg #lvl0 { + fill: none; +} +.psv-video-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + z-index: 110; + pointer-events: none; +} +.psv-video-bigbutton { + display: block; + border: none; + background: none; + padding: 0; + color: rgba(255, 255, 255, 0.7); + pointer-events: auto; + cursor: pointer; + opacity: 0; + width: 0; + -webkit-transition: opacity 0.2s linear, width 0.3s step-end; + transition: opacity 0.2s linear, width 0.3s step-end; +} +.psv-video-bigbutton--pause { + width: 20vw; + opacity: 1; + -webkit-transition-timing-function: linear, step-start; + transition-timing-function: linear, step-start; +} +@media (orientation: landscape) { + .psv-video-bigbutton--pause { + width: 10vw; + } +} +.psv-video-bigbutton svg { + width: 100%; +} +/*# sourceMappingURL=video.css.map */ \ No newline at end of file diff --git a/dist/plugins/video.css.map b/dist/plugins/video.css.map new file mode 100644 index 000000000..4dafa48d5 --- /dev/null +++ b/dist/plugins/video.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["","style.scss"],"names":[],"mappings":"AAAA;;;;;GAAA;ACAA;EACE,kBAAkB;EAClB,OAAO;EACP,SAAS;EACT,WAAW;EACX,YAAY;EACZ,eAAe;EACf,WAAW;AACb;AACA;EACE,YAAY;AACd;;AAEA;EACE,kBAAkB;EAClB,OAAO;EACP,SAAS;EACT,WAAW;EACX,WAAW;EACX,sCAA8B;EAA9B,8BAA8B;AAChC;AACA;EACE,WAAW;AACb;AACA;EACE,0CAA0C;AAC5C;AACA;EACE,0CAA0C;AAC5C;AACA;EACE,aAAa;EACb,sBAAsB;EACtB,UAAU;EACV,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,iBAAiB;AACnB;AACA;EACE,mBAAc;MAAd,kBAAc;UAAd,cAAc;AAChB;AACA;EACE,cAAc;EACd,kBAAkB;AACpB;AACA;EACE,kBAAkB;EAClB,OAAO;EACP,YAAY;EACZ,eAAe;EACf,WAAW;EACX,SAAS;EACT,UAAU;EACV,iCAAiC;EACjC,6DAAqD;EAArD,qDAAqD;AACvD;AACA;EACE,kBAAkB;EAClB,YAAY;AACd;AACA;EACE,kBAAkB;EAClB,SAAS;EACT,YAAY;EACZ,UAAU;EACV,oCAAoC;AACtC;AACA;EACE,YAAY;EACZ,oCAAoC;AACtC;AACA;EACE,kBAAkB;EAClB,YAAY;EACZ,WAAW;EACX,UAAU;EACV,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,iBAAiB;AACnB;AACA;EACE,kBAAkB;AACpB;AACA;EACE,YAAY;EACZ,UAAU;EACV,sDAA8C;UAA9C,8CAA8C;EAC9C,8BAAsB;UAAtB,sBAAsB;AACxB;AACA;;;EAGE,UAAU;AACZ;AACA;;;EAGE,UAAU;AACZ;AACA;;EAEE,UAAU;AACZ;AACA;EACE,UAAU;AACZ;AACA;EACE,kBAAkB;EAClB,MAAM;EACN,OAAO;EACP,WAAW;EACX,YAAY;EACZ,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;EACnB,wBAAuB;MAAvB,qBAAuB;UAAvB,uBAAuB;EACvB,YAAY;EACZ,oBAAoB;AACtB;AACA;EACE,cAAc;EACd,YAAY;EACZ,gBAAgB;EAChB,UAAU;EACV,+BAA+B;EAC/B,oBAAoB;EACpB,eAAe;EACf,UAAU;EACV,QAAQ;EACR,4DAAoD;EAApD,oDAAoD;AACtD;AACA;EACE,WAAW;EACX,UAAU;EACV,sDAA8C;UAA9C,8CAA8C;AAChD;AACA;EACE;IACE,WAAW;EACb;AACF;AACA;EACE,WAAW;AACb","file":"video.css","sourcesContent":[null,".psv-video-progressbar {\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n height: 20px;\n cursor: pointer;\n z-index: 89;\n}\n.psv--has-navbar .psv-video-progressbar {\n bottom: 40px;\n}\n\n.psv-video-progressbar > * {\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n height: 3px;\n transition: height 0.2s linear;\n}\n.psv-video-progressbar:hover > * {\n height: 5px;\n}\n.psv-video-progressbar__progress {\n background-color: rgba(255, 255, 255, 0.7);\n}\n.psv-video-progressbar__buffer {\n background-color: rgba(255, 255, 255, 0.2);\n}\n.psv-video-progressbar__handle {\n display: none;\n height: 9px !important;\n width: 9px;\n border-radius: 50%;\n margin-bottom: -2px;\n margin-left: -4.5px;\n background: white;\n}\n.psv-video-time {\n flex: 0 0 auto;\n}\n.psv-video-time .psv-caption-content {\n min-width: 6em;\n text-align: center;\n}\n.psv-video-volume__container {\n position: absolute;\n left: 0;\n bottom: 40px;\n padding: 20px 0;\n width: 40px;\n height: 0;\n opacity: 0;\n background: rgba(61, 61, 61, 0.5);\n transition: opacity 0.2s linear, height 0.3s step-end;\n}\n.psv-video-volume__range {\n position: relative;\n height: 80px;\n}\n.psv-video-volume__progress, .psv-video-volume__track {\n position: absolute;\n bottom: 0;\n left: 17.5px;\n width: 5px;\n background: rgba(255, 255, 255, 0.7);\n}\n.psv-video-volume__track {\n height: 100%;\n background: rgba(255, 255, 255, 0.2);\n}\n.psv-video-volume__handle {\n position: absolute;\n left: 17.5px;\n height: 9px;\n width: 9px;\n border-radius: 50%;\n margin-left: -2px;\n margin-bottom: -4.5px;\n background: white;\n}\n.psv-video-volume-button {\n position: relative;\n}\n.psv-video-volume-button:hover .psv-video-volume__container {\n height: 80px;\n opacity: 1;\n transition-timing-function: linear, step-start;\n transition-delay: 0.3s;\n}\n.psv-video-volume-button--0 .psv-button-svg #lvl1,\n.psv-video-volume-button--0 .psv-button-svg #lvl2,\n.psv-video-volume-button--0 .psv-button-svg #lvl3 {\n fill: none;\n}\n.psv-video-volume-button--1 .psv-button-svg #lvl0,\n.psv-video-volume-button--1 .psv-button-svg #lvl2,\n.psv-video-volume-button--1 .psv-button-svg #lvl3 {\n fill: none;\n}\n.psv-video-volume-button--2 .psv-button-svg #lvl0,\n.psv-video-volume-button--2 .psv-button-svg #lvl3 {\n fill: none;\n}\n.psv-video-volume-button--3 .psv-button-svg #lvl0 {\n fill: none;\n}\n.psv-video-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 110;\n pointer-events: none;\n}\n.psv-video-bigbutton {\n display: block;\n border: none;\n background: none;\n padding: 0;\n color: rgba(255, 255, 255, 0.7);\n pointer-events: auto;\n cursor: pointer;\n opacity: 0;\n width: 0;\n transition: opacity 0.2s linear, width 0.3s step-end;\n}\n.psv-video-bigbutton--pause {\n width: 20vw;\n opacity: 1;\n transition-timing-function: linear, step-start;\n}\n@media (orientation: landscape) {\n .psv-video-bigbutton--pause {\n width: 10vw;\n }\n}\n.psv-video-bigbutton svg {\n width: 100%;\n}"]} \ No newline at end of file diff --git a/dist/plugins/video.d.ts b/dist/plugins/video.d.ts new file mode 100644 index 000000000..6c7df47f7 --- /dev/null +++ b/dist/plugins/video.d.ts @@ -0,0 +1,127 @@ +import { Event } from 'uevent'; +import { ExtendedPosition, AbstractPlugin, Viewer } from 'photo-sphere-viewer'; + +declare const EVENTS: { + PLAY: 'play', + PAUSE: 'pause', + VOLUME_CHANGE: 'volume-change', + PROGRESS: 'progress', + BUFFER: 'buffer', +}; + +/** + * @summary Definition of keypoints for automatic rotation, can be a position object, a marker id or an object with the following properties + */ +type AutorotateKeypoint = { + position: ExtendedPosition; + time: number; +}; + +type VideoPluginOptions = { + progressbar?: boolean; + bigbutton?: boolean; + keypoints?: AutorotateKeypoint[]; +}; + +/** + * @summary Controls a video adapter + */ +declare class VideoPlugin extends AbstractPlugin { + + static EVENTS: typeof EVENTS; + + constructor(psv: Viewer, options: VideoPluginOptions); + + /** + * @summary Changes the keypoints + */ + setKeypoints(keypoints: AutorotateKeypoint[]); + + /** + * @summary Returns the durection of the video + */ + getDuration(): number; + + /** + * @summary Returns the current time of the video + */ + getTime(): number; + + /** + * @summary Returns the play progression of the video + */ + getProgress(): number; + + /** + * @summary Returns if the video is playing + */ + isPlaying(): boolean; + + /** + * @summary Returns the video volume + */ + getVolume(): number; + + /** + * @summary Starts or pause the video + */ + playPause(): void; + + /** + * @summary Starts the video if paused + */ + play(): void; + + /** + * @summary Pauses the cideo if playing + */ + pause(): void; + + /** + * @summary Sets the volume of the video + */ + setVolume(volume: number): void; + + /** + * @summary (Un)mutes the video + */ + setMute(mute?: boolean): void; + + /** + * @summary Changes the current time of the video + */ + setTime(time: number): void; + + /** + * @summary Changes the progression of the video + */ + setProgress(progress: number): void; + + /** + * @summary Triggered when the video starts playing + */ + on(e: 'play', cb: (e: Event) => void): this; + + /** + * @summary Triggered when the video is paused + */ + on(e: 'pause', cb: (e: Event) => void): this; + + /** + * @summary Triggered when the video volume changes + */ + on(e: 'volume-change', cb: (e: Event, volume: number) => void): this; + + /** + * @summary Triggered when the video play progression changes + */ + on(e: 'progress', cb: (e: Event, data: { time: number, duration: number, progress: number }) => void): this; + + /** + * @summary Triggered when the video buffer changes + */ + on(e: 'buffer', cb: (e: Event, maxBuffer: number) => void): this; + +} + +export { AutorotateKeypoint, EVENTS, VideoPlugin, VideoPluginOptions }; diff --git a/dist/plugins/video.js b/dist/plugins/video.js new file mode 100644 index 000000000..7dafcc47d --- /dev/null +++ b/dist/plugins/video.js @@ -0,0 +1,1245 @@ +/*! +* Photo Sphere Viewer 4.6.0 +* @copyright 2014-2015 Jérémy Heleine +* @copyright 2015-2022 Damien "Mistic" Sorel +* @licence MIT (https://opensource.org/licenses/MIT) +*/ +(function (global, factory) { + 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.VideoPlugin = {}), global.THREE, global.PhotoSphereViewer)); +})(this, (function (exports, THREE, photoSphereViewer) { 'use strict'; + + 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) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + + _setPrototypeOf(subClass, superClass); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + var EVENTS = { + /** + * @event play + * @memberof PSV.plugins.VideoPlugin + * @summary Triggered when the video starts playing + */ + PLAY: 'play', + + /** + * @event pause + * @memberof PSV.plugins.VideoPlugin + * @summary Triggered when the video is paused + */ + PAUSE: 'pause', + + /** + * @event volume-change + * @memberof PSV.plugins.VideoPlugin + * @summary Triggered when the video volume changes + * @param {number} volume + */ + VOLUME_CHANGE: 'volume-change', + + /** + * @event progress + * @memberof PSV.plugins.VideoPlugin + * @summary Triggered when the video play progression changes + * @param {{time: number, duration: number, progress: number}} data + */ + PROGRESS: 'progress', + + /** + * @event buffer + * @memberof PSV.plugins.VideoPlugin + * @summary Triggered when the video buffer changes + * @param {number} maxBuffer + */ + BUFFER: 'buffer' + }; + + var playIcon = "\n"; + + /** + * @private + */ + + var PauseOverlay = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(PauseOverlay, _AbstractComponent); + + function PauseOverlay(plugin) { + var _this; + + _this = _AbstractComponent.call(this, plugin.psv, 'psv-video-overlay') || this; + /** + * @type {PSV.plugins.VideoPlugin} + * @private + * @readonly + */ + + _this.plugin = plugin; + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + _this.button = document.createElement('button'); + _this.button.className = 'psv-video-bigbutton'; + _this.button.innerHTML = playIcon; + + _this.container.appendChild(_this.button); + + _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.PLAY, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.PAUSE, _assertThisInitialized(_this)); + + _this.button.addEventListener('click', _assertThisInitialized(_this)); + + return _this; + } + /** + * @private + */ + + + var _proto = PauseOverlay.prototype; + + _proto.destroy = function destroy() { + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); + this.plugin.off(EVENTS.PLAY, this); + this.plugin.off(EVENTS.PAUSE, this); + delete this.plugin; + + _AbstractComponent.prototype.destroy.call(this); + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED: + case EVENTS.PLAY: + case EVENTS.PAUSE: + photoSphereViewer.utils.toggleClass(this.button, 'psv-video-bigbutton--pause', !this.plugin.isPlaying()); + break; + + case 'click': + this.plugin.playPause(); + break; + } + /* eslint-enable */ + + }; + + return PauseOverlay; + }(photoSphereViewer.AbstractComponent); + + var pauseIcon = "\n"; + + /** + * @summary Navigation bar video play/pause button + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ + + var PlayPauseButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(PlayPauseButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + */ + function PlayPauseButton(navbar) { + var _this; + + _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-video-play-button', true) || this; + /** + * @type {PSV.plugins.VideoPlugin} + * @private + * @readonly + */ + + _this.plugin = _this.psv.getPlugin('video'); + + if (_this.plugin) { + _this.plugin.on(EVENTS.PLAY, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.PAUSE, _assertThisInitialized(_this)); + } + + return _this; + } + /** + * @override + */ + + + var _proto = PlayPauseButton.prototype; + + _proto.destroy = function destroy() { + if (this.plugin) { + this.plugin.off(EVENTS.PLAY, this); + this.plugin.off(EVENTS.PAUSE, this); + } + + delete this.plugin; + + _AbstractButton.prototype.destroy.call(this); + } + /** + * @override + */ + ; + + _proto.isSupported = function isSupported() { + return !!this.plugin; + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case EVENTS.PLAY: + case EVENTS.PAUSE: + this.toggleActive(this.plugin.isPlaying()); + break; + } + /* eslint-enable */ + + } + /** + * @override + * @description Toggles video playback + */ + ; + + _proto.onClick = function onClick() { + this.plugin.playPause(); + }; + + return PlayPauseButton; + }(photoSphereViewer.AbstractButton); + PlayPauseButton.id = 'videoPlay'; + PlayPauseButton.groupId = 'video'; + PlayPauseButton.icon = playIcon; + PlayPauseButton.iconActive = pauseIcon; + + /** + * @private + */ + function formatTime(time) { + var seconds = Math.round(time % 60); + var minutes = Math.round(time - seconds) / 60; + return minutes + ":" + ('0' + seconds).slice(-2); + } + + /** + * @private + */ + + var ProgressBar = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(ProgressBar, _AbstractComponent); + + function ProgressBar(plugin) { + var _this; + + _this = _AbstractComponent.call(this, plugin.psv, 'psv-video-progressbar') || this; + /** + * @type {PSV.plugins.VideoPlugin} + * @private + * @readonly + */ + + _this.plugin = plugin; + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + _this.bufferElt = document.createElement('div'); + _this.bufferElt.className = 'psv-video-progressbar__buffer'; + + _this.container.appendChild(_this.bufferElt); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + + _this.progressElt = document.createElement('div'); + _this.progressElt.className = 'psv-video-progressbar__progress'; + + _this.container.appendChild(_this.progressElt); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + + _this.handleElt = document.createElement('div'); + _this.handleElt.className = 'psv-video-progressbar__handle'; + + _this.container.appendChild(_this.handleElt); + /** + * @type {PSV.utils.Slider} + * @private + * @readonly + */ + + + _this.slider = new photoSphereViewer.utils.Slider({ + psv: _this.psv, + container: _this.container, + direction: photoSphereViewer.utils.Slider.HORIZONTAL, + onUpdate: function onUpdate(e) { + return _this.__onSliderUpdate(e); + } + }); + + _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.BUFFER, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.PROGRESS, _assertThisInitialized(_this)); + + _this.prop.req = window.requestAnimationFrame(function () { + return _this.__updateProgress(); + }); + + _this.hide(); + + return _this; + } + /** + * @override + */ + + + var _proto = ProgressBar.prototype; + + _proto.destroy = function destroy() { + var _this$prop$tooltip; + + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); + this.plugin.off(EVENTS.BUFFER, this); + this.plugin.off(EVENTS.PROGRESS, this); + this.slider.destroy(); + (_this$prop$tooltip = this.prop.tooltip) == null ? void 0 : _this$prop$tooltip.hide(); + window.cancelAnimationFrame(this.prop.req); + delete this.prop.tooltip; + delete this.slider; + delete this.plugin; + + _AbstractComponent.prototype.destroy.call(this); + } + /** + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED: + case EVENTS.BUFFER: + case EVENTS.PROGRESS: + this.bufferElt.style.width = this.plugin.getBufferProgress() * 100 + "%"; + break; + } + /* eslint-enable */ + + } + /** + * @private + */ + ; + + _proto.__updateProgress = function __updateProgress() { + var _this2 = this; + + this.progressElt.style.width = this.plugin.getProgress() * 100 + "%"; + this.prop.req = window.requestAnimationFrame(function () { + return _this2.__updateProgress(); + }); + } + /** + * @private + */ + ; + + _proto.__onSliderUpdate = function __onSliderUpdate(e) { + if (e.mouseover) { + this.handleElt.style.display = 'block'; + this.handleElt.style.left = e.value * 100 + "%"; + var time = formatTime(this.plugin.getDuration() * e.value); + + if (!this.prop.tooltip) { + this.prop.tooltip = this.psv.tooltip.create({ + top: e.cursor.clientY, + left: e.cursor.clientX, + content: time + }); + } else { + this.prop.tooltip.content.innerHTML = time; + this.prop.tooltip.move({ + top: e.cursor.clientY, + left: e.cursor.clientX + }); + } + } else { + var _this$prop$tooltip2; + + this.handleElt.style.display = 'none'; + (_this$prop$tooltip2 = this.prop.tooltip) == null ? void 0 : _this$prop$tooltip2.hide(); + delete this.prop.tooltip; + } + + if (e.click) { + this.plugin.setProgress(e.value); + } + }; + + return ProgressBar; + }(photoSphereViewer.AbstractComponent); + + /** + * @summary Navigation bar video time display + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ + + var TimeCaption = /*#__PURE__*/function (_AbstractComponent) { + _inheritsLoose(TimeCaption, _AbstractComponent); + + /** + * @param {PSV.components.Navbar} navbar + */ + function TimeCaption(navbar) { + var _this; + + _this = _AbstractComponent.call(this, navbar, 'psv-caption psv-video-time') || this; + /** + * @member {HTMLElement} + * @readonly + * @private + */ + + _this.content = document.createElement('div'); + _this.content.className = 'psv-caption-content'; + + _this.container.appendChild(_this.content); + /** + * @type {PSV.plugins.VideoPlugin} + * @private + * @readonly + */ + + + _this.plugin = _this.psv.getPlugin('video'); + + if (_this.plugin) { + _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.PROGRESS, _assertThisInitialized(_this)); + } + + return _this; + } + /** + * @override + */ + + + var _proto = TimeCaption.prototype; + + _proto.destroy = function destroy() { + if (this.plugin) { + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); + this.plugin.off(EVENTS.PROGRESS, this); + } + + delete this.plugin; + + _AbstractComponent.prototype.destroy.call(this); + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED: + case EVENTS.PROGRESS: + this.content.innerHTML = "" + formatTime(this.plugin.getTime()) + " / " + formatTime(this.plugin.getDuration()); + break; + } + /* eslint-enable */ + + }; + + return TimeCaption; + }(photoSphereViewer.AbstractComponent); + TimeCaption.id = 'videoTime'; + TimeCaption.groupId = 'video'; + + var volumeIcon = "\n"; + + /** + * @summary Navigation bar video volume button + * @extends PSV.buttons.AbstractButton + * @memberof PSV.buttons + */ + + var VolumeButton = /*#__PURE__*/function (_AbstractButton) { + _inheritsLoose(VolumeButton, _AbstractButton); + + /** + * @param {PSV.components.Navbar} navbar + */ + function VolumeButton(navbar) { + var _this; + + _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-video-volume-button', true) || this; + /** + * @type {PSV.plugins.VideoPlugin} + * @private + * @readonly + */ + + _this.plugin = _this.psv.getPlugin('video'); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + _this.rangeContainer = document.createElement('div'); + _this.rangeContainer.className = 'psv-video-volume__container'; + + _this.container.appendChild(_this.rangeContainer); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + + _this.range = document.createElement('div'); + _this.range.className = 'psv-video-volume__range'; + + _this.rangeContainer.appendChild(_this.range); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + + _this.trackElt = document.createElement('div'); + _this.trackElt.className = 'psv-video-volume__track'; + + _this.range.appendChild(_this.trackElt); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + + _this.progressElt = document.createElement('div'); + _this.progressElt.className = 'psv-video-volume__progress'; + + _this.range.appendChild(_this.progressElt); + /** + * @type {HTMLElement} + * @private + * @readonly + */ + + + _this.handleElt = document.createElement('div'); + _this.handleElt.className = 'psv-video-volume__handle'; + + _this.range.appendChild(_this.handleElt); + /** + * @type {PSV.utils.Slider} + * @private + * @readonly + */ + + + _this.slider = new photoSphereViewer.utils.Slider({ + psv: _this.psv, + container: _this.range, + direction: photoSphereViewer.utils.Slider.VERTICAL, + onUpdate: function onUpdate(e) { + return _this.__onSliderUpdate(e); + } + }); + + if (_this.plugin) { + _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.PLAY, _assertThisInitialized(_this)); + + _this.plugin.on(EVENTS.VOLUME_CHANGE, _assertThisInitialized(_this)); + + _this.__setVolume(0); + } + + return _this; + } + /** + * @override + */ + + + var _proto = VolumeButton.prototype; + + _proto.destroy = function destroy() { + if (this.plugin) { + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); + this.plugin.off(EVENTS.PLAY, this); + this.plugin.off(EVENTS.VOLUME_CHANGE, this); + } + + this.slider.destroy(); + delete this.plugin; + + _AbstractButton.prototype.destroy.call(this); + } + /** + * @override + */ + ; + + _proto.isSupported = function isSupported() { + return !!this.plugin; + } + /** + * @summary Handles events + * @param {Event} e + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + /* eslint-disable */ + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED: + case EVENTS.PLAY: + case EVENTS.VOLUME_CHANGE: + this.__setVolume(this.plugin.getVolume()); + + break; + } + /* eslint-enable */ + + } + /** + * @override + * @description Toggles video muted + */ + ; + + _proto.onClick = function onClick() { + this.plugin.setMute(); + } + /** + * @private + */ + ; + + _proto.__onSliderUpdate = function __onSliderUpdate(e) { + if (e.mousedown) { + this.plugin.setVolume(e.value); + } + } + /** + * @private + */ + ; + + _proto.__setVolume = function __setVolume(volume) { + var level; + if (volume === 0) level = 0;else if (volume < 0.333) level = 1;else if (volume < 0.666) level = 2;else level = 3; + photoSphereViewer.utils.toggleClass(this.container, 'psv-video-volume-button--0', level === 0); + photoSphereViewer.utils.toggleClass(this.container, 'psv-video-volume-button--1', level === 1); + photoSphereViewer.utils.toggleClass(this.container, 'psv-video-volume-button--2', level === 2); + photoSphereViewer.utils.toggleClass(this.container, 'psv-video-volume-button--3', level === 3); + this.handleElt.style.bottom = volume * 100 + "%"; + this.progressElt.style.height = volume * 100 + "%"; + }; + + return VolumeButton; + }(photoSphereViewer.AbstractButton); + VolumeButton.id = 'videoVolume'; + VolumeButton.groupId = 'video'; + VolumeButton.icon = volumeIcon; + + /** + * @typedef {Object} PSV.plugins.VideoPlugin.Keypoint + * @property {PSV.ExtendedPosition} position + * @property {number} time + */ + + /** + * @typedef {Object} PSV.plugins.VideoPlugin.Options + * @property {boolean} [progressbar=true] - displays a progressbar on top of the navbar + * @property {boolean} [bigbutton=true] - displays a big "play" button in the center of the viewer + * @property {PSV.plugins.VideoPlugin.Keypoint[]} [keypoints] - defines autorotate timed keypoints + */ + // add video buttons + + photoSphereViewer.DEFAULTS.lang[PlayPauseButton.id] = 'Play/Pause'; + photoSphereViewer.DEFAULTS.lang[VolumeButton.id] = 'Volume'; + photoSphereViewer.registerButton(PlayPauseButton); + photoSphereViewer.registerButton(VolumeButton); + photoSphereViewer.registerButton(TimeCaption); + photoSphereViewer.DEFAULTS.navbar.unshift(PlayPauseButton.groupId); + /** + * @summary Controls a video adapter + * @extends PSV.plugins.AbstractPlugin + * @memberof PSV.plugins + */ + + var VideoPlugin = /*#__PURE__*/function (_AbstractPlugin) { + _inheritsLoose(VideoPlugin, _AbstractPlugin); + + /** + * @param {PSV.Viewer} psv + * @param {PSV.plugins.VideoPlugin.Options} options + */ + function VideoPlugin(psv, options) { + var _this; + + _this = _AbstractPlugin.call(this, psv) || this; + + if (!_this.psv.adapter.constructor.id.includes('video')) { + throw new photoSphereViewer.PSVError('VideoPlugin can only be used with a video adapter.'); + } + /** + * @member {Object} + * @property {THREE.SplineCurve} curve + * @property {PSV.plugins.VideoPlugin.Keypoint} start + * @property {PSV.plugins.VideoPlugin.Keypoint} end + * @property {PSV.plugins.VideoPlugin.Keypoint[]} keypoints + * @private + */ + + + _this.autorotate = { + curve: null, + start: null, + end: null, + keypoints: null + }; + /** + * @member {PSV.plugins.VideoPlugin.Options} + * @private + */ + + _this.config = _extends({ + progressbar: true, + bigbutton: true + }, options); + + if (_this.config.progressbar) { + _this.progressbar = new ProgressBar(_assertThisInitialized(_this)); + } + + if (_this.config.bigbutton) { + _this.overlay = new PauseOverlay(_assertThisInitialized(_this)); + } + /** + * @type {PSV.plugins.MarkersPlugin} + * @private + */ + + + _this.markers = null; + return _this; + } + /** + * @package + */ + + + var _proto = VideoPlugin.prototype; + + _proto.init = function init() { + _AbstractPlugin.prototype.init.call(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); + this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); + this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.KEY_PRESS, this); + } + /** + * @package + */ + ; + + _proto.destroy = function destroy() { + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.AUTOROTATE, this); + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this); + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED, this); + this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.KEY_PRESS, this); + delete this.autorotate; + delete this.progressbar; + delete this.overlay; + + _AbstractPlugin.prototype.destroy.call(this); + } + /** + * @private + */ + ; + + _proto.handleEvent = function handleEvent(e) { + var _this$progressbar; + + /* eslint-disable */ + // @formatter:off + switch (e.type) { + case photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER: + this.__autorotate(); + + break; + + case photoSphereViewer.CONSTANTS.EVENTS.AUTOROTATE: + this.__configureAutorotate(); + + break; + + case photoSphereViewer.CONSTANTS.EVENTS.PANORAMA_LOADED: + this.__bindVideo(e.args[0]); + + (_this$progressbar = this.progressbar) == null ? void 0 : _this$progressbar.show(); + break; + + case photoSphereViewer.CONSTANTS.EVENTS.KEY_PRESS: + this.__onKeyPress(e, e.args[0]); + + break; + + case 'play': + this.trigger(EVENTS.PLAY); + break; + + case 'pause': + this.trigger(EVENTS.PAUSE); + break; + + case 'progress': + this.trigger(EVENTS.BUFFER, this.getBufferProgress()); + break; + + case 'volumechange': + this.trigger(EVENTS.VOLUME_CHANGE, this.getVolume()); + break; + + case 'timeupdate': + this.trigger(EVENTS.PROGRESS, { + time: this.getTime(), + duration: this.getDuration(), + progress: this.getProgress() + }); + break; + } // @formatter:on + + /* eslint-enable */ + + } + /** + * @private + */ + ; + + _proto.__bindVideo = function __bindVideo(textureData) { + this.video = textureData.texture.image; + this.video.addEventListener('play', this); + this.video.addEventListener('pause', this); + this.video.addEventListener('progress', this); + this.video.addEventListener('volumechange', this); + this.video.addEventListener('timeupdate', this); + } + /** + * @private + */ + ; + + _proto.__onKeyPress = function __onKeyPress(e, key) { + if (key === photoSphereViewer.CONSTANTS.KEY_CODES.Space) { + this.playPause(); + e.preventDefault(); + } + } + /** + * @summary Returns the durection of the video + * @returns {number} + */ + ; + + _proto.getDuration = function getDuration() { + var _this$video$duration, _this$video; + + return (_this$video$duration = (_this$video = this.video) == null ? void 0 : _this$video.duration) != null ? _this$video$duration : 0; + } + /** + * @summary Returns the current time of the video + * @returns {number} + */ + ; + + _proto.getTime = function getTime() { + var _this$video$currentTi, _this$video2; + + return (_this$video$currentTi = (_this$video2 = this.video) == null ? void 0 : _this$video2.currentTime) != null ? _this$video$currentTi : 0; + } + /** + * @summary Returns the play progression of the video + * @returns {number} 0-1 + */ + ; + + _proto.getProgress = function getProgress() { + return this.video ? this.video.currentTime / this.video.duration : 0; + } + /** + * @summary Returns if the video is playing + * @returns {boolean} + */ + ; + + _proto.isPlaying = function isPlaying() { + return this.video ? !this.video.paused : false; + } + /** + * @summary Returns the video volume + * @returns {number} + */ + ; + + _proto.getVolume = function getVolume() { + var _this$video3, _this$video$volume, _this$video4; + + return (_this$video3 = this.video) != null && _this$video3.muted ? 0 : (_this$video$volume = (_this$video4 = this.video) == null ? void 0 : _this$video4.volume) != null ? _this$video$volume : 0; + } + /** + * @summary Starts or pause the video + */ + ; + + _proto.playPause = function playPause() { + if (this.video) { + if (this.video.paused) { + this.video.play(); + } else { + this.video.pause(); + } + } + } + /** + * @summary Starts the video if paused + */ + ; + + _proto.play = function play() { + if (this.video && this.video.paused) { + this.video.play(); + } + } + /** + * @summary Pauses the cideo if playing + */ + ; + + _proto.pause = function pause() { + if (this.video && !this.video.paused) { + this.video.pause(); + } + } + /** + * @summary Sets the volume of the video + * @param {number} volume + */ + ; + + _proto.setVolume = function setVolume(volume) { + if (this.video) { + this.video.muted = false; + this.video.volume = volume; + } + } + /** + * @summary (Un)mutes the video + * @param {boolean} [mute] - toggle if undefined + */ + ; + + _proto.setMute = function setMute(mute) { + if (this.video) { + this.video.muted = mute === undefined ? !this.video.muted : mute; + + if (!this.video.muted && this.video.volume === 0) { + this.video.volume = 0.1; + } + } + } + /** + * @summary Changes the current time of the video + * @param {number} time + */ + ; + + _proto.setTime = function setTime(time) { + if (this.video) { + this.video.currentTime = time; + } + } + /** + * @summary Changes the progression of the video + * @param {number} progress 0-1 + */ + ; + + _proto.setProgress = function setProgress(progress) { + if (this.video) { + this.video.currentTime = this.video.duration * progress; + } + }; + + _proto.getBufferProgress = function getBufferProgress() { + if (this.video) { + var maxBuffer = 0; + var buffer = this.video.buffered; + + for (var i = 0, l = buffer.length; i < l; i++) { + if (buffer.start(i) <= this.video.currentTime && buffer.end(i) >= this.video.currentTime) { + maxBuffer = buffer.end(i); + break; + } + } + + return Math.max(this.video.currentTime, maxBuffer) / this.video.duration; + } else { + return 0; + } + } + /** + * @summary Changes the keypoints + * @param {PSV.plugins.VideoPlugin.Keypoint[]} keypoints + */ + ; + + _proto.setKeypoints = function setKeypoints(keypoints) { + var _this2 = this; + + if (keypoints && keypoints.length < 2) { + throw new photoSphereViewer.PSVError('At least two points are required'); + } + + this.autorotate.keypoints = photoSphereViewer.utils.clone(keypoints); + + if (this.autorotate.keypoints) { + this.autorotate.keypoints.forEach(function (pt, i) { + if (pt.position) { + var position = _this2.psv.dataHelper.cleanPosition(pt.position); + + pt.position = [position.longitude, position.latitude]; + } else { + throw new photoSphereViewer.PSVError("Keypoint #" + i + " is missing marker or position"); + } + + if (photoSphereViewer.utils.isNil(pt.time)) { + throw new photoSphereViewer.PSVError("Keypoint #" + i + " is missing time"); + } + }); + this.autorotate.keypoints.sort(function (a, b) { + return a.time - b.time; + }); + } + + this.__configureAutorotate(); + } + /** + * @private + */ + ; + + _proto.__configureAutorotate = function __configureAutorotate() { + delete this.autorotate.curve; + delete this.autorotate.start; + delete this.autorotate.end; + + if (this.psv.isAutorotateEnabled() && this.autorotate.keypoints) { + // cancel core rotation + this.psv.dynamics.position.stop(); + } + } + /** + * @private + */ + ; + + _proto.__autorotate = function __autorotate() { + if (!this.psv.isAutorotateEnabled() || !this.autorotate.keypoints) { + return; + } + + var currentTime = this.getTime(); + var autorotate = this.autorotate; + + if (!autorotate.curve || currentTime < autorotate.start.time || currentTime >= autorotate.end.time) { + this.__autorotateNext(currentTime); + } + + if (autorotate.start === autorotate.end) { + this.psv.rotate({ + longitude: autorotate.start.position[0], + latitude: autorotate.start.position[1] + }); + } else { + var progress = (currentTime - autorotate.start.time) / (autorotate.end.time - autorotate.start.time); // only the middle segment contains the current section + + var pt = autorotate.curve.getPoint(1 / 3 + progress / 3); + this.psv.dynamics.position.goto({ + longitude: pt.x, + latitude: pt.y + }); + } + } + /** + * @private + */ + ; + + _proto.__autorotateNext = function __autorotateNext(currentTime) { + var k1 = null; + var k2 = null; + var keypoints = this.autorotate.keypoints; + var l = keypoints.length - 1; + + if (currentTime < keypoints[0].time) { + k1 = 0; + k2 = 0; + } + + for (var i = 0; i < l; i++) { + if (currentTime >= keypoints[i].time && currentTime < keypoints[i + 1].time) { + k1 = i; + k2 = i + 1; + break; + } + } + + if (currentTime >= keypoints[l].time) { + k1 = l; + k2 = l; + } // get the 4 points necessary to compute the current movement + // one point before and two points after the current + + + var workPoints = [keypoints[Math.max(0, k1 - 1)].position, keypoints[k1].position, keypoints[k2].position, keypoints[Math.min(l, k2 + 1)].position]; // apply offsets to avoid crossing the origin + + var workVectors = [new THREE.Vector2(workPoints[0][0], workPoints[0][1])]; + var k = 0; + + for (var _i = 1; _i <= 3; _i++) { + var d = workPoints[_i - 1][0] - workPoints[_i][0]; + + if (d > Math.PI) { + // crossed the origin left to right + k += 1; + } else if (d < -Math.PI) { + // crossed the origin right to left + k -= 1; + } + + if (k !== 0 && _i === 1) { + // do not modify first point, apply the reverse offset the the previous point instead + workVectors[0].x -= k * 2 * Math.PI; + k = 0; + } + + workVectors.push(new THREE.Vector2(workPoints[_i][0] + k * 2 * Math.PI, workPoints[_i][1])); + } + + this.autorotate.curve = new THREE.SplineCurve(workVectors); + this.autorotate.start = keypoints[k1]; + this.autorotate.end = keypoints[k2]; // debugCurve(this.markers, this.autorotate.curve.getPoints(16 * 3).map(p => ([p.x, p.y])), 16); + }; + + return VideoPlugin; + }(photoSphereViewer.AbstractPlugin); + VideoPlugin.id = 'video'; + VideoPlugin.EVENTS = EVENTS; + + exports.EVENTS = EVENTS; + exports.VideoPlugin = VideoPlugin; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=video.js.map diff --git a/dist/plugins/video.js.map b/dist/plugins/video.js.map new file mode 100644 index 000000000..2eb44438b --- /dev/null +++ b/dist/plugins/video.js.map @@ -0,0 +1 @@ +{"version":3,"file":"video.js","sources":["../../src/plugins/video/constants.js","../../src/plugins/video/PauseOverlay.js","../../src/plugins/video/PlayPauseButton.js","../../src/plugins/video/utils.js","../../src/plugins/video/ProgressBar.js","../../src/plugins/video/TimeCaption.js","../../src/plugins/video/VolumeButton.js","../../src/plugins/video/index.js"],"sourcesContent":["export const EVENTS = {\n /**\n * @event play\n * @memberof PSV.plugins.VideoPlugin\n * @summary Triggered when the video starts playing\n */\n PLAY : 'play',\n /**\n * @event pause\n * @memberof PSV.plugins.VideoPlugin\n * @summary Triggered when the video is paused\n */\n PAUSE : 'pause',\n /**\n * @event volume-change\n * @memberof PSV.plugins.VideoPlugin\n * @summary Triggered when the video volume changes\n * @param {number} volume\n */\n VOLUME_CHANGE: 'volume-change',\n /**\n * @event progress\n * @memberof PSV.plugins.VideoPlugin\n * @summary Triggered when the video play progression changes\n * @param {{time: number, duration: number, progress: number}} data\n */\n PROGRESS : 'progress',\n /**\n * @event buffer\n * @memberof PSV.plugins.VideoPlugin\n * @summary Triggered when the video buffer changes\n * @param {number} maxBuffer\n */\n BUFFER : 'buffer',\n};\n","import { AbstractComponent, CONSTANTS, utils } from '../..';\nimport { EVENTS } from './constants';\nimport playIcon from './play.svg';\n\n/**\n * @private\n */\nexport class PauseOverlay extends AbstractComponent {\n\n constructor(plugin) {\n super(plugin.psv, 'psv-video-overlay');\n\n /**\n * @type {PSV.plugins.VideoPlugin}\n * @private\n * @readonly\n */\n this.plugin = plugin;\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.button = document.createElement('button');\n this.button.className = 'psv-video-bigbutton';\n this.button.innerHTML = playIcon;\n this.container.appendChild(this.button);\n\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.on(EVENTS.PLAY, this);\n this.plugin.on(EVENTS.PAUSE, this);\n this.button.addEventListener('click', this);\n }\n\n /**\n * @private\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.off(EVENTS.PLAY, this);\n this.plugin.off(EVENTS.PAUSE, this);\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.PANORAMA_LOADED:\n case EVENTS.PLAY:\n case EVENTS.PAUSE:\n utils.toggleClass(this.button, 'psv-video-bigbutton--pause', !this.plugin.isPlaying());\n break;\n case 'click':\n this.plugin.playPause();\n break;\n }\n /* eslint-enable */\n }\n\n}\n","import { AbstractButton } from '../..';\nimport { EVENTS } from './constants';\nimport pauseIcon from './pause.svg';\nimport playIcon from './play.svg';\n\n/**\n * @summary Navigation bar video play/pause button\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class PlayPauseButton extends AbstractButton {\n\n static id = 'videoPlay';\n static groupId = 'video';\n static icon = playIcon;\n static iconActive = pauseIcon;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-video-play-button', true);\n\n /**\n * @type {PSV.plugins.VideoPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('video');\n\n if (this.plugin) {\n this.plugin.on(EVENTS.PLAY, this);\n this.plugin.on(EVENTS.PAUSE, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.plugin.off(EVENTS.PLAY, this);\n this.plugin.off(EVENTS.PAUSE, this);\n }\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case EVENTS.PLAY:\n case EVENTS.PAUSE:\n this.toggleActive(this.plugin.isPlaying());\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles video playback\n */\n onClick() {\n this.plugin.playPause();\n }\n\n}\n","/**\n * @private\n */\nexport function formatTime(time) {\n const seconds = Math.round(time % 60);\n const minutes = Math.round(time - seconds) / 60;\n return `${minutes}:${('0' + seconds).slice(-2)}`;\n}\n","import { AbstractComponent, CONSTANTS, utils } from '../..';\nimport { EVENTS } from './constants';\nimport { formatTime } from './utils';\n\n/**\n * @private\n */\nexport class ProgressBar extends AbstractComponent {\n\n constructor(plugin) {\n super(plugin.psv, 'psv-video-progressbar');\n\n /**\n * @type {PSV.plugins.VideoPlugin}\n * @private\n * @readonly\n */\n this.plugin = plugin;\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.bufferElt = document.createElement('div');\n this.bufferElt.className = 'psv-video-progressbar__buffer';\n this.container.appendChild(this.bufferElt);\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.progressElt = document.createElement('div');\n this.progressElt.className = 'psv-video-progressbar__progress';\n this.container.appendChild(this.progressElt);\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.handleElt = document.createElement('div');\n this.handleElt.className = 'psv-video-progressbar__handle';\n this.container.appendChild(this.handleElt);\n\n /**\n * @type {PSV.utils.Slider}\n * @private\n * @readonly\n */\n this.slider = new utils.Slider({\n psv : this.psv,\n container: this.container,\n direction: utils.Slider.HORIZONTAL,\n onUpdate : e => this.__onSliderUpdate(e),\n });\n\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.on(EVENTS.BUFFER, this);\n this.plugin.on(EVENTS.PROGRESS, this);\n\n this.prop.req = window.requestAnimationFrame(() => this.__updateProgress());\n\n this.hide();\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.off(EVENTS.BUFFER, this);\n this.plugin.off(EVENTS.PROGRESS, this);\n\n this.slider.destroy();\n this.prop.tooltip?.hide();\n window.cancelAnimationFrame(this.prop.req);\n\n delete this.prop.tooltip;\n delete this.slider;\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.PANORAMA_LOADED:\n case EVENTS.BUFFER:\n case EVENTS.PROGRESS:\n this.bufferElt.style.width = `${this.plugin.getBufferProgress() * 100}%`;\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @private\n */\n __updateProgress() {\n this.progressElt.style.width = `${this.plugin.getProgress() * 100}%`;\n\n this.prop.req = window.requestAnimationFrame(() => this.__updateProgress());\n }\n\n /**\n * @private\n */\n __onSliderUpdate(e) {\n if (e.mouseover) {\n this.handleElt.style.display = 'block';\n this.handleElt.style.left = `${e.value * 100}%`;\n\n const time = formatTime(this.plugin.getDuration() * e.value);\n\n if (!this.prop.tooltip) {\n this.prop.tooltip = this.psv.tooltip.create({\n top : e.cursor.clientY,\n left : e.cursor.clientX,\n content: time,\n });\n }\n else {\n this.prop.tooltip.content.innerHTML = time;\n this.prop.tooltip.move({\n top : e.cursor.clientY,\n left: e.cursor.clientX,\n });\n }\n }\n else {\n this.handleElt.style.display = 'none';\n\n this.prop.tooltip?.hide();\n delete this.prop.tooltip;\n }\n if (e.click) {\n this.plugin.setProgress(e.value);\n }\n }\n\n}\n","import { AbstractComponent, CONSTANTS } from '../..';\nimport { EVENTS } from './constants';\nimport { formatTime } from './utils';\n\n/**\n * @summary Navigation bar video time display\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class TimeCaption extends AbstractComponent {\n\n static id = 'videoTime';\n static groupId = 'video';\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-caption psv-video-time');\n\n /**\n * @member {HTMLElement}\n * @readonly\n * @private\n */\n this.content = document.createElement('div');\n this.content.className = 'psv-caption-content';\n this.container.appendChild(this.content);\n\n /**\n * @type {PSV.plugins.VideoPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('video');\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.on(EVENTS.PROGRESS, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.off(EVENTS.PROGRESS, this);\n }\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.PANORAMA_LOADED:\n case EVENTS.PROGRESS:\n this.content.innerHTML = `${formatTime(this.plugin.getTime())} / ${formatTime(this.plugin.getDuration())}`;\n break;\n }\n /* eslint-enable */\n }\n\n}\n","import { AbstractButton, CONSTANTS, utils } from '../..';\nimport { EVENTS } from './constants';\nimport volumeIcon from './volume.svg';\n\n/**\n * @summary Navigation bar video volume button\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class VolumeButton extends AbstractButton {\n\n static id = 'videoVolume';\n static groupId = 'video';\n static icon = volumeIcon;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-video-volume-button', true);\n\n /**\n * @type {PSV.plugins.VideoPlugin}\n * @private\n * @readonly\n */\n this.plugin = this.psv.getPlugin('video');\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.rangeContainer = document.createElement('div');\n this.rangeContainer.className = 'psv-video-volume__container';\n this.container.appendChild(this.rangeContainer);\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.range = document.createElement('div');\n this.range.className = 'psv-video-volume__range';\n this.rangeContainer.appendChild(this.range);\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.trackElt = document.createElement('div');\n this.trackElt.className = 'psv-video-volume__track';\n this.range.appendChild(this.trackElt);\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.progressElt = document.createElement('div');\n this.progressElt.className = 'psv-video-volume__progress';\n this.range.appendChild(this.progressElt);\n\n /**\n * @type {HTMLElement}\n * @private\n * @readonly\n */\n this.handleElt = document.createElement('div');\n this.handleElt.className = 'psv-video-volume__handle';\n this.range.appendChild(this.handleElt);\n\n /**\n * @type {PSV.utils.Slider}\n * @private\n * @readonly\n */\n this.slider = new utils.Slider({\n psv : this.psv,\n container: this.range,\n direction: utils.Slider.VERTICAL,\n onUpdate : e => this.__onSliderUpdate(e),\n });\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.on(EVENTS.PLAY, this);\n this.plugin.on(EVENTS.VOLUME_CHANGE, this);\n\n this.__setVolume(0);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n if (this.plugin) {\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.plugin.off(EVENTS.PLAY, this);\n this.plugin.off(EVENTS.VOLUME_CHANGE, this);\n }\n\n this.slider.destroy();\n\n delete this.plugin;\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin;\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n case CONSTANTS.EVENTS.PANORAMA_LOADED:\n case EVENTS.PLAY:\n case EVENTS.VOLUME_CHANGE:\n this.__setVolume(this.plugin.getVolume());\n break;\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles video muted\n */\n onClick() {\n this.plugin.setMute();\n }\n\n /**\n * @private\n */\n __onSliderUpdate(e) {\n if (e.mousedown) {\n this.plugin.setVolume(e.value);\n }\n }\n\n /**\n * @private\n */\n __setVolume(volume) {\n let level;\n if (volume === 0) level = 0;\n else if (volume < 0.333) level = 1;\n else if (volume < 0.666) level = 2;\n else level = 3;\n\n utils.toggleClass(this.container, 'psv-video-volume-button--0', level === 0);\n utils.toggleClass(this.container, 'psv-video-volume-button--1', level === 1);\n utils.toggleClass(this.container, 'psv-video-volume-button--2', level === 2);\n utils.toggleClass(this.container, 'psv-video-volume-button--3', level === 3);\n\n this.handleElt.style.bottom = `${volume * 100}%`;\n this.progressElt.style.height = `${volume * 100}%`;\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport { EVENTS } from './constants';\nimport { PauseOverlay } from './PauseOverlay';\nimport { PlayPauseButton } from './PlayPauseButton';\nimport { ProgressBar } from './ProgressBar';\nimport { TimeCaption } from './TimeCaption';\nimport { VolumeButton } from './VolumeButton';\nimport './style.scss';\n\n\n/**\n * @typedef {Object} PSV.plugins.VideoPlugin.Keypoint\n * @property {PSV.ExtendedPosition} position\n * @property {number} time\n */\n\n/**\n * @typedef {Object} PSV.plugins.VideoPlugin.Options\n * @property {boolean} [progressbar=true] - displays a progressbar on top of the navbar\n * @property {boolean} [bigbutton=true] - displays a big \"play\" button in the center of the viewer\n * @property {PSV.plugins.VideoPlugin.Keypoint[]} [keypoints] - defines autorotate timed keypoints\n */\n\n\n// add video buttons\nDEFAULTS.lang[PlayPauseButton.id] = 'Play/Pause';\nDEFAULTS.lang[VolumeButton.id] = 'Volume';\nregisterButton(PlayPauseButton);\nregisterButton(VolumeButton);\nregisterButton(TimeCaption);\nDEFAULTS.navbar.unshift(PlayPauseButton.groupId);\n\n\nexport { EVENTS } from './constants';\n\n\n/**\n * @summary Controls a video adapter\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class VideoPlugin extends AbstractPlugin {\n\n static id = 'video';\n\n static EVENTS = EVENTS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.VideoPlugin.Options} options\n */\n constructor(psv, options) {\n super(psv);\n\n if (!this.psv.adapter.constructor.id.includes('video')) {\n throw new PSVError('VideoPlugin can only be used with a video adapter.');\n }\n\n /**\n * @member {Object}\n * @property {THREE.SplineCurve} curve\n * @property {PSV.plugins.VideoPlugin.Keypoint} start\n * @property {PSV.plugins.VideoPlugin.Keypoint} end\n * @property {PSV.plugins.VideoPlugin.Keypoint[]} keypoints\n * @private\n */\n this.autorotate = {\n curve : null,\n start : null,\n end : null,\n keypoints: null,\n };\n\n /**\n * @member {PSV.plugins.VideoPlugin.Options}\n * @private\n */\n this.config = {\n progressbar: true,\n bigbutton : true,\n ...options,\n };\n\n if (this.config.progressbar) {\n this.progressbar = new ProgressBar(this);\n }\n\n if (this.config.bigbutton) {\n this.overlay = new PauseOverlay(this);\n }\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @private\n */\n this.markers = null;\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n\n if (this.config.keypoints) {\n this.setKeypoints(this.config.keypoints);\n delete this.config.keypoints;\n }\n\n this.psv.on(CONSTANTS.EVENTS.AUTOROTATE, this);\n this.psv.on(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n this.psv.on(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.psv.on(CONSTANTS.EVENTS.KEY_PRESS, this);\n }\n\n /**\n * @package\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.AUTOROTATE, this);\n this.psv.off(CONSTANTS.EVENTS.BEFORE_RENDER, this);\n this.psv.off(CONSTANTS.EVENTS.PANORAMA_LOADED, this);\n this.psv.off(CONSTANTS.EVENTS.KEY_PRESS, this);\n\n delete this.autorotate;\n delete this.progressbar;\n delete this.overlay;\n\n super.destroy();\n }\n\n /**\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n // @formatter:off\n switch (e.type) {\n case CONSTANTS.EVENTS.BEFORE_RENDER:\n this.__autorotate();\n break;\n case CONSTANTS.EVENTS.AUTOROTATE:\n this.__configureAutorotate();\n break;\n case CONSTANTS.EVENTS.PANORAMA_LOADED:\n this.__bindVideo(e.args[0]);\n this.progressbar?.show();\n break;\n case CONSTANTS.EVENTS.KEY_PRESS:\n this.__onKeyPress(e, e.args[0]);\n break;\n case 'play': this.trigger(EVENTS.PLAY); break;\n case 'pause': this.trigger(EVENTS.PAUSE); break;\n case 'progress': this.trigger(EVENTS.BUFFER, this.getBufferProgress()); break;\n case 'volumechange': this.trigger(EVENTS.VOLUME_CHANGE, this.getVolume()); break;\n case 'timeupdate':\n this.trigger(EVENTS.PROGRESS, {\n time : this.getTime(),\n duration: this.getDuration(),\n progress: this.getProgress(),\n });\n break;\n }\n // @formatter:on\n /* eslint-enable */\n }\n\n /**\n * @private\n */\n __bindVideo(textureData) {\n this.video = textureData.texture.image;\n\n this.video.addEventListener('play', this);\n this.video.addEventListener('pause', this);\n this.video.addEventListener('progress', this);\n this.video.addEventListener('volumechange', this);\n this.video.addEventListener('timeupdate', this);\n }\n\n /**\n * @private\n */\n __onKeyPress(e, key) {\n if (key === CONSTANTS.KEY_CODES.Space) {\n this.playPause();\n e.preventDefault();\n }\n }\n\n /**\n * @summary Returns the durection of the video\n * @returns {number}\n */\n getDuration() {\n return this.video?.duration ?? 0;\n }\n\n /**\n * @summary Returns the current time of the video\n * @returns {number}\n */\n getTime() {\n return this.video?.currentTime ?? 0;\n }\n\n /**\n * @summary Returns the play progression of the video\n * @returns {number} 0-1\n */\n getProgress() {\n return this.video ? this.video.currentTime / this.video.duration : 0;\n }\n\n /**\n * @summary Returns if the video is playing\n * @returns {boolean}\n */\n isPlaying() {\n return this.video ? !this.video.paused : false;\n }\n\n /**\n * @summary Returns the video volume\n * @returns {number}\n */\n getVolume() {\n return this.video?.muted ? 0 : this.video?.volume ?? 0;\n }\n\n /**\n * @summary Starts or pause the video\n */\n playPause() {\n if (this.video) {\n if (this.video.paused) {\n this.video.play();\n }\n else {\n this.video.pause();\n }\n }\n }\n\n /**\n * @summary Starts the video if paused\n */\n play() {\n if (this.video && this.video.paused) {\n this.video.play();\n }\n }\n\n /**\n * @summary Pauses the cideo if playing\n */\n pause() {\n if (this.video && !this.video.paused) {\n this.video.pause();\n }\n }\n\n /**\n * @summary Sets the volume of the video\n * @param {number} volume\n */\n setVolume(volume) {\n if (this.video) {\n this.video.muted = false;\n this.video.volume = volume;\n }\n }\n\n /**\n * @summary (Un)mutes the video\n * @param {boolean} [mute] - toggle if undefined\n */\n setMute(mute) {\n if (this.video) {\n this.video.muted = mute === undefined ? !this.video.muted : mute;\n if (!this.video.muted && this.video.volume === 0) {\n this.video.volume = 0.1;\n }\n }\n }\n\n /**\n * @summary Changes the current time of the video\n * @param {number} time\n */\n setTime(time) {\n if (this.video) {\n this.video.currentTime = time;\n }\n }\n\n /**\n * @summary Changes the progression of the video\n * @param {number} progress 0-1\n */\n setProgress(progress) {\n if (this.video) {\n this.video.currentTime = this.video.duration * progress;\n }\n }\n\n getBufferProgress() {\n if (this.video) {\n let maxBuffer = 0;\n\n const buffer = this.video.buffered;\n\n for (let i = 0, l = buffer.length; i < l; i++) {\n if (buffer.start(i) <= this.video.currentTime && buffer.end(i) >= this.video.currentTime) {\n maxBuffer = buffer.end(i);\n break;\n }\n }\n\n return Math.max(this.video.currentTime, maxBuffer) / this.video.duration;\n }\n else {\n return 0;\n }\n }\n\n /**\n * @summary Changes the keypoints\n * @param {PSV.plugins.VideoPlugin.Keypoint[]} keypoints\n */\n setKeypoints(keypoints) {\n if (keypoints && keypoints.length < 2) {\n throw new PSVError('At least two points are required');\n }\n\n this.autorotate.keypoints = utils.clone(keypoints);\n\n if (this.autorotate.keypoints) {\n this.autorotate.keypoints.forEach((pt, i) => {\n if (pt.position) {\n const position = this.psv.dataHelper.cleanPosition(pt.position);\n pt.position = [position.longitude, position.latitude];\n }\n else {\n throw new PSVError(`Keypoint #${i} is missing marker or position`);\n }\n\n if (utils.isNil(pt.time)) {\n throw new PSVError(`Keypoint #${i} is missing time`);\n }\n });\n\n this.autorotate.keypoints.sort((a, b) => a.time - b.time);\n }\n\n this.__configureAutorotate();\n }\n\n /**\n * @private\n */\n __configureAutorotate() {\n delete this.autorotate.curve;\n delete this.autorotate.start;\n delete this.autorotate.end;\n\n if (this.psv.isAutorotateEnabled() && this.autorotate.keypoints) {\n // cancel core rotation\n this.psv.dynamics.position.stop();\n }\n }\n\n /**\n * @private\n */\n __autorotate() {\n if (!this.psv.isAutorotateEnabled() || !this.autorotate.keypoints) {\n return;\n }\n\n const currentTime = this.getTime();\n const autorotate = this.autorotate;\n\n if (!autorotate.curve || currentTime < autorotate.start.time || currentTime >= autorotate.end.time) {\n this.__autorotateNext(currentTime);\n }\n\n if (autorotate.start === autorotate.end) {\n this.psv.rotate({\n longitude: autorotate.start.position[0],\n latitude : autorotate.start.position[1],\n });\n }\n else {\n const progress = (currentTime - autorotate.start.time) / (autorotate.end.time - autorotate.start.time);\n // only the middle segment contains the current section\n const pt = autorotate.curve.getPoint(1 / 3 + progress / 3);\n\n this.psv.dynamics.position.goto({\n longitude: pt.x,\n latitude : pt.y,\n });\n }\n }\n\n /**\n * @private\n */\n __autorotateNext(currentTime) {\n let k1 = null;\n let k2 = null;\n\n const keypoints = this.autorotate.keypoints;\n const l = keypoints.length - 1;\n\n if (currentTime < keypoints[0].time) {\n k1 = 0;\n k2 = 0;\n }\n for (let i = 0; i < l; i++) {\n if (currentTime >= keypoints[i].time && currentTime < keypoints[i + 1].time) {\n k1 = i;\n k2 = i + 1;\n break;\n }\n }\n if (currentTime >= keypoints[l].time) {\n k1 = l;\n k2 = l;\n }\n\n // get the 4 points necessary to compute the current movement\n // one point before and two points after the current\n const workPoints = [\n keypoints[Math.max(0, k1 - 1)].position,\n keypoints[k1].position,\n keypoints[k2].position,\n keypoints[Math.min(l, k2 + 1)].position,\n ];\n\n // apply offsets to avoid crossing the origin\n const workVectors = [new THREE.Vector2(workPoints[0][0], workPoints[0][1])];\n\n let k = 0;\n for (let i = 1; i <= 3; i++) {\n const d = workPoints[i - 1][0] - workPoints[i][0];\n if (d > Math.PI) { // crossed the origin left to right\n k += 1;\n }\n else if (d < -Math.PI) { // crossed the origin right to left\n k -= 1;\n }\n if (k !== 0 && i === 1) {\n // do not modify first point, apply the reverse offset the the previous point instead\n workVectors[0].x -= k * 2 * Math.PI;\n k = 0;\n }\n workVectors.push(new THREE.Vector2(workPoints[i][0] + k * 2 * Math.PI, workPoints[i][1]));\n }\n\n this.autorotate.curve = new THREE.SplineCurve(workVectors);\n this.autorotate.start = keypoints[k1];\n this.autorotate.end = keypoints[k2];\n\n // debugCurve(this.markers, this.autorotate.curve.getPoints(16 * 3).map(p => ([p.x, p.y])), 16);\n }\n\n}\n"],"names":["EVENTS","PLAY","PAUSE","VOLUME_CHANGE","PROGRESS","BUFFER","PauseOverlay","plugin","psv","button","document","createElement","className","innerHTML","playIcon","container","appendChild","on","CONSTANTS","PANORAMA_LOADED","addEventListener","destroy","off","handleEvent","e","type","utils","toggleClass","isPlaying","playPause","AbstractComponent","PlayPauseButton","navbar","getPlugin","isSupported","toggleActive","onClick","AbstractButton","id","groupId","icon","iconActive","pauseIcon","formatTime","time","seconds","Math","round","minutes","slice","ProgressBar","bufferElt","progressElt","handleElt","slider","Slider","direction","HORIZONTAL","onUpdate","__onSliderUpdate","prop","req","window","requestAnimationFrame","__updateProgress","hide","tooltip","cancelAnimationFrame","style","width","getBufferProgress","getProgress","mouseover","display","left","value","getDuration","create","top","cursor","clientY","clientX","content","move","click","setProgress","TimeCaption","getTime","VolumeButton","rangeContainer","range","trackElt","VERTICAL","__setVolume","getVolume","setMute","mousedown","setVolume","volume","level","bottom","height","volumeIcon","DEFAULTS","lang","registerButton","unshift","VideoPlugin","options","adapter","constructor","includes","PSVError","autorotate","curve","start","end","keypoints","config","progressbar","bigbutton","overlay","markers","init","setKeypoints","AUTOROTATE","BEFORE_RENDER","KEY_PRESS","__autorotate","__configureAutorotate","__bindVideo","args","show","__onKeyPress","trigger","duration","progress","textureData","video","texture","image","key","KEY_CODES","Space","preventDefault","currentTime","paused","muted","play","pause","mute","undefined","setTime","maxBuffer","buffer","buffered","i","l","length","max","clone","forEach","pt","position","dataHelper","cleanPosition","longitude","latitude","isNil","sort","a","b","isAutorotateEnabled","dynamics","stop","__autorotateNext","rotate","getPoint","goto","x","y","k1","k2","workPoints","min","workVectors","THREE","Vector2","k","d","PI","push","SplineCurve","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAaA,MAAM,GAAG;EACpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,IAAI,EAAW,MANK;;EAOpB;EACF;EACA;EACA;EACA;EACEC,EAAAA,KAAK,EAAU,OAZK;;EAapB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,aAAa,EAAE,eAnBK;;EAoBpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,QAAQ,EAAO,UA1BK;;EA2BpB;EACF;EACA;EACA;EACA;EACA;EACEC,EAAAA,MAAM,EAAS;EAjCK;;;;ECItB;EACA;EACA;;MACaC,YAAb;EAAA;;EAEE,wBAAYC,MAAZ,EAAoB;EAAA;;EAClB,0CAAMA,MAAM,CAACC,GAAb,EAAkB,mBAAlB;EAEA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ACD,UAAIA,CAAC,KAAK,CAAN,IAAWhC,EAAC,KAAK,CAArB,EAAwB;EACtB;EACA6B,QAAAA,WAAW,CAAC,CAAD,CAAX,CAAeN,CAAf,IAAoBS,CAAC,GAAG,CAAJ,GAAQ9I,IAAI,CAACgJ,EAAjC;EACAF,QAAAA,CAAC,GAAG,CAAJ;EACD;;EACDH,MAAAA,WAAW,CAACM,IAAZ,CAAiB,IAAIL,KAAK,CAACC,OAAV,CAAkBJ,UAAU,CAAC3B,EAAD,CAAV,CAAc,CAAd,IAAmBgC,CAAC,GAAG,CAAJ,GAAQ9I,IAAI,CAACgJ,EAAlD,EAAsDP,UAAU,CAAC3B,EAAD,CAAV,CAAc,CAAd,CAAtD,CAAjB;EACD;;EAED,SAAK3C,UAAL,CAAgBC,KAAhB,GAAwB,IAAIwE,KAAK,CAACM,WAAV,CAAsBP,WAAtB,CAAxB;EACA,SAAKxE,UAAL,CAAgBE,KAAhB,GAAwBE,SAAS,CAACgE,EAAD,CAAjC;EACA,SAAKpE,UAAL,CAAgBG,GAAhB,GAAsBC,SAAS,CAACiE,EAAD,CAA/B,CAtD4B;EAyD7B,GA1aH;;EAAA;EAAA,EAAiCW,gCAAjC;EAAatF,YAEJrE,KAAK;EAFDqE,YAIJ3G,SAASA;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/virtual-tour.css b/dist/plugins/virtual-tour.css index 4dc94b81c..3f99f7650 100644 --- a/dist/plugins/virtual-tour.css +++ b/dist/plugins/virtual-tour.css @@ -1,5 +1,5 @@ /*! - * Photo Sphere Viewer 4.5.3 + * Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) diff --git a/dist/plugins/virtual-tour.d.ts b/dist/plugins/virtual-tour.d.ts index e151b7e0d..36cbbb056 100644 --- a/dist/plugins/virtual-tour.d.ts +++ b/dist/plugins/virtual-tour.d.ts @@ -14,6 +14,7 @@ type VirtualTourNode = { sphereCorrection?: ViewerOptions['sphereCorrection']; name?: string; caption?: string; + description?: string; markers?: Marker[]; }; @@ -76,11 +77,26 @@ declare const EVENTS: { RENDER_NODES_LIST: 'render-nodes-list', }; +declare const MODE_CLIENT = 'client'; +declare const MODE_SERVER = 'server'; +declare const MODE_MANUAL = 'manual'; +declare const MODE_GPS = 'gps'; +declare const MODE_MARKERS = 'markers'; +declare const MODE_3D = '3d'; + /** * @summary Replaces the standard autorotate animation by a smooth transition between multiple points */ declare class VirtualTourPlugin extends AbstractPlugin { + static EVENTS: typeof EVENTS; + static MODE_CLIENT: typeof MODE_CLIENT; + static MODE_SERVER: typeof MODE_SERVER; + static MODE_3D: typeof MODE_3D; + static MODE_MARKERS: typeof MODE_MARKERS; + static MODE_MANUAL: typeof MODE_MANUAL; + static MODE_GPS: typeof MODE_GPS; + constructor(psv: Viewer, options: VirtualTourPluginPluginOptions); /** @@ -121,4 +137,4 @@ declare class VirtualTourPlugin extends AbstractPlugin { } -export { EVENTS, VirtualTourArrowStyle, VirtualTourNode, VirtualTourNodeChangedData, VirtualTourNodeLink, VirtualTourPlugin, VirtualTourPluginPluginOptions }; +export { EVENTS, MODE_3D, MODE_CLIENT, MODE_GPS, MODE_MANUAL, MODE_MARKERS, MODE_SERVER, VirtualTourArrowStyle, VirtualTourNode, VirtualTourNodeChangedData, VirtualTourNodeLink, VirtualTourPlugin, VirtualTourPluginPluginOptions }; diff --git a/dist/plugins/virtual-tour.js b/dist/plugins/virtual-tour.js index 2b91e41ca..a8dfe87be 100644 --- a/dist/plugins/virtual-tour.js +++ b/dist/plugins/virtual-tour.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) @@ -54,7 +54,7 @@ /** * @memberOf PSV.plugins.VirtualTourPlugin - * @package + * @private */ var AbstractDatasource = /*#__PURE__*/function () { @@ -182,7 +182,7 @@ /** * @memberOf PSV.plugins.VirtualTourPlugin - * @package + * @private */ var ClientSideDatasource = /*#__PURE__*/function (_AbstractDatasource) { @@ -510,7 +510,7 @@ /** * @memberOf PSV.plugins.VirtualTourPlugin - * @package + * @private */ var ServerSideDatasource = /*#__PURE__*/function (_AbstractDatasource) { @@ -622,6 +622,7 @@ * @property {PSV.SphereCorrection} [sphereCorrection] - sphere correction to apply to this panorama * @property {string} [name] - short name of the node * @property {string} [caption] - caption visible in the navbar + * @property {string} [description] - description visible in the side panel * @property {string} [thumbnail] - thumbnail for the nodes list in the side panel * @property {PSV.plugins.MarkersPlugin.Properties[]} [markers] - additional markers to use on this node */ @@ -1026,6 +1027,7 @@ return Promise.all([_this3.psv.setPanorama(node.panorama, { transition: _this3.config.transition, caption: node.caption, + description: node.description, panoData: node.panoData, sphereCorrection: node.sphereCorrection }).then(function (completed) { @@ -1328,6 +1330,13 @@ return VirtualTourPlugin; }(photoSphereViewer.AbstractPlugin); VirtualTourPlugin.id = 'virtual-tour'; + VirtualTourPlugin.EVENTS = EVENTS; + VirtualTourPlugin.MODE_CLIENT = MODE_CLIENT; + VirtualTourPlugin.MODE_SERVER = MODE_SERVER; + VirtualTourPlugin.MODE_3D = MODE_3D; + VirtualTourPlugin.MODE_MARKERS = MODE_MARKERS; + VirtualTourPlugin.MODE_MANUAL = MODE_MANUAL; + VirtualTourPlugin.MODE_GPS = MODE_GPS; exports.EVENTS = EVENTS; exports.MODE_3D = MODE_3D; diff --git a/dist/plugins/virtual-tour.js.map b/dist/plugins/virtual-tour.js.map index 998e79b16..052a55a68 100644 --- a/dist/plugins/virtual-tour.js.map +++ b/dist/plugins/virtual-tour.js.map @@ -1 +1 @@ -{"version":3,"file":"virtual-tour.js","sources":["../../src/plugins/virtual-tour/AbstractDatasource.js","../../src/plugins/virtual-tour/utils.js","../../src/plugins/virtual-tour/ClientSideDatasource.js","../../src/plugins/virtual-tour/constants.js","../../src/plugins/virtual-tour/NodesListButton.js","../../src/plugins/virtual-tour/ServerSideDatasource.js","../../src/plugins/virtual-tour/index.js"],"sourcesContent":["import { PSVError } from 'photo-sphere-viewer';\n\n/**\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @package\n */\nexport class AbstractDatasource {\n\n /**\n * @type {Record}\n */\n nodes = {};\n\n /**\n * @param {PSV.plugins.VirtualTourPlugin} plugin\n */\n constructor(plugin) {\n this.plugin = plugin;\n }\n\n destroy() {\n delete this.plugin;\n }\n\n /**\n * @summary Loads a node\n * @param {string} nodeId\n * @return {Promise}\n */\n loadNode(nodeId) { // eslint-disable-line no-unused-vars\n throw new PSVError('loadNode not implemented');\n }\n\n /**\n * @summary Loades nodes linked to another node\n * @param {string} nodeId\n * @return {Promise}\n */\n loadLinkedNodes(nodeId) { // eslint-disable-line no-unused-vars\n throw new PSVError('loadLinkedNodes not implemented');\n }\n\n}\n","import { PSVError, utils } from 'photo-sphere-viewer';\n\n/**\n * @summary Checks the configuration of a node\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {boolean} isGps\n * @private\n */\nexport function checkNode(node, isGps) {\n if (!node.id) {\n throw new PSVError('No id given for node');\n }\n if (!node.panorama) {\n throw new PSVError(`No panorama provided for node ${node.id}`);\n }\n if (isGps && !(node.position?.length >= 2)) {\n throw new PSVError(`No position provided for node ${node.id}`);\n }\n}\n\n/**\n * @summary Checks the configuration of a link\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} link\n * @param {boolean} isGps\n * @private\n */\nexport function checkLink(node, link, isGps) {\n if (!link.nodeId) {\n throw new PSVError(`Link of node ${node.id} has no target id`);\n }\n if (!isGps && !utils.isExtendedPosition(link)) {\n throw new PSVError(`No position provided for link ${link.nodeId} of node ${node.id}`);\n }\n}\n\n/**\n * @summary Changes the color of a mesh\n * @param {external:THREE.Mesh} mesh\n * @param {*} color\n * @private\n */\nexport function setMeshColor(mesh, color) {\n mesh.material.color.set(color);\n}\n\n/**\n * @summary Returns the distance between two GPS points\n * @param {number[]} p1\n * @param {number[]} p2\n * @return {number}\n * @private\n */\nexport function distance(p1, p2) {\n return utils.greatArcDistance(p1, p2) * 6371e3;\n}\n\n/**\n * @summary Returns the bearing between two GPS points\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @param {number[]} p1\n * @param {number[]} p2\n * @return {number}\n * @private\n */\nexport function bearing(p1, p2) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const y = Math.sin(λ2 - λ1) * Math.cos(φ2);\n const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(λ2 - λ1);\n return Math.atan2(y, x);\n}\n","import { PSVError, utils } from 'photo-sphere-viewer';\nimport { AbstractDatasource } from './AbstractDatasource';\nimport { checkLink, checkNode } from './utils';\n\n/**\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @package\n */\nexport class ClientSideDatasource extends AbstractDatasource {\n\n loadNode(nodeId) {\n if (this.nodes[nodeId]) {\n return Promise.resolve(this.nodes[nodeId]);\n }\n else {\n return Promise.reject(new PSVError(`Node ${nodeId} not found`));\n }\n }\n\n loadLinkedNodes(nodeId) {\n if (!this.nodes[nodeId]) {\n return Promise.reject(new PSVError(`Node ${nodeId} not found`));\n }\n else {\n return Promise.resolve();\n }\n }\n\n setNodes(rawNodes) {\n if (!rawNodes?.length) {\n throw new PSVError('No nodes provided');\n }\n\n const nodes = {};\n const linkedNodes = {};\n\n rawNodes.forEach((node) => {\n checkNode(node, this.plugin.isGps());\n\n if (nodes[node.id]) {\n throw new PSVError(`Duplicate node ${node.id}`);\n }\n if (!node.links) {\n utils.logWarn(`Node ${node.id} has no links`);\n nodes.links = [];\n }\n\n nodes[node.id] = node;\n });\n\n rawNodes.forEach((node) => {\n node.links.forEach((link) => {\n checkLink(node, link, this.plugin.isGps());\n\n if (!nodes[link.nodeId]) {\n throw new PSVError(`Target node ${link.nodeId} of node ${node.id} does not exists`);\n }\n\n // copy essential data\n link.position = link.position || nodes[link.nodeId].position;\n link.name = link.name || nodes[link.nodeId].name;\n\n linkedNodes[link.nodeId] = true;\n });\n });\n\n rawNodes.forEach((node) => {\n if (!linkedNodes[node.id]) {\n utils.logWarn(`Node ${node.id} is never linked to`);\n }\n });\n\n this.nodes = nodes;\n }\n\n}\n","import * as THREE from 'three';\nimport arrowGeometryJson from './arrow.json';\nimport arrowIconSvg from './arrow.svg';\nimport arrowOutlineGeometryJson from './arrow_outline.json';\nimport nodesList from './nodes-list.svg';\n\n/**\n * @summary In client mode all the nodes are provided in the config or with the `setNodes` method\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_CLIENT = 'client';\n\n/**\n * @summary In server mode the nodes are fetched asynchronously\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_SERVER = 'server';\n\n/**\n * @summary In manual mode each link is positionned manually on the panorama\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_MANUAL = 'manual';\n\n/**\n * @summary In GPS mode each node is globally positionned and the links are automatically computed\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_GPS = 'gps';\n\n/**\n * @summaru In markers mode the links are represented using markers\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_MARKERS = 'markers';\n\n/**\n * @summaru In 3D mode the links are represented using 3d arrows\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_3D = '3d';\n\n/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event node-changed\n * @memberof PSV.plugins.VirtualTourPlugin\n * @summary Triggered when the current node changes\n * @param {string} nodeId\n */\n NODE_CHANGED : 'node-changed',\n /**\n * @event filter:render-nodes-list\n * @memberof PSV.plugins.VirtualTourPlugin\n * @summary Used to alter the list of nodes displayed on the side-panel\n * @param {PSV.plugins.VirtualTourPlugin.Node[]} nodes\n * @returns {PSV.plugins.VirtualTourPlugin.Node[]}\n */\n RENDER_NODES_LIST: 'render-nodes-list',\n};\n\n/**\n * @summary Property name added to markers\n * @type {string}\n * @constant\n * @private\n */\nexport const LINK_DATA = 'tourLink';\n\n/**\n * @summary Default style of the link marker\n * @type {PSV.plugins.MarkersPlugin.Properties}\n * @constant\n * @private\n */\nexport const DEFAULT_MARKER = {\n html : arrowIconSvg,\n width : 80,\n height : 80,\n scale : [0.5, 2],\n anchor : 'top center',\n className: 'psv-virtual-tour__marker',\n style : {\n color: 'rgba(0, 208, 255, 0.8)',\n },\n};\n\n/**\n * @summary Default style of the link arrow\n * @type {PSV.plugins.VirtualTourPlugin.ArrowStyle}\n * @constant\n * @private\n */\nexport const DEFAULT_ARROW = {\n color : 0xaaaaaa,\n hoverColor : 0xaa5500,\n outlineColor: 0x000000,\n scale : [0.5, 2],\n};\n\n/**\n * @type {external:THREE.BufferedGeometry}\n * @constant\n * @private\n */\nexport const { ARROW_GEOM, ARROW_OUTLINE_GEOM } = (() => {\n const loader = new THREE.ObjectLoader();\n const geometries = loader.parseGeometries([arrowGeometryJson, arrowOutlineGeometryJson]);\n const arrow = geometries[arrowGeometryJson.uuid];\n const arrowOutline = geometries[arrowOutlineGeometryJson.uuid];\n const scale = 0.015;\n const rot = Math.PI / 2;\n arrow.scale(scale, scale, scale);\n arrow.rotateX(rot);\n arrowOutline.scale(scale, scale, scale);\n arrowOutline.rotateX(rot);\n return { ARROW_GEOM: arrow, ARROW_OUTLINE_GEOM: arrowOutline };\n})();\n\n/**\n * @summary Panel identifier for nodes list\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL_NODES_LIST = 'virtualTourNodesList';\n\n/**\n * @summary Nodes list template\n * @param {PSV.plugins.VirtualTourPlugin.Node[]} nodes\n * @param {string} title\n * @param {string} currentNodeId\n * @returns {string}\n * @constant\n * @private\n */\nexport const NODES_LIST_TEMPLATE = (nodes, title, currentNodeId) => `\n
      \n

      ${nodesList} ${title}

      \n
        \n ${nodes.map(node => `\n
      • \n ${node.thumbnail ? `` : ''}\n ${node.caption || node.name}\n
      • \n `).join('')}\n
      \n
      \n`;\n","import { AbstractButton, CONSTANTS } from '../..';\nimport { ID_PANEL_NODES_LIST } from './constants';\nimport nodesList from './nodes-list.svg';\n\n/**\n * @summary Navigation bar markers list button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class NodesListButton extends AbstractButton {\n\n static id = 'nodesList';\n static icon = nodesList;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-nodes-list-button', true);\n\n /**\n * @type {PSV.plugins.VirtualTourPlugin}\n */\n this.plugin = this.psv.getPlugin('virtual-tour');\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.on(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.off(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin && !this.plugin.isServerSide();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case CONSTANTS.EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === ID_PANEL_NODES_LIST); break;\n case CONSTANTS.EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles nodes list\n */\n onClick() {\n this.plugin.toggleNodesList();\n }\n\n}\n","import { PSVError, utils } from 'photo-sphere-viewer';\nimport { AbstractDatasource } from './AbstractDatasource';\nimport { checkLink, checkNode } from './utils';\n\n/**\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @package\n */\nexport class ServerSideDatasource extends AbstractDatasource {\n\n constructor(plugin) {\n super(plugin);\n\n if (!plugin.config.getNode) {\n throw new PSVError('Missing getNode() option.');\n }\n\n this.nodeResolver = plugin.config.getNode;\n this.linksResolver = plugin.config.getLinks;\n }\n\n loadNode(nodeId) {\n if (this.nodes[nodeId]) {\n return Promise.resolve(this.nodes[nodeId]);\n }\n else {\n return Promise.resolve(this.nodeResolver(nodeId))\n .then((node) => {\n checkNode(node, this.plugin.isGps());\n this.nodes[nodeId] = node;\n return node;\n });\n }\n }\n\n loadLinkedNodes(nodeId) {\n if (!this.nodes[nodeId]) {\n return Promise.reject(new PSVError(`Node ${nodeId} not found`));\n }\n else if (this.nodes[nodeId].links) {\n return Promise.resolve();\n }\n else {\n if (!this.linksResolver) {\n this.nodes[nodeId].links = [];\n return Promise.resolve();\n }\n\n utils.logWarn(`getLinks() option is deprecated, instead make getNode() also return the node' links.`);\n\n return Promise.resolve(this.linksResolver(nodeId))\n .then(links => links || [])\n .then((links) => {\n const node = this.nodes[nodeId];\n\n links.forEach((link) => {\n checkLink(node, link, this.plugin.isGps());\n\n // copy essential data\n if (this.nodes[link.nodeId]) {\n link.position = link.position || this.nodes[link.nodeId].position;\n link.name = link.name || this.nodes[link.nodeId].name;\n }\n\n if (this.plugin.isGps() && !link.position) {\n throw new PSVError(`No GPS position provided for link ${link.nodeId} of node ${node.id}`);\n }\n });\n\n // store links\n node.links = links;\n });\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport { ClientSideDatasource } from './ClientSideDatasource';\nimport {\n ARROW_GEOM,\n ARROW_OUTLINE_GEOM,\n DEFAULT_ARROW,\n DEFAULT_MARKER,\n EVENTS,\n ID_PANEL_NODES_LIST,\n LINK_DATA,\n MODE_3D,\n MODE_CLIENT,\n MODE_GPS,\n MODE_MANUAL,\n MODE_MARKERS,\n MODE_SERVER,\n NODES_LIST_TEMPLATE\n} from './constants';\nimport { NodesListButton } from './NodesListButton';\nimport { ServerSideDatasource } from './ServerSideDatasource';\nimport './style.scss';\nimport { bearing, distance, setMeshColor } from './utils';\n\n\n/**\n * @callback GetNode\n * @summary Function to load a node\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @param {string} nodeId\n * @returns {PSV.plugins.VirtualTourPlugin.Node|Promise}\n */\n\n/**\n * @callback GetLinks\n * @summary Function to load the links of a node\n * @deprecated `getNode` must directly return the links of each node\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @param {string} nodeId\n * @returns {PSV.plugins.VirtualTourPlugin.NodeLink[]|Promise}\n */\n\n/**\n * @callback Preload\n * @summary Function to determine if a link must be preloaded\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} link\n * @returns {boolean}\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.Node\n * @summary Definition of a single node in the tour\n * @property {string} id - unique identifier of the node\n * @property {*} panorama\n * @property {PSV.plugins.VirtualTourPlugin.NodeLink[]} [links] - links to other nodes\n * @property {number[]} [position] - GPS position (longitude, latitude, optional altitude)\n * @property {PSV.PanoData | PSV.PanoDataProvider} [panoData] - data used for this panorama\n * @property {PSV.SphereCorrection} [sphereCorrection] - sphere correction to apply to this panorama\n * @property {string} [name] - short name of the node\n * @property {string} [caption] - caption visible in the navbar\n * @property {string} [thumbnail] - thumbnail for the nodes list in the side panel\n * @property {PSV.plugins.MarkersPlugin.Properties[]} [markers] - additional markers to use on this node\n */\n\n/**\n * @typedef {PSV.ExtendedPosition} PSV.plugins.VirtualTourPlugin.NodeLink\n * @summary Definition of a link between two nodes\n * @property {string} nodeId - identifier of the target node\n * @property {string} [name] - override the name of the node (tooltip)\n * @property {number[]} [position] - override the GPS position of the node\n * @property {PSV.plugins.MarkersPlugin.Properties} [markerStyle] - override global marker style\n * @property {PSV.plugins.VirtualTourPlugin.ArrowStyle} [arrowStyle] - override global arrow style\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.ArrowStyle\n * @summary Style of the arrow in 3D mode\n * @property {string} [color=0xaaaaaa]\n * @property {string} [hoverColor=0xaa5500]\n * @property {number} [outlineColor=0x000000]\n * @property {number[]} [scale=[0.5,2]]\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.Options\n * @property {'client'|'server'} [dataMode='client'] - configure data mode\n * @property {'manual'|'gps'} [positionMode='manual'] - configure positioning mode\n * @property {'markers'|'3d'} [renderMode='3d'] - configure rendering mode of links\n * @property {PSV.plugins.VirtualTourPlugin.Node[]} [nodes] - initial nodes\n * @property {PSV.plugins.VirtualTourPlugin.GetNode} [getNode]\n * @property {PSV.plugins.VirtualTourPlugin.GetLinks} [getLinks] - Deprecated: `getNode` must directly return the links of each node\n * @property {string} [startNodeId] - id of the initial node, if not defined the first node will be used\n * @property {boolean|PSV.plugins.VirtualTourPlugin.Preload} [preload=false] - preload linked panoramas\n * @property {boolean|string|number} [rotateSpeed='20rpm'] - speed of rotation when clicking on a link, if 'false' the viewer won't rotate at all\n * @property {boolean|number} [transition=1500] - duration of the transition between nodes\n * @property {boolean} [linksOnCompass] - if the Compass plugin is enabled, displays the links on the compass, defaults to `true` on in markers render mode\n * @property {PSV.plugins.MarkersPlugin.Properties} [markerStyle] - global marker style\n * @property {PSV.plugins.VirtualTourPlugin.ArrowStyle} [arrowStyle] - global arrow style\n * @property {number} [markerLatOffset=-0.1] - (GPS & Markers mode) latitude offset applied to link markers, to compensate for viewer height\n * @property {'top'|'bottom'} [arrowPosition='bottom'] - (3D mode) arrows vertical position\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.NodeChangedData\n * @summary Data associated to the \"node-changed\" event\n * @type {PSV.plugins.VirtualTourPlugin.Node} [fromNode] - The previous node\n * @type {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink] - The link that was clicked in the previous node\n * @type {PSV.Position} [fromLinkPosition] - The position of the link on the previous node\n */\n\n// add markers buttons\nDEFAULTS.lang[NodesListButton.id] = 'Locations';\nregisterButton(NodesListButton, 'caption:left');\n\n\nexport { EVENTS, MODE_3D, MODE_CLIENT, MODE_GPS, MODE_MANUAL, MODE_MARKERS, MODE_SERVER } from './constants';\n\n\n/**\n * @summary Create virtual tours by linking multiple panoramas\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class VirtualTourPlugin extends AbstractPlugin {\n\n static id = 'virtual-tour';\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.VirtualTourPlugin.Options} [options]\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {Object}\n * @property {PSV.plugins.VirtualTourPlugin.Node} currentNode\n * @property {PSV.Tooltip} currentTooltip\n * @property {string} loadingNode\n * @property {function} stopObserver\n * @private\n */\n this.prop = {\n currentNode : null,\n currentTooltip: null,\n loadingNode : null,\n stopObserver : null,\n };\n\n /**\n * @type {Record}\n * @private\n */\n this.preload = {};\n\n /**\n * @member {PSV.plugins.VirtualTourPlugin.Options}\n * @private\n */\n this.config = {\n dataMode : MODE_CLIENT,\n positionMode : MODE_MANUAL,\n renderMode : MODE_3D,\n preload : false,\n rotateSpeed : '20rpm',\n transition : CONSTANTS.DEFAULT_TRANSITION,\n markerLatOffset: -0.1,\n arrowPosition : 'bottom',\n linksOnCompass : options?.renderMode === MODE_MARKERS,\n ...options,\n markerStyle : {\n ...DEFAULT_MARKER,\n ...options?.markerStyle,\n },\n arrowStyle : {\n ...DEFAULT_ARROW,\n ...options?.arrowStyle,\n },\n };\n\n if (options?.listButton === false) {\n utils.logWarn('VirtualTourPlugin: listButton option is deprecated. '\n + 'Please define the global navbar options according to your needs.');\n }\n if (options?.listButton === true && this.config.dataMode === MODE_SERVER) {\n utils.logWarn('VirtualTourPlugin: the list button is not supported in server mode.');\n }\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @private\n */\n this.markers = null;\n\n /**\n * @type {PSV.plugins.CompassPlugin}\n * @private\n */\n this.compass = null;\n\n /**\n * @type {PSV.plugins.VirtualTourPlugin.AbstractDatasource}\n */\n this.datasource = null;\n\n /**\n * @type {external:THREE.Group}\n * @private\n */\n this.arrowsGroup = null;\n\n if (this.is3D()) {\n this.arrowsGroup = new THREE.Group();\n\n const localLight = new THREE.PointLight(0xffffff, 1, 0);\n localLight.position.set(0, this.config.arrowPosition === 'bottom' ? 2 : -2, 0);\n this.arrowsGroup.add(localLight);\n }\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n this.compass = this.psv.getPlugin('compass');\n\n if (!this.is3D() && !this.markers) {\n throw new PSVError('Tour plugin requires the Markers plugin in markers mode');\n }\n\n this.datasource = this.isServerSide() ? new ServerSideDatasource(this) : new ClientSideDatasource(this);\n\n if (this.is3D()) {\n this.psv.once(CONSTANTS.EVENTS.READY, () => {\n this.__positionArrows();\n this.psv.renderer.scene.add(this.arrowsGroup);\n\n const ambientLight = new THREE.AmbientLight(0xffffff, 1);\n this.psv.renderer.scene.add(ambientLight);\n\n this.psv.needsUpdate();\n });\n\n this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.CLICK, this);\n this.prop.stopObserver = this.psv.observeObjects(LINK_DATA, this);\n }\n else {\n this.markers.on('select-marker', this);\n }\n\n if (this.isServerSide()) {\n if (this.config.startNodeId) {\n this.setCurrentNode(this.config.startNodeId);\n }\n }\n else if (this.config.nodes) {\n this.setNodes(this.config.nodes, this.config.startNodeId);\n delete this.config.nodes;\n }\n }\n\n /**\n * @package\n */\n destroy() {\n if (this.markers) {\n this.markers.off('select-marker', this);\n }\n if (this.arrowsGroup) {\n this.psv.renderer.scene.remove(this.arrowsGroup);\n }\n\n this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.CLICK, this);\n this.prop.stopObserver?.();\n\n this.datasource.destroy();\n\n delete this.preload;\n delete this.datasource;\n delete this.markers;\n delete this.compass;\n delete this.arrowsGroup;\n\n super.destroy();\n }\n\n handleEvent(e) {\n let link;\n switch (e.type) {\n case 'select-marker':\n link = e.args[0].data?.[LINK_DATA];\n if (link) {\n this.setCurrentNode(link.nodeId, link);\n }\n break;\n\n case CONSTANTS.EVENTS.POSITION_UPDATED:\n case CONSTANTS.EVENTS.ZOOM_UPDATED:\n if (this.arrowsGroup) {\n this.__positionArrows();\n }\n break;\n\n case CONSTANTS.EVENTS.CLICK:\n link = e.args[0].objects.find(o => o.userData[LINK_DATA])?.userData[LINK_DATA];\n if (link) {\n this.setCurrentNode(link.nodeId, link);\n }\n break;\n\n case CONSTANTS.OBJECT_EVENTS.ENTER_OBJECT:\n this.__onEnterObject(e.detail.object, e.detail.viewerPoint);\n break;\n case CONSTANTS.OBJECT_EVENTS.HOVER_OBJECT:\n this.__onHoverObject(e.detail.object, e.detail.viewerPoint);\n break;\n case CONSTANTS.OBJECT_EVENTS.LEAVE_OBJECT:\n this.__onLeaveObject(e.detail.object);\n break;\n\n default:\n }\n }\n\n /**\n * @summary Tests if running in server mode\n * @return {boolean}\n */\n isServerSide() {\n return this.config.dataMode === MODE_SERVER;\n }\n\n /**\n * @summary Tests if running in GPS mode\n * @return {boolean}\n */\n isGps() {\n return this.config.positionMode === MODE_GPS;\n }\n\n /**\n * @summary Tests if running in 3D mode\n * @return {boolean}\n */\n is3D() {\n return this.config.renderMode === MODE_3D;\n }\n\n /**\n * @summary Sets the nodes (client mode only)\n * @param {PSV.plugins.VirtualTourPlugin.Node[]} nodes\n * @param {string} [startNodeId]\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n setNodes(nodes, startNodeId) {\n if (this.isServerSide()) {\n throw new PSVError('Cannot set nodes in server side mode');\n }\n\n this.datasource.setNodes(nodes);\n\n if (!startNodeId) {\n startNodeId = nodes[0].id;\n }\n else if (!this.datasource.nodes[startNodeId]) {\n startNodeId = nodes[0].id;\n utils.logWarn(`startNodeId not found is provided nodes, resetted to ${startNodeId}`);\n }\n\n this.setCurrentNode(startNodeId);\n }\n\n /**\n * @summary Changes the current node\n * @param {string} nodeId\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink]\n * @returns {Promise} resolves false if the loading was aborted by another call\n */\n setCurrentNode(nodeId, fromLink = null) {\n if (nodeId === this.prop.currentNode?.id) {\n return Promise.resolve(true);\n }\n\n this.psv.hideError();\n\n this.prop.loadingNode = nodeId;\n\n const fromNode = this.prop.currentNode;\n const fromLinkPosition = fromNode && fromLink ? this.__getLinkPosition(fromNode, fromLink) : null;\n\n return Promise.all([\n // if this node is already preloading, wait for it\n Promise.resolve(this.preload[nodeId])\n .then(() => {\n if (this.prop.loadingNode !== nodeId) {\n throw utils.getAbortError();\n }\n\n return this.datasource.loadNode(nodeId);\n }),\n Promise.resolve(fromLinkPosition ? this.config.rotateSpeed : false)\n .then((speed) => { // eslint-disable-line consistent-return\n if (speed) {\n return this.psv.animate({ ...fromLinkPosition, speed });\n }\n })\n .then(() => {\n this.psv.loader.show();\n }),\n ])\n .then(([node]) => {\n if (this.prop.loadingNode !== nodeId) {\n throw utils.getAbortError();\n }\n\n this.prop.currentNode = node;\n\n if (this.prop.currentTooltip) {\n this.prop.currentTooltip.hide();\n this.prop.currentTooltip = null;\n }\n\n if (this.is3D()) {\n this.arrowsGroup.remove(...this.arrowsGroup.children.filter(o => o.type === 'Mesh'));\n }\n\n this.markers?.clearMarkers();\n this.compass?.clearHotspots();\n\n return Promise.all([\n this.psv.setPanorama(node.panorama, {\n transition : this.config.transition,\n caption : node.caption,\n panoData : node.panoData,\n sphereCorrection: node.sphereCorrection,\n })\n .then((completed) => {\n if (!completed) {\n throw utils.getAbortError();\n }\n }),\n this.datasource.loadLinkedNodes(nodeId),\n ]);\n })\n .then(() => {\n if (this.prop.loadingNode !== nodeId) {\n throw utils.getAbortError();\n }\n\n const node = this.prop.currentNode;\n\n if (node.markers) {\n if (this.markers) {\n this.markers.setMarkers(node.markers);\n }\n else {\n utils.logWarn(`Node ${node.id} markers ignored because the plugin is not loaded.`);\n }\n }\n\n this.__renderLinks(node);\n this.__preload(node);\n\n /**\n * @event node-changed\n * @memberof PSV.plugins.VirtualTourPlugin\n * @summary Triggered when the current node is changed\n * @param {string} nodeId\n * @param {PSV.plugins.VirtualTourPlugin.NodeChangedData} data\n */\n this.trigger(EVENTS.NODE_CHANGED, nodeId, {\n fromNode,\n fromLink,\n fromLinkPosition,\n });\n\n this.prop.loadingNode = null;\n\n return true;\n })\n .catch((err) => {\n if (utils.isAbortError(err)) {\n return false;\n }\n\n this.psv.showError(this.psv.config.lang.loadError);\n\n this.psv.loader.hide();\n this.psv.navbar.setCaption('');\n\n this.prop.loadingNode = null;\n\n throw err;\n });\n }\n\n /**\n * @summary Adds the links for the node\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @private\n */\n __renderLinks(node) {\n const positions = [];\n\n node.links.forEach((link) => {\n const position = this.__getLinkPosition(node, link);\n positions.push(position);\n\n if (this.is3D()) {\n const mesh = new THREE.Mesh(ARROW_GEOM, new THREE.MeshLambertMaterial());\n mesh.userData = { [LINK_DATA]: link, longitude: position.longitude };\n mesh.rotation.order = 'YXZ';\n mesh.rotateY(-position.longitude);\n this.psv.dataHelper\n .sphericalCoordsToVector3({ longitude: position.longitude, latitude: 0 }, mesh.position)\n .multiplyScalar(1 / CONSTANTS.SPHERE_RADIUS);\n\n const outlineMesh = new THREE.Mesh(ARROW_OUTLINE_GEOM, new THREE.MeshBasicMaterial({ side: THREE.BackSide }));\n outlineMesh.position.copy(mesh.position);\n outlineMesh.rotation.copy(mesh.rotation);\n\n setMeshColor(mesh, link.arrowStyle?.color || this.config.arrowStyle.color);\n setMeshColor(outlineMesh, link.arrowStyle?.outlineColor || this.config.arrowStyle.outlineColor);\n\n this.arrowsGroup.add(mesh);\n this.arrowsGroup.add(outlineMesh);\n }\n else {\n if (this.isGps()) {\n position.latitude += this.config.markerLatOffset;\n }\n\n this.markers.addMarker({\n ...this.config.markerStyle,\n ...link.markerStyle,\n id : `tour-link-${link.nodeId}`,\n tooltip : link.name,\n hideList: true,\n data : { [LINK_DATA]: link },\n ...position,\n }, false);\n }\n });\n\n if (this.is3D()) {\n this.__positionArrows();\n }\n else {\n this.markers.renderMarkers();\n }\n\n if (this.config.linksOnCompass && this.compass) {\n this.compass.setHotspots(positions);\n }\n }\n\n /**\n * @summary Computes the marker position for a link\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} link\n * @return {PSV.Position}\n * @private\n */\n __getLinkPosition(node, link) {\n if (this.isGps()) {\n const p1 = [THREE.Math.degToRad(node.position[0]), THREE.Math.degToRad(node.position[1])];\n const p2 = [THREE.Math.degToRad(link.position[0]), THREE.Math.degToRad(link.position[1])];\n const h1 = node.position[2] !== undefined ? node.position[2] : link.position[2] || 0;\n const h2 = link.position[2] !== undefined ? link.position[2] : node.position[2] || 0;\n\n let latitude = 0;\n if (h1 !== h2) {\n latitude = Math.atan((h2 - h1) / distance(p1, p2));\n }\n\n const longitude = bearing(p1, p2);\n\n return { longitude, latitude };\n }\n else {\n return this.psv.dataHelper.cleanPosition(link);\n }\n }\n\n /**\n * @private\n */\n __onEnterObject(mesh, viewerPoint) {\n const link = mesh.userData[LINK_DATA];\n\n setMeshColor(mesh, link.arrowStyle?.hoverColor || this.config.arrowStyle.hoverColor);\n\n if (link.name) {\n this.prop.currentTooltip = this.psv.tooltip.create({\n left : viewerPoint.x,\n top : viewerPoint.y,\n content: link.name,\n });\n }\n\n this.psv.needsUpdate();\n }\n\n\n /**\n * @private\n */\n __onHoverObject(mesh, viewerPoint) {\n if (this.prop.currentTooltip) {\n this.prop.currentTooltip.move({\n left: viewerPoint.x,\n top : viewerPoint.y,\n });\n }\n }\n\n\n /**\n * @private\n */\n __onLeaveObject(mesh) {\n const link = mesh.userData[LINK_DATA];\n\n setMeshColor(mesh, link.arrowStyle?.color || this.config.arrowStyle.color);\n\n if (this.prop.currentTooltip) {\n this.prop.currentTooltip.hide();\n this.prop.currentTooltip = null;\n }\n\n this.psv.needsUpdate();\n }\n\n /**\n * @summary Updates to position of the group of arrows\n * @private\n */\n __positionArrows() {\n this.arrowsGroup.position.copy(this.psv.prop.direction).multiplyScalar(0.5);\n const s = this.config.arrowStyle.scale;\n const f = s[1] + (s[0] - s[1]) * (this.psv.getZoomLevel() / 100);\n const y = 2.5 - (this.psv.getZoomLevel() / 100) * 1.5;\n this.arrowsGroup.position.y += this.config.arrowPosition === 'bottom' ? -y : y;\n this.arrowsGroup.scale.set(f, f, f);\n }\n\n /**\n * @summary Manage the preload of the linked panoramas\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @private\n */\n __preload(node) {\n if (!this.config.preload) {\n return;\n }\n\n this.preload[node.id] = true;\n\n this.prop.currentNode.links\n .filter(link => !this.preload[link.nodeId])\n .filter((link) => {\n if (typeof this.config.preload === 'function') {\n return this.config.preload(this.prop.currentNode, link);\n }\n else {\n return true;\n }\n })\n .forEach((link) => {\n this.preload[link.nodeId] = this.datasource.loadNode(link.nodeId)\n .then((linkNode) => {\n return this.psv.textureLoader.preloadPanorama(linkNode.panorama);\n })\n .then(() => {\n this.preload[link.nodeId] = true;\n })\n .catch(() => {\n delete this.preload[link.nodeId];\n });\n });\n }\n\n /**\n * @summary Toggles the visibility of the list of nodes\n */\n toggleNodesList() {\n if (this.psv.panel.prop.contentId === ID_PANEL_NODES_LIST) {\n this.hideNodesList();\n }\n else {\n this.showNodesList();\n }\n }\n\n /**\n * @summary Opens side panel with the list of nodes\n */\n showNodesList() {\n const nodes = this.change(EVENTS.RENDER_NODES_LIST, Object.values(this.datasource.nodes));\n\n this.psv.panel.show({\n id : ID_PANEL_NODES_LIST,\n content : NODES_LIST_TEMPLATE(\n nodes,\n this.psv.config.lang[NodesListButton.id],\n this.prop.currentNode?.id\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const nodeId = li ? li.dataset.nodeId : undefined;\n\n if (nodeId) {\n this.setCurrentNode(nodeId);\n this.hideNodesList();\n }\n },\n });\n }\n\n /**\n * @summary Closes side panel if it contains the list of nodes\n */\n hideNodesList() {\n this.psv.panel.hide(ID_PANEL_NODES_LIST);\n }\n\n}\n"],"names":["AbstractDatasource","plugin","nodes","destroy","loadNode","nodeId","PSVError","loadLinkedNodes","checkNode","node","isGps","id","panorama","position","length","checkLink","link","utils","isExtendedPosition","setMeshColor","mesh","color","material","set","distance","p1","p2","greatArcDistance","bearing","λ1","φ1","λ2","φ2","y","Math","sin","cos","x","atan2","ClientSideDatasource","Promise","resolve","reject","setNodes","rawNodes","linkedNodes","forEach","links","logWarn","name","MODE_CLIENT","MODE_SERVER","MODE_MANUAL","MODE_GPS","MODE_MARKERS","MODE_3D","EVENTS","NODE_CHANGED","RENDER_NODES_LIST","LINK_DATA","DEFAULT_MARKER","html","arrowIconSvg","width","height","scale","anchor","className","style","DEFAULT_ARROW","hoverColor","outlineColor","loader","THREE","ObjectLoader","geometries","parseGeometries","arrowGeometryJson","arrowOutlineGeometryJson","arrow","uuid","arrowOutline","rot","PI","rotateX","ARROW_GEOM","ARROW_OUTLINE_GEOM","ID_PANEL_NODES_LIST","NODES_LIST_TEMPLATE","title","currentNodeId","nodesList","map","thumbnail","caption","join","NodesListButton","navbar","psv","getPlugin","on","CONSTANTS","OPEN_PANEL","CLOSE_PANEL","off","isSupported","isServerSide","handleEvent","e","type","toggleActive","args","onClick","toggleNodesList","AbstractButton","icon","ServerSideDatasource","config","getNode","nodeResolver","linksResolver","getLinks","then","DEFAULTS","lang","registerButton","VirtualTourPlugin","options","prop","currentNode","currentTooltip","loadingNode","stopObserver","preload","dataMode","positionMode","renderMode","rotateSpeed","transition","DEFAULT_TRANSITION","markerLatOffset","arrowPosition","linksOnCompass","markerStyle","arrowStyle","listButton","markers","compass","datasource","arrowsGroup","is3D","Group","localLight","PointLight","add","init","once","READY","__positionArrows","renderer","scene","ambientLight","AmbientLight","needsUpdate","POSITION_UPDATED","ZOOM_UPDATED","CLICK","observeObjects","startNodeId","setCurrentNode","remove","data","objects","find","o","userData","OBJECT_EVENTS","ENTER_OBJECT","__onEnterObject","detail","object","viewerPoint","HOVER_OBJECT","__onHoverObject","LEAVE_OBJECT","__onLeaveObject","fromLink","hideError","fromNode","fromLinkPosition","__getLinkPosition","all","getAbortError","speed","animate","show","hide","children","filter","clearMarkers","clearHotspots","setPanorama","panoData","sphereCorrection","completed","setMarkers","__renderLinks","__preload","trigger","catch","err","isAbortError","showError","loadError","setCaption","positions","push","Mesh","MeshLambertMaterial","longitude","rotation","order","rotateY","dataHelper","sphericalCoordsToVector3","latitude","multiplyScalar","SPHERE_RADIUS","outlineMesh","MeshBasicMaterial","side","BackSide","copy","addMarker","tooltip","hideList","renderMarkers","setHotspots","degToRad","h1","undefined","h2","atan","cleanPosition","create","left","top","content","move","direction","s","f","getZoomLevel","linkNode","textureLoader","preloadPanorama","panel","contentId","hideNodesList","showNodesList","change","Object","values","noMargin","clickHandler","li","target","getClosest","dataset","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA;EACA;EACA;EACA;;MACaA,kBAAb;EAEE;EACF;EACA;;EAGE;EACF;EACA;EACE,8BAAYC,MAAZ,EAAoB;EAAA,SALpBC,KAKoB,GALZ,EAKY;EAClB,SAAKD,MAAL,GAAcA,MAAd;EACD;;EAZH;;EAAA,SAcEE,OAdF,GAcE,mBAAU;EACR,WAAO,KAAKF,MAAZ;EACD;EAED;EACF;EACA;EACA;EACA;EAtBA;;EAAA,SAuBEG,QAvBF,GAuBE,kBAASC,MAA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AiB/J,CAAC,CAAC8J,MAAnB,EAA2B,IAA3B,CAAX,GAA8C1B,SAAzD;EACA,YAAM3O,MAAM,GAAGoQ,EAAE,GAAGA,EAAE,CAACG,OAAH,CAAWvQ,MAAd,GAAuB2O,SAAxC;;EAEA,YAAI3O,MAAJ,EAAY;EACV,UAAA,MAAI,CAACoK,cAAL,CAAoBpK,MAApB;;EACA,UAAA,MAAI,CAAC6P,aAAL;EACD;EACF;EAhBiB,KAApB;EAkBD;EAED;EACF;EACA;EA9lBA;;EAAA,SA+lBEA,aA/lBF,GA+lBE,yBAAgB;EACd,SAAKhK,GAAL,CAAS8J,KAAT,CAAe5D,IAAf,CAAoB7G,mBAApB;EACD,GAjmBH;;EAAA;EAAA,EAAuCsL,gCAAvC;EAAa/I,kBAEJnH,KAAK;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"virtual-tour.js","sources":["../../src/plugins/virtual-tour/AbstractDatasource.js","../../src/plugins/virtual-tour/utils.js","../../src/plugins/virtual-tour/ClientSideDatasource.js","../../src/plugins/virtual-tour/constants.js","../../src/plugins/virtual-tour/NodesListButton.js","../../src/plugins/virtual-tour/ServerSideDatasource.js","../../src/plugins/virtual-tour/index.js"],"sourcesContent":["import { PSVError } from 'photo-sphere-viewer';\n\n/**\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @private\n */\nexport class AbstractDatasource {\n\n /**\n * @type {Record}\n */\n nodes = {};\n\n /**\n * @param {PSV.plugins.VirtualTourPlugin} plugin\n */\n constructor(plugin) {\n this.plugin = plugin;\n }\n\n destroy() {\n delete this.plugin;\n }\n\n /**\n * @summary Loads a node\n * @param {string} nodeId\n * @return {Promise}\n */\n loadNode(nodeId) { // eslint-disable-line no-unused-vars\n throw new PSVError('loadNode not implemented');\n }\n\n /**\n * @summary Loades nodes linked to another node\n * @param {string} nodeId\n * @return {Promise}\n */\n loadLinkedNodes(nodeId) { // eslint-disable-line no-unused-vars\n throw new PSVError('loadLinkedNodes not implemented');\n }\n\n}\n","import { PSVError, utils } from 'photo-sphere-viewer';\n\n/**\n * @summary Checks the configuration of a node\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {boolean} isGps\n * @private\n */\nexport function checkNode(node, isGps) {\n if (!node.id) {\n throw new PSVError('No id given for node');\n }\n if (!node.panorama) {\n throw new PSVError(`No panorama provided for node ${node.id}`);\n }\n if (isGps && !(node.position?.length >= 2)) {\n throw new PSVError(`No position provided for node ${node.id}`);\n }\n}\n\n/**\n * @summary Checks the configuration of a link\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} link\n * @param {boolean} isGps\n * @private\n */\nexport function checkLink(node, link, isGps) {\n if (!link.nodeId) {\n throw new PSVError(`Link of node ${node.id} has no target id`);\n }\n if (!isGps && !utils.isExtendedPosition(link)) {\n throw new PSVError(`No position provided for link ${link.nodeId} of node ${node.id}`);\n }\n}\n\n/**\n * @summary Changes the color of a mesh\n * @param {external:THREE.Mesh} mesh\n * @param {*} color\n * @private\n */\nexport function setMeshColor(mesh, color) {\n mesh.material.color.set(color);\n}\n\n/**\n * @summary Returns the distance between two GPS points\n * @param {number[]} p1\n * @param {number[]} p2\n * @return {number}\n * @private\n */\nexport function distance(p1, p2) {\n return utils.greatArcDistance(p1, p2) * 6371e3;\n}\n\n/**\n * @summary Returns the bearing between two GPS points\n * {@link http://www.movable-type.co.uk/scripts/latlong.html}\n * @param {number[]} p1\n * @param {number[]} p2\n * @return {number}\n * @private\n */\nexport function bearing(p1, p2) {\n const [λ1, φ1] = p1;\n const [λ2, φ2] = p2;\n\n const y = Math.sin(λ2 - λ1) * Math.cos(φ2);\n const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(λ2 - λ1);\n return Math.atan2(y, x);\n}\n","import { PSVError, utils } from 'photo-sphere-viewer';\nimport { AbstractDatasource } from './AbstractDatasource';\nimport { checkLink, checkNode } from './utils';\n\n/**\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @private\n */\nexport class ClientSideDatasource extends AbstractDatasource {\n\n loadNode(nodeId) {\n if (this.nodes[nodeId]) {\n return Promise.resolve(this.nodes[nodeId]);\n }\n else {\n return Promise.reject(new PSVError(`Node ${nodeId} not found`));\n }\n }\n\n loadLinkedNodes(nodeId) {\n if (!this.nodes[nodeId]) {\n return Promise.reject(new PSVError(`Node ${nodeId} not found`));\n }\n else {\n return Promise.resolve();\n }\n }\n\n setNodes(rawNodes) {\n if (!rawNodes?.length) {\n throw new PSVError('No nodes provided');\n }\n\n const nodes = {};\n const linkedNodes = {};\n\n rawNodes.forEach((node) => {\n checkNode(node, this.plugin.isGps());\n\n if (nodes[node.id]) {\n throw new PSVError(`Duplicate node ${node.id}`);\n }\n if (!node.links) {\n utils.logWarn(`Node ${node.id} has no links`);\n nodes.links = [];\n }\n\n nodes[node.id] = node;\n });\n\n rawNodes.forEach((node) => {\n node.links.forEach((link) => {\n checkLink(node, link, this.plugin.isGps());\n\n if (!nodes[link.nodeId]) {\n throw new PSVError(`Target node ${link.nodeId} of node ${node.id} does not exists`);\n }\n\n // copy essential data\n link.position = link.position || nodes[link.nodeId].position;\n link.name = link.name || nodes[link.nodeId].name;\n\n linkedNodes[link.nodeId] = true;\n });\n });\n\n rawNodes.forEach((node) => {\n if (!linkedNodes[node.id]) {\n utils.logWarn(`Node ${node.id} is never linked to`);\n }\n });\n\n this.nodes = nodes;\n }\n\n}\n","import * as THREE from 'three';\nimport arrowGeometryJson from './arrow.json';\nimport arrowIconSvg from './arrow.svg';\nimport arrowOutlineGeometryJson from './arrow_outline.json';\nimport nodesList from './nodes-list.svg';\n\n/**\n * @summary In client mode all the nodes are provided in the config or with the `setNodes` method\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_CLIENT = 'client';\n\n/**\n * @summary In server mode the nodes are fetched asynchronously\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_SERVER = 'server';\n\n/**\n * @summary In manual mode each link is positionned manually on the panorama\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_MANUAL = 'manual';\n\n/**\n * @summary In GPS mode each node is globally positionned and the links are automatically computed\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_GPS = 'gps';\n\n/**\n * @summaru In markers mode the links are represented using markers\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_MARKERS = 'markers';\n\n/**\n * @summaru In 3D mode the links are represented using 3d arrows\n * @type {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const MODE_3D = '3d';\n\n/**\n * @summary Available events\n * @enum {string}\n * @memberof PSV.plugins.VirtualTourPlugin\n * @constant\n */\nexport const EVENTS = {\n /**\n * @event node-changed\n * @memberof PSV.plugins.VirtualTourPlugin\n * @summary Triggered when the current node changes\n * @param {string} nodeId\n */\n NODE_CHANGED : 'node-changed',\n /**\n * @event filter:render-nodes-list\n * @memberof PSV.plugins.VirtualTourPlugin\n * @summary Used to alter the list of nodes displayed on the side-panel\n * @param {PSV.plugins.VirtualTourPlugin.Node[]} nodes\n * @returns {PSV.plugins.VirtualTourPlugin.Node[]}\n */\n RENDER_NODES_LIST: 'render-nodes-list',\n};\n\n/**\n * @summary Property name added to markers\n * @type {string}\n * @constant\n * @private\n */\nexport const LINK_DATA = 'tourLink';\n\n/**\n * @summary Default style of the link marker\n * @type {PSV.plugins.MarkersPlugin.Properties}\n * @constant\n * @private\n */\nexport const DEFAULT_MARKER = {\n html : arrowIconSvg,\n width : 80,\n height : 80,\n scale : [0.5, 2],\n anchor : 'top center',\n className: 'psv-virtual-tour__marker',\n style : {\n color: 'rgba(0, 208, 255, 0.8)',\n },\n};\n\n/**\n * @summary Default style of the link arrow\n * @type {PSV.plugins.VirtualTourPlugin.ArrowStyle}\n * @constant\n * @private\n */\nexport const DEFAULT_ARROW = {\n color : 0xaaaaaa,\n hoverColor : 0xaa5500,\n outlineColor: 0x000000,\n scale : [0.5, 2],\n};\n\n/**\n * @type {external:THREE.BufferedGeometry}\n * @constant\n * @private\n */\nexport const { ARROW_GEOM, ARROW_OUTLINE_GEOM } = (() => {\n const loader = new THREE.ObjectLoader();\n const geometries = loader.parseGeometries([arrowGeometryJson, arrowOutlineGeometryJson]);\n const arrow = geometries[arrowGeometryJson.uuid];\n const arrowOutline = geometries[arrowOutlineGeometryJson.uuid];\n const scale = 0.015;\n const rot = Math.PI / 2;\n arrow.scale(scale, scale, scale);\n arrow.rotateX(rot);\n arrowOutline.scale(scale, scale, scale);\n arrowOutline.rotateX(rot);\n return { ARROW_GEOM: arrow, ARROW_OUTLINE_GEOM: arrowOutline };\n})();\n\n/**\n * @summary Panel identifier for nodes list\n * @type {string}\n * @constant\n * @private\n */\nexport const ID_PANEL_NODES_LIST = 'virtualTourNodesList';\n\n/**\n * @summary Nodes list template\n * @param {PSV.plugins.VirtualTourPlugin.Node[]} nodes\n * @param {string} title\n * @param {string} currentNodeId\n * @returns {string}\n * @constant\n * @private\n */\nexport const NODES_LIST_TEMPLATE = (nodes, title, currentNodeId) => `\n
      \n

      ${nodesList} ${title}

      \n
        \n ${nodes.map(node => `\n
      • \n ${node.thumbnail ? `` : ''}\n ${node.caption || node.name}\n
      • \n `).join('')}\n
      \n
      \n`;\n","import { AbstractButton, CONSTANTS } from '../..';\nimport { ID_PANEL_NODES_LIST } from './constants';\nimport nodesList from './nodes-list.svg';\n\n/**\n * @summary Navigation bar markers list button class\n * @extends PSV.buttons.AbstractButton\n * @memberof PSV.buttons\n */\nexport class NodesListButton extends AbstractButton {\n\n static id = 'nodesList';\n static icon = nodesList;\n\n /**\n * @param {PSV.components.Navbar} navbar\n */\n constructor(navbar) {\n super(navbar, 'psv-button--hover-scale psv-nodes-list-button', true);\n\n /**\n * @type {PSV.plugins.VirtualTourPlugin}\n */\n this.plugin = this.psv.getPlugin('virtual-tour');\n\n if (this.plugin) {\n this.psv.on(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.on(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n }\n }\n\n /**\n * @override\n */\n destroy() {\n this.psv.off(CONSTANTS.EVENTS.OPEN_PANEL, this);\n this.psv.off(CONSTANTS.EVENTS.CLOSE_PANEL, this);\n\n super.destroy();\n }\n\n /**\n * @override\n */\n isSupported() {\n return !!this.plugin && !this.plugin.isServerSide();\n }\n\n /**\n * @summary Handles events\n * @param {Event} e\n * @private\n */\n handleEvent(e) {\n /* eslint-disable */\n switch (e.type) {\n // @formatter:off\n case CONSTANTS.EVENTS.OPEN_PANEL: this.toggleActive(e.args[0] === ID_PANEL_NODES_LIST); break;\n case CONSTANTS.EVENTS.CLOSE_PANEL: this.toggleActive(false); break;\n // @formatter:on\n }\n /* eslint-enable */\n }\n\n /**\n * @override\n * @description Toggles nodes list\n */\n onClick() {\n this.plugin.toggleNodesList();\n }\n\n}\n","import { PSVError, utils } from 'photo-sphere-viewer';\nimport { AbstractDatasource } from './AbstractDatasource';\nimport { checkLink, checkNode } from './utils';\n\n/**\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @private\n */\nexport class ServerSideDatasource extends AbstractDatasource {\n\n constructor(plugin) {\n super(plugin);\n\n if (!plugin.config.getNode) {\n throw new PSVError('Missing getNode() option.');\n }\n\n this.nodeResolver = plugin.config.getNode;\n this.linksResolver = plugin.config.getLinks;\n }\n\n loadNode(nodeId) {\n if (this.nodes[nodeId]) {\n return Promise.resolve(this.nodes[nodeId]);\n }\n else {\n return Promise.resolve(this.nodeResolver(nodeId))\n .then((node) => {\n checkNode(node, this.plugin.isGps());\n this.nodes[nodeId] = node;\n return node;\n });\n }\n }\n\n loadLinkedNodes(nodeId) {\n if (!this.nodes[nodeId]) {\n return Promise.reject(new PSVError(`Node ${nodeId} not found`));\n }\n else if (this.nodes[nodeId].links) {\n return Promise.resolve();\n }\n else {\n if (!this.linksResolver) {\n this.nodes[nodeId].links = [];\n return Promise.resolve();\n }\n\n utils.logWarn(`getLinks() option is deprecated, instead make getNode() also return the node' links.`);\n\n return Promise.resolve(this.linksResolver(nodeId))\n .then(links => links || [])\n .then((links) => {\n const node = this.nodes[nodeId];\n\n links.forEach((link) => {\n checkLink(node, link, this.plugin.isGps());\n\n // copy essential data\n if (this.nodes[link.nodeId]) {\n link.position = link.position || this.nodes[link.nodeId].position;\n link.name = link.name || this.nodes[link.nodeId].name;\n }\n\n if (this.plugin.isGps() && !link.position) {\n throw new PSVError(`No GPS position provided for link ${link.nodeId} of node ${node.id}`);\n }\n });\n\n // store links\n node.links = links;\n });\n }\n }\n\n}\n","import * as THREE from 'three';\nimport { AbstractPlugin, CONSTANTS, DEFAULTS, PSVError, registerButton, utils } from '../..';\nimport { ClientSideDatasource } from './ClientSideDatasource';\nimport {\n ARROW_GEOM,\n ARROW_OUTLINE_GEOM,\n DEFAULT_ARROW,\n DEFAULT_MARKER,\n EVENTS,\n ID_PANEL_NODES_LIST,\n LINK_DATA,\n MODE_3D,\n MODE_CLIENT,\n MODE_GPS,\n MODE_MANUAL,\n MODE_MARKERS,\n MODE_SERVER,\n NODES_LIST_TEMPLATE\n} from './constants';\nimport { NodesListButton } from './NodesListButton';\nimport { ServerSideDatasource } from './ServerSideDatasource';\nimport './style.scss';\nimport { bearing, distance, setMeshColor } from './utils';\n\n\n/**\n * @callback GetNode\n * @summary Function to load a node\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @param {string} nodeId\n * @returns {PSV.plugins.VirtualTourPlugin.Node|Promise}\n */\n\n/**\n * @callback GetLinks\n * @summary Function to load the links of a node\n * @deprecated `getNode` must directly return the links of each node\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @param {string} nodeId\n * @returns {PSV.plugins.VirtualTourPlugin.NodeLink[]|Promise}\n */\n\n/**\n * @callback Preload\n * @summary Function to determine if a link must be preloaded\n * @memberOf PSV.plugins.VirtualTourPlugin\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} link\n * @returns {boolean}\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.Node\n * @summary Definition of a single node in the tour\n * @property {string} id - unique identifier of the node\n * @property {*} panorama\n * @property {PSV.plugins.VirtualTourPlugin.NodeLink[]} [links] - links to other nodes\n * @property {number[]} [position] - GPS position (longitude, latitude, optional altitude)\n * @property {PSV.PanoData | PSV.PanoDataProvider} [panoData] - data used for this panorama\n * @property {PSV.SphereCorrection} [sphereCorrection] - sphere correction to apply to this panorama\n * @property {string} [name] - short name of the node\n * @property {string} [caption] - caption visible in the navbar\n * @property {string} [description] - description visible in the side panel\n * @property {string} [thumbnail] - thumbnail for the nodes list in the side panel\n * @property {PSV.plugins.MarkersPlugin.Properties[]} [markers] - additional markers to use on this node\n */\n\n/**\n * @typedef {PSV.ExtendedPosition} PSV.plugins.VirtualTourPlugin.NodeLink\n * @summary Definition of a link between two nodes\n * @property {string} nodeId - identifier of the target node\n * @property {string} [name] - override the name of the node (tooltip)\n * @property {number[]} [position] - override the GPS position of the node\n * @property {PSV.plugins.MarkersPlugin.Properties} [markerStyle] - override global marker style\n * @property {PSV.plugins.VirtualTourPlugin.ArrowStyle} [arrowStyle] - override global arrow style\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.ArrowStyle\n * @summary Style of the arrow in 3D mode\n * @property {string} [color=0xaaaaaa]\n * @property {string} [hoverColor=0xaa5500]\n * @property {number} [outlineColor=0x000000]\n * @property {number[]} [scale=[0.5,2]]\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.Options\n * @property {'client'|'server'} [dataMode='client'] - configure data mode\n * @property {'manual'|'gps'} [positionMode='manual'] - configure positioning mode\n * @property {'markers'|'3d'} [renderMode='3d'] - configure rendering mode of links\n * @property {PSV.plugins.VirtualTourPlugin.Node[]} [nodes] - initial nodes\n * @property {PSV.plugins.VirtualTourPlugin.GetNode} [getNode]\n * @property {PSV.plugins.VirtualTourPlugin.GetLinks} [getLinks] - Deprecated: `getNode` must directly return the links of each node\n * @property {string} [startNodeId] - id of the initial node, if not defined the first node will be used\n * @property {boolean|PSV.plugins.VirtualTourPlugin.Preload} [preload=false] - preload linked panoramas\n * @property {boolean|string|number} [rotateSpeed='20rpm'] - speed of rotation when clicking on a link, if 'false' the viewer won't rotate at all\n * @property {boolean|number} [transition=1500] - duration of the transition between nodes\n * @property {boolean} [linksOnCompass] - if the Compass plugin is enabled, displays the links on the compass, defaults to `true` on in markers render mode\n * @property {PSV.plugins.MarkersPlugin.Properties} [markerStyle] - global marker style\n * @property {PSV.plugins.VirtualTourPlugin.ArrowStyle} [arrowStyle] - global arrow style\n * @property {number} [markerLatOffset=-0.1] - (GPS & Markers mode) latitude offset applied to link markers, to compensate for viewer height\n * @property {'top'|'bottom'} [arrowPosition='bottom'] - (3D mode) arrows vertical position\n */\n\n/**\n * @typedef {Object} PSV.plugins.VirtualTourPlugin.NodeChangedData\n * @summary Data associated to the \"node-changed\" event\n * @type {PSV.plugins.VirtualTourPlugin.Node} [fromNode] - The previous node\n * @type {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink] - The link that was clicked in the previous node\n * @type {PSV.Position} [fromLinkPosition] - The position of the link on the previous node\n */\n\n// add markers buttons\nDEFAULTS.lang[NodesListButton.id] = 'Locations';\nregisterButton(NodesListButton, 'caption:left');\n\n\nexport { EVENTS, MODE_3D, MODE_CLIENT, MODE_GPS, MODE_MANUAL, MODE_MARKERS, MODE_SERVER } from './constants';\n\n\n/**\n * @summary Create virtual tours by linking multiple panoramas\n * @extends PSV.plugins.AbstractPlugin\n * @memberof PSV.plugins\n */\nexport class VirtualTourPlugin extends AbstractPlugin {\n\n static id = 'virtual-tour';\n\n static EVENTS = EVENTS;\n static MODE_CLIENT = MODE_CLIENT;\n static MODE_SERVER = MODE_SERVER;\n static MODE_3D = MODE_3D;\n static MODE_MARKERS = MODE_MARKERS;\n static MODE_MANUAL = MODE_MANUAL;\n static MODE_GPS = MODE_GPS;\n\n /**\n * @param {PSV.Viewer} psv\n * @param {PSV.plugins.VirtualTourPlugin.Options} [options]\n */\n constructor(psv, options) {\n super(psv);\n\n /**\n * @member {Object}\n * @property {PSV.plugins.VirtualTourPlugin.Node} currentNode\n * @property {PSV.Tooltip} currentTooltip\n * @property {string} loadingNode\n * @property {function} stopObserver\n * @private\n */\n this.prop = {\n currentNode : null,\n currentTooltip: null,\n loadingNode : null,\n stopObserver : null,\n };\n\n /**\n * @type {Record}\n * @private\n */\n this.preload = {};\n\n /**\n * @member {PSV.plugins.VirtualTourPlugin.Options}\n * @private\n */\n this.config = {\n dataMode : MODE_CLIENT,\n positionMode : MODE_MANUAL,\n renderMode : MODE_3D,\n preload : false,\n rotateSpeed : '20rpm',\n transition : CONSTANTS.DEFAULT_TRANSITION,\n markerLatOffset: -0.1,\n arrowPosition : 'bottom',\n linksOnCompass : options?.renderMode === MODE_MARKERS,\n ...options,\n markerStyle : {\n ...DEFAULT_MARKER,\n ...options?.markerStyle,\n },\n arrowStyle : {\n ...DEFAULT_ARROW,\n ...options?.arrowStyle,\n },\n };\n\n if (options?.listButton === false) {\n utils.logWarn('VirtualTourPlugin: listButton option is deprecated. '\n + 'Please define the global navbar options according to your needs.');\n }\n if (options?.listButton === true && this.config.dataMode === MODE_SERVER) {\n utils.logWarn('VirtualTourPlugin: the list button is not supported in server mode.');\n }\n\n /**\n * @type {PSV.plugins.MarkersPlugin}\n * @private\n */\n this.markers = null;\n\n /**\n * @type {PSV.plugins.CompassPlugin}\n * @private\n */\n this.compass = null;\n\n /**\n * @type {PSV.plugins.VirtualTourPlugin.AbstractDatasource}\n */\n this.datasource = null;\n\n /**\n * @type {external:THREE.Group}\n * @private\n */\n this.arrowsGroup = null;\n\n if (this.is3D()) {\n this.arrowsGroup = new THREE.Group();\n\n const localLight = new THREE.PointLight(0xffffff, 1, 0);\n localLight.position.set(0, this.config.arrowPosition === 'bottom' ? 2 : -2, 0);\n this.arrowsGroup.add(localLight);\n }\n }\n\n /**\n * @package\n */\n init() {\n super.init();\n\n this.markers = this.psv.getPlugin('markers');\n this.compass = this.psv.getPlugin('compass');\n\n if (!this.is3D() && !this.markers) {\n throw new PSVError('Tour plugin requires the Markers plugin in markers mode');\n }\n\n this.datasource = this.isServerSide() ? new ServerSideDatasource(this) : new ClientSideDatasource(this);\n\n if (this.is3D()) {\n this.psv.once(CONSTANTS.EVENTS.READY, () => {\n this.__positionArrows();\n this.psv.renderer.scene.add(this.arrowsGroup);\n\n const ambientLight = new THREE.AmbientLight(0xffffff, 1);\n this.psv.renderer.scene.add(ambientLight);\n\n this.psv.needsUpdate();\n });\n\n this.psv.on(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n this.psv.on(CONSTANTS.EVENTS.CLICK, this);\n this.prop.stopObserver = this.psv.observeObjects(LINK_DATA, this);\n }\n else {\n this.markers.on('select-marker', this);\n }\n\n if (this.isServerSide()) {\n if (this.config.startNodeId) {\n this.setCurrentNode(this.config.startNodeId);\n }\n }\n else if (this.config.nodes) {\n this.setNodes(this.config.nodes, this.config.startNodeId);\n delete this.config.nodes;\n }\n }\n\n /**\n * @package\n */\n destroy() {\n if (this.markers) {\n this.markers.off('select-marker', this);\n }\n if (this.arrowsGroup) {\n this.psv.renderer.scene.remove(this.arrowsGroup);\n }\n\n this.psv.off(CONSTANTS.EVENTS.POSITION_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.ZOOM_UPDATED, this);\n this.psv.off(CONSTANTS.EVENTS.CLICK, this);\n this.prop.stopObserver?.();\n\n this.datasource.destroy();\n\n delete this.preload;\n delete this.datasource;\n delete this.markers;\n delete this.compass;\n delete this.arrowsGroup;\n\n super.destroy();\n }\n\n handleEvent(e) {\n let link;\n switch (e.type) {\n case 'select-marker':\n link = e.args[0].data?.[LINK_DATA];\n if (link) {\n this.setCurrentNode(link.nodeId, link);\n }\n break;\n\n case CONSTANTS.EVENTS.POSITION_UPDATED:\n case CONSTANTS.EVENTS.ZOOM_UPDATED:\n if (this.arrowsGroup) {\n this.__positionArrows();\n }\n break;\n\n case CONSTANTS.EVENTS.CLICK:\n link = e.args[0].objects.find(o => o.userData[LINK_DATA])?.userData[LINK_DATA];\n if (link) {\n this.setCurrentNode(link.nodeId, link);\n }\n break;\n\n case CONSTANTS.OBJECT_EVENTS.ENTER_OBJECT:\n this.__onEnterObject(e.detail.object, e.detail.viewerPoint);\n break;\n case CONSTANTS.OBJECT_EVENTS.HOVER_OBJECT:\n this.__onHoverObject(e.detail.object, e.detail.viewerPoint);\n break;\n case CONSTANTS.OBJECT_EVENTS.LEAVE_OBJECT:\n this.__onLeaveObject(e.detail.object);\n break;\n\n default:\n }\n }\n\n /**\n * @summary Tests if running in server mode\n * @return {boolean}\n */\n isServerSide() {\n return this.config.dataMode === MODE_SERVER;\n }\n\n /**\n * @summary Tests if running in GPS mode\n * @return {boolean}\n */\n isGps() {\n return this.config.positionMode === MODE_GPS;\n }\n\n /**\n * @summary Tests if running in 3D mode\n * @return {boolean}\n */\n is3D() {\n return this.config.renderMode === MODE_3D;\n }\n\n /**\n * @summary Sets the nodes (client mode only)\n * @param {PSV.plugins.VirtualTourPlugin.Node[]} nodes\n * @param {string} [startNodeId]\n * @throws {PSV.PSVError} when the configuration is incorrect\n */\n setNodes(nodes, startNodeId) {\n if (this.isServerSide()) {\n throw new PSVError('Cannot set nodes in server side mode');\n }\n\n this.datasource.setNodes(nodes);\n\n if (!startNodeId) {\n startNodeId = nodes[0].id;\n }\n else if (!this.datasource.nodes[startNodeId]) {\n startNodeId = nodes[0].id;\n utils.logWarn(`startNodeId not found is provided nodes, resetted to ${startNodeId}`);\n }\n\n this.setCurrentNode(startNodeId);\n }\n\n /**\n * @summary Changes the current node\n * @param {string} nodeId\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} [fromLink]\n * @returns {Promise} resolves false if the loading was aborted by another call\n */\n setCurrentNode(nodeId, fromLink = null) {\n if (nodeId === this.prop.currentNode?.id) {\n return Promise.resolve(true);\n }\n\n this.psv.hideError();\n\n this.prop.loadingNode = nodeId;\n\n const fromNode = this.prop.currentNode;\n const fromLinkPosition = fromNode && fromLink ? this.__getLinkPosition(fromNode, fromLink) : null;\n\n return Promise.all([\n // if this node is already preloading, wait for it\n Promise.resolve(this.preload[nodeId])\n .then(() => {\n if (this.prop.loadingNode !== nodeId) {\n throw utils.getAbortError();\n }\n\n return this.datasource.loadNode(nodeId);\n }),\n Promise.resolve(fromLinkPosition ? this.config.rotateSpeed : false)\n .then((speed) => { // eslint-disable-line consistent-return\n if (speed) {\n return this.psv.animate({ ...fromLinkPosition, speed });\n }\n })\n .then(() => {\n this.psv.loader.show();\n }),\n ])\n .then(([node]) => {\n if (this.prop.loadingNode !== nodeId) {\n throw utils.getAbortError();\n }\n\n this.prop.currentNode = node;\n\n if (this.prop.currentTooltip) {\n this.prop.currentTooltip.hide();\n this.prop.currentTooltip = null;\n }\n\n if (this.is3D()) {\n this.arrowsGroup.remove(...this.arrowsGroup.children.filter(o => o.type === 'Mesh'));\n }\n\n this.markers?.clearMarkers();\n this.compass?.clearHotspots();\n\n return Promise.all([\n this.psv.setPanorama(node.panorama, {\n transition : this.config.transition,\n caption : node.caption,\n description : node.description,\n panoData : node.panoData,\n sphereCorrection: node.sphereCorrection,\n })\n .then((completed) => {\n if (!completed) {\n throw utils.getAbortError();\n }\n }),\n this.datasource.loadLinkedNodes(nodeId),\n ]);\n })\n .then(() => {\n if (this.prop.loadingNode !== nodeId) {\n throw utils.getAbortError();\n }\n\n const node = this.prop.currentNode;\n\n if (node.markers) {\n if (this.markers) {\n this.markers.setMarkers(node.markers);\n }\n else {\n utils.logWarn(`Node ${node.id} markers ignored because the plugin is not loaded.`);\n }\n }\n\n this.__renderLinks(node);\n this.__preload(node);\n\n /**\n * @event node-changed\n * @memberof PSV.plugins.VirtualTourPlugin\n * @summary Triggered when the current node is changed\n * @param {string} nodeId\n * @param {PSV.plugins.VirtualTourPlugin.NodeChangedData} data\n */\n this.trigger(EVENTS.NODE_CHANGED, nodeId, {\n fromNode,\n fromLink,\n fromLinkPosition,\n });\n\n this.prop.loadingNode = null;\n\n return true;\n })\n .catch((err) => {\n if (utils.isAbortError(err)) {\n return false;\n }\n\n this.psv.showError(this.psv.config.lang.loadError);\n\n this.psv.loader.hide();\n this.psv.navbar.setCaption('');\n\n this.prop.loadingNode = null;\n\n throw err;\n });\n }\n\n /**\n * @summary Adds the links for the node\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @private\n */\n __renderLinks(node) {\n const positions = [];\n\n node.links.forEach((link) => {\n const position = this.__getLinkPosition(node, link);\n positions.push(position);\n\n if (this.is3D()) {\n const mesh = new THREE.Mesh(ARROW_GEOM, new THREE.MeshLambertMaterial());\n mesh.userData = { [LINK_DATA]: link, longitude: position.longitude };\n mesh.rotation.order = 'YXZ';\n mesh.rotateY(-position.longitude);\n this.psv.dataHelper\n .sphericalCoordsToVector3({ longitude: position.longitude, latitude: 0 }, mesh.position)\n .multiplyScalar(1 / CONSTANTS.SPHERE_RADIUS);\n\n const outlineMesh = new THREE.Mesh(ARROW_OUTLINE_GEOM, new THREE.MeshBasicMaterial({ side: THREE.BackSide }));\n outlineMesh.position.copy(mesh.position);\n outlineMesh.rotation.copy(mesh.rotation);\n\n setMeshColor(mesh, link.arrowStyle?.color || this.config.arrowStyle.color);\n setMeshColor(outlineMesh, link.arrowStyle?.outlineColor || this.config.arrowStyle.outlineColor);\n\n this.arrowsGroup.add(mesh);\n this.arrowsGroup.add(outlineMesh);\n }\n else {\n if (this.isGps()) {\n position.latitude += this.config.markerLatOffset;\n }\n\n this.markers.addMarker({\n ...this.config.markerStyle,\n ...link.markerStyle,\n id : `tour-link-${link.nodeId}`,\n tooltip : link.name,\n hideList: true,\n data : { [LINK_DATA]: link },\n ...position,\n }, false);\n }\n });\n\n if (this.is3D()) {\n this.__positionArrows();\n }\n else {\n this.markers.renderMarkers();\n }\n\n if (this.config.linksOnCompass && this.compass) {\n this.compass.setHotspots(positions);\n }\n }\n\n /**\n * @summary Computes the marker position for a link\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @param {PSV.plugins.VirtualTourPlugin.NodeLink} link\n * @return {PSV.Position}\n * @private\n */\n __getLinkPosition(node, link) {\n if (this.isGps()) {\n const p1 = [THREE.Math.degToRad(node.position[0]), THREE.Math.degToRad(node.position[1])];\n const p2 = [THREE.Math.degToRad(link.position[0]), THREE.Math.degToRad(link.position[1])];\n const h1 = node.position[2] !== undefined ? node.position[2] : link.position[2] || 0;\n const h2 = link.position[2] !== undefined ? link.position[2] : node.position[2] || 0;\n\n let latitude = 0;\n if (h1 !== h2) {\n latitude = Math.atan((h2 - h1) / distance(p1, p2));\n }\n\n const longitude = bearing(p1, p2);\n\n return { longitude, latitude };\n }\n else {\n return this.psv.dataHelper.cleanPosition(link);\n }\n }\n\n /**\n * @private\n */\n __onEnterObject(mesh, viewerPoint) {\n const link = mesh.userData[LINK_DATA];\n\n setMeshColor(mesh, link.arrowStyle?.hoverColor || this.config.arrowStyle.hoverColor);\n\n if (link.name) {\n this.prop.currentTooltip = this.psv.tooltip.create({\n left : viewerPoint.x,\n top : viewerPoint.y,\n content: link.name,\n });\n }\n\n this.psv.needsUpdate();\n }\n\n\n /**\n * @private\n */\n __onHoverObject(mesh, viewerPoint) {\n if (this.prop.currentTooltip) {\n this.prop.currentTooltip.move({\n left: viewerPoint.x,\n top : viewerPoint.y,\n });\n }\n }\n\n\n /**\n * @private\n */\n __onLeaveObject(mesh) {\n const link = mesh.userData[LINK_DATA];\n\n setMeshColor(mesh, link.arrowStyle?.color || this.config.arrowStyle.color);\n\n if (this.prop.currentTooltip) {\n this.prop.currentTooltip.hide();\n this.prop.currentTooltip = null;\n }\n\n this.psv.needsUpdate();\n }\n\n /**\n * @summary Updates to position of the group of arrows\n * @private\n */\n __positionArrows() {\n this.arrowsGroup.position.copy(this.psv.prop.direction).multiplyScalar(0.5);\n const s = this.config.arrowStyle.scale;\n const f = s[1] + (s[0] - s[1]) * (this.psv.getZoomLevel() / 100);\n const y = 2.5 - (this.psv.getZoomLevel() / 100) * 1.5;\n this.arrowsGroup.position.y += this.config.arrowPosition === 'bottom' ? -y : y;\n this.arrowsGroup.scale.set(f, f, f);\n }\n\n /**\n * @summary Manage the preload of the linked panoramas\n * @param {PSV.plugins.VirtualTourPlugin.Node} node\n * @private\n */\n __preload(node) {\n if (!this.config.preload) {\n return;\n }\n\n this.preload[node.id] = true;\n\n this.prop.currentNode.links\n .filter(link => !this.preload[link.nodeId])\n .filter((link) => {\n if (typeof this.config.preload === 'function') {\n return this.config.preload(this.prop.currentNode, link);\n }\n else {\n return true;\n }\n })\n .forEach((link) => {\n this.preload[link.nodeId] = this.datasource.loadNode(link.nodeId)\n .then((linkNode) => {\n return this.psv.textureLoader.preloadPanorama(linkNode.panorama);\n })\n .then(() => {\n this.preload[link.nodeId] = true;\n })\n .catch(() => {\n delete this.preload[link.nodeId];\n });\n });\n }\n\n /**\n * @summary Toggles the visibility of the list of nodes\n */\n toggleNodesList() {\n if (this.psv.panel.prop.contentId === ID_PANEL_NODES_LIST) {\n this.hideNodesList();\n }\n else {\n this.showNodesList();\n }\n }\n\n /**\n * @summary Opens side panel with the list of nodes\n */\n showNodesList() {\n const nodes = this.change(EVENTS.RENDER_NODES_LIST, Object.values(this.datasource.nodes));\n\n this.psv.panel.show({\n id : ID_PANEL_NODES_LIST,\n content : NODES_LIST_TEMPLATE(\n nodes,\n this.psv.config.lang[NodesListButton.id],\n this.prop.currentNode?.id\n ),\n noMargin : true,\n clickHandler: (e) => {\n const li = e.target ? utils.getClosest(e.target, 'li') : undefined;\n const nodeId = li ? li.dataset.nodeId : undefined;\n\n if (nodeId) {\n this.setCurrentNode(nodeId);\n this.hideNodesList();\n }\n },\n });\n }\n\n /**\n * @summary Closes side panel if it contains the list of nodes\n */\n hideNodesList() {\n this.psv.panel.hide(ID_PANEL_NODES_LIST);\n }\n\n}\n"],"names":["AbstractDatasource","plugin","nodes","destroy","loadNode","nodeId","PSVError","loadLinkedNodes","checkNode","node","isGps","id","panorama","position","length","checkLink","link","utils","isExtendedPosition","setMeshColor","mesh","color","material","set","distance","p1","p2","greatArcDistance","bearing","λ1","φ1","λ2","φ2","y","Math","sin","cos","x","atan2","ClientSideDatasource","Promise","resolve","reject","setNodes","rawNodes","linkedNodes","forEach","links","logWarn","name","MODE_CLIENT","MODE_SERVER","MODE_MANUAL","MODE_GPS","MODE_MARKERS","MODE_3D","EVENTS","NODE_CHANGED","RENDER_NODES_LIST","LINK_DATA","DEFAULT_MARKER","html","arrowIconSvg","width","height","scale","anchor","className","style","DEFAULT_ARROW","hoverColor","outlineColor","loader","THREE","ObjectLoader","geometries","parseGeometries","arrowGeometryJson","arrowOutlineGeometryJson","arrow","uuid","arrowOutline","rot","PI","rotateX","ARROW_GEOM","ARROW_OUTLINE_GEOM","ID_PANEL_NODES_LIST","NODES_LIST_TEMPLATE","title","currentNodeId","nodesList","map","thumbnail","caption","join","NodesListButton","navbar","psv","getPlugin","on","CONSTANTS","OPEN_PANEL","CLOSE_PANEL","off","isSupported","isServerSide","handleEvent","e","type","toggleActive","args","onClick","toggleNodesList","AbstractButton","icon","ServerSideDatasource","config","getNode","nodeResolver","linksResolver","getLinks","then","DEFAULTS","lang","registerButton","VirtualTourPlugin","options","prop","currentNode","currentTooltip","loadingNode","stopObserver","preload","dataMode","positionMode","renderMode","rotateSpeed","transition","DEFAULT_TRANSITION","markerLatOffset","arrowPosition","linksOnCompass","markerStyle","arrowStyle","listButton","markers","compass","datasource","arrowsGroup","is3D","Group","localLight","PointLight","add","init","once","READY","__positionArrows","renderer","scene","ambientLight","AmbientLight","needsUpdate","POSITION_UPDATED","ZOOM_UPDATED","CLICK","observeObjects","startNodeId","setCurrentNode","remove","data","objects","find","o","userData","OBJECT_EVENTS","ENTER_OBJECT","__onEnterObject","detail","object","viewerPoint","HOVER_OBJECT","__onHoverObject","LEAVE_OBJECT","__onLeaveObject","fromLink","hideError","fromNode","fromLinkPosition","__getLinkPosition","all","getAbortError","speed","animate","show","hide","children","filter","clearMarkers","clearHotspots","setPanorama","description","panoData","sphereCorrection","completed","setMarkers","__renderLinks","__preload","trigger","catch","err","isAbortError","showError","loadError","setCaption","positions","push","Mesh","MeshLambertMaterial","longitude","rotation","order","rotateY","dataHelper","sphericalCoordsToVector3","latitude","multiplyScalar","SPHERE_RADIUS","outlineMesh","MeshBasicMaterial","side","BackSide","copy","addMarker","tooltip","hideList","renderMarkers","setHotspots","degToRad","h1","undefined","h2","atan","cleanPosition","create","left","top","content","move","direction","s","f","getZoomLevel","linkNode","textureLoader","preloadPanorama","panel","contentId","hideNodesList","showNodesList","change","Object","values","noMargin","clickHandler","li","target","getClosest","dataset","AbstractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEA;EACA;EACA;EACA;;MACaA,kBAAb;EAEE;EACF;EACA;;EAGE;EACF;EACA;EACE,8BAAYC,MAAZ,EAAoB;EAAA,SALpBC,KAKoB,GALZ,EAKY;EAClB,SAAKD,MAAL,GAAcA,MAAd;EACD;;EAZH;;EAAA,SAcEE,OAdF,GAcE,mBAAU;EACR,WAAO,KAAKF,MAAZ;EACD;EAED;EACF;EACA;EACA;EACA;EAtBA;;EAAA,SAuBEG,QAvBF,GAuBE,kBAASC,MAAT,EAAiB;EAAE;EACjB,UAAM,IAAIC,0BAAJ,CAAa,0BAAb,CAAN;EACD;EAED;EACF;EACA;EACA;EACA;EA/BA;;EAAA,SAgCEC,eAhCF,GAgCE,yBAAgBF,MAAhB,EAAwB;EAAE;EACxB,UAAM,IAAIC,0BAAJ,CAAa,iCAAb,CAAN;EACD,GAlCH;;EAAA;EAAA;;ECJA;EACA;EACA;EACA;EACA;EACA;;EACO,SAASE,SAAT,CAAmBC,IAAnB,EAAyBC,KAAzB,EAAgC;EAAA;;EACrC,MAAI,CAACD,IAAI,CAAC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AkBD;EAED;EACF;EACA;EAvmBA;;EAAA,SAwmBEA,aAxmBF,GAwmBE,yBAAgB;EACd,SAAKjK,GAAL,CAAS+J,KAAT,CAAe7D,IAAf,CAAoB7G,mBAApB;EACD,GA1mBH;;EAAA;EAAA,EAAuCuL,gCAAvC;EAAahJ,kBAEJnH,KAAK;EAFDmH,kBAIJtE,SAASA;EAJLsE,kBAKJ5E,cAAcA;EALV4E,kBAMJ3E,cAAcA;EANV2E,kBAOJvE,UAAUA;EAPNuE,kBAQJxE,eAAeA;EARXwE,kBASJ1E,cAAcA;EATV0E,kBAUJzE,WAAWA;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/plugins/visible-range.js b/dist/plugins/visible-range.js index 5fb04b004..7b8ed6778 100644 --- a/dist/plugins/visible-range.js +++ b/dist/plugins/visible-range.js @@ -1,5 +1,5 @@ /*! -* Photo Sphere Viewer 4.5.3 +* Photo Sphere Viewer 4.6.0 * @copyright 2014-2015 Jérémy Heleine * @copyright 2015-2022 Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) diff --git a/dist/viewer-compat.js.map b/dist/viewer-compat.js.map deleted file mode 100644 index c7c7bbc1d..000000000 --- a/dist/viewer-compat.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"viewer-compat.js","sources":["../src/ViewerCompat.js"],"sourcesContent":["export default class ViewerCompat {\n\n constructor() {\n throw new Error('PhotoSphereViewer#ViewerCompat has been removed, please migrate to v4 Viewer.');\n }\n\n}\n"],"names":["ViewerCompat","Error"],"mappings":";;;;;;;;;;;;MAAqBA,eAEnB,wBAAc;EACZ,QAAM,IAAIC,KAAJ,CAAU,+EAAV,CAAN;EACD;;;;;;;;"} \ No newline at end of file diff --git a/docs/.jsdoc/index.md b/docs/.jsdoc/index.md index 9b2498530..b203acc4e 100644 --- a/docs/.jsdoc/index.md +++ b/docs/.jsdoc/index.md @@ -16,13 +16,12 @@ ## Exported members - [AbstractAdapter](PSV.adapters.AbstractAdapter.html) - Base class for render adapters -- [AbstractButton](PSV.buttons.AbstractButton.html) - Base class for plugins buttons +- [AbstractButton](PSV.buttons.AbstractButton.html) - Base class for buttons - [AbstractPlugin](PSV.plugins.AbstractPlugin.html) - Base class for plugins -- [Animation](PSV.Animation.html) - Animations manager - [CONSTANTS](PSV.constants.html) - All internal constants - [DEFAULTS](PSV.html#.DEFAULTS) - Default configuration - [PSVError](PSV.PSVError.html) - Generic error -- [registerButton](PSV.html#.registerButton) - Helper for registering plugins buttons +- [registerButton](PSV.html#.registerButton) - Helper for registering buttons - [SYSTEM](PSV.html#.SYSTEM) - System informations -- [Viewer](PSV.Viewer.html) - Base class - [utils](PSV.utils.html) - Various utilities +- [Viewer](PSV.Viewer.html) - Base class diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index b80af97e9..5c2222f82 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -48,8 +48,10 @@ module.exports = { children : [ 'adapters/equirectangular', 'adapters/equirectangular-tiles', + ['adapters/equirectangular-video', 'Equirectangular videos (NEW)'], 'adapters/cubemap', - ['adapters/cubemap-tiles', 'Cubemap tiles (NEW)'], + 'adapters/cubemap-tiles', + ['adapters/cubemap-video', 'Cubemap videos (NEW)'], ], }, { @@ -88,6 +90,7 @@ module.exports = { 'plugin-resolution', 'plugin-settings', 'plugin-stereo', + ['plugin-video', 'Video (NEW)'], 'plugin-virtual-tour', 'plugin-visible-range', ], diff --git a/docs/.vuepress/public/assets/cubemap-video.png b/docs/.vuepress/public/assets/cubemap-video.png new file mode 100644 index 000000000..65989b2f5 Binary files /dev/null and b/docs/.vuepress/public/assets/cubemap-video.png differ diff --git a/docs/README.md b/docs/README.md index fd08f2d24..7902a0591 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,8 +15,8 @@ features: details: Many options, methods and events allows deep integration in your website/app. - title: Plugins details: New plugins add new features without bloating the main library. - - title: Modern technologies - details: Photo Sphere Viewer is pure JS and based on Three.js, allowing very good performances on WebGL enabled systems. + - title: Videos + details: Photo Sphere Viewer also supports video, both equirectangular and cubemaps. footer: Licensed under MIT License, documentation under CC BY 3.0 --- diff --git a/docs/guide/README.md b/docs/guide/README.md index 4e0ea739e..f3d90722a 100644 --- a/docs/guide/README.md +++ b/docs/guide/README.md @@ -56,7 +56,7 @@ Include all JS & CSS files in your page manually or with your favorite bundler a
      + + + + + + + + + + diff --git a/example/cubemap.html b/example/cubemap.html index 9e80acaa8..6d75cd71f 100644 --- a/example/cubemap.html +++ b/example/cubemap.html @@ -21,7 +21,7 @@ + + + + + + + + + + + diff --git a/example/equirectangular.html b/example/equirectangular.html index 87b3d28e3..3299870db 100644 --- a/example/equirectangular.html +++ b/example/equirectangular.html @@ -16,22 +16,47 @@ + +