@3dweb/360javascriptviewer 1.8.38 → 1.8.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,360 +1,401 @@
1
- import {Slot} from "ts-event-bus";
1
+ import { Slot } from 'ts-event-bus';
2
2
 
3
3
  export class JavascriptViewer {
4
- /**
5
- * Create an instance of the viewer.
6
- * There are multiple instances possible on a page
7
- * @param options
8
- */
9
- constructor(options: options);
10
-
11
- /**
12
- * Use this to register events.
13
- * @return IEvents
14
- */
15
- events(): IEvents;
16
-
17
- /**
18
- * Start the presentation, loading all images and replace the main image with a 360 presentation
19
- * @async
20
- * @return boolean
21
- * @throws string
22
- */
23
- start(): Promise<boolean>;
24
-
25
- /**
26
- * Destroys the presentation and returns to previous state
27
- * @async
28
- * @return boolean
29
- * @throws string
30
- */
31
- destroy(): Promise<boolean>;
32
-
33
- /**
34
- * Set the desired rotation and the 360 model is rotating to it.
35
- * @async
36
- * @param degree
37
- * @return IResponse
38
- * @throws string
39
- */
40
- rotateDegrees(degree: number): Promise<IResponse>;
41
-
42
- /**
43
- * Rotate to a certain degree. Frame nr 1 is 0 degrees.
44
- * @param targetDegree
45
- * @param shortestWay
46
- * @param useEasing
47
- * @return IResponse
48
- * @throws string
49
- */
50
- rotateToDegree(targetDegree: number, shortestWay?: boolean, useEasing?: boolean): Promise<IResponse>;
51
-
52
- /**
53
- * Rotate to a certain degree. Frame nr 1 is 0 degrees.
54
- * @param frame
55
- * @param shortestWay
56
- * @param useEasing
57
- * @return IResponse
58
- * @throws string
59
- */
60
- rotateToFrame(frame: number, shortestWay?: boolean, useEasing?: boolean): Promise<IResponse>;
61
-
62
- /**
63
- * Set the current speed of rotating for the viewer instance
64
- * @param speed
65
- */
66
- setSpeed(speed: number): void;
67
-
68
- /**
69
- * Set the current inertia of the viewer
70
- * Set the current inertia for the viewer instance
71
- * @param inertia
72
- */
73
- setInertia(inertia: number): void;
74
-
75
- /**
76
- * Change the current presentation created by 3dweb.io
77
- * @param id
78
- */
79
- setId(id: number): Promise<boolean>;
80
-
81
- /**
82
- * Resets the zoom
83
- */
84
- resetZoom(): Promise<void>
85
-
86
- /**
87
- * Zoom to given location.
88
- * x and y are percentages from the middle 0-1 and -1-0
89
- */
90
- zoomTo(factor:number, x:number, y:number): Promise<void>
91
-
92
- /**
93
- * Checks if the presentation is zoomed
94
- */
95
- isZoomedIn(): boolean
4
+ /**
5
+ * Create an instance of the viewer.
6
+ * There are multiple instances possible on a page
7
+ * @param options
8
+ */
9
+ constructor(options: options);
10
+
11
+ /**
12
+ * Use this to register events.
13
+ * @return IEvents
14
+ */
15
+ events(): IEvents;
16
+
17
+ /**
18
+ * Start the presentation, loading all images and replace the main image with a 360 presentation
19
+ * @async
20
+ * @return boolean
21
+ * @throws string
22
+ */
23
+ start(): Promise<boolean>;
24
+
25
+ /**
26
+ * Destroys the presentation and returns to previous state
27
+ * @async
28
+ * @return boolean
29
+ * @throws string
30
+ */
31
+ destroy(): Promise<boolean>;
32
+
33
+ /**
34
+ * Set the desired rotation and the 360 model is rotating to it.
35
+ * @async
36
+ * @param degree
37
+ * @return IResponse
38
+ * @throws string
39
+ */
40
+ rotateDegrees(degree: number): Promise<IResponse>;
41
+
42
+ /**
43
+ * Rotate to a certain degree. Frame nr 1 is 0 degrees.
44
+ * @param targetDegree
45
+ * @param shortestWay
46
+ * @param useEasing
47
+ * @return IResponse
48
+ * @throws string
49
+ */
50
+ rotateToDegree(targetDegree: number, shortestWay?: boolean, useEasing?: boolean): Promise<IResponse>;
51
+
52
+ /**
53
+ * Rotate to a certain degree. Frame nr 1 is 0 degrees.
54
+ * @param frame
55
+ * @param shortestWay
56
+ * @param useEasing
57
+ * @return IResponse
58
+ * @throws string
59
+ */
60
+ rotateToFrame(frame: number, shortestWay?: boolean, useEasing?: boolean): Promise<IResponse>;
61
+
62
+ /**
63
+ * Set the current speed of rotating for the viewer instance
64
+ * @param speed
65
+ */
66
+ setSpeed(speed: number): void;
67
+
68
+ /**
69
+ * Set the current inertia of the viewer
70
+ * Set the current inertia for the viewer instance
71
+ * @param inertia
72
+ */
73
+ setInertia(inertia: number): void;
74
+
75
+ /**
76
+ * Change the current presentation created by 3dweb.io
77
+ * @param id
78
+ */
79
+ setId(id: number): Promise<boolean>;
80
+
81
+ /**
82
+ * Resets the zoom
83
+ */
84
+ resetZoom(): Promise<void>
85
+
86
+ /**
87
+ * Zoom to given location.
88
+ * x and y are percentages from the middle 0-1 and -1-0
89
+ */
90
+ zoomTo(factor: number, x: number, y: number): Promise<void>
91
+
92
+ /**
93
+ * Checks if the presentation is zoomed
94
+ */
95
+ isZoomedIn(): boolean
96
96
  }
