@antv/g-webgpu 1.7.52 → 1.7.54

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
@@ -3072,9 +3072,7 @@
3072
3072
  if (!isNaN(iterable.length)) {
3073
3073
  var i = -1,
3074
3074
  next = function next() {
3075
- for (; ++i < iterable.length;) {
3076
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
3077
- }
3075
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
3078
3076
  return next.value = undefined, next.done = !0, next;
3079
3077
  };
3080
3078
  return next.next = next;
@@ -3120,9 +3118,7 @@
3120
3118
  }), exports.keys = function (val) {
3121
3119
  var object = Object(val),
3122
3120
  keys = [];
3123
- for (var key in object) {
3124
- keys.push(key);
3125
- }
3121
+ for (var key in object) keys.push(key);
3126
3122
  return keys.reverse(), function next() {
3127
3123
  for (; keys.length;) {
3128
3124
  var key = keys.pop();
@@ -3133,9 +3129,7 @@
3133
3129
  }, exports.values = values, Context.prototype = {
3134
3130
  constructor: Context,
3135
3131
  reset: function reset(skipTempReset) {
3136
- 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) {
3137
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
3138
- }
3132
+ 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);
3139
3133
  },
3140
3134
  stop: function stop() {
3141
3135
  this.done = !0;
@@ -3314,9 +3308,7 @@
3314
3308
  }
3315
3309
  function _arrayLikeToArray(arr, len) {
3316
3310
  if (len == null || len > arr.length) len = arr.length;
3317
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
3318
- arr2[i] = arr[i];
3319
- }
3311
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3320
3312
  return arr2;
3321
3313
  }
3322
3314
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
@@ -3359,7 +3351,13 @@
3359
3351
  Renderable3D.tag = 'c-renderable-3d';
3360
3352
  var LightPool = /*#__PURE__*/function () {
3361
3353
  function LightPool() {
3354
+ /**
3355
+ * lights
3356
+ */
3362
3357
  this.lights = [];
3358
+ /**
3359
+ * support only 1 fog
3360
+ */
3363
3361
  this.fog = void 0;
3364
3362
  }
3365
3363
  var _proto = LightPool.prototype;
@@ -4747,9 +4745,7 @@
4747
4745
  }
4748
4746
  function nArray(n, c) {
4749
4747
  var d = new Array(n);
4750
- for (var i = 0; i < n; i++) {
4751
- d[i] = c();
4752
- }
4748
+ for (var i = 0; i < n; i++) d[i] = c();
4753
4749
  return d;
4754
4750
  }
4755
4751
  function prependLineNo(str, lineStart) {
@@ -4765,16 +4761,12 @@
4765
4761
  if (ch === void 0) {
4766
4762
  ch = '0';
4767
4763
  }
4768
- while (S.length < spaces) {
4769
- S = "" + ch + S;
4770
- }
4764
+ while (S.length < spaces) S = "" + ch + S;
4771
4765
  return S;
4772
4766
  }
4773
4767
  function range(start, count) {
4774
4768
  var L = [];
4775
- for (var i = start; i < start + count; i++) {
4776
- L.push(i);
4777
- }
4769
+ for (var i = start; i < start + count; i++) L.push(i);
4778
4770
  return L;
4779
4771
  }
4780
4772
  function copyChannelBlendState(dst, src) {
@@ -4797,9 +4789,7 @@
4797
4789
  }
4798
4790
  function copyAttachmentsState(dst, src) {
4799
4791
  if (dst.length !== src.length) dst.length = src.length;
4800
- for (var i = 0; i < src.length; i++) {
4801
- dst[i] = copyAttachmentState(dst[i], src[i]);
4802
- }
4792
+ for (var i = 0; i < src.length; i++) dst[i] = copyAttachmentState(dst[i], src[i]);
4803
4793
  }
