@antv/g-webgpu 1.7.71 → 1.7.73

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.
package/dist/index.umd.js CHANGED
@@ -4140,6 +4140,9 @@
4140
4140
  function bufferBindingEquals(a, b) {
4141
4141
  return a.buffer === b.buffer && a.wordCount === b.wordCount;
4142
4142
  }
4143
+ function bindingLayoutSamplerDescriptorEqual(a, b) {
4144
+ return a.dimension === b.dimension && a.formatKind === b.formatKind;
4145
+ }
4143
4146
  function samplerBindingEquals(a, b) {
4144
4147
  if (a === null) return b === null;
4145
4148
  if (b === null) return false;
@@ -4148,6 +4151,8 @@
4148
4151
  function bindingLayoutDescriptorEqual(a, b) {
4149
4152
  if (a.numSamplers !== b.numSamplers) return false;
4150
4153
  if (a.numUniformBuffers !== b.numUniformBuffers) return false;
4154
+ if (a.samplerEntries === undefined !== (b.samplerEntries === undefined)) return false;
4155
+ if (a.samplerEntries !== undefined && !arrayEqual(a.samplerEntries, b.samplerEntries, bindingLayoutSamplerDescriptorEqual)) return false;
4151
4156
  return true;
4152
4157
  }
4153
4158
  function bindingsDescriptorEquals(a, b) {
@@ -4843,7 +4848,7 @@
4843
4848
  }
4844
4849
  this.buffer = this.device.createBuffer({
4845
4850
  viewOrSize: this.currentBufferWordSize,
4846
- usage: BufferUsage.UNIFORM | BufferUsage.COPY_DST,
4851
+ usage: BufferUsage.UNIFORM,
4847
4852
  hint: BufferFrequencyHint.Dynamic
4848
4853
  });
4849
4854
  }
@@ -5153,31 +5158,28 @@
5153
5158
  RGAttachmentSlot[RGAttachmentSlot["ColorMax"] = 3] = "ColorMax";
5154
5159
  RGAttachmentSlot[RGAttachmentSlot["DepthStencil"] = 4] = "DepthStencil";
5155
5160
  })(RGAttachmentSlot || (RGAttachmentSlot = {}));
5156
- var IdentityViewportCoords = {
5157
- x: 0,
5158
- y: 0,
5159
- w: 1,
5160
- h: 1
5161
- };
5162
5161
  var RenderGraphPass = /*#__PURE__*/function () {
5163
5162
  function RenderGraphPass() {
5164
5163
  // RenderTargetAttachmentSlot => renderTargetID
5165
5164
  this.renderTargetIDs = [];
5165
+ this.renderTargetLevels = [];
5166
5166
  // RenderTargetAttachmentSlot => resolveTextureID
5167
5167
  this.resolveTextureOutputIDs = [];
5168
5168
  // RenderTargetAttachmentSlot => Texture
5169
5169
  this.resolveTextureOutputExternalTextures = [];
5170
+ this.resolveTextureOutputExternalTextureLevel = [];
5170
5171
  // List of resolveTextureIDs that we have a reference to.
5171
5172
  this.resolveTextureInputIDs = [];
5172
5173
  // RGAttachmentSlot => refcount.
5173
5174
  this.renderTargetExtraRefs = [];
5174
- this.viewport = IdentityViewportCoords;
5175
5175
  this.resolveTextureInputTextures = [];
5176
5176
  this.renderTargets = [];
5177
5177
  // Execution state computed by scheduling.
5178
5178
  this.descriptor = {
5179
5179
  colorAttachment: [],
5180
+ colorAttachmentLevel: [],
5180
5181
  colorResolveTo: [],
5182
+ colorResolveToLevel: [],
5181
5183
  colorStore: [],
5182
5184
  depthStencilAttachment: null,
5183
5185
  depthStencilResolveTo: null,
@@ -5189,8 +5191,8 @@
5189
5191
  };
5190
5192
  this.viewportX = 0;
5191
5193
  this.viewportY = 0;
5192
- this.viewportW = 0;
5193
- this.viewportH = 0;
5194
+ this.viewportW = 1;
5195
+ this.viewportH = 1;
5194
5196
  // Execution callback from user.
5195
5197
  this.execFunc = null;
5196
5198
  this.postFunc = null;
@@ -5205,12 +5207,19 @@
5205
5207
  _proto.pushDebugThumbnail = function pushDebugThumbnail(attachmentSlot) {
5206
5208
  this.debugThumbnails[attachmentSlot] = true;
5207
5209
  };
5208
- _proto.setViewport = function setViewport(viewport) {
5209
- this.viewport = viewport;
5210
+ _proto.setViewport = function setViewport(x, y, w, h) {
5211
+ this.viewportX = x;
5212
+ this.viewportY = y;
5213
+ this.viewportW = w;
5214
+ this.viewportH = h;
5210
5215
  };
5211
- _proto.attachRenderTargetID = function attachRenderTargetID(attachmentSlot, renderTargetID) {
5216
+ _proto.attachRenderTargetID = function attachRenderTargetID(attachmentSlot, renderTargetID, level) {
5217
+ if (level === void 0) {
5218
+ level = 0;
5219
+ }
5212
5220
  assert(this.renderTargetIDs[attachmentSlot] === undefined);
5213
5221
  this.renderTargetIDs[attachmentSlot] = renderTargetID;
5222
+ this.renderTargetLevels[attachmentSlot] = level;
5214
5223
  };
5215
5224
  _proto.attachResolveTexture = function attachResolveTexture(resolveTextureID) {
5216
5225
  this.resolveTextureInputIDs.push(resolveTextureID);
@@ -5429,12 +5438,16 @@
5429
5438
  var attachmentSlot = renderPass.renderTargetIDs.indexOf(renderTargetID);
5430
5439
  return this.resolveRenderTargetPassAttachmentSlot(renderPass, attachmentSlot);
5431
5440
  };
5432
- _proto.resolveRenderTargetToExternalTexture = function resolveRenderTargetToExternalTexture(renderTargetID, texture) {
5441
+ _proto.resolveRenderTargetToExternalTexture = function resolveRenderTargetToExternalTexture(renderTargetID, texture, level) {
5442
+ if (level === void 0) {
5443
+ level = 0;
5444
+ }
5433
5445
  var renderPass = this.findPassForResolveRenderTarget(renderTargetID);
5434
5446
  var attachmentSlot = renderPass.renderTargetIDs.indexOf(renderTargetID);
5435
5447
  // We shouldn't be resolving to a resolve texture ID in this case.
5436
5448
  assert(renderPass.resolveTextureOutputIDs[attachmentSlot] === undefined);
5437
5449
  renderPass.resolveTextureOutputExternalTextures[attachmentSlot] = texture;
5450
+ renderPass.resolveTextureOutputExternalTextureLevel[attachmentSlot] = level;
5438
5451
  };
5439
5452
  _proto.getRenderTargetDescription = function getRenderTargetDescription(renderTargetID) {
5440
5453
  return assertExists(this.currentGraph.renderTargetDescriptions[renderTargetID]);
@@ -5511,6 +5524,7 @@
5511
5524
  assert(!(hasResolveTextureOutputID && hasExternalTexture));
5512
5525
  var resolveTo = null;
5513
5526
  var store = false;
5527
+ var level = 0;
5514
5528
  if (this.renderTargetOutputCount[renderTargetID] > 1) {
5515
5529
  // A future pass is going to render to this RT, we need to store the results.
5516
5530
  store = true;
@@ -5538,12 +5552,14 @@
5538
5552
  }
5539
5553
  } else if (hasExternalTexture) {
5540
5554
  resolveTo = externalTexture;
5555
+ level = pass.resolveTextureOutputExternalTextureLevel[slot];
5541
5556
  } else {
5542
5557
  resolveTo = null;
5543
5558
  }
5544
5559
  return {
5545
5560
  resolveTo: resolveTo,
5546
- store: store
5561
+ store: store,
5562
+ level: level
5547
5563
  };
5548
5564
  };
5549
5565
  _proto.schedulePass = function schedulePass(graph, pass) {
@@ -5553,10 +5569,13 @@
5553
5569
  var colorRenderTarget = this.acquireRenderTargetForID(graph, colorRenderTargetID);
5554
5570
  pass.renderTargets[slot] = colorRenderTarget;
5555
5571
  pass.descriptor.colorAttachment[slot] = colorRenderTarget !== null ? colorRenderTarget.attachment : null;
5572
+ pass.descriptor.colorAttachmentLevel[slot] = pass.renderTargetLevels[slot];
5556
5573
  var _this$determineResolv = this.determineResolveParam(graph, pass, slot),
5557
5574
  _resolveTo = _this$determineResolv.resolveTo,
5558
- _store = _this$determineResolv.store;
5575
+ _store = _this$determineResolv.store,
5576
+ level = _this$determineResolv.level;
5559
5577
  pass.descriptor.colorResolveTo[slot] = _resolveTo;
5578
+ pass.descriptor.colorResolveToLevel[slot] = level;
5560
5579
  pass.descriptor.colorStore[slot] = _store;
5561
5580
  pass.descriptor.colorClearColor[slot] = colorRenderTarget !== null && colorRenderTarget.needsClear ? graph.renderTargetDescriptions[colorRenderTargetID].colorClearColor : 'load';
5562
5581
  }
@@ -5576,25 +5595,23 @@
5576
5595
  for (var i = 0; i < pass.renderTargets.length; i++) {
5577
5596
  var renderTarget = pass.renderTargets[i];
5578
5597
  if (!renderTarget) continue;
5598
+ var width = renderTarget.width >>> pass.renderTargetLevels[i];
5599
+ var height = renderTarget.height >>> pass.renderTargetLevels[i];
5579
5600
  if (rtWidth === 0) {
5580
- rtWidth = renderTarget.width;
5581
- rtHeight = renderTarget.height;
5601
+ rtWidth = width;
5602
+ rtHeight = height;
5582
5603
  rtSampleCount = renderTarget.sampleCount;
5583
5604
  }
5584
- assert(renderTarget.width === rtWidth);
5585
- assert(renderTarget.height === rtHeight);
5605
+ assert(width === rtWidth);
5606
+ assert(height === rtHeight);
5586
5607
  assert(renderTarget.sampleCount === rtSampleCount);
5587
5608
  renderTarget.needsClear = false;
5588
5609
  }
5589
5610
  if (rtWidth > 0 && rtHeight > 0) {
5590
- var x = rtWidth * pass.viewport.x;
5591
- var y = rtHeight * pass.viewport.y;
5592
- var w = rtWidth * pass.viewport.w;
5593
- var h = rtHeight * pass.viewport.h;
5594
- pass.viewportX = x;
5595
- pass.viewportY = y;
5596
- pass.viewportW = w;
5597
- pass.viewportH = h;
5611
+ pass.viewportX *= rtWidth;
5612
+ pass.viewportY *= rtHeight;
5613
+ pass.viewportW *= rtWidth;
5614
+ pass.viewportH *= rtHeight;
5598
5615
  }
5599
5616
  for (var _i = 0; _i < pass.resolveTextureInputIDs.length; _i++) {
5600
5617
  var resolveTextureID = pass.resolveTextureInputIDs[_i];
@@ -5662,9 +5679,11 @@
5662
5679
  _proto.execGraph = function execGraph(graph) {
5663
5680
  var _this = this;
5664
5681
  this.scheduleGraph(graph);
5682
+ this.device.beginFrame();
5665
5683
  graph.passes.forEach(function (pass) {
5666
5684
  _this.execPass(pass);
5667
5685
  });
5686
+ this.device.endFrame();
5668
5687
  // Clear our transient scope state.
5669
5688
  this.singleSampledTextureForResolveTextureID.length = 0;
5670
5689
  };
@@ -5977,6 +5996,7 @@
5977
5996
 
5978
5997
  var RenderInstFlags;
5979
5998
  (function (RenderInstFlags) {
5999
+ RenderInstFlags[RenderInstFlags["None"] = 0] = "None";
5980
6000
  RenderInstFlags[RenderInstFlags["Indexed"] = 1] = "Indexed";
5981
6001
  RenderInstFlags[RenderInstFlags["AllowSkippingIfPipelineNotReady"] = 2] = "AllowSkippingIfPipelineNotReady";
5982
6002
  // Mostly for error checking.
@@ -6360,7 +6380,6 @@
6360
6380
  pipeline: gfxPipeline
6361
6381
  }));
6362
6382
  passRenderer.setBindings(0, gfxBindings, this.dynamicUniformBufferByteOffsets);
6363
- // if (this.drawInstanceCount > 0) {
6364
6383
  if (this.drawInstanceCount > 1) {
6365
6384
  assert(!!(this.flags & RenderInstFlags.Indexed));
6366
6385
  passRenderer.drawIndexedInstanced(this.drawCount, this.drawStart, this.drawInstanceCount);
@@ -6934,12 +6953,11 @@
6934
6953
  _this.lightPool.addFog(object);
6935
6954
  return;
6936
6955
  }
6937
- var renderable3D = new Renderable3D();
6938
- // add geometry & material required by Renderable3D
6939
- // object.entity.addComponent(Geometry3D);
6940
- // object.entity.addComponent(Material3D);
6941
6956
  // @ts-ignore
6942
- object.renderable3D = renderable3D;
6957
+ if (!object.renderable3D) {
6958
+ // @ts-ignore
6959
+ object.renderable3D = new Renderable3D();
6960
+ }
6943
6961
  _this.batchManager.add(object);
6944
6962
  };
6945
6963
  var handleUnmounted = function handleUnmounted(e) {
@@ -6951,7 +6969,9 @@
6951
6969
  _this.lightPool.removeFog(object);
6952
6970
  return;
6953
6971
  }
6954
- _this.batchManager.remove(object);
6972
+ if (_this.swapChain) {
6973
+ _this.batchManager.remove(object);
6974
+ }
6955
6975
  // @ts-ignore
6956
6976
  delete object.renderable3D;
6957
6977
  // entity.removeComponent(Geometry3D, true);
@@ -6960,22 +6980,26 @@
6960
6980
  };
6961
6981
 
6962
6982
  var handleAttributeChanged = function handleAttributeChanged(e) {
6963
- var object = e.target;
6964
- var attrName = e.attrName,
6965
- newValue = e.newValue;
6966
- if (attrName === 'zIndex') {
6967
- object.parentNode.forEach(function (child) {
6968
- _this.batchManager.changeRenderOrder(child, child.sortable.renderOrder);
6969
- });
6970
- } else {
6971
- _this.batchManager.updateAttribute(object, attrName, newValue);
6983
+ if (_this.swapChain) {
6984
+ var object = e.target;
6985
+ var attrName = e.attrName,
6986
+ newValue = e.newValue;
6987
+ if (attrName === 'zIndex') {
6988
+ object.parentNode.forEach(function (child) {
6989
+ _this.batchManager.changeRenderOrder(child, child.sortable.renderOrder);
6990
+ });
6991
+ } else {
6992
+ _this.batchManager.updateAttribute(object, attrName, newValue);
6993
+ }
6972
6994
  }
6973
6995
  };
6974
6996
  var handleBoundsChanged = function handleBoundsChanged(e) {
6975
- var object = e.target;
6976
- _this.batchManager.updateAttribute(object, 'modelMatrix', null);
6997
+ if (_this.swapChain) {
6998
+ var object = e.target;
6999
+ _this.batchManager.updateAttribute(object, 'modelMatrix', null);
7000
+ }
6977
7001
  };
6978
- renderingService.hooks.init.tapPromise(RenderGraphPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
7002
+ renderingService.hooks.initAsync.tapPromise(RenderGraphPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
6979
7003
  var $canvas, _this$context$config, width, height;
6980
7004
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
6981
7005
  while (1) switch (_context.prev = _context.next) {
@@ -7021,9 +7045,6 @@
7021
7045
  * build frame graph at the beginning of each frame
7022
7046
  */
7023
7047
  renderingService.hooks.beginFrame.tap(RenderGraphPlugin.tag, function () {
7024
- // if (renderingContext.renderListCurrentFrame.length === 0) {
7025
- // return;
7026
- // }
7027
7048
  var canvas = _this.swapChain.getCanvas();
7028
7049
  var renderInstManager = _this.renderHelper.renderInstManager;
7029
7050
  _this.builder = _this.renderHelper.renderGraph.newGraphBuilder();
@@ -7061,9 +7082,6 @@
7061
7082
  _this.builder.resolveRenderTargetToExternalTexture(mainColorTargetID, _this.swapChain.getOnscreenTexture());
7062
7083
  });
7063
7084
  renderingService.hooks.endFrame.tap(RenderGraphPlugin.tag, function () {
7064
- // if (renderingContext.renderListCurrentFrame.length === 0) {
7065
- // return;
7066
- // }
7067
7085
  var renderInstManager = _this.renderHelper.renderInstManager;
7068
7086
  // TODO: time for GPU Animation
7069
7087
  // const timeInMilliseconds = window.performance.now();
@@ -7117,8 +7135,6 @@
7117
7135
  _this.renderHelper.prepareToRender();
7118
7136
  _this.renderHelper.renderGraph.execute();
7119
7137
  renderInstManager.resetRenderInsts();
7120
- // output to screen
7121
- _this.swapChain.present();
7122
7138
  // capture here since we don't preserve drawing buffer
7123
7139
  if (_this.enableCapture && _this.resolveCapturePromise) {
7124
7140
  var _this$captureOptions = _this.captureOptions,
@@ -7201,25 +7217,20 @@
7201
7217
  var handleMounted = function handleMounted(e) {
7202
7218
  var object = e.target;
7203
7219
  // @ts-ignore
7204
- var renderable3D = object.renderable3D;
7205
- if (renderable3D) {
7206
- // generate picking id for later use
7207
- var pickingId = _this.pickingIdGenerator.getId(object);
7208
- renderable3D.pickingId = pickingId;
7209
- renderable3D.encodedPickingColor = _this.pickingIdGenerator.encodePickingColor(pickingId);
7220
+ if (!object.renderable3D) {
7221
+ // @ts-ignore
7222
+ object.renderable3D = new Renderable3D();
7210
7223
  }
7224
+ // @ts-ignore
7225
+ var renderable3D = object.renderable3D;
7226
+ // generate picking id for later use
7227
+ var pickingId = _this.pickingIdGenerator.getId(object);
7228
+ renderable3D.pickingId = pickingId;
7229
+ renderable3D.encodedPickingColor = _this.pickingIdGenerator.encodePickingColor(pickingId);
7211
7230
  };
7212
- renderingService.hooks.init.tapPromise(PickingPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
7213
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7214
- while (1) switch (_context.prev = _context.next) {
7215
- case 0:
7216
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7217
- case 1:
7218
- case "end":
7219
- return _context.stop();
7220
- }
7221
- }, _callee);
7222
- })));
7231
+ renderingService.hooks.init.tap(PickingPlugin.tag, function () {
7232
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7233
+ });
7223
7234
  renderingService.hooks.destroy.tap(PickingPlugin.tag, function () {
7224
7235
  canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7225
7236
  });
@@ -7230,19 +7241,19 @@
7230
7241
  return _this.pick(result);
7231
7242
  });
7232
7243
  renderingService.hooks.pick.tapPromise(PickingPlugin.tag, /*#__PURE__*/function () {
7233
- var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(result) {
7234
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7235
- while (1) switch (_context2.prev = _context2.next) {
7244
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
7245
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7246
+ while (1) switch (_context.prev = _context.next) {
7236
7247
  case 0:
7237
- return _context2.abrupt("return", _this.pick(result));
7248
+ return _context.abrupt("return", _this.pick(result));
7238
7249
  case 1:
7239
7250
  case "end":
7240
- return _context2.stop();
7251
+ return _context.stop();
7241
7252
  }
7242
- }, _callee2);
7253
+ }, _callee);
7243
7254
  }));
7244
7255
  return function (_x) {
7245
- return _ref2.apply(this, arguments);
7256
+ return _ref.apply(this, arguments);
7246
7257
  };
7247
7258
  }());
7248
7259
  };
@@ -7517,7 +7528,7 @@
7517
7528
  if (this.indexBuffer) {
7518
7529
  this.indexBuffer.destroy();
7519
7530
  }
7520
- this.indexBuffer = makeStaticDataBuffer(this.device, BufferUsage.INDEX | BufferUsage.COPY_DST, new Uint32Array(ArrayBuffer.isView(indices) ? indices.buffer : indices).buffer);
7531
+ this.indexBuffer = makeStaticDataBuffer(this.device, BufferUsage.INDEX, new Uint32Array(ArrayBuffer.isView(indices) ? indices.buffer : indices).buffer);
7521
7532
  this.indices = indices;