97
97
 
98
98
  export type Optional<T> = {
99
- [P in keyof T]?: T[P];
99
+ [P in keyof T]?: T[P];
100
100
  };
101
101
 
102
102
  export type options = Optional<IOptions>;
103
103
 
104
104
  export interface IResponse {
105
- currentDegree: number;
105
+ currentDegree: number;
106
106
  }
107
107
 
108
108
  export interface IOptions {
109
109
 
110
- /**
111
- * ID of the presentation created by 3dweb.io
112
- */
113
- id?: string;
114
-
115
- /**
116
- * ID of the image which is the base for all the frames
117
- * default is jsv-image
118
- */
119
- mainImageId?: string;
120
-
121
- /**
122
- * ID of the div where the presentation runs in
123
- * Default is jsv-holder
124
- */
125
- mainHolderId?: string;
126
-
127
- /**
128
- * URl of the first image, doesn't have to be in the document.
129
- * Default is empty
130
- */
131
- mainImageUrl?: string;
132
-
133
- /**
134
- * Amount of frames in the presentation, more images means smoother rotations
135
- * but also more heavier for the browser
136
- * default is 72
137
- */
138
- totalFrames?: number;
139
-
140
- /**
141
- * After loading the presentation this is the first frame visible
142
- * Default is 1
143
- */
144
- firstImageNumber?: number;
145
-
146
- /**
147
- * Invert the rotation direction when dragging
148
- * Default is false
149
- */
150
- reverse?: boolean;
151
-
152
- /**
153
- * Speed of rotating -199 to 100
154
- * Default is 80
155
- */
156
- speed?: number;
157
-
158
- /**
159
- * Delay when stop dragging
160
- * Default is 20
161
- */
162
- inertia?: number;
163
-
164
- /**
165
- * Disable the build in progress bar, use this when you have
166
- * implemented your own loader or don't like this one.
167
- * Default is true
168
- */
169
- defaultProgressBar?: boolean;
170
-
171
- /**
172
- * Format for determining the filenames of the frames
173
- * {filename}_xx.{extension} is the default
174
- * ipod_x.jpg => ipod_1.jpg
175
- * ipod_xx.jpg => ipod_01.jpg
176
- * https://other.cdn/images/ipod_xx.jpg => https://other.cdn/images/ipod_01.jpg
177
- */
178
- imageUrlFormat?: string
179
-
180
- /**
181
- * Load all image urls into the viewer. Total frames will be overwritten
182
- */
183
- imageUrls?: string[]
184
-
185
- /**
186
- * Add a class to all the images used in the presentation, separate multiple classes with a space.
187
- * Default is empty
188
- */
189
- extraImageClass?: string
190
-
191
- /**
192
- * Use this setting in combination with imageUrlFormat.
193
- * startFrameNo: 4 => first file is ipod_04.jpg
194
- * Default is 1
195
- */
196
- startFrameNo?: number
197
-
198
- /**
199
- * Use this setting for rotating the view at start. Rotation stops when user drags the model
200
- * or another animation method is called
201
- * startRotation: 0 => No Rotation, 1 => Rotate once, 2 => Rotate twice
202
- * Default is 0
203
- */
204
- autoRotate?: number
205
-
206
- /**
207
- * Use this setting for changing the speed of the auto rotating. -199 to 100
208
- * Default is speed of viewer
209
- */
210
- autoRotateSpeed?: number
211
-
212
- /**
213
- * Use this setting for changing the direction of the auto rotating.
214
- * Default is false
215
- */
216
- autoRotateReverse?: boolean
217
-
218
- /**
219
- * Use this setting for enabling click and pinch events on images
220
- * Default is false
221
- */
222
- enableImageEvents?: boolean
223
-
224
- /**
225
- * Fires changeImage event in rotation. Keep track what your user is watching.
226
- * Could be CPU heavy
227
- * Default is false
228
- */
229
- enableChangeImageEvent?: boolean
230
-
231
- /**
232
- * Use this setting for enabling zoom functions.
233
- * Default is false
234
- */
235
- zoom?: boolean
236
-
237
- /**
238
- * If zoom is enabled this is the max zoom factor.
239
- * Default is 2
240
- */
241
- zoomMax?: number
242
-
243
- /**
244
- * Change the speed of zooming with the mousewheel.
245
- * Default is 50
246
- */
247
- zoomWheelSpeed?: number
248
-
249
- /**
250
- * Blocks repeating images after reaching last image.
251
- * Default is false
252
- */
253
- stopAtEdges?: boolean
254
-
255
- /**
256
- * Change the cursors for the presentation
257
- */
258
- cursorConfig?: ICursorConfig
259
-
260
- /**
261
- * Configure the notifications
262
- */
263
- notificationConfig?: INotificationConfig
264
-
265
- /**
266
- * Set the query params height and width for use with an image resizer.
267
- */
268
- autoCDNResizer?: boolean
269
-
270
- /**
271
- * Configure the image resizer
272
- */
273
- autoCDNResizerConfig?: IAutoCDNResizerConfig
274
-
275
- /**
276
- * License to remove powered by logo
277
- * default is empty
278
- */
279
- license?: string;
110
+ /**
111
+ * ID of the presentation created by 3dweb.io
112
+ */
113
+ id?: string;
114
+
115
+ /**
116
+ * ID of the image which is the base for all the frames
117
+ * default is jsv-image
118
+ */
119
+ mainImageId?: string;
120
+
121
+ /**
122
+ * ID of the div where the presentation runs in
123
+ * Default is jsv-holder
124
+ */
125
+ mainHolderId?: string;
126
+
127
+ /**
128
+ * URl of the first image, doesn't have to be in the document.
129
+ * Default is empty
130
+ */
131
+ mainImageUrl?: string;
132
+
133
+ /**
134
+ * Amount of frames in the presentation, more images means smoother rotations
135
+ * but also more heavier for the browser
136
+ * default is 72
137
+ */
138
+ totalFrames?: number;
139
+
140
+ /**
141
+ * After loading the presentation this is the first frame visible
142
+ * Default is 1
143
+ */
144
+ firstImageNumber?: number;
145
+
146
+ /**
147
+ * Invert the rotation direction when dragging
148
+ * Default is false
149
+ */
150
+ reverse?: boolean;
151
+
152
+ /**
153
+ * Speed of rotating -199 to 100
154
+ * Default is 80
155
+ */
156
+ speed?: number;
157
+
158
+ /**
159
+ * Delay when stop dragging
160
+ * Default is 20
161
+ */
162
+ inertia?: number;
163
+
164
+ /**
165
+ * Disable the build in progress bar, use this when you have
166
+ * implemented your own loader or don't like this one.
167
+ * Default is true
168
+ */
169
+ defaultProgressBar?: boolean;
170
+
171
+ /**
172
+ * Change the color of the progress bar, can be hex of rgb
173
+ * Default is rgb(0, 0, 0)
174
+ */
175
+ defaultProgressBarColor?: string;
176
+
177
+ /**
178
+ * Change the background color of the progress bar, can be hex or rgb
179
+ * Default is rgba(255, 255, 255, 0.5)
180
+ */
181
+ defaultProgressBarBackgroundColor?: string;
182
+
183
+ /**
184
+ * Change the height of the progress bar, can be any css value for height
185
+ * Default is '5px'
186
+ */
187
+ defaultProgressBarHeight?: string;
188
+
189
+ /**
190
+ * Format for determining the filenames of the frames
191
+ * {filename}_xx.{extension} is the default
192
+ * ipod_x.jpg => ipod_1.jpg
193
+ * ipod_xx.jpg => ipod_01.jpg
194
+ * https://other.cdn/images/ipod_xx.jpg => https://other.cdn/images/ipod_01.jpg
195
+ */
196
+ imageUrlFormat?: string;
197
+
198
+ /**
199
+ * Load all image urls into the viewer. Total frames will be overwritten
200
+ */
201
+ imageUrls?: string[];
202
+
203
+ /**
204
+ * Add a class to all the images used in the presentation, separate multiple classes with a space.
205
+ * Default is empty
206
+ */
207
+ extraImageClass?: string;
208
+
209
+ /**
210
+ * Use this setting in combination with imageUrlFormat.
211
+ * startFrameNo: 4 => first file is ipod_04.jpg
212
+ * Default is 1
213
+ */
214
+ startFrameNo?: number;
215
+
216
+ /**
217
+ * Use this setting for rotating the view at start. Rotation stops when user drags the model
218
+ * or another animation method is called
219
+ * startRotation: 0 => No Rotation, 1 => Rotate once, 2 => Rotate twice
220
+ * Default is 0
221
+ */
222
+ autoRotate?: number;
223
+
224
+ /**
225
+ * Use this setting for changing the speed of the auto rotating. -199 to 100
226
+ * Default is speed of viewer
227
+ */
228
+ autoRotateSpeed?: number;
229
+
230
+ /**
231
+ * Use this setting for changing the direction of the auto rotating.
232
+ * Default is false
233
+ */
234
+ autoRotateReverse?: boolean;
235
+
236
+ /**
237
+ * Use this setting for enabling click and pinch events on images
238
+ * Default is false
239
+ */
240
+ enableImageEvents?: boolean;
241
+
242
+ /**
243
+ * Fires changeImage event in rotation. Keep track what your user is watching.
244
+ * Could be CPU heavy
245
+ * Default is false
246
+ */
247
+ enableChangeImageEvent?: boolean;
248
+
249
+ /**
250
+ * Use this setting for enabling zoom functions.
251
+ * Default is false
252
+ */
253
+ zoom?: boolean;
254
+
255
+ /**
256
+ * If zoom is enabled this is the max zoom factor.
257
+ * Default is 2
258
+ */
259
+ zoomMax?: number;
260
+
261
+ /**
262
+ * Change the speed of zooming with the mousewheel.
263
+ * Default is 50
264
+ */
265
+ zoomWheelSpeed?: number;
266
+
267
+ /**
268
+ * Blocks repeating images after reaching last image.
269
+ * Default is false
270
+ */
271
+ stopAtEdges?: boolean;
272
+
273
+ /**
274
+ * Change the cursors for the presentation
275
+ */
276
+ cursorConfig?: ICursorConfig;
277
+
278
+ /**
279
+ * Configure the notifications
280
+ */
281
+ notificationConfig?: INotificationConfig;
282
+
283
+ /**
284
+ * Set the query params height and width for use with an image resizer.
285
+ */
286
+ autoCDNResizer?: boolean;
287
+
288
+ /**
289
+ * Configure the image resizer
290
+ */
291
+ autoCDNResizerConfig?: IAutoCDNResizerConfig;
292
+
293
+ /**
294
+ * License to remove powered by logo
295
+ * Default is empty
296
+ */
297
+ license?: string;
280
298
  }