4804
4794
  function setMegaStateFlags(dst, src) {
4805
4795
  if (src.attachmentsState !== undefined) {
@@ -4902,16 +4892,12 @@
4902
4892
  };
4903
4893
  function arrayEqual(a, b, e) {
4904
4894
  if (a.length !== b.length) return false;
4905
- for (var i = 0; i < a.length; i++) {
4906
- if (!e(a[i], b[i])) return false;
4907
- }
4895
+ for (var i = 0; i < a.length; i++) if (!e(a[i], b[i])) return false;
4908
4896
  return true;
4909
4897
  }
4910
4898
  function arrayCopy(a, copyFunc) {
4911
4899
  var b = Array(a.length);
4912
- for (var i = 0; i < a.length; i++) {
4913
- b[i] = copyFunc(a[i]);
4914
- }
4900
+ for (var i = 0; i < a.length; i++) b[i] = copyFunc(a[i]);
4915
4901
  return b;
4916
4902
  }
4917
4903
  function bufferBindingEquals(a, b) {
@@ -5503,8 +5489,10 @@
5503
5489
  var DeviceProgram = /*#__PURE__*/function () {
5504
5490
  function DeviceProgram() {
5505
5491
  this.name = '(unnamed)';
5492
+ // Compiled program.
5506
5493
  this.preprocessedVert = '';
5507
5494
  this.preprocessedFrag = '';
5495
+ // Inputs.
5508
5496
  this.both = '';
5509
5497
  this.vert = '';
5510
5498
  this.frag = '';
@@ -5671,9 +5659,7 @@
5671
5659
  }
5672
5660
  var _proto = HashMap.prototype;
5673
5661
  _proto.findBucketIndex = function findBucketIndex(bucket, k) {
5674
- for (var i = 0; i < bucket.keys.length; i++) {
5675
- if (this.keyEqualFunc(k, bucket.keys[i])) return i;
5676
- }
5662
+ for (var i = 0; i < bucket.keys.length; i++) if (this.keyEqualFunc(k, bucket.keys[i])) return i;
5677
5663
  return -1;
5678
5664
  };
5679
5665
  _proto.findBucket = function findBucket(k) {
@@ -5716,35 +5702,33 @@
5716
5702
  _proto.values = /*#__PURE__*/_regeneratorRuntime$1().mark(function values() {
5717
5703
  var _iterator2, _step2, bucket, j;
5718
5704
  return _regeneratorRuntime$1().wrap(function values$(_context) {
5719
- while (1) {
5720
- switch (_context.prev = _context.next) {
5721
- case 0:
5722
- _iterator2 = _createForOfIteratorHelperLoose(this.buckets.values());
5723
- case 1:
5724
- if ((_step2 = _iterator2()).done) {
5725
- _context.next = 12;
5726
- break;
5727
- }
5728
- bucket = _step2.value;
5729
- j = bucket.values.length - 1;
5730
- case 4:
5731
- if (!(j >= 0)) {
5732
- _context.next = 10;
5733
- break;
5734
- }
5735
- _context.next = 7;
5736
- return bucket.values[j];
5737
- case 7:
5738
- j--;
5739
- _context.next = 4;
5705
+ while (1) switch (_context.prev = _context.next) {
5706
+ case 0:
5707
+ _iterator2 = _createForOfIteratorHelperLoose(this.buckets.values());
5708
+ case 1:
5709
+ if ((_step2 = _iterator2()).done) {
5710
+ _context.next = 12;
5740
5711
  break;
5741
- case 10:
5742
- _context.next = 1;
5712
+ }
5713
+ bucket = _step2.value;
5714
+ j = bucket.values.length - 1;
5715
+ case 4:
5716
+ if (!(j >= 0)) {
5717
+ _context.next = 10;
5743
5718
  break;
5744
- case 12:
5745
- case "end":
5746
- return _context.stop();
5747
- }
5719
+ }
5720
+ _context.next = 7;
5721
+ return bucket.values[j];
5722
+ case 7:
5723
+ j--;
5724
+ _context.next = 4;
5725
+ break;
5726
+ case 10:
5727
+ _context.next = 1;
5728
+ break;
5729
+ case 12:
5730
+ case "end":
5731
+ return _context.stop();
5748
5732
  }
5749
5733
  }, values, this);
5750
5734
  });
@@ -5789,9 +5773,7 @@
5789
5773
  return hash;
5790
5774
  }
5791
5775
  function megaStateDescriptorHash(hash, a) {
5792
- for (var i = 0; i < a.attachmentsState.length; i++) {
5793
- hash = attachmentStateHash(hash, a.attachmentsState[i]);
5794
- }
5776
+ for (var i = 0; i < a.attachmentsState.length; i++) hash = attachmentStateHash(hash, a.attachmentsState[i]);
5795
5777
  hash = colorHash(hash, a.blendConstant);
5796
5778
  hash = hashCodeNumberUpdate(hash, a.depthCompare);
5797
5779
  hash = hashCodeNumberUpdate(hash, a.depthWrite ? 1 : 0);
@@ -5807,13 +5789,9 @@
5807
5789
  var hash = 0;
5808
5790
  hash = hashCodeNumberUpdate(hash, a.program.id);
5809
5791
  if (a.inputLayout !== null) hash = hashCodeNumberUpdate(hash, a.inputLayout.id);
5810
- for (var i = 0; i < a.bindingLayouts.length; i++) {
5811
- hash = renderBindingLayoutHash(hash, a.bindingLayouts[i]);
5812
- }
5792
+ for (var i = 0; i < a.bindingLayouts.length; i++) hash = renderBindingLayoutHash(hash, a.bindingLayouts[i]);
5813
5793
  hash = megaStateDescriptorHash(hash, a.megaStateDescriptor);
5814
- for (var _i = 0; _i < a.colorAttachmentFormats.length; _i++) {
5815
- hash = hashCodeNumberUpdate(hash, a.colorAttachmentFormats[_i] || 0);
5816
- }
5794
+ for (var _i = 0; _i < a.colorAttachmentFormats.length; _i++) hash = hashCodeNumberUpdate(hash, a.colorAttachmentFormats[_i] || 0);
5817
5795
  hash = hashCodeNumberUpdate(hash, a.depthStencilAttachmentFormat || 0);
5818
5796
  return hashCodeNumberFinish(hash);
5819
5797
  }
@@ -5937,14 +5915,20 @@
5937
5915
  };
5938
5916
  var RenderGraphPass = /*#__PURE__*/function () {
5939
5917
  function RenderGraphPass() {
5918
+ // RenderTargetAttachmentSlot => renderTargetID
5940
5919
  this.renderTargetIDs = [];
5920
+ // RenderTargetAttachmentSlot => resolveTextureID
5941
5921
  this.resolveTextureOutputIDs = [];
5922
+ // RenderTargetAttachmentSlot => Texture
5942
5923
  this.resolveTextureOutputExternalTextures = [];
5924
+ // List of resolveTextureIDs that we have a reference to.
5943
5925
  this.resolveTextureInputIDs = [];
5926
+ // RGAttachmentSlot => refcount.
5944
5927
  this.renderTargetExtraRefs = [];
5945
5928
  this.viewport = IdentityViewportCoords;
5946
5929
  this.resolveTextureInputTextures = [];
5947
5930
  this.renderTargets = [];
5931
+ // Execution state computed by scheduling.
5948
5932
  this.descriptor = {
5949
5933
  colorAttachment: [],
5950
5934
  colorResolveTo: [],
@@ -5961,8 +5945,10 @@
5961
5945
  this.viewportY = 0;
5962
5946
  this.viewportW = 0;
5963
5947
  this.viewportH = 0;
5948
+ // Execution callback from user.
5964
5949
  this.execFunc = null;
5965
5950
  this.postFunc = null;
5951
+ // Misc. state.
5966
5952
  this.debugName = void 0;
5967
5953
  this.debugThumbnails = [];
5968
5954
  }
@@ -6089,9 +6075,12 @@
6089
6075
  return SingleSampledTexture;
6090
6076
  }();
6091
6077
  var GraphImpl = function GraphImpl() {
6078
+ // [Symbol.species]?: 'RGGraph';
6079
+ // Used for determining scheduling.
6092
6080
  this.renderTargetDescriptions = [];
6093
6081
  this.resolveTextureRenderTargetIDs = [];
6094
6082
  this.passes = [];
6083
+ // Debugging.
6095
6084
  this.renderTargetDebugNames = [];
6096
6085
  };
6097
6086
  var RenderGraph = /*#__PURE__*/function () {
@@ -6104,7 +6093,11 @@
6104
6093
  this.currentPass = null;
6105
6094
  this.renderTargetDeadPool = [];
6106
6095
  this.singleSampledTextureDeadPool = [];
6096
+ //#endregion
6097
+ //#region Graph Builder
6107
6098
  this.currentGraph = null;
6099
+ //#endregion
6100
+ //#region Scheduling
6108
6101
  this.renderTargetOutputCount = [];
6109
6102
  this.renderTargetResolveCount = [];
6110
6103
  this.resolveTextureUseCount = [];
@@ -6138,11 +6131,7 @@
6138
6131
  }
6139
6132
  // Allocate a new resolve texture.
6140
6133
  return new SingleSampledTexture(this.device, desc);
6141
- }
6142
- //#endregion
6143
- //#region Graph Builder
6144
- ;
6145
-
6134
+ };
6146
6135
  _proto.beginGraphBuilder = function beginGraphBuilder() {
6147
6136
  assert(this.currentGraph === null);
6148
6137
  this.currentGraph = new GraphImpl();
@@ -6205,11 +6194,7 @@
6205
6194
  };
6206
6195
  _proto.getRenderTargetDescription = function getRenderTargetDescription(renderTargetID) {
6207
6196
  return assertExists(this.currentGraph.renderTargetDescriptions[renderTargetID]);
6208
- }
6209
- //#endregion
6210
- //#region Scheduling
6211
- ;
6212
-
6197
+ };
6213
6198
  _proto.scheduleAddUseCount = function scheduleAddUseCount(graph, pass) {
6214
6199
  for (var slot = 0; slot < pass.renderTargetIDs.length; slot++) {
6215
6200
  var renderTargetID = pass.renderTargetIDs[slot];
@@ -6371,50 +6356,30 @@
6371
6356
  var resolveTextureID = pass.resolveTextureInputIDs[_i];
6372
6357
  pass.resolveTextureInputTextures[_i] = this.acquireResolveTextureInputTextureForID(graph, resolveTextureID);
6373
6358
  }
6374
- for (var _i2 = 0; _i2 < pass.renderTargetIDs.length; _i2++) {
6375
- this.releaseRenderTargetForID(pass.renderTargetIDs[_i2], true);
6376
- }
6377
- for (var slot = 0; slot < pass.renderTargetExtraRefs.length; slot++) {
6378
- if (pass.renderTargetExtraRefs[slot]) this.releaseRenderTargetForID(pass.renderTargetIDs[slot], true);
6379
- }
6359
+ for (var _i2 = 0; _i2 < pass.renderTargetIDs.length; _i2++) this.releaseRenderTargetForID(pass.renderTargetIDs[_i2], true);
6360
+ for (var _slot = 0; _slot < pass.renderTargetExtraRefs.length; _slot++) if (pass.renderTargetExtraRefs[_slot]) this.releaseRenderTargetForID(pass.renderTargetIDs[_slot], true);
6380
6361
  };
6381
6362
  _proto.scheduleGraph = function scheduleGraph(graph) {
6382
6363
  assert(this.renderTargetOutputCount.length === 0);
6383
6364
  assert(this.renderTargetResolveCount.length === 0);
6384
6365
  assert(this.resolveTextureUseCount.length === 0);
6385
6366
  // Go through and increment the age of everything in our dead pools to mark that it's old.
6386
- for (var i = 0; i < this.renderTargetDeadPool.length; i++) {
6387
- this.renderTargetDeadPool[i].age++;
6388
- }
6389
- for (var _i3 = 0; _i3 < this.singleSampledTextureDeadPool.length; _i3++) {
6390
- this.singleSampledTextureDeadPool[_i3].age++;
6391
- }
6367
+ for (var i = 0; i < this.renderTargetDeadPool.length; i++) this.renderTargetDeadPool[i].age++;
6368
+ for (var _i3 = 0; _i3 < this.singleSampledTextureDeadPool.length; _i3++) this.singleSampledTextureDeadPool[_i3].age++;
6392
6369
  // Schedule our resources -- first, count up all uses of resources, then hand them out.
6393
6370
  // Initialize our accumulators.
6394
6371
  fillArray(this.renderTargetOutputCount, graph.renderTargetDescriptions.length, 0);
6395
6372
  fillArray(this.renderTargetResolveCount, graph.renderTargetDescriptions.length, 0);
6396
6373
  fillArray(this.resolveTextureUseCount, graph.resolveTextureRenderTargetIDs.length, 0);
6397
6374
  // Count.
6398
- for (var _i4 = 0; _i4 < graph.passes.length; _i4++) {
6399
- this.scheduleAddUseCount(graph, graph.passes[_i4]);
6400
- }
6375
+ for (var _i4 = 0; _i4 < graph.passes.length; _i4++) this.scheduleAddUseCount(graph, graph.passes[_i4]);
6401
6376
  // Now hand out resources.
6402
- for (var _i5 = 0; _i5 < graph.passes.length; _i5++) {
6403
- this.schedulePass(graph, graph.passes[_i5]);
6404
- }
6377
+ for (var _i5 = 0; _i5 < graph.passes.length; _i5++) this.schedulePass(graph, graph.passes[_i5]);
6405
6378
  // Double-check that all resources were handed out.
6406
- for (var _i6 = 0; _i6 < this.renderTargetOutputCount.length; _i6++) {
6407
- assert(this.renderTargetOutputCount[_i6] === 0);
6408
- }
6409
- for (var _i7 = 0; _i7 < this.renderTargetResolveCount.length; _i7++) {
6410
- assert(this.renderTargetResolveCount[_i7] === 0);
6411
- }
6412
- for (var _i8 = 0; _i8 < this.resolveTextureUseCount.length; _i8++) {
6413
- assert(this.resolveTextureUseCount[_i8] === 0);
6414
- }
6415
- for (var _i9 = 0; _i9 < this.renderTargetAliveForID.length; _i9++) {
6416
- assert(this.renderTargetAliveForID[_i9] === undefined);
6417
- }
6379
+ for (var _i6 = 0; _i6 < this.renderTargetOutputCount.length; _i6++) assert(this.renderTargetOutputCount[_i6] === 0);
6380
+ for (var _i7 = 0; _i7 < this.renderTargetResolveCount.length; _i7++) assert(this.renderTargetResolveCount[_i7] === 0);
6381
+ for (var _i8 = 0; _i8 < this.resolveTextureUseCount.length; _i8++) assert(this.resolveTextureUseCount[_i8] === 0);
6382
+ for (var _i9 = 0; _i9 < this.renderTargetAliveForID.length; _i9++) assert(this.renderTargetAliveForID[_i9] === undefined);
6418
6383
  // Now go through and kill anything that's over our age threshold (hasn't been used in a bit)
6419
6384
  var ageThreshold = 1;
6420
6385
  for (var _i10 = 0; _i10 < this.renderTargetDeadPool.length; _i10++) {
@@ -6514,18 +6479,10 @@
6514
6479
  };
6515
6480
  _proto.destroy = function destroy() {
6516
6481
  // At the time this is called, we shouldn't have anything alive.
6517
- for (var i = 0; i < this.renderTargetAliveForID.length; i++) {
6518
- assert(this.renderTargetAliveForID[i] === undefined);
6519
- }
6520
- for (var _i12 = 0; _i12 < this.singleSampledTextureForResolveTextureID.length; _i12++) {
6521
- assert(this.singleSampledTextureForResolveTextureID[_i12] === undefined);
6522
- }
6523
- for (var _i13 = 0; _i13 < this.renderTargetDeadPool.length; _i13++) {
6524
- this.renderTargetDeadPool[_i13].destroy();
6525
- }
6526
- for (var _i14 = 0; _i14 < this.singleSampledTextureDeadPool.length; _i14++) {
6527
- this.singleSampledTextureDeadPool[_i14].destroy();
6528
- }
6482
+ for (var i = 0; i < this.renderTargetAliveForID.length; i++) assert(this.renderTargetAliveForID[i] === undefined);
6483
+ for (var _i12 = 0; _i12 < this.singleSampledTextureForResolveTextureID.length; _i12++) assert(this.singleSampledTextureForResolveTextureID[_i12] === undefined);
6484
+ for (var _i13 = 0; _i13 < this.renderTargetDeadPool.length; _i13++) this.renderTargetDeadPool[_i13].destroy();
6485
+ for (var _i14 = 0; _i14 < this.singleSampledTextureDeadPool.length; _i14++) this.singleSampledTextureDeadPool[_i14].destroy();
6529
6486
  };
6530
6487
  return RenderGraph;
6531
6488
  }();
@@ -6845,9 +6802,7 @@
6845
6802
  this.renderPipelineDescriptor.inputLayout = o.renderPipelineDescriptor.inputLayout;
6846
6803
  this.renderPipelineDescriptor.topology = o.renderPipelineDescriptor.topology;
6847
6804
  this.renderPipelineDescriptor.colorAttachmentFormats.length = Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length, o.renderPipelineDescriptor.colorAttachmentFormats.length);
6848
- for (var i = 0; i < o.renderPipelineDescriptor.colorAttachmentFormats.length; i++) {
6849
- this.renderPipelineDescriptor.colorAttachmentFormats[i] = o.renderPipelineDescriptor.colorAttachmentFormats[i];
6850
- }
6805
+ for (var i = 0; i < o.renderPipelineDescriptor.colorAttachmentFormats.length; i++) this.renderPipelineDescriptor.colorAttachmentFormats[i] = o.renderPipelineDescriptor.colorAttachmentFormats[i];
6851
6806
  this.renderPipelineDescriptor.depthStencilAttachmentFormat = o.renderPipelineDescriptor.depthStencilAttachmentFormat;
6852
6807
  this.renderPipelineDescriptor.sampleCount = o.renderPipelineDescriptor.sampleCount;
6853
6808
  this.inputState = o.inputState;
@@ -6861,13 +6816,9 @@
6861
6816
  var tbd = this.bindingDescriptors[0],
6862
6817
  obd = o.bindingDescriptors[0];
6863
6818
  if (obd.bindingLayout !== null) this.setBindingLayout(obd.bindingLayout);
6864
- for (var _i = 0; _i < Math.min(tbd.uniformBufferBindings.length, obd.uniformBufferBindings.length); _i++) {
6865
- tbd.uniformBufferBindings[_i].wordCount = o.bindingDescriptors[0].uniformBufferBindings[_i].wordCount;
6866
- }
6819
+ for (var _i = 0; _i < Math.min(tbd.uniformBufferBindings.length, obd.uniformBufferBindings.length); _i++) tbd.uniformBufferBindings[_i].wordCount = o.bindingDescriptors[0].uniformBufferBindings[_i].wordCount;
6867
6820
  this.setSamplerBindingsFromTextureMappings(obd.samplerBindings);