7522
7533
  return this;
7523
7534
  };
@@ -7562,7 +7573,7 @@
7562
7573
  if (this.vertexBuffers[bufferIndex]) {
7563
7574
  this.vertexBuffers[bufferIndex].destroy();
7564
7575
  }
7565
- var buffer = makeStaticDataBuffer(this.device, BufferUsage.VERTEX | BufferUsage.COPY_DST, data.buffer);
7576
+ var buffer = makeStaticDataBuffer(this.device, BufferUsage.VERTEX, data.buffer);
7566
7577
  this.vertexBuffers[bufferIndex] = buffer;
7567
7578
  return this;
7568
7579
  };
@@ -7589,7 +7600,7 @@
7589
7600
  offset = 0;
7590
7601
  }
7591
7602
  if (this.indexBuffer) {
7592
- this.indexBuffer.setSubData(offset, ArrayBuffer.isView(indices) ? indices : new Uint32Array(indices));
7603
+ this.indexBuffer.setSubData(offset, new Uint8Array(ArrayBuffer.isView(indices) ? indices : new Uint32Array(indices)));
7593
7604
  }
7594
7605
  return this;
7595
7606
  };
@@ -8004,6 +8015,11 @@
8004
8015
  return v !== undefined;
8005
8016
  }));
8006
8017
  };
8018
+ function packUint8ToFloat(a, b) {
8019
+ a = clamp(Math.floor(a), 0, 255);
8020
+ b = clamp(Math.floor(b), 0, 255);
8021
+ return 256 * a + b;
8022
+ }
8007
8023
  var counter = 1;
8008
8024
  var FILL_TEXTURE_MAPPING = 'FillTextureMapping';
8009
8025
  /**
@@ -8032,16 +8048,15 @@
8032
8048
  VertexAttributeLocation[VertexAttributeLocation["MODEL_MATRIX1"] = 1] = "MODEL_MATRIX1";
8033
8049
  VertexAttributeLocation[VertexAttributeLocation["MODEL_MATRIX2"] = 2] = "MODEL_MATRIX2";
8034
8050
  VertexAttributeLocation[VertexAttributeLocation["MODEL_MATRIX3"] = 3] = "MODEL_MATRIX3";
8035
- VertexAttributeLocation[VertexAttributeLocation["COLOR"] = 4] = "COLOR";
8036
- VertexAttributeLocation[VertexAttributeLocation["STROKE_COLOR"] = 5] = "STROKE_COLOR";
8037
- VertexAttributeLocation[VertexAttributeLocation["PACKED_STYLE1"] = 6] = "PACKED_STYLE1";
8038
- VertexAttributeLocation[VertexAttributeLocation["PACKED_STYLE2"] = 7] = "PACKED_STYLE2";
8039
- VertexAttributeLocation[VertexAttributeLocation["PICKING_COLOR"] = 8] = "PICKING_COLOR";
8040
- VertexAttributeLocation[VertexAttributeLocation["POSITION"] = 9] = "POSITION";
8041
- VertexAttributeLocation[VertexAttributeLocation["NORMAL"] = 10] = "NORMAL";
8042
- VertexAttributeLocation[VertexAttributeLocation["UV"] = 11] = "UV";
8043
- VertexAttributeLocation[VertexAttributeLocation["BARYCENTRIC"] = 12] = "BARYCENTRIC";
8044
- VertexAttributeLocation[VertexAttributeLocation["MAX"] = 13] = "MAX";
8051
+ VertexAttributeLocation[VertexAttributeLocation["PACKED_COLOR"] = 4] = "PACKED_COLOR";
8052
+ VertexAttributeLocation[VertexAttributeLocation["PACKED_STYLE1"] = 5] = "PACKED_STYLE1";
8053
+ VertexAttributeLocation[VertexAttributeLocation["PACKED_STYLE2"] = 6] = "PACKED_STYLE2";
8054
+ VertexAttributeLocation[VertexAttributeLocation["PICKING_COLOR"] = 7] = "PICKING_COLOR";
8055
+ VertexAttributeLocation[VertexAttributeLocation["POSITION"] = 8] = "POSITION";
8056
+ VertexAttributeLocation[VertexAttributeLocation["NORMAL"] = 9] = "NORMAL";
8057
+ VertexAttributeLocation[VertexAttributeLocation["UV"] = 10] = "UV";
8058
+ VertexAttributeLocation[VertexAttributeLocation["BARYCENTRIC"] = 11] = "BARYCENTRIC";
8059
+ VertexAttributeLocation[VertexAttributeLocation["MAX"] = 12] = "MAX";
8045
8060
  })(VertexAttributeLocation || (VertexAttributeLocation = {}));
8046
8061
  /**
8047
8062
  * Instanced mesh
@@ -8196,16 +8211,16 @@
8196
8211
  increasedLineWidthForHitTesting = _object$parsedStyle.increasedLineWidthForHitTesting;
8197
8212
  var fillColor = [0, 0, 0, 0];
8198
8213
  if (gLite.isCSSRGB(fill)) {
8199
- fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
8214
+ fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
8200
8215
  }
8201
8216
  var strokeColor = [0, 0, 0, 0];
8202
8217
  if (gLite.isCSSRGB(stroke)) {
8203
- strokeColor = [Number(stroke.r) / 255, Number(stroke.g) / 255, Number(stroke.b) / 255, Number(stroke.alpha)];
8218
+ strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
8204
8219
  }
8205
8220
  if (_this3.clipPathTarget) {
8206
8221
  // account for target's rts
8207
8222
  copy(modelMatrix, object.getLocalTransform());
8208
- fillColor = [1, 1, 1, 1];
8223
+ fillColor = [255, 255, 255, 255];
8209
8224
  mul(modelMatrix, _this3.clipPathTarget.getWorldTransform(), modelMatrix);
8210
8225
  } else {
8211
8226
  copy(modelMatrix, object.getWorldTransform());
@@ -8215,7 +8230,7 @@
8215
8230
  // @ts-ignore
8216
8231
  (_object$renderable3D = object.renderable3D) === null || _object$renderable3D === void 0 ? void 0 : _object$renderable3D.encodedPickingColor) || [0, 0, 0];
8217
8232
  packedModelMatrix.push.apply(packedModelMatrix, modelMatrix);
8218
- packedFillStroke.push.apply(packedFillStroke, fillColor.concat(strokeColor));
8233
+ packedFillStroke.push(packUint8ToFloat(fillColor[0], fillColor[1]), packUint8ToFloat(fillColor[2], fillColor[3]), packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(strokeColor[2], strokeColor[3]));
8219
8234
  packedStyle.push(opacity, fillOpacity, strokeOpacity, lineWidth, visibility === 'visible' ? 1 : 0, anchor[0], anchor[1], increasedLineWidthForHitTesting || 0);
8220
8235
  packedPicking.push.apply(packedPicking, encodedPickingColor.concat([object.sortable.renderOrder * RENDER_ORDER_SCALE]));
8221
8236
  // if (useNormal) {
@@ -8284,17 +8299,12 @@
8284
8299
  });
8285
8300
  this.geometry.setVertexBuffer({
8286
8301
  bufferIndex: VertexAttributeBufferIndex.FILL_STROKE,
8287
- byteStride: 4 * 8,
8302
+ byteStride: 4 * 4,
8288
8303
  frequency: VertexBufferFrequency.PerInstance,
8289
8304
  attributes: [{
8290
8305
  format: Format.F32_RGBA,
8291
8306
  bufferByteOffset: 4 * 0,
8292
- location: VertexAttributeLocation.COLOR,
8293
- divisor: 1
8294
- }, {
8295
- format: Format.F32_RGBA,
8296
- bufferByteOffset: 4 * 4,
8297
- location: VertexAttributeLocation.STROKE_COLOR,
8307
+ location: VertexAttributeLocation.PACKED_COLOR,
8298
8308
  divisor: 1
8299
8309
  }],
8300
8310
  data: new Float32Array(packedFillStroke)
@@ -8494,15 +8504,15 @@
8494
8504
  stroke = _object$parsedStyle2.stroke;
8495
8505
  var fillColor = [0, 0, 0, 0];
8496
8506
  if (gLite.isCSSRGB(fill)) {
8497
- fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
8507
+ fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
8498
8508
  }
8499
8509
  var strokeColor = [0, 0, 0, 0];
8500
8510
  if (gLite.isCSSRGB(stroke)) {
8501
- strokeColor = [Number(stroke.r) / 255, Number(stroke.g) / 255, Number(stroke.b) / 255, Number(stroke.alpha)];
8511
+ strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
8502
8512
  }
8503
- packedFillStroke.push.apply(packedFillStroke, fillColor.concat(strokeColor));
8513
+ packedFillStroke.push(packUint8ToFloat(fillColor[0], fillColor[1]), packUint8ToFloat(fillColor[2], fillColor[3]), packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(strokeColor[2], strokeColor[3]));
8504
8514
  });
8505
- this.geometry.updateVertexBuffer(VertexAttributeBufferIndex.FILL_STROKE, VertexAttributeLocation.COLOR, startIndex, new Uint8Array(new Float32Array(packedFillStroke).buffer));
8515
+ this.geometry.updateVertexBuffer(VertexAttributeBufferIndex.FILL_STROKE, VertexAttributeLocation.PACKED_COLOR, startIndex, new Uint8Array(new Float32Array(packedFillStroke).buffer));
8506
8516
  var fill = this.instance.parsedStyle.fill;
8507
8517
  var i = this.textureMappings.findIndex(function (m) {
8508
8518
  return m.name === FILL_TEXTURE_MAPPING;
@@ -8837,7 +8847,7 @@
8837
8847
  }();
8838
8848
  var frag = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, vec2 r) {\n vec2 q = abs(p) - b + r;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r.x;\n}\n\nvoid main() {\n int shape = int(floor(v_Data.w + 0.5));\n float epsilon = 0.000001;\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius;\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\n } else if (shape == 2) {\n outer_df = sdRoundedBox(v_Data.xy, vec2(1.0), vec2(0.0));\n inner_df = sdRoundedBox(v_Data.xy, r, vec2(0.0));\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}"; // eslint-disable-line
8839
8849
 
8840
- var vert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float antialiasblur = 1.0 / (a_Size.x + strokeWidth);\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * radius;\n\n bool isBillboard = a_StylePacked3.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4( 0.0, 0.0, u_ZIndex, 1.0 );\nvec2 scale;\nscale.x = length( vec3( u_ModelMatrix[ 0 ].x, u_ModelMatrix[ 0 ].y, u_ModelMatrix[ 0 ].z ) );\nscale.y = length( vec3( u_ModelMatrix[ 1 ].x, u_ModelMatrix[ 1 ].y, u_ModelMatrix[ 1 ].z ) );\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\n v_StylePacked3 = a_StylePacked3;\n}"; // eslint-disable-line
8850
+ var vert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float antialiasblur = 1.0 / (a_Size.x + strokeWidth);\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * radius;\n\n bool isBillboard = a_StylePacked3.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\n v_StylePacked3 = a_StylePacked3;\n}"; // eslint-disable-line
8841
8851
 
8842
8852
  var SDFVertexAttributeBufferIndex;
8843
8853
  (function (SDFVertexAttributeBufferIndex) {
@@ -8845,8 +8855,8 @@
8845
8855
  })(SDFVertexAttributeBufferIndex || (SDFVertexAttributeBufferIndex = {}));
8846
8856
  var SDFVertexAttributeLocation;
8847
8857
  (function (SDFVertexAttributeLocation) {
8848
- SDFVertexAttributeLocation[SDFVertexAttributeLocation["PACKED_STYLE3"] = 13] = "PACKED_STYLE3";
8849
- SDFVertexAttributeLocation[SDFVertexAttributeLocation["SIZE"] = 14] = "SIZE";
8858
+ SDFVertexAttributeLocation[SDFVertexAttributeLocation["PACKED_STYLE3"] = 12] = "PACKED_STYLE3";
8859
+ SDFVertexAttributeLocation[SDFVertexAttributeLocation["SIZE"] = 13] = "SIZE";
8850
8860
  })(SDFVertexAttributeLocation || (SDFVertexAttributeLocation = {}));
8851
8861
  var SDF_Shape = [gLite.Shape.CIRCLE, gLite.Shape.ELLIPSE, gLite.Shape.RECT];
8852
8862
  /**
@@ -8993,7 +9003,7 @@
8993
9003
  }(Instanced);
8994
9004
  var frag$1 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * blur\n * u_Opacity * u_StrokeOpacity\n * ceil(mod(v_Dash.x + u_dash_offset, u_dash_array) - (u_dash_array * u_dash_ratio));\n }\n}"; // eslint-disable-line
8995
9005
 
8996
- var vert$1 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float isBillboard = a_Dash.w;\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n if (isBillboard > 0.5 && isPerspective) {\n // clip space\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * strokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(strokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}"; // eslint-disable-line
9006
+ var vert$1 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float isBillboard = a_Dash.w;\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n if (isBillboard > 0.5 && isPerspective) {\n // clip space\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * strokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(strokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}"; // eslint-disable-line
8997
9007
 
8998
9008
  var segmentInstanceGeometry = [0, -0.5, 0, 0, 0, 1, -0.5, 1, 1, 0, 1, 0.5, 1, 1, 1, 0, 0.5, 0, 0, 1];
8999
9009
  var InstancedLineVertexAttributeBufferIndex;
@@ -9004,12 +9014,12 @@
9004
9014
  })(InstancedLineVertexAttributeBufferIndex || (InstancedLineVertexAttributeBufferIndex = {}));
9005
9015
  var InstancedLineVertexAttributeLocation;
9006
9016
  (function (InstancedLineVertexAttributeLocation) {
9007
- InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POSITION"] = 9] = "POSITION";
9008
- InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["UV"] = 11] = "UV";
9009
- InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTA"] = 10] = "POINTA";
9010
- InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTB"] = 12] = "POINTB";
9011
- InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["CAP"] = 13] = "CAP";
9012
- InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["DASH"] = 14] = "DASH";
9017
+ InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POSITION"] = 8] = "POSITION";
9018
+ InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["UV"] = 10] = "UV";
9019
+ InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTA"] = 9] = "POINTA";
9020
+ InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTB"] = 11] = "POINTB";
9021
+ InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["CAP"] = 12] = "CAP";
9022
+ InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["DASH"] = 13] = "DASH";
9013
9023
  })(InstancedLineVertexAttributeLocation || (InstancedLineVertexAttributeLocation = {}));
9014
9024
  var LineCap_MAP = {
9015
9025
  butt: 1,
@@ -9856,7 +9866,9 @@
9856
9866
  // $offscreenCanvas.height = height * dpr;
9857
9867
  $offscreenCanvas.width = size;
9858
9868
  $offscreenCanvas.height = size;
9859
- var ctx = gLite.runtime.offscreenCanvas.getOrCreateContext(canvas);
9869
+ var ctx = gLite.runtime.offscreenCanvas.getOrCreateContext(canvas, {
9870
+ willReadFrequently: true
9871
+ });
9860
9872
  this.ctx = ctx;
9861
9873
  // const ctx = (this.ctx = canvas.getContext('2d', {
9862
9874
  // willReadFrequently: true,
@@ -10694,9 +10706,9 @@
10694
10706
  };
10695
10707
  return FillMesh;
10696
10708
  }(Instanced);
10697
- var frag$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n }\n}"; // eslint-disable-line
10709
+ var frag$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n }\n}"; // eslint-disable-line
10698
10710
 
10699
- var vert$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec4 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nbool isPerspectiveMatrix(mat4 m) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size.xy;\n\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n bool isBillboard = a_Size.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4( 0.0, 0.0, u_ZIndex, 1.0 );\nvec2 scale;\nscale.x = length( vec3( u_ModelMatrix[ 0 ].x, u_ModelMatrix[ 0 ].y, u_ModelMatrix[ 0 ].z ) );\nscale.y = length( vec3( u_ModelMatrix[ 1 ].x, u_ModelMatrix[ 1 ].y, u_ModelMatrix[ 1 ].z ) );\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}"; // eslint-disable-line
10711
+ var vert$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec4 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nbool isPerspectiveMatrix(mat4 m) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size.xy;\n\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n bool isBillboard = a_Size.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}"; // eslint-disable-line
10700
10712
 
10701
10713
  var ImageMesh = /*#__PURE__*/function (_Instanced) {
10702
10714
  _inheritsLoose$1(ImageMesh, _Instanced);
@@ -10794,7 +10806,7 @@
10794
10806
  }(Instanced);
10795
10807
  var frag$4 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nin float v_GammaScale;\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float EDGE_GAMMA = 0.105 / u_DevicePixelRatio;\n float fontScale = u_FontSize / 24.0;\n highp float gamma = EDGE_GAMMA / (fontScale * u_GammaScale);\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n gamma = (u_StrokeBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_GammaScale);\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = gamma * v_GammaScale;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < 0.001) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}"; // eslint-disable-line
10796
10808
 
10797
- var vert$4 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\nout float v_GammaScale;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n float sizeAttenuation = a_StylePacked2.z;\n vec2 offset = a_Offset * fontScale;\n\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4( 0.0, 0.0, u_ZIndex, 1.0 );\nvec2 scale;\nscale.x = length( vec3( u_ModelMatrix[ 0 ].x, u_ModelMatrix[ 0 ].y, u_ModelMatrix[ 0 ].z ) );\nscale.y = length( vec3( u_ModelMatrix[ 1 ].x, u_ModelMatrix[ 1 ].y, u_ModelMatrix[ 1 ].z ) );\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n v_GammaScale = 1.0;\n } else {\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\n }\n}"; // eslint-disable-line
10809
+ var vert$4 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\nout float v_GammaScale;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n float sizeAttenuation = a_StylePacked2.z;\n vec2 offset = a_Offset * fontScale;\n\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n v_GammaScale = 1.0;\n } else {\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\n }\n}"; // eslint-disable-line
10798
10810
 
10799
10811
  // borrow from mapbox/src/symbol
10800
10812
  function createImage(image, _ref, channels, data) {
@@ -11256,8 +11268,8 @@
11256
11268
  })(TextVertexAttributeBufferIndex || (TextVertexAttributeBufferIndex = {}));
11257
11269
  var TextVertexAttributeLocation;
11258
11270
  (function (TextVertexAttributeLocation) {
11259
- TextVertexAttributeLocation[TextVertexAttributeLocation["TEX"] = 13] = "TEX";
11260
- TextVertexAttributeLocation[TextVertexAttributeLocation["OFFSET"] = 14] = "OFFSET";
11271
+ TextVertexAttributeLocation[TextVertexAttributeLocation["TEX"] = 12] = "TEX";
11272
+ TextVertexAttributeLocation[TextVertexAttributeLocation["OFFSET"] = 13] = "OFFSET";
11261
11273
  })(TextVertexAttributeLocation || (TextVertexAttributeLocation = {}));
11262
11274
  var TextUniform;