281
299
 
282
300
  /**
283
301
  * Object for getting the loading progress
284
302
  */
285
303
  export interface IProgress {
286
- totalImages: number;
287
- currentImage: number;
288
- percentage: number;
289
- image: IImage;
304
+ totalImages: number;
305
+ currentImage: number;
306
+ percentage: number;
307
+ image: IImage;
290
308
  }
291
309
 
292
310
  export interface IHandle {
293
- invocations: number;
311
+ invocations: number;
294
312
  }
295
313
 
296
314
  export interface IEvents {
297
- loadImage: Slot<IProgress>;
298
- started: Slot<boolean>;
299
- startDragging: Slot<IHandle>;
300
- changeImage: Slot<IStatus>;
301
- endAutoRotate: Slot<IStatus>;
302
- click: Slot<IClick>;
303
- pinch: Slot<IPinch>;
304
- scroll: Slot<IScroll>;
305
- doubleClick: Slot<IClick>;
315
+ loadImage: Slot<IProgress>;
316
+ started: Slot<boolean>;
317
+ startDragging: Slot<IHandle>;
318
+ changeImage: Slot<IStatus>;
319
+ endAutoRotate: Slot<IStatus>;
320
+ click: Slot<IClick>;
321
+ pinch: Slot<IPinch>;
322
+ scroll: Slot<IScroll>;
323
+ doubleClick: Slot<IClick>;
306
324
  }