6868
- for (var _i2 = 0; _i2 < o.dynamicUniformBufferByteOffsets.length; _i2++) {
6869
- this.dynamicUniformBufferByteOffsets[_i2] = o.dynamicUniformBufferByteOffsets[_i2];
6870
- }
6821
+ for (var _i2 = 0; _i2 < o.dynamicUniformBufferByteOffsets.length; _i2++) this.dynamicUniformBufferByteOffsets[_i2] = o.dynamicUniformBufferByteOffsets[_i2];
6871
6822
  }
6872
6823
  /**
6873
6824
  * Set the {@see Program} that this render inst will render with. This is part of the automatic
@@ -6907,19 +6858,15 @@
6907
6858
  assert(bindingLayout.numUniformBuffers < this.dynamicUniformBufferByteOffsets.length);
6908
6859
  this.renderPipelineDescriptor.bindingLayouts[0] = bindingLayout;
6909
6860
  this.bindingDescriptors[0].bindingLayout = bindingLayout;
6910
- for (var i = this.bindingDescriptors[0].uniformBufferBindings.length; i < bindingLayout.numUniformBuffers; i++) {
6911
- this.bindingDescriptors[0].uniformBufferBindings.push({
6912
- buffer: null,
6913
- wordCount: 0
6914
- });
6915
- }
6916
- for (var _i3 = this.bindingDescriptors[0].samplerBindings.length; _i3 < bindingLayout.numSamplers; _i3++) {
6917
- this.bindingDescriptors[0].samplerBindings.push({
6918
- sampler: null,
6919
- texture: null,
6920
- lateBinding: null
6921
- });
6922
- }
6861
+ for (var i = this.bindingDescriptors[0].uniformBufferBindings.length; i < bindingLayout.numUniformBuffers; i++) this.bindingDescriptors[0].uniformBufferBindings.push({
6862
+ buffer: null,
6863
+ wordCount: 0
6864
+ });
6865
+ for (var _i3 = this.bindingDescriptors[0].samplerBindings.length; _i3 < bindingLayout.numSamplers; _i3++) this.bindingDescriptors[0].samplerBindings.push({
6866
+ sampler: null,
6867
+ texture: null,
6868
+ lateBinding: null
6869
+ });
6923
6870
  }
6924
6871
  /**
6925
6872
  * Sets the {@see BindingLayoutDescriptor}s that this render inst will render with.
@@ -7155,9 +7102,7 @@
7155
7102
  passRenderer.setPipeline(gfxPipeline);
7156
7103
  passRenderer.setInputState(this.inputState);
7157
7104
  // upload uniforms
7158
- for (var i = 0; i < this.bindingDescriptors[0].uniformBufferBindings.length; i++) {
7159
- this.bindingDescriptors[0].uniformBufferBindings[i].buffer = assertExists(this.uniformBuffer.buffer);
7160
- }
7105
+ for (var i = 0; i < this.bindingDescriptors[0].uniformBufferBindings.length; i++) this.bindingDescriptors[0].uniformBufferBindings[i].buffer = assertExists(this.uniformBuffer.buffer);
7161
7106
  if (this.renderPipelineDescriptor.program.gl_program) {
7162
7107
  this.uniforms.forEach(function (uniforms) {
7163
7108
  var uniformsMap = {};
@@ -7239,10 +7184,8 @@
7239
7184
  this.insertSorted(renderInst);
7240
7185
  };
7241
7186
  _proto.hasLateSamplerBinding = function hasLateSamplerBinding(name) {
7242
- for (var i = 0; i < this.renderInsts.length; i++) {
7243
- if (this.renderInsts[i].hasLateSamplerBinding(name)) {
7244
- return true;
7245
- }
7187
+ for (var i = 0; i < this.renderInsts.length; i++) if (this.renderInsts[i].hasLateSamplerBinding(name)) {
7188
+ return true;
7246
7189
  }
7247
7190
  return false;
7248
7191
  }
@@ -7250,9 +7193,7 @@
7250
7193
  * Resolve sampler bindings for all render insts on this render inst list.
7251
7194
  */;
7252
7195
  _proto.resolveLateSamplerBinding = function resolveLateSamplerBinding(name, binding) {
7253
- for (var i = 0; i < this.renderInsts.length; i++) {
7254
- this.renderInsts[i].resolveLateSamplerBinding(name, binding);
7255
- }
7196
+ for (var i = 0; i < this.renderInsts.length; i++) this.renderInsts[i].resolveLateSamplerBinding(name, binding);
7256
7197
  };
7257
7198
  _proto.ensureSorted = function ensureSorted() {
7258
7199
  if (this.usePostSort) {
@@ -7264,13 +7205,9 @@
7264
7205
  this.ensureSorted();
7265
7206
  var numDrawn = 0;
7266
7207
  if (this.executionOrder === RenderInstExecutionOrder.Forwards) {
7267
- for (var i = 0; i < this.renderInsts.length; i++) {
7268
- if (this.renderInsts[i].drawOnPass(cache, passRenderer)) numDrawn++;
7269
- }
7208
+ for (var i = 0; i < this.renderInsts.length; i++) if (this.renderInsts[i].drawOnPass(cache, passRenderer)) numDrawn++;
7270
7209
  } else {
7271
- for (var _i = this.renderInsts.length - 1; _i >= 0; _i--) {
7272
- if (this.renderInsts[_i].drawOnPass(cache, passRenderer)) numDrawn++;
7273
- }
7210
+ for (var _i = this.renderInsts.length - 1; _i >= 0; _i--) if (this.renderInsts[_i].drawOnPass(cache, passRenderer)) numDrawn++;
7274
7211
  }
7275
7212
  return numDrawn;
7276
7213
  };
@@ -7285,7 +7222,9 @@
7285
7222
  }();
7286
7223
  var RenderInstPool = /*#__PURE__*/function () {
7287
7224
  function RenderInstPool() {
7225
+ // The pool contains all render insts that we've ever created.
7288
7226
  this.pool = [];
7227
+ // The number of render insts currently allocated out to the user.
7289
7228
  this.allocCount = 0;
7290
7229
  }
7291
7230
  var _proto = RenderInstPool.prototype;
@@ -7428,6 +7367,7 @@
7428
7367
  this.renderGraph = void 0;
7429
7368
  this.renderInstManager = void 0;
7430
7369
  this.uniformBuffer = void 0;
7370
+ // debugThumbnails: DebugThumbnailDrawer;
7431
7371
  this.device = void 0;
7432
7372
  }
7433
7373
  var _proto = RenderHelper.prototype;
@@ -7552,6 +7492,8 @@
7552
7492
  this.texture = null;
7553
7493
  this.sampler = null;
7554
7494
  this.lateBinding = null;
7495
+ // These are not used when binding to samplers, and are conveniences for custom behavior.
7496
+ // TODO(jstpierre): Are any of these really worth anything?
7555
7497
  this.width = 0;
7556
7498
  this.height = 0;
7557
7499
  this.lodBias = 0;
@@ -7586,6 +7528,8 @@
7586
7528
  // Public API for saving off copies of images for temporal-style effects.
7587
7529
  var TemporalTexture = /*#__PURE__*/function () {
7588
7530
  function TemporalTexture() {
7531
+ // These names might be a bit confusing, but they're named relative to the graph.
7532
+ // outputTexture is the target of a resolve, inputTexture is the source for sampling.
7589
7533
  this.inputTexture = null;
7590
7534
  this.outputTexture = null;
7591
7535
  }
@@ -7701,6 +7645,9 @@
7701
7645
  */
7702
7646
  picking: new RenderInstList()
7703
7647
  };
7648
+ /**
7649
+ * Render Graph builder at each frame
7650
+ */
7704
7651
  this.builder = void 0;
7705
7652
  this.enableCapture = void 0;
7706
7653
  this.captureOptions = void 0;
@@ -7788,38 +7735,36 @@
7788
7735
  renderingService.hooks.init.tapPromise(RenderGraphPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
7789
7736
  var $canvas, _this$context$config, width, height;
7790
7737
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
7791
- while (1) {
7792
- switch (_context.prev = _context.next) {
7793
- case 0:
7794
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7795
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
7796
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
7797
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
7798
- canvas.addEventListener(gLite.ElementEvent.RENDER_ORDER_CHANGED, handleRenderOrderChanged);
7799
- _this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
7800
- $canvas = _this.context.contextService.getDomElement();
7801
- _this$context$config = _this.context.config, width = _this$context$config.width, height = _this$context$config.height;
7802
- _this.context.contextService.resize(width, height);
7803
- // create swap chain and get device
7804
- // @ts-ignore
7805
- _context.next = 11;
7806
- return _this.context.deviceContribution.createSwapChain($canvas);
7807
- case 11:
7808
- _this.swapChain = _context.sent;
7809
- _this.device = _this.swapChain.getDevice();
7810
- _this.renderHelper.setDevice(_this.device);
7811
- _this.renderHelper.renderInstManager.disableSimpleMode();
7738
+ while (1) switch (_context.prev = _context.next) {
7739
+ case 0:
7740
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7741
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
7742
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
7743
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
7744
+ canvas.addEventListener(gLite.ElementEvent.RENDER_ORDER_CHANGED, handleRenderOrderChanged);
7745
+ _this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
7746
+ $canvas = _this.context.contextService.getDomElement();
7747
+ _this$context$config = _this.context.config, width = _this$context$config.width, height = _this$context$config.height;
7748
+ _this.context.contextService.resize(width, height);
7749
+ // create swap chain and get device
7750
+ // @ts-ignore
7751
+ _context.next = 11;
7752
+ return _this.context.deviceContribution.createSwapChain($canvas);
7753
+ case 11:
7754
+ _this.swapChain = _context.sent;
7755
+ _this.device = _this.swapChain.getDevice();
7756
+ _this.renderHelper.setDevice(_this.device);
7757
+ _this.renderHelper.renderInstManager.disableSimpleMode();
7758
+ _this.swapChain.configureSwapChain($canvas.width, $canvas.height);
7759
+ canvas.addEventListener(gLite.CanvasEvent.RESIZE, function () {
7812
7760
  _this.swapChain.configureSwapChain($canvas.width, $canvas.height);
7813
- canvas.addEventListener(gLite.CanvasEvent.RESIZE, function () {
7814
- _this.swapChain.configureSwapChain($canvas.width, $canvas.height);
7815
- });
7816
- _this.batchManager.attach(_extends({
7817
- device: _this.device
7818
- }, context));
7819
- case 18:
7820
- case "end":
7821
- return _context.stop();
7822
- }
7761
+ });
7762
+ _this.batchManager.attach(_extends({
7763
+ device: _this.device
7764
+ }, context));
7765
+ case 18:
7766
+ case "end":
7767
+ return _context.stop();
7823
7768
  }
7824
7769
  }, _callee);
7825
7770
  })));
@@ -7960,22 +7905,20 @@
7960
7905
  var _toDataURL = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(options) {
7961
7906
  var _this2 = this;
7962
7907
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
7963
- while (1) {
7964
- switch (_context2.prev = _context2.next) {
7965
- case 0:
7966
- // trigger re-render
7967
- this.enableCapture = true;
7968
- this.captureOptions = options;
7969
- this.capturePromise = new Promise(function (resolve) {
7970
- _this2.resolveCapturePromise = function (dataURL) {
7971
- resolve(dataURL);
7972
- };
7973
- });
7974
- return _context2.abrupt("return", this.capturePromise);
7975
- case 4:
7976
- case "end":
7977
- return _context2.stop();
7978
- }
7908
+ while (1) switch (_context2.prev = _context2.next) {
7909
+ case 0:
7910
+ // trigger re-render
7911
+ this.enableCapture = true;
7912
+ this.captureOptions = options;
7913
+ this.capturePromise = new Promise(function (resolve) {
7914
+ _this2.resolveCapturePromise = function (dataURL) {
7915
+ resolve(dataURL);
7916
+ };
7917
+ });
7918
+ return _context2.abrupt("return", this.capturePromise);
7919
+ case 4:
7920
+ case "end":
7921
+ return _context2.stop();
7979
7922
  }
7980
7923
  }, _callee2, this);
