diff --git a/packages/core/src/Viewer.ts b/packages/core/src/Viewer.ts index 912a0682f..bbfa0088f 100644 --- a/packages/core/src/Viewer.ts +++ b/packages/core/src/Viewer.ts @@ -29,6 +29,7 @@ import { AnimateOptions, CssSize, ExtendedPosition, + PanoData, PanoramaOptions, ParsedViewerConfig, Position, @@ -38,6 +39,7 @@ import { } from './model'; import type { AbstractPlugin, PluginConstructor } from './plugins/AbstractPlugin'; import { pluginInterop } from './plugins/AbstractPlugin'; +import { PSVError } from './PSVError'; import { DataHelper } from './services/DataHelper'; import { EventsHandler } from './services/EventsHandler'; import { Renderer } from './services/Renderer'; @@ -323,7 +325,7 @@ export class Viewer extends TypedEventTarget { // apply default parameters on first load if (!this.state.ready) { - ['sphereCorrection', 'panoData'].forEach((opt) => { + ['sphereCorrection', 'panoData', 'overlay', 'overlayOpacity'].forEach((opt) => { if (!(opt in options)) { // @ts-ignore options[opt] = this.config[opt]; @@ -331,6 +333,16 @@ export class Viewer extends TypedEventTarget { }); } + if (isExtendedPosition(options)) { + logWarn(`PanoramaOptions.yaw and PanoramaOptions.pitch are deprecated, use PanoramaOptions.position instead`); + (options as PanoramaOptions).position = this.dataHelper.cleanPosition(options); + } + if (typeof options.transition === 'number') { + logWarn(`Use PanoramaOptions.speed to define the speed/duration of the transition`); + options.speed = options.transition; + options.transition = true; + } + if (options.transition === undefined) { options.transition = true; } @@ -378,6 +390,7 @@ export class Viewer extends TypedEventTarget { this.dispatchEvent(new PanoramaErrorEvent(path, err)); throw err; } else { + this.setOverlay(options.overlay, options.overlayOpacity); this.navbar.setCaption(this.config.caption); return true; } @@ -449,6 +462,50 @@ export class Viewer extends TypedEventTarget { return this.state.loadingPromise; } + /** + * @deprecated Use the `overlay` plugin instead + */ + setOverlay(path: any, opacity = this.config.overlayOpacity): Promise { + const supportsOverlay = (this.adapter.constructor as typeof AbstractAdapter).supportsOverlay; + + if (!path) { + if (supportsOverlay) { + this.renderer.setOverlay(null, 0); + } + + return Promise.resolve(); + } else { + if (!supportsOverlay) { + return Promise.reject(new PSVError(`Current adapter does not supports overlay`)); + } + + return this.adapter + .loadTexture( + path, + (image) => { + if ((this.state.textureData.panoData as PanoData).isEquirectangular) { + const p = this.state.textureData.panoData as PanoData; + const r = image.width / p.croppedWidth; + return { + isEquirectangular: true, + fullWidth: r * p.fullWidth, + fullHeight: r * p.fullHeight, + croppedWidth: r * p.croppedWidth, + croppedHeight: r * p.croppedHeight, + croppedX: r * p.croppedX, + croppedY: r * p.croppedY, + }; + } + }, + false, + false + ) + .then((textureData) => { + this.renderer.setOverlay(textureData, opacity); + }); + } + } + /** * Update options * @throws {@link PSVError} if the configuration is invalid diff --git a/packages/core/src/adapters/AbstractAdapter.ts b/packages/core/src/adapters/AbstractAdapter.ts index 85f8f1858..b255d06d2 100644 --- a/packages/core/src/adapters/AbstractAdapter.ts +++ b/packages/core/src/adapters/AbstractAdapter.ts @@ -1,7 +1,7 @@ -import { Mesh } from 'three'; -import { PSVError } from '../PSVError'; -import type { Viewer } from '../Viewer'; +import { Mesh, ShaderMaterial, ShaderMaterialParameters } from 'three'; import { PanoData, PanoDataProvider, PanoramaPosition, Position, TextureData } from '../model'; +import type { Viewer } from '../Viewer'; +import { PSVError } from '../PSVError'; import { checkVersion } from '../utils'; /** @@ -26,6 +26,11 @@ export abstract class AbstractAdapter { */ static readonly supportsDownload: boolean = false; + /** + * @deprecated + */ + static readonly supportsOverlay: boolean = false; + constructor(protected readonly viewer: Viewer) {} /** @@ -107,6 +112,73 @@ export abstract class AbstractAdapter { * Clear a loaded texture from memory */ abstract disposeTexture(textureData: TextureData): void; + + /** + * @deprecated + */ + // @ts-ignore unused parameter + // eslint-disable-next-line @typescript-eslint/no-unused-vars + setOverlay(mesh: Mesh, textureData: TextureData, opacity: number): void { + throw new PSVError('Current adapter does not support overlay'); + } + + /** + * @internal + */ + static OVERLAY_UNIFORMS = { + panorama: 'panorama', + overlay: 'overlay', + globalOpacity: 'globalOpacity', + overlayOpacity: 'overlayOpacity', + }; + + /** + * @internal + */ + static createOverlayMaterial({ + additionalUniforms, + overrideVertexShader, + }: { + additionalUniforms?: ShaderMaterialParameters['uniforms']; + overrideVertexShader?: ShaderMaterialParameters['vertexShader']; + } = {}): ShaderMaterial { + return new ShaderMaterial({ + uniforms: { + ...additionalUniforms, + [AbstractAdapter.OVERLAY_UNIFORMS.panorama]: { value: null }, + [AbstractAdapter.OVERLAY_UNIFORMS.overlay]: { value: null }, + [AbstractAdapter.OVERLAY_UNIFORMS.globalOpacity]: { value: 1.0 }, + [AbstractAdapter.OVERLAY_UNIFORMS.overlayOpacity]: { value: 0.0 }, + }, + + vertexShader: + overrideVertexShader || + ` +varying vec2 vUv; + +void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`, + + fragmentShader: ` +uniform sampler2D ${AbstractAdapter.OVERLAY_UNIFORMS.panorama}; +uniform sampler2D ${AbstractAdapter.OVERLAY_UNIFORMS.overlay}; +uniform float ${AbstractAdapter.OVERLAY_UNIFORMS.globalOpacity}; +uniform float ${AbstractAdapter.OVERLAY_UNIFORMS.overlayOpacity}; + +varying vec2 vUv; + +void main() { + vec4 tColor1 = texture2D( ${AbstractAdapter.OVERLAY_UNIFORMS.panorama}, vUv ); + vec4 tColor2 = texture2D( ${AbstractAdapter.OVERLAY_UNIFORMS.overlay}, vUv ); + gl_FragColor = vec4( + mix( tColor1.rgb, tColor2.rgb, tColor2.a * ${AbstractAdapter.OVERLAY_UNIFORMS.overlayOpacity} ), + ${AbstractAdapter.OVERLAY_UNIFORMS.globalOpacity} + ); +}`, + }); + } } // prettier-ignore diff --git a/packages/core/src/adapters/EquirectangularAdapter.ts b/packages/core/src/adapters/EquirectangularAdapter.ts index 8ff4861df..bdab18685 100644 --- a/packages/core/src/adapters/EquirectangularAdapter.ts +++ b/packages/core/src/adapters/EquirectangularAdapter.ts @@ -1,4 +1,4 @@ -import { BufferGeometry, Material, MathUtils, Mesh, MeshBasicMaterial, SphereGeometry, Texture } from 'three'; +import { BufferGeometry, MathUtils, Mesh, ShaderMaterial, SphereGeometry, Texture } from 'three'; import { PSVError } from '../PSVError'; import type { Viewer } from '../Viewer'; import { SPHERE_RADIUS } from '../data/constants'; @@ -38,7 +38,7 @@ export type EquirectangularAdapterConfig = { blur?: boolean; }; -type EquirectangularMesh = Mesh; +type EquirectangularMesh = Mesh; type EquirectangularTexture = TextureData; const getConfig = getConfigParser( @@ -66,6 +66,7 @@ export class EquirectangularAdapter extends AbstractAdapter = { panorama: null, + overlay: null, + overlayOpacity: 1, container: null, adapter: [EquirectangularAdapter as any, null], plugins: [], @@ -36,8 +38,10 @@ export const DEFAULTS: Required = { mousemove: true, mousewheelCtrlKey: false, touchmoveTwoFingers: false, + useXmpData: null, panoData: null, requestHeaders: null, + canvasBackground: null, rendererParameters: { alpha: true, antialias: true }, withCredentials: false, // prettier-ignore @@ -85,6 +89,8 @@ export const DEFAULTS: Required = { export const READONLY_OPTIONS: Record = { panorama: 'Use setPanorama method to change the panorama', panoData: 'Use setPanorama method to change the panorama', + overlay: 'Use setOverlay method to changer the overlay', + overlayOpacity: 'Use setOverlay method to changer the overlay', container: 'Cannot change viewer container', adapter: 'Cannot change adapter', plugins: 'Cannot change plugins', @@ -117,6 +123,9 @@ export const CONFIG_PARSERS: ConfigParsers = { } return adapter; }, + overlayOpacity: (overlayOpacity) => { + return MathUtils.clamp(overlayOpacity, 0, 1); + }, defaultYaw: (defaultYaw) => { // defaultYaw is between 0 and PI return parseAngle(defaultYaw); @@ -223,6 +232,24 @@ export const CONFIG_PARSERS: ConfigParsers = { } return navbar; }, + useXmpData: (useXmpData) => { + if (useXmpData !== null) { + logWarn(`Global useXmpData is deprecated, it is now configured on the adapter.`); + } + return useXmpData; + }, + canvasBackground: (canvasBackground) => { + if (canvasBackground !== null) { + logWarn(`Global canvasBackground is deprecated, it is now configured on the adapter.`); + } + return canvasBackground; + }, + overlay: (overlay) => { + if (overlay !== null) { + logWarn(`"overlay" option is deprecated, use "@photo-sphere-viewer/overlay-plugin" instead.`); + } + return overlay; + }, }; /** diff --git a/packages/core/src/model.ts b/packages/core/src/model.ts index da7aa6cf7..cf5149998 100644 --- a/packages/core/src/model.ts +++ b/packages/core/src/model.ts @@ -110,7 +110,7 @@ export type PanoDataProvider = (image: HTMLImageElement, xmpData?: PanoData) => /** * Object defining options for {@link Viewer.setPanorama} */ -export type PanoramaOptions = { +export type PanoramaOptions = Partial & { /** * new panorama position */ @@ -131,7 +131,7 @@ export type PanoramaOptions = { * enable transition between old and new panorama * @default true */ - transition?: boolean | 'fade-only'; + transition?: boolean | number | 'fade-only'; /** * speed or duration of the transition between old and new panorama * @default 1500 @@ -150,6 +150,14 @@ export type PanoramaOptions = { * new data used for this panorama */ panoData?: PanoData | PanoDataProvider; + /** + * @deprecated Use the `overlay` plugin instead + */ + overlay?: any; + /** + * @deprecated Use the `overlay` plugin instead + */ + overlayOpacity?: number; }; /** @@ -293,6 +301,10 @@ export type NavbarCustomButton = { export type ViewerConfig = { container: HTMLElement | string; panorama?: any; + /** @deprecated Use the `overlay` plugin instead */ + overlay?: any; + /** @deprecated Use the `overlay` plugin instead */ + overlayOpacity?: number; /** @default equirectangular */ adapter?: AdapterConstructor | [AdapterConstructor, any]; plugins?: Array; @@ -338,8 +350,12 @@ export type ViewerConfig = { mousewheelCtrlKey?: boolean; /** @default false */ touchmoveTwoFingers?: boolean; + /** @deprecated configure `useXmpData` on EquirectangularAdapter */ + useXmpData?: boolean; panoData?: PanoData | PanoDataProvider; requestHeaders?: Record | ((url: string) => Record); + /** @deprecated configure `backgroundColor` on EquirectangularAdapter */ + canvasBackground?: string; /** @default '{ alpha: true, antialias: true }' */ rendererParameters?: WebGLRendererParameters; /** @default false */ @@ -397,6 +413,8 @@ export type ParsedViewerConfig = Omit< export type ReadonlyViewerConfig = | 'panorama' | 'panoData' + | 'overlay' + | 'overlayOpacity' | 'container' | 'adapter' | 'plugins'; diff --git a/packages/core/src/services/Renderer.ts b/packages/core/src/services/Renderer.ts index 123e6f3d1..ba95c9b56 100644 --- a/packages/core/src/services/Renderer.ts +++ b/packages/core/src/services/Renderer.ts @@ -32,6 +32,7 @@ import { PanoData, PanoramaOptions, Point, SphereCorrection, TextureData } from import { Animation, isNil } from '../utils'; import type { Viewer } from '../Viewer'; import { AbstractService } from './AbstractService'; +import type { AbstractAdapter } from '../adapters/AbstractAdapter'; const vector2 = new Vector2(); const matrix4 = new Matrix4(); @@ -149,6 +150,9 @@ export class Renderer extends AbstractService { if ((e as ConfigChangedEvent).containsOptions('fisheye')) { this.__onPositionUpdated(); } + if ((e as ConfigChangedEvent).containsOptions('canvasBackground')) { + this.container.style.background = this.config.canvasBackground; + } break; } } @@ -239,6 +243,10 @@ export class Renderer extends AbstractService { * @internal */ setTexture(textureData: TextureData) { + if ((this.viewer.adapter.constructor as typeof AbstractAdapter).supportsOverlay) { + this.setOverlay(null, 0); + } + if (this.state.textureData) { this.viewer.adapter.disposeTexture(this.state.textureData); } @@ -250,6 +258,21 @@ export class Renderer extends AbstractService { this.viewer.needsUpdate(); } + /** + * @deprecated + */ + setOverlay(textureData: TextureData, opacity: number) { + if (this.state.overlayData) { + this.viewer.adapter.disposeTexture(this.state.overlayData); + } + + this.state.overlayData = textureData; + + this.viewer.adapter.setOverlay(this.mesh, textureData, opacity); + + this.viewer.needsUpdate(); + } + /** * Applies a panorama data pose to a Mesh * @internal diff --git a/packages/core/src/services/ViewerState.ts b/packages/core/src/services/ViewerState.ts index 8631761d7..9111519b9 100644 --- a/packages/core/src/services/ViewerState.ts +++ b/packages/core/src/services/ViewerState.ts @@ -2,6 +2,7 @@ import { Mesh, Vector3 } from 'three'; import { SPHERE_RADIUS } from '../data/constants'; import { Size, TextureData } from '../model'; import type { Animation } from '../utils'; +import { logWarn } from '../utils'; /** * Internal properties of the viewer @@ -90,6 +91,20 @@ export class ViewerState { */ textureData: TextureData; + /** + * Current overlay texture displayed + */ + overlayData: TextureData; + + /** + * panorama metadata, if supported + * @deprecated use `textureData.panoData` instead + */ + get panoData() { + logWarn('ViewerState.panoData is deprecated, use ViewerState.textureData.panoData instead'); + return this.textureData?.panoData; + } + /** * Current override of the global cursor */ diff --git a/packages/core/src/utils/browser.ts b/packages/core/src/utils/browser.ts index 6062f7194..508782c3f 100644 --- a/packages/core/src/utils/browser.ts +++ b/packages/core/src/utils/browser.ts @@ -94,6 +94,13 @@ export function getPosition(el: HTMLElement): Point { return { x, y }; } +/** + * @deprecated use {@link getStyleProperty} (using dash-case instead of camelCase) + */ +export function getStyle(elt: Element, prop: string): string { + return (window.getComputedStyle(elt, null) as any)[prop]; +} + /** * Gets an element style value */ diff --git a/packages/cubemap-adapter/src/CubemapAdapter.ts b/packages/cubemap-adapter/src/CubemapAdapter.ts index bed4e6e6e..60aa49b1f 100644 --- a/packages/cubemap-adapter/src/CubemapAdapter.ts +++ b/packages/cubemap-adapter/src/CubemapAdapter.ts @@ -1,6 +1,6 @@ import type { PanoramaPosition, Position, TextureData, Viewer } from '@photo-sphere-viewer/core'; import { AbstractAdapter, CONSTANTS, PSVError, SYSTEM, utils } from '@photo-sphere-viewer/core'; -import { BoxGeometry, MathUtils, Mesh, MeshBasicMaterial, Texture, Vector2, Vector3 } from 'three'; +import { BoxGeometry, MathUtils, Mesh, ShaderMaterial, Texture, Vector3 } from 'three'; import { Cubemap, CubemapAdapterConfig, @@ -13,12 +13,23 @@ import { } from './model'; import { cleanCubemap, cleanCubemapArray, isCubemap } from './utils'; -type CubemapMesh = Mesh; +type CubemapMesh = Mesh; type CubemapTexture = TextureData; -const getConfig = utils.getConfigParser({ - blur: false, -}); +const getConfig = utils.getConfigParser( + { + flipTopBottom: null, + blur: false, + }, + { + flipTopBottom(flipTopBottom) { + if (!utils.isNil(flipTopBottom)) { + utils.logWarn('CubemapPanorama "flipTopBottom" option is deprecated, it must be defined on the panorama object'); + } + return flipTopBottom; + }, + } +); const EPS = 0.000001; const ORIGIN = new Vector3(); @@ -30,6 +41,7 @@ export class CubemapAdapter extends AbstractAdapter texture.dispose()); } + + private __setUniform(mesh: CubemapMesh, index: number, uniform: string, value: any) { + mesh.material[index].uniforms[uniform].value = value; + } } diff --git a/packages/cubemap-adapter/src/model.ts b/packages/cubemap-adapter/src/model.ts index b8388576a..0adea9ac9 100644 --- a/packages/cubemap-adapter/src/model.ts +++ b/packages/cubemap-adapter/src/model.ts @@ -65,6 +65,10 @@ export type CubemapData = { }; export type CubemapAdapterConfig = { + /** + * @deprecated Must be defined on the panorama object + */ + flipTopBottom?: boolean; /** * used for cubemap tiles adapter * @internal diff --git a/packages/cubemap-tiles-adapter/src/CubemapTilesAdapter.ts b/packages/cubemap-tiles-adapter/src/CubemapTilesAdapter.ts index a4c2a9538..83dc34425 100644 --- a/packages/cubemap-tiles-adapter/src/CubemapTilesAdapter.ts +++ b/packages/cubemap-tiles-adapter/src/CubemapTilesAdapter.ts @@ -39,13 +39,24 @@ function prettyTileId(tile: CubemapTile) { return `${tileId(tile)}\n${CUBE_HASHMAP[tile.face]}`; } -const getConfig = utils.getConfigParser({ - showErrorTile: true, - baseBlur: true, - antialias: true, - blur: false, - debug: false, -}); +const getConfig = utils.getConfigParser( + { + flipTopBottom: null, + showErrorTile: true, + baseBlur: true, + antialias: true, + blur: false, + debug: false, + }, + { + flipTopBottom(flipTopBottom) { + if (!utils.isNil(flipTopBottom)) { + utils.logWarn('CubemapTilesAdapter "flipTopBottom" option is deprecated, it must be defined on the panorama object'); + } + return flipTopBottom; + }, + } +); const vertexPosition = new Vector3(); @@ -60,6 +71,7 @@ export class CubemapTilesAdapter extends AbstractAdapter< static override readonly id = 'cubemap-tiles'; static override readonly VERSION = PKG_VERSION; static override readonly supportsDownload = false; + static override readonly supportsOverlay = false; private readonly config: CubemapTilesAdapterConfig; @@ -148,7 +160,7 @@ export class CubemapTilesAdapter extends AbstractAdapter< const firstTile = getTileConfig(panorama, 0, { CUBE_SEGMENTS }); const panoData: CubemapData = { isCubemap: true, - flipTopBottom: panorama.flipTopBottom ?? false, + flipTopBottom: panorama.flipTopBottom ?? this.config.flipTopBottom ?? false, faceSize: firstTile.faceSize, }; @@ -445,6 +457,7 @@ export class CubemapTilesAdapter extends AbstractAdapter< this.adapter = new CubemapAdapter(this.viewer, { blur: this.config.baseBlur, + flipTopBottom: this.config.flipTopBottom, }); } return this.adapter; diff --git a/packages/cubemap-video-adapter/src/CubemapVideoAdapter.ts b/packages/cubemap-video-adapter/src/CubemapVideoAdapter.ts index 18333c5c9..ce25fcfb2 100644 --- a/packages/cubemap-video-adapter/src/CubemapVideoAdapter.ts +++ b/packages/cubemap-video-adapter/src/CubemapVideoAdapter.ts @@ -17,10 +17,21 @@ type ShaderUniforms = { vidWH: { value: Vector2 }; }; -const getConfig = utils.getConfigParser({ - autoplay: false, - muted: false, -}); +const getConfig = utils.getConfigParser( + { + equiangular: null, + autoplay: false, + muted: false, + }, + { + equiangular(equiangular) { + if (!utils.isNil(equiangular)) { + utils.logWarn('CubemapVideoAdapter "equiangular" option is deprecated, it must be defined on the panorama object'); + } + return equiangular; + }, + } +); /** * Adapter for cubemap videos @@ -38,7 +49,7 @@ export class CubemapVideoAdapter extends AbstractVideoAdapter { - panorama.equiangular = panorama.equiangular ?? true; + panorama.equiangular = panorama.equiangular ?? this.config.equiangular ?? true; return super.loadTexture(panorama); } diff --git a/packages/cubemap-video-adapter/src/model.ts b/packages/cubemap-video-adapter/src/model.ts index d3d8a54e0..55b99b2d2 100644 --- a/packages/cubemap-video-adapter/src/model.ts +++ b/packages/cubemap-video-adapter/src/model.ts @@ -11,4 +11,9 @@ export type CubemapVideoPanorama = AbstractVideoPanorama & { equiangular?: boolean; }; -export type CubemapVideoAdapterConfig = AbstractVideoAdapterConfig; +export type CubemapVideoAdapterConfig = AbstractVideoAdapterConfig & { + /** + * @deprecated Must be defined on the panorama object + */ + equiangular?: boolean; +}; diff --git a/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts b/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts index 7d85ae5f7..b35b47666 100644 --- a/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts +++ b/packages/equirectangular-tiles-adapter/src/EquirectangularTilesAdapter.ts @@ -102,6 +102,7 @@ export class EquirectangularTilesAdapter extends AbstractAdapter< static override readonly id = 'equirectangular-tiles'; static override readonly VERSION = PKG_VERSION; static override readonly supportsDownload = false; + static override readonly supportsOverlay = false; // @internal public readonly SPHERE_SEGMENTS: number; diff --git a/packages/little-planet-adapter/src/LittlePlanetAdapter.ts b/packages/little-planet-adapter/src/LittlePlanetAdapter.ts index 3fef55b1e..51d56a9a4 100644 --- a/packages/little-planet-adapter/src/LittlePlanetAdapter.ts +++ b/packages/little-planet-adapter/src/LittlePlanetAdapter.ts @@ -24,6 +24,7 @@ export class LittlePlanetAdapter extends EquirectangularAdapter { static override readonly id = 'little-planet'; static override readonly VERSION = PKG_VERSION; static override readonly supportsDownload = true; + static override readonly supportsOverlay = false; private uniforms: ShaderUniforms; diff --git a/packages/map-plugin/src/MapPlugin.ts b/packages/map-plugin/src/MapPlugin.ts index 853353e71..ac50b3377 100644 --- a/packages/map-plugin/src/MapPlugin.ts +++ b/packages/map-plugin/src/MapPlugin.ts @@ -17,10 +17,14 @@ const getConfig = utils.getConfigParser( position: ['bottom', 'left'], visibleOnLoad: true, overlayImage: overlay, + compassImage: null, pinImage: pin, pinSize: 35, coneColor: '#1E78E6', coneSize: 40, + spotColor: null, + spotImage: null, + spotSize: null, spotStyle: { size: 15, image: null, @@ -44,7 +48,28 @@ const getConfig = utils.getConfigParser( }, }, { - spotStyle: (spotStyle, { defValue }) => ({ ...defValue, ...spotStyle }), + overlayImage: (overlayImage, { rawConfig }) => { + if (rawConfig.compassImage) { + utils.logWarn('map: "compassImage" is deprecated, use "overlayImage" instead'); + return rawConfig.compassImage; + } + return overlayImage; + }, + spotStyle: (spotStyle, { rawConfig, defValue }) => { + [ + ['spotColor', 'color'], + ['spotImage', 'image'], + ['spotSize', 'size'], + ].forEach(([oldName, newName]) => { + // @ts-ignore + if (rawConfig[oldName]) { + utils.logWarn(`map: "${oldName}" is deprecated, use "spotStyle.${newName}" instead`); + // @ts-ignore + spotStyle[newName] = rawConfig[oldName]; + } + }); + return { ...defValue, ...spotStyle }; + }, position: (position, { defValue }) => { return utils.cleanCssPosition(position, { allowCenter: false, cssOrder: true }) || defValue; }, @@ -53,7 +78,9 @@ const getConfig = utils.getConfigParser( defaultZoom: (defaultZoom) => Math.log(defaultZoom / 100), maxZoom: (maxZoom) => Math.log(maxZoom / 100), minZoom: (minZoom) => Math.log(minZoom / 100), - buttons: (buttons, { defValue }) => ({ ...defValue, ...buttons }), + buttons: (buttons, { defValue }) => { + return { ...defValue, ...buttons }; + }, } ); diff --git a/packages/map-plugin/src/model.ts b/packages/map-plugin/src/model.ts index cf0dbf1d5..d807d840f 100644 --- a/packages/map-plugin/src/model.ts +++ b/packages/map-plugin/src/model.ts @@ -94,6 +94,11 @@ export type MapPluginConfig = { */ overlayImage?: string; + /** + * @deprecated Use `overlayImage` instead + */ + compassImage?: string; + /** * SVG or image URL used for the central pin (must be square) */ @@ -117,6 +122,21 @@ export type MapPluginConfig = { */ coneSize?: number; + /** + * @deprecated use `spotStyle.color` + */ + spotColor?: string; + + /** + * @deprecated use `spotStyle.image` + */ + spotImage?: string; + + /** + * @deprecated use `spotStyle.size` + */ + spotSize?: number; + /** * Default style of hotspots */ diff --git a/packages/shared/AbstractVideoAdapter.ts b/packages/shared/AbstractVideoAdapter.ts index 6a496cd55..6fb09aecd 100644 --- a/packages/shared/AbstractVideoAdapter.ts +++ b/packages/shared/AbstractVideoAdapter.ts @@ -31,6 +31,7 @@ export abstract class AbstractVideoAdapter< TData > extends AbstractAdapter { static override readonly supportsDownload = false; + static override readonly supportsOverlay = false; protected abstract readonly config: AbstractVideoAdapterConfig; diff --git a/packages/virtual-tour-plugin/src/VirtualTourPlugin.ts b/packages/virtual-tour-plugin/src/VirtualTourPlugin.ts index 45a362c14..c41508df1 100644 --- a/packages/virtual-tour-plugin/src/VirtualTourPlugin.ts +++ b/packages/virtual-tour-plugin/src/VirtualTourPlugin.ts @@ -36,6 +36,8 @@ const getConfig = utils.getConfigParser( fadeIn: true, rotation: true, }, + rotateSpeed: null, + transition: null, linksOnCompass: true, markerStyle: DEFAULT_MARKER, arrowStyle: DEFAULT_ARROW, @@ -85,6 +87,25 @@ const getConfig = utils.getConfigParser( } return map; }, + transitionOptions(transitionOptions, { rawConfig }) { + if (typeof transitionOptions === 'object') { + if (!utils.isNil(rawConfig.transition)) { + utils.logWarn('VirtualTourPlugin: "transition" option is deprecated, use "transitionOptions" instead'); + if (typeof rawConfig.transition === 'number') { + transitionOptions.speed = rawConfig.transition; + } else if (rawConfig.transition === false) { + transitionOptions.fadeIn = false; + } + } + if (!utils.isNil(rawConfig.rotateSpeed)) { + utils.logWarn('VirtualTourPlugin: "rotateSpeed" option is deprecated, use "transitionOptions" instead'); + if (rawConfig.rotateSpeed === false) { + transitionOptions.rotation = false; + } + } + } + return transitionOptions; + }, } ); diff --git a/packages/virtual-tour-plugin/src/model.ts b/packages/virtual-tour-plugin/src/model.ts index f2a81a0fc..bf5b13629 100644 --- a/packages/virtual-tour-plugin/src/model.ts +++ b/packages/virtual-tour-plugin/src/model.ts @@ -218,6 +218,7 @@ export type VirtualTourPluginConfig = { * preload linked panoramas */ preload?: boolean | ((node: VirtualTourNode, link: VirtualTourLink) => boolean); + /** * Configuration of the transition between nodes. Can be a callback. * @default `{ showLoader: true, speed: '20rpm', fadeIn: true, rotation: true }` @@ -229,6 +230,14 @@ export type VirtualTourPluginConfig = { fromNode?: VirtualTourNode, fromLink?: VirtualTourLink ) => VirtualTourTransitionOptions); + /** + * @deprecated Use {@link VirtualTourPluginConfig#transitionOptions} + */ + rotateSpeed?: false | string | number; + /** + * @deprecated Use {@link VirtualTourPluginConfig#transitionOptions} + */ + transition?: boolean | number; /** * if the Compass plugin is enabled, displays the links on the compass * @default true diff --git a/packages/visible-range-plugin/src/VisibleRangePlugin.ts b/packages/visible-range-plugin/src/VisibleRangePlugin.ts index cf6e73655..26044233a 100644 --- a/packages/visible-range-plugin/src/VisibleRangePlugin.ts +++ b/packages/visible-range-plugin/src/VisibleRangePlugin.ts @@ -177,17 +177,15 @@ export class VisibleRangePlugin extends AbstractConfigurablePlugin< * Changes the ranges according the current panorama cropping data */ setRangesFromPanoData() { - if (this.viewer.state.textureData.panoData) { - this.setVerticalRange(this.__getPanoVerticalRange()); - this.setHorizontalRange(this.__getPanoHorizontalRange()); - } + this.setVerticalRange(this.__getPanoVerticalRange()); + this.setHorizontalRange(this.__getPanoHorizontalRange()); } /** * Gets the vertical range defined by the viewer's panoData */ private __getPanoVerticalRange(): Range { - const p = this.viewer.state.textureData.panoData; + const p = this.viewer.state.panoData; if (p.croppedHeight === p.fullHeight) { return null; } else { @@ -200,7 +198,7 @@ export class VisibleRangePlugin extends AbstractConfigurablePlugin< * Gets the horizontal range defined by the viewer's panoData */ private __getPanoHorizontalRange(): Range { - const p = this.viewer.state.textureData.panoData; + const p = this.viewer.state.panoData; if (p.croppedWidth === p.fullWidth) { return null; } else {