11263
11275
  (function (TextUniform) {
@@ -11370,7 +11382,7 @@
11370
11382
  this.geometry.setIndexBuffer(new Uint32Array(indices));
11371
11383
  this.geometry.setVertexBuffer({
11372
11384
  bufferIndex: TextVertexAttributeBufferIndex.INSTANCED,
11373
- byteStride: 4 * (4 * 4 + 4 + 4 + 4 + 4 + 4),
11385
+ byteStride: 4 * (4 * 4 + 4 + 4 + 4 + 4),
11374
11386
  // frequency: VertexBufferFrequency.PerInstance,
11375
11387
  frequency: VertexBufferFrequency.PerVertex,
11376
11388
  attributes: [{
@@ -11400,30 +11412,24 @@
11400
11412
  }, {
11401
11413
  format: Format.F32_RGBA,
11402
11414
  bufferByteOffset: 4 * 16,
11403
- location: VertexAttributeLocation.COLOR
11415
+ location: VertexAttributeLocation.PACKED_COLOR
11404
11416
  // byteStride: 4 * 4,
11405
11417
  // divisor: 1,
11406
11418
  }, {
11407
11419
  format: Format.F32_RGBA,
11408
11420
  bufferByteOffset: 4 * 20,
11409
- location: VertexAttributeLocation.STROKE_COLOR
11410
- // byteStride: 4 * 4,
11411
- // divisor: 1,
11412
- }, {
11413
- format: Format.F32_RGBA,
11414
- bufferByteOffset: 4 * 24,
11415
11421
  location: VertexAttributeLocation.PACKED_STYLE1
11416
11422
  // byteStride: 4 * 4,
11417
11423
  // divisor: 1,
11418
11424
  }, {
11419
11425
  format: Format.F32_RGBA,
11420
- bufferByteOffset: 4 * 28,
11426
+ bufferByteOffset: 4 * 24,
11421
11427
  location: VertexAttributeLocation.PACKED_STYLE2
11422
11428
  // byteStride: 4 * 4,
11423
11429
  // divisor: 1,
11424
11430
  }, {
11425
11431
  format: Format.F32_RGBA,
11426
- bufferByteOffset: 4 * 32,
11432
+ bufferByteOffset: 4 * 28,
11427
11433
  location: VertexAttributeLocation.PICKING_COLOR
11428
11434
  // byteStride: 4 * 4,
11429
11435
  // divisor: 1,
@@ -11513,11 +11519,11 @@
11513
11519
  sizeAttenuation = _object$parsedStyle4.sizeAttenuation;
11514
11520
  var fillColor = [0, 0, 0, 0];
11515
11521
  if (gLite.isCSSRGB(fill)) {
11516
- fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
11522
+ fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
11517
11523
  }
11518
11524
  var strokeColor = [0, 0, 0, 0];
11519
11525
  if (gLite.isCSSRGB(stroke)) {
11520
- strokeColor = [Number(stroke.r) / 255, Number(stroke.g) / 255, Number(stroke.b) / 255, Number(stroke.alpha)];
11526
+ strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
11521
11527
  }
11522
11528
  var encodedPickingColor = object.isInteractive() && (
11523
11529
  // @ts-ignore
@@ -11546,27 +11552,23 @@
11546
11552
  sliced[i + 14] = modelMatrix[14];
11547
11553
  sliced[i + 15] = modelMatrix[15];
11548
11554
  } else if (name === 'fill') {
11549
- sliced[i + 16] = fillColor[0];
11550
- sliced[i + 17] = fillColor[1];
11551
- sliced[i + 18] = fillColor[2];
11552
- sliced[i + 19] = fillColor[3];
11555
+ sliced[i + 16] = packUint8ToFloat(fillColor[0], fillColor[1]);
11556
+ sliced[i + 17] = packUint8ToFloat(fillColor[2], fillColor[3]);
11553
11557
  } else if (name === 'stroke') {
11554
- sliced[i + 20] = strokeColor[0];
11555
- sliced[i + 21] = strokeColor[1];
11556
- sliced[i + 22] = strokeColor[2];
11557
- sliced[i + 23] = strokeColor[3];
11558
+ sliced[i + 18] = packUint8ToFloat(strokeColor[0], strokeColor[1]);
11559
+ sliced[i + 19] = packUint8ToFloat(strokeColor[2], strokeColor[3]);
11558
11560
  }
11559
- sliced[i + 24] = opacity;
11560
- sliced[i + 25] = fillOpacity;
11561
- sliced[i + 26] = strokeOpacity;
11562
- sliced[i + 27] = lineWidth;
11563
- sliced[i + 28] = visibility === 'visible' ? 1 : 0;
11564
- sliced[i + 29] = isBillboard ? 1 : 0;
11565
- sliced[i + 30] = sizeAttenuation ? 1 : 0;
11566
- sliced[i + 31] = 0;
11567
- sliced[i + 32] = encodedPickingColor[0];
11568
- sliced[i + 33] = encodedPickingColor[1];
11569
- sliced[i + 34] = encodedPickingColor[2];
11561
+ sliced[i + 20] = opacity;
11562
+ sliced[i + 21] = fillOpacity;
11563
+ sliced[i + 22] = strokeOpacity;
11564
+ sliced[i + 23] = lineWidth;
11565
+ sliced[i + 24] = visibility === 'visible' ? 1 : 0;
11566
+ sliced[i + 25] = isBillboard ? 1 : 0;
11567
+ sliced[i + 26] = sizeAttenuation ? 1 : 0;
11568
+ sliced[i + 27] = 0;
11569
+ sliced[i + 28] = encodedPickingColor[0];
11570
+ sliced[i + 29] = encodedPickingColor[1];
11571
+ sliced[i + 30] = encodedPickingColor[2];
11570
11572
  }
11571
11573
  _this3.geometry.updateVertexBuffer(TextVertexAttributeBufferIndex.INSTANCED, VertexAttributeLocation.MODEL_MATRIX0, start / bytes, new Uint8Array(sliced.buffer));
11572
11574
  });
@@ -11596,11 +11598,11 @@
11596
11598
  sizeAttenuation = _object$parsedStyle5.sizeAttenuation;
11597
11599
  var fillColor = [0, 0, 0, 0];
11598
11600
  if (gLite.isCSSRGB(fill)) {
11599
- fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
11601
+ fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
11600
11602
  }
11601
11603
  var strokeColor = [0, 0, 0, 0];
11602
11604
  if (gLite.isCSSRGB(stroke)) {
11603
- strokeColor = [Number(stroke.r) / 255, Number(stroke.g) / 255, Number(stroke.b) / 255, Number(stroke.alpha)];
11605
+ strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
11604
11606
  }
11605
11607
  var encodedPickingColor = object.isInteractive() && (
11606
11608
  // @ts-ignore
@@ -11617,7 +11619,7 @@
11617
11619
  // rollup will use `concat`
11618
11620
  var temp = [];
11619
11621
  temp.push.apply(temp, modelMatrix);
11620
- var packed = [].concat(temp, fillColor, strokeColor, [opacity, fillOpacity, strokeOpacity, lineWidth, visibility === 'visible' ? 1 : 0, isBillboard ? 1 : 0, sizeAttenuation ? 1 : 0, 0], encodedPickingColor, [object.sortable.renderOrder * RENDER_ORDER_SCALE]);
11622
+ var packed = [].concat(temp, [packUint8ToFloat(fillColor[0], fillColor[1]), packUint8ToFloat(fillColor[2], fillColor[3]), packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(strokeColor[2], strokeColor[3]), opacity, fillOpacity, strokeOpacity, lineWidth, visibility === 'visible' ? 1 : 0, isBillboard ? 1 : 0, sizeAttenuation ? 1 : 0, 0], encodedPickingColor, [object.sortable.renderOrder * RENDER_ORDER_SCALE]);
11621
11623
  // FIXME: instanced
11622
11624
  charPackedBuffer.push.apply(charPackedBuffer, packed.concat(packed, packed, packed));
11623
11625
  // interleaved uv & offsets
@@ -12558,7 +12560,6 @@
12558
12560
  get GL () { return GL; },
12559
12561
  get GeometryEvent () { return GeometryEvent; },
12560
12562
  HashMap: HashMap,
12561
- IdentityViewportCoords: IdentityViewportCoords,
12562
12563
  ImageMesh: ImageMesh,
12563
12564
  Instanced: Instanced,
12564
12565
  InstancedLineMesh: InstancedLineMesh,
@@ -12729,1493 +12730,484 @@
12729
12730
  vertexAttributeDescriptorEquals: vertexAttributeDescriptorEquals
12730
12731
  });
12731
12732
 
12732
- function _regeneratorRuntime$2() {
12733
- _regeneratorRuntime$2 = function _regeneratorRuntime() {
12734
- return exports;
12733
+ function _inheritsLoose$2(subClass, superClass) {
12734
+ subClass.prototype = Object.create(superClass.prototype);
12735
+ subClass.prototype.constructor = subClass;
12736
+ _setPrototypeOf$2(subClass, superClass);
12737
+ }
12738
+ function _setPrototypeOf$2(o, p) {
12739
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
12740
+ o.__proto__ = p;
12741
+ return o;
12735
12742
  };
12736
- var exports = {},
12737
- Op = Object.prototype,
12738
- hasOwn = Op.hasOwnProperty,
12739
- defineProperty = Object.defineProperty || function (obj, key, desc) {
12740
- obj[key] = desc.value;
12741
- },
12742
- $Symbol = "function" == typeof Symbol ? Symbol : {},
12743
- iteratorSymbol = $Symbol.iterator || "@@iterator",
12744
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
12745
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
12746
- function define(obj, key, value) {
12747
- return Object.defineProperty(obj, key, {
12748
- value: value,
12749
- enumerable: !0,
12750
- configurable: !0,
12751
- writable: !0
12752
- }), obj[key];
12743
+ return _setPrototypeOf$2(o, p);
12744
+ }
12745
+
12746
+ // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
12747
+ /**
12748
+ * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
12749
+ */
12750
+ var DOMInteractionPlugin = /*#__PURE__*/function () {
12751
+ function DOMInteractionPlugin() {
12752
+ this.context = void 0;
12753
12753
  }
12754
- try {
12755
- define({}, "");
12756
- } catch (err) {
12757
- define = function define(obj, key, value) {
12758
- return obj[key] = value;
12754
+ var _proto = DOMInteractionPlugin.prototype;
12755
+ _proto.apply = function apply(context, runtime) {
12756
+ var _this = this;
12757
+ var renderingService = context.renderingService,
12758
+ renderingContext = context.renderingContext,
12759
+ config = context.config;
12760
+ this.context = context;
12761
+ var canvas = renderingContext.root.ownerDocument.defaultView;
12762
+ // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
12763
+ var onPointerMove = function onPointerMove(ev) {
12764
+ renderingService.hooks.pointerMove.call(ev);
12759
12765
  };
12760
- }
12761
- function wrap(innerFn, outerFn, self, tryLocsList) {
12762
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
12763
- generator = Object.create(protoGenerator.prototype),
12764
- context = new Context(tryLocsList || []);
12765
- return defineProperty(generator, "_invoke", {
12766
- value: makeInvokeMethod(innerFn, self, context)
12767
- }), generator;
12768
- }
12769
- function tryCatch(fn, obj, arg) {
12770
- try {
12771
- return {
12772
- type: "normal",
12773
- arg: fn.call(obj, arg)
12774
- };
12775
- } catch (err) {
12776
- return {
12777
- type: "throw",
12778
- arg: err
12779
- };
12780
- }
12781
- }
12782
- exports.wrap = wrap;
12783
- var ContinueSentinel = {};
12784
- function Generator() {}
12785
- function GeneratorFunction() {}
12786
- function GeneratorFunctionPrototype() {}
12787
- var IteratorPrototype = {};
12788
- define(IteratorPrototype, iteratorSymbol, function () {
12789
- return this;
12790
- });
12791
- var getProto = Object.getPrototypeOf,
12792
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
12793
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
12794
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
12795
- function defineIteratorMethods(prototype) {
12796
- ["next", "throw", "return"].forEach(function (method) {
12797
- define(prototype, method, function (arg) {
12798
- return this._invoke(method, arg);
12799
- });
12800
- });
12801
- }
12802
- function AsyncIterator(generator, PromiseImpl) {
12803
- function invoke(method, arg, resolve, reject) {
12804
- var record = tryCatch(generator[method], generator, arg);
12805
- if ("throw" !== record.type) {
12806
- var result = record.arg,
12807
- value = result.value;
12808
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
12809
- invoke("next", value, resolve, reject);
12810
- }, function (err) {
12811
- invoke("throw", err, resolve, reject);
12812
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
12813
- result.value = unwrapped, resolve(result);
12814
- }, function (error) {
12815
- return invoke("throw", error, resolve, reject);
12816
- });
12766
+ var onPointerUp = function onPointerUp(ev) {
12767
+ renderingService.hooks.pointerUp.call(ev);
12768
+ };
12769
+ var onPointerDown = function onPointerDown(ev) {
12770
+ renderingService.hooks.pointerDown.call(ev);
12771
+ };
12772
+ var onPointerOver = function onPointerOver(ev) {
12773
+ renderingService.hooks.pointerOver.call(ev);
12774
+ };
12775
+ var onPointerOut = function onPointerOut(ev) {
12776
+ renderingService.hooks.pointerOut.call(ev);
12777
+ };
12778
+ var onPointerCancel = function onPointerCancel(ev) {
12779
+ renderingService.hooks.pointerCancel.call(ev);
12780
+ };
12781
+ var onPointerWheel = function onPointerWheel(ev) {
12782
+ renderingService.hooks.pointerWheel.call(ev);
12783
+ };
12784
+ var onClick = function onClick(ev) {
12785
+ renderingService.hooks.click.call(ev);
12786
+ };
12787
+ var addPointerEventListener = function addPointerEventListener($el) {
12788
+ runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
12789
+ $el.addEventListener('pointerdown', onPointerDown, true);
12790
+ $el.addEventListener('pointerleave', onPointerOut, true);
12791
+ $el.addEventListener('pointerover', onPointerOver, true);
12792
+ runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
12793
+ runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true);
12794
+ };
12795
+ var addTouchEventListener = function addTouchEventListener($el) {
12796
+ $el.addEventListener('touchstart', onPointerDown, true);
12797
+ $el.addEventListener('touchend', onPointerUp, true);
12798
+ $el.addEventListener('touchmove', onPointerMove, true);
12799
+ $el.addEventListener('touchcancel', onPointerCancel, true);
12800
+ };
12801
+ var addMouseEventListener = function addMouseEventListener($el) {
12802
+ runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
12803
+ $el.addEventListener('mousedown', onPointerDown, true);
12804
+ $el.addEventListener('mouseout', onPointerOut, true);
12805
+ $el.addEventListener('mouseover', onPointerOver, true);
12806
+ runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
12807
+ };
12808
+ var removePointerEventListener = function removePointerEventListener($el) {
12809
+ runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
12810
+ $el.removeEventListener('pointerdown', onPointerDown, true);
12811
+ $el.removeEventListener('pointerleave', onPointerOut, true);
12812
+ $el.removeEventListener('pointerover', onPointerOver, true);
12813
+ runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
12814
+ };
12815
+ var removeTouchEventListener = function removeTouchEventListener($el) {
12816
+ $el.removeEventListener('touchstart', onPointerDown, true);
12817
+ $el.removeEventListener('touchend', onPointerUp, true);
12818
+ $el.removeEventListener('touchmove', onPointerMove, true);
12819
+ $el.removeEventListener('touchcancel', onPointerCancel, true);
12820
+ };
12821
+ var removeMouseEventListener = function removeMouseEventListener($el) {
12822
+ runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
12823
+ $el.removeEventListener('mousedown', onPointerDown, true);
12824
+ $el.removeEventListener('mouseout', onPointerOut, true);
12825
+ $el.removeEventListener('mouseover', onPointerOver, true);
12826
+ runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
12827
+ };
12828
+ renderingService.hooks.init.tap(DOMInteractionPlugin.tag, function () {
12829
+ var $el = _this.context.contextService.getDomElement();
12830
+ // @ts-ignore
12831
+ if (runtime.globalThis.navigator.msPointerEnabled) {
12832
+ // @ts-ignore
12833
+ $el.style.msContentZooming = 'none';
12834
+ // @ts-ignore
12835
+ $el.style.msTouchAction = 'none';
12836
+ } else if (canvas.supportsPointerEvents) {
12837
+ $el.style.touchAction = 'none';
12817
12838
  }
12818
- reject(record.arg);
12819
- }
12820
- var previousPromise;
12821
- defineProperty(this, "_invoke", {
12822
- value: function value(method, arg) {
12823
- function callInvokeWithMethodAndArg() {
12824
- return new PromiseImpl(function (resolve, reject) {
12825
- invoke(method, arg, resolve, reject);
12826
- });
12827
- }
12828
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
12839
+ if (canvas.supportsPointerEvents) {
12840
+ addPointerEventListener($el);
12841
+ } else {
12842
+ addMouseEventListener($el);
12843
+ }
12844
+ if (canvas.supportsTouchEvents) {
12845
+ addTouchEventListener($el);
12846
+ }
12847
+ if (config.useNativeClickEvent) {
12848
+ $el.addEventListener('click', onClick, true);
12829
12849
  }
12850
+ // use passive event listeners
12851
+ // @see https://zhuanlan.zhihu.com/p/24555031
12852
+ $el.addEventListener('wheel', onPointerWheel, {
12853
+ passive: true,
12854
+ capture: true
12855
+ });
12830
12856
  });
12831
- }
12832
- function makeInvokeMethod(innerFn, self, context) {
12833
- var state = "suspendedStart";
12834
- return function (method, arg) {
12835
- if ("executing" === state) throw new Error("Generator is already running");
12836
- if ("completed" === state) {
12837
- if ("throw" === method) throw arg;
12838
- return doneResult();
12857
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
12858
+ var $el = _this.context.contextService.getDomElement();
12859
+ // @ts-ignore
12860
+ if (runtime.globalThis.navigator.msPointerEnabled) {
12861
+ // @ts-ignore
12862
+ $el.style.msContentZooming = '';
12863
+ // @ts-ignore
12864
+ $el.style.msTouchAction = '';
12865
+ } else if (canvas.supportsPointerEvents) {
12866
+ $el.style.touchAction = '';
12839
12867
  }
12840
- for (context.method = method, context.arg = arg;;) {
12841
- var delegate = context.delegate;
12842
- if (delegate) {
12843
- var delegateResult = maybeInvokeDelegate(delegate, context);
12844
- if (delegateResult) {
12845
- if (delegateResult === ContinueSentinel) continue;
12846
- return delegateResult;
12847
- }
12848
- }
12849
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
12850
- if ("suspendedStart" === state) throw state = "completed", context.arg;
12851
- context.dispatchException(context.arg);
12852
- } else "return" === context.method && context.abrupt("return", context.arg);
12853
- state = "executing";
12854
- var record = tryCatch(innerFn, self, context);
12855
- if ("normal" === record.type) {
12856
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
12857
- return {
12858
- value: record.arg,
12859
- done: context.done
12860
- };
12861
- }
12862
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
12868
+ if (canvas.supportsPointerEvents) {
12869
+ removePointerEventListener($el);
12870
+ } else {
12871
+ removeMouseEventListener($el);
12863
12872
  }
12864
- };
12873
+ if (canvas.supportsTouchEvents) {
12874
+ removeTouchEventListener($el);
12875
+ }
12876
+ if (config.useNativeClickEvent) {
12877
+ $el.removeEventListener('click', onClick, true);
12878
+ }
12879
+ $el.removeEventListener('wheel', onPointerWheel, true);
12880
+ });
12881
+ };
12882
+ return DOMInteractionPlugin;
12883
+ }();
12884
+ DOMInteractionPlugin.tag = 'DOMInteraction';
12885
+ var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
12886
+ _inheritsLoose$2(Plugin, _AbstractRendererPlug);
12887
+ function Plugin() {
12888
+ var _this;
12889
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12890
+ args[_key] = arguments[_key];
12891
+ }
12892
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
12893
+ _this.name = 'dom-interaction';
12894
+ return _this;
12865
12895
  }
12866
- function maybeInvokeDelegate(delegate, context) {
12867
- var methodName = context.method,
12868
- method = delegate.iterator[methodName];
12869
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
12870
- var record = tryCatch(method, delegate.iterator, context.arg);
12871
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
12872
- var info = record.arg;
12873
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
12896
+ var _proto = Plugin.prototype;
12897
+ _proto.init = function init() {
12898
+ this.addRenderingPlugin(new DOMInteractionPlugin());
12899
+ };
12900
+ _proto.destroy = function destroy() {
12901
+ this.removeAllRenderingPlugins();
12902
+ };
12903
+ return Plugin;
12904
+ }(gLite.AbstractRendererPlugin);
12905
+
12906
+ var index_esm$1 = /*#__PURE__*/Object.freeze({
12907
+ __proto__: null,
12908
+ Plugin: Plugin$1
12909
+ });
12910
+
12911
+ function _inheritsLoose$3(subClass, superClass) {
12912
+ subClass.prototype = Object.create(superClass.prototype);
12913
+ subClass.prototype.constructor = subClass;
12914
+ _setPrototypeOf$3(subClass, superClass);
12915
+ }
12916
+ function _setPrototypeOf$3(o, p) {
12917
+ _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
12918
+ o.__proto__ = p;
12919
+ return o;
12920
+ };
12921
+ return _setPrototypeOf$3(o, p);
12922
+ }
12923
+ var HTML_PREFIX = 'g-html-';
12924
+ var CANVAS_CAMERA_ID = 'g-canvas-camera';
12925
+ var HTMLRenderingPlugin = /*#__PURE__*/function () {
12926
+ function HTMLRenderingPlugin() {
12927
+ this.context = void 0;
12928
+ /**
12929
+ * wrapper for camera
12930
+ */
12931
+ this.$camera = void 0;
12874
12932
  }
12875
- function pushTryEntry(locs) {
12876
- var entry = {
12877
- tryLoc: locs[0]
12933
+ var _proto = HTMLRenderingPlugin.prototype;
12934
+ _proto.joinTransformMatrix = function joinTransformMatrix(matrix) {
12935
+ return "matrix(" + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(',') + ")";
12936
+ };
12937
+ _proto.apply = function apply(context) {
12938
+ var _this = this;
12939
+ var camera = context.camera,
12940
+ renderingContext = context.renderingContext,
12941
+ renderingService = context.renderingService;
12942
+ this.context = context;
12943
+ var canvas = renderingContext.root.ownerDocument.defaultView;
12944
+ var setTransform = function setTransform(object, $el) {
12945
+ $el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
12878
12946
  };
12879
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
12880
- }
12881
- function resetTryEntry(entry) {
12882
- var record = entry.completion || {};
12883
- record.type = "normal", delete record.arg, entry.completion = record;
12884
- }
12885
- function Context(tryLocsList) {
12886
- this.tryEntries = [{
12887
- tryLoc: "root"
12888
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
12889
- }
12890
- function values(iterable) {
12891
- if (iterable) {
12892
- var iteratorMethod = iterable[iteratorSymbol];
12893
- if (iteratorMethod) return iteratorMethod.call(iterable);
12894
- if ("function" == typeof iterable.next) return iterable;
12895
- if (!isNaN(iterable.length)) {
12896
- var i = -1,
12897
- next = function next() {
12898
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
12899
- return next.value = undefined, next.done = !0, next;
12900
- };
12901
- return next.next = next;
12947
+ var handleMounted = function handleMounted(e) {
12948
+ var object = e.target;
12949
+ if (object.nodeName === gLite.Shape.HTML) {
12950
+ if (!_this.$camera) {
12951
+ _this.$camera = _this.createCamera(camera);
12952
+ }
12953
+ // create DOM element
12954
+ var $el = _this.getOrCreateEl(object);
12955
+ _this.$camera.appendChild($el);
12956
+ // apply documentElement's style
12957
+ var attributes = object.ownerDocument.documentElement.attributes;
12958
+ Object.keys(attributes).forEach(function (name) {
12959
+ $el.style[name] = attributes[name];
12960
+ });
12961
+ Object.keys(object.attributes).forEach(function (name) {
12962
+ _this.updateAttribute(name, object);
12963
+ });
12964
+ setTransform(object, $el);
12965
+ gLite.runtime.nativeHTMLMap.set($el, object);
12902
12966
  }
12903
- }
12904
- return {
12905
- next: doneResult
12906
- };
12907
- }
12908
- function doneResult() {
12909
- return {
12910
- value: undefined,
12911
- done: !0
12912
12967
  };
12913
- }
12914
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
12915
- value: GeneratorFunctionPrototype,
12916
- configurable: !0
12917
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
12918
- value: GeneratorFunction,
12919
- configurable: !0
12920
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
12921
- var ctor = "function" == typeof genFun && genFun.constructor;
12922
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
12923
- }, exports.mark = function (genFun) {
12924
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
12925
- }, exports.awrap = function (arg) {
12926
- return {
12927
- __await: arg
12968
+ var handleUnmounted = function handleUnmounted(e) {
12969
+ var object = e.target;
12970
+ if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
12971
+ var $el = _this.getOrCreateEl(object);
12972
+ if ($el) {
12973
+ $el.remove();
12974
+ gLite.runtime.nativeHTMLMap.delete($el);
12975
+ }
12976
+ // const existedId = this.getId(object);
12977
+ // const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
12978
+ // if ($existedElement) {
12979
+ // this.$camera.removeChild($existedElement);
12980
+ // }
12981
+ }
12928
12982
  };
12929
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
12930
- return this;
12931
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
12932
- void 0 === PromiseImpl && (PromiseImpl = Promise);
12933
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
12934
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
12935
- return result.done ? result.value : iter.next();
12936
- });
12937
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
12938
- return this;
12939
- }), define(Gp, "toString", function () {
12940
- return "[object Generator]";
12941
- }), exports.keys = function (val) {
12942
- var object = Object(val),
12943
- keys = [];
12944
- for (var key in object) keys.push(key);
12945
- return keys.reverse(), function next() {
12946
- for (; keys.length;) {
12947
- var key = keys.pop();
12948
- if (key in object) return next.value = key, next.done = !1, next;
12983
+
12984
+ var handleAttributeChanged = function handleAttributeChanged(e) {
12985
+ var object = e.target;
12986
+ if (object.nodeName === gLite.Shape.HTML) {
12987
+ var attrName = e.attrName;
12988
+ _this.updateAttribute(attrName, object);
12949
12989
  }
12950
- return next.done = !0, next;
12951
12990
  };
12952
- }, exports.values = values, Context.prototype = {
12953
- constructor: Context,
12954
- reset: function reset(skipTempReset) {
12955
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
12956
- },
12957
- stop: function stop() {
12958
- this.done = !0;
12959
- var rootRecord = this.tryEntries[0].completion;
12960
- if ("throw" === rootRecord.type) throw rootRecord.arg;
12961
- return this.rval;
12962
- },
12963
- dispatchException: function dispatchException(exception) {
12964
- if (this.done) throw exception;
12965
- var context = this;
12966
- function handle(loc, caught) {
12967
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
12991
+ var handleBoundsChanged = function handleBoundsChanged(e) {
12992
+ var object = e.target;
12993
+ if (object.nodeName === gLite.Shape.HTML) {
12994
+ var $el = _this.getOrCreateEl(object);
12995
+ setTransform(object, $el);
12968
12996
  }
12969
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
12970
- var entry = this.tryEntries[i],
12971
- record = entry.completion;
12972
- if ("root" === entry.tryLoc) return handle("end");
12973
- if (entry.tryLoc <= this.prev) {
12974
- var hasCatch = hasOwn.call(entry, "catchLoc"),
12975
- hasFinally = hasOwn.call(entry, "finallyLoc");
12976
- if (hasCatch && hasFinally) {
12977
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
12978
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
12979
- } else if (hasCatch) {
12980
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
12981
- } else {
12982
- if (!hasFinally) throw new Error("try statement without catch or finally");
12983
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
12984
- }
12985
- }
12997
+ };
12998
+ var handleCanvasResize = function handleCanvasResize() {
12999
+ if (_this.$camera) {
13000
+ var _this$context$config = _this.context.config,
13001
+ width = _this$context$config.width,
13002
+ height = _this$context$config.height;
13003
+ _this.$camera.style.width = (width || 0) + "px";
13004
+ _this.$camera.style.height = (height || 0) + "px";
12986
13005
  }
12987
- },
12988
- abrupt: function abrupt(type, arg) {
12989
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
12990
- var entry = this.tryEntries[i];
12991
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
12992
- var finallyEntry = entry;
12993
- break;
12994
- }
13006
+ };
13007
+ renderingService.hooks.init.tap(HTMLRenderingPlugin.tag, function () {
13008
+ canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13009
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13010
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13011
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13012
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13013
+ });
13014
+ renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
13015
+ if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
13016
+ _this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
12995
13017
  }
12996
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
12997
- var record = finallyEntry ? finallyEntry.completion : {};
12998
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
12999
- },
13000
- complete: function complete(record, afterLoc) {
13001
- if ("throw" === record.type) throw record.arg;
13002
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
13003
- },
13004
- finish: function finish(finallyLoc) {
13005
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13006
- var entry = this.tryEntries[i];
13007
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
13018
+ });
13019
+ renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
13020
+ // remove camera
13021
+ if (_this.$camera) {
13022
+ _this.$camera.remove();
13008
13023
  }
13009
- },
13010
- catch: function _catch(tryLoc) {
13011
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13012
- var entry = this.tryEntries[i];
13013
- if (entry.tryLoc === tryLoc) {
13014
- var record = entry.completion;
13015
- if ("throw" === record.type) {
13016
- var thrown = record.arg;
13017
- resetTryEntry(entry);
13018
- }
13019
- return thrown;
13020
- }
13024
+ canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13025
+ canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13026
+ canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13027
+ canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13028
+ canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13029
+ });
13030
+ };
13031
+ _proto.getId = function getId(object) {
13032
+ return object.id || HTML_PREFIX + object.entity;
13033
+ };
13034
+ _proto.createCamera = function createCamera(camera) {
13035
+ var _this$context$config2 = this.context.config,
13036
+ doc = _this$context$config2.document,
13037
+ width = _this$context$config2.width,
13038
+ height = _this$context$config2.height;
13039
+ var $canvas = this.context.contextService.getDomElement();
13040
+ var $container = $canvas.parentNode;
13041
+ if ($container) {
13042
+ var cameraId = CANVAS_CAMERA_ID;
13043
+ var $existedCamera = $container.querySelector('#' + cameraId);
13044
+ if (!$existedCamera) {
13045
+ var $camera = (doc || document).createElement('div');
13046
+ $existedCamera = $camera;
13047
+ $camera.id = cameraId;
13048
+ // use absolute position
13049
+ $camera.style.position = 'absolute';
13050
+ // account for DOM element's offset @see https://github.com/antvis/G/issues/1150
13051
+ $camera.style.left = ($canvas.offsetLeft || 0) + "px";
13052
+ $camera.style.top = ($canvas.offsetTop || 0) + "px";
13053
+ $camera.style.transformOrigin = 'left top';
13054
+ $camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix());
13055
+ // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
13056
+ $camera.style.overflow = 'hidden';
13057
+ $camera.style.pointerEvents = 'none';
13058
+ $camera.style.width = (width || 0) + "px";
13059
+ $camera.style.height = (height || 0) + "px";
13060
+ $container.appendChild($camera);
13021
13061
  }
13022
- throw new Error("illegal catch attempt");
13023
- },
13024
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
13025
- return this.delegate = {
13026
- iterator: values(iterable),
13027
- resultName: resultName,
13028
- nextLoc: nextLoc
13029
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
13062
+ return $existedCamera;
13030
13063
  }
13031
- }, exports;
13032
- }
13033
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
13034
- try {
13035
- var info = gen[key](arg);
13036
- var value = info.value;
13037
- } catch (error) {
13038
- reject(error);
13039
- return;
13040
- }
13041
- if (info.done) {
13042
- resolve(value);
13043
- } else {
13044
- Promise.resolve(value).then(_next, _throw);
13045
- }
13046
- }
13047
- function _asyncToGenerator$2(fn) {
13048
- return function () {
13049
- var self = this,
13050
- args = arguments;
13051
- return new Promise(function (resolve, reject) {
13052
- var gen = fn.apply(self, args);
13053
- function _next(value) {
13054
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
13064
+ return null;
13065
+ };
13066
+ _proto.getOrCreateEl = function getOrCreateEl(object) {
13067
+ var doc = this.context.config.document;
13068
+ var existedId = this.getId(object);
13069
+ var $existedElement = this.$camera.querySelector('#' + existedId);
13070
+ if (!$existedElement) {
13071
+ $existedElement = (doc || document).createElement('div');
13072
+ object.parsedStyle.$el = $existedElement;
13073
+ $existedElement.id = existedId;
13074
+ if (object.name) {
13075
+ $existedElement.setAttribute('name', object.name);
13055
13076
  }
13056
- function _throw(err) {
13057
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
13077
+ if (object.className) {
13078
+ $existedElement.className = object.className;
13058
13079
  }
13059
- _next(undefined);
13060
- });
13061
- };
13062
- }
13063
- function _inheritsLoose$2(subClass, superClass) {
13064
- subClass.prototype = Object.create(superClass.prototype);
13065
- subClass.prototype.constructor = subClass;
13066
- _setPrototypeOf$2(subClass, superClass);
13067
- }
13068
- function _setPrototypeOf$2(o, p) {
13069
- _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
13070
- o.__proto__ = p;
13071
- return o;
13080
+ // use absolute position
13081
+ $existedElement.style.position = 'absolute';
13082
+ // @see https://github.com/antvis/G/issues/1150
13083
+ $existedElement.style.left = "0px";
13084
+ $existedElement.style.top = "0px";
13085
+ $existedElement.style['will-change'] = 'transform';
13086
+ $existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
13087
+ }
13088
+ return $existedElement;
13072
13089
  };
13073
- return _setPrototypeOf$2(o, p);
13074
- }
13075
-
13076
- // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
13077
- /**
13078
- * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
13079
- */
13080
- var DOMInteractionPlugin = /*#__PURE__*/function () {
13081
- function DOMInteractionPlugin() {
13082
- this.context = void 0;
13083
- }
13084
- var _proto = DOMInteractionPlugin.prototype;
13085
- _proto.apply = function apply(context, runtime) {
13086
- var _this = this;
13087
- var renderingService = context.renderingService,
13088
- renderingContext = context.renderingContext,
13089
- config = context.config;
13090
- this.context = context;
13091
- var canvas = renderingContext.root.ownerDocument.defaultView;
13092
- // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
13093
- var onPointerMove = function onPointerMove(ev) {
13094
- renderingService.hooks.pointerMove.call(ev);
13095
- };
13096
- var onPointerUp = function onPointerUp(ev) {
13097
- renderingService.hooks.pointerUp.call(ev);
13098
- };
13099
- var onPointerDown = function onPointerDown(ev) {
13100
- renderingService.hooks.pointerDown.call(ev);
13101
- };
13102
- var onPointerOver = function onPointerOver(ev) {
13103
- renderingService.hooks.pointerOver.call(ev);
13104
- };
13105
- var onPointerOut = function onPointerOut(ev) {
13106
- renderingService.hooks.pointerOut.call(ev);
13107
- };
13108
- var onPointerCancel = function onPointerCancel(ev) {
13109
- renderingService.hooks.pointerCancel.call(ev);
13110
- };
13111
- var onPointerWheel = function onPointerWheel(ev) {
13112
- renderingService.hooks.pointerWheel.call(ev);
13113
- };
13114
- var onClick = function onClick(ev) {
13115
- renderingService.hooks.click.call(ev);
13116
- };
13117
- var addPointerEventListener = function addPointerEventListener($el) {
13118
- runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
13119
- $el.addEventListener('pointerdown', onPointerDown, true);
13120
- $el.addEventListener('pointerleave', onPointerOut, true);
13121
- $el.addEventListener('pointerover', onPointerOver, true);
13122
- runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
13123
- runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true);
13124
- };
13125
- var addTouchEventListener = function addTouchEventListener($el) {
13126
- $el.addEventListener('touchstart', onPointerDown, true);
13127
- $el.addEventListener('touchend', onPointerUp, true);
13128
- $el.addEventListener('touchmove', onPointerMove, true);
13129
- $el.addEventListener('touchcancel', onPointerCancel, true);
13130
- };
13131
- var addMouseEventListener = function addMouseEventListener($el) {
13132
- runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
13133
- $el.addEventListener('mousedown', onPointerDown, true);
13134
- $el.addEventListener('mouseout', onPointerOut, true);
13135
- $el.addEventListener('mouseover', onPointerOver, true);
13136
- runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
13137
- };
13138
- var removePointerEventListener = function removePointerEventListener($el) {
13139
- runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
13140
- $el.removeEventListener('pointerdown', onPointerDown, true);
13141
- $el.removeEventListener('pointerleave', onPointerOut, true);
13142
- $el.removeEventListener('pointerover', onPointerOver, true);
13143
- runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
13144
- };
13145
- var removeTouchEventListener = function removeTouchEventListener($el) {
13146
- $el.removeEventListener('touchstart', onPointerDown, true);
13147
- $el.removeEventListener('touchend', onPointerUp, true);
13148
- $el.removeEventListener('touchmove', onPointerMove, true);
13149
- $el.removeEventListener('touchcancel', onPointerCancel, true);
13150
- };
13151
- var removeMouseEventListener = function removeMouseEventListener($el) {
13152
- runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
13153
- $el.removeEventListener('mousedown', onPointerDown, true);
13154
- $el.removeEventListener('mouseout', onPointerOut, true);
13155
- $el.removeEventListener('mouseover', onPointerOver, true);
13156
- runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
13157
- };
13158
- renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
13159
- var $el;
13160
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
13161
- while (1) switch (_context.prev = _context.next) {
13162
- case 0:
13163
- $el = _this.context.contextService.getDomElement(); // @ts-ignore
13164
- if (runtime.globalThis.navigator.msPointerEnabled) {
13165
- // @ts-ignore
13166
- $el.style.msContentZooming = 'none';
13167
- // @ts-ignore
13168
- $el.style.msTouchAction = 'none';
13169
- } else if (canvas.supportsPointerEvents) {
13170
- $el.style.touchAction = 'none';
13171
- }
13172
- if (canvas.supportsPointerEvents) {
13173
- addPointerEventListener($el);
13174
- } else {
13175
- addMouseEventListener($el);
13176
- }
13177
- if (canvas.supportsTouchEvents) {
13178
- addTouchEventListener($el);
13179
- }
13180
- if (config.useNativeClickEvent) {
13181
- $el.addEventListener('click', onClick, true);
13182
- }
13183
- // use passive event listeners
13184
- // @see https://zhuanlan.zhihu.com/p/24555031
13185
- $el.addEventListener('wheel', onPointerWheel, {
13186
- passive: true,
13187
- capture: true
13188
- });
13189
- case 6:
13190
- case "end":
13191
- return _context.stop();
13192
- }
13193
- }, _callee);
13194
- })));
13195
- renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
13196
- var $el = _this.context.contextService.getDomElement();
13197
- // @ts-ignore
13198
- if (runtime.globalThis.navigator.msPointerEnabled) {
13199
- // @ts-ignore
13200
- $el.style.msContentZooming = '';
13201
- // @ts-ignore
13202
- $el.style.msTouchAction = '';
13203
- } else if (canvas.supportsPointerEvents) {
13204
- $el.style.touchAction = '';
13205
- }
13206
- if (canvas.supportsPointerEvents) {
13207
- removePointerEventListener($el);
13208
- } else {
13209
- removeMouseEventListener($el);
13210
- }
13211
- if (canvas.supportsTouchEvents) {
13212
- removeTouchEventListener($el);
13213
- }
13214
- if (config.useNativeClickEvent) {
13215
- $el.removeEventListener('click', onClick, true);
13216
- }
13217
- $el.removeEventListener('wheel', onPointerWheel, true);
13218
- });
13219
- };
13220
- return DOMInteractionPlugin;
13221
- }();
13222
- DOMInteractionPlugin.tag = 'DOMInteraction';
13223
- var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
13224
- _inheritsLoose$2(Plugin, _AbstractRendererPlug);
13225
- function Plugin() {
13226
- var _this;
13227
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13228
- args[_key] = arguments[_key];
13229
- }
13230
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
13231
- _this.name = 'dom-interaction';
13232
- return _this;
13233
- }
13234
- var _proto = Plugin.prototype;
13235
- _proto.init = function init() {
13236
- this.addRenderingPlugin(new DOMInteractionPlugin());
13237
- };
13238
- _proto.destroy = function destroy() {
13239
- this.removeAllRenderingPlugins();
13240
- };
13241
- return Plugin;
13242
- }(gLite.AbstractRendererPlugin);
13243
-
13244
- var index_esm$1 = /*#__PURE__*/Object.freeze({
13245
- __proto__: null,
13246
- Plugin: Plugin$1
13247
- });
13248
-
13249
- function _regeneratorRuntime$3() {
13250
- _regeneratorRuntime$3 = function _regeneratorRuntime() {
13251
- return exports;
13252
- };
13253
- var exports = {},
13254
- Op = Object.prototype,
13255
- hasOwn = Op.hasOwnProperty,
13256
- defineProperty = Object.defineProperty || function (obj, key, desc) {
13257
- obj[key] = desc.value;
13258
- },
13259
- $Symbol = "function" == typeof Symbol ? Symbol : {},
13260
- iteratorSymbol = $Symbol.iterator || "@@iterator",
13261
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
13262
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
13263
- function define(obj, key, value) {
13264
- return Object.defineProperty(obj, key, {
13265
- value: value,
13266
- enumerable: !0,
13267
- configurable: !0,
13268
- writable: !0
13269
- }), obj[key];
13270
- }
13271
- try {
13272
- define({}, "");
13273
- } catch (err) {
13274
- define = function define(obj, key, value) {
13275
- return obj[key] = value;
13276
- };
13277
- }
13278
- function wrap(innerFn, outerFn, self, tryLocsList) {
13279
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
13280
- generator = Object.create(protoGenerator.prototype),
13281
- context = new Context(tryLocsList || []);
13282
- return defineProperty(generator, "_invoke", {
13283
- value: makeInvokeMethod(innerFn, self, context)
13284
- }), generator;
13285
- }
13286
- function tryCatch(fn, obj, arg) {
13287
- try {
13288
- return {
13289
- type: "normal",
13290
- arg: fn.call(obj, arg)
13291
- };
13292
- } catch (err) {
13293
- return {
13294
- type: "throw",
13295
- arg: err
13296
- };
13297
- }
13298
- }
13299
- exports.wrap = wrap;
13300
- var ContinueSentinel = {};
13301
- function Generator() {}
13302
- function GeneratorFunction() {}
13303
- function GeneratorFunctionPrototype() {}
13304
- var IteratorPrototype = {};
13305
- define(IteratorPrototype, iteratorSymbol, function () {
13306
- return this;
13307
- });
13308
- var getProto = Object.getPrototypeOf,
13309
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
13310
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
13311
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
13312
- function defineIteratorMethods(prototype) {
13313
- ["next", "throw", "return"].forEach(function (method) {
13314
- define(prototype, method, function (arg) {
13315
- return this._invoke(method, arg);
13316
- });
13317
- });
13318
- }
13319
- function AsyncIterator(generator, PromiseImpl) {
13320
- function invoke(method, arg, resolve, reject) {
13321
- var record = tryCatch(generator[method], generator, arg);
13322
- if ("throw" !== record.type) {
13323
- var result = record.arg,
13324
- value = result.value;
13325
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
13326
- invoke("next", value, resolve, reject);
13327
- }, function (err) {
13328
- invoke("throw", err, resolve, reject);
13329
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
13330
- result.value = unwrapped, resolve(result);
13331
- }, function (error) {
13332
- return invoke("throw", error, resolve, reject);
13333
- });
13334
- }
13335
- reject(record.arg);
13336
- }
13337
- var previousPromise;
13338
- defineProperty(this, "_invoke", {
13339
- value: function value(method, arg) {
13340
- function callInvokeWithMethodAndArg() {
13341
- return new PromiseImpl(function (resolve, reject) {
13342
- invoke(method, arg, resolve, reject);
13343
- });
13344
- }
13345
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
13346
- }
13347
- });
13348
- }
13349
- function makeInvokeMethod(innerFn, self, context) {
13350
- var state = "suspendedStart";
13351
- return function (method, arg) {
13352
- if ("executing" === state) throw new Error("Generator is already running");
13353
- if ("completed" === state) {
13354
- if ("throw" === method) throw arg;
13355
- return doneResult();
13356
- }
13357
- for (context.method = method, context.arg = arg;;) {
13358
- var delegate = context.delegate;
13359
- if (delegate) {
13360
- var delegateResult = maybeInvokeDelegate(delegate, context);
13361
- if (delegateResult) {
13362
- if (delegateResult === ContinueSentinel) continue;
13363
- return delegateResult;
13364
- }
13365
- }
13366
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
13367
- if ("suspendedStart" === state) throw state = "completed", context.arg;
13368
- context.dispatchException(context.arg);
13369
- } else "return" === context.method && context.abrupt("return", context.arg);
13370
- state = "executing";
13371
- var record = tryCatch(innerFn, self, context);
13372
- if ("normal" === record.type) {
13373
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
13374
- return {
13375
- value: record.arg,
13376
- done: context.done
13377
- };
13378
- }
13379
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
13380
- }
13381
- };
13382
- }
13383
- function maybeInvokeDelegate(delegate, context) {
13384
- var methodName = context.method,
13385
- method = delegate.iterator[methodName];
13386
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
13387
- var record = tryCatch(method, delegate.iterator, context.arg);
13388
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
13389
- var info = record.arg;
13390
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
13391
- }
13392
- function pushTryEntry(locs) {
13393
- var entry = {
13394
- tryLoc: locs[0]
13395
- };
13396
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
13397
- }
13398
- function resetTryEntry(entry) {
13399
- var record = entry.completion || {};
13400
- record.type = "normal", delete record.arg, entry.completion = record;
13401
- }
13402
- function Context(tryLocsList) {
13403
- this.tryEntries = [{
13404
- tryLoc: "root"
13405
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
13406
- }
13407
- function values(iterable) {
13408
- if (iterable) {
13409
- var iteratorMethod = iterable[iteratorSymbol];
13410
- if (iteratorMethod) return iteratorMethod.call(iterable);
13411
- if ("function" == typeof iterable.next) return iterable;
13412
- if (!isNaN(iterable.length)) {
13413
- var i = -1,
13414
- next = function next() {
13415
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
13416
- return next.value = undefined, next.done = !0, next;
13417
- };
13418
- return next.next = next;
13419
- }
13420
- }
13421
- return {
13422
- next: doneResult
13423
- };
13424
- }
13425
- function doneResult() {
13426
- return {
13427
- value: undefined,
13428
- done: !0
13429
- };
13430
- }
13431
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
13432
- value: GeneratorFunctionPrototype,
13433
- configurable: !0
13434
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
13435
- value: GeneratorFunction,
13436
- configurable: !0
13437
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
13438
- var ctor = "function" == typeof genFun && genFun.constructor;
13439
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
13440
- }, exports.mark = function (genFun) {
13441
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
13442
- }, exports.awrap = function (arg) {
13443
- return {
13444
- __await: arg
13445
- };
13446
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
13447
- return this;
13448
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
13449
- void 0 === PromiseImpl && (PromiseImpl = Promise);
13450
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
13451
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
13452
- return result.done ? result.value : iter.next();
13453
- });
13454
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
13455
- return this;
13456
- }), define(Gp, "toString", function () {
13457
- return "[object Generator]";
13458
- }), exports.keys = function (val) {
13459
- var object = Object(val),
13460
- keys = [];
13461
- for (var key in object) keys.push(key);
13462
- return keys.reverse(), function next() {
13463
- for (; keys.length;) {
13464
- var key = keys.pop();
13465
- if (key in object) return next.value = key, next.done = !1, next;
13466
- }
13467
- return next.done = !0, next;
13468
- };
13469
- }, exports.values = values, Context.prototype = {
13470
- constructor: Context,
13471
- reset: function reset(skipTempReset) {
13472
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
13473
- },
13474
- stop: function stop() {
13475
- this.done = !0;
13476
- var rootRecord = this.tryEntries[0].completion;
13477
- if ("throw" === rootRecord.type) throw rootRecord.arg;
13478
- return this.rval;
13479
- },
13480
- dispatchException: function dispatchException(exception) {
13481
- if (this.done) throw exception;
13482
- var context = this;
13483
- function handle(loc, caught) {
13484
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
13485
- }
13486
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13487
- var entry = this.tryEntries[i],
13488
- record = entry.completion;
13489
- if ("root" === entry.tryLoc) return handle("end");
13490
- if (entry.tryLoc <= this.prev) {
13491
- var hasCatch = hasOwn.call(entry, "catchLoc"),
13492
- hasFinally = hasOwn.call(entry, "finallyLoc");
13493
- if (hasCatch && hasFinally) {
13494
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
13495
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
13496
- } else if (hasCatch) {
13497
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
13498
- } else {
13499
- if (!hasFinally) throw new Error("try statement without catch or finally");
13500
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
13501
- }
13502
- }
13503
- }
13504
- },
13505
- abrupt: function abrupt(type, arg) {
13506
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13507
- var entry = this.tryEntries[i];
13508
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
13509
- var finallyEntry = entry;
13510
- break;
13511
- }
13512
- }
13513
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
13514
- var record = finallyEntry ? finallyEntry.completion : {};
13515
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
13516
- },
13517
- complete: function complete(record, afterLoc) {
13518
- if ("throw" === record.type) throw record.arg;
13519
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
13520
- },
13521
- finish: function finish(finallyLoc) {
13522
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13523
- var entry = this.tryEntries[i];
13524
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
13525
- }
13526
- },
13527
- catch: function _catch(tryLoc) {
13528
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
13529
- var entry = this.tryEntries[i];
13530
- if (entry.tryLoc === tryLoc) {
13531
- var record = entry.completion;
13532
- if ("throw" === record.type) {
13533
- var thrown = record.arg;
13534
- resetTryEntry(entry);
13535
- }
13536
- return thrown;
13537
- }
13538
- }
13539
- throw new Error("illegal catch attempt");
13540
- },
13541
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
13542
- return this.delegate = {
13543
- iterator: values(iterable),
13544
- resultName: resultName,
13545
- nextLoc: nextLoc
13546
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
13547
- }
13548
- }, exports;
13549
- }
13550
- function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
13551
- try {
13552
- var info = gen[key](arg);
13553
- var value = info.value;
13554
- } catch (error) {
13555
- reject(error);
13556
- return;
13557
- }
13558
- if (info.done) {
13559
- resolve(value);
13560
- } else {
13561
- Promise.resolve(value).then(_next, _throw);
13562
- }
13563
- }
13564
- function _asyncToGenerator$3(fn) {
13565
- return function () {
13566
- var self = this,
13567
- args = arguments;
13568
- return new Promise(function (resolve, reject) {
13569
- var gen = fn.apply(self, args);
13570
- function _next(value) {
13571
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
13572
- }
13573
- function _throw(err) {
13574
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
13575
- }
13576
- _next(undefined);
13577
- });
13578
- };
13579
- }
13580
- function _inheritsLoose$3(subClass, superClass) {
13581
- subClass.prototype = Object.create(superClass.prototype);
13582
- subClass.prototype.constructor = subClass;
13583
- _setPrototypeOf$3(subClass, superClass);
13584
- }
13585
- function _setPrototypeOf$3(o, p) {
13586
- _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
13587
- o.__proto__ = p;
13588
- return o;
13589
- };
13590
- return _setPrototypeOf$3(o, p);
13591
- }
13592
- var HTML_PREFIX = 'g-html-';
13593
- var CANVAS_CAMERA_ID = 'g-canvas-camera';
13594
- var HTMLRenderingPlugin = /*#__PURE__*/function () {
13595
- function HTMLRenderingPlugin() {
13596
- this.context = void 0;
13597
- /**
13598
- * wrapper for camera
13599
- */
13600
- this.$camera = void 0;
13601
- }
13602
- var _proto = HTMLRenderingPlugin.prototype;
13603
- _proto.joinTransformMatrix = function joinTransformMatrix(matrix) {
13604
- return "matrix(" + [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]].join(',') + ")";
13605
- };
13606
- _proto.apply = function apply(context) {
13607
- var _this = this;
13608
- var camera = context.camera,
13609
- renderingContext = context.renderingContext,
13610
- renderingService = context.renderingService;
13611
- this.context = context;
13612
- var canvas = renderingContext.root.ownerDocument.defaultView;
13613
- var setTransform = function setTransform(object, $el) {
13614
- $el.style.transform = _this.joinTransformMatrix(object.getWorldTransform());
13615
- };
13616
- var handleMounted = function handleMounted(e) {
13617
- var object = e.target;
13618
- if (object.nodeName === gLite.Shape.HTML) {
13619
- if (!_this.$camera) {
13620
- _this.$camera = _this.createCamera(camera);
13621
- }
13622
- // create DOM element
13623
- var $el = _this.getOrCreateEl(object);
13624
- _this.$camera.appendChild($el);
13625
- // apply documentElement's style
13626
- var attributes = object.ownerDocument.documentElement.attributes;
13627
- Object.keys(attributes).forEach(function (name) {
13628
- $el.style[name] = attributes[name];
13629
- });
13630
- Object.keys(object.attributes).forEach(function (name) {
13631
- _this.updateAttribute(name, object);
13632
- });
13633
- setTransform(object, $el);
13634
- gLite.runtime.nativeHTMLMap.set($el, object);
13635
- }
13636
- };
13637
- var handleUnmounted = function handleUnmounted(e) {
13638
- var object = e.target;
13639
- if (object.nodeName === gLite.Shape.HTML && _this.$camera) {
13640
- var $el = _this.getOrCreateEl(object);
13641
- if ($el) {
13642
- $el.remove();
13643
- gLite.runtime.nativeHTMLMap.delete($el);
13644
- }
13645
- // const existedId = this.getId(object);
13646
- // const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
13647
- // if ($existedElement) {
13648
- // this.$camera.removeChild($existedElement);
13649
- // }
13650
- }
13651
- };
13652
-
13653
- var handleAttributeChanged = function handleAttributeChanged(e) {
13654
- var object = e.target;
13655
- if (object.nodeName === gLite.Shape.HTML) {
13656
- var attrName = e.attrName;
13657
- _this.updateAttribute(attrName, object);
13658
- }
13659
- };
13660
- var handleBoundsChanged = function handleBoundsChanged(e) {
13661
- var object = e.target;
13662
- if (object.nodeName === gLite.Shape.HTML) {
13663
- var $el = _this.getOrCreateEl(object);
13664
- setTransform(object, $el);
13665
- }
13666
- };
13667
- var handleCanvasResize = function handleCanvasResize() {
13668
- if (_this.$camera) {
13669
- var _this$context$config = _this.context.config,
13670
- width = _this$context$config.width,
13671
- height = _this$context$config.height;
13672
- _this.$camera.style.width = (width || 0) + "px";
13673
- _this.$camera.style.height = (height || 0) + "px";
13674
- }
13675
- };
13676
- renderingService.hooks.init.tapPromise(HTMLRenderingPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
13677
- return _regeneratorRuntime$3().wrap(function _callee$(_context) {
13678
- while (1) switch (_context.prev = _context.next) {
13679
- case 0:
13680
- canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13681
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13682
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13683
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13684
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13685
- case 5:
13686
- case "end":
13687
- return _context.stop();
13688
- }
13689
- }, _callee);
13690
- })));
13691
- renderingService.hooks.endFrame.tap(HTMLRenderingPlugin.tag, function () {
13692
- if (_this.$camera && renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
13693
- _this.$camera.style.transform = _this.joinTransformMatrix(camera.getOrthoMatrix());
13694
- }
13695
- });
13696
- renderingService.hooks.destroy.tap(HTMLRenderingPlugin.tag, function () {
13697
- // remove camera
13698
- if (_this.$camera) {
13699
- _this.$camera.remove();
13700
- }
13701
- canvas.removeEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
13702
- canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13703
- canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
13704
- canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13705
- canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
13706
- });
13707
- };
13708
- _proto.getId = function getId(object) {
13709
- return object.id || HTML_PREFIX + object.entity;
13710
- };
13711
- _proto.createCamera = function createCamera(camera) {
13712
- var _this$context$config2 = this.context.config,
13713
- doc = _this$context$config2.document,
13714
- width = _this$context$config2.width,
13715
- height = _this$context$config2.height;
13716
- var $canvas = this.context.contextService.getDomElement();
13717
- var $container = $canvas.parentNode;
13718
- if ($container) {
13719
- var cameraId = CANVAS_CAMERA_ID;
13720
- var $existedCamera = $container.querySelector('#' + cameraId);
13721
- if (!$existedCamera) {
13722
- var $camera = (doc || document).createElement('div');
13723
- $existedCamera = $camera;
13724
- $camera.id = cameraId;
13725
- // use absolute position
13726
- $camera.style.position = 'absolute';
13727
- // account for DOM element's offset @see https://github.com/antvis/G/issues/1150
13728
- $camera.style.left = ($canvas.offsetLeft || 0) + "px";
13729
- $camera.style.top = ($canvas.offsetTop || 0) + "px";
13730
- $camera.style.transformOrigin = 'left top';
13731
- $camera.style.transform = this.joinTransformMatrix(camera.getOrthoMatrix());
13732
- // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163
13733
- $camera.style.overflow = 'hidden';
13734
- $camera.style.pointerEvents = 'none';
13735
- $camera.style.width = (width || 0) + "px";
13736
- $camera.style.height = (height || 0) + "px";
13737
- $container.appendChild($camera);
13738
- }
13739
- return $existedCamera;
13740
- }
13741
- return null;
13742
- };
13743
- _proto.getOrCreateEl = function getOrCreateEl(object) {
13744
- var doc = this.context.config.document;
13745
- var existedId = this.getId(object);
13746
- var $existedElement = this.$camera.querySelector('#' + existedId);
13747
- if (!$existedElement) {
13748
- $existedElement = (doc || document).createElement('div');
13749
- object.parsedStyle.$el = $existedElement;
13750
- $existedElement.id = existedId;
13751
- if (object.name) {
13752
- $existedElement.setAttribute('name', object.name);
13753
- }
13754
- if (object.className) {
13755
- $existedElement.className = object.className;
13756
- }
13757
- // use absolute position
13758
- $existedElement.style.position = 'absolute';
13759
- // @see https://github.com/antvis/G/issues/1150
13760
- $existedElement.style.left = "0px";
13761
- $existedElement.style.top = "0px";
13762
- $existedElement.style['will-change'] = 'transform';
13763
- $existedElement.style.transform = this.joinTransformMatrix(object.getWorldTransform());
13764
- }
13765
- return $existedElement;
13766
- };
13767
- _proto.updateAttribute = function updateAttribute(name, object) {
13768
- var $el = this.getOrCreateEl(object);
13769
- switch (name) {
13770
- case 'innerHTML':
13771
- var innerHTML = object.parsedStyle.innerHTML;
13772
- if (isString(innerHTML)) {
13773
- $el.innerHTML = innerHTML;
13774
- } else {
13775
- $el.innerHTML = '';
13776
- $el.appendChild(innerHTML);
13777
- }
13778
- break;
13779
- case 'transformOrigin':
13780
- var transformOrigin = object.parsedStyle.transformOrigin;
13781
- $el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
13782
- break;
13783
- case 'width':
13784
- if (gLite.runtime.enableCSSParsing) {
13785
- var width = object.computedStyleMap().get('width');
13786
- $el.style.width = width.toString();
13787
- } else {
13788
- var _width = object.parsedStyle.width;
13789
- $el.style.width = isNumber(_width) ? _width + "px" : _width.toString();
13790
- }
13791
- break;
13792
- case 'height':
13793
- if (gLite.runtime.enableCSSParsing) {
13794
- var height = object.computedStyleMap().get('height');
13795
- $el.style.height = height.toString();
13796
- } else {
13797
- var _height = object.parsedStyle.height;
13798
- $el.style.height = isNumber(_height) ? _height + "px" : _height.toString();
13799
- }
13800
- break;
13801
- case 'zIndex':
13802
- var zIndex = object.parsedStyle.zIndex;
13803
- $el.style['z-index'] = "" + zIndex;
13804
- break;
13805
- case 'visibility':
13806
- var visibility = object.parsedStyle.visibility;
13807
- $el.style.visibility = visibility;
13808
- break;
13809
- case 'pointerEvents':
13810
- var pointerEvents = object.parsedStyle.pointerEvents;
13811
- $el.style.pointerEvents = pointerEvents;
13812
- break;
13813
- case 'opacity':
13814
- var opacity = object.parsedStyle.opacity;
13815
- $el.style.opacity = "" + opacity;
13816
- break;
13817
- case 'fill':
13818
- var fill = object.parsedStyle.fill;
13819
- var color = '';
13820
- if (gLite.isCSSRGB(fill)) {
13821
- if (fill.isNone) {
13822
- color = 'transparent';
13823
- } else {
13824
- color = object.getAttribute('fill');
13825
- }
13826
- } else if (Array.isArray(fill)) {
13827
- color = object.getAttribute('fill');
13828
- } else if (gLite.isPattern(fill)) ;
13829
- $el.style.background = color;
13830
- break;
13831
- case 'stroke':
13832
- var stroke = object.parsedStyle.stroke;
13833
- var borderColor = '';
13834
- if (gLite.isCSSRGB(stroke)) {
13835
- if (stroke.isNone) {
13836
- borderColor = 'transparent';
13837
- } else {
13838
- borderColor = object.getAttribute('stroke');
13839
- }
13840
- } else if (Array.isArray(stroke)) {
13841
- borderColor = object.getAttribute('stroke');
13842
- } else if (gLite.isPattern(stroke)) ;
13843
- $el.style['border-color'] = borderColor;
13844
- $el.style['border-style'] = 'solid';
13845
- break;
13846
- case 'lineWidth':
13847
- var lineWidth = object.parsedStyle.lineWidth;
13848
- $el.style['border-width'] = (lineWidth || 0) + "px";
13849
- break;
13850
- case 'lineDash':
13851
- $el.style['border-style'] = 'dashed';
13852
- break;
13853
- case 'filter':
13854
- var filter = object.style.filter;
13855
- $el.style.filter = filter;
13856
- break;
13857
- }
13858
- };
13859
- return HTMLRenderingPlugin;
13860
- }();
13861
- HTMLRenderingPlugin.tag = 'HTMLRendering';
13862
- var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
13863
- _inheritsLoose$3(Plugin, _AbstractRendererPlug);
13864
- function Plugin() {
13865
- var _this;
13866
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13867
- args[_key] = arguments[_key];
13868
- }
13869
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
13870
- _this.name = 'html-renderer';
13871
- return _this;
13872
- }
13873
- var _proto = Plugin.prototype;
13874
- _proto.init = function init() {
13875
- this.addRenderingPlugin(new HTMLRenderingPlugin());
13876
- };
13877
- _proto.destroy = function destroy() {
13878
- this.removeAllRenderingPlugins();
13879
- };
13880
- return Plugin;
13881
- }(gLite.AbstractRendererPlugin);
13882
-
13883
- var index_esm$2 = /*#__PURE__*/Object.freeze({
13884
- __proto__: null,
13885
- Plugin: Plugin$2
13886
- });
13887
-
13888
- function _regeneratorRuntime$4() {
13889
- _regeneratorRuntime$4 = function _regeneratorRuntime() {
13890
- return exports;
13891
- };
13892
- var exports = {},
13893
- Op = Object.prototype,
13894
- hasOwn = Op.hasOwnProperty,
13895
- defineProperty = Object.defineProperty || function (obj, key, desc) {
13896
- obj[key] = desc.value;
13897
- },
13898
- $Symbol = "function" == typeof Symbol ? Symbol : {},
13899
- iteratorSymbol = $Symbol.iterator || "@@iterator",
13900
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
13901
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
13902
- function define(obj, key, value) {
13903
- return Object.defineProperty(obj, key, {
13904
- value: value,
13905
- enumerable: !0,
13906
- configurable: !0,
13907
- writable: !0
13908
- }), obj[key];
13909
- }
13910
- try {
13911
- define({}, "");
13912
- } catch (err) {
13913
- define = function define(obj, key, value) {
13914
- return obj[key] = value;
13915
- };
13916
- }
13917
- function wrap(innerFn, outerFn, self, tryLocsList) {
13918
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
13919
- generator = Object.create(protoGenerator.prototype),
13920
- context = new Context(tryLocsList || []);
13921
- return defineProperty(generator, "_invoke", {
13922
- value: makeInvokeMethod(innerFn, self, context)
13923
- }), generator;
13924
- }
13925
- function tryCatch(fn, obj, arg) {
13926
- try {
13927
- return {
13928
- type: "normal",
13929
- arg: fn.call(obj, arg)
13930
- };
13931
- } catch (err) {
13932
- return {
13933
- type: "throw",
13934
- arg: err
13935
- };
13936
- }
13937
- }
13938
- exports.wrap = wrap;
13939
- var ContinueSentinel = {};
13940
- function Generator() {}
13941
- function GeneratorFunction() {}
13942
- function GeneratorFunctionPrototype() {}
13943
- var IteratorPrototype = {};
13944
- define(IteratorPrototype, iteratorSymbol, function () {
13945
- return this;
13946
- });
13947
- var getProto = Object.getPrototypeOf,
13948
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
13949
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
13950
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
13951
- function defineIteratorMethods(prototype) {
13952
- ["next", "throw", "return"].forEach(function (method) {
13953
- define(prototype, method, function (arg) {
13954
- return this._invoke(method, arg);
13955
- });
13956
- });
13957
- }
13958
- function AsyncIterator(generator, PromiseImpl) {
13959
- function invoke(method, arg, resolve, reject) {
13960
- var record = tryCatch(generator[method], generator, arg);
13961
- if ("throw" !== record.type) {
13962
- var result = record.arg,
13963
- value = result.value;
13964
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
13965
- invoke("next", value, resolve, reject);
13966
- }, function (err) {
13967
- invoke("throw", err, resolve, reject);
13968
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
13969
- result.value = unwrapped, resolve(result);
13970
- }, function (error) {
13971
- return invoke("throw", error, resolve, reject);
13972
- });
13973
- }
13974
- reject(record.arg);
13975
- }
13976
- var previousPromise;
13977
- defineProperty(this, "_invoke", {
13978
- value: function value(method, arg) {
13979
- function callInvokeWithMethodAndArg() {
13980
- return new PromiseImpl(function (resolve, reject) {
13981
- invoke(method, arg, resolve, reject);
13982
- });
13090
+ _proto.updateAttribute = function updateAttribute(name, object) {
13091
+ var $el = this.getOrCreateEl(object);
13092
+ switch (name) {
13093
+ case 'innerHTML':
13094
+ var innerHTML = object.parsedStyle.innerHTML;
13095
+ if (isString(innerHTML)) {
13096
+ $el.innerHTML = innerHTML;
13097
+ } else {
13098
+ $el.innerHTML = '';
13099
+ $el.appendChild(innerHTML);
13983
13100
  }
13984
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
13985
- }
13986
- });
13987
- }
13988
- function makeInvokeMethod(innerFn, self, context) {
13989
- var state = "suspendedStart";
13990
- return function (method, arg) {
13991
- if ("executing" === state) throw new Error("Generator is already running");
13992
- if ("completed" === state) {
13993
- if ("throw" === method) throw arg;
13994
- return doneResult();
13995
- }
13996
- for (context.method = method, context.arg = arg;;) {
13997
- var delegate = context.delegate;
13998
- if (delegate) {
13999
- var delegateResult = maybeInvokeDelegate(delegate, context);
14000
- if (delegateResult) {
14001
- if (delegateResult === ContinueSentinel) continue;
14002
- return delegateResult;
14003
- }
13101
+ break;
13102
+ case 'transformOrigin':
13103
+ var transformOrigin = object.parsedStyle.transformOrigin;
13104
+ $el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
13105
+ break;
13106
+ case 'width':
13107
+ if (gLite.runtime.enableCSSParsing) {
13108
+ var width = object.computedStyleMap().get('width');
13109
+ $el.style.width = width.toString();
13110
+ } else {
13111
+ var _width = object.parsedStyle.width;
13112
+ $el.style.width = isNumber(_width) ? _width + "px" : _width.toString();
14004
13113
  }
14005
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
14006
- if ("suspendedStart" === state) throw state = "completed", context.arg;
14007
- context.dispatchException(context.arg);
14008
- } else "return" === context.method && context.abrupt("return", context.arg);
14009
- state = "executing";
14010
- var record = tryCatch(innerFn, self, context);
14011
- if ("normal" === record.type) {
14012
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
14013
- return {
14014
- value: record.arg,
14015
- done: context.done
14016
- };
13114
+ break;
13115
+ case 'height':
13116
+ if (gLite.runtime.enableCSSParsing) {
13117
+ var height = object.computedStyleMap().get('height');
13118
+ $el.style.height = height.toString();
13119
+ } else {
13120
+ var _height = object.parsedStyle.height;
13121
+ $el.style.height = isNumber(_height) ? _height + "px" : _height.toString();
14017
13122
  }
14018
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
14019
- }
14020
- };
14021
- }
14022
- function maybeInvokeDelegate(delegate, context) {
14023
- var methodName = context.method,
14024
- method = delegate.iterator[methodName];
14025
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
14026
- var record = tryCatch(method, delegate.iterator, context.arg);
14027
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
14028
- var info = record.arg;
14029
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
14030
- }
14031
- function pushTryEntry(locs) {
14032
- var entry = {
14033
- tryLoc: locs[0]
14034
- };
14035
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
14036
- }
14037
- function resetTryEntry(entry) {
14038
- var record = entry.completion || {};
14039
- record.type = "normal", delete record.arg, entry.completion = record;
14040
- }
14041
- function Context(tryLocsList) {
14042
- this.tryEntries = [{
14043
- tryLoc: "root"
14044
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
14045
- }
14046
- function values(iterable) {
14047
- if (iterable) {
14048
- var iteratorMethod = iterable[iteratorSymbol];
14049
- if (iteratorMethod) return iteratorMethod.call(iterable);
14050
- if ("function" == typeof iterable.next) return iterable;
14051
- if (!isNaN(iterable.length)) {
14052
- var i = -1,
14053
- next = function next() {
14054
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
14055
- return next.value = undefined, next.done = !0, next;
14056
- };
14057
- return next.next = next;
14058
- }
14059
- }
14060
- return {
14061
- next: doneResult
14062
- };
14063
- }
14064
- function doneResult() {
14065
- return {
14066
- value: undefined,
14067
- done: !0
14068
- };
14069
- }
14070
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
14071
- value: GeneratorFunctionPrototype,
14072
- configurable: !0
14073
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
14074
- value: GeneratorFunction,
14075
- configurable: !0
14076
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
14077
- var ctor = "function" == typeof genFun && genFun.constructor;
14078
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
14079
- }, exports.mark = function (genFun) {
14080
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
14081
- }, exports.awrap = function (arg) {
14082
- return {
14083
- __await: arg
14084
- };
14085
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
14086
- return this;
14087
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
14088
- void 0 === PromiseImpl && (PromiseImpl = Promise);
14089
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
14090
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
14091
- return result.done ? result.value : iter.next();
14092
- });
14093
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
14094
- return this;
14095
- }), define(Gp, "toString", function () {
14096
- return "[object Generator]";
14097
- }), exports.keys = function (val) {
14098
- var object = Object(val),
14099
- keys = [];
14100
- for (var key in object) keys.push(key);
14101
- return keys.reverse(), function next() {
14102
- for (; keys.length;) {
14103
- var key = keys.pop();
14104
- if (key in object) return next.value = key, next.done = !1, next;
14105
- }
14106
- return next.done = !0, next;
14107
- };
14108
- }, exports.values = values, Context.prototype = {
14109
- constructor: Context,
14110
- reset: function reset(skipTempReset) {
14111
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
14112
- },
14113
- stop: function stop() {
14114
- this.done = !0;
14115
- var rootRecord = this.tryEntries[0].completion;
14116
- if ("throw" === rootRecord.type) throw rootRecord.arg;
14117
- return this.rval;
14118
- },
14119
- dispatchException: function dispatchException(exception) {
14120
- if (this.done) throw exception;
14121
- var context = this;
14122
- function handle(loc, caught) {
14123
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
14124
- }
14125
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14126
- var entry = this.tryEntries[i],
14127
- record = entry.completion;
14128
- if ("root" === entry.tryLoc) return handle("end");
14129
- if (entry.tryLoc <= this.prev) {
14130
- var hasCatch = hasOwn.call(entry, "catchLoc"),
14131
- hasFinally = hasOwn.call(entry, "finallyLoc");
14132
- if (hasCatch && hasFinally) {
14133
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
14134
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
14135
- } else if (hasCatch) {
14136
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
13123
+ break;
13124
+ case 'zIndex':
13125
+ var zIndex = object.parsedStyle.zIndex;
13126
+ $el.style['z-index'] = "" + zIndex;
13127
+ break;
13128
+ case 'visibility':
13129
+ var visibility = object.parsedStyle.visibility;
13130
+ $el.style.visibility = visibility;
13131
+ break;
13132
+ case 'pointerEvents':
13133
+ var pointerEvents = object.parsedStyle.pointerEvents;
13134
+ $el.style.pointerEvents = pointerEvents;
13135
+ break;
13136
+ case 'opacity':
13137
+ var opacity = object.parsedStyle.opacity;
13138
+ $el.style.opacity = "" + opacity;
13139
+ break;
13140
+ case 'fill':
13141
+ var fill = object.parsedStyle.fill;
13142
+ var color = '';
13143
+ if (gLite.isCSSRGB(fill)) {
13144
+ if (fill.isNone) {
13145
+ color = 'transparent';
14137
13146
  } else {
14138
- if (!hasFinally) throw new Error("try statement without catch or finally");
14139
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
13147
+ color = object.getAttribute('fill');
14140
13148
  }
14141
- }
14142
- }
14143
- },
14144
- abrupt: function abrupt(type, arg) {
14145
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14146
- var entry = this.tryEntries[i];
14147
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
14148
- var finallyEntry = entry;
14149
- break;
14150
- }
14151
- }
14152
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
14153
- var record = finallyEntry ? finallyEntry.completion : {};
14154
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
14155
- },
14156
- complete: function complete(record, afterLoc) {
14157
- if ("throw" === record.type) throw record.arg;
14158
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
14159
- },
14160
- finish: function finish(finallyLoc) {
14161
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14162
- var entry = this.tryEntries[i];
14163
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
14164
- }
14165
- },
14166
- catch: function _catch(tryLoc) {
14167
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
14168
- var entry = this.tryEntries[i];
14169
- if (entry.tryLoc === tryLoc) {
14170
- var record = entry.completion;
14171
- if ("throw" === record.type) {
14172
- var thrown = record.arg;
14173
- resetTryEntry(entry);
13149
+ } else if (Array.isArray(fill)) {
13150
+ color = object.getAttribute('fill');
13151
+ } else if (gLite.isPattern(fill)) ;
13152
+ $el.style.background = color;
13153
+ break;
13154
+ case 'stroke':
13155
+ var stroke = object.parsedStyle.stroke;
13156
+ var borderColor = '';
13157
+ if (gLite.isCSSRGB(stroke)) {
13158
+ if (stroke.isNone) {
13159
+ borderColor = 'transparent';
13160
+ } else {
13161
+ borderColor = object.getAttribute('stroke');
14174
13162
  }
14175
- return thrown;
14176
- }
14177
- }
14178
- throw new Error("illegal catch attempt");
14179
- },
14180
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
14181
- return this.delegate = {
14182
- iterator: values(iterable),
14183
- resultName: resultName,
14184
- nextLoc: nextLoc
14185
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
13163
+ } else if (Array.isArray(stroke)) {
13164
+ borderColor = object.getAttribute('stroke');
13165
+ } else if (gLite.isPattern(stroke)) ;
13166
+ $el.style['border-color'] = borderColor;
13167
+ $el.style['border-style'] = 'solid';
13168
+ break;
13169
+ case 'lineWidth':
13170
+ var lineWidth = object.parsedStyle.lineWidth;
13171
+ $el.style['border-width'] = (lineWidth || 0) + "px";
13172
+ break;
13173
+ case 'lineDash':
13174
+ $el.style['border-style'] = 'dashed';
13175
+ break;
13176
+ case 'filter':
13177
+ var filter = object.style.filter;
13178
+ $el.style.filter = filter;
13179
+ break;
14186
13180
  }