7981
7924
  }));
@@ -8027,14 +7970,12 @@
8027
7970
  };
8028
7971
  renderingService.hooks.init.tapPromise(PickingPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
8029
7972
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
8030
- while (1) {
8031
- switch (_context.prev = _context.next) {
8032
- case 0:
8033
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
8034
- case 1:
8035
- case "end":
8036
- return _context.stop();
8037
- }
7973
+ while (1) switch (_context.prev = _context.next) {
7974
+ case 0:
7975
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
7976
+ case 1:
7977
+ case "end":
7978
+ return _context.stop();
8038
7979
  }
8039
7980
  }, _callee);
8040
7981
  })));
@@ -8045,39 +7986,17 @@
8045
7986
  * Sync version is not implemented.
8046
7987
  */
8047
7988
  renderingService.hooks.pickSync.tap(PickingPlugin.tag, function (result) {
8048
- return result;
7989
+ return _this.pick(result);
8049
7990
  });
8050
7991
  renderingService.hooks.pick.tapPromise(PickingPlugin.tag, /*#__PURE__*/function () {
8051
7992
  var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(result) {
8052
- var topmost, position, x, y, dpr, width, height, xInDevicePixel, yInDevicePixel, pickedDisplayObjects;
8053
7993
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
8054
- while (1) {
8055
- switch (_context2.prev = _context2.next) {
8056
- case 0:
8057
- topmost = result.topmost, position = result.position; // use viewportX/Y
8058
- x = position.viewportX, y = position.viewportY;
8059
- dpr = _this.context.contextService.getDPR();
8060
- width = _this.context.config.width * dpr;
8061
- height = _this.context.config.height * dpr;
8062
- xInDevicePixel = x * dpr;
8063
- yInDevicePixel = y * dpr;
8064
- if (!(xInDevicePixel > width || xInDevicePixel < 0 || yInDevicePixel > height || yInDevicePixel < 0)) {
8065
- _context2.next = 10;
8066
- break;
8067
- }
8068
- result.picked = [];
8069
- return _context2.abrupt("return", result);
8070
- case 10:
8071
- _context2.next = 12;
8072
- return _this.pickByRectangleInDepth(new gLite.Rectangle(clamp(Math.round(xInDevicePixel), 0, width - 1), clamp(Math.round(yInDevicePixel), 0, height - 1), 1, 1), topmost ? 1 : MAX_PICKING_DEPTH);
8073
- case 12:
8074
- pickedDisplayObjects = _context2.sent;
8075
- result.picked = pickedDisplayObjects;
8076
- return _context2.abrupt("return", result);
8077
- case 15:
8078
- case "end":
8079
- return _context2.stop();
8080
- }
7994
+ while (1) switch (_context2.prev = _context2.next) {
7995
+ case 0:
7996
+ return _context2.abrupt("return", _this.pick(result));
7997
+ case 1:
7998
+ case "end":
7999
+ return _context2.stop();
8081
8000
  }
8082
8001
  }, _callee2);
8083
8002
  }));
@@ -8086,57 +8005,49 @@
8086
8005
  };
8087
8006
  }());
8088
8007
  };
