@inweb/viewer-visualize 25.3.18 → 25.3.19

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.
@@ -65,54 +65,62 @@
65
65
 
66
66
  commands("ThreeJS").registerCommand("noop", (() => {}));
67
67
 
68
+ function defaultOptions() {
69
+ return {
70
+ showWCS: true,
71
+ cameraAnimation: true,
72
+ antialiasing: true,
73
+ groundShadow: false,
74
+ shadows: false,
75
+ cameraAxisXSpeed: 4,
76
+ cameraAxisYSpeed: 1,
77
+ ambientOcclusion: false,
78
+ enableStreamingMode: true,
79
+ enablePartialMode: false,
80
+ memoryLimit: 3294967296,
81
+ cuttingPlaneFillColor: {
82
+ red: 255,
83
+ green: 152,
84
+ blue: 0
85
+ },
86
+ edgesColor: {
87
+ r: 255,
88
+ g: 152,
89
+ b: 0
90
+ },
91
+ facesColor: {
92
+ r: 255,
93
+ g: 152,
94
+ b: 0
95
+ },
96
+ edgesVisibility: true,
97
+ edgesOverlap: true,
98
+ facesOverlap: false,
99
+ facesTransparancy: 200,
100
+ enableCustomHighlight: true,
101
+ sceneGraph: false,
102
+ edgeModel: true,
103
+ reverseZoomWheel: false,
104
+ enableZoomWheel: true,
105
+ enableGestures: true,
106
+ geometryType: "vsfx"
107
+ };
108
+ }
109
+
68
110
  class Options {
69
111
  constructor(emitter) {
70
112
  this._emitter = emitter;
71
- this._data = Options.defaults();
113
+ this._data = defaultOptions();
72
114
  this.loadFromStorage();
73
115
  }
74
116
  static defaults() {
75
- return {
76
- showWCS: true,
77
- cameraAnimation: true,
78
- antialiasing: true,
79
- groundShadow: false,
80
- shadows: false,
81
- cameraAxisXSpeed: 4,
82
- cameraAxisYSpeed: 1,
83
- ambientOcclusion: false,
84
- enableStreamingMode: true,
85
- enablePartialMode: false,
86
- memoryLimit: 3294967296,
87
- cuttingPlaneFillColor: {
88
- red: 255,
89
- green: 152,
90
- blue: 0
91
- },
92
- edgesColor: {
93
- r: 255,
94
- g: 152,
95
- b: 0
96
- },
97
- facesColor: {
98
- r: 255,
99
- g: 152,
100
- b: 0
101
- },
102
- edgesVisibility: true,
103
- edgesOverlap: true,
104
- facesOverlap: false,
105
- facesTransparancy: 200,
106
- enableCustomHighlight: true,
107
- sceneGraph: false,
108
- edgeModel: true,
109
- reverseZoomWheel: false,
110
- enableZoomWheel: true,
111
- enableGestures: true,
112
- geometryType: "vsfx"
113
- };
117
+ return defaultOptions();
114
118
  }
115
119
  notifierChangeEvent() {
120
+ console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead.");
121
+ this.change();
122
+ }
123
+ change() {
116
124
  if (this._emitter !== undefined) {
117
125
  this.saveToStorage();
118
126
  this._emitter.emit({
@@ -163,151 +171,154 @@
163
171
  return this._data;
164
172
  }
165
173
  set data(value) {
166
- const sceneGraph = value.enablePartialMode ? false : value.sceneGraph;
174
+ const enablePartialMode = value.enableStreamingMode ? value.enablePartialMode : false;
175
+ const sceneGraph = enablePartialMode ? false : value.sceneGraph;
167
176
  this._data = {
168
177
  ...Options.defaults(),
169
178
  ...this._data,
170
179
  ...value,
180
+ enablePartialMode: enablePartialMode,
171
181
  sceneGraph: sceneGraph
172
182
  };
173
- this.notifierChangeEvent();
183
+ this.change();
174
184
  }
175
185
  get showWCS() {
176
186
  return this._data.showWCS;
177
187
  }
178
188
  set showWCS(value) {
179
189
  this._data.showWCS = value;
180
- this.notifierChangeEvent();
190
+ this.change();
181
191
  }
182
192
  get cameraAnimation() {
183
193
  return this._data.cameraAnimation;
184
194
  }
185
195
  set cameraAnimation(value) {
186
196
  this._data.cameraAnimation = value;
187
- this.notifierChangeEvent();
197
+ this.change();
188
198
  }
189
199
  get antialiasing() {
190
200
  return this._data.antialiasing;
191
201
  }
192
202
  set antialiasing(value) {
193
203
  this._data.antialiasing = value;
194
- this.notifierChangeEvent();
204
+ this.change();
195
205
  }
196
206
  get groundShadow() {
197
207
  return this._data.groundShadow;
198
208
  }
199
209
  set groundShadow(value) {
200
210
  this._data.groundShadow = value;
201
- this.notifierChangeEvent();
211
+ this.change();
202
212
  }
203
213
  get shadows() {
204
214
  return this._data.shadows;
205
215
  }
206
216
  set shadows(value) {
207
217
  this._data.shadows = value;
208
- this.notifierChangeEvent();
218
+ this.change();
209
219
  }
210
220
  get cameraAxisXSpeed() {
211
221
  return this._data.cameraAxisXSpeed;
212
222
  }
213
223
  set cameraAxisXSpeed(value) {
214
224
  this._data.cameraAxisXSpeed = value;
215
- this.notifierChangeEvent();
225
+ this.change();
216
226
  }
217
227
  get cameraAxisYSpeed() {
218
228
  return this._data.cameraAxisYSpeed;
219
229
  }
220
230
  set cameraAxisYSpeed(value) {
221
231
  this.cameraAxisYSpeed = value;
222
- this.notifierChangeEvent();
232
+ this.change();
223
233
  }
224
234
  get ambientOcclusion() {
225
235
  return this._data.ambientOcclusion;
226
236
  }
227
237
  set ambientOcclusion(value) {
228
238
  this._data.ambientOcclusion = value;
229
- this.notifierChangeEvent();
239
+ this.change();
230
240
  }
231
241
  get enableStreamingMode() {
232
242
  return this._data.enableStreamingMode;
233
243
  }
234
244
  set enableStreamingMode(value) {
235
245
  this._data.enableStreamingMode = value;
236
- if (this._data.enableStreamingMode) {
237
- this._data.enablePartialMode = false;
238
- }
239
- this.notifierChangeEvent();
246
+ if (!value) this._data.enablePartialMode = false;
247
+ this.change();
240
248
  }
241
249
  get enablePartialMode() {
242
250
  return this._data.enablePartialMode;
243
251
  }
244
252
  set enablePartialMode(value) {
245
253
  this._data.enablePartialMode = value;
246
- if (value) this._data.sceneGraph = false;
247
- this.notifierChangeEvent();
254
+ if (value) {
255
+ this._data.enableStreamingMode = true;
256
+ this._data.sceneGraph = false;
257
+ }
258
+ this.change();
248
259
  }
249
260
  get memoryLimit() {
250
261
  return this._data.memoryLimit;
251
262
  }
252
263
  set memoryLimit(value) {
253
264
  this._data.memoryLimit = value;
254
- this.notifierChangeEvent();
265
+ this.change();
255
266
  }
256
267
  get cuttingPlaneFillColor() {
257
268
  return this._data.cuttingPlaneFillColor;
258
269
  }
259
270
  set cuttingPlaneFillColor(value) {
260
271
  this._data.cuttingPlaneFillColor = value;
261
- this.notifierChangeEvent();
272
+ this.change();
262
273
  }
263
274
  get edgesColor() {
264
275
  return this._data.edgesColor;
265
276
  }
266
277
  set edgesColor(value) {
267
278
  this._data.edgesColor = value;
268
- this.notifierChangeEvent();
279
+ this.change();
269
280
  }
270
281
  get facesColor() {
271
282
  return this._data.facesColor;
272
283
  }
273
284
  set facesColor(value) {
274
285
  this._data.facesColor = value;
275
- this.notifierChangeEvent();
286
+ this.change();
276
287
  }
277
288
  get edgesVisibility() {
278
289
  return this._data.edgesVisibility;
279
290
  }
280
291
  set edgesVisibility(value) {
281
292
  this._data.edgesVisibility = value;
282
- this.notifierChangeEvent();
293
+ this.change();
283
294
  }
284
295
  get edgesOverlap() {
285
296
  return this._data.edgesOverlap;
286
297
  }
287
298
  set edgesOverlap(value) {
288
299
  this._data.edgesOverlap = value;
289
- this.notifierChangeEvent();
300
+ this.change();
290
301
  }
291
302
  get facesOverlap() {
292
303
  return this._data.facesOverlap;
293
304
  }
294
305
  set facesOverlap(value) {
295
306
  this._data.facesOverlap = value;
296
- this.notifierChangeEvent();
307
+ this.change();
297
308
  }
298
309
  get facesTransparancy() {
299
310
  return this._data.facesTransparancy;
300
311
  }
301
312
  set facesTransparancy(value) {
302
313
  this._data.facesTransparancy = value;
303
- this.notifierChangeEvent();
314
+ this.change();
304
315
  }
305
316
  get enableCustomHighlight() {
306
317
  return this._data.enableCustomHighlight;
307
318
  }
308
319
  set enableCustomHighlight(value) {
309
320
  this._data.enableCustomHighlight = value;
310
- this.notifierChangeEvent();
321
+ this.change();
311
322
  }
312
323
  get sceneGraph() {
313
324
  return this._data.sceneGraph;
@@ -315,42 +326,42 @@
315
326
  set sceneGraph(value) {
316
327
  this._data.sceneGraph = value;
317
328
  if (value) this._data.enablePartialMode = false;
318
- this.notifierChangeEvent();
329
+ this.change();
319
330
  }
320
331
  get edgeModel() {
321
332
  return Boolean(this._data.edgeModel);
322
333
  }
323
334
  set edgeModel(value) {
324
335
  this._data.edgeModel = Boolean(value);
325
- this.notifierChangeEvent();
336
+ this.change();
326
337
  }
327
338
  get reverseZoomWheel() {
328
339
  return this._data.reverseZoomWheel;
329
340
  }
330
341
  set reverseZoomWheel(value) {
331
342
  this._data.reverseZoomWheel = !!value;
332
- this.notifierChangeEvent();
343
+ this.change();
333
344
  }
334
345
  get enableZoomWheel() {
335
346
  return this._data.enableZoomWheel;
336
347
  }
337
348
  set enableZoomWheel(value) {
338
349
  this._data.enableZoomWheel = !!value;
339
- this.notifierChangeEvent();
350
+ this.change();
340
351
  }
341
352
  get enableGestures() {
342
353
  return this._data.enableGestures;
343
354
  }
344
355
  set enableGestures(value) {
345
356
  this._data.enableGestures = !!value;
346
- this.notifierChangeEvent();
357
+ this.change();
347
358
  }
348
359
  get geometryType() {
349
360
  return this._data.geometryType;
350
361
  }
351
362
  set geometryType(value) {
352
363
  this._data.geometryType = value;
353
- this.notifierChangeEvent();
364
+ this.change();
354
365
  }
355
366
  }
356
367
 
@@ -2855,14 +2866,12 @@
2855
2866
  }
2856
2867
  };
2857
2868
  const downloadResourceRange = async (dataId, requestId, ranges) => {
2858
- console.log("--- VsfXPartialLoader.downloadResourceRange", dataId, requestId, ranges);
2859
2869
  const abortCtrl = new AbortController();
2860
2870
  abortControllerForRequestMap.set(requestId, abortCtrl);
2861
2871
  try {
2862
2872
  await this.model.downloadResourceRange(dataId, ranges, requestId, chunkLoadHandler, abortCtrl.signal);
2863
2873
  }
2864
2874
  catch (error) {
2865
- console.log("--- VsfXPartialLoader.downloadResourceRange error", dataId, requestId, error);
2866
2875
  this.viewer.emitEvent({ type: "geometryerror", data: error, model: this.model });
2867
2876
  }
2868
2877
  finally {
@@ -2886,7 +2895,6 @@
2886
2895
  };
2887
2896
  const objectHandler = {
2888
2897
  onServicePartReceived: (bHasIndex) => {
2889
- console.log("--- VsfXPartialLoader.onServicePartReceived", bHasIndex);
2890
2898
  if (bHasIndex) {
2891
2899
  servicePartAborted = true;
2892
2900
  abortController.abort();
@@ -2894,28 +2902,23 @@
2894
2902
  },
2895
2903
  onRequest: (requestId, records) => {
2896
2904
  const ranges = requestRecordsToRanges(requestId, records);
2897
- console.log("--- VsfXPartialLoader.onRequest", this.model.database, requestId, ranges);
2898
2905
  downloadResourceRange(this.model.database, requestId, ranges);
2899
2906
  },
2900
2907
  onFullLoaded: () => {
2901
- console.log("--- VsfXPartialLoader.onFullLoaded");
2902
2908
  updaterController.update(UpdateType.kNormal);
2903
2909
  },
2904
2910
  onRequestResponseParsed: (requestId) => {
2905
- console.log("--- VsfXPartialLoader.onRequestResponseParsed", requestId);
2906
2911
  abortControllerForRequestMap.delete(requestId);
2907
2912
  updaterController.update(UpdateType.kNormal);
2908
2913
  },
2909
2914
  onRequestAborted: (requestId) => {
2910
- console.log("--- VsfXPartialLoader.onRequestAborted", requestId);
2911
2915
  const abortCtrl = abortControllerForRequestMap.get(requestId);
2912
2916
  if (abortCtrl)
2913
2917
  abortCtrl.abort();
2914
2918
  },
2915
- onRequestResourceFile: (requestId, dataId, records) => {
2916
- // const dataId = `${this.model.fileId}${this.model.file.type}`;
2919
+ onRequestResourceFile: (requestId, _, records) => {
2920
+ const dataId = `${this.model.fileId}${this.model.file.type}`;
2917
2921
  const ranges = requestRecordsToRanges(requestId, records);
2918
- console.log("--- VsfXPartialLoader.onRequestResourceFile", dataId, requestId, ranges);
2919
2922
  let pendingRanges = [];
2920
2923
  let requestNumber = 0;
2921
2924
  const pendingRequest = pendingRequestsMap.get(dataId);
@@ -2925,7 +2928,6 @@
2925
2928
  }
2926
2929
  // first several records of each file are processed without grouping (they usually require to be processed sequentially)
2927
2930
  if (requestNumber <= 5) {
2928
- console.log("--- VsfXPartialLoader.onRequestResourceFile: requestNumber <= 5");
2929
2931
  pendingRequestsMap.set(dataId, { ranges: [], number: requestNumber + 1 });
2930
2932
  downloadResourceRange(dataId, requestId, ranges);
2931
2933
  return;
@@ -2933,7 +2935,6 @@
2933
2935
  pendingRanges = pendingRanges.concat(ranges);
2934
2936
  // group requests to each file to launch a combined server request
2935
2937
  if (pendingRanges.length >= PENDING_REQUESTS_SIZE) {
2936
- console.log("--- VsfXPartialLoader.onRequestResourceFile: pendingRanges.length >", PENDING_REQUESTS_SIZE);
2937
2938
  if (pendingRequestsTimerId) {
2938
2939
  window.clearTimeout(pendingRequestsTimerId);
2939
2940
  pendingRequestsTimerId = 0;
@@ -2946,7 +2947,6 @@
2946
2947
  // set timeout to wait for the new requests, after that process the remaining requests
2947
2948
  if (pendingRequestsTimerId === 0) {
2948
2949
  pendingRequestsTimerId = window.setTimeout(() => {
2949
- console.log("--- VsfXPartialLoader.onRequestResourceFile: timer", PENDING_REQUESTS_SIZE);
2950
2950
  pendingRequestsAbortController.signal.removeEventListener("abort", pendingRequestsAbortHandler);
2951
2951
  pendingRequestsTimerId = 0;
2952
2952
  pendingRequestsMap.forEach((request, dataId) => {
@@ -16694,7 +16694,7 @@
16694
16694
  device.delete();
16695
16695
  return this;
16696
16696
  }
16697
- syncOptions(options = this.options.data) {
16697
+ syncOptions(options = this.options) {
16698
16698
  if (!this.visualizeJs)
16699
16699
  return this;
16700
16700
  const visLib = this.visLib();
@@ -16746,7 +16746,7 @@
16746
16746
  this.update();
16747
16747
  return this;
16748
16748
  }
16749
- syncHighlightingOptions(options = this.options.data) {
16749
+ syncHighlightingOptions(options = this.options) {
16750
16750
  if (!this.visualizeJs)
16751
16751
  return this;
16752
16752
  const params = options.enableCustomHighlight ? options : Options.defaults();
@@ -17038,7 +17038,7 @@
17038
17038
  overrideOptions.enablePartialMode = true;
17039
17039
  }
17040
17040
  const loaderFactory = new LoaderFactory();
17041
- const loader = loaderFactory.create(this, model, overrideOptions.data);
17041
+ const loader = loaderFactory.create(this, model, overrideOptions);
17042
17042
  await this.loadReferences(model);
17043
17043
  await loader.load();
17044
17044
  if (this.visualizeJs) {
@@ -17293,10 +17293,12 @@
17293
17293
  }
17294
17294
  }
17295
17295
 
17296
+ exports.CANVAS_EVENTS = CANVAS_EVENTS;
17296
17297
  exports.OdBaseDragger = OdBaseDragger;
17297
17298
  exports.Options = Options;
17298
17299
  exports.Viewer = Viewer;
17299
17300
  exports.commands = commands;
17301
+ exports.defaultOptions = defaultOptions;
17300
17302
 
17301
17303
  Object.defineProperty(exports, '__esModule', { value: true });
17302
17304