@inweb/viewer-core 27.5.0 → 27.6.0

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,9 +1,9 @@
1
- import { EventEmitter2 } from "@inweb/eventemitter2";
1
+ import { IEventEmitter } from "@inweb/eventemitter2";
2
2
  import { CameraMode, IOptions, RGB } from "./IOptions";
3
3
  export declare class Options implements IOptions {
4
- protected _emitter?: EventEmitter2;
4
+ protected _emitter?: IEventEmitter;
5
5
  protected _data: IOptions;
6
- constructor(emitter?: EventEmitter2);
6
+ constructor(emitter?: IEventEmitter);
7
7
  static defaults(): IOptions;
8
8
  change(): void;
9
9
  saveToStorage(): void;
@@ -14,8 +14,9 @@ export declare class Options implements IOptions {
14
14
  * @param fields - Name of fields to be reset. Specify `undefined` to reset all.
15
15
  */
16
16
  resetToDefaults(fields?: string[]): void;
17
+ setProperty<K extends keyof IOptions>(key: K, value?: IOptions[K]): void;
17
18
  get data(): IOptions;
18
- set data(value: IOptions);
19
+ set data(value: Partial<IOptions>);
19
20
  get showWCS(): boolean;
20
21
  set showWCS(value: boolean);
21
22
  get cameraAnimation(): boolean;
@@ -126,8 +127,12 @@ export declare class Options implements IOptions {
126
127
  set geometryType(value: string);
127
128
  get rulerUnit(): string;
128
129
  set rulerUnit(value: string);
129
- get rulerPrecision(): any;
130
- set rulerPrecision(value: any);
130
+ get rulerPrecision(): "Default" | "Auto" | number;
131
+ set rulerPrecision(value: "Default" | "Auto" | number);
131
132
  get cameraMode(): CameraMode;
132
133
  set cameraMode(value: CameraMode);
134
+ get snapshotMimeType(): string;
135
+ set snapshotMimeType(value: string);
136
+ get snapshotQuality(): number;
137
+ set snapshotQuality(value: number);
133
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-core",
3
- "version": "27.5.0",
3
+ "version": "27.6.0",
4
4
  "description": "3D CAD and BIM data Viewer core",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -26,7 +26,7 @@
26
26
  "test": "karma start karma.conf.js"
27
27
  },
28
28
  "dependencies": {
29
- "@inweb/client": "~27.5.0",
30
- "@inweb/eventemitter2": "~27.5.0"
29
+ "@inweb/client": "~27.6.0",
30
+ "@inweb/eventemitter2": "~27.6.0"
31
31
  }
32
32
  }
@@ -28,8 +28,7 @@ export class Loader implements ILoader {
28
28
  public abortController: AbortController = new AbortController();
29
29
 
30
30
  dispose(): void {
31
- this.abortController.abort();
32
- this.abortController = undefined;
31
+ this.cancel();
33
32
  }
34
33
 
35
34
  isSupport(file: FileSource, format?: string): boolean {
@@ -53,9 +52,9 @@ export class Loader implements ILoader {
53
52
  extractFileName(file: FileSource): string {
54
53
  const regex = /[^/\\?#:]+(?=\?|#|$)/;
55
54
 
56
- if (typeof file === "string") return (file.match(regex) || [])[0];
57
- else if (file instanceof globalThis.File) return (file.name.match(regex) || [])[0];
55
+ if (typeof file === "string") return (file.match(regex) || [])[0] || "";
56
+ else if (file instanceof globalThis.File) return (file.name.match(regex) || [])[0] || "";
58
57
 
59
- return undefined;
58
+ return "";
60
59
  }
61
60
  }
@@ -42,7 +42,7 @@ class Loaders implements ILoadersRegistry {
42
42
  }
43
43
 
44
44
  createLoader(viewer: IViewer, file: FileSource, format?: string): ILoader | null {
45
- let result: ILoader = null;
45
+ let result: ILoader | null = null;
46
46
  this._providers.forEach((provider, key) => {
47
47
  const loader = provider(viewer);
48
48
  if (loader.isSupport(file, format)) {
@@ -38,14 +38,14 @@ export interface IOptions {
38
38
  *
39
39
  * @defaultValue true
40
40
  */
41
- showWCS?: boolean;
41
+ showWCS: boolean;
42
42
 
43
43
  /**
44
44
  * Enable camera animation.
45
45
  *
46
46
  * @defaultValue true
47
47
  */
48
- cameraAnimation?: boolean;
48
+ cameraAnimation: boolean;
49
49
 
50
50
  /**
51
51
  * Enable anti-aliasing. Can be one of:
@@ -58,42 +58,42 @@ export interface IOptions {
58
58
  *
59
59
  * @defaultValue true
60
60
  */
61
- antialiasing?: boolean | string;
61
+ antialiasing: boolean | string;
62
62
 
63
63
  /**
64
64
  * Show ground shadows below the model.
65
65
  *
66
66
  * @defaultValue false
67
67
  */
68
- groundShadow?: boolean;
68
+ groundShadow: boolean;
69
69
 
70
70
  /**
71
71
  * Enable ambient shadows.
72
72
  *
73
73
  * @defaultValue false
74
74
  */
75
- shadows?: boolean;
75
+ shadows: boolean;
76
76
 
77
77
  /**
78
78
  * Camera speed on X axis.
79
79
  *
80
80
  * @defaultValue 4
81
81
  */
82
- cameraAxisXSpeed?: number;
82
+ cameraAxisXSpeed: number;
83
83
 
84
84
  /**
85
85
  * Camera speed on Y axis.
86
86
  *
87
87
  * @defaultValue 1
88
88
  */
89
- cameraAxisYSpeed?: number;
89
+ cameraAxisYSpeed: number;
90
90
 
91
91
  /**
92
92
  * Enable ambient occlusion.
93
93
  *
94
94
  * @defaultValue false
95
95
  */
96
- ambientOcclusion?: boolean;
96
+ ambientOcclusion: boolean;
97
97
 
98
98
  /**
99
99
  * Enable streaming of drawings from the Open Cloud Server.
@@ -105,7 +105,7 @@ export interface IOptions {
105
105
  *
106
106
  * @defaultValue true
107
107
  */
108
- enableStreamingMode?: boolean;
108
+ enableStreamingMode: boolean;
109
109
 
110
110
  /**
111
111
  * Enable partial streaming mode to be able open large drawing.
@@ -118,21 +118,21 @@ export interface IOptions {
118
118
  *
119
119
  * @defaultValue false
120
120
  */
121
- enablePartialMode?: boolean;
121
+ enablePartialMode: boolean;
122
122
 
123
123
  /**
124
124
  * The size of the memory buffer for graphics data, in bytes.
125
125
  *
126
126
  * @defaultValue 3294967296
127
127
  */
128
- memoryLimit?: number;
128
+ memoryLimit: number;
129
129
 
130
130
  /**
131
131
  * Deprecated since `27.5`. Use {@link sectionFillColor} instead.
132
132
  *
133
133
  * @deprecated
134
134
  */
135
- cuttingPlaneFillColor?: RGB;
135
+ cuttingPlaneFillColor: RGB;
136
136
 
137
137
  /**
138
138
  * Show solid fill on section caps.
@@ -141,14 +141,14 @@ export interface IOptions {
141
141
  *
142
142
  * @defaultValue true
143
143
  */
144
- enableSectionFill?: boolean;
144
+ enableSectionFill: boolean;
145
145
 
146
146
  /**
147
147
  * Section cap fill color.
148
148
  *
149
149
  * @defaultValue { red: 0xff, green: 0x98, blue: 0x00 }
150
150
  */
151
- sectionFillColor?: { r: number; g: number; b: number };
151
+ sectionFillColor: { r: number; g: number; b: number };
152
152
 
153
153
  /**
154
154
  * Use the intersected object's color for the section cap fill.
@@ -158,21 +158,21 @@ export interface IOptions {
158
158
  *
159
159
  * @defaultValue false
160
160
  */
161
- sectionUseObjectColor?: boolean;
161
+ sectionUseObjectColor: boolean;
162
162
 
163
163
  /**
164
164
  * Overlay a hatch pattern on top of the section fill.
165
165
  *
166
166
  * @defaultValue true
167
167
  */
168
- enableSectionHatch?: boolean;
168
+ enableSectionHatch: boolean;
169
169
 
170
170
  /**
171
171
  * Hatch line color used on top of the section fill.
172
172
  *
173
173
  * @defaultValue { red: 0x4b, green: 0x4c, blue: 0x35 }
174
174
  */
175
- sectionHatchColor?: { r: number; g: number; b: number };
175
+ sectionHatchColor: { r: number; g: number; b: number };
176
176
 
177
177
  /**
178
178
  * Distance between hatch lines, in screen-space pixels.
@@ -181,63 +181,63 @@ export interface IOptions {
181
181
  *
182
182
  * @defaultValue 8
183
183
  */
184
- sectionHatchScale?: number;
184
+ sectionHatchScale: number;
185
185
 
186
186
  /**
187
187
  * Draw the outline contour along the section boundary.
188
188
  *
189
189
  * @defaultValue true
190
190
  */
191
- enableSectionOutline?: boolean;
191
+ enableSectionOutline: boolean;
192
192
 
193
193
  /**
194
194
  * Color of the section outline contour.
195
195
  *
196
196
  * @defaultValue { red: 0, green: 0, blue: 0 }
197
197
  */
198
- sectionOutlineColor?: { r: number; g: number; b: number };
198
+ sectionOutlineColor: { r: number; g: number; b: number };
199
199
 
200
200
  /**
201
201
  * Width of the section outline contour, in pixels.
202
202
  *
203
203
  * @defaultValue 2
204
204
  */
205
- sectionOutlineWidth?: number;
205
+ sectionOutlineWidth: number;
206
206
 
207
207
  /**
208
208
  * Edges highlight color.
209
209
  */
210
- edgesColor?: { r: number; g: number; b: number };
210
+ edgesColor: { r: number; g: number; b: number };
211
211
 
212
212
  /**
213
213
  * Faces highlight color.
214
214
  */
215
- facesColor?: { r: number; g: number; b: number };
215
+ facesColor: { r: number; g: number; b: number };
216
216
 
217
217
  /**
218
218
  * Show highlighted edges.
219
219
  */
220
- edgesVisibility?: boolean;
220
+ edgesVisibility: boolean;
221
221
 
222
222
  /**
223
223
  * Show highlighted edges over drawing.
224
224
  */
225
- edgesOverlap?: boolean;
225
+ edgesOverlap: boolean;
226
226
 
227
227
  /**
228
228
  * Show highlighted faces over drawing.
229
229
  */
230
- facesOverlap?: boolean;
230
+ facesOverlap: boolean;
231
231
 
232
232
  /**
233
233
  * Highlighted faces transparency value, from 0 to 255.
234
234
  */
235
- facesTransparancy?: number;
235
+ facesTransparancy: number;
236
236
 
237
237
  /**
238
238
  * Enable custom highlight settings.
239
239
  */
240
- enableCustomHighlight?: boolean;
240
+ enableCustomHighlight: boolean;
241
241
 
242
242
  /**
243
243
  * Enable scene graph.
@@ -282,7 +282,7 @@ export interface IOptions {
282
282
  * - `vsfx` - `VSFX` (default), for opening a file in `VisualizeJS` viewer.
283
283
  * - `gltf` - `glTF`, for opening a file in `Three.js` viewer.
284
284
  */
285
- geometryType?: string;
285
+ geometryType: string;
286
286
 
287
287
  /**
288
288
  * Unit of measurement for the ruler tool (distance measurements).
@@ -307,7 +307,7 @@ export interface IOptions {
307
307
  *
308
308
  * @defaultValue "Default"
309
309
  */
310
- rulerUnit?: string;
310
+ rulerUnit: string;
311
311
 
312
312
  /**
313
313
  * Number of decimal places to display in ruler measurements.
@@ -323,7 +323,7 @@ export interface IOptions {
323
323
  *
324
324
  * @defaultValue 2
325
325
  */
326
- rulerPrecision?: any;
326
+ rulerPrecision: "Default" | "Auto" | number;
327
327
 
328
328
  /**
329
329
  * Camera projection mode:
@@ -333,7 +333,7 @@ export interface IOptions {
333
333
  *
334
334
  * @defaultValue "perspective"
335
335
  */
336
- cameraMode?: CameraMode;
336
+ cameraMode: CameraMode;
337
337
 
338
338
  /**
339
339
  * Default MIME type for snapshot images.
@@ -346,7 +346,7 @@ export interface IOptions {
346
346
  *
347
347
  * @defaultValue "image/jpeg"
348
348
  */
349
- snapshotMimeType?: string;
349
+ snapshotMimeType: string;
350
350
 
351
351
  /**
352
352
  * Default quality level for snapshot images when using lossy formats (JPEG, WebP).
@@ -361,14 +361,7 @@ export interface IOptions {
361
361
  *
362
362
  * @defaultValue 0.25
363
363
  */
364
- snapshotQuality?: number;
365
-
366
- /**
367
- * Resets options to default values.
368
- *
369
- * @param fields - Name of fields to be reset.
370
- */
371
- resetToDefaults?: (fields?: string[]) => void;
364
+ snapshotQuality: number;
372
365
  }
373
366
 
374
367
  export function defaultOptions(): IOptions {