@inweb/viewer-core 27.4.7 → 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;
@@ -40,6 +41,48 @@ export declare class Options implements IOptions {
40
41
  set memoryLimit(value: number);
41
42
  get cuttingPlaneFillColor(): RGB;
42
43
  set cuttingPlaneFillColor(value: RGB);
44
+ get enableSectionFill(): boolean;
45
+ set enableSectionFill(value: boolean);
46
+ get sectionFillColor(): {
47
+ r: number;
48
+ g: number;
49
+ b: number;
50
+ };
51
+ set sectionFillColor(value: {
52
+ r: number;
53
+ g: number;
54
+ b: number;
55
+ });
56
+ get sectionUseObjectColor(): boolean;
57
+ set sectionUseObjectColor(value: boolean);
58
+ get enableSectionHatch(): boolean;
59
+ set enableSectionHatch(value: boolean);
60
+ get sectionHatchColor(): {
61
+ r: number;
62
+ g: number;
63
+ b: number;
64
+ };
65
+ set sectionHatchColor(value: {
66
+ r: number;
67
+ g: number;
68
+ b: number;
69
+ });
70
+ get sectionHatchScale(): number;
71
+ set sectionHatchScale(value: number);
72
+ get enableSectionOutline(): boolean;
73
+ set enableSectionOutline(value: boolean);
74
+ get sectionOutlineColor(): {
75
+ r: number;
76
+ g: number;
77
+ b: number;
78
+ };
79
+ set sectionOutlineColor(value: {
80
+ r: number;
81
+ g: number;
82
+ b: number;
83
+ });
84
+ get sectionOutlineWidth(): number;
85
+ set sectionOutlineWidth(value: number);
43
86
  get edgesColor(): {
44
87
  r: number;
45
88
  g: number;
@@ -84,8 +127,12 @@ export declare class Options implements IOptions {
84
127
  set geometryType(value: string);
85
128
  get rulerUnit(): string;
86
129
  set rulerUnit(value: string);
87
- get rulerPrecision(): any;
88
- set rulerPrecision(value: any);
130
+ get rulerPrecision(): "Default" | "Auto" | number;
131
+ set rulerPrecision(value: "Default" | "Auto" | number);
89
132
  get cameraMode(): CameraMode;
90
133
  set cameraMode(value: CameraMode);
134
+ get snapshotMimeType(): string;
135
+ set snapshotMimeType(value: string);
136
+ get snapshotQuality(): number;
137
+ set snapshotQuality(value: number);
91
138
  }
@@ -130,10 +130,12 @@ export interface IViewer extends IEventEmitter, ICommandService {
130
130
  * - {@link UpdateEvent | update}
131
131
  * - {@link RenderEvent | render}
132
132
  *
133
- * @param force - If `true` updates the viewer immidietly. Otherwise the update will be scheduled for
134
- * the next animation frame. Default is `false`.
133
+ * @param force - If `true` updates the viewer immidietly. If a `number` is specified and more than the
134
+ * given amount of milliseconds has elapsed since the last rendering, the update is performed
135
+ * immediately as well. Otherwise the update will be scheduled for the next animation frame. Default
136
+ * is `false`.
135
137
  */
136
- update(force?: boolean): void;
138
+ update(force?: boolean | number): void;
137
139
  /**
138
140
  * Loads a file into the viewer.
139
141
  *
@@ -171,7 +171,9 @@ export interface IText {
171
171
  */
172
172
  font_size?: number;
173
173
  /**
174
- * Deprecated. Use {@link font_size} instead.
174
+ * Deprecated since `25.3`. Use {@link font_size} instead.
175
+ *
176
+ * @deprecated
175
177
  */
176
178
  text_size?: number;
177
179
  /**
@@ -296,11 +298,15 @@ export interface IImage {
296
298
  */
297
299
  src: string;
298
300
  /**
299
- * Deprecated. Use {@link position2} instead. Width of the image.
301
+ * Deprecated since `26.5`. Use {@link position2} instead. Width of the image.
302
+ *
303
+ * @deprecated
300
304
  */
301
305
  width?: number;
302
306
  /**
303
- * Deprecated. Use {@link position2} instead. Height of the image.
307
+ * Deprecated since `26.5`. Use {@link position2} instead. Height of the image.
308
+ *
309
+ * @deprecated
304
310
  */
305
311
  height?: number;
306
312
  /**
@@ -321,11 +327,15 @@ export interface IRectangle {
321
327
  */
322
328
  position2: IPoint;
323
329
  /**
324
- * Deprecated. Use {@link position2} instead. Width of the rectangle.
330
+ * Deprecated since `26.5`. Use {@link position2} instead. Width of the rectangle.
331
+ *
332
+ * @deprecated
325
333
  */
326
334
  width?: number;
327
335
  /**
328
- * Deprecated. Use {@link position2} instead. Height of the rectangle.
336
+ * Deprecated since `26.5`. Use {@link position2} instead. Height of the rectangle.
337
+ *
338
+ * @deprecated
329
339
  */
330
340
  height?: number;
331
341
  /**
@@ -68,6 +68,19 @@ export interface ChangeCameraModeEvent {
68
68
  */
69
69
  mode: string;
70
70
  }
71
+ /**
72
+ * Event that fires when cutting planes (slices) have been changed.
73
+ *
74
+ * Fires when cutting planes are added, deleted, or transformed (moved/rotated).
75
+ *
76
+ * @event
77
+ */
78
+ export interface ChangeCuttingPlanesEvent {
79
+ /**
80
+ * Event type.
81
+ */
82
+ type: "changecuttingplanes";
83
+ }
71
84
  /**
72
85
  * Event that fires when the default color of new markup objects has been changed.
73
86
  *
@@ -691,6 +704,10 @@ export interface ViewerEventMap {
691
704
  * Event that fires when camera projection mode changes.
692
705
  */
693
706
  changecameramode: ChangeCameraModeEvent;
707
+ /**
708
+ * Event that fires when cutting planes (slices) have been changed.
709
+ */
710
+ changecuttingplanes: ChangeCuttingPlanesEvent;
694
711
  /**
695
712
  * Event that fires when the markup color has been changed.
696
713
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-core",
3
- "version": "27.4.7",
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.4.7",
30
- "@inweb/eventemitter2": "~27.4.7"
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,56 +118,126 @@ 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
- * Cutting planes fill color.
131
+ * Deprecated since `27.5`. Use {@link sectionFillColor} instead.
132
+ *
133
+ * @deprecated
134
+ */
135
+ cuttingPlaneFillColor: RGB;
136
+
137
+ /**
138
+ * Show solid fill on section caps.
139
+ *
140
+ * When disabled, neither the fill nor the hatch is drawn (the outline, if enabled, is still shown).
141
+ *
142
+ * @defaultValue true
143
+ */
144
+ enableSectionFill: boolean;
145
+
146
+ /**
147
+ * Section cap fill color.
132
148
  *
133
149
  * @defaultValue { red: 0xff, green: 0x98, blue: 0x00 }
134
150
  */
135
- cuttingPlaneFillColor?: RGB;
151
+ sectionFillColor: { r: number; g: number; b: number };
152
+
153
+ /**
154
+ * Use the intersected object's color for the section cap fill.
155
+ *
156
+ * When enabled, each section cap is filled with a color derived from the intersected object and
157
+ * `sectionFillColor` is ignored. The outline color is not affected.
158
+ *
159
+ * @defaultValue false
160
+ */
161
+ sectionUseObjectColor: boolean;
162
+
163
+ /**
164
+ * Overlay a hatch pattern on top of the section fill.
165
+ *
166
+ * @defaultValue true
167
+ */
168
+ enableSectionHatch: boolean;
169
+
170
+ /**
171
+ * Hatch line color used on top of the section fill.
172
+ *
173
+ * @defaultValue { red: 0x4b, green: 0x4c, blue: 0x35 }
174
+ */
175
+ sectionHatchColor: { r: number; g: number; b: number };
176
+
177
+ /**
178
+ * Distance between hatch lines, in screen-space pixels.
179
+ *
180
+ * Larger values produce sparser hatching.
181
+ *
182
+ * @defaultValue 8
183
+ */
184
+ sectionHatchScale: number;
185
+
186
+ /**
187
+ * Draw the outline contour along the section boundary.
188
+ *
189
+ * @defaultValue true
190
+ */
191
+ enableSectionOutline: boolean;
192
+
193
+ /**
194
+ * Color of the section outline contour.
195
+ *
196
+ * @defaultValue { red: 0, green: 0, blue: 0 }
197
+ */
198
+ sectionOutlineColor: { r: number; g: number; b: number };
199
+
200
+ /**
201
+ * Width of the section outline contour, in pixels.
202
+ *
203
+ * @defaultValue 2
204
+ */
205
+ sectionOutlineWidth: number;
136
206
 
137
207
  /**
138
208
  * Edges highlight color.
139
209
  */
140
- edgesColor?: { r: number; g: number; b: number };
210
+ edgesColor: { r: number; g: number; b: number };
141
211
 
142
212
  /**
143
213
  * Faces highlight color.
144
214
  */
145
- facesColor?: { r: number; g: number; b: number };
215
+ facesColor: { r: number; g: number; b: number };
146
216
 
147
217
  /**
148
218
  * Show highlighted edges.
149
219
  */
150
- edgesVisibility?: boolean;
220
+ edgesVisibility: boolean;
151
221
 
152
222
  /**
153
223
  * Show highlighted edges over drawing.
154
224
  */
155
- edgesOverlap?: boolean;
225
+ edgesOverlap: boolean;
156
226
 
157
227
  /**
158
228
  * Show highlighted faces over drawing.
159
229
  */
160
- facesOverlap?: boolean;
230
+ facesOverlap: boolean;
161
231
 
162
232
  /**
163
233
  * Highlighted faces transparency value, from 0 to 255.
164
234
  */
165
- facesTransparancy?: number;
235
+ facesTransparancy: number;
166
236
 
167
237
  /**
168
238
  * Enable custom highlight settings.
169
239
  */
170
- enableCustomHighlight?: boolean;
240
+ enableCustomHighlight: boolean;
171
241
 
172
242
  /**
173
243
  * Enable scene graph.
@@ -212,7 +282,7 @@ export interface IOptions {
212
282
  * - `vsfx` - `VSFX` (default), for opening a file in `VisualizeJS` viewer.
213
283
  * - `gltf` - `glTF`, for opening a file in `Three.js` viewer.
214
284
  */
215
- geometryType?: string;
285
+ geometryType: string;
216
286
 
217
287
  /**
218
288
  * Unit of measurement for the ruler tool (distance measurements).
@@ -237,7 +307,7 @@ export interface IOptions {
237
307
  *
238
308
  * @defaultValue "Default"
239
309
  */
240
- rulerUnit?: string;
310
+ rulerUnit: string;
241
311
 
242
312
  /**
243
313
  * Number of decimal places to display in ruler measurements.
@@ -253,7 +323,7 @@ export interface IOptions {
253
323
  *
254
324
  * @defaultValue 2
255
325
  */
256
- rulerPrecision?: any;
326
+ rulerPrecision: "Default" | "Auto" | number;
257
327
 
258
328
  /**
259
329
  * Camera projection mode:
@@ -263,7 +333,7 @@ export interface IOptions {
263
333
  *
264
334
  * @defaultValue "perspective"
265
335
  */
266
- cameraMode?: CameraMode;
336
+ cameraMode: CameraMode;
267
337
 
268
338
  /**
269
339
  * Default MIME type for snapshot images.
@@ -276,7 +346,7 @@ export interface IOptions {
276
346
  *
277
347
  * @defaultValue "image/jpeg"
278
348
  */
279
- snapshotMimeType?: string;
349
+ snapshotMimeType: string;
280
350
 
281
351
  /**
282
352
  * Default quality level for snapshot images when using lossy formats (JPEG, WebP).
@@ -291,14 +361,7 @@ export interface IOptions {
291
361
  *
292
362
  * @defaultValue 0.25
293
363
  */
294
- snapshotQuality?: number;
295
-
296
- /**
297
- * Resets options to default values.
298
- *
299
- * @param fields - Name of fields to be reset.
300
- */
301
- resetToDefaults?: (fields?: string[]) => void;
364
+ snapshotQuality: number;
302
365
  }
303
366
 
304
367
  export function defaultOptions(): IOptions {
@@ -315,6 +378,15 @@ export function defaultOptions(): IOptions {
315
378
  enablePartialMode: false,
316
379
  memoryLimit: 3294967296,
317
380
  cuttingPlaneFillColor: { red: 0xff, green: 0x98, blue: 0x00 },
381
+ enableSectionFill: true,
382
+ sectionFillColor: { r: 0xff, g: 0x98, b: 0x00 },
383
+ sectionUseObjectColor: false,
384
+ enableSectionHatch: true,
385
+ sectionHatchColor: { r: 0, g: 0, b: 0 },
386
+ sectionHatchScale: 8,
387
+ enableSectionOutline: true,
388
+ sectionOutlineColor: { r: 0, g: 0, b: 0 },
389
+ sectionOutlineWidth: 2,
318
390
  edgesColor: { r: 0xff, g: 0x98, b: 0x00 },
319
391
  facesColor: { r: 0xff, g: 0x98, b: 0x00 },
320
392
  edgesVisibility: true,