@inweb/viewer-three 26.12.1 → 26.12.3

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.
@@ -37335,7 +37335,6 @@ void main() {
37335
37335
  constructor(id, loadController) {
37336
37336
  this.id = `${id}`;
37337
37337
  this.json = null;
37338
- this.baseUrl = "";
37339
37338
  this.loadController = loadController;
37340
37339
  this.loader = null;
37341
37340
  this.batchDelay = 10;
@@ -37354,13 +37353,11 @@ void main() {
37354
37353
  }
37355
37354
  async initialize(loader) {
37356
37355
  this.json = await this.loadController.loadJson();
37357
- this.baseUrl = await this.loadController.baseUrl();
37358
37356
  this.loader = loader;
37359
37357
  this.uri = this.json.buffers[0].uri || "";
37360
37358
  }
37361
37359
  clear() {
37362
37360
  this.json = null;
37363
- this.baseUrl = "";
37364
37361
  this.loadController = null;
37365
37362
  this.pendingRequests = [];
37366
37363
  if (this.batchTimeout) {
@@ -37641,12 +37638,8 @@ void main() {
37641
37638
  const loadTexture = async (imageIndex) => {
37642
37639
  const image = this.json.images[imageIndex];
37643
37640
  if (image.uri) {
37644
- if (image.uri.startsWith("data:")) {
37645
- return await this.textureLoader.loadAsync(image.uri);
37646
- } else {
37647
- const fullUrl = this.baseUrl + image.uri;
37648
- return await this.textureLoader.loadAsync(fullUrl);
37649
- }
37641
+ const fullUrl = await this.loadController.resolveURL(image.uri);
37642
+ return this.textureLoader.loadAsync(fullUrl);
37650
37643
  } else if (image.bufferView !== undefined) {
37651
37644
  const bufferView = this.json.bufferViews[image.bufferView];
37652
37645
  const array = await this.getBufferView(bufferView.byteOffset || 0, bufferView.byteLength, 5121);
@@ -39966,7 +39959,10 @@ void main() {
39966
39959
  const data = await loader.loadAsync(this.manager.fileURL, progress);
39967
39960
  const extension = new GLTFBinaryExtension(data);
39968
39961
  this.gltf = JSON.parse(extension.content);
39969
- this.bin = extension.body;
39962
+ this.glb = extension.body;
39963
+ if (/\.glb$/i.test(this.manager.fileURL) && !this.glb) {
39964
+ throw new Error("GLTFFileDynamicLoader: Binary buffer chunk not found or type not supported.");
39965
+ }
39970
39966
  return this.gltf;
39971
39967
  },
39972
39968
  loadBinaryData: (ranges, uri = "") => {
@@ -39974,15 +39970,16 @@ void main() {
39974
39970
  loader.setRequestHeader(params.requestHeader || {});
39975
39971
  loader.setWithCredentials(params.withCredentials || false);
39976
39972
  loader.setAbortSignal(this.gltfLoader.abortController.signal);
39977
- if (this.bin)
39978
- return loader.extractRanges(this.bin, ranges);
39973
+ if (this.glb)
39974
+ return loader.extractRanges(this.glb, ranges);
39979
39975
  const path = this.manager.path || this.manager.resourcePath;
39980
39976
  const url = LoaderUtils.resolveURL(uri, path);
39981
39977
  return loader.load(this.manager.resolveURL(url), ranges);
39982
39978
  },
39983
- baseUrl: () => {
39979
+ resolveURL: (uri) => {
39984
39980
  const path = this.manager.path || this.manager.resourcePath;
39985
- return Promise.resolve(path);
39981
+ const url = LoaderUtils.resolveURL(uri, path);
39982
+ return Promise.resolve(this.manager.resolveURL(url));
39986
39983
  },
39987
39984
  };
39988
39985
  const structure = new GltfStructure(modelImpl.id, loadController);
@@ -40053,7 +40050,11 @@ void main() {
40053
40050
  }));
40054
40051
  return model.downloadResourceRange(model.geometry[0], undefined, ranges, undefined, this.gltfLoader.getAbortController().signal);
40055
40052
  },
40056
- baseUrl: () => Promise.resolve(`${model.httpClient.serverUrl}${model.path}/`),
40053
+ resolveURL: (uri) => {
40054
+ const path = `${model.httpClient.serverUrl}${model.path}/`;
40055
+ const url = LoaderUtils.resolveURL(uri, path);
40056
+ return Promise.resolve(url);
40057
+ },
40057
40058
  };
40058
40059
  const structure = new GltfStructure(modelImpl.id, loadController);
40059
40060
  await this.gltfLoader.loadStructure(structure);
@@ -41599,7 +41600,7 @@ void main() {
41599
41600
  : {};
41600
41601
  const Konva$2 = {
41601
41602
  _global: glob,
41602
- version: '10.0.2',
41603
+ version: '10.0.12',
41603
41604
  isBrowser: detectBrowser(),
41604
41605
  isUnminified: /param/.test(function (param) { }.toString()),
41605
41606
  dblClickWindow: 400,
@@ -41641,7 +41642,7 @@ void main() {
41641
41642
  document: glob.document,
41642
41643
  _injectGlobal(Konva) {
41643
41644
  if (typeof glob.Konva !== 'undefined') {
41644
- console.error('Severa Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
41645
+ console.error('Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
41645
41646
  }
41646
41647
  glob.Konva = Konva;
41647
41648
  },
@@ -41816,7 +41817,7 @@ js: import "konva/skia-backend";
41816
41817
  return result;
41817
41818
  }
41818
41819
  }
41819
- const OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH$1 = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
41820
+ const OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
41820
41821
  aliceblue: [240, 248, 255],
41821
41822
  antiquewhite: [250, 235, 215],
41822
41823
  aqua: [0, 255, 255],
@@ -41968,6 +41969,7 @@ js: import "konva/skia-backend";
41968
41969
  yellowgreen: [154, 205, 5],
41969
41970
  }, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;
41970
41971
  let animQueue = [];
41972
+ let _isCanvasFarblingActive = null;
41971
41973
  const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
41972
41974
  function (f) {
41973
41975
  setTimeout(f, 60);
@@ -42063,7 +42065,7 @@ js: import "konva/skia-backend";
42063
42065
  return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
42064
42066
  },
42065
42067
  _hexToRgb(hex) {
42066
- hex = hex.replace(HASH$1, EMPTY_STRING$1);
42068
+ hex = hex.replace(HASH, EMPTY_STRING$1);
42067
42069
  const bigint = parseInt(hex, 16);
42068
42070
  return {
42069
42071
  r: (bigint >> 16) & 255,
@@ -42076,7 +42078,58 @@ js: import "konva/skia-backend";
42076
42078
  while (randColor.length < 6) {
42077
42079
  randColor = ZERO + randColor;
42078
42080
  }
42079
- return HASH$1 + randColor;
42081
+ return HASH + randColor;
42082
+ },
42083
+ isCanvasFarblingActive() {
42084
+ if (_isCanvasFarblingActive !== null) {
42085
+ return _isCanvasFarblingActive;
42086
+ }
42087
+ if (typeof document === 'undefined') {
42088
+ _isCanvasFarblingActive = false;
42089
+ return false;
42090
+ }
42091
+ const c = this.createCanvasElement();
42092
+ c.width = 10;
42093
+ c.height = 10;
42094
+ const ctx = c.getContext('2d', {
42095
+ willReadFrequently: true,
42096
+ });
42097
+ ctx.clearRect(0, 0, 10, 10);
42098
+ ctx.fillStyle = '#282828';
42099
+ ctx.fillRect(0, 0, 10, 10);
42100
+ const d = ctx.getImageData(0, 0, 10, 10).data;
42101
+ let isFarbling = false;
42102
+ for (let i = 0; i < 100; i++) {
42103
+ if (d[i * 4] !== 40 ||
42104
+ d[i * 4 + 1] !== 40 ||
42105
+ d[i * 4 + 2] !== 40 ||
42106
+ d[i * 4 + 3] !== 255) {
42107
+ isFarbling = true;
42108
+ break;
42109
+ }
42110
+ }
42111
+ _isCanvasFarblingActive = isFarbling;
42112
+ this.releaseCanvas(c);
42113
+ return _isCanvasFarblingActive;
42114
+ },
42115
+ getHitColor() {
42116
+ const color = this.getRandomColor();
42117
+ return this.isCanvasFarblingActive()
42118
+ ? this.getSnappedHexColor(color)
42119
+ : color;
42120
+ },
42121
+ getHitColorKey(r, g, b) {
42122
+ if (this.isCanvasFarblingActive()) {
42123
+ r = Math.round(r / 5) * 5;
42124
+ g = Math.round(g / 5) * 5;
42125
+ b = Math.round(b / 5) * 5;
42126
+ }
42127
+ return HASH + this._rgbToHex(r, g, b);
42128
+ },
42129
+ getSnappedHexColor(hex) {
42130
+ const rgb = this._hexToRgb(hex);
42131
+ return (HASH +
42132
+ this._rgbToHex(Math.round(rgb.r / 5) * 5, Math.round(rgb.g / 5) * 5, Math.round(rgb.b / 5) * 5));
42080
42133
  },
42081
42134
  getRGB(color) {
42082
42135
  let rgb;
@@ -42088,7 +42141,7 @@ js: import "konva/skia-backend";
42088
42141
  b: rgb[2],
42089
42142
  };
42090
42143
  }
42091
- else if (color[0] === HASH$1) {
42144
+ else if (color[0] === HASH) {
42092
42145
  return this._hexToRgb(color.substring(1));
42093
42146
  }
42094
42147
  else if (color.substr(0, 4) === RGB_PAREN) {
@@ -43172,42 +43225,12 @@ js: import "konva/skia-backend";
43172
43225
  this.setSize(config.width, config.height);
43173
43226
  }
43174
43227
  }
43175
- function isCanvasFarblingActive() {
43176
- const c = Util.createCanvasElement();
43177
- c.width = 1;
43178
- c.height = 1;
43179
- const ctx = c.getContext('2d', {
43180
- willReadFrequently: true,
43181
- });
43182
- ctx.clearRect(0, 0, 1, 1);
43183
- ctx.fillStyle = 'rgba(255,0,255,1)';
43184
- ctx.fillRect(0, 0, 1, 1);
43185
- const d = ctx.getImageData(0, 0, 1, 1).data;
43186
- const exact = d[0] === 255 && d[1] === 0 && d[2] === 255 && d[3] === 255;
43187
- return !exact;
43188
- }
43189
- function isBraveBrowser() {
43190
- var _a, _b;
43191
- if (typeof navigator === 'undefined') {
43192
- return false;
43193
- }
43194
- return (_b = (_a = navigator.brave) === null || _a === void 0 ? void 0 : _a.isBrave()) !== null && _b !== void 0 ? _b : false;
43195
- }
43196
- let warned = false;
43197
- function checkHitCanvasSupport() {
43198
- if (isBraveBrowser() && isCanvasFarblingActive() && !warned) {
43199
- warned = true;
43200
- Util.error('Looks like you have "Brave shield" enabled in your browser. It breaks KonvaJS internals. Please disable it. You may need to ask your users to do the same.');
43201
- }
43202
- return isBraveBrowser() && isCanvasFarblingActive();
43203
- }
43204
43228
  class HitCanvas extends Canvas {
43205
43229
  constructor(config = { width: 0, height: 0 }) {
43206
43230
  super(config);
43207
43231
  this.hitCanvas = true;
43208
43232
  this.context = new HitContext(this);
43209
43233
  this.setSize(config.width, config.height);
43210
- checkHitCanvasSupport();
43211
43234
  }
43212
43235
  }
43213
43236
 
@@ -44063,7 +44086,7 @@ js: import "konva/skia-backend";
44063
44086
  return ancestors;
44064
44087
  }
44065
44088
  getAttrs() {
44066
- return (this.attrs || {});
44089
+ return this.attrs || {};
44067
44090
  }
44068
44091
  setAttrs(config) {
44069
44092
  this._batchTransformChanges(() => {
@@ -46236,11 +46259,18 @@ js: import "konva/skia-backend";
46236
46259
  constructor(config) {
46237
46260
  super(config);
46238
46261
  let key;
46262
+ let attempts = 0;
46239
46263
  while (true) {
46240
- key = Util.getRandomColor();
46264
+ key = Util.getHitColor();
46241
46265
  if (key && !(key in shapes)) {
46242
46266
  break;
46243
46267
  }
46268
+ attempts++;
46269
+ if (attempts >= 10000) {
46270
+ Util.warn('Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.');
46271
+ key = Util.getRandomColor();
46272
+ break;
46273
+ }
46244
46274
  }
46245
46275
  this.colorKey = key;
46246
46276
  shapes[key] = this;
@@ -46523,8 +46553,10 @@ js: import "konva/skia-backend";
46523
46553
  if (hasShadow) {
46524
46554
  context._applyShadow(this);
46525
46555
  }
46526
- context._applyOpacity(this);
46527
- context._applyGlobalCompositeOperation(this);
46556
+ if (!cachingSelf) {
46557
+ context._applyOpacity(this);
46558
+ context._applyGlobalCompositeOperation(this);
46559
+ }
46528
46560
  context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
46529
46561
  }
46530
46562
  else {
@@ -46718,7 +46750,7 @@ js: import "konva/skia-backend";
46718
46750
  setDrawHitFunc: 'setHitFunc',
46719
46751
  });
46720
46752
 
46721
- const HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
46753
+ const BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
46722
46754
  { x: 0, y: 0 },
46723
46755
  { x: -1, y: -1 },
46724
46756
  { x: 1, y: -1 },
@@ -46936,8 +46968,8 @@ js: import "konva/skia-backend";
46936
46968
  const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
46937
46969
  const p3 = p[3];
46938
46970
  if (p3 === 255) {
46939
- const colorKey = Util._rgbToHex(p[0], p[1], p[2]);
46940
- const shape = shapes[HASH + colorKey];
46971
+ const colorKey = Util.getHitColorKey(p[0], p[1], p[2]);
46972
+ const shape = shapes[colorKey];
46941
46973
  if (shape) {
46942
46974
  return {
46943
46975
  shape: shape,
@@ -49642,12 +49674,12 @@ js: import "konva/skia-backend";
49642
49674
  context.fillStrokeShape(this);
49643
49675
  }
49644
49676
  getWidth() {
49645
- var _a, _b;
49646
- return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
49677
+ var _a, _b, _c;
49678
+ return (_c = (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;
49647
49679
  }
49648
49680
  getHeight() {
49649
- var _a, _b;
49650
- return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
49681
+ var _a, _b, _c;
49682
+ return (_c = (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 0;
49651
49683
  }
49652
49684
  static fromURL(url, callback, onError = null) {
49653
49685
  const img = Util.createImageElement();
@@ -49663,6 +49695,7 @@ js: import "konva/skia-backend";
49663
49695
  }
49664
49696
  };
49665
49697
  Image$1.prototype.className = 'Image';
49698
+ Image$1.prototype._attrsAffectingSize = ['image'];
49666
49699
  _registerNode(Image$1);
49667
49700
  Factory.addGetterSetter(Image$1, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
49668
49701
  Factory.addGetterSetter(Image$1, 'image');
@@ -49890,8 +49923,8 @@ js: import "konva/skia-backend";
49890
49923
  getSelfRect() {
49891
49924
  const points = this._getPoints();
49892
49925
  let minX = points[0].x;
49893
- let maxX = points[0].y;
49894
- let minY = points[0].x;
49926
+ let maxX = points[0].x;
49927
+ let minY = points[0].y;
49895
49928
  let maxY = points[0].y;
49896
49929
  points.forEach((point) => {
49897
49930
  minX = Math.min(minX, point.x);
@@ -50243,6 +50276,7 @@ js: import "konva/skia-backend";
50243
50276
  context.stroke();
50244
50277
  context.restore();
50245
50278
  }
50279
+ const lineThroughStartX = lineTranslateX;
50246
50280
  if (direction !== RTL &&
50247
50281
  (letterSpacing !== 0 || align === JUSTIFY || charRenderFunc)) {
50248
50282
  const spacesNumber = text.split(' ').length - 1;
@@ -50294,7 +50328,7 @@ js: import "konva/skia-backend";
50294
50328
  const yOffset = !Konva$2.legacyTextRendering
50295
50329
  ? -Math.round(fontSize / 4)
50296
50330
  : 0;
50297
- const x = align === JUSTIFY ? 0 : lineTranslateX;
50331
+ const x = lineThroughStartX;
50298
50332
  context.moveTo(x, translateY + lineTranslateY + yOffset);
50299
50333
  const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
50300
50334
  context.lineTo(x + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
@@ -50597,7 +50631,9 @@ js: import "konva/skia-backend";
50597
50631
  const fill = this.fill();
50598
50632
  const fontSize = this.fontSize();
50599
50633
  const glyphInfo = this.glyphInfo;
50600
- if (textDecoration === 'underline') {
50634
+ const hasUnderline = textDecoration.indexOf('underline') !== -1;
50635
+ const hasLineThrough = textDecoration.indexOf('line-through') !== -1;
50636
+ if (hasUnderline) {
50601
50637
  context.beginPath();
50602
50638
  }
50603
50639
  for (let i = 0; i < glyphInfo.length; i++) {
@@ -50607,15 +50643,32 @@ js: import "konva/skia-backend";
50607
50643
  context.rotate(glyphInfo[i].rotation);
50608
50644
  this.partialText = glyphInfo[i].text;
50609
50645
  context.fillStrokeShape(this);
50610
- if (textDecoration === 'underline') {
50646
+ if (hasUnderline) {
50611
50647
  if (i === 0) {
50612
50648
  context.moveTo(0, fontSize / 2 + 1);
50613
50649
  }
50614
- context.lineTo(fontSize, fontSize / 2 + 1);
50650
+ context.lineTo(glyphInfo[i].width, fontSize / 2 + 1);
50615
50651
  }
50616
50652
  context.restore();
50617
50653
  }
50618
- if (textDecoration === 'underline') {
50654
+ if (hasUnderline) {
50655
+ context.strokeStyle = fill;
50656
+ context.lineWidth = fontSize / 20;
50657
+ context.stroke();
50658
+ }
50659
+ if (hasLineThrough) {
50660
+ context.beginPath();
50661
+ for (let i = 0; i < glyphInfo.length; i++) {
50662
+ context.save();
50663
+ const p0 = glyphInfo[i].p0;
50664
+ context.translate(p0.x, p0.y);
50665
+ context.rotate(glyphInfo[i].rotation);
50666
+ if (i === 0) {
50667
+ context.moveTo(0, 0);
50668
+ }
50669
+ context.lineTo(glyphInfo[i].width, 0);
50670
+ context.restore();
50671
+ }
50619
50672
  context.strokeStyle = fill;
50620
50673
  context.lineWidth = fontSize / 20;
50621
50674
  context.stroke();
@@ -50728,6 +50781,7 @@ js: import "konva/skia-backend";
50728
50781
  rotation: rotation,
50729
50782
  p0: charStartPoint,
50730
50783
  p1: charEndPoint,
50784
+ width: width,
50731
50785
  });
50732
50786
  offsetToGlyph += glyphWidth;
50733
50787
  }