@inweb/viewer-visualize 26.2.0 → 26.2.2

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.
@@ -2421,11 +2421,12 @@ components.registerComponent("ZoomWheelComponent", (viewer => new ZoomWheelCompo
2421
2421
 
2422
2422
  components.registerComponent("GestureManagerComponent", (viewer => new GestureManagerComponent(viewer)));
2423
2423
 
2424
- function loadScript(url) {
2424
+ function loadScript(url, params = {}) {
2425
2425
  return new Promise(((resolve, reject) => {
2426
2426
  const script = document.createElement("script");
2427
2427
  script.src = url;
2428
2428
  script.async = true;
2429
+ script.crossOrigin = params.crossOrigin;
2429
2430
  script.onload = () => resolve(script);
2430
2431
  script.onerror = () => {
2431
2432
  script.remove();
@@ -2435,7 +2436,7 @@ function loadScript(url) {
2435
2436
  }));
2436
2437
  }
2437
2438
 
2438
- function loadVisuazlizeJsScript(url) {
2439
+ function loadVisuazlizeJsScript(url, params) {
2439
2440
  if (window["getVisualizeLibInst"]) {
2440
2441
  const script = window["getVisualizeLibInst"].script;
2441
2442
  if (script) {
@@ -2444,21 +2445,25 @@ function loadVisuazlizeJsScript(url) {
2444
2445
  }
2445
2446
  delete window["getVisualizeLibInst"];
2446
2447
  }
2447
- return loadScript(url);
2448
+ return loadScript(url, params);
2448
2449
  }
2449
2450
 
2450
- const loadVisualizeJs = (url, onprogress) => loadVisuazlizeJsScript(url).then((script => new Promise(((resolve, reject) => {
2451
- const instance = window["getVisualizeLibInst"]({
2452
- urlMemFile: url + ".wasm",
2453
- TOTAL_MEMORY: 134217728,
2454
- onprogress: onprogress
2455
- });
2456
- instance["loadWasmError"] = reject;
2457
- instance.postRun.push((() => {
2458
- window["getVisualizeLibInst"].script = script;
2459
- resolve(instance);
2451
+ const loadVisualizeJs = async (url, onprogress, params = {}) => {
2452
+ const script = await loadVisuazlizeJsScript(url, params);
2453
+ return await new Promise(((resolve, reject) => {
2454
+ const options = {
2455
+ urlMemFile: url + ".wasm",
2456
+ TOTAL_MEMORY: 134217728,
2457
+ onprogress: onprogress
2458
+ };
2459
+ const instance = window["getVisualizeLibInst"](options);
2460
+ instance.loadWasmError = reject;
2461
+ instance.postRun.push((() => {
2462
+ window["getVisualizeLibInst"].script = script;
2463
+ resolve(instance);
2464
+ }));
2460
2465
  }));
2461
- }))));
2466
+ };
2462
2467
 
2463
2468
  class BaseLoader {
2464
2469
  constructor(viewer, model, options) {
@@ -3246,6 +3251,7 @@ class Viewer extends EventEmitter2 {
3246
3251
  }
3247
3252
  configure(params) {
3248
3253
  this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js";
3254
+ this._crossOrigin = params.crossOrigin;
3249
3255
  return this;
3250
3256
  }
3251
3257
  async initialize(canvas, onProgress) {
@@ -3273,7 +3279,9 @@ class Viewer extends EventEmitter2 {
3273
3279
  loaded: loaded,
3274
3280
  total: total
3275
3281
  });
3276
- }));
3282
+ }), {
3283
+ crossOrigin: this._crossOrigin
3284
+ });
3277
3285
  if (visualizeTimestamp !== this._visualizeTimestamp) throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");
3278
3286
  this._visualizeJs = visualizeJs;
3279
3287
  this.visualizeJs.canvas = canvas;