307
325
 
308
326
  export interface IImage {
309
- id: string;
310
- src: string;
311
- sequence: number
327
+ id: string;
328
+ src: string;
329
+ sequence: number;
312
330
  }
313
331
 
314
332
  export interface IStatus {
315
- currentDegree: number;
316
- currentImage: IImage;
317
- completed: boolean;
333
+ currentDegree: number;
334
+ currentImage: IImage;
335
+ completed: boolean;
318
336
  }
319
337
 
320
338
  export interface IClick extends IStatus {
321
- originalEvent: TouchEvent | MouseEvent
339
+ originalEvent: TouchEvent | MouseEvent;
322
340
  }
323
341
 
324
342
  export interface IPinch extends IStatus {
325
- originalEvent: TouchEvent,
326
- scale: number
343
+ originalEvent: TouchEvent,
344
+ scale: number
327
345
  }
328
346
 
329
347
  export interface IScroll extends IStatus {
330
- originalEvent: Event
348
+ originalEvent: Event;
331
349
  }
332
350
 
333
351
  interface ICursorConfig {
334
- default: string,
335
- drag: string,
336
- zoomIn: string,
337
- zoomOut: string,
338
- pan: string
352
+ default: string,
353
+ drag: string,
354
+ zoomIn: string,
355
+ zoomOut: string,
356
+ pan: string
339
357
  }
