forked from mistic100/Photo-Sphere-Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewer.d.ts
More file actions
392 lines (343 loc) · 10.1 KB
/
Copy pathViewer.d.ts
File metadata and controls
392 lines (343 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
import { Vector3 } from 'three';
import { Event, EventEmitter } from 'uevent';
import { AdapterConstructor } from './adapters/AbstractAdapter';
import { Animation } from './Animation';
import { Loader } from './components/Loader';
import { Navbar } from './components/Navbar';
import { Notification } from './components/Notification';
import { Overlay } from './components/Overlay';
import { Panel } from './components/Panel';
import { Tooltip } from './components/Tooltip';
import {
AnimateOptions,
ClickData,
CssSize,
ExtendedPosition,
NavbarCustomButton,
PanoData,
PanoDataProvider,
PanoramaOptions,
Position,
Size
} from './models';
import { AbstractPlugin, PluginConstructor } from './plugins/AbstractPlugin';
import { DataHelper } from './services/DataHelper';
import { TextureLoader } from './services/TextureLoader';
import { TooltipRenderer } from './services/TooltipRenderer';
/**
* @summary Viewer options, see {@link http://photo-sphere-viewer.js.org/guide/config.html}
*/
export type ViewerOptions = {
container: HTMLElement | string;
panorama?: string;
adapter?: AdapterConstructor<any> | [AdapterConstructor<any>, any];
caption?: string;
loadingImg?: string;
loadingTxt?: string;
size?: Size;
fisheye?: boolean;
minFov?: number;
maxFov?: number;
defaultZoomLvl?: number;
defaultLong?: number;
defaultLat?: number;
sphereCorrection?: { pan?: number, tilt?: number, roll?: number },
sphereCorrectionReorder?: boolean;
moveSpeed?: number;
zoomSpeed?: number;
autorotateDelay?: null,
autorotateSpeed?: string | number;
autorotateLat?: number;
moveInertia?: boolean;
mousewheel?: boolean;
mousemove?: boolean;
captureCursor?: boolean;
mousewheelCtrlKey?: boolean;
touchmoveTwoFingers?: boolean;
useXmpData?: boolean;
panoData?: PanoData | PanoDataProvider;
requestHeaders?: Record<string, string> | ((url: string) => Record<string, string>);
canvasBackground?: string;
withCredentials?: boolean;
navbar?: string | Array<string | NavbarCustomButton>,
lang?: Record<string, string>,
keyboard?: Record<string, string>,
plugins?: Array<PluginConstructor<any> | [PluginConstructor<any>, any]>,
};
/**
* Internal properties of the viewer
*/
export type ViewerProps = {
ready: boolean;
uiRefresh: boolean;
needsUpdate: boolean;
fullscreen: boolean;
direction: Vector3;
vFov: number;
hFov: number;
aspect: number;
autorotateEnabled: boolean;
animationPromise: Animation;
loadingPromise: Promise<void>;
startTimeout: any;
size: Size;
panoData: PanoData;
};
/**
* Main class
*/
export class Viewer extends EventEmitter {
/**
* Configuration holder
*/
readonly config: ViewerOptions;
/**
* Internal properties
*/
prop: ViewerProps;
/**
* Top most parent
*/
readonly parent: HTMLElement;
/**
* Main container
*/
readonly container: HTMLElement;
/**
* Textures loader
*/
readonly textureLoader: TextureLoader;
/**
* Utilities to help converting data
*/
readonly dataHelper: DataHelper;
readonly loader: Loader;
readonly navbar: Navbar;
readonly panel: Panel;
readonly tooltip: TooltipRenderer;
readonly notification: Notification;
readonly overlay: Overlay;
/**
* @throws {PSVError} when the configuration is incorrect
*/
constructor(options: ViewerOptions);
/**
* @summary Destroys the viewer
* @description The memory used by the ThreeJS context is not totally cleared. This will be fixed as soon as possible.
*/
destroy();
/**
* @summary Returns the instance of a plugin if it exists
*/
getPlugin<T extends AbstractPlugin>(pluginId: string | PluginConstructor<T>): T;
/**
* @summary Returns the current position of the camera
*/
getPosition(): Position;
/**
* @summary Returns the current zoom level
*/
getZoomLevel(): number;
/**
* @summary Returns the current viewer size
*/
getSize(): Size;
/**
* @summary Checks if the automatic rotation is enabled
*/
isAutorotateEnabled(): boolean;
/**
* @summary Checks if the viewer is in fullscreen
*/
isFullscreenEnabled(): boolean;
/**
* @summary Flags the view has changed for the next render
*/
needsUpdate();
/**
* @summary Resizes the canvas when the window is resized
*/
autoSize();
/**
* @summary Loads a new panorama file
* @description Loads a new panorama file, optionally changing the camera position/zoom and activating the transition animation.<br>
* If the "options" parameter is not defined, the camera will not move and the ongoing animation will continue.<br>
* If another loading is already in progress it will be aborted.
*/
setPanorama(panorama: any, options?: PanoramaOptions): Promise<void>;
/**
* @summary Update options
*/
setOptions(options: Partial<ViewerOptions>);
/**
* @summary Update options
*/
setOption<K extends keyof ViewerOptions>(option: K, value: ViewerOptions[K]);
/**
* @summary Starts the automatic rotation
*/
startAutorotate();
/**
* @summary Stops the automatic rotation
*/
stopAutorotate();
/**
* @summary Starts or stops the automatic rotation
*/
toggleAutorotate();
/**
* @summary Displays an error message
*/
showError(message: string);
/**
* @summary Hides the error message
*/
hideError();
/**
* @summary Rotates the view to specific longitude and latitude
*/
rotate(position: ExtendedPosition);
/**
* @summary Rotates and zooms the view with a smooth animation
*/
animate(options: AnimateOptions): Animation;
/**
* @summary Stops the ongoing animation
* @description The return value is a Promise because the is no guaranty the animation can be stopped synchronously.
*/
stopAnimation(): Promise<void>;
/**
* @summary Zooms to a specific level between `max_fov` and `min_fov`
*/
zoom(level: number);
/**
* @summary Increases the zoom level
* @param {number} [step=1]
*/
zoomIn(step?: number);
/**
* @summary Decreases the zoom level
* @param {number} [step=1]
*/
zoomOut(step?: number);
/**
* @summary Resizes the viewer
*/
resize(size: CssSize);
/**
* @summary Enters the fullscreen mode
*/
enterFullscreen();
/**
* @summary Exits the fullscreen mode
*/
exitFullscreen();
/**
* @summary Enters or exits the fullscreen mode
*/
toggleFullscreen();
/**
* @summary Enables the keyboard controls (done automatically when entering fullscreen)
*/
startKeyboardControl();
/**
* @summary Disables the keyboard controls (done automatically when exiting fullscreen)
*/
stopKeyboardControl();
/**
* @summary Triggered when the automatic rotation is enabled/disabled
*/
on(e: 'autorotate', cb: (e: Event, enabled: true) => void): this;
/**
* @summary Triggered before a render, used to modify the view
*/
on(e: 'before-render', cb: (e: Event, timestamp: number, elapsed: number) => void): this;
/**
* @summary Triggered before a rotate operation, can be cancelled
*/
on(e: 'before-rotate', cb: (e: Event, position: ExtendedPosition) => void): this;
/**
* @summary Triggered when the user clicks on the viewer (everywhere excluding the navbar and the side panel)
*/
on(e: 'click', cb: (e: Event, data: ClickData) => void): this;
/**
* @summary Trigered when the panel is closed
*/
on(e: 'close-panel', cb: (e: Event, id: string | undefined) => void): this;
/**
* @summary Triggered after a call to setOption/setOptions
*/
on(e: 'config-changed', cb: (e: Event, options: string[]) => void): this;
/**
* @summary Triggered when the user double clicks on the viewer. The simple `click` event is always fired before `dblclick`
*/
on(e: 'dblclick', cb: (e: Event, data: ClickData) => void): this;
/**
* @summary Triggered when the fullscreen mode is enabled/disabled
*/
on(e: 'fullscreen-updated', cb: (e: Event, enabled: true) => void): this;
/**
* @summary Called to alter the target position of an animation
*/
on(e: 'get-animate-position', cb: (e: Event, position: Position) => Position): this;
/**
* @summary Called to alter the target position of a rotation
*/
on(e: 'get-rotate-position', cb: (e: Event, position: Position) => Position): this;
/**
* @summary Triggered when the notification is hidden
*/
on(e: 'hide-notification', cb: (e: Event) => void): this;
/**
* @summary Triggered when the overlay is hidden
*/
on(e: 'hide-overlay', cb: (e: Event, id: string | undefined) => void): this;
/**
* @summary Trigered when the tooltip is hidden
*/
on(e: 'hide-tooltip', cb: (e: Event, data: any) => void): this;
/**
* @summary Triggered when the panel is opened
*/
on(e: 'open-panel', cb: (e: Event, id: string | undefined) => void): this;
/**
* @summary Triggered when a panorama image has been loaded
*/
on(e: 'panorama-loaded', cb: (e: Event) => void): this;
/**
* @summary Triggered when the view longitude and/or latitude changes
*/
on(e: 'position-updated', cb: (e: Event, position: Position) => void): this;
/**
* @summary Triggered when the panorama image has been loaded and the viewer is ready to perform the first render
*/
once(e: 'ready', cb: (e: Event) => void): this;
/**
* @summary Triggered on each viewer render, **this event is triggered very often**
*/
on(e: 'render', cb: (e: Event) => void): this;
/**
* @summary Trigered when the notification is shown
*/
on(e: 'show-notification', cb: (e: Event) => void): this;
/**
* @summary Trigered when the overlay is shown
*/
on(e: 'show-overlay', cb: (e: Event, id: string | undefined) => void): this;
/**
* @summary Trigered when the tooltip is shown
*/
on(e: 'show-tooltip', cb: (e: Event, data: any, tooltip: Tooltip) => void): this;
/**
* @summary Triggered when the viewer size changes
*/
on(e: 'size-updated', cb: (e: Event, size: Size) => void): this;
/**
* @summary Triggered when all current animations are stopped
*/
on(e: 'stop-all', cb: (e: Event) => void): this;
/**
* @summary Triggered when the zoom level changes
*/
on(e: 'zoom-updated', cb: (e: Event, zoom: number) => void): this;
}