@inweb/viewer-visualize 27.5.0 → 27.6.1

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.
@@ -121,6 +121,7 @@ const INTERACTIVITY_FPS = 24;
121
121
  class OdBaseDragger extends OdaGeAction {
122
122
  constructor(subject) {
123
123
  super(subject.visualizeJs);
124
+ this.name = "";
124
125
  this.beginInteractivity = () => {
125
126
  const viewer = this.getViewer();
126
127
  const view = viewer.activeView;
@@ -147,6 +148,8 @@ class OdBaseDragger extends OdaGeAction {
147
148
  this.needInputText = false;
148
149
  this.mouseDownPosition = { x: 0, y: 0 };
149
150
  this.autoSelect = false;
151
+ this.isDragging = false;
152
+ this.press = false;
150
153
  this.pointerdown = this.pointerdown.bind(this);
151
154
  this.pointerup = this.pointerup.bind(this);
152
155
  this.pointercancel = this.pointercancel.bind(this);
@@ -2332,16 +2335,16 @@ class OdaLineDragger extends OdBaseDragger {
2332
2335
  constructor(subject) {
2333
2336
  super(subject);
2334
2337
  this.press = false;
2338
+ this.drawPoints = [];
2335
2339
  }
2336
2340
  dispose() {
2337
2341
  super.dispose();
2338
2342
  this.end();
2339
- this.points = null;
2340
- this.drawPoints = null;
2343
+ this.drawPoints.length = 0;
2341
2344
  }
2342
2345
  start(x, y) {
2343
2346
  const point = this.getViewer().screenToWorld(x, y);
2344
- this.drawPoints = [point[0], point[1], point[2]];
2347
+ this.drawPoints.push(point[0], point[1], point[2]);
2345
2348
  }
2346
2349
  drag(x, y) {
2347
2350
  if (this.isDragging) {
@@ -2353,7 +2356,7 @@ class OdaLineDragger extends OdBaseDragger {
2353
2356
  end() {
2354
2357
  if (this.entity) {
2355
2358
  this.entity.delete();
2356
- this.drawPoints = null;
2359
+ this.drawPoints.length = 0;
2357
2360
  this.entity = null;
2358
2361
  }
2359
2362
  }
@@ -3049,7 +3052,6 @@ class CanvasRemoveComponent {
3049
3052
  }
3050
3053
  dispose() {
3051
3054
  this.mutationObserver.disconnect();
3052
- this.mutationObserver = undefined;
3053
3055
  }
3054
3056
  }
3055
3057
 
@@ -3075,7 +3077,6 @@ class ZoomWheelComponent {
3075
3077
  }
3076
3078
  dispose() {
3077
3079
  this.zoomWheelDragger.dispose();
3078
- this.zoomWheelDragger = undefined;
3079
3080
  }
3080
3081
  }
3081
3082
 
@@ -3269,7 +3270,6 @@ class GestureManagerComponent {
3269
3270
  }
3270
3271
  dispose() {
3271
3272
  this.gestureManager.dispose();
3272
- this.gestureManager = undefined;
3273
3273
  }
3274
3274
  }
3275
3275
 
@@ -3332,6 +3332,9 @@ components.registerComponent("GestureManagerComponent", (viewer) => new GestureM
3332
3332
  components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
3333
3333
 
3334
3334
  class ModelImpl {
3335
+ constructor() {
3336
+ this.id = "";
3337
+ }
3335
3338
  dispose() { }
3336
3339
  }
3337
3340
 
@@ -3339,7 +3342,6 @@ class FileLoader {
3339
3342
  constructor() {
3340
3343
  this.requestHeader = {};
3341
3344
  this.withCredentials = false;
3342
- this.abortSignal = undefined;
3343
3345
  }
3344
3346
  setRequestHeader(requestHeader) {
3345
3347
  this.requestHeader = requestHeader;
@@ -3361,12 +3363,15 @@ class FileLoader {
3361
3363
  .then((response) => {
3362
3364
  if (!response.ok)
3363
3365
  throw new Error(`Failed to fetch "${response.url}", status ${response.status}`);
3366
+ const body = response.body;
3367
+ if (!body)
3368
+ return response;
3364
3369
  const contentLength = response.headers.get("X-File-Size") || response.headers.get("Content-Length");
3365
3370
  const total = parseInt(contentLength || "", 10) || 0;
3366
3371
  const lengthComputable = total > 0;
3367
3372
  const stream = new ReadableStream({
3368
3373
  async start(controller) {
3369
- const reader = response.body.getReader();
3374
+ const reader = body.getReader();
3370
3375
  let loaded = 0;
3371
3376
  try {
3372
3377
  while (true) {
@@ -3395,7 +3400,7 @@ class FileLoader {
3395
3400
  const reader = new FileReader();
3396
3401
  reader.onload = () => resolve(reader.result);
3397
3402
  reader.onerror = () => reject(reader.error);
3398
- reader.onprogress = onProgress;
3403
+ reader.onprogress = onProgress || null;
3399
3404
  reader.readAsArrayBuffer(new Blob([file]));
3400
3405
  });
3401
3406
  }
@@ -3414,7 +3419,7 @@ class VSFFileLoader extends Loader {
3414
3419
  super();
3415
3420
  this.viewer = viewer;
3416
3421
  }
3417
- isSupport(file, format) {
3422
+ isSupport(file, format = "") {
3418
3423
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3419
3424
  /vsf$/i.test(format));
3420
3425
  }
@@ -3509,7 +3514,7 @@ class VSFXFileLoader extends Loader {
3509
3514
  super();
3510
3515
  this.viewer = viewer;
3511
3516
  }
3512
- isSupport(file, format) {
3517
+ isSupport(file, format = "") {
3513
3518
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
3514
3519
  /vsfx$/i.test(format));
3515
3520
  }
@@ -3819,7 +3824,7 @@ function loadScript(url, params = {}) {
3819
3824
  const script = document.createElement("script");
3820
3825
  script.src = url;
3821
3826
  script.async = true;
3822
- script.crossOrigin = params.crossOrigin;
3827
+ script.crossOrigin = params.crossOrigin || null;
3823
3828
  script.onload = () => resolve(script);
3824
3829
  script.onerror = () => {
3825
3830
  script.remove();
@@ -3861,6 +3866,7 @@ class VisualizeMarkup {
3861
3866
  constructor() {
3862
3867
  this._markupColor = { r: 255, g: 0, b: 0 };
3863
3868
  this.lineWidth = 4;
3869
+ this.lineType = "solid";
3864
3870
  this.fontSize = 34;
3865
3871
  }
3866
3872
  initialize(container, containerEvents, viewer, worldTransformer) {
@@ -4069,6 +4075,7 @@ class Viewer extends EventEmitter2 {
4069
4075
  this.info = new Info();
4070
4076
  this.canvasEvents = CANVAS_EVENTS.slice();
4071
4077
  this.canvaseventlistener = (event) => this.emit(event);
4078
+ this._visualizeTimestamp = 0;
4072
4079
  this._activeDragger = null;
4073
4080
  this._components = [];
4074
4081
  this._renderNeeded = false;
@@ -4135,7 +4142,9 @@ class Viewer extends EventEmitter2 {
4135
4142
  this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
4136
4143
  this._markup.initialize(this.canvas, this.canvasEvents, this, this);
4137
4144
  for (const name of components.getComponents().keys()) {
4138
- this._components.push(components.createComponent(name, this));
4145
+ const component = components.createComponent(name, this);
4146
+ if (component)
4147
+ this._components.push(component);
4139
4148
  }
4140
4149
  this.syncOptions();
4141
4150
  this.syncOverlay();
@@ -4152,10 +4161,7 @@ class Viewer extends EventEmitter2 {
4152
4161
  this.setActiveDragger();
4153
4162
  this._components.forEach((component) => component.dispose());
4154
4163
  this._components.length = 0;
4155
- if (this._markup) {
4156
- this._markup.dispose();
4157
- this._markup = undefined;
4158
- }
4164
+ this._markup.dispose();
4159
4165
  if (this.canvas) {
4160
4166
  this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
4161
4167
  this.canvas = undefined;
@@ -4163,7 +4169,7 @@ class Viewer extends EventEmitter2 {
4163
4169
  if (this._viewer)
4164
4170
  this._viewer.clear();
4165
4171
  this._visualizeJs = undefined;
4166
- this._visualizeTimestamp = undefined;
4172
+ this._visualizeTimestamp = 0;
4167
4173
  this._viewer = undefined;
4168
4174
  return this;
4169
4175
  }
@@ -4540,7 +4546,7 @@ class Viewer extends EventEmitter2 {
4540
4546
  }
4541
4547
  }
4542
4548
  getComponent(name) {
4543
- return this._components.find((component) => component.name === name);
4549
+ return this._components.find((component) => component.name === name) || null;
4544
4550
  }
4545
4551
  drawViewpoint(viewpoint) {
4546
4552
  var _a, _b;