14187
- }, exports;
14188
- }
14189
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
14190
- try {
14191
- var info = gen[key](arg);
14192
- var value = info.value;
14193
- } catch (error) {
14194
- reject(error);
14195
- return;
14196
- }
14197
- if (info.done) {
14198
- resolve(value);
14199
- } else {
14200
- Promise.resolve(value).then(_next, _throw);
13181
+ };
13182
+ return HTMLRenderingPlugin;
13183
+ }();
13184
+ HTMLRenderingPlugin.tag = 'HTMLRendering';
13185
+ var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
13186
+ _inheritsLoose$3(Plugin, _AbstractRendererPlug);
13187
+ function Plugin() {
13188
+ var _this;
13189
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13190
+ args[_key] = arguments[_key];
13191
+ }
13192
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
13193
+ _this.name = 'html-renderer';
13194
+ return _this;
14201
13195
  }
14202
- }
14203
- function _asyncToGenerator$4(fn) {
14204
- return function () {
14205
- var self = this,
14206
- args = arguments;
14207
- return new Promise(function (resolve, reject) {
14208
- var gen = fn.apply(self, args);
14209
- function _next(value) {
14210
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
14211
- }
14212
- function _throw(err) {
14213
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
14214
- }
14215
- _next(undefined);
14216
- });
13196
+ var _proto = Plugin.prototype;
13197
+ _proto.init = function init() {
13198
+ this.addRenderingPlugin(new HTMLRenderingPlugin());
14217
13199
  };
14218
- }
13200
+ _proto.destroy = function destroy() {
13201
+ this.removeAllRenderingPlugins();
13202
+ };
13203
+ return Plugin;
13204
+ }(gLite.AbstractRendererPlugin);
13205
+
13206
+ var index_esm$2 = /*#__PURE__*/Object.freeze({
13207
+ __proto__: null,
13208
+ Plugin: Plugin$2
13209
+ });
13210
+
14219
13211
  function _inheritsLoose$4(subClass, superClass) {
14220
13212
  subClass.prototype = Object.create(superClass.prototype);
14221
13213
  subClass.prototype.constructor = subClass;
@@ -14372,6 +13364,7 @@
14372
13364
  }