8089
- _proto.pickByRectangleInDepth = /*#__PURE__*/function () {
8090
- var _pickByRectangleInDepth = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3(rect, depth) {
8091
- var picked, counter, targets;
8092
- return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
8093
- while (1) {
8094
- switch (_context3.prev = _context3.next) {
8095
- case 0:
8096
- if (depth === void 0) {
8097
- depth = MAX_PICKING_DEPTH;
8098
- }
8099
- picked = null;
8100
- counter = 1;
8101
- targets = [];
8102
- case 4:
8103
- _context3.next = 6;
8104
- return this.pickByRectangle(rect, picked);
8105
- case 6:
8106
- picked = _context3.sent;
8107
- if (!picked) {
8108
- _context3.next = 12;
8109
- break;
8110
- }
8111
- counter++;
8112
- targets.push(picked);
8113
- _context3.next = 13;
8114
- break;
8115
- case 12:
8116
- return _context3.abrupt("break", 14);
8117
- case 13:
8118
- if (picked && counter <= depth) {
8119
- _context3.next = 4;
8120
- break;
8121
- }
8122
- case 14:
8123
- if (depth > 1) {
8124
- // restore encoded picking color
8125
- this.restorePickingColor(targets);
8126
- }
8127
- return _context3.abrupt("return", targets);
8128
- case 16:
8129
- case "end":
8130
- return _context3.stop();
8131
- }
8132
- }
8133
- }, _callee3, this);
8134
- }));
8135
- function pickByRectangleInDepth(_x2, _x3) {
8136
- return _pickByRectangleInDepth.apply(this, arguments);
8008
+ _proto.pick = function pick(result) {
8009
+ var topmost = result.topmost,
8010
+ position = result.position;
8011
+ // use viewportX/Y
8012
+ var x = position.viewportX,
8013
+ y = position.viewportY;
8014
+ var dpr = this.context.contextService.getDPR();
8015
+ var width = this.context.config.width * dpr;
8016
+ var height = this.context.config.height * dpr;
8017
+ var xInDevicePixel = x * dpr;
8018
+ var yInDevicePixel = y * dpr;
8019
+ if (xInDevicePixel > width || xInDevicePixel < 0 || yInDevicePixel > height || yInDevicePixel < 0) {
8020
+ result.picked = [];
8021
+ return result;
8137
8022
  }
8138
- return pickByRectangleInDepth;
8139
- }();
8023
+ // implements multi-layer picking
8024
+ // @see https://github.com/antvis/g/issues/948
8025
+ var pickedDisplayObjects = this.pickByRectangleInDepth(new gLite.Rectangle(clamp(Math.round(xInDevicePixel), 0, width - 1), clamp(Math.round(yInDevicePixel), 0, height - 1), 1, 1), topmost ? 1 : MAX_PICKING_DEPTH);
8026
+ result.picked = pickedDisplayObjects;
8027
+ return result;
8028
+ };
8029
+ _proto.pickByRectangleInDepth = function pickByRectangleInDepth(rect, depth) {
8030
+ if (depth === void 0) {
8031
+ depth = MAX_PICKING_DEPTH;
8032
+ }
8033
+ var picked = null;
8034
+ var counter = 1;
8035
+ var targets = [];
8036
+ do {
8037
+ picked = this.pickByRectangle(rect, picked);
8038
+ if (picked) {
8039
+ counter++;
8040
+ targets.push(picked);
8041
+ } else {
8042
+ break;
8043
+ }
8044
+ } while (picked && counter <= depth);
8045
+ if (depth > 1) {
8046
+ // restore encoded picking color
8047
+ this.restorePickingColor(targets);
8048
+ }
8049
+ return targets;
8050
+ };
8140
8051
  _proto.restorePickingColor = function restorePickingColor(displayObjects) {
8141
8052
  var _this2 = this;
8142
8053
  displayObjects.forEach(function (picked) {
@@ -8172,101 +8083,98 @@
8172
8083
  var mainDepthTargetID = builder.createRenderTargetID(mainDepthDesc, 'Picking Depth');
8173
8084
  // account for current view offset
8174
8085
  var currentView = _extends({}, camera.getView());
8175
- return new Promise(function (resolve) {
8176
- // prevent unused RTs like main color being destroyed
8177
- _this3.renderHelper.renderGraph.renderTargetDeadPool.forEach(function (rt) {
8178
- rt.age = -1;
8086
+ // prevent unused RTs like main color being destroyed
8087
+ this.renderHelper.renderGraph.renderTargetDeadPool.forEach(function (rt) {
8088
+ rt.age = -1;
8089
+ });
8090
+ // picking pass
8091
+ var target;
8092
+ builder.pushPass(function (pass) {
8093
+ pass.setDebugName('Picking Pass');
8094
+ pass.attachRenderTargetID(RGAttachmentSlot.Color0, pickingColorTargetID);
8095
+ pass.attachRenderTargetID(RGAttachmentSlot.DepthStencil, mainDepthTargetID);
8096
+ pass.exec(function (passRenderer) {
8097
+ renderLists.picking.drawOnPassRenderer(renderInstManager.renderCache, passRenderer);
8179
8098
  });
8180
- // picking pass
8181
- builder.pushPass(function (pass) {
8182
- pass.setDebugName('Picking Pass');
8183
- pass.attachRenderTargetID(RGAttachmentSlot.Color0, pickingColorTargetID);
8184
- pass.attachRenderTargetID(RGAttachmentSlot.DepthStencil, mainDepthTargetID);
8185
- pass.exec(function (passRenderer) {
8186
- renderLists.picking.drawOnPassRenderer(renderInstManager.renderCache, passRenderer);
8187
- });
8188
- pass.post(function (scope) {
8189
- var texture = scope.getRenderTargetTexture(RGAttachmentSlot.Color0);
8190
- var readback = device.createReadback();
8191
- // restore previous view
8192
- if (currentView && currentView.enabled) {
8193
- camera.setViewOffset(currentView.fullWidth, currentView.fullHeight, currentView.offsetX, currentView.offsetY, currentView.width, currentView.height);
8194
- } else {
8195
- camera.clearViewOffset();
8099
+ pass.post(function (scope) {
8100
+ var texture = scope.getRenderTargetTexture(RGAttachmentSlot.Color0);
8101
+ var readback = device.createReadback();
8102
+ // restore previous view
8103
+ if (currentView && currentView.enabled) {
8104
+ camera.setViewOffset(currentView.fullWidth, currentView.fullHeight, currentView.offsetX, currentView.offsetY, currentView.width, currentView.height);
8105
+ } else {
8106
+ camera.clearViewOffset();
8107
+ }
8108
+ camera.setEnableUpdate(true);
8109
+ var pickedColors = readback.readTexture(texture, 0, 0, width, height, new Uint8Array(width * height * 4));
8110
+ var pickedFeatureIdx = -1;
8111
+ if (pickedColors && (pickedColors[0] !== 0 || pickedColors[1] !== 0 || pickedColors[2] !== 0)) {
8112
+ pickedFeatureIdx = _this3.pickingIdGenerator.decodePickingColor(pickedColors);
8113
+ }
8114
+ if (pickedFeatureIdx > -1) {
8115
+ var pickedDisplayObject = _this3.pickingIdGenerator.getById(pickedFeatureIdx);
8116
+ if (pickedDisplayObject && pickedDisplayObject.isVisible() && pickedDisplayObject.isInteractive()) {
8117
+ target = pickedDisplayObject;
8196
8118
  }
8197
- camera.setEnableUpdate(true);
8198
- readback.readTexture(texture, 0, 0, width, height, new Uint8Array(width * height * 4)).then(function (pickedColors) {
8199
- var target;
8200
- var pickedFeatureIdx = -1;
8201
- if (pickedColors && (pickedColors[0] !== 0 || pickedColors[1] !== 0 || pickedColors[2] !== 0)) {
8202
- pickedFeatureIdx = _this3.pickingIdGenerator.decodePickingColor(pickedColors);
8203
- }
8204
- if (pickedFeatureIdx > -1) {
8205
- var pickedDisplayObject = _this3.pickingIdGenerator.getById(pickedFeatureIdx);
8206
- if (pickedDisplayObject && pickedDisplayObject.isVisible() && pickedDisplayObject.isInteractive()) {
8207
- target = pickedDisplayObject;
8208
- }
8209
- }
8210
- readback.destroy();
8211
- resolve(target);
8212
- });
8213
- });
8119
+ }
8120
+ readback.destroy();
8214
8121
  });
8215
- // Push our outer template, which contains the dynamic UBO bindings...
8216
- var template = _this3.renderHelper.pushTemplateRenderInst();
8217
- // SceneParams: binding = 0, ObjectParams: binding = 1
8218
- template.setBindingLayouts([{
8219
- numUniformBuffers: 2,
8220
- numSamplers: 0
8221
- }]);
8222
- template.setMegaStateFlags(setAttachmentStateSimple({
8223
- depthWrite: true
8224
- }, {
8225
- rgbBlendMode: BlendMode.Add,
8226
- rgbBlendSrcFactor: BlendFactor.One,
8227
- rgbBlendDstFactor: BlendFactor.Zero,
8228
- alphaBlendMode: BlendMode.Add,
8229
- alphaBlendSrcFactor: BlendFactor.One,
8230
- alphaBlendDstFactor: BlendFactor.Zero
8231
- }));
8232
- // Update Scene Params
8233
- var _this3$context$config = _this3.context.config,
8234
- canvasWidth = _this3$context$config.width,
8235
- canvasHeight = _this3$context$config.height;
8236
- var dpr = _this3.context.contextService.getDPR();
8237
- camera.setEnableUpdate(false);
8238
- camera.setViewOffset(canvasWidth * dpr, canvasHeight * dpr, x, y, width, height);
8239
- template.setUniforms(SceneUniformBufferIndex, [{
8240
- name: SceneUniform.PROJECTION_MATRIX,
8241
- value: camera.getPerspective()
8242
- }, {
8243
- name: SceneUniform.VIEW_MATRIX,
8244
- value: camera.getViewTransform()
8245
- }, {
8246
- name: SceneUniform.CAMERA_POSITION,
8247
- value: camera.getPosition()
8248
- }, {
8249
- name: SceneUniform.DEVICE_PIXEL_RATIO,
8250
- value: _this3.context.contextService.getDPR()
8251
- }, {
8252
- name: SceneUniform.VIEWPORT,
8253
- value: [canvasWidth, canvasHeight]
8254
- }, {
8255
- name: SceneUniform.IS_ORTHO,
8256
- value: camera.isOrtho() ? 1 : 0
8257
- }, {
8258
- name: SceneUniform.IS_PICKING,
8259
- value: 1
8260
- }]);
8261
- if (picked) {
8262
- _this3.batchManager.updateAttribute(picked, 'pointerEvents', false, true);
8263
- }
8264
- _this3.batchManager.render(renderLists.picking, true);
8265
- renderInstManager.popTemplateRenderInst();
8266
- _this3.renderHelper.prepareToRender();
8267
- _this3.renderHelper.renderGraph.execute();
8268
- renderInstManager.resetRenderInsts();
8269
8122
  });
8123
+ // Push our outer template, which contains the dynamic UBO bindings...
8124
+ var template = this.renderHelper.pushTemplateRenderInst();
8125
+ // SceneParams: binding = 0, ObjectParams: binding = 1
8126
+ template.setBindingLayouts([{
8127
+ numUniformBuffers: 2,
8128
+ numSamplers: 0
8129
+ }]);
8130
+ template.setMegaStateFlags(setAttachmentStateSimple({
8131
+ depthWrite: true
8132
+ }, {
8133
+ rgbBlendMode: BlendMode.Add,
8134
+ rgbBlendSrcFactor: BlendFactor.One,
8135
+ rgbBlendDstFactor: BlendFactor.Zero,
8136
+ alphaBlendMode: BlendMode.Add,
8137
+ alphaBlendSrcFactor: BlendFactor.One,
8138
+ alphaBlendDstFactor: BlendFactor.Zero
8139
+ }));
8140
+ // Update Scene Params
8141
+ var _this$context$config = this.context.config,
8142
+ canvasWidth = _this$context$config.width,
8143
+ canvasHeight = _this$context$config.height;
8144
+ var dpr = this.context.contextService.getDPR();
8145
+ camera.setEnableUpdate(false);
8146
+ camera.setViewOffset(canvasWidth * dpr, canvasHeight * dpr, x, y, width, height);
8147
+ template.setUniforms(SceneUniformBufferIndex, [{
8148
+ name: SceneUniform.PROJECTION_MATRIX,
8149
+ value: camera.getPerspective()
8150
+ }, {
8151
+ name: SceneUniform.VIEW_MATRIX,
8152
+ value: camera.getViewTransform()
8153
+ }, {
8154
+ name: SceneUniform.CAMERA_POSITION,
8155
+ value: camera.getPosition()
8156
+ }, {
8157
+ name: SceneUniform.DEVICE_PIXEL_RATIO,
8158
+ value: this.context.contextService.getDPR()
8159
+ }, {
8160
+ name: SceneUniform.VIEWPORT,
8161
+ value: [canvasWidth, canvasHeight]
8162
+ }, {
8163
+ name: SceneUniform.IS_ORTHO,
8164
+ value: camera.isOrtho() ? 1 : 0
8165
+ }, {
8166
+ name: SceneUniform.IS_PICKING,
8167
+ value: 1
8168
+ }]);
8169
+ if (picked) {
8170
+ this.batchManager.updateAttribute(picked, 'pointerEvents', false, true);
8171
+ }
8172
+ this.batchManager.render(renderLists.picking, true);
8173
+ renderInstManager.popTemplateRenderInst();
8174
+ this.renderHelper.prepareToRender();
8175
+ this.renderHelper.renderGraph.execute();
8176
+ renderInstManager.resetRenderInsts();
8177
+ return target;
8270
8178
  };
8271
8179
  return PickingPlugin;
8272
8180
  }();
@@ -8283,7 +8191,25 @@
8283
8191
  */
8284
8192
  var Batch = /*#__PURE__*/function () {
8285
8193
  function Batch() {
8194
+ // @inject(RenderHelper)
8195
+ // protected renderHelper: RenderHelper;
8196
+ // @inject(TexturePool)
8197
+ // protected texturePool: TexturePool;
8198
+ // @inject(DefaultCamera)
8199
+ // protected camera: ICamera;
8200
+ // @inject(LightPool)
8201
+ // protected lightPool: LightPool;
8202
+ // @inject(BatchManager)
8203
+ // protected batchManager: BatchManager;
8204
+ // @inject(MeshFactory)
8205
+ // protected meshFactory: (shape: string) => Instanced;
8206
+ // device: Device;
8207
+ // renderingService: RenderingService;
8286
8208
  this.id = counter++;
8209
+ /**
8210
+ * describe render insts used in this draw call
8211
+ * eg. a Polygon with stroke will use 2 renderInsts
8212
+ */
8287
8213
  this.meshes = [];
8288
8214
  this.clipPathMeshCreated = false;
8289
8215
  }
@@ -8484,15 +8410,29 @@
8484
8410
  _this = _EventEmitter.call(this) || this;
8485
8411
  _this.device = void 0;
8486
8412
  _this.props = {};
8413
+ /**
8414
+ * relative meshes
8415
+ */
8487
8416
  _this.meshes = [];
8417
+ // USE_XXX
8488
8418
  _this.defines = {};
8489
8419
  _this.uniforms = {};
8420
+ // used when sorting before inserted into WebGL2's UBO
8490
8421
  _this.uniformNames = void 0;
8491
8422
  _this.uboBuffer = [];
8492
8423
  _this.textures = {};
8493
8424
  _this.samplers = [];
8425
+ /**
8426
+ * need re-compiling like vs/fs changed
8427
+ */
8494
8428
  _this.programDirty = true;
8429
+ /**
8430
+ * need re-upload textures
8431
+ */
8495
8432
  _this.textureDirty = true;
8433
+ /**
8434
+ * inform geometry to rebuild, eg. wireframe
8435
+ */
8496
8436
  _this.geometryDirty = true;
8497
8437
  var _copyMegaState = copyMegaState(defaultMegaState),
8498
8438
  cullMode = _copyMegaState.cullMode,
@@ -8591,10 +8531,6 @@
8591
8531
  _createClass(Material, [{
8592
8532
  key: "cullMode",
8593
8533
  get:
8594
- /**
8595
- * relative meshes
8596
- */
8597
-
8598
8534
  /**
8599
8535
  * cullFace
8600
8536
  */
@@ -8802,9 +8738,7 @@
8802
8738
  this.compile();
8803
8739
  }
8804
8740
  }
8805
- // USE_XXX
8806
8741
  }]);
8807
-
8808
8742
  return Material;
8809
8743
  }(eventemitter3);
8810
8744
  var ShaderMaterial = /*#__PURE__*/function (_Material) {
@@ -8908,6 +8842,9 @@
8908
8842
  this.renderer = void 0;
8909
8843
  this.index = -1;
8910
8844
  this.context = void 0;
8845
+ /**
8846
+ * instances
8847
+ */
8911
8848
  this.objects = [];
8912
8849
  this.material = void 0;
8913
8850
  this.geometry = void 0;
@@ -8917,8 +8854,14 @@
8917
8854
  this.program = new DeviceProgram();
8918
8855
  this.programDescriptorSimpleWithOrig = void 0;
8919
8856
  this.geometryDirty = true;
8857
+ /**
8858
+ * the same material maybe shared between different canvases
8859
+ */
8920
8860
  this.materialDirty = true;
8921
8861
  this.inputStateDirty = true;
8862
+ /**
8863
+ * texture mappings
8864
+ */
8922
8865
  this.textureMappings = [];
8923
8866
  this.samplerEntries = void 0;
8924
8867
  this.inited = false;
@@ -9173,10 +9116,6 @@
9173
9116
  var fog = this.lightPool.getFog();
9174
9117
  var useFog = !!fog;
9175
9118
  var useLight = !!lights.length;
9176
- var oldDefines = _extends({}, this.material.defines);
9177
- this.material.defines.USE_FOG = useFog;
9178
- this.material.defines.USE_LIGHT = useLight;
9179
- this.material.defines = _extends({}, this.material.defines, this.lightPool.getDefines());
9180
9119
  if (this.clipPathTarget || this.clipPath) {
9181
9120
  if (this.clipPathTarget) {
9182
9121
  this.material.stencilWrite = true;
@@ -9196,6 +9135,10 @@
9196
9135
  if (this.materialDirty || this.material.programDirty) {
9197
9136
  this.createMaterial(objects);
9198
9137
  }
9138
+ var oldDefines = _extends({}, this.material.defines);
9139
+ this.material.defines.USE_FOG = useFog;
9140
+ this.material.defines.USE_LIGHT = useLight;
9141
+ this.material.defines = _extends({}, this.material.defines, this.lightPool.getDefines());
9199
9142
  // re-upload textures
9200
9143
  if (this.material.textureDirty) {
9201
9144
  this.textureMappings = [];
@@ -9231,7 +9174,7 @@
9231
9174
  }
9232
9175
  this.material.textureDirty = false;
9233
9176
  }
9234
- var needRecompileProgram = compareDefines(oldDefines, this.material.defines);
9177
+ var needRecompileProgram = !compareDefines(oldDefines, this.material.defines);
9235
9178
  // re-compile program, eg. DEFINE changed
9236
9179
  if (needRecompileProgram || this.material.programDirty || this.materialDirty) {
9237
9180
  // set defines
@@ -10771,12 +10714,8 @@
10771
10714
  }();
10772
10715
  // 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf
10773
10716
  function edt(data, x0, y0, width, height, gridSize, f, v, z) {
10774
- for (var x = x0; x < x0 + width; x++) {
10775
- edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z);
10776
- }
10777
- for (var y = y0; y < y0 + height; y++) {
10778
- edt1d(data, y * gridSize + x0, 1, width, f, v, z);
10779
- }
10717
+ for (var x = x0; x < x0 + width; x++) edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z);
10718
+ for (var y = y0; y < y0 + height; y++) edt1d(data, y * gridSize + x0, 1, width, f, v, z);
10780
10719
  }
10781
10720
  // 1D squared distance transform
10782
10721
  function edt1d(grid, offset, stride, length, f, v, z) {
@@ -10797,9 +10736,7 @@
10797
10736
  z[k + 1] = INF;
10798
10737
  }
10799
10738
  for (var _q = 0, _k = 0; _q < length; _q++) {
10800
- while (z[_k + 1] < _q) {
10801
- _k++;
10802
- }
10739
+ while (z[_k + 1] < _q) _k++;
10803
10740
  var _r = v[_k];
10804
10741
  var qr = _q - _r;
10805
10742
  grid[offset + _q * stride] = f[_r] + qr * qr;
@@ -11835,20 +11772,20 @@
11835
11772
  width: w || 1,
11836
11773
  height: h || 1
11837
11774
  });
11838
- for (var stack in stacks) {
11839
- var glyphs = stacks[stack];
11840
- for (var id in glyphs) {
11841
- var src = glyphs[+id];
11842
- if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
11775
+ for (var _stack in stacks) {
11776
+ var _glyphs = stacks[_stack];
11777
+ for (var _id in _glyphs) {
11778
+ var _src = _glyphs[+_id];
11779
+ if (!_src || _src.bitmap.width === 0 || _src.bitmap.height === 0) continue;
11843
11780
  // @ts-ignore
11844
- var bin = positions[stack][id].rect;
11845
- AlphaImage.copy(src.bitmap, image, {
11781
+ var _bin = positions[_stack][_id].rect;
11782
+ AlphaImage.copy(_src.bitmap, image, {
11846
11783
  x: 0,
11847
11784
  y: 0
11848
11785
  }, {
11849
- x: bin.x + padding,
11850
- y: bin.y + padding
11851
- }, src.bitmap);
11786
+ x: _bin.x + padding,
11787
+ y: _bin.y + padding
11788
+ }, _src.bitmap);
11852
11789
  }
11853
11790
  }
11854
11791
  this.image = image;
@@ -12149,8 +12086,7 @@
12149
12086
  var font = metrics.font,
12150
12087
  lines = metrics.lines,
12151
12088
  height = metrics.height,
12152
- lineHeight = metrics.lineHeight,
12153
- fontProperties = metrics.fontProperties;
12089
+ lineHeight = metrics.lineHeight;
12154
12090
  // account for dx & dy
12155
12091
  var offsetX = dx || 0;
12156
12092
  var offsetY = dy || 0;
@@ -12566,6 +12502,9 @@
12566
12502
  args[_key] = arguments[_key];
12567
12503
  }
12568
12504
  _this = _Batch.call.apply(_Batch, [this].concat(args)) || this;
12505
+ /**
12506
+ * one for fill, one for stroke
12507
+ */
12569
12508
  _this.meshes = [TextMesh, TextMesh];
12570
12509
  return _this;
12571
12510
  }
@@ -12632,8 +12571,17 @@
12632
12571
  this.rendererFactory = void 0;
12633
12572
  this.texturePool = void 0;
12634
12573
  this.lightPool = void 0;
12574
+ /**
12575
+ * attached when Device created
12576
+ */
12635
12577
  this.context = void 0;
12578
+ /**
12579
+ * draw calls
12580
+ */
12636
12581
  this.meshes = [];
12582
+ /**
12583
+ * update patches which can be merged before rendering
12584
+ */
12637
12585
  this.pendingUpdatePatches = {};
12638
12586
  this.stencilRefCache = {};
12639
12587
  this.renderHelper = renderHelper;
@@ -12641,9 +12589,6 @@
12641
12589
  this.texturePool = texturePool;
12642
12590
  this.lightPool = lightPool;
12643
12591
  }
12644
- /**
12645
- * attached when Device created
12646
- */
12647
12592
  var _proto = BatchManager.prototype;
12648
12593
  _proto.render = function render(list, isPicking) {
12649
12594
  var _this = this;
@@ -13553,9 +13498,7 @@
13553
13498
  if (!isNaN(iterable.length)) {
13554
13499
  var i = -1,
13555
13500
  next = function next() {
13556
- for (; ++i < iterable.length;) {
13557
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
13558
- }
13501
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
13559
13502
  return next.value = undefined, next.done = !0, next;
13560
13503
  };
13561
13504
  return next.next = next;
@@ -13601,9 +13544,7 @@
13601
13544
  }), exports.keys = function (val) {
13602
13545
  var object = Object(val),
13603
13546
  keys = [];
13604
- for (var key in object) {
13605
- keys.push(key);
13606
- }
13547
+ for (var key in object) keys.push(key);
13607
13548
  return keys.reverse(), function next() {
13608
13549
  for (; keys.length;) {
13609
13550
  var key = keys.pop();
@@ -13614,9 +13555,7 @@
13614
13555
  }, exports.values = values, Context.prototype = {
13615
13556
  constructor: Context,
13616
13557
  reset: function reset(skipTempReset) {
13617
- 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) {
13618
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
13619
- }
13558
+ 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);
13620
13559
  },
13621
13560
  stop: function stop() {
13622
13561
  this.done = !0;
@@ -13749,7 +13688,8 @@
13749
13688
  _proto.apply = function apply(context, runtime) {
13750
13689
  var _this = this;
13751
13690
  var renderingService = context.renderingService,
13752
- renderingContext = context.renderingContext;
13691
+ renderingContext = context.renderingContext,
13692
+ config = context.config;
13753
13693
  this.context = context;
13754
13694
  var canvas = renderingContext.root.ownerDocument.defaultView;
13755
13695
  // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
@@ -13774,6 +13714,9 @@
13774
13714
  var onPointerWheel = function onPointerWheel(ev) {
13775
13715
  renderingService.hooks.pointerWheel.call(ev);
13776
13716
  };
13717
+ var onClick = function onClick(ev) {
13718
+ renderingService.hooks.click.call(ev);
13719
+ };
13777
13720
  var addPointerEventListener = function addPointerEventListener($el) {
13778
13721
  runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
13779
13722
  $el.addEventListener('pointerdown', onPointerDown, true);
@@ -13817,36 +13760,37 @@
13817
13760
  renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
13818
13761
  var $el;
13819
13762
  return _regeneratorRuntime$2().wrap(function _callee$(_context) {
13820
- while (1) {
13821
- switch (_context.prev = _context.next) {
13822
- case 0:
13823
- $el = _this.context.contextService.getDomElement(); // @ts-ignore
13824
- if (runtime.globalThis.navigator.msPointerEnabled) {
13825
- // @ts-ignore
13826
- $el.style.msContentZooming = 'none';
13827
- // @ts-ignore
13828
- $el.style.msTouchAction = 'none';
13829
- } else if (canvas.supportsPointerEvents) {
13830
- $el.style.touchAction = 'none';
13831
- }
13832
- if (canvas.supportsPointerEvents) {
13833
- addPointerEventListener($el);
13834
- } else {
13835
- addMouseEventListener($el);
13836
- }
13837
- if (canvas.supportsTouchEvents) {
13838
- addTouchEventListener($el);
13839
- }
13840
- // use passive event listeners
13841
- // @see https://zhuanlan.zhihu.com/p/24555031
13842
- $el.addEventListener('wheel', onPointerWheel, {
13843
- passive: true,
13844
- capture: true
13845
- });
13846
- case 5:
13847
- case "end":
13848
- return _context.stop();
13849
- }
13763
+ while (1) switch (_context.prev = _context.next) {
13764
+ case 0:
13765
+ $el = _this.context.contextService.getDomElement(); // @ts-ignore
13766
+ if (runtime.globalThis.navigator.msPointerEnabled) {
13767
+ // @ts-ignore
13768
+ $el.style.msContentZooming = 'none';
13769
+ // @ts-ignore
13770
+ $el.style.msTouchAction = 'none';
13771
+ } else if (canvas.supportsPointerEvents) {
13772
+ $el.style.touchAction = 'none';
13773
+ }
13774
+ if (canvas.supportsPointerEvents) {
13775
+ addPointerEventListener($el);
13776
+ } else {
13777
+ addMouseEventListener($el);
13778
+ }
13779
+ if (canvas.supportsTouchEvents) {
13780
+ addTouchEventListener($el);
13781
+ }
13782
+ if (config.useNativeClickEvent) {
13783
+ $el.addEventListener('click', onClick, true);
13784
+ }
13785
+ // use passive event listeners
13786
+ // @see https://zhuanlan.zhihu.com/p/24555031
13787
+ $el.addEventListener('wheel', onPointerWheel, {
13788
+ passive: true,
13789
+ capture: true
13790
+ });
13791
+ case 6:
13792
+ case "end":
13793
+ return _context.stop();
13850
13794
  }
13851
13795
  }, _callee);
13852
13796
  })));
@@ -13869,6 +13813,9 @@
13869
13813
  if (canvas.supportsTouchEvents) {
13870
13814
  removeTouchEventListener($el);
13871
13815
  }
13816
+ if (config.useNativeClickEvent) {
13817
+ $el.removeEventListener('click', onClick, true);
13818
+ }
13872
13819
  $el.removeEventListener('wheel', onPointerWheel, true);
13873
13820
  });
13874
13821
  };
@@ -14067,9 +14014,7 @@
14067
14014
  if (!isNaN(iterable.length)) {
14068
14015
  var i = -1,
14069
14016
  next = function next() {
14070
- for (; ++i < iterable.length;) {
14071
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
14072
- }
14017
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
14073
14018
  return next.value = undefined, next.done = !0, next;
14074
14019
  };
14075
14020
  return next.next = next;
@@ -14115,9 +14060,7 @@
14115
14060
  }), exports.keys = function (val) {
14116
14061
  var object = Object(val),
14117
14062
  keys = [];
14118
- for (var key in object) {
14119
- keys.push(key);
14120
- }
14063
+ for (var key in object) keys.push(key);
14121
14064
  return keys.reverse(), function next() {
14122
14065
  for (; keys.length;) {
14123
14066
  var key = keys.pop();
@@ -14128,9 +14071,7 @@
14128
14071
  }, exports.values = values, Context.prototype = {
14129
14072
  constructor: Context,
14130
14073
  reset: function reset(skipTempReset) {
14131
- 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) {
14132
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
14133
- }
14074
+ 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);
14134
14075
  },
14135
14076
  stop: function stop() {
14136
14077
  this.done = !0;
@@ -14255,6 +14196,9 @@
14255
14196
  var HTMLRenderingPlugin = /*#__PURE__*/function () {
14256
14197
  function HTMLRenderingPlugin() {
14257
14198
  this.context = void 0;
14199
+ /**
14200
+ * wrapper for camera
14201
+ */
14258
14202
  this.$camera = void 0;
14259
14203
  }
14260
14204
  var _proto = HTMLRenderingPlugin.prototype;
@@ -14332,22 +14276,20 @@
14332
14276
  };
14333
14277
  renderingService.hooks.init.tapPromise(HTMLRenderingPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
14334
14278
  return _regeneratorRuntime$3().wrap(function _callee$(_context) {
14335
- while (1) {
14336
- switch (_context.prev = _context.next) {
14337
- case 0:
14338
- if (displayObjectPool.getHTMLs().length) {
14339
- // append camera
14340
- _this.$camera = _this.createCamera(camera);
14341
- }
14342
- canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
14343
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14344
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
14345
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
14346
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14347
- case 6:
14348
- case "end":
14349
- return _context.stop();
14350
- }
14279
+ while (1) switch (_context.prev = _context.next) {
14280
+ case 0:
14281
+ if (displayObjectPool.getHTMLs().length) {
14282
+ // append camera
14283
+ _this.$camera = _this.createCamera(camera);
14284
+ }
14285
+ canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
14286
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14287
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
14288
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
14289
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14290
+ case 6:
14291
+ case "end":
14292
+ return _context.stop();
14351
14293
  }
14352
14294
  }, _callee);
14353
14295
  })));
@@ -14714,9 +14656,7 @@
14714
14656
  if (!isNaN(iterable.length)) {
14715
14657
  var i = -1,
14716
14658
  next = function next() {
14717
- for (; ++i < iterable.length;) {
14718
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
14719
- }
14659
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
14720
14660
  return next.value = undefined, next.done = !0, next;
14721
14661
  };
14722
14662
  return next.next = next;
@@ -14762,9 +14702,7 @@
14762
14702
  }), exports.keys = function (val) {
14763
14703
  var object = Object(val),
14764
14704
  keys = [];
14765
- for (var key in object) {
14766
- keys.push(key);
14767
- }
14705
+ for (var key in object) keys.push(key);
14768
14706
  return keys.reverse(), function next() {
14769
14707
  for (; keys.length;) {
14770
14708
  var key = keys.pop();
@@ -14775,9 +14713,7 @@
14775
14713
  }, exports.values = values, Context.prototype = {
14776
14714
  constructor: Context,
14777
14715
  reset: function reset(skipTempReset) {
14778
- 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) {
14779
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
14780
- }
14716
+ 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);
14781
14717
  },
14782
14718
  stop: function stop() {
14783
14719
  this.done = !0;
@@ -15210,15 +15146,13 @@
15210
15146
  };
15211
15147
  renderingService.hooks.init.tapPromise(LoadImagePlugin.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
15212
15148
  return _regeneratorRuntime$4().wrap(function _callee$(_context) {
15213
- while (1) {
15214
- switch (_context.prev = _context.next) {
15215
- case 0:
15216
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
15217
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
15218
- case 2:
15219
- case "end":
15220
- return _context.stop();
15221
- }
15149
+ while (1) switch (_context.prev = _context.next) {
15150
+ case 0:
15151
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
15152
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
15153
+ case 2:
15154
+ case "end":
15155
+ return _context.stop();
15222
15156
  }
15223
15157
  }, _callee);
15224
15158
  })));
