@inweb/viewer-three 26.12.2 → 26.12.4

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);
@@ -38188,7 +38181,6 @@ void main() {
38188
38181
  const uniqueTextureIds = new Set();
38189
38182
  if (Array.isArray(this.structures)) {
38190
38183
  for (const structure of this.structures) {
38191
- console.log(structure.materialCache.values());
38192
38184
  try {
38193
38185
  for (const entry of structure.materialCache.values()) {
38194
38186
  if (entry?.mesh?.uuid) uniqueMaterialIds.add(entry.mesh.uuid);
@@ -39966,7 +39958,10 @@ void main() {
39966
39958
  const data = await loader.loadAsync(this.manager.fileURL, progress);
39967
39959
  const extension = new GLTFBinaryExtension(data);
39968
39960
  this.gltf = JSON.parse(extension.content);
39969
- this.bin = extension.body;
39961
+ this.glb = extension.body;
39962
+ if (/\.glb$/i.test(this.manager.fileURL) && !this.glb) {
39963
+ throw new Error("GLTFFileDynamicLoader: Binary buffer chunk not found or type not supported.");
39964
+ }
39970
39965
  return this.gltf;
39971
39966
  },
39972
39967
  loadBinaryData: (ranges, uri = "") => {
@@ -39974,15 +39969,16 @@ void main() {
39974
39969
  loader.setRequestHeader(params.requestHeader || {});
39975
39970
  loader.setWithCredentials(params.withCredentials || false);
39976
39971
  loader.setAbortSignal(this.gltfLoader.abortController.signal);
39977
- if (this.bin)
39978
- return loader.extractRanges(this.bin, ranges);
39972
+ if (this.glb)
39973
+ return loader.extractRanges(this.glb, ranges);
39979
39974
  const path = this.manager.path || this.manager.resourcePath;
39980
39975
  const url = LoaderUtils.resolveURL(uri, path);
39981
39976
  return loader.load(this.manager.resolveURL(url), ranges);
39982
39977
  },
39983
- baseUrl: () => {
39978
+ resolveURL: (uri) => {
39984
39979
  const path = this.manager.path || this.manager.resourcePath;
39985
- return Promise.resolve(path);
39980
+ const url = LoaderUtils.resolveURL(uri, path);
39981
+ return Promise.resolve(this.manager.resolveURL(url));
39986
39982
  },
39987
39983
  };
39988
39984
  const structure = new GltfStructure(modelImpl.id, loadController);
@@ -40053,7 +40049,11 @@ void main() {
40053
40049
  }));
40054
40050
  return model.downloadResourceRange(model.geometry[0], undefined, ranges, undefined, this.gltfLoader.getAbortController().signal);
40055
40051
  },
40056
- baseUrl: () => Promise.resolve(`${model.httpClient.serverUrl}${model.path}/`),
40052
+ resolveURL: (uri) => {
40053
+ const path = `${model.httpClient.serverUrl}${model.path}/`;
40054
+ const url = LoaderUtils.resolveURL(uri, path);
40055
+ return Promise.resolve(url);
40056
+ },
40057
40057
  };
40058
40058
  const structure = new GltfStructure(modelImpl.id, loadController);
40059
40059
  await this.gltfLoader.loadStructure(structure);
@@ -41599,7 +41599,7 @@ void main() {
41599
41599
  : {};
41600
41600
  const Konva$2 = {
41601
41601
  _global: glob,
41602
- version: '10.0.2',
41602
+ version: '10.0.12',
41603
41603
  isBrowser: detectBrowser(),
41604
41604
  isUnminified: /param/.test(function (param) { }.toString()),
41605
41605
  dblClickWindow: 400,
@@ -41641,7 +41641,7 @@ void main() {
41641
41641
  document: glob.document,
41642
41642
  _injectGlobal(Konva) {
41643
41643
  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.');
41644
+ console.error('Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
41645
41645
  }
41646
41646
  glob.Konva = Konva;
41647
41647
  },
@@ -41816,7 +41816,7 @@ js: import "konva/skia-backend";
41816
41816
  return result;
41817
41817
  }
41818
41818
  }
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 = {
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 = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
41820
41820
  aliceblue: [240, 248, 255],
41821
41821
  antiquewhite: [250, 235, 215],
41822
41822
  aqua: [0, 255, 255],
@@ -41968,6 +41968,7 @@ js: import "konva/skia-backend";
41968
41968
  yellowgreen: [154, 205, 5],
41969
41969
  }, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;
41970
41970
  let animQueue = [];
41971
+ let _isCanvasFarblingActive = null;
41971
41972
  const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
41972
41973
  function (f) {
41973
41974
  setTimeout(f, 60);
@@ -42063,7 +42064,7 @@ js: import "konva/skia-backend";
42063
42064
  return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
42064
42065
  },
42065
42066
  _hexToRgb(hex) {
42066
- hex = hex.replace(HASH$1, EMPTY_STRING$1);
42067
+ hex = hex.replace(HASH, EMPTY_STRING$1);
42067
42068
  const bigint = parseInt(hex, 16);
42068
42069
  return {
42069
42070
  r: (bigint >> 16) & 255,
@@ -42076,7 +42077,58 @@ js: import "konva/skia-backend";
42076
42077
  while (randColor.length < 6) {
42077
42078
  randColor = ZERO + randColor;
42078
42079
  }
42079
- return HASH$1 + randColor;
42080
+ return HASH + randColor;
42081
+ },
42082
+ isCanvasFarblingActive() {
42083
+ if (_isCanvasFarblingActive !== null) {
42084
+ return _isCanvasFarblingActive;
42085
+ }
42086
+ if (typeof document === 'undefined') {
42087
+ _isCanvasFarblingActive = false;
42088
+ return false;
42089
+ }
42090
+ const c = this.createCanvasElement();
42091
+ c.width = 10;
42092
+ c.height = 10;
42093
+ const ctx = c.getContext('2d', {
42094
+ willReadFrequently: true,
42095
+ });
42096
+ ctx.clearRect(0, 0, 10, 10);
42097
+ ctx.fillStyle = '#282828';
42098
+ ctx.fillRect(0, 0, 10, 10);
42099
+ const d = ctx.getImageData(0, 0, 10, 10).data;
42100
+ let isFarbling = false;
42101
+ for (let i = 0; i < 100; i++) {
42102
+ if (d[i * 4] !== 40 ||
42103
+ d[i * 4 + 1] !== 40 ||
42104
+ d[i * 4 + 2] !== 40 ||
42105
+ d[i * 4 + 3] !== 255) {
42106
+ isFarbling = true;
42107
+ break;
42108
+ }
42109
+ }
42110
+ _isCanvasFarblingActive = isFarbling;
42111
+ this.releaseCanvas(c);
42112
+ return _isCanvasFarblingActive;
42113
+ },
42114
+ getHitColor() {
42115
+ const color = this.getRandomColor();
42116
+ return this.isCanvasFarblingActive()
42117
+ ? this.getSnappedHexColor(color)
42118
+ : color;
42119
+ },
42120
+ getHitColorKey(r, g, b) {
42121
+ if (this.isCanvasFarblingActive()) {
42122
+ r = Math.round(r / 5) * 5;
42123
+ g = Math.round(g / 5) * 5;
42124
+ b = Math.round(b / 5) * 5;
42125
+ }
42126
+ return HASH + this._rgbToHex(r, g, b);
42127
+ },
42128
+ getSnappedHexColor(hex) {
42129
+ const rgb = this._hexToRgb(hex);
42130
+ return (HASH +
42131
+ this._rgbToHex(Math.round(rgb.r / 5) * 5, Math.round(rgb.g / 5) * 5, Math.round(rgb.b / 5) * 5));
42080
42132
  },
42081
42133
  getRGB(color) {
42082
42134
  let rgb;
@@ -42088,7 +42140,7 @@ js: import "konva/skia-backend";
42088
42140
  b: rgb[2],
42089
42141
  };
42090
42142
  }
42091
- else if (color[0] === HASH$1) {
42143
+ else if (color[0] === HASH) {
42092
42144
  return this._hexToRgb(color.substring(1));
42093
42145
  }
42094
42146
  else if (color.substr(0, 4) === RGB_PAREN) {
@@ -43172,42 +43224,12 @@ js: import "konva/skia-backend";
43172
43224
  this.setSize(config.width, config.height);
43173
43225
  }
43174
43226
  }
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
43227
  class HitCanvas extends Canvas {
43205
43228
  constructor(config = { width: 0, height: 0 }) {
43206
43229
  super(config);
43207
43230
  this.hitCanvas = true;
43208
43231
  this.context = new HitContext(this);
43209
43232
  this.setSize(config.width, config.height);
43210
- checkHitCanvasSupport();
43211
43233
  }
43212
43234
  }
43213
43235
 
@@ -44063,7 +44085,7 @@ js: import "konva/skia-backend";
44063
44085
  return ancestors;
44064
44086
  }
44065
44087
  getAttrs() {
44066
- return (this.attrs || {});
44088
+ return this.attrs || {};
44067
44089
  }
44068
44090
  setAttrs(config) {
44069
44091
  this._batchTransformChanges(() => {
@@ -46236,11 +46258,18 @@ js: import "konva/skia-backend";
46236
46258
  constructor(config) {
46237
46259
  super(config);
46238
46260
  let key;
46261
+ let attempts = 0;
46239
46262
  while (true) {
46240
- key = Util.getRandomColor();
46263
+ key = Util.getHitColor();
46241
46264
  if (key && !(key in shapes)) {
46242
46265
  break;
46243
46266
  }
46267
+ attempts++;
46268
+ if (attempts >= 10000) {
46269
+ 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.');
46270
+ key = Util.getRandomColor();
46271
+ break;
46272
+ }
46244
46273
  }
46245
46274
  this.colorKey = key;
46246
46275
  shapes[key] = this;
@@ -46523,8 +46552,10 @@ js: import "konva/skia-backend";
46523
46552
  if (hasShadow) {
46524
46553
  context._applyShadow(this);
46525
46554
  }
46526
- context._applyOpacity(this);
46527
- context._applyGlobalCompositeOperation(this);
46555
+ if (!cachingSelf) {
46556
+ context._applyOpacity(this);
46557
+ context._applyGlobalCompositeOperation(this);
46558
+ }
46528
46559
  context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
46529
46560
  }
46530
46561
  else {
@@ -46718,7 +46749,7 @@ js: import "konva/skia-backend";
46718
46749
  setDrawHitFunc: 'setHitFunc',
46719
46750
  });
46720
46751
 
46721
- const HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
46752
+ const BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
46722
46753
  { x: 0, y: 0 },
46723
46754
  { x: -1, y: -1 },
46724
46755
  { x: 1, y: -1 },
@@ -46936,8 +46967,8 @@ js: import "konva/skia-backend";
46936
46967
  const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
46937
46968
  const p3 = p[3];
46938
46969
  if (p3 === 255) {
46939
- const colorKey = Util._rgbToHex(p[0], p[1], p[2]);
46940
- const shape = shapes[HASH + colorKey];
46970
+ const colorKey = Util.getHitColorKey(p[0], p[1], p[2]);
46971
+ const shape = shapes[colorKey];
46941
46972
  if (shape) {
46942
46973
  return {
46943
46974
  shape: shape,
@@ -49642,12 +49673,12 @@ js: import "konva/skia-backend";
49642
49673
  context.fillStrokeShape(this);
49643
49674
  }
49644
49675
  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;
49676
+ var _a, _b, _c;
49677
+ 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
49678
  }
49648
49679
  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;
49680
+ var _a, _b, _c;
49681
+ 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
49682
  }
49652
49683
  static fromURL(url, callback, onError = null) {
49653
49684
  const img = Util.createImageElement();
@@ -49663,6 +49694,7 @@ js: import "konva/skia-backend";
49663
49694
  }
49664
49695
  };
49665
49696
  Image$1.prototype.className = 'Image';
49697
+ Image$1.prototype._attrsAffectingSize = ['image'];
49666
49698
  _registerNode(Image$1);
49667
49699
  Factory.addGetterSetter(Image$1, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
49668
49700
  Factory.addGetterSetter(Image$1, 'image');
@@ -49890,8 +49922,8 @@ js: import "konva/skia-backend";
49890
49922
  getSelfRect() {
49891
49923
  const points = this._getPoints();
49892
49924
  let minX = points[0].x;
49893
- let maxX = points[0].y;
49894
- let minY = points[0].x;
49925
+ let maxX = points[0].x;
49926
+ let minY = points[0].y;
49895
49927
  let maxY = points[0].y;
49896
49928
  points.forEach((point) => {
49897
49929
  minX = Math.min(minX, point.x);
@@ -50243,6 +50275,7 @@ js: import "konva/skia-backend";
50243
50275
  context.stroke();
50244
50276
  context.restore();
50245
50277
  }
50278
+ const lineThroughStartX = lineTranslateX;
50246
50279
  if (direction !== RTL &&
50247
50280
  (letterSpacing !== 0 || align === JUSTIFY || charRenderFunc)) {
50248
50281
  const spacesNumber = text.split(' ').length - 1;
@@ -50294,7 +50327,7 @@ js: import "konva/skia-backend";
50294
50327
  const yOffset = !Konva$2.legacyTextRendering
50295
50328
  ? -Math.round(fontSize / 4)
50296
50329
  : 0;
50297
- const x = align === JUSTIFY ? 0 : lineTranslateX;
50330
+ const x = lineThroughStartX;
50298
50331
  context.moveTo(x, translateY + lineTranslateY + yOffset);
50299
50332
  const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
50300
50333
  context.lineTo(x + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
@@ -50597,7 +50630,9 @@ js: import "konva/skia-backend";
50597
50630
  const fill = this.fill();
50598
50631
  const fontSize = this.fontSize();
50599
50632
  const glyphInfo = this.glyphInfo;
50600
- if (textDecoration === 'underline') {
50633
+ const hasUnderline = textDecoration.indexOf('underline') !== -1;
50634
+ const hasLineThrough = textDecoration.indexOf('line-through') !== -1;
50635
+ if (hasUnderline) {
50601
50636
  context.beginPath();
50602
50637
  }
50603
50638
  for (let i = 0; i < glyphInfo.length; i++) {
@@ -50607,15 +50642,32 @@ js: import "konva/skia-backend";
50607
50642
  context.rotate(glyphInfo[i].rotation);
50608
50643
  this.partialText = glyphInfo[i].text;
50609
50644
  context.fillStrokeShape(this);
50610
- if (textDecoration === 'underline') {
50645
+ if (hasUnderline) {
50611
50646
  if (i === 0) {
50612
50647
  context.moveTo(0, fontSize / 2 + 1);
50613
50648
  }
50614
- context.lineTo(fontSize, fontSize / 2 + 1);
50649
+ context.lineTo(glyphInfo[i].width, fontSize / 2 + 1);
50615
50650
  }
50616
50651
  context.restore();
50617
50652
  }
50618
- if (textDecoration === 'underline') {
50653
+ if (hasUnderline) {
50654
+ context.strokeStyle = fill;
50655
+ context.lineWidth = fontSize / 20;
50656
+ context.stroke();
50657
+ }
50658
+ if (hasLineThrough) {
50659
+ context.beginPath();
50660
+ for (let i = 0; i < glyphInfo.length; i++) {
50661
+ context.save();
50662
+ const p0 = glyphInfo[i].p0;
50663
+ context.translate(p0.x, p0.y);
50664
+ context.rotate(glyphInfo[i].rotation);
50665
+ if (i === 0) {
50666
+ context.moveTo(0, 0);
50667
+ }
50668
+ context.lineTo(glyphInfo[i].width, 0);
50669
+ context.restore();
50670
+ }
50619
50671
  context.strokeStyle = fill;
50620
50672
  context.lineWidth = fontSize / 20;
50621
50673
  context.stroke();
@@ -50728,6 +50780,7 @@ js: import "konva/skia-backend";
50728
50780
  rotation: rotation,
50729
50781
  p0: charStartPoint,
50730
50782
  p1: charEndPoint,
50783
+ width: width,
50731
50784
  });
50732
50785
  offsetToGlyph += glyphWidth;
50733
50786
  }