14373
13365
  if (image) {
14374
13366
  image.onload = function () {
13367
+ _this.imageCache[src] = image;
14375
13368
  resolve(image);
14376
13369
  };
14377
13370
  image.onerror = function (ev) {
@@ -14379,7 +13372,6 @@
14379
13372
  };
14380
13373
  image.crossOrigin = 'Anonymous';
14381
13374
  image.src = src;
14382
- _this.imageCache[src] = image;
14383
13375
  }
14384
13376
  });
14385
13377
  };
@@ -14539,18 +13531,10 @@
14539
13531
  }
14540
13532
  }
14541
13533
  };
14542
- renderingService.hooks.init.tapPromise(LoadImagePlugin.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
14543
- return _regeneratorRuntime$4().wrap(function _callee$(_context) {
14544
- while (1) switch (_context.prev = _context.next) {
14545
- case 0:
14546
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14547
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
14548
- case 2:
14549
- case "end":
14550
- return _context.stop();
14551
- }
14552
- }, _callee);
14553
- })));
13534
+ renderingService.hooks.init.tap(LoadImagePlugin.tag, function () {
13535
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
13536
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
13537
+ });
14554
13538
  renderingService.hooks.destroy.tap(LoadImagePlugin.tag, function () {
14555
13539
  canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14556
13540
  canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
@@ -14582,8 +13566,8 @@
14582
13566
  return Plugin;
14583
13567
  }(gLite.AbstractRendererPlugin);
14584
13568
 
14585
- function _regeneratorRuntime$5() {
14586
- _regeneratorRuntime$5 = function _regeneratorRuntime() {
13569
+ function _regeneratorRuntime$2() {
13570
+ _regeneratorRuntime$2 = function _regeneratorRuntime() {
14587
13571
  return exports;
14588
13572
  };
14589
13573
  var exports = {},
@@ -14883,7 +13867,7 @@
14883
13867
  }
14884
13868
  }, exports;
14885
13869
  }
14886
- function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
13870
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
14887
13871
  try {
14888
13872
  var info = gen[key](arg);
14889
13873
  var value = info.value;
@@ -14897,17 +13881,17 @@
14897
13881
  Promise.resolve(value).then(_next, _throw);
14898
13882
  }
14899
13883
  }