340
358
 
341
359
  interface INotificationConfig {
342
- dragToRotate: {
343
- showStartToRotateDefaultNotification?: boolean,
344
- languages?: ITranslation[],
345
- imageUrl?: string,
346
- mainColor?: string,
347
- textColor?: string
348
- }
360
+ dragToRotate: {
361
+
362
+ /**
363
+ * If you want to show a custom image as notification
364
+ */
365
+ imageUrl?: string,
366
+
367
+ /**
368
+ * Show the default notification when starting to rotate
369
+ * Default is true
370
+ */
371
+ showStartToRotateDefaultNotification?: boolean,
372
+
373
+ /**
374
+ * Override the default text for the notification for any language
375
+ */
376
+ languages?: ITranslation[],
377
+
378
+ /**
379
+ * Set the background color for the notification, hex or rgba
380
+ * Default is rgba(0,0,0,0.20)
381
+ */
382
+ mainColor?: string,
383
+
384
+ /**
385
+ * Set the text color for the notification, hex or rgba
386
+ * Default is rgba(243,237,237,0.80)
387
+ */
388
+ textColor?: string
389
+ };
349
390
  }
350
391
 
351
- interface ITranslation{
352
- language: string;
353
- text: string
392
+ interface ITranslation {
393
+ language: string;
394
+ text: string;
354
395
  }
355
396
 
356
397
  interface IAutoCDNResizerConfig {
357
- useWidth?: boolean,
358
- useHeight?: boolean,
359
- scaleWithZoomMax?: boolean,
398
+ useWidth?: boolean,
399
+ useHeight?: boolean,
400
+ scaleWithZoomMax?: boolean,
360
401
  }