@@ -15419,9 +15353,7 @@
15419
15353
  if (!isNaN(iterable.length)) {
15420
15354
  var i = -1,
15421
15355
  next = function next() {
15422
- for (; ++i < iterable.length;) {
15423
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
15424
- }
15356
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
15425
15357
  return next.value = undefined, next.done = !0, next;
15426
15358
  };
15427
15359
  return next.next = next;
@@ -15467,9 +15399,7 @@
15467
15399
  }), exports.keys = function (val) {
15468
15400
  var object = Object(val),
15469
15401
  keys = [];
15470
- for (var key in object) {
15471
- keys.push(key);
15472
- }
15402
+ for (var key in object) keys.push(key);
15473
15403
  return keys.reverse(), function next() {
15474
15404
  for (; keys.length;) {
15475
15405
  var key = keys.pop();
@@ -15480,9 +15410,7 @@
15480
15410
  }, exports.values = values, Context.prototype = {
15481
15411
  constructor: Context,
15482
15412
  reset: function reset(skipTempReset) {
15483
- 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) {
15484
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
15485
- }
15413
+ 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);
15486
15414
  },
15487
15415
  stop: function stop() {
15488
15416
  this.done = !0;
@@ -15738,62 +15666,60 @@
15738
15666
  _load = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee(module, imports) {
15739
15667
  var bytes, instance;
15740
15668
  return _regeneratorRuntime$5().wrap(function _callee$(_context) {
15741
- while (1) {
15742
- switch (_context.prev = _context.next) {
15743
- case 0:
15744
- if (!(typeof Response === 'function' && module instanceof Response)) {
15745
- _context.next = 23;
15746
- break;
15747
- }
15748
- if (!(typeof WebAssembly.instantiateStreaming === 'function')) {
15749
- _context.next = 15;
15750
- break;
15751
- }
15752
- _context.prev = 2;
15753
- _context.next = 5;
15754
- return WebAssembly.instantiateStreaming(module, imports);
15755
- case 5:
15756
- return _context.abrupt("return", _context.sent);
15757
- case 8:
15758
- _context.prev = 8;
15759
- _context.t0 = _context["catch"](2);
15760
- if (!(module.headers.get('Content-Type') != 'application/wasm')) {
15761
- _context.next = 14;
15762
- break;
15763
- }
15764
- console.warn('`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n', _context.t0);
15669
+ while (1) switch (_context.prev = _context.next) {
15670
+ case 0:
15671
+ if (!(typeof Response === 'function' && module instanceof Response)) {
15672
+ _context.next = 23;
15673
+ break;
15674
+ }
15675
+ if (!(typeof WebAssembly.instantiateStreaming === 'function')) {
15765
15676
  _context.next = 15;
15766
15677
  break;
15767
- case 14:
15768
- throw _context.t0;
15769
- case 15:
15770
- _context.next = 17;
15771
- return module.arrayBuffer();
15772
- case 17:
15773
- bytes = _context.sent;
15774
- _context.next = 20;
15775
- return WebAssembly.instantiate(bytes, imports);
15776
- case 20:
15777
- return _context.abrupt("return", _context.sent);
15778
- case 23:
15779
- _context.next = 25;
15780
- return WebAssembly.instantiate(module, imports);
15781
- case 25:
15782
- instance = _context.sent;
15783
- if (!(instance instanceof WebAssembly.Instance)) {
15784
- _context.next = 30;
15785
- break;
15786
- }
15787
- return _context.abrupt("return", {
15788
- instance: instance,
15789
- module: module
15790
- });
15791
- case 30:
15792
- return _context.abrupt("return", instance);
15793
- case 31:
15794
- case "end":
15795
- return _context.stop();
15796
- }
15678
+ }
15679
+ _context.prev = 2;
15680
+ _context.next = 5;
15681
+ return WebAssembly.instantiateStreaming(module, imports);
15682
+ case 5:
15683
+ return _context.abrupt("return", _context.sent);
15684
+ case 8:
15685
+ _context.prev = 8;
15686
+ _context.t0 = _context["catch"](2);
15687
+ if (!(module.headers.get('Content-Type') != 'application/wasm')) {
15688
+ _context.next = 14;
15689
+ break;
15690
+ }
15691
+ console.warn('`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n', _context.t0);
15692
+ _context.next = 15;
15693
+ break;
15694
+ case 14:
15695
+ throw _context.t0;
15696
+ case 15:
15697
+ _context.next = 17;
15698
+ return module.arrayBuffer();
15699
+ case 17:
15700
+ bytes = _context.sent;
15701
+ _context.next = 20;
15702
+ return WebAssembly.instantiate(bytes, imports);
15703
+ case 20:
15704
+ return _context.abrupt("return", _context.sent);
15705
+ case 23:
15706
+ _context.next = 25;
15707
+ return WebAssembly.instantiate(module, imports);
15708
+ case 25:
15709
+ instance = _context.sent;
15710
+ if (!(instance instanceof WebAssembly.Instance)) {
15711
+ _context.next = 30;
15712
+ break;
15713
+ }
15714
+ return _context.abrupt("return", {
15715
+ instance: instance,
15716
+ module: module
15717
+ });
15718
+ case 30:
15719
+ return _context.abrupt("return", instance);
15720
+ case 31:
15721
+ case "end":
15722
+ return _context.stop();
15797
15723
  }
15798
15724
  }, _callee, null, [[2, 8]]);
15799
15725
  }));
@@ -15806,49 +15732,47 @@
15806
15732
  _init = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee2(input) {
15807
15733
  var imports, _yield$load, instance, module;
15808
15734
  return _regeneratorRuntime$5().wrap(function _callee2$(_context2) {
15809
- while (1) {
15810
- switch (_context2.prev = _context2.next) {
15811
- case 0:
15812
- imports = {};
15813
- imports.wbg = {};
15814
- imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
15815
- var ret = getStringFromWasm0(arg0, arg1);
15816
- return addHeapObject(ret);
15817
- };
15818
- imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
15819
- takeObject(arg0);
15820
- };
15821
- imports.wbg.__wbg_log_fbd13631356d44e4 = function (arg0) {
15822
- console.log(getObject(arg0));
15823
- };
15824
- imports.wbg.__wbg_log_00fa6d531d56c191 = function (arg0, arg1) {
15825
- console.log(getObject(arg0), getObject(arg1));
15826
- };
15827
- imports.wbg.__wbindgen_throw = function (arg0, arg1) {
15828
- throw new Error(getStringFromWasm0(arg0, arg1));
15829
- };
15830
- if (typeof input === 'string' || typeof Request === 'function' && input instanceof Request || typeof URL === 'function' && input instanceof URL) {
15831
- input = fetch(input);
15832
- }
15833
- _context2.t0 = load;
15834
- _context2.next = 12;
15835
- return input;
15836
- case 12:
15837
- _context2.t1 = _context2.sent;
15838
- _context2.t2 = imports;
15839
- _context2.next = 16;
15840
- return (0, _context2.t0)(_context2.t1, _context2.t2);
15841
- case 16:
15842
- _yield$load = _context2.sent;
15843
- instance = _yield$load.instance;
15844
- module = _yield$load.module;
15845
- wasm = instance.exports;
15846
- init.__wbindgen_wasm_module = module;
15847
- return _context2.abrupt("return", wasm);
15848
- case 22:
15849
- case "end":
15850
- return _context2.stop();
15851
- }
15735
+ while (1) switch (_context2.prev = _context2.next) {
15736
+ case 0:
15737
+ imports = {};
15738
+ imports.wbg = {};
15739
+ imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
15740
+ var ret = getStringFromWasm0(arg0, arg1);
15741
+ return addHeapObject(ret);
15742
+ };
15743
+ imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
15744
+ takeObject(arg0);
15745
+ };
15746
+ imports.wbg.__wbg_log_fbd13631356d44e4 = function (arg0) {
15747
+ console.log(getObject(arg0));
15748
+ };
15749
+ imports.wbg.__wbg_log_00fa6d531d56c191 = function (arg0, arg1) {
15750
+ console.log(getObject(arg0), getObject(arg1));
15751
+ };
15752
+ imports.wbg.__wbindgen_throw = function (arg0, arg1) {
15753
+ throw new Error(getStringFromWasm0(arg0, arg1));
15754
+ };
15755
+ if (typeof input === 'string' || typeof Request === 'function' && input instanceof Request || typeof URL === 'function' && input instanceof URL) {
15756
+ input = fetch(input);
15757
+ }
15758
+ _context2.t0 = load;
15759
+ _context2.next = 12;
15760
+ return input;
15761
+ case 12:
15762
+ _context2.t1 = _context2.sent;
15763
+ _context2.t2 = imports;
15764
+ _context2.next = 16;
15765
+ return (0, _context2.t0)(_context2.t1, _context2.t2);
15766
+ case 16:
15767
+ _yield$load = _context2.sent;
15768
+ instance = _yield$load.instance;
15769
+ module = _yield$load.module;
15770
+ wasm = instance.exports;
15771
+ init.__wbindgen_wasm_module = module;
15772
+ return _context2.abrupt("return", wasm);
15773
+ case 22:
15774
+ case "end":
15775
+ return _context2.stop();
15852
15776
  }
15853
15777
  }, _callee2);