14900
- function _asyncToGenerator$5(fn) {
13884
+ function _asyncToGenerator$2(fn) {
14901
13885
  return function () {
14902
13886
  var self = this,
14903
13887
  args = arguments;
14904
13888
  return new Promise(function (resolve, reject) {
14905
13889
  var gen = fn.apply(self, args);
14906
13890
  function _next(value) {
14907
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
13891
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
14908
13892
  }
14909
13893
  function _throw(err) {
14910
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
13894
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
14911
13895
  }
14912
13896
  _next(undefined);
14913
13897
  });
@@ -15058,9 +14042,9 @@
15058
14042
  return _load.apply(this, arguments);
15059
14043
  }
15060
14044
  function _load() {
15061
- _load = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee(module, imports) {
14045
+ _load = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(module, imports) {
15062
14046
  var bytes, instance;
15063
- return _regeneratorRuntime$5().wrap(function _callee$(_context) {
14047
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
15064
14048
  while (1) switch (_context.prev = _context.next) {
15065
14049
  case 0:
15066
14050
  if (!(typeof Response === 'function' && module instanceof Response)) {
@@ -15124,9 +14108,9 @@
15124
14108
  return _init.apply(this, arguments);
15125
14109
  }
15126
14110
  function _init() {
15127
- _init = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee2(input) {
14111
+ _init = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee2(input) {
15128
14112
  var imports, _yield$load, instance, module;
15129
- return _regeneratorRuntime$5().wrap(function _callee2$(_context2) {
14113
+ return _regeneratorRuntime$2().wrap(function _callee2$(_context2) {
15130
14114
  while (1) switch (_context2.prev = _context2.next) {
15131
14115
  case 0:
15132
14116
  imports = {};
@@ -15205,6 +14189,16 @@
15205
14189
  function translateTextureDimension(dimension) {
15206
14190
  if (dimension === TextureDimension.n2D) return '2d';else if (dimension === TextureDimension.Cube) return '3d';else if (dimension === TextureDimension.n2DArray) return '3d';else if (dimension === TextureDimension.n3D) return '3d';else throw new Error('whoops');
15207
14191
  }
14192
+ function translateBufferUsage(usage_) {
14193
+ var usage = 0;
14194
+ if (usage_ & BufferUsage.INDEX) usage |= GPUBufferUsage.INDEX;
14195
+ if (usage_ & BufferUsage.VERTEX) usage |= GPUBufferUsage.VERTEX;
14196
+ if (usage_ & BufferUsage.UNIFORM) usage |= GPUBufferUsage.UNIFORM;
14197
+ if (usage_ & BufferUsage.STORAGE) usage |= GPUBufferUsage.STORAGE;
14198
+ if (usage_ & BufferUsage.COPY_SRC) usage |= GPUBufferUsage.COPY_SRC;
14199
+ usage |= GPUBufferUsage.COPY_DST;
14200
+ return usage;
14201
+ }
15208
14202
  function translateWrapMode(wrapMode) {
15209
14203
  if (wrapMode === WrapMode.Clamp) return 'clamp-to-edge';else if (wrapMode === WrapMode.Repeat) return 'repeat';else if (wrapMode === WrapMode.Mirror) return 'mirror-repeat';else throw new Error('whoops');
15210
14204
  }
@@ -15217,6 +14211,21 @@
15217
14211
  function translateSampleType(type) {
15218
14212
  if (type === SamplerFormatKind.Float) return 'float';else if (type === SamplerFormatKind.Depth) return 'depth';else throw new Error('whoops');
15219
14213
  }
14214
+ function translateBindGroupSamplerBinding(sampler) {
14215
+ if (sampler.formatKind === SamplerFormatKind.Depth && sampler.comparison) {
14216
+ return {
14217
+ type: 'comparison'
14218
+ };
14219
+ } else if (sampler.formatKind === SamplerFormatKind.Float) {
14220
+ return {
14221
+ type: 'filtering'
14222
+ };
14223
+ } else {
14224
+ return {
14225
+ type: 'non-filtering'
14226
+ };
14227
+ }
14228
+ }
15220
14229
  function translateViewDimension(dimension) {
15221
14230
  if (dimension === TextureDimension.n2D) return '2d';else if (dimension === TextureDimension.n2DArray) return '2d-array';else if (dimension === TextureDimension.n3D) return '3d';else if (dimension === TextureDimension.Cube) return 'cube';else throw new Error('whoops');
15222
14231
  }
@@ -15277,20 +14286,30 @@
15277
14286
  function translateBlendMode(mode) {
15278
14287
  if (mode === BlendMode.Add) return 'add';else if (mode === BlendMode.Subtract) return 'subtract';else if (mode === BlendMode.ReverseSubtract) return 'reverse-subtract';else throw new Error('whoops');
15279
14288
  }
15280
- function translateBlendState(blendState) {
14289
+ function translateBlendComponent(ch) {
15281
14290
  return {
15282
- operation: translateBlendMode(blendState.blendMode),
15283
- srcFactor: translateBlendFactor(blendState.blendSrcFactor),
15284
- dstFactor: translateBlendFactor(blendState.blendDstFactor)
14291
+ operation: translateBlendMode(ch.blendMode),
14292
+ srcFactor: translateBlendFactor(ch.blendSrcFactor),
14293
+ dstFactor: translateBlendFactor(ch.blendDstFactor)
15285
14294
  };
15286
14295
  }
14296
+ function blendComponentIsNil(ch) {
14297
+ return ch.blendMode === BlendMode.Add && ch.blendSrcFactor === BlendFactor.One && ch.blendDstFactor === BlendFactor.Zero;
14298
+ }
14299
+ function translateBlendState(attachmentState) {
14300
+ if (blendComponentIsNil(attachmentState.rgbBlendState) && blendComponentIsNil(attachmentState.alphaBlendState)) {
14301
+ return undefined;
14302
+ } else {
14303
+ return {
14304
+ color: translateBlendComponent(attachmentState.rgbBlendState),
14305
+ alpha: translateBlendComponent(attachmentState.alphaBlendState)
14306
+ };
14307
+ }
14308
+ }
15287
14309
  function translateColorState(attachmentState, format) {
15288
14310
  return {
15289
14311
  format: translateTextureFormat(format),
15290
- blend: {
15291
- color: translateBlendState(attachmentState.rgbBlendState),
15292
- alpha: translateBlendState(attachmentState.alphaBlendState)
15293
- },
14312
+ blend: translateBlendState(attachmentState),
15294
14313
  writeMask: attachmentState.channelWriteMask
15295
14314
  };
15296
14315
  }
@@ -15319,7 +14338,7 @@
15319
14338
  if (frequency === VertexBufferFrequency.PerVertex) return 'vertex';else if (frequency === VertexBufferFrequency.PerInstance) return 'instance';else throw new Error('whoops');
15320
14339
  }
15321
14340
  function translateVertexFormat(format) {
15322
- if (format === Format.U8_R) return 'uint8x2';else if (format === Format.U8_RG) return 'uint8x2';else if (format === Format.U8_RGB) return 'uint8x4';else if (format === Format.U8_RGBA) return 'uint8x4';else if (format === Format.U8_RGBA_NORM) return 'unorm8x4';else if (format === Format.S8_RGB_NORM) return 'snorm8x4';else if (format === Format.S8_RGBA_NORM) return 'snorm8x4';else if (format === Format.S16_RG) return 'uint16x2';else if (format === Format.F32_R) return 'float32';else if (format === Format.F32_RG) return 'float32x2';else if (format === Format.F32_RGB) return 'float32x3';else if (format === Format.F32_RGBA) return 'float32x4';else throw new Error('whoops');
14341
+ if (format === Format.U8_R) return 'uint8x2';else if (format === Format.U8_RG) return 'uint8x2';else if (format === Format.U8_RGB) return 'uint8x4';else if (format === Format.U8_RGBA) return 'uint8x4';else if (format === Format.U8_RG_NORM) return 'unorm8x2';else if (format === Format.U8_RGBA_NORM) return 'unorm8x4';else if (format === Format.S8_RGB_NORM) return 'snorm8x4';else if (format === Format.S8_RGBA_NORM) return 'snorm8x4';else if (format === Format.U16_RG_NORM) return 'unorm16x2';else if (format === Format.U16_RGBA_NORM) return 'unorm16x4';else if (format === Format.S16_RG_NORM) return 'snorm16x2';else if (format === Format.S16_RGBA_NORM) return 'snorm16x4';else if (format === Format.S16_RG) return 'uint16x2';else if (format === Format.F16_RG) return 'float16x2';else if (format === Format.F16_RGBA) return 'float16x4';else if (format === Format.F32_R) return 'float32';else if (format === Format.F32_RG) return 'float32x2';else if (format === Format.F32_RGB) return 'float32x3';else if (format === Format.F32_RGBA) return 'float32x4';else throw 'whoops';
15323
14342
  }
15324
14343
  function isFormatTextureCompressionBC(format) {
15325
14344
  var formatTypeFlags = getFormatTypeFlags(format);
@@ -15543,7 +14562,7 @@
15543
14562
  binding: numBindings++,
15544
14563
  resource: gpuTextureView
15545
14564
  });
15546
- var sampler = _binding2.sampler !== null ? _binding2.sampler : _this.device.fallbackSampler;
14565
+ var sampler = _binding2.sampler !== null ? _binding2.sampler : _this.device.getFallbackSampler(samplerEntry);
15547
14566
  var gpuSampler = getPlatformSampler(sampler);
15548
14567
  gpuBindGroupEntries[1].push({
15549
14568
  binding: numBindings++,
@@ -15552,11 +14571,11 @@
15552
14571
  }
15553
14572
  _this.gpuBindGroup = gpuBindGroupEntries.filter(function (entries) {
15554
14573
  return entries.length > 0;
15555
- }).map(function (gpuBindGroupEntry, i) {
14574
+ }).map(function (gpuBindGroupEntries, i) {
15556
14575
  return _this.device.device.createBindGroup({
15557
- layout: pipeline.getBindGroupLayout(i),
15558
14576
  // layout: bindGroupLayout.gpuBindGroupLayout[i],
15559
- entries: gpuBindGroupEntry
14577
+ layout: pipeline.getBindGroupLayout(i),
14578
+ entries: gpuBindGroupEntries
15560
14579
  });
15561
14580
  });
15562
14581
  _this.bindingLayout = descriptor.bindingLayout;
@@ -15589,26 +14608,26 @@
15589
14608
  _this.usage = void 0;
15590
14609
  var usage = descriptor.usage,
15591
14610
  viewOrSize = descriptor.viewOrSize;
15592
- var alignedLength = isView(viewOrSize) ? viewOrSize.byteLength + 3 & ~3 : viewOrSize + 3 & ~3; // 4 bytes alignments (because of the upload which requires this)
15593
- _this.usage = usage;
14611
+ var useMapRead = !!(usage & BufferUsage.MAP_READ);
14612
+ // const alignedLength = isView(viewOrSize)
14613
+ // ? viewOrSize.byteLength
14614
+ // : viewOrSize * 4; // 4 bytes alignments (because of the upload which requires this)
14615
+ _this.usage = translateBufferUsage(usage);
15594
14616
  // Buffer usages (BufferUsage::(MapRead|CopyDst|Storage)) is invalid. If a buffer usage contains BufferUsage::MapRead the only other allowed usage is BufferUsage::CopyDst.
15595
14617
  // @see https://www.w3.org/TR/webgpu/#dom-gpubufferusage-copy_dst
15596
- if (_this.usage & BufferUsage.MAP_READ) {
14618
+ if (useMapRead) {
15597
14619
  _this.usage = BufferUsage.MAP_READ | BufferUsage.COPY_DST;
15598
14620
  }
15599
14621
  var mapBuffer = isView(viewOrSize);
15600
- _this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize;
14622
+ _this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize * 4;
15601
14623
  _this.view = isView(viewOrSize) ? viewOrSize : null;
15602
14624
  _this.gpuBuffer = _this.device.device.createBuffer({
15603
14625
  usage: _this.usage,
15604
- size: alignedLength,
15605
- mappedAtCreation: mapBuffer
14626
+ size: _this.size,
14627
+ mappedAtCreation: useMapRead ? mapBuffer : false
15606
14628
  });
15607
- if (mapBuffer) {
15608
- var arrayBuffer = _this.gpuBuffer.getMappedRange();
15609
- // @ts-expect-error
15610
- new viewOrSize.constructor(arrayBuffer).set(viewOrSize);
15611
- _this.gpuBuffer.unmap();
14629
+ if (isView(viewOrSize)) {
14630
+ _this.setSubData(0, new Uint8Array(viewOrSize.buffer));
15612
14631
  }
15613
14632
  return _this;
15614
14633
  }
@@ -15656,7 +14675,6 @@
15656
14675
  var ComputePass_WebGPU = /*#__PURE__*/function () {
15657
14676
  function ComputePass_WebGPU() {
15658
14677
  this.commandEncoder = null;
15659
- this.descriptor = void 0;
15660
14678
  this.gpuComputePassDescriptor = void 0;
15661
14679
  this.gpuComputePassEncoder = null;
15662
14680
  }
@@ -15677,9 +14695,8 @@
15677
14695
  /**
15678
14696
  * @see https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-begincomputepass
15679
14697
  */;
15680
- _proto.beginComputePass = function beginComputePass(computePassDescriptor) {
14698
+ _proto.beginComputePass = function beginComputePass() {
15681
14699
  assert(this.gpuComputePassEncoder === null);
15682
- this.setComputePassDescriptor(computePassDescriptor);
15683
14700
  this.gpuComputePassEncoder = this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor);
15684
14701
  };
15685
14702
  _proto.setPipeline = function setPipeline(pipeline_) {
@@ -15687,12 +14704,19 @@
15687
14704
  var gpuComputePipeline = assertExists(pipeline.gpuComputePipeline);
15688
14705
  this.gpuComputePassEncoder.setPipeline(gpuComputePipeline);
15689
14706
  };
15690
- _proto.setBindings = function setBindings(bindingLayoutIndex, bindings_) {
14707
+ _proto.setBindings = function setBindings(bindingLayoutIndex, bindings_, dynamicByteOffsets) {
15691
14708
  var bindings = bindings_;
15692
- this.gpuComputePassEncoder.setBindGroup(bindingLayoutIndex, bindings.gpuBindGroup[0]);
14709
+ this.gpuComputePassEncoder.setBindGroup(bindingLayoutIndex, bindings.gpuBindGroup[0], dynamicByteOffsets);
15693
14710
  };
15694
- _proto.setComputePassDescriptor = function setComputePassDescriptor(descriptor) {
15695
- this.descriptor = descriptor;
14711
+ _proto.beginDebugGroup = function beginDebugGroup(name) {
14712
+ // FIREFOX MISSING
14713
+ if (this.gpuComputePassEncoder.pushDebugGroup === undefined) return;
14714
+ this.gpuComputePassEncoder.pushDebugGroup(name);
14715
+ };
14716
+ _proto.endDebugGroup = function endDebugGroup() {
14717
+ // FIREFOX MISSING
14718
+ if (this.gpuComputePassEncoder.popDebugGroup === undefined) return;
14719
+ this.gpuComputePassEncoder.popDebugGroup();
15696
14720
  };
15697
14721
  return ComputePass_WebGPU;
15698
14722
  }();
@@ -15746,27 +14770,26 @@
15746
14770
  _this.buffers = void 0;
15747
14771
  _this.indexFormat = void 0;
15748
14772
  var buffers = [];
15749
- for (var i = 0; i < descriptor.vertexBufferDescriptors.length; i++) {
15750
- var b = descriptor.vertexBufferDescriptors[i];
15751
- if (isNil(b)) continue;
15752
- var arrayStride = b.byteStride;
15753
- var stepMode = translateVertexBufferFrequency(b.frequency);
15754
- var attributes = [];
15755
- buffers[i] = {
15756
- arrayStride: arrayStride,
15757
- stepMode: stepMode,
15758
- attributes: attributes
15759
- };
15760
- }
15761
- for (var _i = 0; _i < descriptor.vertexAttributeDescriptors.length; _i++) {
15762
- var attr = descriptor.vertexAttributeDescriptors[_i];
15763
- var _b = assertExists(buffers[attr.bufferIndex]);
14773
+ for (var i = 0; i < descriptor.vertexAttributeDescriptors.length; i++) {
14774
+ var attr = descriptor.vertexAttributeDescriptors[i];
15764
14775
  var attribute = {
15765
14776
  shaderLocation: attr.location,
15766
14777
  format: translateVertexFormat(attr.format),
15767
14778
  offset: attr.bufferByteOffset
15768
14779
  };
15769
- _b.attributes.push(attribute);
14780
+ if (buffers[attr.bufferIndex] !== undefined) {
14781
+ buffers[attr.bufferIndex].attributes.push(attribute);
14782
+ } else {
14783
+ var b = assertExists(descriptor.vertexBufferDescriptors[attr.bufferIndex]);
14784
+ var arrayStride = b.byteStride;
14785
+ var stepMode = translateVertexBufferFrequency(b.frequency);
14786
+ var attributes = [attribute];
14787
+ buffers[attr.bufferIndex] = {
14788
+ arrayStride: arrayStride,
14789
+ stepMode: stepMode,
14790
+ attributes: attributes
14791
+ };
14792
+ }
15770
14793
  }
15771
14794
  _this.indexFormat = translateIndexFormat(descriptor.indexBufferFormat);
15772
14795
  _this.buffers = buffers;
@@ -15876,17 +14899,35 @@
15876
14899
  }) || this;
15877
14900
  _this.type = ResourceType.QueryPool;
15878
14901
  _this.querySet = void 0;
14902
+ _this.resolveBuffer = void 0;
14903
+ _this.cpuBuffer = void 0;
14904
+ _this.results = void 0;
15879
14905
  var elemCount = descriptor.elemCount,
15880
14906
  type = descriptor.type;
15881
14907
  _this.querySet = _this.device.device.createQuerySet({
15882
14908
  type: translateQueryPoolType(type),
15883
14909
  count: elemCount
15884
14910
  });
14911
+ _this.resolveBuffer = _this.device.device.createBuffer({
14912
+ size: elemCount * 8,
14913
+ usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC
14914
+ });
14915
+ _this.cpuBuffer = _this.device.device.createBuffer({
14916
+ size: elemCount * 8,
14917
+ usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
14918
+ });
14919
+ _this.results = null;
15885
14920
  return _this;
15886
14921
  }
15887
14922
  var _proto = QueryPool_WebGPU.prototype;
15888
14923
  _proto.queryResultOcclusion = function queryResultOcclusion(dstOffs) {
15889
- return true;
14924
+ if (this.results === null) return null;
14925
+ return this.results[dstOffs] !== BigInt(0);
14926
+ };
14927
+ _proto.destroy = function destroy() {
14928
+ this.querySet.destroy();
14929
+ this.resolveBuffer.destroy();
14930
+ this.cpuBuffer.destroy();
15890
14931
  };
15891
14932
  return QueryPool_WebGPU;
15892
14933
  }(ResourceBase_WebGPU);
@@ -16334,7 +15375,9 @@
16334
15375
  _proto.setBindings = function setBindings(bindingLayoutIndex, bindings_, dynamicByteOffsets) {
16335
15376
  var bindings = bindings_;
16336
15377
  this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 0, bindings.gpuBindGroup[0], dynamicByteOffsets.slice(0, bindings.bindingLayout.numUniformBuffers));
16337
- this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 1, bindings.gpuBindGroup[1]);
15378
+ if (bindings.gpuBindGroup[1]) {
15379
+ this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 1, bindings.gpuBindGroup[1]);
15380
+ }
16338
15381
  };
16339
15382
  _proto.setStencilRef = function setStencilRef(ref) {
16340
15383
  this.gpuRenderPassEncoder.setStencilReference(ref);
@@ -16411,7 +15454,6 @@
16411
15454
  }) || this;
16412
15455
  _this.type = ResourceType.RenderPipeline;
16413
15456
  _this.descriptor = void 0;
16414
- _this.isCreating = false;
16415
15457
  _this.isCreatingAsync = false;
16416
15458
  _this.gpuRenderPipeline = null;
16417
15459
  _this.descriptor = descriptor;
@@ -16452,6 +15494,7 @@
16452
15494
  minFilter: translateMinMagFilter(descriptor.minFilter),
16453
15495
  magFilter: translateMinMagFilter(descriptor.magFilter),
16454
15496
  mipmapFilter: translateMipFilter(descriptor.mipFilter),
15497
+ compare: descriptor.compareMode !== undefined ? translateCompareMode(descriptor.compareMode) : undefined,
16455
15498
  maxAnisotropy: maxAnisotropy
16456
15499
  });
16457
15500
  return _this;
@@ -16510,19 +15553,22 @@
16510
15553
  function Device_WebGPU(adapter, device, canvas, canvasContext, glsl_compile) {
16511
15554
  this.swapChainWidth = 0;
16512
15555
  this.swapChainHeight = 0;
15556
+ this.swapChainFormat = void 0;
16513
15557
  this.swapChainTextureUsage = GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST;
16514
15558
  this._resourceUniqueId = 0;
16515
15559
  this.renderPassPool = [];
16516
15560
  this.computePassPool = [];
16517
15561
  this.bindGroupLayoutCache = new HashMap(bindingLayoutDescriptorEqual, nullHashFunc);
15562
+ // private frameCommandEncoder: GPUCommandEncoder | null = null;
15563
+ // private queryPoolsSubmitted: QueryPool_WebGPU[] = [];
16518
15564
  this.fallbackTexture2D = void 0;
16519
15565
  this.fallbackTexture2DDepth = void 0;
16520
15566
  this.fallbackTexture2DArray = void 0;
16521
15567
  this.fallbackTexture3D = void 0;
16522
15568
  this.fallbackTextureCube = void 0;
16523
- this.fallbackSampler = void 0;
15569
+ this.fallbackSamplerFiltering = void 0;
15570
+ this.fallbackSamplerComparison = void 0;
16524
15571
  this.featureTextureCompressionBC = false;
16525
- // private fullscreenAlphaClear: FullscreenAlphaClear;
16526
15572
  // VendorInfo
16527
15573
  this.platformString = 'WebGPU';
16528
15574
  this.glslVersion = "#version 440";
@@ -16532,12 +15578,10 @@
16532
15578
  this.clipSpaceNearZ = ClipSpaceNearZ.Zero;
16533
15579
  this.supportsSyncPipelineCompilation = false;
16534
15580
  this.supportMRT = true;
16535
- this.adapter = void 0;
16536
15581
  this.device = void 0;
16537
15582
  this.canvas = void 0;
16538
15583
  this.canvasContext = void 0;
16539
15584
  this.glsl_compile = void 0;
16540
- this.adapter = adapter;
16541
15585
  this.device = device;
16542
15586
  this.canvas = canvas;
16543
15587
  this.canvasContext = canvasContext;
@@ -16547,13 +15591,23 @@
16547
15591
  this.fallbackTexture2DArray = this.createFallbackTexture(TextureDimension.n2DArray, SamplerFormatKind.Float);
16548
15592
  this.fallbackTexture3D = this.createFallbackTexture(TextureDimension.n3D, SamplerFormatKind.Float);
16549
15593
  this.fallbackTextureCube = this.createFallbackTexture(TextureDimension.Cube, SamplerFormatKind.Float);
16550
- this.fallbackSampler = this.createSampler({
16551
- wrapS: WrapMode.Clamp,
16552
- wrapT: WrapMode.Clamp,
15594
+ this.fallbackSamplerFiltering = this.createSampler({
15595
+ wrapS: WrapMode.Repeat,
15596
+ wrapT: WrapMode.Repeat,
15597
+ minFilter: TexFilterMode.Point,
15598
+ magFilter: TexFilterMode.Point,
15599
+ mipFilter: MipFilterMode.Nearest
15600
+ });
15601
+ this.setResourceName(this.fallbackSamplerFiltering, 'Fallback Sampler Filtering');
15602
+ this.fallbackSamplerComparison = this.createSampler({
15603
+ wrapS: WrapMode.Repeat,
15604
+ wrapT: WrapMode.Repeat,
16553
15605
  minFilter: TexFilterMode.Point,
16554
15606
  magFilter: TexFilterMode.Point,
16555
- mipFilter: MipFilterMode.NoMip
15607
+ mipFilter: MipFilterMode.Nearest,
15608
+ compareMode: CompareMode.Always
16556
15609
  });
15610
+ this.setResourceName(this.fallbackSamplerFiltering, 'Fallback Sampler Filtering');
16557
15611
  // Firefox doesn't support GPUDevice.features yet...
16558
15612
  if (this.device.features) {
16559
15613
  this.featureTextureCompressionBC = this.device.features.has('texture-compression-bc');
@@ -16561,7 +15615,15 @@
16561
15615
  this.device.onuncapturederror = function (event) {
16562
15616
  console.error(event.error);
16563
15617
  };
16564
- // this.fullscreenAlphaClear = new FullscreenAlphaClear(this.device);
15618
+ this.swapChainFormat = navigator.gpu.getPreferredCanvasFormat();
15619
+ // @see https://www.w3.org/TR/webgpu/#canvas-configuration
15620
+ this.canvasContext.configure({
15621
+ device: this.device,
15622
+ format: this.swapChainFormat,
15623
+ usage: this.swapChainTextureUsage,
15624
+ // @see https://www.w3.org/TR/webgpu/#enumdef-gpucanvascompositingalphamode
15625
+ alphaMode: 'opaque'
15626
+ });
16565
15627
  }
16566
15628
  // SwapChain
16567
15629
  var _proto = Device_WebGPU.prototype;
@@ -16569,16 +15631,6 @@
16569
15631
  if (this.swapChainWidth === width && this.swapChainHeight === height) return;
16570
15632
  this.swapChainWidth = width;
16571
15633
  this.swapChainHeight = height;
16572
- // @see https://www.w3.org/TR/webgpu/#canvas-configuration
16573
- this.canvasContext.configure({
16574
- device: this.device,
16575
- format: 'bgra8unorm',
16576
- usage: this.swapChainTextureUsage,
16577
- // @see https://developer.chrome.com/blog/new-in-chrome-94/#canvas-colorspace
16578
- // colorSpace: 'srgb',
16579
- // @see https://www.w3.org/TR/webgpu/#enumdef-gpucanvascompositingalphamode
16580
- alphaMode: 'premultiplied'
16581
- });
16582
15634
  };
16583
15635
  _proto.getOnscreenTexture = function getOnscreenTexture() {
16584
15636
  // @see https://www.w3.org/TR/webgpu/#dom-gpucanvascontext-getcurrenttexture
@@ -16610,11 +15662,23 @@
16610
15662
  _proto.getCanvas = function getCanvas() {
16611
15663
  return this.canvas;
16612
15664
  };
16613
- _proto.present = function present() {
16614
- // this.fullscreenAlphaClear.render(
16615
- // this.device,
16616
- // this.canvasContext.getCurrentTexture().createView(),
16617
- // );
15665
+ _proto.beginFrame = function beginFrame() {
15666
+ // assert(this.frameCommandEncoder === null);
15667
+ // this.frameCommandEncoder = this.device.createCommandEncoder();
15668
+ };
15669
+ _proto.endFrame = function endFrame() {
15670
+ // assert(this.frameCommandEncoder !== null);
15671
+ // this.device.queue.submit([this.frameCommandEncoder.finish()]);
15672
+ // this.frameCommandEncoder = null;
15673
+ // for (let i = 0; i < this.queryPoolsSubmitted.length; i++) {
15674
+ // const queryPool = this.queryPoolsSubmitted[i];
15675
+ // queryPool.cpuBuffer.mapAsync(GPUMapMode.READ).then(() => {
15676
+ // queryPool.results = new BigUint64Array(
15677
+ // queryPool.cpuBuffer.getMappedRange(),
15678
+ // );
15679
+ // });
15680
+ // }
15681
+ // this.queryPoolsSubmitted.length = 0;
16618
15682
  };
16619
15683
  _proto.getNextUniqueId = function getNextUniqueId() {
16620
15684
  return ++this._resourceUniqueId;
@@ -16733,6 +15797,14 @@
16733
15797
  texture.gpuTextureView = gpuTextureView;
16734
15798
  }
16735
15799
  };
15800
+ _proto.getFallbackSampler = function getFallbackSampler(samplerEntry) {
15801
+ var formatKind = samplerEntry.formatKind;
15802
+ if (formatKind === SamplerFormatKind.Depth && samplerEntry.comparison) {
15803
+ return this.fallbackSamplerComparison;
15804
+ } else {
15805
+ return this.fallbackSamplerFiltering;
15806
+ }
15807
+ };
16736
15808
  _proto.getFallbackTexture = function getFallbackTexture(samplerEntry) {
16737
15809
  var dimension = samplerEntry.dimension,
16738
15810
  formatKind = samplerEntry.formatKind;
@@ -16839,15 +15911,15 @@
16839
15911
  entries[1].push({
16840
15912
  binding: entries[1].length,
16841
15913
  visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
16842
- sampler: {
16843
- type: 'filtering'
16844
- }
15914
+ sampler: translateBindGroupSamplerBinding(samplerEntry)
16845
15915
  });
16846
15916
  }
16847
15917
  var gpuBindGroupLayout = entries.map(function (entries) {
16848
- return _this.device.createBindGroupLayout({
15918
+ return entries.length ? _this.device.createBindGroupLayout({
16849
15919
  entries: entries
16850
- });
15920
+ }) : null;
15921
+ }).filter(function (layout) {
15922
+ return !!layout;
16851
15923
  });
16852
15924
  return {
16853
15925
  gpuBindGroupLayout: gpuBindGroupLayout
@@ -16863,8 +15935,16 @@
16863
15935
  });
16864
15936
  };
16865
15937
  _proto._createRenderPipeline = function _createRenderPipeline(renderPipeline, async) {
16866
- if (renderPipeline.isCreating) return;
16867
- if (renderPipeline.gpuRenderPipeline !== null) return;
15938
+ // if (this.device.createRenderPipelineAsync === undefined) {
15939
+ // async = false;
15940
+ // }
15941
+ // // If we're already in the process of creating a the pipeline async, no need to kick the process off again...
15942
+ // if (async && renderPipeline.isCreatingAsync) {
15943
+ // return;
15944
+ // }
15945
+ if (renderPipeline.gpuRenderPipeline !== null) {
15946
+ return;
15947
+ }
16868
15948
  var descriptor = renderPipeline.descriptor;
16869
15949
  var program = descriptor.program;
16870
15950
  var vertexStage = program.vertexStage,
@@ -16877,9 +15957,10 @@
16877
15957
  var buffers = undefined;
16878
15958
  if (descriptor.inputLayout !== null) buffers = descriptor.inputLayout.buffers;
16879
15959
  var sampleCount = descriptor.sampleCount;
16880
- renderPipeline.isCreating = true;
16881
- var gpuRenderPipeline = {
15960
+ // renderPipeline.isCreatingAsync = true;
15961
+ var gpuRenderPipelineDescriptor = {
16882
15962
  layout: layout,
15963
+ // layout: 'auto',
16883
15964
  vertex: _extends$1({}, vertexStage, {
16884
15965
  buffers: buffers
16885
15966
  }),
@@ -16894,9 +15975,26 @@
16894
15975
  };
16895
15976
  // TODO: async creation
16896
15977
  // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipeline
16897
- renderPipeline.gpuRenderPipeline = this.device.createRenderPipeline(gpuRenderPipeline);
16898
- if (renderPipeline.name !== undefined) renderPipeline.gpuRenderPipeline.label = renderPipeline.name;
15978
+ // renderPipeline.gpuRenderPipeline =
15979
+ // this.device.createRenderPipeline(gpuRenderPipeline);
15980
+ // if (renderPipeline.name !== undefined)
15981
+ // renderPipeline.gpuRenderPipeline.label = renderPipeline.name;
15982
+ // if (async) {
15983
+ // const gpuRenderPipeline = await this.device.createRenderPipelineAsync(
15984
+ // gpuRenderPipelineDescriptor,
15985
+ // );
15986
+ // // We might have created a sync pipeline while we were async building; no way to cancel the async
15987
+ // // pipeline build at this point, so just chuck it out :/
15988
+ // if (renderPipeline.gpuRenderPipeline === null)
15989
+ // renderPipeline.gpuRenderPipeline = gpuRenderPipeline;
15990
+ // } else {
15991
+ renderPipeline.gpuRenderPipeline = this.device.createRenderPipeline(gpuRenderPipelineDescriptor);
15992
+ // }
15993
+ // // if (renderPipeline.ResourceName !== undefined)
15994
+ // // renderPipeline.gpuRenderPipeline.label = renderPipeline.ResourceName;
15995
+ // renderPipeline.isCreatingAsync = false;
16899
15996
  };
15997
+
16900
15998
  _proto.createReadback = function createReadback() {
16901
15999
  return new Readback_WebGPU({
16902
16000
  id: this.getNextUniqueId(),
@@ -16916,11 +16014,11 @@
16916
16014
  pass.beginRenderPass(renderPassDescriptor);
16917
16015
  return pass;
16918
16016
  };
16919
- _proto.createComputePass = function createComputePass(computePassDescriptor) {
16017
+ _proto.createComputePass = function createComputePass() {
16920
16018
  var pass = this.computePassPool.pop();
16921
16019
  if (pass === undefined) pass = new ComputePass_WebGPU();
16922
16020
  pass.commandEncoder = this.device.createCommandEncoder();
16923
- pass.beginComputePass(computePassDescriptor);
16021
+ pass.beginComputePass();
16924
16022
  return pass;
16925
16023
  };
16926
16024
  _proto.submitPass = function submitPass(_pass) {
@@ -16929,12 +16027,18 @@
16929
16027
  var commands = pass.finish();
16930
16028
  queue.submit([commands]);
16931
16029
  pass.commandEncoder = null;
16932
- if (pass instanceof RenderPass_WebGPU) {
16933
- this.renderPassPool.push(pass);
16934
- } else {
16935
- this.computePassPool.push(pass);
16936
- }
16030
+ // if (pass instanceof RenderPass_WebGPU) {
16031
+ // pass.finish();
16032
+ // this.renderPassPool.push(pass);
16033
+ // if (pass.occlusionQueryPool !== null) {
16034
+ // this.queryPoolsSubmitted.push(pass.occlusionQueryPool);
16035
+ // }
16036
+ // } else if (pass instanceof ComputePass_WebGPU) {
16037
+ // pass.finish();
16038
+ // this.computePassPool.push(pass);
16039
+ // }
16937
16040
  };
16041
+
16938
16042
  _proto.copySubTexture2D = function copySubTexture2D(dst_, dstX, dstY, src_, srcX, srcY) {
16939
16043
  var cmd = this.device.createCommandEncoder();
16940
16044
  var dst = dst_;
@@ -17035,9 +16139,9 @@
17035
16139
  }
17036
16140
  var _proto = WebGPUDeviceContribution.prototype;
17037
16141
  _proto.createSwapChain = /*#__PURE__*/function () {
17038
- var _createSwapChain = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee($canvas) {
17039
- var adapter, optionalFeatures, requiredFeatures, device, context;
17040
- return _regeneratorRuntime$5().wrap(function _callee$(_context) {
16142
+ var _createSwapChain = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee($canvas) {
16143
+ var adapter, optionalFeatures, requiredFeatures, device, onContextLost, context;
16144
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
17041
16145
  while (1) switch (_context.prev = _context.next) {
17042
16146
  case 0:
17043
16147
  if (!(gLite.runtime.globalThis.navigator.gpu === undefined)) {
@@ -17078,35 +16182,44 @@
17078
16182
  });
17079
16183
  case 18:
17080
16184
  device = _context.sent;
16185
+ if (device) {
16186
+ // @see https://github.com/gpuweb/gpuweb/blob/main/design/ErrorHandling.md#fatal-errors-requestadapter-requestdevice-and-devicelost
16187
+ onContextLost = this.pluginOptions.onContextLost;
16188
+ device.lost.then(function () {
16189
+ if (onContextLost) {
16190
+ onContextLost();
16191
+ }
16192
+ });
16193
+ }
17081
16194
  if (!(device === null)) {
17082
- _context.next = 21;
16195
+ _context.next = 22;
17083
16196
  break;
17084
16197
  }
17085
16198
  return _context.abrupt("return", null);
17086
- case 21:
16199
+ case 22:
17087
16200
  context = $canvas.getContext('webgpu');
17088
16201
  if (context) {
17089
- _context.next = 24;
16202
+ _context.next = 25;
17090
16203
  break;
17091
16204
  }
17092
16205
  return _context.abrupt("return", null);
17093
- case 24:
17094
- _context.prev = 24;
17095
- _context.next = 27;
17096
- return init('/glsl_wgsl_compiler_bg.wasm');
17097
- case 27:
17098
- _context.next = 31;
16206
+ case 25:
16207
+ _context.prev = 25;
16208
+ _context.next = 28;
16209
+ return init(this.pluginOptions.shaderCompilerPath);
16210
+ case 28:
16211
+ _context.next = 32;
17099
16212
  break;
17100
- case 29:
17101
- _context.prev = 29;
17102
- _context.t1 = _context["catch"](24);
17103
- case 31:
17104
- return _context.abrupt("return", new Device_WebGPU(adapter, device, $canvas, context, glsl_compile));
16213
+ case 30:
16214
+ _context.prev = 30;
16215
+ _context.t1 = _context["catch"](25);
17105
16216
  case 32:
16217
+ return _context.abrupt("return", new Device_WebGPU(adapter, device, $canvas, context, glsl_compile));
16218
+ case 33:
17106
16219
  case "end":
17107
16220
  return _context.stop();
17108
16221
  }
17109
- }, _callee, null, [[3, 9], [24, 29]]);
16222
+ }, _callee, this, [[3, 9], [25, 30]]);
17110
16223
  }));
17111
16224
  function createSwapChain(_x) {
17112
16225
  return _createSwapChain.apply(this, arguments);
@@ -17130,11 +16243,11 @@
17130
16243
  }
17131
16244
  var _proto = Plugin.prototype;
17132
16245
  _proto.init = function init() {
17133
- // @ts-ignore
17134
- this.context.deviceContribution = new WebGPUDeviceContribution(_extends$1({}, this.options));
16246
+ this.context.deviceContribution = new WebGPUDeviceContribution(_extends$1({
16247
+ shaderCompilerPath: '/glsl_wgsl_compiler_bg.wasm'
16248
+ }, this.options));
17135
16249
  };
17136
16250
  _proto.destroy = function destroy() {
17137
- // @ts-ignore
17138
16251
  delete this.context.deviceContribution;
17139
16252
  };
17140
16253
  return Plugin;
@@ -17157,51 +16270,40 @@
17157
16270
  this.deviceRendererPlugin = context.deviceRendererPlugin;
17158
16271
  }
17159
16272
  var _proto = WebGPUContextService.prototype;
17160
- _proto.init = /*#__PURE__*/function () {
17161
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17162
- var _this$canvasConfig, container, canvas, $canvas;
17163
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17164
- while (1) switch (_context.prev = _context.next) {
17165
- case 0:
17166
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
17167
- if (canvas) {
17168
- this.$canvas = canvas;
17169
- if (container && canvas.parentElement !== container) {
17170
- container.appendChild(canvas);
17171
- }
17172
- this.$container = canvas.parentElement;
17173
- this.canvasConfig.container = this.$container;
17174
- } else if (container) {
17175
- // create container
17176
- this.$container = isString(container) ? document.getElementById(container) : container;
17177
- if (this.$container) {
17178
- // create canvas
17179
- $canvas = document.createElement('canvas');
17180
- this.$container.appendChild($canvas);
17181
- if (!this.$container.style.position) {
17182
- this.$container.style.position = 'relative';
17183
- }
17184
- this.$canvas = $canvas;
17185
- }
17186
- }
17187
- this.resize(this.canvasConfig.width, this.canvasConfig.height);
17188
- case 3:
17189
- case "end":
17190
- return _context.stop();
16273
+ _proto.init = function init() {
16274
+ var _this$canvasConfig = this.canvasConfig,
16275
+ container = _this$canvasConfig.container,
16276
+ canvas = _this$canvasConfig.canvas;
16277
+ if (canvas) {
16278
+ this.$canvas = canvas;
16279
+ if (container && canvas.parentElement !== container) {
16280
+ container.appendChild(canvas);
16281
+ }
16282
+ this.$container = canvas.parentElement;
16283
+ this.canvasConfig.container = this.$container;
16284
+ } else if (container) {
16285
+ // create container
16286
+ this.$container = isString(container) ? document.getElementById(container) : container;
16287
+ if (this.$container) {
16288
+ // create canvas
16289
+ var $canvas = document.createElement('canvas');
16290
+ this.$container.appendChild($canvas);
16291
+ if (!this.$container.style.position) {
16292
+ this.$container.style.position = 'relative';
17191
16293
  }
17192
- }, _callee, this);
17193
- }));
17194
- function init() {
17195
- return _init.apply(this, arguments);
16294
+ this.$canvas = $canvas;
16295
+ }
17196
16296
  }
17197
- return init;
17198
- }();
16297
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
16298
+ };
17199
16299
  _proto.getDomElement = function getDomElement() {
17200
16300
  return this.$canvas;
17201
16301
  };
17202
16302
  _proto.getContext = function getContext() {
17203
- // @ts-ignore
17204
- return this.deviceRendererPlugin.getDevice().canvasContext;
16303
+ return (
16304
+ // @ts-ignore
16305
+ this.deviceRendererPlugin.getDevice().canvasContext
16306
+ );
17205
16307
  };
17206
16308
  _proto.getBoundingClientRect = function getBoundingClientRect() {
17207
16309
  if (this.$canvas.getBoundingClientRect) {
@@ -17239,16 +16341,16 @@
17239
16341
  }
17240
16342
  };
17241
16343
  _proto.toDataURL = /*#__PURE__*/function () {
17242
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
17243
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
17244
- while (1) switch (_context2.prev = _context2.next) {
16344
+ var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
16345
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
16346
+ while (1) switch (_context.prev = _context.next) {
17245
16347
  case 0:
17246
- return _context2.abrupt("return", '');
16348
+ return _context.abrupt("return", '');
17247
16349
  case 1:
17248
16350
  case "end":
17249
- return _context2.stop();
16351
+ return _context.stop();
17250
16352
  }
17251
- }, _callee2);
16353
+ }, _callee);
17252
16354
  }));
17253
16355
  function toDataURL(_x) {
17254
16356
  return _toDataURL.apply(this, arguments);
@@ -17288,7 +16390,10 @@
17288
16390
  var deviceRendererPlugin = new Plugin();
17289
16391
  _this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
17290
16392
  _this.registerPlugin(new Plugin$3());
17291
- _this.registerPlugin(new Plugin$4());
16393
+ _this.registerPlugin(new Plugin$4({
16394
+ shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
16395
+ onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost
16396
+ }));
17292
16397
  _this.registerPlugin(deviceRendererPlugin);
17293
16398
  _this.registerPlugin(new Plugin$1());
17294
16399
  _this.registerPlugin(new Plugin$2());