15854
15778
  }));
@@ -16587,12 +16511,6 @@
16587
16511
  }
16588
16512
  var _proto = Readback_WebGPU.prototype;
16589
16513
  _proto.readTexture = function readTexture(t, x, y, width, height, dst, dstOffset, length) {
16590
- if (dstOffset === void 0) {
16591
- dstOffset = 0;
16592
- }
16593
- if (length === void 0) {
16594
- length = 0;
16595
- }
16596
16514
  var texture = t;
16597
16515
  var faceIndex = 0;
16598
16516
  var blockInformation = this.getBlockInformationFromFormat(texture.format);
@@ -16624,8 +16542,9 @@
16624
16542
  depthOrArrayLayers: 1
16625
16543
  });
16626
16544
  this.device.device.queue.submit([commandEncoder.finish()]);
16627
- // read from buffer
16628
- return this.readBuffer(buffer, size, dst, dstOffset, length, texture.pixelFormat);
16545
+ // FIXME: read from buffer
16546
+ // return this.readBuffer(buffer, size, dst, dstOffset, length, texture.pixelFormat);
16547
+ return null;
16629
16548
  };
16630
16549
  _proto.readBuffer = function readBuffer(b, srcByteOffset, dstArrayBufferView, dstOffset, _size, type, noDataConversion, destroy) {
16631
16550
  var _this2 = this;
@@ -17266,7 +17185,7 @@
17266
17185
  // @see https://developer.chrome.com/blog/new-in-chrome-94/#canvas-colorspace
17267
17186
  // colorSpace: 'srgb',
17268
17187
  // @see https://www.w3.org/TR/webgpu/#enumdef-gpucanvascompositingalphamode
17269
- compositingAlphaMode: 'premultiplied'
17188
+ alphaMode: 'premultiplied'
17270
17189
  });
17271
17190
  };
17272
17191
  _proto.getOnscreenTexture = function getOnscreenTexture() {
@@ -17510,16 +17429,14 @@
17510
17429
  });
17511
17430
  }
17512
17431
  }
17513
- for (var _i = 0; _i < bindingLayout.numUniformBuffers; _i++) {
17514
- entries[0].push({
17515
- binding: entries[0].length,
17516
- visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
17517
- buffer: {
17518
- type: 'uniform',
17519
- hasDynamicOffset: true
17520
- }
17521
- });
17522
- }
17432
+ for (var _i = 0; _i < bindingLayout.numUniformBuffers; _i++) entries[0].push({
17433
+ binding: entries[0].length,
17434
+ visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
17435
+ buffer: {
17436
+ type: 'uniform',
17437
+ hasDynamicOffset: true
17438
+ }
17439
+ });
17523
17440
  for (var _i2 = 0; _i2 < bindingLayout.numSamplers; _i2++) {
17524
17441
  var samplerEntry = bindingLayout.samplerEntries !== undefined ? bindingLayout.samplerEntries[_i2] : defaultBindingLayoutSamplerDescriptor;
17525
17442
  entries[1].push({
@@ -17729,75 +17646,73 @@
17729
17646
  var _createSwapChain = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee($canvas) {
17730
17647
  var adapter, optionalFeatures, requiredFeatures, device, context;
17731
17648
  return _regeneratorRuntime$5().wrap(function _callee$(_context) {
17732
- while (1) {
17733
- switch (_context.prev = _context.next) {
17734
- case 0:
17735
- if (!(gLite.runtime.globalThis.navigator.gpu === undefined)) {
17736
- _context.next = 2;
17737
- break;
17738
- }
17739
- return _context.abrupt("return", null);
17740
- case 2:
17741
- adapter = null;
17742
- _context.prev = 3;
17743
- _context.next = 6;
17744
- return gLite.runtime.globalThis.navigator.gpu.requestAdapter();
17745
- case 6:
17746
- adapter = _context.sent;
17747
- _context.next = 12;
17649
+ while (1) switch (_context.prev = _context.next) {
17650
+ case 0:
17651
+ if (!(gLite.runtime.globalThis.navigator.gpu === undefined)) {
17652
+ _context.next = 2;
17748
17653
  break;
17749
- case 9:
17750
- _context.prev = 9;
17751
- _context.t0 = _context["catch"](3);
17752
- console.log(_context.t0);
17753
- case 12:
17754
- if (!(adapter === null)) {
17755
- _context.next = 14;
17756
- break;
17757
- }
17758
- return _context.abrupt("return", null);
17759
- case 14:
17760
- // @see https://www.w3.org/TR/webgpu/#dom-gpudevicedescriptor-requiredfeatures
17761
- optionalFeatures = [
17762
- // 'depth24unorm-stencil8',
17763
- 'depth32float-stencil8', 'texture-compression-bc'];
17764
- requiredFeatures = optionalFeatures.filter(function (feature) {
17765
- return adapter.features.has(feature);
17766
- });
17767
- _context.next = 18;
17768
- return adapter.requestDevice({
17769
- requiredFeatures: requiredFeatures
17770
- });
17771
- case 18:
17772
- device = _context.sent;
17773
- if (!(device === null)) {
17774
- _context.next = 21;
17775
- break;
17776
- }
17777
- return _context.abrupt("return", null);
17778
- case 21:
17779
- context = $canvas.getContext('webgpu');
17780
- if (context) {
17781
- _context.next = 24;
17782
- break;
17783
- }
17784
- return _context.abrupt("return", null);
17785
- case 24:
17786
- _context.prev = 24;
17787
- _context.next = 27;
17788
- return init('/glsl_wgsl_compiler_bg.wasm');
17789
- case 27:
17790
- _context.next = 31;
17654
+ }
17655
+ return _context.abrupt("return", null);
17656
+ case 2:
17657
+ adapter = null;
17658
+ _context.prev = 3;
17659
+ _context.next = 6;
17660
+ return gLite.runtime.globalThis.navigator.gpu.requestAdapter();
17661
+ case 6:
17662
+ adapter = _context.sent;
17663
+ _context.next = 12;
17664
+ break;
17665
+ case 9:
17666
+ _context.prev = 9;
17667
+ _context.t0 = _context["catch"](3);
17668
+ console.log(_context.t0);
17669
+ case 12:
17670
+ if (!(adapter === null)) {
17671
+ _context.next = 14;
17791
17672
  break;
17792
- case 29:
17793
- _context.prev = 29;
17794
- _context.t1 = _context["catch"](24);
17795
- case 31:
17796
- return _context.abrupt("return", new Device_WebGPU(adapter, device, $canvas, context, glsl_compile));
17797
- case 32:
17798
- case "end":
17799
- return _context.stop();
17800
- }
17673
+ }
17674
+ return _context.abrupt("return", null);
17675
+ case 14:
17676
+ // @see https://www.w3.org/TR/webgpu/#dom-gpudevicedescriptor-requiredfeatures
17677
+ optionalFeatures = [
17678
+ // 'depth24unorm-stencil8',
17679
+ 'depth32float-stencil8', 'texture-compression-bc'];
17680
+ requiredFeatures = optionalFeatures.filter(function (feature) {
17681
+ return adapter.features.has(feature);
17682
+ });
17683
+ _context.next = 18;
17684
+ return adapter.requestDevice({
17685
+ requiredFeatures: requiredFeatures
17686
+ });
17687
+ case 18:
17688
+ device = _context.sent;
17689
+ if (!(device === null)) {
17690
+ _context.next = 21;
17691
+ break;
17692
+ }
17693
+ return _context.abrupt("return", null);
17694
+ case 21:
17695
+ context = $canvas.getContext('webgpu');
17696
+ if (context) {
17697
+ _context.next = 24;
17698
+ break;
17699
+ }
17700
+ return _context.abrupt("return", null);
17701
+ case 24:
17702
+ _context.prev = 24;
17703
+ _context.next = 27;
17704
+ return init('/glsl_wgsl_compiler_bg.wasm');
17705
+ case 27:
17706
+ _context.next = 31;
17707
+ break;
17708
+ case 29:
17709
+ _context.prev = 29;
17710
+ _context.t1 = _context["catch"](24);
17711
+ case 31:
17712
+ return _context.abrupt("return", new Device_WebGPU(adapter, device, $canvas, context, glsl_compile));
17713
+ case 32:
17714
+ case "end":
17715
+ return _context.stop();
17801
17716
  }
17802
17717
  }, _callee, null, [[3, 9], [24, 29]]);
17803
17718
  }));
@@ -17854,35 +17769,33 @@
17854
17769
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17855
17770
  var _this$canvasConfig, container, canvas, $canvas;
17856
17771
  return _regeneratorRuntime().wrap(function _callee$(_context) {
17857
- while (1) {
17858
- switch (_context.prev = _context.next) {
17859
- case 0:
17860
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
17861
- if (canvas) {
17862
- this.$canvas = canvas;
17863
- if (container && canvas.parentElement !== container) {
17864
- container.appendChild(canvas);
17865
- }
17866
- this.$container = canvas.parentElement;
17867
- this.canvasConfig.container = this.$container;
17868
- } else if (container) {
17869
- // create container
17870
- this.$container = isString(container) ? document.getElementById(container) : container;
17871
- if (this.$container) {
17872
- // create canvas
17873
- $canvas = document.createElement('canvas');
17874
- this.$container.appendChild($canvas);
17875
- if (!this.$container.style.position) {
17876
- this.$container.style.position = 'relative';
17877
- }
17878
- this.$canvas = $canvas;
17772
+ while (1) switch (_context.prev = _context.next) {
17773
+ case 0:
17774
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
17775
+ if (canvas) {
17776
+ this.$canvas = canvas;
17777
+ if (container && canvas.parentElement !== container) {
17778
+ container.appendChild(canvas);
17779
+ }
17780
+ this.$container = canvas.parentElement;
17781
+ this.canvasConfig.container = this.$container;
17782
+ } else if (container) {
17783
+ // create container
17784
+ this.$container = isString(container) ? document.getElementById(container) : container;
17785
+ if (this.$container) {
17786
+ // create canvas
17787
+ $canvas = document.createElement('canvas');
17788
+ this.$container.appendChild($canvas);
17789
+ if (!this.$container.style.position) {
17790
+ this.$container.style.position = 'relative';
17879
17791
  }
17792
+ this.$canvas = $canvas;
17880
17793
  }
17881
- this.resize(this.canvasConfig.width, this.canvasConfig.height);
17882
- case 3:
17883
- case "end":
17884
- return _context.stop();
17885
- }
17794
+ }
17795
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
17796
+ case 3:
17797
+ case "end":
17798
+ return _context.stop();
17886
17799
  }
17887
17800
  }, _callee, this);
17888
17801
  }));
@@ -17936,14 +17849,12 @@
17936
17849
  _proto.toDataURL = /*#__PURE__*/function () {
17937
17850
  var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
17938
17851
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
17939
- while (1) {
17940
- switch (_context2.prev = _context2.next) {
17941
- case 0:
17942
- return _context2.abrupt("return", '');
17943
- case 1:
17944
- case "end":
17945
- return _context2.stop();
17946
- }
17852
+ while (1) switch (_context2.prev = _context2.next) {
17853
+ case 0:
17854
+ return _context2.abrupt("return", '');
17855
+ case 1:
17856
+ case "end":
17857
+ return _context2.stop();
17947
17858
  }
17948
17859
  }, _callee2);
17949
17860
  }));