modern-canvas 0.4.19 → 0.4.21

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.cjs CHANGED
@@ -2155,13 +2155,13 @@ class Vector3 extends Vector {
2155
2155
  }
2156
2156
  }
2157
2157
 
2158
- var __defProp$H = Object.defineProperty;
2159
- var __decorateClass$P = (decorators, target, key, kind) => {
2158
+ var __defProp$J = Object.defineProperty;
2159
+ var __decorateClass$R = (decorators, target, key, kind) => {
2160
2160
  var result = void 0 ;
2161
2161
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
2162
2162
  if (decorator = decorators[i])
2163
2163
  result = (decorator(target, key, result) ) || result;
2164
- if (result) __defProp$H(target, key, result);
2164
+ if (result) __defProp$J(target, key, result);
2165
2165
  return result;
2166
2166
  };
2167
2167
  class MainLoop extends CoreObject {
@@ -2204,10 +2204,10 @@ class MainLoop extends CoreObject {
2204
2204
  this.stop();
2205
2205
  }
2206
2206
  }
2207
- __decorateClass$P([
2207
+ __decorateClass$R([
2208
2208
  property({ default: 24 })
2209
2209
  ], MainLoop.prototype, "fps");
2210
- __decorateClass$P([
2210
+ __decorateClass$R([
2211
2211
  property({ default: 1 })
2212
2212
  ], MainLoop.prototype, "speed");
2213
2213
 
@@ -2228,19 +2228,15 @@ class Renderer {
2228
2228
  return related;
2229
2229
  }
2230
2230
  resize(width, height, updateStyle = true) {
2231
- const viewWidth = Math.floor(width * this.pixelRatio);
2232
- const viewHeight = Math.floor(height * this.pixelRatio);
2233
- const screenWidth = viewWidth / this.pixelRatio;
2234
- const screenHeight = viewHeight / this.pixelRatio;
2235
2231
  if (this.view) {
2236
- this.view.width = viewWidth;
2237
- this.view.height = viewHeight;
2232
+ this.view.width = Math.floor(width * this.pixelRatio);
2233
+ this.view.height = Math.floor(height * this.pixelRatio);
2238
2234
  }
2239
- this.screen.width = screenWidth;
2240
- this.screen.height = screenHeight;
2235
+ this.screen.width = width;
2236
+ this.screen.height = height;
2241
2237
  if (updateStyle && this.view) {
2242
- this.view.style.width = `${screenWidth}px`;
2243
- this.view.style.height = `${screenHeight}px`;
2238
+ this.view.style.width = `${width}px`;
2239
+ this.view.style.height = `${height}px`;
2244
2240
  }
2245
2241
  }
2246
2242
  }
@@ -4513,13 +4509,13 @@ class Geometry extends Resource {
4513
4509
  }
4514
4510
  }
4515
4511
 
4516
- var __defProp$G = Object.defineProperty;
4517
- var __decorateClass$O = (decorators, target, key, kind) => {
4512
+ var __defProp$I = Object.defineProperty;
4513
+ var __decorateClass$Q = (decorators, target, key, kind) => {
4518
4514
  var result = void 0 ;
4519
4515
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4520
4516
  if (decorator = decorators[i])
4521
4517
  result = (decorator(target, key, result) ) || result;
4522
- if (result) __defProp$G(target, key, result);
4518
+ if (result) __defProp$I(target, key, result);
4523
4519
  return result;
4524
4520
  };
4525
4521
  class IndexBuffer extends Resource {
@@ -4563,20 +4559,20 @@ class IndexBuffer extends Resource {
4563
4559
  return result;
4564
4560
  }
4565
4561
  }
4566
- __decorateClass$O([
4562
+ __decorateClass$Q([
4567
4563
  protectedProperty({ default: null })
4568
4564
  ], IndexBuffer.prototype, "data");
4569
- __decorateClass$O([
4565
+ __decorateClass$Q([
4570
4566
  protectedProperty({ default: false })
4571
4567
  ], IndexBuffer.prototype, "dynamic");
4572
4568
 
4573
- var __defProp$F = Object.defineProperty;
4574
- var __decorateClass$N = (decorators, target, key, kind) => {
4569
+ var __defProp$H = Object.defineProperty;
4570
+ var __decorateClass$P = (decorators, target, key, kind) => {
4575
4571
  var result = void 0 ;
4576
4572
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4577
4573
  if (decorator = decorators[i])
4578
4574
  result = (decorator(target, key, result) ) || result;
4579
- if (result) __defProp$F(target, key, result);
4575
+ if (result) __defProp$H(target, key, result);
4580
4576
  return result;
4581
4577
  };
4582
4578
  class VertexBuffer extends Resource {
@@ -4620,20 +4616,20 @@ class VertexBuffer extends Resource {
4620
4616
  return result;
4621
4617
  }
4622
4618
  }
4623
- __decorateClass$N([
4619
+ __decorateClass$P([
4624
4620
  protectedProperty({ default: null })
4625
4621
  ], VertexBuffer.prototype, "data");
4626
- __decorateClass$N([
4622
+ __decorateClass$P([
4627
4623
  protectedProperty({ default: false })
4628
4624
  ], VertexBuffer.prototype, "dynamic");
4629
4625
 
4630
- var __defProp$E = Object.defineProperty;
4631
- var __decorateClass$M = (decorators, target, key, kind) => {
4626
+ var __defProp$G = Object.defineProperty;
4627
+ var __decorateClass$O = (decorators, target, key, kind) => {
4632
4628
  var result = void 0 ;
4633
4629
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4634
4630
  if (decorator = decorators[i])
4635
4631
  result = (decorator(target, key, result) ) || result;
4636
- if (result) __defProp$E(target, key, result);
4632
+ if (result) __defProp$G(target, key, result);
4637
4633
  return result;
4638
4634
  };
4639
4635
  class VertexAttribute extends Resource {
@@ -4670,25 +4666,25 @@ class VertexAttribute extends Resource {
4670
4666
  return result;
4671
4667
  }
4672
4668
  }
4673
- __decorateClass$M([
4669
+ __decorateClass$O([
4674
4670
  protectedProperty()
4675
4671
  ], VertexAttribute.prototype, "buffer");
4676
- __decorateClass$M([
4672
+ __decorateClass$O([
4677
4673
  protectedProperty({ default: 0 })
4678
4674
  ], VertexAttribute.prototype, "size");
4679
- __decorateClass$M([
4675
+ __decorateClass$O([
4680
4676
  protectedProperty({ default: false })
4681
4677
  ], VertexAttribute.prototype, "normalized");
4682
- __decorateClass$M([
4678
+ __decorateClass$O([
4683
4679
  protectedProperty({ default: "float" })
4684
4680
  ], VertexAttribute.prototype, "type");
4685
- __decorateClass$M([
4681
+ __decorateClass$O([
4686
4682
  protectedProperty()
4687
4683
  ], VertexAttribute.prototype, "stride");
4688
- __decorateClass$M([
4684
+ __decorateClass$O([
4689
4685
  protectedProperty()
4690
4686
  ], VertexAttribute.prototype, "offset");
4691
- __decorateClass$M([
4687
+ __decorateClass$O([
4692
4688
  protectedProperty()
4693
4689
  ], VertexAttribute.prototype, "divisor");
4694
4690
 
@@ -4932,13 +4928,13 @@ class UvGeometry extends Geometry {
4932
4928
  }
4933
4929
  }
4934
4930
 
4935
- var __defProp$D = Object.defineProperty;
4936
- var __decorateClass$L = (decorators, target, key, kind) => {
4931
+ var __defProp$F = Object.defineProperty;
4932
+ var __decorateClass$N = (decorators, target, key, kind) => {
4937
4933
  var result = void 0 ;
4938
4934
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4939
4935
  if (decorator = decorators[i])
4940
4936
  result = (decorator(target, key, result) ) || result;
4941
- if (result) __defProp$D(target, key, result);
4937
+ if (result) __defProp$F(target, key, result);
4942
4938
  return result;
4943
4939
  };
4944
4940
  class Texture2D extends Resource {
@@ -5064,22 +5060,22 @@ class Texture2D extends Resource {
5064
5060
  }
5065
5061
  }
5066
5062
  }
5067
- __decorateClass$L([
5063
+ __decorateClass$N([
5068
5064
  protectedProperty()
5069
5065
  ], Texture2D.prototype, "source");
5070
- __decorateClass$L([
5066
+ __decorateClass$N([
5071
5067
  property({ default: 0 })
5072
5068
  ], Texture2D.prototype, "width");
5073
- __decorateClass$L([
5069
+ __decorateClass$N([
5074
5070
  property({ default: 0 })
5075
5071
  ], Texture2D.prototype, "height");
5076
- __decorateClass$L([
5072
+ __decorateClass$N([
5077
5073
  property({ default: "linear" })
5078
5074
  ], Texture2D.prototype, "filterMode");
5079
- __decorateClass$L([
5075
+ __decorateClass$N([
5080
5076
  property({ default: "clamp_to_edge" })
5081
5077
  ], Texture2D.prototype, "wrapMode");
5082
- __decorateClass$L([
5078
+ __decorateClass$N([
5083
5079
  property({ default: 1 })
5084
5080
  ], Texture2D.prototype, "pixelRatio");
5085
5081
 
@@ -5109,13 +5105,13 @@ class AnimatedTexture extends Resource {
5109
5105
  }
5110
5106
  }
5111
5107
 
5112
- var __defProp$C = Object.defineProperty;
5113
- var __decorateClass$K = (decorators, target, key, kind) => {
5108
+ var __defProp$E = Object.defineProperty;
5109
+ var __decorateClass$M = (decorators, target, key, kind) => {
5114
5110
  var result = void 0 ;
5115
5111
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5116
5112
  if (decorator = decorators[i])
5117
5113
  result = (decorator(target, key, result) ) || result;
5118
- if (result) __defProp$C(target, key, result);
5114
+ if (result) __defProp$E(target, key, result);
5119
5115
  return result;
5120
5116
  };
5121
5117
  class CanvasTexture extends Texture2D {
@@ -5134,7 +5130,7 @@ class CanvasTexture extends Texture2D {
5134
5130
  super._updateProperty(key, value, oldValue, declaration);
5135
5131
  }
5136
5132
  }
5137
- __decorateClass$K([
5133
+ __decorateClass$M([
5138
5134
  property({ default: 2 })
5139
5135
  ], CanvasTexture.prototype, "pixelRatio");
5140
5136
 
@@ -5282,23 +5278,27 @@ class PixelsTexture extends Texture2D {
5282
5278
  _updateProperty(key, value, oldValue, declaration) {
5283
5279
  switch (key) {
5284
5280
  case "width":
5285
- this.source.width = Math.round(value * this.pixelRatio);
5281
+ this.source.width = Math.round(this.width * this.pixelRatio);
5286
5282
  break;
5287
5283
  case "height":
5288
- this.source.height = Math.round(value * this.pixelRatio);
5284
+ this.source.height = Math.round(this.height * this.pixelRatio);
5285
+ break;
5286
+ case "pixelRatio":
5287
+ this.source.width = Math.round(this.width * this.pixelRatio);
5288
+ this.source.height = Math.round(this.height * this.pixelRatio);
5289
5289
  break;
5290
5290
  }
5291
5291
  super._updateProperty(key, value, oldValue, declaration);
5292
5292
  }
5293
5293
  }
5294
5294
 
5295
- var __defProp$B = Object.defineProperty;
5296
- var __decorateClass$J = (decorators, target, key, kind) => {
5295
+ var __defProp$D = Object.defineProperty;
5296
+ var __decorateClass$L = (decorators, target, key, kind) => {
5297
5297
  var result = void 0 ;
5298
5298
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5299
5299
  if (decorator = decorators[i])
5300
5300
  result = (decorator(target, key, result) ) || result;
5301
- if (result) __defProp$B(target, key, result);
5301
+ if (result) __defProp$D(target, key, result);
5302
5302
  return result;
5303
5303
  };
5304
5304
  function resolveOptions(options) {
@@ -5542,10 +5542,10 @@ const _VideoTexture = class _VideoTexture extends Texture2D {
5542
5542
  }
5543
5543
  }
5544
5544
  };
5545
- __decorateClass$J([
5545
+ __decorateClass$L([
5546
5546
  protectedProperty({ default: true })
5547
5547
  ], _VideoTexture.prototype, "autoUpdate");
5548
- __decorateClass$J([
5548
+ __decorateClass$L([
5549
5549
  protectedProperty({ default: 0 })
5550
5550
  ], _VideoTexture.prototype, "fps");
5551
5551
  let VideoTexture = _VideoTexture;
@@ -5554,14 +5554,14 @@ class ViewportTexture extends PixelsTexture {
5554
5554
  //
5555
5555
  }
5556
5556
 
5557
- var __defProp$A = Object.defineProperty;
5558
- var __getOwnPropDesc$G = Object.getOwnPropertyDescriptor;
5559
- var __decorateClass$I = (decorators, target, key, kind) => {
5560
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$G(target, key) : target;
5557
+ var __defProp$C = Object.defineProperty;
5558
+ var __getOwnPropDesc$I = Object.getOwnPropertyDescriptor;
5559
+ var __decorateClass$K = (decorators, target, key, kind) => {
5560
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$I(target, key) : target;
5561
5561
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5562
5562
  if (decorator = decorators[i])
5563
5563
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
5564
- if (kind && result) __defProp$A(target, key, result);
5564
+ if (kind && result) __defProp$C(target, key, result);
5565
5565
  return result;
5566
5566
  };
5567
5567
  const tagUidMap = {};
@@ -6066,36 +6066,36 @@ exports.Node = class Node extends CoreObject {
6066
6066
  return node;
6067
6067
  }
6068
6068
  };
6069
- __decorateClass$I([
6069
+ __decorateClass$K([
6070
6070
  protectedProperty()
6071
6071
  ], exports.Node.prototype, "name", 2);
6072
- __decorateClass$I([
6072
+ __decorateClass$K([
6073
6073
  property()
6074
6074
  ], exports.Node.prototype, "mask", 2);
6075
- __decorateClass$I([
6075
+ __decorateClass$K([
6076
6076
  property({ default: "inherit" })
6077
6077
  ], exports.Node.prototype, "processMode", 2);
6078
- __decorateClass$I([
6078
+ __decorateClass$K([
6079
6079
  property({ default: "default" })
6080
6080
  ], exports.Node.prototype, "processSortMode", 2);
6081
- __decorateClass$I([
6081
+ __decorateClass$K([
6082
6082
  property({ default: "inherit" })
6083
6083
  ], exports.Node.prototype, "renderMode", 2);
6084
- __decorateClass$I([
6084
+ __decorateClass$K([
6085
6085
  property({ default: "default" })
6086
6086
  ], exports.Node.prototype, "internalMode", 2);
6087
- exports.Node = __decorateClass$I([
6087
+ exports.Node = __decorateClass$K([
6088
6088
  customNode("Node")
6089
6089
  ], exports.Node);
6090
6090
 
6091
- var __defProp$z = Object.defineProperty;
6092
- var __getOwnPropDesc$F = Object.getOwnPropertyDescriptor;
6093
- var __decorateClass$H = (decorators, target, key, kind) => {
6094
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$F(target, key) : target;
6091
+ var __defProp$B = Object.defineProperty;
6092
+ var __getOwnPropDesc$H = Object.getOwnPropertyDescriptor;
6093
+ var __decorateClass$J = (decorators, target, key, kind) => {
6094
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$H(target, key) : target;
6095
6095
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6096
6096
  if (decorator = decorators[i])
6097
6097
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6098
- if (kind && result) __defProp$z(target, key, result);
6098
+ if (kind && result) __defProp$B(target, key, result);
6099
6099
  return result;
6100
6100
  };
6101
6101
  exports.TimelineNode = class TimelineNode extends exports.Node {
@@ -6155,30 +6155,30 @@ exports.TimelineNode = class TimelineNode extends exports.Node {
6155
6155
  this._updateCurrentTime();
6156
6156
  }
6157
6157
  };
6158
- __decorateClass$H([
6158
+ __decorateClass$J([
6159
6159
  property({ default: 0 })
6160
6160
  ], exports.TimelineNode.prototype, "delay", 2);
6161
- __decorateClass$H([
6161
+ __decorateClass$J([
6162
6162
  property({ default: 0 })
6163
6163
  ], exports.TimelineNode.prototype, "duration", 2);
6164
- __decorateClass$H([
6164
+ __decorateClass$J([
6165
6165
  property({ default: false })
6166
6166
  ], exports.TimelineNode.prototype, "paused", 2);
6167
- __decorateClass$H([
6167
+ __decorateClass$J([
6168
6168
  protectedProperty()
6169
6169
  ], exports.TimelineNode.prototype, "insideTimeRange", 2);
6170
- exports.TimelineNode = __decorateClass$H([
6170
+ exports.TimelineNode = __decorateClass$J([
6171
6171
  customNode("TimelineNode")
6172
6172
  ], exports.TimelineNode);
6173
6173
 
6174
- var __defProp$y = Object.defineProperty;
6175
- var __getOwnPropDesc$E = Object.getOwnPropertyDescriptor;
6176
- var __decorateClass$G = (decorators, target, key, kind) => {
6177
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$E(target, key) : target;
6174
+ var __defProp$A = Object.defineProperty;
6175
+ var __getOwnPropDesc$G = Object.getOwnPropertyDescriptor;
6176
+ var __decorateClass$I = (decorators, target, key, kind) => {
6177
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$G(target, key) : target;
6178
6178
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6179
6179
  if (decorator = decorators[i])
6180
6180
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6181
- if (kind && result) __defProp$y(target, key, result);
6181
+ if (kind && result) __defProp$A(target, key, result);
6182
6182
  return result;
6183
6183
  };
6184
6184
  exports.Viewport = class Viewport extends exports.Node {
@@ -6208,9 +6208,9 @@ exports.Viewport = class Viewport extends exports.Node {
6208
6208
  const { pixelRatio } = renderer;
6209
6209
  this._framebuffers.forEach((framebuffer) => {
6210
6210
  const texture = framebuffer.texture;
6211
- texture.pixelRatio = pixelRatio;
6212
6211
  texture.width = width;
6213
6212
  texture.height = height;
6213
+ texture.pixelRatio = pixelRatio;
6214
6214
  texture.upload(renderer);
6215
6215
  });
6216
6216
  return {
@@ -6316,30 +6316,30 @@ exports.Viewport = class Viewport extends exports.Node {
6316
6316
  return this._projection.toArray(transpose);
6317
6317
  }
6318
6318
  };
6319
- __decorateClass$G([
6319
+ __decorateClass$I([
6320
6320
  property({ default: 0 })
6321
6321
  ], exports.Viewport.prototype, "x", 2);
6322
- __decorateClass$G([
6322
+ __decorateClass$I([
6323
6323
  property({ default: 0 })
6324
6324
  ], exports.Viewport.prototype, "y", 2);
6325
- __decorateClass$G([
6325
+ __decorateClass$I([
6326
6326
  property({ default: 0 })
6327
6327
  ], exports.Viewport.prototype, "width", 2);
6328
- __decorateClass$G([
6328
+ __decorateClass$I([
6329
6329
  property({ default: 0 })
6330
6330
  ], exports.Viewport.prototype, "height", 2);
6331
- exports.Viewport = __decorateClass$G([
6331
+ exports.Viewport = __decorateClass$I([
6332
6332
  customNode("Viewport")
6333
6333
  ], exports.Viewport);
6334
6334
 
6335
- var __defProp$x = Object.defineProperty;
6336
- var __getOwnPropDesc$D = Object.getOwnPropertyDescriptor;
6337
- var __decorateClass$F = (decorators, target, key, kind) => {
6338
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$D(target, key) : target;
6335
+ var __defProp$z = Object.defineProperty;
6336
+ var __getOwnPropDesc$F = Object.getOwnPropertyDescriptor;
6337
+ var __decorateClass$H = (decorators, target, key, kind) => {
6338
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$F(target, key) : target;
6339
6339
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6340
6340
  if (decorator = decorators[i])
6341
6341
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6342
- if (kind && result) __defProp$x(target, key, result);
6342
+ if (kind && result) __defProp$z(target, key, result);
6343
6343
  return result;
6344
6344
  };
6345
6345
  exports.Effect = class Effect extends exports.TimelineNode {
@@ -6580,69 +6580,35 @@ exports.Effect = class Effect extends exports.TimelineNode {
6580
6580
  }
6581
6581
  }
6582
6582
  };
6583
- __decorateClass$F([
6583
+ __decorateClass$H([
6584
6584
  protectedProperty()
6585
6585
  ], exports.Effect.prototype, "material", 2);
6586
- __decorateClass$F([
6586
+ __decorateClass$H([
6587
6587
  property()
6588
6588
  ], exports.Effect.prototype, "effectMode", 2);
6589
- __decorateClass$F([
6589
+ __decorateClass$H([
6590
6590
  property({ default: "" })
6591
6591
  ], exports.Effect.prototype, "glsl", 2);
6592
- __decorateClass$F([
6592
+ __decorateClass$H([
6593
6593
  property({ default: "" })
6594
6594
  ], exports.Effect.prototype, "glslSrc", 2);
6595
- exports.Effect = __decorateClass$F([
6595
+ exports.Effect = __decorateClass$H([
6596
6596
  customNode("Effect")
6597
6597
  ], exports.Effect);
6598
6598
 
6599
- var __defProp$w = Object.defineProperty;
6600
- var __getOwnPropDesc$C = Object.getOwnPropertyDescriptor;
6601
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6602
- var __decorateClass$E = (decorators, target, key, kind) => {
6603
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$C(target, key) : target;
6599
+ var __defProp$y = Object.defineProperty;
6600
+ var __getOwnPropDesc$E = Object.getOwnPropertyDescriptor;
6601
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6602
+ var __decorateClass$G = (decorators, target, key, kind) => {
6603
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$E(target, key) : target;
6604
6604
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6605
6605
  if (decorator = decorators[i])
6606
6606
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6607
- if (kind && result) __defProp$w(target, key, result);
6607
+ if (kind && result) __defProp$y(target, key, result);
6608
6608
  return result;
6609
6609
  };
6610
- var __publicField$h = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
6611
- const vertX = `attribute vec2 position;
6612
- attribute vec2 uv;
6613
- varying vec2 vUv[9];
6614
- uniform float strength;
6615
-
6616
- void main(void) {
6617
- gl_Position = vec4(position, 0, 1);
6618
- vUv[0] = uv + vec2(-4.0 * strength, 0.0);
6619
- vUv[1] = uv + vec2(-3.0 * strength, 0.0);
6620
- vUv[2] = uv + vec2(-2.0 * strength, 0.0);
6621
- vUv[3] = uv + vec2(-1.0 * strength, 0.0);
6622
- vUv[4] = uv + vec2(0.0 * strength, 0.0);
6623
- vUv[5] = uv + vec2(1.0 * strength, 0.0);
6624
- vUv[6] = uv + vec2(2.0 * strength, 0.0);
6625
- vUv[7] = uv + vec2(3.0 * strength, 0.0);
6626
- vUv[8] = uv + vec2(4.0 * strength, 0.0);
6627
- }`;
6628
- const vertY = `attribute vec2 position;
6629
- attribute vec2 uv;
6630
- uniform float strength;
6631
- varying vec2 vUv[9];
6632
-
6633
- void main(void) {
6634
- gl_Position = vec4(position, 0, 1);
6635
- vUv[0] = uv + vec2(0.0, -4.0 * strength);
6636
- vUv[1] = uv + vec2(0.0, -3.0 * strength);
6637
- vUv[2] = uv + vec2(0.0, -2.0 * strength);
6638
- vUv[3] = uv + vec2(0.0, -1.0 * strength);
6639
- vUv[4] = uv + vec2(0.0, 0.0 * strength);
6640
- vUv[5] = uv + vec2(0.0, 1.0 * strength);
6641
- vUv[6] = uv + vec2(0.0, 2.0 * strength);
6642
- vUv[7] = uv + vec2(0.0, 3.0 * strength);
6643
- vUv[8] = uv + vec2(0.0, 4.0 * strength);
6644
- }`;
6645
- const frag = `varying vec2 vUv[9];
6610
+ var __publicField$i = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
6611
+ const frag$2 = `varying vec2 vUv[9];
6646
6612
  uniform sampler2D sampler;
6647
6613
 
6648
6614
  void main(void) {
@@ -6678,6 +6644,10 @@ void main(void) {
6678
6644
  }
6679
6645
  }`;
6680
6646
  exports.BlurEffect = class BlurEffect extends exports.Effect {
6647
+ constructor(properties, children = []) {
6648
+ super();
6649
+ this.setProperties(properties).append(children);
6650
+ }
6681
6651
  apply(renderer, source) {
6682
6652
  source.redraw(renderer, () => {
6683
6653
  QuadUvGeometry.draw(renderer, exports.BlurEffect.materialX, {
@@ -6693,45 +6663,73 @@ exports.BlurEffect = class BlurEffect extends exports.Effect {
6693
6663
  });
6694
6664
  }
6695
6665
  };
6696
- __publicField$h(exports.BlurEffect, "materialX", new Material({
6697
- vert: vertX,
6698
- frag
6666
+ __publicField$i(exports.BlurEffect, "materialX", new Material({
6667
+ vert: `attribute vec2 position;
6668
+ attribute vec2 uv;
6669
+ varying vec2 vUv[9];
6670
+ uniform float strength;
6671
+
6672
+ void main(void) {
6673
+ gl_Position = vec4(position, 0, 1);
6674
+ vUv[0] = uv + vec2(-4.0 * strength, 0.0);
6675
+ vUv[1] = uv + vec2(-3.0 * strength, 0.0);
6676
+ vUv[2] = uv + vec2(-2.0 * strength, 0.0);
6677
+ vUv[3] = uv + vec2(-1.0 * strength, 0.0);
6678
+ vUv[4] = uv + vec2(0.0 * strength, 0.0);
6679
+ vUv[5] = uv + vec2(1.0 * strength, 0.0);
6680
+ vUv[6] = uv + vec2(2.0 * strength, 0.0);
6681
+ vUv[7] = uv + vec2(3.0 * strength, 0.0);
6682
+ vUv[8] = uv + vec2(4.0 * strength, 0.0);
6683
+ }`,
6684
+ frag: frag$2
6699
6685
  }));
6700
- __publicField$h(exports.BlurEffect, "materialY", new Material({
6701
- vert: vertY,
6702
- frag
6686
+ __publicField$i(exports.BlurEffect, "materialY", new Material({
6687
+ vert: `attribute vec2 position;
6688
+ attribute vec2 uv;
6689
+ uniform float strength;
6690
+ varying vec2 vUv[9];
6691
+
6692
+ void main(void) {
6693
+ gl_Position = vec4(position, 0, 1);
6694
+ vUv[0] = uv + vec2(0.0, -4.0 * strength);
6695
+ vUv[1] = uv + vec2(0.0, -3.0 * strength);
6696
+ vUv[2] = uv + vec2(0.0, -2.0 * strength);
6697
+ vUv[3] = uv + vec2(0.0, -1.0 * strength);
6698
+ vUv[4] = uv + vec2(0.0, 0.0 * strength);
6699
+ vUv[5] = uv + vec2(0.0, 1.0 * strength);
6700
+ vUv[6] = uv + vec2(0.0, 2.0 * strength);
6701
+ vUv[7] = uv + vec2(0.0, 3.0 * strength);
6702
+ vUv[8] = uv + vec2(0.0, 4.0 * strength);
6703
+ }`,
6704
+ frag: frag$2
6703
6705
  }));
6704
- __decorateClass$E([
6705
- property({ default: 8 })
6706
- ], exports.BlurEffect.prototype, "strength", 2);
6707
- __decorateClass$E([
6706
+ __decorateClass$G([
6708
6707
  property({ default: 4 })
6708
+ ], exports.BlurEffect.prototype, "strength", 2);
6709
+ __decorateClass$G([
6710
+ property({ default: 3 })
6709
6711
  ], exports.BlurEffect.prototype, "quality", 2);
6710
- exports.BlurEffect = __decorateClass$E([
6712
+ exports.BlurEffect = __decorateClass$G([
6711
6713
  customNode("BlurEffect")
6712
6714
  ], exports.BlurEffect);
6713
6715
 
6714
- var __defProp$v = Object.defineProperty;
6715
- var __getOwnPropDesc$B = Object.getOwnPropertyDescriptor;
6716
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6717
- var __decorateClass$D = (decorators, target, key, kind) => {
6718
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$B(target, key) : target;
6716
+ var __defProp$x = Object.defineProperty;
6717
+ var __getOwnPropDesc$D = Object.getOwnPropertyDescriptor;
6718
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6719
+ var __decorateClass$F = (decorators, target, key, kind) => {
6720
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$D(target, key) : target;
6719
6721
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6720
6722
  if (decorator = decorators[i])
6721
6723
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6722
- if (kind && result) __defProp$v(target, key, result);
6724
+ if (kind && result) __defProp$x(target, key, result);
6723
6725
  return result;
6724
6726
  };
6725
- var __publicField$g = (obj, key, value) => __defNormalProp$g(obj, key + "" , value);
6727
+ var __publicField$h = (obj, key, value) => __defNormalProp$h(obj, key + "" , value);
6726
6728
  exports.ColorAdjustEffect = class ColorAdjustEffect extends exports.Effect {
6727
- saturation = 1;
6728
- contrast = 1;
6729
- brightness = 1;
6730
- red = 1;
6731
- green = 1;
6732
- blue = 1;
6733
- alpha = 1;
6734
- gamma = 1;
6729
+ constructor(properties, children = []) {
6730
+ super();
6731
+ this.setProperties(properties).append(children);
6732
+ }
6735
6733
  apply(renderer, source) {
6736
6734
  source.redraw(renderer, () => {
6737
6735
  QuadUvGeometry.draw(renderer, exports.ColorAdjustEffect.material, {
@@ -6748,7 +6746,7 @@ exports.ColorAdjustEffect = class ColorAdjustEffect extends exports.Effect {
6748
6746
  });
6749
6747
  }
6750
6748
  };
6751
- __publicField$g(exports.ColorAdjustEffect, "material", new Material({
6749
+ __publicField$h(exports.ColorAdjustEffect, "material", new Material({
6752
6750
  vert: `precision mediump float;
6753
6751
  attribute vec2 position;
6754
6752
  attribute vec2 uv;
@@ -6783,51 +6781,51 @@ void main(void) {
6783
6781
  gl_FragColor = c * alpha;
6784
6782
  }`
6785
6783
  }));
6786
- __decorateClass$D([
6787
- property()
6784
+ __decorateClass$F([
6785
+ property({ default: 1 })
6788
6786
  ], exports.ColorAdjustEffect.prototype, "saturation", 2);
6789
- __decorateClass$D([
6790
- property()
6787
+ __decorateClass$F([
6788
+ property({ default: 1 })
6791
6789
  ], exports.ColorAdjustEffect.prototype, "contrast", 2);
6792
- __decorateClass$D([
6793
- property()
6790
+ __decorateClass$F([
6791
+ property({ default: 1 })
6794
6792
  ], exports.ColorAdjustEffect.prototype, "brightness", 2);
6795
- __decorateClass$D([
6796
- property()
6793
+ __decorateClass$F([
6794
+ property({ default: 1 })
6797
6795
  ], exports.ColorAdjustEffect.prototype, "red", 2);
6798
- __decorateClass$D([
6799
- property()
6796
+ __decorateClass$F([
6797
+ property({ default: 1 })
6800
6798
  ], exports.ColorAdjustEffect.prototype, "green", 2);
6801
- __decorateClass$D([
6802
- property()
6799
+ __decorateClass$F([
6800
+ property({ default: 1 })
6803
6801
  ], exports.ColorAdjustEffect.prototype, "blue", 2);
6804
- __decorateClass$D([
6805
- property()
6802
+ __decorateClass$F([
6803
+ property({ default: 1 })
6806
6804
  ], exports.ColorAdjustEffect.prototype, "alpha", 2);
6807
- __decorateClass$D([
6808
- property()
6805
+ __decorateClass$F([
6806
+ property({ default: 1 })
6809
6807
  ], exports.ColorAdjustEffect.prototype, "gamma", 2);
6810
- exports.ColorAdjustEffect = __decorateClass$D([
6808
+ exports.ColorAdjustEffect = __decorateClass$F([
6811
6809
  customNode("ColorAdjustEffect")
6812
6810
  ], exports.ColorAdjustEffect);
6813
6811
 
6814
- var __defProp$u = Object.defineProperty;
6815
- var __getOwnPropDesc$A = Object.getOwnPropertyDescriptor;
6816
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6817
- var __decorateClass$C = (decorators, target, key, kind) => {
6818
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$A(target, key) : target;
6812
+ var __defProp$w = Object.defineProperty;
6813
+ var __getOwnPropDesc$C = Object.getOwnPropertyDescriptor;
6814
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6815
+ var __decorateClass$E = (decorators, target, key, kind) => {
6816
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$C(target, key) : target;
6819
6817
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6820
6818
  if (decorator = decorators[i])
6821
6819
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6822
- if (kind && result) __defProp$u(target, key, result);
6820
+ if (kind && result) __defProp$w(target, key, result);
6823
6821
  return result;
6824
6822
  };
6825
- var __publicField$f = (obj, key, value) => __defNormalProp$f(obj, key + "" , value);
6823
+ var __publicField$g = (obj, key, value) => __defNormalProp$g(obj, key + "" , value);
6826
6824
  exports.ColorFilterEffect = class ColorFilterEffect extends exports.Effect {
6827
6825
  _colorMatrix = new ColorMatrix();
6828
- constructor(properties) {
6826
+ constructor(properties, children = []) {
6829
6827
  super();
6830
- this.setProperties(properties);
6828
+ this.setProperties(properties).append(children);
6831
6829
  }
6832
6830
  apply(renderer, source) {
6833
6831
  if (!this.filter)
@@ -6872,7 +6870,7 @@ exports.ColorFilterEffect = class ColorFilterEffect extends exports.Effect {
6872
6870
  });
6873
6871
  }
6874
6872
  };
6875
- __publicField$f(exports.ColorFilterEffect, "material", new Material({
6873
+ __publicField$g(exports.ColorFilterEffect, "material", new Material({
6876
6874
  vert: `precision mediump float;
6877
6875
  attribute vec2 position;
6878
6876
  attribute vec2 uv;
@@ -6899,30 +6897,32 @@ void main(void) {
6899
6897
  );
6900
6898
  }`
6901
6899
  }));
6902
- __decorateClass$C([
6903
- property({ default: "" })
6900
+ __decorateClass$E([
6901
+ property()
6904
6902
  ], exports.ColorFilterEffect.prototype, "filter", 2);
6905
- exports.ColorFilterEffect = __decorateClass$C([
6903
+ exports.ColorFilterEffect = __decorateClass$E([
6906
6904
  customNode("ColorFilterEffect")
6907
6905
  ], exports.ColorFilterEffect);
6908
6906
 
6909
- var __defProp$t = Object.defineProperty;
6910
- var __getOwnPropDesc$z = Object.getOwnPropertyDescriptor;
6911
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6912
- var __decorateClass$B = (decorators, target, key, kind) => {
6913
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$z(target, key) : target;
6907
+ var __defProp$v = Object.defineProperty;
6908
+ var __getOwnPropDesc$B = Object.getOwnPropertyDescriptor;
6909
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6910
+ var __decorateClass$D = (decorators, target, key, kind) => {
6911
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$B(target, key) : target;
6914
6912
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6915
6913
  if (decorator = decorators[i])
6916
6914
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6917
- if (kind && result) __defProp$t(target, key, result);
6915
+ if (kind && result) __defProp$v(target, key, result);
6918
6916
  return result;
6919
6917
  };
6920
- var __publicField$e = (obj, key, value) => __defNormalProp$e(obj, key + "" , value);
6918
+ var __publicField$f = (obj, key, value) => __defNormalProp$f(obj, key + "" , value);
6921
6919
  const MAX_COLORS$1 = 50;
6922
6920
  exports.ColorOverlayEffect = class ColorOverlayEffect extends exports.Effect {
6923
- colors = [];
6924
- alpha = 0.5;
6925
6921
  _color = new Color();
6922
+ constructor(properties, children = []) {
6923
+ super();
6924
+ this.setProperties(properties).append(children);
6925
+ }
6926
6926
  apply(renderer, source) {
6927
6927
  source.redraw(renderer, () => {
6928
6928
  const colors = this.colors.map((val) => {
@@ -6941,7 +6941,7 @@ exports.ColorOverlayEffect = class ColorOverlayEffect extends exports.Effect {
6941
6941
  });
6942
6942
  }
6943
6943
  };
6944
- __publicField$e(exports.ColorOverlayEffect, "material", new Material({
6944
+ __publicField$f(exports.ColorOverlayEffect, "material", new Material({
6945
6945
  vert: `precision mediump float;
6946
6946
  attribute vec2 position;
6947
6947
  attribute vec2 uv;
@@ -6988,32 +6988,34 @@ void main(void) {
6988
6988
  gl_FragColor = vec4(mix(color.rgb, mask.rgb, color.a * mask.a), color.a);
6989
6989
  }`
6990
6990
  }));
6991
- __decorateClass$B([
6992
- property()
6991
+ __decorateClass$D([
6992
+ property({ default: [] })
6993
6993
  ], exports.ColorOverlayEffect.prototype, "colors", 2);
6994
- __decorateClass$B([
6995
- property()
6994
+ __decorateClass$D([
6995
+ property({ default: 0.5 })
6996
6996
  ], exports.ColorOverlayEffect.prototype, "alpha", 2);
6997
- exports.ColorOverlayEffect = __decorateClass$B([
6997
+ exports.ColorOverlayEffect = __decorateClass$D([
6998
6998
  customNode("ColorOverlayEffect")
6999
6999
  ], exports.ColorOverlayEffect);
7000
7000
 
7001
- var __defProp$s = Object.defineProperty;
7002
- var __getOwnPropDesc$y = Object.getOwnPropertyDescriptor;
7003
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7004
- var __decorateClass$A = (decorators, target, key, kind) => {
7005
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$y(target, key) : target;
7001
+ var __defProp$u = Object.defineProperty;
7002
+ var __getOwnPropDesc$A = Object.getOwnPropertyDescriptor;
7003
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7004
+ var __decorateClass$C = (decorators, target, key, kind) => {
7005
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$A(target, key) : target;
7006
7006
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7007
7007
  if (decorator = decorators[i])
7008
7008
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7009
- if (kind && result) __defProp$s(target, key, result);
7009
+ if (kind && result) __defProp$u(target, key, result);
7010
7010
  return result;
7011
7011
  };
7012
- var __publicField$d = (obj, key, value) => __defNormalProp$d(obj, key + "" , value);
7012
+ var __publicField$e = (obj, key, value) => __defNormalProp$e(obj, key + "" , value);
7013
7013
  exports.ColorRemoveEffect = class ColorRemoveEffect extends exports.Effect {
7014
- colors = [];
7015
- epsilon = 0.5;
7016
7014
  _color = new Color();
7015
+ constructor(properties, children = []) {
7016
+ super();
7017
+ this.setProperties(properties).append(children);
7018
+ }
7017
7019
  apply(renderer, source) {
7018
7020
  const maxColors = 50;
7019
7021
  const originalColors = new Float32Array(maxColors * 3);
@@ -7038,7 +7040,7 @@ exports.ColorRemoveEffect = class ColorRemoveEffect extends exports.Effect {
7038
7040
  });
7039
7041
  }
7040
7042
  };
7041
- __publicField$d(exports.ColorRemoveEffect, "material", new Material({
7043
+ __publicField$e(exports.ColorRemoveEffect, "material", new Material({
7042
7044
  vert: `precision mediump float;
7043
7045
  attribute vec2 position;
7044
7046
  attribute vec2 uv;
@@ -7071,33 +7073,35 @@ void main(void) {
7071
7073
  gl_FragColor = color;
7072
7074
  }`
7073
7075
  }));
7074
- __decorateClass$A([
7075
- property()
7076
+ __decorateClass$C([
7077
+ property({ default: [] })
7076
7078
  ], exports.ColorRemoveEffect.prototype, "colors", 2);
7077
- __decorateClass$A([
7078
- property()
7079
+ __decorateClass$C([
7080
+ property({ default: 0.5 })
7079
7081
  ], exports.ColorRemoveEffect.prototype, "epsilon", 2);
7080
- exports.ColorRemoveEffect = __decorateClass$A([
7082
+ exports.ColorRemoveEffect = __decorateClass$C([
7081
7083
  customNode("ColorRemoveEffect")
7082
7084
  ], exports.ColorRemoveEffect);
7083
7085
 
7084
- var __defProp$r = Object.defineProperty;
7085
- var __getOwnPropDesc$x = Object.getOwnPropertyDescriptor;
7086
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7087
- var __decorateClass$z = (decorators, target, key, kind) => {
7088
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$x(target, key) : target;
7086
+ var __defProp$t = Object.defineProperty;
7087
+ var __getOwnPropDesc$z = Object.getOwnPropertyDescriptor;
7088
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7089
+ var __decorateClass$B = (decorators, target, key, kind) => {
7090
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$z(target, key) : target;
7089
7091
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7090
7092
  if (decorator = decorators[i])
7091
7093
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7092
- if (kind && result) __defProp$r(target, key, result);
7094
+ if (kind && result) __defProp$t(target, key, result);
7093
7095
  return result;
7094
7096
  };
7095
- var __publicField$c = (obj, key, value) => __defNormalProp$c(obj, key + "" , value);
7097
+ var __publicField$d = (obj, key, value) => __defNormalProp$d(obj, key + "" , value);
7096
7098
  const MAX_COLORS = 50;
7097
7099
  exports.ColorReplaceEffect = class ColorReplaceEffect extends exports.Effect {
7098
- colors = [];
7099
- epsilon = 0.05;
7100
7100
  _color = new Color();
7101
+ constructor(properties, children = []) {
7102
+ super();
7103
+ this.setProperties(properties).append(children);
7104
+ }
7101
7105
  apply(renderer, source) {
7102
7106
  const colors = this.colors.map((val) => {
7103
7107
  this._color.value = val[0];
@@ -7136,7 +7140,7 @@ exports.ColorReplaceEffect = class ColorReplaceEffect extends exports.Effect {
7136
7140
  });
7137
7141
  }
7138
7142
  };
7139
- __publicField$c(exports.ColorReplaceEffect, "material", new Material({
7143
+ __publicField$d(exports.ColorReplaceEffect, "material", new Material({
7140
7144
  vert: `precision mediump float;
7141
7145
  attribute vec2 position;
7142
7146
  attribute vec2 uv;
@@ -7176,626 +7180,756 @@ void main(void) {
7176
7180
  }
7177
7181
  }`
7178
7182
  }));
7179
- __decorateClass$z([
7180
- property()
7183
+ __decorateClass$B([
7184
+ property({ default: [] })
7181
7185
  ], exports.ColorReplaceEffect.prototype, "colors", 2);
7182
- __decorateClass$z([
7183
- property()
7186
+ __decorateClass$B([
7187
+ property({ default: 0.05 })
7184
7188
  ], exports.ColorReplaceEffect.prototype, "epsilon", 2);
7185
- exports.ColorReplaceEffect = __decorateClass$z([
7189
+ exports.ColorReplaceEffect = __decorateClass$B([
7186
7190
  customNode("ColorReplaceEffect")
7187
7191
  ], exports.ColorReplaceEffect);
7188
7192
 
7189
- var __defProp$q = Object.defineProperty;
7190
- var __getOwnPropDesc$w = Object.getOwnPropertyDescriptor;
7191
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7192
- var __decorateClass$y = (decorators, target, key, kind) => {
7193
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$w(target, key) : target;
7194
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7195
- if (decorator = decorators[i])
7196
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7197
- if (kind && result) __defProp$q(target, key, result);
7198
- return result;
7199
- };
7200
- var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, key + "" , value);
7201
- exports.EmbossEffect = class EmbossEffect extends exports.Effect {
7202
- strength;
7203
- constructor(strength = 5) {
7204
- super();
7205
- this.strength = strength;
7206
- }
7207
- apply(renderer, source) {
7208
- source.redraw(renderer, () => {
7209
- QuadUvGeometry.draw(renderer, exports.EmbossEffect.material, {
7210
- sampler: 0,
7211
- strength: this.strength,
7212
- inputSize: [source.width, source.height, 1 / source.width, 1 / source.height]
7193
+ class CanvasContext extends modernPath2d.Path2D {
7194
+ textureTransform;
7195
+ fillStyle;
7196
+ strokeStyle;
7197
+ lineCap;
7198
+ lineJoin;
7199
+ lineWidth;
7200
+ miterLimit;
7201
+ _defaultStyle = Texture2D.EMPTY;
7202
+ _draws = [];
7203
+ stroke() {
7204
+ let texture = this._defaultStyle;
7205
+ if (this.strokeStyle) {
7206
+ if (this.strokeStyle instanceof Texture2D) {
7207
+ texture = this.strokeStyle;
7208
+ } else {
7209
+ texture = new ColorTexture(this.strokeStyle);
7210
+ }
7211
+ }
7212
+ if (this.curves.length) {
7213
+ this._draws.push({
7214
+ type: "stroke",
7215
+ path: new modernPath2d.Path2D(this),
7216
+ texture,
7217
+ textureTransform: this.textureTransform,
7218
+ style: {
7219
+ alignment: 0.5,
7220
+ cap: this.lineCap ?? "butt",
7221
+ join: this.lineJoin ?? "miter",
7222
+ width: this.lineWidth ?? 1,
7223
+ miterLimit: this.miterLimit ?? 10
7224
+ }
7213
7225
  });
7214
- });
7226
+ super.reset();
7227
+ }
7215
7228
  }
7216
- };
7217
- __publicField$b(exports.EmbossEffect, "material", new Material({
7218
- vert: `precision mediump float;
7219
- attribute vec2 position;
7220
- attribute vec2 uv;
7221
- varying vec2 vUv;
7222
- void main() {
7223
- gl_Position = vec4(position, 0.0, 1.0);
7224
- vUv = uv;
7225
- }`,
7226
- frag: `precision mediump float;
7227
- uniform sampler2D sampler;
7228
- uniform vec4 inputSize;
7229
- uniform float strength;
7230
- varying vec2 vUv;
7231
-
7232
- void main(void) {
7233
- vec2 onePixel = inputSize.zw;
7234
- vec4 color;
7235
- color.rgb = vec3(0.5);
7236
- color -= texture2D(sampler, vUv - onePixel) * strength;
7237
- color += texture2D(sampler, vUv + onePixel) * strength;
7238
- color.rgb = vec3((color.r + color.g + color.b) / 3.0);
7239
- float alpha = texture2D(sampler, vUv).a;
7240
- gl_FragColor = vec4(color.rgb * alpha, alpha);
7241
- }`
7242
- }));
7243
- __decorateClass$y([
7244
- property()
7245
- ], exports.EmbossEffect.prototype, "strength", 2);
7246
- exports.EmbossEffect = __decorateClass$y([
7247
- customNode("EmbossEffect")
7248
- ], exports.EmbossEffect);
7249
-
7250
- var __defProp$p = Object.defineProperty;
7251
- var __getOwnPropDesc$v = Object.getOwnPropertyDescriptor;
7252
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7253
- var __decorateClass$x = (decorators, target, key, kind) => {
7254
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$v(target, key) : target;
7255
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7256
- if (decorator = decorators[i])
7257
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7258
- if (kind && result) __defProp$p(target, key, result);
7259
- return result;
7260
- };
7261
- var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, key + "" , value);
7262
- exports.GlitchEffect = class GlitchEffect extends exports.Effect {
7263
- _canvas;
7264
- _texture;
7265
- _sizes;
7266
- _offsets;
7267
- _needsRedraw = false;
7268
- slices = 10;
7269
- sampleSize = 512;
7270
- offset = 100;
7271
- direction = 0;
7272
- fillMode = 2;
7273
- seed = 0;
7274
- red = [2, 2];
7275
- green = [-10, 4];
7276
- blue = [10, -4];
7277
- constructor() {
7278
- super();
7279
- this._canvas = document.createElement("canvas");
7280
- this._canvas.width = 4;
7281
- this._canvas.height = this.sampleSize;
7282
- this._texture = new Texture2D(this._canvas);
7283
- this._sizes = new Float32Array(this.slices);
7284
- this._offsets = new Float32Array(this.slices);
7229
+ fillRect(x, y, width, height) {
7230
+ this.rect(x, y, width, height).fill();
7285
7231
  }
7286
- redraw() {
7287
- const size = this.sampleSize;
7288
- const texture = this._texture;
7289
- const ctx = this._canvas.getContext("2d");
7290
- ctx.clearRect(0, 0, 8, size);
7291
- let offset;
7292
- let y = 0;
7293
- for (let i = 0; i < this.slices; i++) {
7294
- offset = Math.floor(this._offsets[i] * 256);
7295
- const height = this._sizes[i] * size;
7296
- const red = offset > 0 ? offset : 0;
7297
- const green = offset < 0 ? -offset : 0;
7298
- ctx.fillStyle = `rgba(${red}, ${green}, 0, 1)`;
7299
- ctx.fillRect(0, y >> 0, size, height + 1 >> 0);
7300
- y += height;
7301
- }
7302
- texture.requestUpload();
7232
+ strokeRect(x, y, width, height) {
7233
+ this.rect(x, y, width, height).stroke();
7303
7234
  }
7304
- apply(renderer, source) {
7305
- if (!this._needsRedraw) {
7306
- this._needsRedraw = true;
7307
- this.redraw();
7308
- }
7309
- const width = source.width;
7310
- const height = source.height;
7311
- const radians = this.direction * (Math.PI / 180);
7312
- const sinDir = Math.sin(radians);
7313
- const cosDir = Math.cos(radians);
7314
- source.redraw(renderer, () => {
7315
- this._texture.activate(renderer, 1);
7316
- QuadUvGeometry.draw(renderer, exports.GlitchEffect.material, {
7317
- sampler: 0,
7318
- filterClamp: [0, 0, 1, 1],
7319
- filterArea: [width, height, 0, 0],
7320
- dimensions: [width, height],
7321
- aspect: height / width,
7322
- displacementMap: 1,
7323
- offset: this.offset,
7324
- sinDir,
7325
- cosDir,
7326
- fillMode: this.fillMode,
7327
- seed: this.seed,
7328
- red: this.red,
7329
- green: this.green,
7330
- blue: this.blue
7331
- });
7235
+ fill() {
7236
+ let texture = this._defaultStyle;
7237
+ if (this.fillStyle) {
7238
+ if (this.fillStyle instanceof Texture2D) {
7239
+ texture = this.fillStyle;
7240
+ } else {
7241
+ texture = new ColorTexture(this.fillStyle);
7242
+ }
7243
+ }
7244
+ this._draws.push({
7245
+ type: "fill",
7246
+ path: new modernPath2d.Path2D(this),
7247
+ texture,
7248
+ textureTransform: this.textureTransform
7332
7249
  });
7250
+ super.reset();
7333
7251
  }
7334
- };
7335
- __publicField$a(exports.GlitchEffect, "material", new Material({
7336
- vert: `precision mediump float;
7337
- attribute vec2 position;
7338
- attribute vec2 uv;
7339
- varying vec2 vUv;
7340
- void main() {
7341
- gl_Position = vec4(position, 0.0, 1.0);
7342
- vUv = uv;
7343
- }`,
7344
- frag: `precision mediump float;
7345
-
7346
- varying vec2 vUv;
7347
- uniform sampler2D sampler;
7348
-
7349
- uniform vec4 filterArea;
7350
- uniform vec4 filterClamp;
7351
- uniform vec2 dimensions;
7352
- uniform float aspect;
7353
-
7354
- uniform sampler2D displacementMap;
7355
- uniform float offset;
7356
- uniform float sinDir;
7357
- uniform float cosDir;
7358
- uniform int fillMode;
7359
-
7360
- uniform float seed;
7361
- uniform vec2 red;
7362
- uniform vec2 green;
7363
- uniform vec2 blue;
7364
-
7365
- const int TRANSPARENT = 0;
7366
- const int ORIGINAL = 1;
7367
- const int LOOP = 2;
7368
- const int CLAMP = 3;
7369
- const int MIRROR = 4;
7370
-
7371
- void main(void) {
7372
- vec2 coord = (vUv * filterArea.xy) / dimensions;
7373
-
7374
- if (coord.x > 1.0 || coord.y > 1.0) {
7375
- return;
7252
+ copy(source) {
7253
+ super.copy(source);
7254
+ this.strokeStyle = source.strokeStyle;
7255
+ this.fillStyle = source.fillStyle;
7256
+ this.textureTransform = source.textureTransform;
7257
+ this.lineCap = source.lineCap;
7258
+ this.lineJoin = source.lineJoin;
7259
+ this.lineWidth = source.lineWidth;
7260
+ this.miterLimit = source.miterLimit;
7261
+ this._draws = source._draws.slice();
7262
+ return this;
7376
7263
  }
7377
-
7378
- float cx = coord.x - 0.5;
7379
- float cy = (coord.y - 0.5) * aspect;
7380
- float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5;
7381
-
7382
- // displacementMap: repeat
7383
- // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny);
7384
-
7385
- // displacementMap: mirror
7386
- ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny);
7387
-
7388
- vec4 dc = texture2D(displacementMap, vec2(0.5, ny));
7389
-
7390
- float displacement = (dc.r - dc.g) * (offset / filterArea.x);
7391
-
7392
- coord = vUv + vec2(cosDir * displacement, sinDir * displacement * aspect);
7393
-
7394
- if (fillMode == CLAMP) {
7395
- coord = clamp(coord, filterClamp.xy, filterClamp.zw);
7396
- } else {
7397
- if (coord.x > filterClamp.z) {
7398
- if (fillMode == TRANSPARENT) {
7399
- discard;
7400
- } else if (fillMode == LOOP) {
7401
- coord.x -= filterClamp.z;
7402
- } else if (fillMode == MIRROR) {
7403
- coord.x = filterClamp.z * 2.0 - coord.x;
7264
+ reset() {
7265
+ super.reset();
7266
+ this.strokeStyle = void 0;
7267
+ this.fillStyle = void 0;
7268
+ this.textureTransform = void 0;
7269
+ this.lineCap = void 0;
7270
+ this.lineJoin = void 0;
7271
+ this.lineWidth = void 0;
7272
+ this.miterLimit = void 0;
7273
+ this._draws.length = 0;
7274
+ return this;
7275
+ }
7276
+ buildUvs(start, vertices, uvs, texture, textureTransform) {
7277
+ if (texture) {
7278
+ const w = texture.width;
7279
+ const h = texture.height;
7280
+ for (let len = vertices.length, i = start; i < len; i += 2) {
7281
+ const x = vertices[i];
7282
+ const y = vertices[i + 1];
7283
+ let uvX;
7284
+ let uvY;
7285
+ if (textureTransform) {
7286
+ [uvX, uvY] = textureTransform?.applyToPoint(x, y);
7287
+ } else {
7288
+ [uvX, uvY] = [x / w, y / h];
7289
+ }
7290
+ uvs.push(uvX, uvY);
7404
7291
  }
7405
- } else if (coord.x < filterClamp.x) {
7406
- if (fillMode == TRANSPARENT) {
7407
- discard;
7408
- } else if (fillMode == LOOP) {
7409
- coord.x += filterClamp.z;
7410
- } else if (fillMode == MIRROR) {
7411
- coord.x *= -filterClamp.z;
7292
+ } else {
7293
+ for (let len = vertices.length, i = start; i < len; i += 2) {
7294
+ uvs.push(0, 0);
7412
7295
  }
7413
7296
  }
7414
-
7415
- if (coord.y > filterClamp.w) {
7416
- if (fillMode == TRANSPARENT) {
7417
- discard;
7418
- } else if (fillMode == LOOP) {
7419
- coord.y -= filterClamp.w;
7420
- } else if (fillMode == MIRROR) {
7421
- coord.y = filterClamp.w * 2.0 - coord.y;
7297
+ }
7298
+ toBatchables() {
7299
+ const batchables = [];
7300
+ let vertices = [];
7301
+ let indices = [];
7302
+ let uvs = [];
7303
+ let texture;
7304
+ const push = (type) => {
7305
+ batchables.push({
7306
+ type,
7307
+ vertices,
7308
+ indices,
7309
+ uvs,
7310
+ texture
7311
+ });
7312
+ vertices = [];
7313
+ indices = [];
7314
+ uvs = [];
7315
+ texture = void 0;
7316
+ };
7317
+ for (let len = this._draws.length, i = 0; i < len; i++) {
7318
+ const draw = this._draws[i];
7319
+ const prev = this._draws[i - 1];
7320
+ if (vertices.length && prev && prev?.type !== draw.type) {
7321
+ push(prev.type);
7422
7322
  }
7423
- } else if (coord.y < filterClamp.y) {
7424
- if (fillMode == TRANSPARENT) {
7425
- discard;
7426
- } else if (fillMode == LOOP) {
7427
- coord.y += filterClamp.w;
7428
- } else if (fillMode == MIRROR) {
7429
- coord.y *= -filterClamp.w;
7323
+ const oldTexture = texture;
7324
+ if (!oldTexture) {
7325
+ texture = draw.texture;
7326
+ }
7327
+ if (vertices.length && oldTexture !== draw.texture && !oldTexture?.is(draw.texture)) {
7328
+ push(draw.type);
7329
+ }
7330
+ const start = vertices.length;
7331
+ if (draw.type === "fill") {
7332
+ draw.path.fillTriangulate({
7333
+ vertices,
7334
+ indices
7335
+ });
7336
+ this.buildUvs(start, vertices, uvs, draw.texture, draw.textureTransform);
7337
+ } else {
7338
+ draw.path.strokeTriangulate({
7339
+ vertices,
7340
+ indices,
7341
+ lineStyle: draw.style,
7342
+ flipAlignment: false,
7343
+ closed: true
7344
+ });
7345
+ this.buildUvs(start, vertices, uvs, draw.texture, draw.textureTransform);
7430
7346
  }
7431
7347
  }
7348
+ const last = this._draws[this._draws.length - 1];
7349
+ if (last && vertices.length) {
7350
+ push(last.type);
7351
+ }
7352
+ return batchables;
7353
+ }
7354
+ }
7355
+
7356
+ var __defProp$s = Object.defineProperty;
7357
+ var __getOwnPropDesc$y = Object.getOwnPropertyDescriptor;
7358
+ var __decorateClass$A = (decorators, target, key, kind) => {
7359
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$y(target, key) : target;
7360
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7361
+ if (decorator = decorators[i])
7362
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7363
+ if (kind && result) __defProp$s(target, key, result);
7364
+ return result;
7365
+ };
7366
+ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
7367
+ _parentGlobalVisible;
7368
+ _globalVisible;
7369
+ get globalVisible() {
7370
+ return this._globalVisible ?? true;
7371
+ }
7372
+ _parentGlobalOpacity;
7373
+ _globalOpacity;
7374
+ get globalOpacity() {
7375
+ return this._globalOpacity ?? 1;
7376
+ }
7377
+ _modulate = new Color(4294967295);
7378
+ _backgroundImage;
7379
+ // Batch render
7380
+ context = new CanvasContext();
7381
+ _resetContext = true;
7382
+ _redrawing = false;
7383
+ _relayouting = false;
7384
+ _repainting = false;
7385
+ _originalBatchables = [];
7386
+ _layoutedBatchables = [];
7387
+ _batchables = [];
7388
+ constructor(properties, nodes = []) {
7389
+ super();
7390
+ this.setProperties(properties).append(nodes);
7391
+ }
7392
+ _updateProperty(key, value, oldValue, declaration) {
7393
+ super._updateProperty(key, value, oldValue, declaration);
7394
+ switch (key) {
7395
+ case "modulate":
7396
+ this._modulate.value = value;
7397
+ this.requestRepaint();
7398
+ break;
7399
+ case "blendMode":
7400
+ this.requestRepaint();
7401
+ break;
7402
+ case "opacity":
7403
+ this._updateGlobalOpacity();
7404
+ break;
7405
+ case "visible":
7406
+ case "insideTimeRange":
7407
+ this._updateGlobalVisible();
7408
+ break;
7409
+ }
7410
+ }
7411
+ show() {
7412
+ this.visible = true;
7413
+ }
7414
+ hide() {
7415
+ this.visible = false;
7416
+ }
7417
+ isVisibleInTree() {
7418
+ return this.globalOpacity > 0 && this.globalVisible;
7419
+ }
7420
+ canRender() {
7421
+ return super.canRender() && this.isVisibleInTree();
7422
+ }
7423
+ requestRedraw() {
7424
+ this._redrawing = true;
7425
+ this.requestUpdate();
7426
+ }
7427
+ requestRelayout() {
7428
+ this._relayouting = true;
7429
+ this.requestUpdate();
7430
+ }
7431
+ requestRepaint() {
7432
+ this._repainting = true;
7433
+ this.requestUpdate();
7434
+ }
7435
+ _updateGlobalVisible() {
7436
+ this._parentGlobalVisible = this.getParent()?.globalVisible;
7437
+ this._globalVisible = (this._parentGlobalVisible ?? true) && this.visible && this.insideTimeRange;
7438
+ }
7439
+ _updateGlobalOpacity() {
7440
+ this._parentGlobalOpacity = this.getParent()?.opacity;
7441
+ const globalOpacity = clamp(0, this.opacity, 1) * (this._parentGlobalOpacity ?? 1);
7442
+ if (this._globalOpacity !== globalOpacity) {
7443
+ this._globalOpacity = globalOpacity;
7444
+ this.requestRepaint();
7445
+ }
7446
+ }
7447
+ _draw() {
7448
+ this.emit("draw");
7449
+ }
7450
+ _redraw() {
7451
+ this._tree?.log(this.name, "redrawing");
7452
+ this._draw();
7453
+ return this.context.toBatchables();
7454
+ }
7455
+ _relayout(batchables) {
7456
+ this._tree?.log(this.name, "relayouting");
7457
+ return batchables;
7458
+ }
7459
+ _repaint(batchables) {
7460
+ this._tree?.log(this.name, "repainting");
7461
+ return batchables.map((batchable) => {
7462
+ return {
7463
+ ...batchable,
7464
+ modulate: this._modulate.toArgb(this.globalOpacity, true),
7465
+ blendMode: this.blendMode
7466
+ };
7467
+ });
7468
+ }
7469
+ _process(delta) {
7470
+ super._process(delta);
7471
+ const parent = this.getParent();
7472
+ if (this._parentGlobalVisible !== parent?.globalVisible) {
7473
+ this.requestUpdate();
7474
+ }
7475
+ if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7476
+ this.requestUpdate();
7477
+ }
7478
+ }
7479
+ _update() {
7480
+ const parent = this.getParent();
7481
+ if (this._parentGlobalVisible !== parent?.globalVisible) {
7482
+ this._updateGlobalVisible();
7483
+ }
7484
+ if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7485
+ this._updateGlobalOpacity();
7486
+ }
7487
+ const redrawing = this._redrawing;
7488
+ let relayouting = this._relayouting;
7489
+ let repainting = this._repainting;
7490
+ let batchables;
7491
+ if (redrawing) {
7492
+ this._originalBatchables = this._redraw();
7493
+ relayouting = true;
7494
+ }
7495
+ if (relayouting) {
7496
+ this._layoutedBatchables = this._relayout(this._originalBatchables);
7497
+ repainting = true;
7498
+ }
7499
+ if (repainting) {
7500
+ batchables = this._repaint(this._layoutedBatchables);
7501
+ }
7502
+ if (redrawing) {
7503
+ if (this._resetContext) {
7504
+ this.context.reset();
7505
+ }
7506
+ }
7507
+ if (batchables) {
7508
+ this._batchables = batchables;
7509
+ this._redrawing = false;
7510
+ this._relayouting = false;
7511
+ this._repainting = false;
7512
+ }
7513
+ }
7514
+ _render(renderer) {
7515
+ this._batchables.forEach((batchable) => {
7516
+ batchable.texture?.upload(renderer);
7517
+ renderer.batch2D.render({
7518
+ ...batchable,
7519
+ texture: batchable.texture?._glTexture(renderer)
7520
+ });
7521
+ });
7522
+ super._render(renderer);
7523
+ }
7524
+ };
7525
+ __decorateClass$A([
7526
+ property()
7527
+ ], exports.CanvasItem.prototype, "modulate", 2);
7528
+ __decorateClass$A([
7529
+ property()
7530
+ ], exports.CanvasItem.prototype, "blendMode", 2);
7531
+ __decorateClass$A([
7532
+ protectedProperty({ default: true })
7533
+ ], exports.CanvasItem.prototype, "visible", 2);
7534
+ __decorateClass$A([
7535
+ protectedProperty({ default: 1 })
7536
+ ], exports.CanvasItem.prototype, "opacity", 2);
7537
+ exports.CanvasItem = __decorateClass$A([
7538
+ customNode("CanvasItem")
7539
+ ], exports.CanvasItem);
7540
+
7541
+ class RenderStack {
7542
+ currentCall;
7543
+ calls = [];
7544
+ createCall(renderable) {
7545
+ return {
7546
+ renderable,
7547
+ parentCall: this.currentCall,
7548
+ fn: renderable.render.bind(renderable),
7549
+ calls: []
7550
+ };
7551
+ }
7552
+ push(renderable) {
7553
+ const call = this.createCall(renderable);
7554
+ (this.currentCall?.calls ?? this.calls).push(call);
7555
+ return call;
7556
+ }
7557
+ render(renderer) {
7558
+ this.calls.forEach(function render(call) {
7559
+ call.fn(renderer, () => {
7560
+ call.calls.forEach(render);
7561
+ });
7562
+ });
7563
+ this.calls = [];
7564
+ }
7565
+ }
7566
+
7567
+ var __defProp$r = Object.defineProperty;
7568
+ var __getOwnPropDesc$x = Object.getOwnPropertyDescriptor;
7569
+ var __decorateClass$z = (decorators, target, key, kind) => {
7570
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$x(target, key) : target;
7571
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7572
+ if (decorator = decorators[i])
7573
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7574
+ if (kind && result) __defProp$r(target, key, result);
7575
+ return result;
7576
+ };
7577
+ exports.Timeline = class Timeline extends exports.Node {
7578
+ static from(range, loop = false) {
7579
+ const [startTime, endTime] = range ? Array.isArray(range) ? range : [0, range] : [];
7580
+ return new exports.Timeline({
7581
+ startTime,
7582
+ endTime,
7583
+ loop
7584
+ });
7585
+ }
7586
+ constructor(properties) {
7587
+ super();
7588
+ this.setProperties(properties);
7589
+ }
7590
+ _updateProperty(key, value, oldValue) {
7591
+ super._updateProperty(key, value, oldValue);
7592
+ switch (key) {
7593
+ case "startTime":
7594
+ this.startTime = Math.min(value, this.endTime);
7595
+ break;
7596
+ case "endTime":
7597
+ this.endTime = value || Number.MAX_SAFE_INTEGER;
7598
+ break;
7599
+ }
7600
+ }
7601
+ addTime(delta) {
7602
+ const start = this.startTime;
7603
+ const end = this.endTime;
7604
+ let current = this.currentTime;
7605
+ current = current + delta;
7606
+ if (this.loop && current > end) {
7607
+ current = start + current % end;
7608
+ }
7609
+ current = clamp(start, current, end);
7610
+ this.currentTime = current;
7611
+ this.emit("updateCurrentTime", current, delta);
7612
+ return this;
7613
+ }
7614
+ _process(delta) {
7615
+ super._process(delta);
7616
+ this.addTime(delta);
7617
+ }
7618
+ };
7619
+ __decorateClass$z([
7620
+ property({ default: 0 })
7621
+ ], exports.Timeline.prototype, "startTime", 2);
7622
+ __decorateClass$z([
7623
+ property({ default: 0 })
7624
+ ], exports.Timeline.prototype, "currentTime", 2);
7625
+ __decorateClass$z([
7626
+ property({ default: Number.MAX_SAFE_INTEGER })
7627
+ ], exports.Timeline.prototype, "endTime", 2);
7628
+ __decorateClass$z([
7629
+ property({ default: false })
7630
+ ], exports.Timeline.prototype, "loop", 2);
7631
+ exports.Timeline = __decorateClass$z([
7632
+ customNode("Timeline")
7633
+ ], exports.Timeline);
7634
+
7635
+ var __defProp$q = Object.defineProperty;
7636
+ var __decorateClass$y = (decorators, target, key, kind) => {
7637
+ var result = void 0 ;
7638
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7639
+ if (decorator = decorators[i])
7640
+ result = (decorator(target, key, result) ) || result;
7641
+ if (result) __defProp$q(target, key, result);
7642
+ return result;
7643
+ };
7644
+ class SceneTree extends MainLoop {
7645
+ input = new Input();
7646
+ renderStack = new RenderStack();
7647
+ root = new exports.Viewport(true).setTree(this);
7648
+ timeline;
7649
+ _backgroundColor = new Color();
7650
+ _currentViewport;
7651
+ getCurrentViewport() {
7652
+ return this._currentViewport;
7653
+ }
7654
+ setCurrentViewport(viewport) {
7655
+ this._currentViewport = viewport;
7656
+ }
7657
+ constructor(timeline = new exports.Timeline()) {
7658
+ super();
7659
+ this.timeline = timeline.setTree(this);
7660
+ }
7661
+ _updateProperty(key, value, oldValue, declaration) {
7662
+ super._updateProperty(key, value, oldValue, declaration);
7663
+ switch (key) {
7664
+ case "backgroundColor":
7665
+ this._backgroundColor.value = value;
7666
+ break;
7667
+ }
7668
+ }
7669
+ log(...args) {
7670
+ if (this.debug) {
7671
+ console.log(`[modern-canvas]`, ...args);
7672
+ }
7673
+ }
7674
+ _process(delta = 0) {
7675
+ this.timeline.emit("process", delta);
7676
+ this.emit("processing");
7677
+ this.root.emit("process", delta);
7678
+ this.emit("processed");
7679
+ }
7680
+ _render(renderer) {
7681
+ this.emit("rendering");
7682
+ renderer.program.uniforms.projectionMatrix = this.root.toProjectionArray(true);
7683
+ this.renderStack.render(renderer);
7684
+ this._renderScreen(renderer);
7685
+ this.emit("rendered");
7686
+ }
7687
+ _renderScreen(renderer) {
7688
+ renderer.state.reset();
7689
+ renderer.framebuffer.bind(null);
7690
+ renderer.viewport.bind({
7691
+ x: 0,
7692
+ y: 0,
7693
+ width: this.root.width * renderer.pixelRatio,
7694
+ height: this.root.height * renderer.pixelRatio
7695
+ });
7696
+ if (this.backgroundColor) {
7697
+ renderer.gl.clearColor(...this._backgroundColor.toArray());
7698
+ }
7699
+ renderer.clear();
7700
+ if (this.backgroundColor) {
7701
+ renderer.gl.clearColor(0, 0, 0, 0);
7702
+ }
7703
+ const texture = this.root.texture;
7704
+ texture.activate(renderer, 0);
7705
+ QuadUvGeometry.draw(renderer);
7706
+ renderer.texture.unbind(texture);
7432
7707
  }
7433
-
7434
- gl_FragColor.r = texture2D(sampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r;
7435
- gl_FragColor.g = texture2D(sampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;
7436
- gl_FragColor.b = texture2D(sampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;
7437
- gl_FragColor.a = texture2D(sampler, coord).a;
7438
- }`
7439
- }));
7440
- __decorateClass$x([
7441
- property()
7442
- ], exports.GlitchEffect.prototype, "slices", 2);
7443
- __decorateClass$x([
7444
- property()
7445
- ], exports.GlitchEffect.prototype, "sampleSize", 2);
7446
- __decorateClass$x([
7447
- property()
7448
- ], exports.GlitchEffect.prototype, "offset", 2);
7449
- __decorateClass$x([
7450
- property()
7451
- ], exports.GlitchEffect.prototype, "direction", 2);
7452
- __decorateClass$x([
7453
- property()
7454
- ], exports.GlitchEffect.prototype, "fillMode", 2);
7455
- __decorateClass$x([
7456
- property()
7457
- ], exports.GlitchEffect.prototype, "seed", 2);
7458
- __decorateClass$x([
7459
- property()
7460
- ], exports.GlitchEffect.prototype, "red", 2);
7461
- __decorateClass$x([
7462
- property()
7463
- ], exports.GlitchEffect.prototype, "green", 2);
7464
- __decorateClass$x([
7708
+ free() {
7709
+ super.free();
7710
+ this.root.getChildren(true).forEach((node) => this.root.removeChild(node));
7711
+ this.input.removeEventListeners();
7712
+ }
7713
+ }
7714
+ __decorateClass$y([
7715
+ property({ default: false })
7716
+ ], SceneTree.prototype, "processPaused");
7717
+ __decorateClass$y([
7465
7718
  property()
7466
- ], exports.GlitchEffect.prototype, "blue", 2);
7467
- exports.GlitchEffect = __decorateClass$x([
7468
- customNode("GlitchEffect")
7469
- ], exports.GlitchEffect);
7719
+ ], SceneTree.prototype, "backgroundColor");
7720
+ __decorateClass$y([
7721
+ protectedProperty({ default: false })
7722
+ ], SceneTree.prototype, "debug");
7470
7723
 
7471
- var __defProp$o = Object.defineProperty;
7472
- var __getOwnPropDesc$u = Object.getOwnPropertyDescriptor;
7473
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7474
- var __decorateClass$w = (decorators, target, key, kind) => {
7475
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$u(target, key) : target;
7724
+ var __getOwnPropDesc$w = Object.getOwnPropertyDescriptor;
7725
+ var __decorateClass$x = (decorators, target, key, kind) => {
7726
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$w(target, key) : target;
7476
7727
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7477
7728
  if (decorator = decorators[i])
7478
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7479
- if (kind && result) __defProp$o(target, key, result);
7729
+ result = (decorator(result)) || result;
7480
7730
  return result;
7481
7731
  };
7482
- var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, key + "" , value);
7483
- exports.GodrayEffect = class GodrayEffect extends exports.Effect {
7484
- angle = 30;
7485
- gain = 0.5;
7486
- lacunarity = 2.5;
7487
- parallel = true;
7488
- center = [0, 0];
7489
- alpha = 1;
7490
- apply(renderer, source) {
7491
- const radians = this.angle * (Math.PI / 180);
7492
- const light = this.parallel ? [Math.cos(radians), Math.sin(radians)] : this.center;
7493
- source.redraw(renderer, () => {
7494
- QuadUvGeometry.draw(renderer, exports.GodrayEffect.material, {
7495
- sampler: 0,
7496
- inputSize: [source.width, source.height, 0, 0],
7497
- gain: this.gain,
7498
- lacunarity: this.lacunarity,
7499
- parallel: this.parallel,
7500
- alpha: this.alpha,
7501
- light,
7502
- aspect: source.height / source.width
7503
- });
7504
- });
7732
+ exports.Transition = class Transition extends exports.Effect {
7733
+ constructor(properties, children = []) {
7734
+ super();
7735
+ this.setProperties(properties).append(children);
7505
7736
  }
7506
7737
  };
7507
- __publicField$9(exports.GodrayEffect, "material", new Material({
7508
- vert: `precision mediump float;
7509
- attribute vec2 position;
7510
- attribute vec2 uv;
7511
- varying vec2 vUv;
7512
- void main() {
7513
- gl_Position = vec4(position, 0.0, 1.0);
7514
- vUv = uv;
7515
- }`,
7516
- frag: `varying vec2 vUv;
7517
- uniform sampler2D sampler;
7518
- uniform vec4 inputSize;
7519
- uniform vec2 light;
7520
- uniform bool parallel;
7521
- uniform float aspect;
7522
- uniform float gain;
7523
- uniform float lacunarity;
7524
- uniform float uTime;
7525
- uniform float alpha;
7526
-
7527
- vec3 mod289(vec3 x) {
7528
- return x - floor(x * (1.0 / 289.0)) * 289.0;
7529
- }
7530
-
7531
- vec4 mod289(vec4 x) {
7532
- return x - floor(x * (1.0 / 289.0)) * 289.0;
7533
- }
7534
-
7535
- vec4 permute(vec4 x) {
7536
- return mod289(((x * 34.0) + 1.0) * x);
7537
- }
7538
-
7539
- vec4 taylorInvSqrt(vec4 r) {
7540
- return 1.79284291400159 - 0.85373472095314 * r;
7541
- }
7542
-
7543
- vec3 fade(vec3 t) {
7544
- return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
7545
- }
7546
-
7547
- float pnoise(vec3 P, vec3 rep) {
7548
- vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
7549
- vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period
7550
- Pi0 = mod289(Pi0);
7551
- Pi1 = mod289(Pi1);
7552
- vec3 Pf0 = fract(P); // Fractional part for interpolation
7553
- vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
7554
- vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
7555
- vec4 iy = vec4(Pi0.yy, Pi1.yy);
7556
- vec4 iz0 = Pi0.zzzz;
7557
- vec4 iz1 = Pi1.zzzz;
7558
- vec4 ixy = permute(permute(ix) + iy);
7559
- vec4 ixy0 = permute(ixy + iz0);
7560
- vec4 ixy1 = permute(ixy + iz1);
7561
- vec4 gx0 = ixy0 * (1.0 / 7.0);
7562
- vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
7563
- gx0 = fract(gx0);
7564
- vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
7565
- vec4 sz0 = step(gz0, vec4(0.0));
7566
- gx0 -= sz0 * (step(0.0, gx0) - 0.5);
7567
- gy0 -= sz0 * (step(0.0, gy0) - 0.5);
7568
- vec4 gx1 = ixy1 * (1.0 / 7.0);
7569
- vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
7570
- gx1 = fract(gx1);
7571
- vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
7572
- vec4 sz1 = step(gz1, vec4(0.0));
7573
- gx1 -= sz1 * (step(0.0, gx1) - 0.5);
7574
- gy1 -= sz1 * (step(0.0, gy1) - 0.5);
7575
- vec3 g000 = vec3(gx0.x, gy0.x, gz0.x);
7576
- vec3 g100 = vec3(gx0.y, gy0.y, gz0.y);
7577
- vec3 g010 = vec3(gx0.z, gy0.z, gz0.z);
7578
- vec3 g110 = vec3(gx0.w, gy0.w, gz0.w);
7579
- vec3 g001 = vec3(gx1.x, gy1.x, gz1.x);
7580
- vec3 g101 = vec3(gx1.y, gy1.y, gz1.y);
7581
- vec3 g011 = vec3(gx1.z, gy1.z, gz1.z);
7582
- vec3 g111 = vec3(gx1.w, gy1.w, gz1.w);
7583
- vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
7584
- g000 *= norm0.x;
7585
- g010 *= norm0.y;
7586
- g100 *= norm0.z;
7587
- g110 *= norm0.w;
7588
- vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
7589
- g001 *= norm1.x;
7590
- g011 *= norm1.y;
7591
- g101 *= norm1.z;
7592
- g111 *= norm1.w;
7593
- float n000 = dot(g000, Pf0);
7594
- float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
7595
- float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
7596
- float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
7597
- float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
7598
- float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
7599
- float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
7600
- float n111 = dot(g111, Pf1);
7601
- vec3 fade_xyz = fade(Pf0);
7602
- vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
7603
- vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
7604
- float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
7605
- return 2.2 * n_xyz;
7606
- }
7607
- float turb(vec3 P, vec3 rep, float lacunarity, float gain) {
7608
- float sum = 0.0;
7609
- float sc = 1.0;
7610
- float totalgain = 1.0;
7611
- for (float i = 0.0; i < 6.0; i++)
7612
- {
7613
- sum += totalgain * pnoise(P * sc, rep);
7614
- sc *= lacunarity;
7615
- totalgain *= gain;
7616
- }
7617
- return abs(sum);
7618
- }
7619
-
7620
- void main(void) {
7621
- vec4 color = texture2D(sampler, vUv);
7622
- vec2 coord = vUv;
7623
- float d;
7624
- if (parallel) {
7625
- d = (light.x * coord.x) + (light.y * coord.y * aspect);
7626
- } else {
7627
- float dx = coord.x - light.x / inputSize.x;
7628
- float dy = (coord.y - light.y / inputSize.y) * aspect;
7629
- float dis = sqrt(dx * dx + dy * dy) + 0.00001;
7630
- d = dy / dis;
7631
- }
7632
- vec3 dir = vec3(d, d, 0.0);
7633
- float noise = turb(dir + vec3(uTime, 0.0, 62.1 + uTime) * 0.05, vec3(480.0, 320.0, 480.0), lacunarity, gain);
7634
- noise = mix(noise, 0.0, 0.3);
7635
- vec4 mist = vec4(noise, noise, noise, 1.0) * (1.0 - coord.y);
7636
- mist.a = 1.0;
7637
- mist *= alpha;
7638
- gl_FragColor = vec4(color.rgb + mist.rgb, color.a);
7639
- }`
7640
- }));
7641
- __decorateClass$w([
7642
- property()
7643
- ], exports.GodrayEffect.prototype, "angle", 2);
7644
- __decorateClass$w([
7645
- property()
7646
- ], exports.GodrayEffect.prototype, "gain", 2);
7647
- __decorateClass$w([
7648
- property()
7649
- ], exports.GodrayEffect.prototype, "lacunarity", 2);
7650
- __decorateClass$w([
7651
- property()
7652
- ], exports.GodrayEffect.prototype, "parallel", 2);
7653
- __decorateClass$w([
7654
- property()
7655
- ], exports.GodrayEffect.prototype, "center", 2);
7656
- __decorateClass$w([
7657
- property()
7658
- ], exports.GodrayEffect.prototype, "alpha", 2);
7659
- exports.GodrayEffect = __decorateClass$w([
7660
- customNode("GodrayEffect")
7661
- ], exports.GodrayEffect);
7738
+ exports.Transition = __decorateClass$x([
7739
+ customNode("Transition", {
7740
+ effectMode: "transition",
7741
+ processMode: "pausable",
7742
+ duration: 2e3
7743
+ })
7744
+ ], exports.Transition);
7662
7745
 
7663
- var __defProp$n = Object.defineProperty;
7664
- var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
7665
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7666
- var __decorateClass$v = (decorators, target, key, kind) => {
7667
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
7746
+ var __defProp$p = Object.defineProperty;
7747
+ var __getOwnPropDesc$v = Object.getOwnPropertyDescriptor;
7748
+ var __decorateClass$w = (decorators, target, key, kind) => {
7749
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$v(target, key) : target;
7668
7750
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7669
7751
  if (decorator = decorators[i])
7670
7752
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7671
- if (kind && result) __defProp$n(target, key, result);
7753
+ if (kind && result) __defProp$p(target, key, result);
7672
7754
  return result;
7673
7755
  };
7674
- var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
7675
- exports.MaskEffect = class MaskEffect extends exports.Effect {
7676
- texture;
7756
+ const frag$1 = `varying vec2 vUv;
7757
+ uniform sampler2D sampler;
7758
+ uniform vec2 uOffset;
7759
+
7760
+ void main(void) {
7761
+ vec4 color = vec4(0.0);
7762
+ color += texture2D(sampler, vec2(vUv.x - uOffset.x, vUv.y + uOffset.y));
7763
+ color += texture2D(sampler, vec2(vUv.x + uOffset.x, vUv.y + uOffset.y));
7764
+ color += texture2D(sampler, vec2(vUv.x + uOffset.x, vUv.y - uOffset.y));
7765
+ color += texture2D(sampler, vec2(vUv.x - uOffset.x, vUv.y - uOffset.y));
7766
+ color *= 0.25;
7767
+ gl_FragColor = color;
7768
+ }`;
7769
+ const clampFrag = `precision highp float;
7770
+ varying vec2 vUv;
7771
+ uniform sampler2D sampler;
7772
+ uniform vec2 uOffset;
7773
+ uniform vec4 uInputClamp;
7774
+ void main(void) {
7775
+ vec4 color = vec4(0.0);
7776
+ color += texture2D(sampler, clamp(vec2(vUv.x - uOffset.x, vUv.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));
7777
+ color += texture2D(sampler, clamp(vec2(vUv.x + uOffset.x, vUv.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));
7778
+ color += texture2D(sampler, clamp(vec2(vUv.x + uOffset.x, vUv.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));
7779
+ color += texture2D(sampler, clamp(vec2(vUv.x - uOffset.x, vUv.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));
7780
+ color *= 0.25;
7781
+ gl_FragColor = color;
7782
+ }`;
7783
+ exports.KawaseBlurEffect = class KawaseBlurEffect extends exports.Effect {
7784
+ material;
7785
+ _kernels = [0];
7677
7786
  constructor(properties, children = []) {
7678
7787
  super();
7788
+ this.material = new Material({
7789
+ vert: `precision mediump float;
7790
+ attribute vec2 position;
7791
+ attribute vec2 uv;
7792
+ varying vec2 vUv;
7793
+ void main() {
7794
+ gl_Position = vec4(position, 0.0, 1.0);
7795
+ vUv = uv;
7796
+ }`,
7797
+ frag: properties?.clamp ? clampFrag : frag$1
7798
+ });
7679
7799
  this.setProperties(properties).append(children);
7680
- }
7681
- async load() {
7682
- this.texture = void 0;
7683
- if (this.src) {
7684
- this.texture = await assets.texture.load(this.src);
7685
- }
7800
+ this._generateKernels();
7686
7801
  }
7687
7802
  _updateProperty(key, value, oldValue, declaration) {
7688
7803
  super._updateProperty(key, value, oldValue, declaration);
7689
7804
  switch (key) {
7690
- case "src":
7691
- this.load();
7692
- break;
7693
- case "texture":
7694
- oldValue?.free?.();
7805
+ case "quality":
7806
+ case "strength":
7807
+ this._generateKernels();
7695
7808
  break;
7696
7809
  }
7697
7810
  }
7698
- apply(renderer, source, context) {
7699
- if (this.texture && context.targetArea) {
7811
+ /** Auto generate kernels by blur & quality */
7812
+ _generateKernels() {
7813
+ const blur = Math.max(1, Math.round(this.strength));
7814
+ const quality = Math.max(1, Math.round(this.quality));
7815
+ const kernels = [blur];
7816
+ if (blur > 0) {
7817
+ let k = blur;
7818
+ const step = blur / quality;
7819
+ for (let i = 1; i < quality; i++) {
7820
+ k -= step;
7821
+ kernels.push(k);
7822
+ }
7823
+ }
7824
+ this._kernels = kernels;
7825
+ }
7826
+ apply(renderer, source) {
7827
+ const uvX = this.pixelSize[0] / source.width;
7828
+ const uvY = this.pixelSize[1] / source.height;
7829
+ let offset;
7830
+ if (this.quality === 1 || this.strength === 0) {
7831
+ offset = this._kernels[0] + 0.5;
7700
7832
  source.redraw(renderer, () => {
7701
- this.texture.activate(renderer, 1);
7702
- QuadUvGeometry.draw(renderer, exports.MaskEffect.material, {
7833
+ QuadUvGeometry.draw(renderer, this.material, {
7703
7834
  sampler: 0,
7704
- mask: 1,
7705
- area: context.targetArea,
7706
- rotation: context.target?.globalRotation ?? 0
7835
+ uOffset: [
7836
+ offset * uvX,
7837
+ offset * uvY
7838
+ ],
7839
+ uInputClamp: [0, 0, 1, 1]
7707
7840
  });
7708
- renderer.texture.unbind(1);
7841
+ });
7842
+ } else {
7843
+ const last = this.quality - 1;
7844
+ for (let i = 0; i < last; i++) {
7845
+ offset = this._kernels[i] + 0.5;
7846
+ source.redraw(renderer, () => {
7847
+ QuadUvGeometry.draw(renderer, this.material, {
7848
+ sampler: 0,
7849
+ uOffset: [
7850
+ offset * uvX,
7851
+ offset * uvY
7852
+ ],
7853
+ uInputClamp: [0, 0, 1, 1]
7854
+ });
7855
+ });
7856
+ }
7857
+ offset = this._kernels[last] + 0.5;
7858
+ QuadUvGeometry.draw(renderer, this.material, {
7859
+ sampler: 0,
7860
+ uOffset: [
7861
+ offset * uvX,
7862
+ offset * uvY
7863
+ ],
7864
+ uInputClamp: [0, 0, 1, 1]
7709
7865
  });
7710
7866
  }
7711
7867
  }
7712
7868
  };
7713
- __publicField$8(exports.MaskEffect, "material", new Material({
7714
- vert: `precision mediump float;
7715
- attribute vec2 position;
7716
- attribute vec2 uv;
7717
- varying vec2 vUv;
7718
- void main() {
7719
- gl_Position = vec4(position, 0.0, 1.0);
7720
- vUv = uv;
7721
- }`,
7722
- frag: `varying vec2 vUv;
7723
- uniform sampler2D sampler;
7724
- uniform sampler2D mask;
7725
- uniform float area[4];
7726
- uniform float rotation;
7727
-
7728
- vec2 rotateUV(vec2 uv, float angle) {
7729
- uv -= 0.5;
7730
- float cosAngle = cos(angle);
7731
- float sinAngle = sin(angle);
7732
- mat2 rotationMatrix = mat2(
7733
- cosAngle, -sinAngle,
7734
- sinAngle, cosAngle
7735
- );
7736
- uv = rotationMatrix * uv;
7737
- uv += 0.5;
7738
- return uv;
7739
- }
7740
-
7741
- void main(void) {
7742
- if (
7743
- vUv.x > area[0]
7744
- && vUv.x < (area[0] + area[2])
7745
- && (1.0 - vUv.y) > area[1]
7746
- && (1.0 - vUv.y) < (area[1] + area[3])
7747
- ) {
7748
- vec4 color = texture2D(sampler, vUv);
7749
- vec2 uv = vec2(
7750
- (vUv.x - area[0]) / area[2],
7751
- ((1.0 - vUv.y) - area[1]) / area[3]
7752
- );
7753
- vec4 maskColor = texture2D(mask, rotateUV(uv, rotation));
7754
- gl_FragColor = mix(vec4(0.), color, maskColor.a);
7755
- } else {
7756
- gl_FragColor = vec4(0.);
7757
- }
7758
- }`
7759
- }));
7760
- __decorateClass$v([
7761
- protectedProperty()
7762
- ], exports.MaskEffect.prototype, "texture", 2);
7763
- __decorateClass$v([
7764
- property({ default: "" })
7765
- ], exports.MaskEffect.prototype, "src", 2);
7766
- exports.MaskEffect = __decorateClass$v([
7767
- customNode("MaskEffect")
7768
- ], exports.MaskEffect);
7869
+ __decorateClass$w([
7870
+ property({ default: 4 })
7871
+ ], exports.KawaseBlurEffect.prototype, "strength", 2);
7872
+ __decorateClass$w([
7873
+ property({ default: 3 })
7874
+ ], exports.KawaseBlurEffect.prototype, "quality", 2);
7875
+ __decorateClass$w([
7876
+ property({ default: [1, 1] })
7877
+ ], exports.KawaseBlurEffect.prototype, "pixelSize", 2);
7878
+ exports.KawaseBlurEffect = __decorateClass$w([
7879
+ customNode("KawaseBlurEffect")
7880
+ ], exports.KawaseBlurEffect);
7769
7881
 
7770
- var __defProp$m = Object.defineProperty;
7771
- var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
7772
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7773
- var __decorateClass$u = (decorators, target, key, kind) => {
7774
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
7882
+ var __defProp$o = Object.defineProperty;
7883
+ var __getOwnPropDesc$u = Object.getOwnPropertyDescriptor;
7884
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7885
+ var __decorateClass$v = (decorators, target, key, kind) => {
7886
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$u(target, key) : target;
7775
7887
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7776
7888
  if (decorator = decorators[i])
7777
7889
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7778
- if (kind && result) __defProp$m(target, key, result);
7890
+ if (kind && result) __defProp$o(target, key, result);
7779
7891
  return result;
7780
7892
  };
7781
- var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
7782
- exports.PixelateEffect = class PixelateEffect extends exports.Effect {
7783
- size;
7784
- constructor(size = 10) {
7893
+ var __publicField$c = (obj, key, value) => __defNormalProp$c(obj, key + "" , value);
7894
+ exports.DropShadowEffect = class DropShadowEffect extends exports.Effect {
7895
+ kawaseBlurEffect = new exports.KawaseBlurEffect();
7896
+ viewport3 = new exports.Viewport();
7897
+ _color = new Color();
7898
+ constructor(properties, children = []) {
7785
7899
  super();
7786
- this.size = size;
7900
+ this.setProperties(properties).append(children);
7787
7901
  }
7788
7902
  apply(renderer, source) {
7789
- source.redraw(renderer, () => {
7790
- QuadUvGeometry.draw(renderer, exports.PixelateEffect.material, {
7903
+ this.viewport3.activateWithCopy(renderer, source);
7904
+ this.viewport3.redraw(renderer, () => {
7905
+ this._color.value = this.color;
7906
+ QuadUvGeometry.draw(renderer, exports.DropShadowEffect.material, {
7791
7907
  sampler: 0,
7792
- size: [this.size, this.size],
7793
- filterArea: [source.width, source.height, 0, 0]
7908
+ uAlpha: this.alpha,
7909
+ uColor: this._color.toArray().slice(0, 3),
7910
+ uOffset: [-this.offset[0], this.offset[1]],
7911
+ uInputSize: [source.width, source.height, 1 / source.width, 1 / source.height]
7912
+ });
7913
+ });
7914
+ this.kawaseBlurEffect.strength = this.blur;
7915
+ this.kawaseBlurEffect.quality = this.quality;
7916
+ this.kawaseBlurEffect.pixelSize = this.pixelSize;
7917
+ this.kawaseBlurEffect.apply(renderer, this.viewport3);
7918
+ source.redraw(renderer, () => {
7919
+ this.viewport3.texture.activate(renderer, 1);
7920
+ QuadUvGeometry.draw(renderer, UvMaterial.instance, {
7921
+ sampler: 1
7794
7922
  });
7923
+ if (!this.shadowOnly) {
7924
+ QuadUvGeometry.draw(renderer, UvMaterial.instance, {
7925
+ sampler: 0
7926
+ });
7927
+ }
7928
+ renderer.texture.unbind(1);
7795
7929
  });
7796
7930
  }
7797
7931
  };
7798
- __publicField$7(exports.PixelateEffect, "material", new Material({
7932
+ __publicField$c(exports.DropShadowEffect, "material", new Material({
7799
7933
  vert: `precision mediump float;
7800
7934
  attribute vec2 position;
7801
7935
  attribute vec2 uv;
@@ -7804,593 +7938,751 @@ void main() {
7804
7938
  gl_Position = vec4(position, 0.0, 1.0);
7805
7939
  vUv = uv;
7806
7940
  }`,
7807
- frag: `varying vec2 vUv;
7808
- uniform vec2 size;
7941
+ frag: `precision highp float;
7942
+ varying vec2 vUv;
7809
7943
  uniform sampler2D sampler;
7810
- uniform vec4 filterArea;
7811
-
7812
- vec2 mapCoord(vec2 coord) {
7813
- coord *= filterArea.xy;
7814
- coord += filterArea.zw;
7815
- return coord;
7816
- }
7817
-
7818
- vec2 unmapCoord(vec2 coord) {
7819
- coord -= filterArea.zw;
7820
- coord /= filterArea.xy;
7821
- return coord;
7822
- }
7823
-
7824
- vec2 pixelate(vec2 coord, vec2 size) {
7825
- return floor(coord / size) * size;
7826
- }
7944
+ uniform float uAlpha;
7945
+ uniform vec3 uColor;
7946
+ uniform vec2 uOffset;
7947
+ uniform vec4 uInputSize;
7827
7948
 
7828
7949
  void main(void) {
7829
- vec2 coord = mapCoord(vUv);
7830
- coord = pixelate(coord, size);
7831
- coord = unmapCoord(coord);
7832
- gl_FragColor = texture2D(sampler, coord);
7950
+ vec4 sample = texture2D(sampler, vUv + uOffset * uInputSize.zw);
7951
+ sample.rgb = uColor.rgb * sample.a;
7952
+ sample *= uAlpha;
7953
+ gl_FragColor = sample;
7833
7954
  }`
7834
7955
  }));
7835
- __decorateClass$u([
7836
- property()
7837
- ], exports.PixelateEffect.prototype, "size", 2);
7838
- exports.PixelateEffect = __decorateClass$u([
7839
- customNode("PixelateEffect")
7840
- ], exports.PixelateEffect);
7956
+ __decorateClass$v([
7957
+ property({ default: [4, 4] })
7958
+ ], exports.DropShadowEffect.prototype, "offset", 2);
7959
+ __decorateClass$v([
7960
+ property({ default: 0 })
7961
+ ], exports.DropShadowEffect.prototype, "color", 2);
7962
+ __decorateClass$v([
7963
+ property({ default: 1 })
7964
+ ], exports.DropShadowEffect.prototype, "alpha", 2);
7965
+ __decorateClass$v([
7966
+ property({ default: false })
7967
+ ], exports.DropShadowEffect.prototype, "shadowOnly", 2);
7968
+ __decorateClass$v([
7969
+ property({ default: 2 })
7970
+ ], exports.DropShadowEffect.prototype, "blur", 2);
7971
+ __decorateClass$v([
7972
+ property({ default: 4 })
7973
+ ], exports.DropShadowEffect.prototype, "quality", 2);
7974
+ __decorateClass$v([
7975
+ property({ default: [1, 1] })
7976
+ ], exports.DropShadowEffect.prototype, "pixelSize", 2);
7977
+ exports.DropShadowEffect = __decorateClass$v([
7978
+ customNode("DropShadowEffect")
7979
+ ], exports.DropShadowEffect);
7841
7980
 
7842
- class CanvasContext extends modernPath2d.Path2D {
7843
- textureTransform;
7844
- fillStyle;
7845
- strokeStyle;
7846
- lineCap;
7847
- lineJoin;
7848
- lineWidth;
7849
- miterLimit;
7850
- _defaultStyle = Texture2D.EMPTY;
7851
- _draws = [];
7852
- stroke() {
7853
- let texture = this._defaultStyle;
7854
- if (this.strokeStyle) {
7855
- if (this.strokeStyle instanceof Texture2D) {
7856
- texture = this.strokeStyle;
7857
- } else {
7858
- texture = new ColorTexture(this.strokeStyle);
7859
- }
7860
- }
7861
- if (this.curves.length) {
7862
- this._draws.push({
7863
- type: "stroke",
7864
- path: new modernPath2d.Path2D(this),
7865
- texture,
7866
- textureTransform: this.textureTransform,
7867
- style: {
7868
- alignment: 0.5,
7869
- cap: this.lineCap ?? "butt",
7870
- join: this.lineJoin ?? "miter",
7871
- width: this.lineWidth ?? 1,
7872
- miterLimit: this.miterLimit ?? 10
7873
- }
7874
- });
7875
- super.reset();
7876
- }
7877
- }
7878
- fillRect(x, y, width, height) {
7879
- this.rect(x, y, width, height).fill();
7880
- }
7881
- strokeRect(x, y, width, height) {
7882
- this.rect(x, y, width, height).stroke();
7883
- }
7884
- fill() {
7885
- let texture = this._defaultStyle;
7886
- if (this.fillStyle) {
7887
- if (this.fillStyle instanceof Texture2D) {
7888
- texture = this.fillStyle;
7889
- } else {
7890
- texture = new ColorTexture(this.fillStyle);
7891
- }
7892
- }
7893
- this._draws.push({
7894
- type: "fill",
7895
- path: new modernPath2d.Path2D(this),
7896
- texture,
7897
- textureTransform: this.textureTransform
7898
- });
7899
- super.reset();
7900
- }
7901
- copy(source) {
7902
- super.copy(source);
7903
- this.strokeStyle = source.strokeStyle;
7904
- this.fillStyle = source.fillStyle;
7905
- this.textureTransform = source.textureTransform;
7906
- this.lineCap = source.lineCap;
7907
- this.lineJoin = source.lineJoin;
7908
- this.lineWidth = source.lineWidth;
7909
- this.miterLimit = source.miterLimit;
7910
- this._draws = source._draws.slice();
7911
- return this;
7912
- }
7913
- reset() {
7914
- super.reset();
7915
- this.strokeStyle = void 0;
7916
- this.fillStyle = void 0;
7917
- this.textureTransform = void 0;
7918
- this.lineCap = void 0;
7919
- this.lineJoin = void 0;
7920
- this.lineWidth = void 0;
7921
- this.miterLimit = void 0;
7922
- this._draws.length = 0;
7923
- return this;
7924
- }
7925
- buildUvs(start, vertices, uvs, texture, textureTransform) {
7926
- if (texture) {
7927
- const w = texture.width;
7928
- const h = texture.height;
7929
- for (let len = vertices.length, i = start; i < len; i += 2) {
7930
- const x = vertices[i];
7931
- const y = vertices[i + 1];
7932
- let uvX;
7933
- let uvY;
7934
- if (textureTransform) {
7935
- [uvX, uvY] = textureTransform?.applyToPoint(x, y);
7936
- } else {
7937
- [uvX, uvY] = [x / w, y / h];
7938
- }
7939
- uvs.push(uvX, uvY);
7940
- }
7941
- } else {
7942
- for (let len = vertices.length, i = start; i < len; i += 2) {
7943
- uvs.push(0, 0);
7944
- }
7945
- }
7981
+ var __defProp$n = Object.defineProperty;
7982
+ var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
7983
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7984
+ var __decorateClass$u = (decorators, target, key, kind) => {
7985
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
7986
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7987
+ if (decorator = decorators[i])
7988
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7989
+ if (kind && result) __defProp$n(target, key, result);
7990
+ return result;
7991
+ };
7992
+ var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, key + "" , value);
7993
+ exports.EmbossEffect = class EmbossEffect extends exports.Effect {
7994
+ constructor(properties, children = []) {
7995
+ super();
7996
+ this.setProperties(properties).append(children);
7946
7997
  }
7947
- toBatchables() {
7948
- const batchables = [];
7949
- let vertices = [];
7950
- let indices = [];
7951
- let uvs = [];
7952
- let texture;
7953
- const push = (type) => {
7954
- batchables.push({
7955
- type,
7956
- vertices,
7957
- indices,
7958
- uvs,
7959
- texture
7998
+ apply(renderer, source) {
7999
+ source.redraw(renderer, () => {
8000
+ QuadUvGeometry.draw(renderer, exports.EmbossEffect.material, {
8001
+ sampler: 0,
8002
+ strength: this.strength,
8003
+ inputSize: [source.width, source.height, 1 / source.width, 1 / source.height]
7960
8004
  });
7961
- vertices = [];
7962
- indices = [];
7963
- uvs = [];
7964
- texture = void 0;
7965
- };
7966
- for (let len = this._draws.length, i = 0; i < len; i++) {
7967
- const draw = this._draws[i];
7968
- const prev = this._draws[i - 1];
7969
- if (vertices.length && prev && prev?.type !== draw.type) {
7970
- push(prev.type);
7971
- }
7972
- const oldTexture = texture;
7973
- if (!oldTexture) {
7974
- texture = draw.texture;
7975
- }
7976
- if (vertices.length && oldTexture !== draw.texture && !oldTexture?.is(draw.texture)) {
7977
- push(draw.type);
7978
- }
7979
- const start = vertices.length;
7980
- if (draw.type === "fill") {
7981
- draw.path.fillTriangulate({
7982
- vertices,
7983
- indices
7984
- });
7985
- this.buildUvs(start, vertices, uvs, draw.texture, draw.textureTransform);
7986
- } else {
7987
- draw.path.strokeTriangulate({
7988
- vertices,
7989
- indices,
7990
- lineStyle: draw.style,
7991
- flipAlignment: false,
7992
- closed: true
7993
- });
7994
- this.buildUvs(start, vertices, uvs, draw.texture, draw.textureTransform);
7995
- }
7996
- }
7997
- const last = this._draws[this._draws.length - 1];
7998
- if (last && vertices.length) {
7999
- push(last.type);
8000
- }
8001
- return batchables;
8005
+ });
8002
8006
  }
8003
- }
8007
+ };
8008
+ __publicField$b(exports.EmbossEffect, "material", new Material({
8009
+ vert: `precision mediump float;
8010
+ attribute vec2 position;
8011
+ attribute vec2 uv;
8012
+ varying vec2 vUv;
8013
+ void main() {
8014
+ gl_Position = vec4(position, 0.0, 1.0);
8015
+ vUv = uv;
8016
+ }`,
8017
+ frag: `precision mediump float;
8018
+ uniform sampler2D sampler;
8019
+ uniform vec4 inputSize;
8020
+ uniform float strength;
8021
+ varying vec2 vUv;
8004
8022
 
8005
- var __defProp$l = Object.defineProperty;
8006
- var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
8023
+ void main(void) {
8024
+ vec2 onePixel = inputSize.zw;
8025
+ vec4 color;
8026
+ color.rgb = vec3(0.5);
8027
+ color -= texture2D(sampler, vUv - onePixel) * strength;
8028
+ color += texture2D(sampler, vUv + onePixel) * strength;
8029
+ color.rgb = vec3((color.r + color.g + color.b) / 3.0);
8030
+ float alpha = texture2D(sampler, vUv).a;
8031
+ gl_FragColor = vec4(color.rgb * alpha, alpha);
8032
+ }`
8033
+ }));
8034
+ __decorateClass$u([
8035
+ property({ default: 5 })
8036
+ ], exports.EmbossEffect.prototype, "strength", 2);
8037
+ exports.EmbossEffect = __decorateClass$u([
8038
+ customNode("EmbossEffect")
8039
+ ], exports.EmbossEffect);
8040
+
8041
+ var __defProp$m = Object.defineProperty;
8042
+ var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
8043
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8007
8044
  var __decorateClass$t = (decorators, target, key, kind) => {
8008
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
8045
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
8009
8046
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8010
8047
  if (decorator = decorators[i])
8011
8048
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8012
- if (kind && result) __defProp$l(target, key, result);
8049
+ if (kind && result) __defProp$m(target, key, result);
8013
8050
  return result;
8014
8051
  };
8015
- exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
8016
- _parentGlobalVisible;
8017
- _globalVisible;
8018
- get globalVisible() {
8019
- return this._globalVisible ?? true;
8020
- }
8021
- _parentGlobalOpacity;
8022
- _globalOpacity;
8023
- get globalOpacity() {
8024
- return this._globalOpacity ?? 1;
8025
- }
8026
- _modulate = new Color(4294967295);
8027
- _backgroundImage;
8028
- // Batch render
8029
- context = new CanvasContext();
8030
- _resetContext = true;
8031
- _redrawing = false;
8032
- _relayouting = false;
8033
- _repainting = false;
8034
- _originalBatchables = [];
8035
- _layoutedBatchables = [];
8036
- _batchables = [];
8037
- constructor(properties, nodes = []) {
8052
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, key + "" , value);
8053
+ exports.GlitchEffect = class GlitchEffect extends exports.Effect {
8054
+ _canvas;
8055
+ _texture;
8056
+ _sizes;
8057
+ _offsets;
8058
+ _needsRedraw = false;
8059
+ constructor(properties, children = []) {
8038
8060
  super();
8039
- this.setProperties(properties).append(nodes);
8061
+ this.setProperties(properties).append(children);
8062
+ this._canvas = document.createElement("canvas");
8063
+ this._canvas.width = 4;
8064
+ this._canvas.height = this.sampleSize;
8065
+ this._texture = new Texture2D(this._canvas);
8066
+ this._sizes = new Float32Array(this.slices);
8067
+ this._offsets = new Float32Array(this.slices);
8040
8068
  }
8041
- _updateProperty(key, value, oldValue, declaration) {
8042
- super._updateProperty(key, value, oldValue, declaration);
8043
- switch (key) {
8044
- case "modulate":
8045
- this._modulate.value = value;
8046
- this.requestRepaint();
8047
- break;
8048
- case "blendMode":
8049
- this.requestRepaint();
8050
- break;
8051
- case "opacity":
8052
- this._updateGlobalOpacity();
8053
- break;
8054
- case "visible":
8055
- case "insideTimeRange":
8056
- this._updateGlobalVisible();
8057
- break;
8069
+ redraw() {
8070
+ const size = this.sampleSize;
8071
+ const texture = this._texture;
8072
+ const ctx = this._canvas.getContext("2d");
8073
+ ctx.clearRect(0, 0, 8, size);
8074
+ let offset;
8075
+ let y = 0;
8076
+ for (let i = 0; i < this.slices; i++) {
8077
+ offset = Math.floor(this._offsets[i] * 256);
8078
+ const height = this._sizes[i] * size;
8079
+ const red = offset > 0 ? offset : 0;
8080
+ const green = offset < 0 ? -offset : 0;
8081
+ ctx.fillStyle = `rgba(${red}, ${green}, 0, 1)`;
8082
+ ctx.fillRect(0, y >> 0, size, height + 1 >> 0);
8083
+ y += height;
8058
8084
  }
8085
+ texture.requestUpload();
8059
8086
  }
8060
- show() {
8061
- this.visible = true;
8062
- }
8063
- hide() {
8064
- this.visible = false;
8065
- }
8066
- isVisibleInTree() {
8067
- return this.globalOpacity > 0 && this.globalVisible;
8068
- }
8069
- canRender() {
8070
- return super.canRender() && this.isVisibleInTree();
8071
- }
8072
- requestRedraw() {
8073
- this._redrawing = true;
8074
- this.requestUpdate();
8075
- }
8076
- requestRelayout() {
8077
- this._relayouting = true;
8078
- this.requestUpdate();
8079
- }
8080
- requestRepaint() {
8081
- this._repainting = true;
8082
- this.requestUpdate();
8083
- }
8084
- _updateGlobalVisible() {
8085
- this._parentGlobalVisible = this.getParent()?.globalVisible;
8086
- this._globalVisible = (this._parentGlobalVisible ?? true) && this.visible && this.insideTimeRange;
8087
- }
8088
- _updateGlobalOpacity() {
8089
- this._parentGlobalOpacity = this.getParent()?.opacity;
8090
- const globalOpacity = clamp(0, this.opacity, 1) * (this._parentGlobalOpacity ?? 1);
8091
- if (this._globalOpacity !== globalOpacity) {
8092
- this._globalOpacity = globalOpacity;
8093
- this.requestRepaint();
8087
+ apply(renderer, source) {
8088
+ if (!this._needsRedraw) {
8089
+ this._needsRedraw = true;
8090
+ this.redraw();
8094
8091
  }
8095
- }
8096
- _draw() {
8097
- this.emit("draw");
8098
- }
8099
- _redraw() {
8100
- this._tree?.log(this.name, "redrawing");
8101
- this._draw();
8102
- return this.context.toBatchables();
8103
- }
8104
- _relayout(batchables) {
8105
- this._tree?.log(this.name, "relayouting");
8106
- return batchables;
8107
- }
8108
- _repaint(batchables) {
8109
- this._tree?.log(this.name, "repainting");
8110
- return batchables.map((batchable) => {
8111
- return {
8112
- ...batchable,
8113
- modulate: this._modulate.toArgb(this.globalOpacity, true),
8114
- blendMode: this.blendMode
8115
- };
8092
+ const width = source.width;
8093
+ const height = source.height;
8094
+ const radians = this.direction * (Math.PI / 180);
8095
+ const sinDir = Math.sin(radians);
8096
+ const cosDir = Math.cos(radians);
8097
+ source.redraw(renderer, () => {
8098
+ this._texture.activate(renderer, 1);
8099
+ QuadUvGeometry.draw(renderer, exports.GlitchEffect.material, {
8100
+ sampler: 0,
8101
+ filterClamp: [0, 0, 1, 1],
8102
+ filterArea: [width, height, 0, 0],
8103
+ dimensions: [width, height],
8104
+ aspect: height / width,
8105
+ displacementMap: 1,
8106
+ offset: this.offset,
8107
+ sinDir,
8108
+ cosDir,
8109
+ fillMode: this.fillMode,
8110
+ seed: this.seed,
8111
+ red: this.red,
8112
+ green: this.green,
8113
+ blue: this.blue
8114
+ });
8116
8115
  });
8117
8116
  }
8118
- _process(delta) {
8119
- super._process(delta);
8120
- const parent = this.getParent();
8121
- if (this._parentGlobalVisible !== parent?.globalVisible) {
8122
- this.requestUpdate();
8123
- }
8124
- if (this._parentGlobalOpacity !== parent?.globalOpacity) {
8125
- this.requestUpdate();
8126
- }
8127
- }
8128
- _update() {
8129
- const parent = this.getParent();
8130
- if (this._parentGlobalVisible !== parent?.globalVisible) {
8131
- this._updateGlobalVisible();
8132
- }
8133
- if (this._parentGlobalOpacity !== parent?.globalOpacity) {
8134
- this._updateGlobalOpacity();
8135
- }
8136
- const redrawing = this._redrawing;
8137
- let relayouting = this._relayouting;
8138
- let repainting = this._repainting;
8139
- let batchables;
8140
- if (redrawing) {
8141
- this._originalBatchables = this._redraw();
8142
- relayouting = true;
8143
- }
8144
- if (relayouting) {
8145
- this._layoutedBatchables = this._relayout(this._originalBatchables);
8146
- repainting = true;
8147
- }
8148
- if (repainting) {
8149
- batchables = this._repaint(this._layoutedBatchables);
8150
- }
8151
- if (redrawing) {
8152
- if (this._resetContext) {
8153
- this.context.reset();
8117
+ };
8118
+ __publicField$a(exports.GlitchEffect, "material", new Material({
8119
+ vert: `precision mediump float;
8120
+ attribute vec2 position;
8121
+ attribute vec2 uv;
8122
+ varying vec2 vUv;
8123
+ void main() {
8124
+ gl_Position = vec4(position, 0.0, 1.0);
8125
+ vUv = uv;
8126
+ }`,
8127
+ frag: `precision mediump float;
8128
+
8129
+ varying vec2 vUv;
8130
+ uniform sampler2D sampler;
8131
+
8132
+ uniform vec4 filterArea;
8133
+ uniform vec4 filterClamp;
8134
+ uniform vec2 dimensions;
8135
+ uniform float aspect;
8136
+
8137
+ uniform sampler2D displacementMap;
8138
+ uniform float offset;
8139
+ uniform float sinDir;
8140
+ uniform float cosDir;
8141
+ uniform int fillMode;
8142
+
8143
+ uniform float seed;
8144
+ uniform vec2 red;
8145
+ uniform vec2 green;
8146
+ uniform vec2 blue;
8147
+
8148
+ const int TRANSPARENT = 0;
8149
+ const int ORIGINAL = 1;
8150
+ const int LOOP = 2;
8151
+ const int CLAMP = 3;
8152
+ const int MIRROR = 4;
8153
+
8154
+ void main(void) {
8155
+ vec2 coord = (vUv * filterArea.xy) / dimensions;
8156
+
8157
+ if (coord.x > 1.0 || coord.y > 1.0) {
8158
+ return;
8159
+ }
8160
+
8161
+ float cx = coord.x - 0.5;
8162
+ float cy = (coord.y - 0.5) * aspect;
8163
+ float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5;
8164
+
8165
+ // displacementMap: repeat
8166
+ // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny);
8167
+
8168
+ // displacementMap: mirror
8169
+ ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny);
8170
+
8171
+ vec4 dc = texture2D(displacementMap, vec2(0.5, ny));
8172
+
8173
+ float displacement = (dc.r - dc.g) * (offset / filterArea.x);
8174
+
8175
+ coord = vUv + vec2(cosDir * displacement, sinDir * displacement * aspect);
8176
+
8177
+ if (fillMode == CLAMP) {
8178
+ coord = clamp(coord, filterClamp.xy, filterClamp.zw);
8179
+ } else {
8180
+ if (coord.x > filterClamp.z) {
8181
+ if (fillMode == TRANSPARENT) {
8182
+ discard;
8183
+ } else if (fillMode == LOOP) {
8184
+ coord.x -= filterClamp.z;
8185
+ } else if (fillMode == MIRROR) {
8186
+ coord.x = filterClamp.z * 2.0 - coord.x;
8187
+ }
8188
+ } else if (coord.x < filterClamp.x) {
8189
+ if (fillMode == TRANSPARENT) {
8190
+ discard;
8191
+ } else if (fillMode == LOOP) {
8192
+ coord.x += filterClamp.z;
8193
+ } else if (fillMode == MIRROR) {
8194
+ coord.x *= -filterClamp.z;
8154
8195
  }
8155
8196
  }
8156
- if (batchables) {
8157
- this._batchables = batchables;
8158
- this._redrawing = false;
8159
- this._relayouting = false;
8160
- this._repainting = false;
8197
+
8198
+ if (coord.y > filterClamp.w) {
8199
+ if (fillMode == TRANSPARENT) {
8200
+ discard;
8201
+ } else if (fillMode == LOOP) {
8202
+ coord.y -= filterClamp.w;
8203
+ } else if (fillMode == MIRROR) {
8204
+ coord.y = filterClamp.w * 2.0 - coord.y;
8205
+ }
8206
+ } else if (coord.y < filterClamp.y) {
8207
+ if (fillMode == TRANSPARENT) {
8208
+ discard;
8209
+ } else if (fillMode == LOOP) {
8210
+ coord.y += filterClamp.w;
8211
+ } else if (fillMode == MIRROR) {
8212
+ coord.y *= -filterClamp.w;
8213
+ }
8161
8214
  }
8162
8215
  }
8163
- _render(renderer) {
8164
- this._batchables.forEach((batchable) => {
8165
- batchable.texture?.upload(renderer);
8166
- renderer.batch2D.render({
8167
- ...batchable,
8168
- texture: batchable.texture?._glTexture(renderer)
8169
- });
8170
- });
8171
- super._render(renderer);
8172
- }
8173
- };
8216
+
8217
+ gl_FragColor.r = texture2D(sampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r;
8218
+ gl_FragColor.g = texture2D(sampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;
8219
+ gl_FragColor.b = texture2D(sampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;
8220
+ gl_FragColor.a = texture2D(sampler, coord).a;
8221
+ }`
8222
+ }));
8174
8223
  __decorateClass$t([
8175
- property()
8176
- ], exports.CanvasItem.prototype, "modulate", 2);
8224
+ property({ default: 10 })
8225
+ ], exports.GlitchEffect.prototype, "slices", 2);
8177
8226
  __decorateClass$t([
8178
- property()
8179
- ], exports.CanvasItem.prototype, "blendMode", 2);
8227
+ property({ default: 512 })
8228
+ ], exports.GlitchEffect.prototype, "sampleSize", 2);
8180
8229
  __decorateClass$t([
8181
- protectedProperty({ default: true })
8182
- ], exports.CanvasItem.prototype, "visible", 2);
8230
+ property({ default: 100 })
8231
+ ], exports.GlitchEffect.prototype, "offset", 2);
8183
8232
  __decorateClass$t([
8184
- protectedProperty({ default: 1 })
8185
- ], exports.CanvasItem.prototype, "opacity", 2);
8186
- exports.CanvasItem = __decorateClass$t([
8187
- customNode("CanvasItem")
8188
- ], exports.CanvasItem);
8189
-
8190
- class RenderStack {
8191
- currentCall;
8192
- calls = [];
8193
- createCall(renderable) {
8194
- return {
8195
- renderable,
8196
- parentCall: this.currentCall,
8197
- fn: renderable.render.bind(renderable),
8198
- calls: []
8199
- };
8200
- }
8201
- push(renderable) {
8202
- const call = this.createCall(renderable);
8203
- (this.currentCall?.calls ?? this.calls).push(call);
8204
- return call;
8205
- }
8206
- render(renderer) {
8207
- this.calls.forEach(function render(call) {
8208
- call.fn(renderer, () => {
8209
- call.calls.forEach(render);
8210
- });
8211
- });
8212
- this.calls = [];
8213
- }
8214
- }
8233
+ property({ default: 0 })
8234
+ ], exports.GlitchEffect.prototype, "direction", 2);
8235
+ __decorateClass$t([
8236
+ property({ default: 2 })
8237
+ ], exports.GlitchEffect.prototype, "fillMode", 2);
8238
+ __decorateClass$t([
8239
+ property({ default: 0 })
8240
+ ], exports.GlitchEffect.prototype, "seed", 2);
8241
+ __decorateClass$t([
8242
+ property({ default: [2, 2] })
8243
+ ], exports.GlitchEffect.prototype, "red", 2);
8244
+ __decorateClass$t([
8245
+ property({ default: [-10, 4] })
8246
+ ], exports.GlitchEffect.prototype, "green", 2);
8247
+ __decorateClass$t([
8248
+ property({ default: [10, -4] })
8249
+ ], exports.GlitchEffect.prototype, "blue", 2);
8250
+ exports.GlitchEffect = __decorateClass$t([
8251
+ customNode("GlitchEffect")
8252
+ ], exports.GlitchEffect);
8215
8253
 
8216
- var __defProp$k = Object.defineProperty;
8217
- var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
8254
+ var __defProp$l = Object.defineProperty;
8255
+ var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
8256
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8218
8257
  var __decorateClass$s = (decorators, target, key, kind) => {
8219
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
8258
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
8220
8259
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8221
8260
  if (decorator = decorators[i])
8222
8261
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8223
- if (kind && result) __defProp$k(target, key, result);
8262
+ if (kind && result) __defProp$l(target, key, result);
8224
8263
  return result;
8225
8264
  };
8226
- exports.Timeline = class Timeline extends exports.Node {
8227
- static from(range, loop = false) {
8228
- const [startTime, endTime] = range ? Array.isArray(range) ? range : [0, range] : [];
8229
- return new exports.Timeline({
8230
- startTime,
8231
- endTime,
8232
- loop
8233
- });
8234
- }
8235
- constructor(properties) {
8265
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, key + "" , value);
8266
+ const perlin = `vec3 mod289(vec3 x)
8267
+ {
8268
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
8269
+ }
8270
+ vec4 mod289(vec4 x)
8271
+ {
8272
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
8273
+ }
8274
+ vec4 permute(vec4 x)
8275
+ {
8276
+ return mod289(((x * 34.0) + 1.0) * x);
8277
+ }
8278
+ vec4 taylorInvSqrt(vec4 r)
8279
+ {
8280
+ return 1.79284291400159 - 0.85373472095314 * r;
8281
+ }
8282
+ vec3 fade(vec3 t)
8283
+ {
8284
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
8285
+ }
8286
+ // Classic Perlin noise, periodic variant
8287
+ float pnoise(vec3 P, vec3 rep)
8288
+ {
8289
+ vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
8290
+ vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period
8291
+ Pi0 = mod289(Pi0);
8292
+ Pi1 = mod289(Pi1);
8293
+ vec3 Pf0 = fract(P); // Fractional part for interpolation
8294
+ vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
8295
+ vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
8296
+ vec4 iy = vec4(Pi0.yy, Pi1.yy);
8297
+ vec4 iz0 = Pi0.zzzz;
8298
+ vec4 iz1 = Pi1.zzzz;
8299
+ vec4 ixy = permute(permute(ix) + iy);
8300
+ vec4 ixy0 = permute(ixy + iz0);
8301
+ vec4 ixy1 = permute(ixy + iz1);
8302
+ vec4 gx0 = ixy0 * (1.0 / 7.0);
8303
+ vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
8304
+ gx0 = fract(gx0);
8305
+ vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
8306
+ vec4 sz0 = step(gz0, vec4(0.0));
8307
+ gx0 -= sz0 * (step(0.0, gx0) - 0.5);
8308
+ gy0 -= sz0 * (step(0.0, gy0) - 0.5);
8309
+ vec4 gx1 = ixy1 * (1.0 / 7.0);
8310
+ vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
8311
+ gx1 = fract(gx1);
8312
+ vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
8313
+ vec4 sz1 = step(gz1, vec4(0.0));
8314
+ gx1 -= sz1 * (step(0.0, gx1) - 0.5);
8315
+ gy1 -= sz1 * (step(0.0, gy1) - 0.5);
8316
+ vec3 g000 = vec3(gx0.x, gy0.x, gz0.x);
8317
+ vec3 g100 = vec3(gx0.y, gy0.y, gz0.y);
8318
+ vec3 g010 = vec3(gx0.z, gy0.z, gz0.z);
8319
+ vec3 g110 = vec3(gx0.w, gy0.w, gz0.w);
8320
+ vec3 g001 = vec3(gx1.x, gy1.x, gz1.x);
8321
+ vec3 g101 = vec3(gx1.y, gy1.y, gz1.y);
8322
+ vec3 g011 = vec3(gx1.z, gy1.z, gz1.z);
8323
+ vec3 g111 = vec3(gx1.w, gy1.w, gz1.w);
8324
+ vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
8325
+ g000 *= norm0.x;
8326
+ g010 *= norm0.y;
8327
+ g100 *= norm0.z;
8328
+ g110 *= norm0.w;
8329
+ vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
8330
+ g001 *= norm1.x;
8331
+ g011 *= norm1.y;
8332
+ g101 *= norm1.z;
8333
+ g111 *= norm1.w;
8334
+ float n000 = dot(g000, Pf0);
8335
+ float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
8336
+ float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
8337
+ float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
8338
+ float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
8339
+ float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
8340
+ float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
8341
+ float n111 = dot(g111, Pf1);
8342
+ vec3 fade_xyz = fade(Pf0);
8343
+ vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
8344
+ vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
8345
+ float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
8346
+ return 2.2 * n_xyz;
8347
+ }
8348
+ float turb(vec3 P, vec3 rep, float lacunarity, float gain)
8349
+ {
8350
+ float sum = 0.0;
8351
+ float sc = 1.0;
8352
+ float totalgain = 1.0;
8353
+ for (float i = 0.0; i < 6.0; i++)
8354
+ {
8355
+ sum += totalgain * pnoise(P * sc, rep);
8356
+ sc *= lacunarity;
8357
+ totalgain *= gain;
8358
+ }
8359
+ return abs(sum);
8360
+ }`;
8361
+ exports.GodrayEffect = class GodrayEffect extends exports.Effect {
8362
+ constructor(properties, children = []) {
8236
8363
  super();
8237
- this.setProperties(properties);
8238
- }
8239
- _updateProperty(key, value, oldValue) {
8240
- super._updateProperty(key, value, oldValue);
8241
- switch (key) {
8242
- case "startTime":
8243
- this.startTime = Math.min(value, this.endTime);
8244
- break;
8245
- case "endTime":
8246
- this.endTime = value || Number.MAX_SAFE_INTEGER;
8247
- break;
8248
- }
8249
- }
8250
- addTime(delta) {
8251
- const start = this.startTime;
8252
- const end = this.endTime;
8253
- let current = this.currentTime;
8254
- current = current + delta;
8255
- if (this.loop && current > end) {
8256
- current = start + current % end;
8257
- }
8258
- current = clamp(start, current, end);
8259
- this.currentTime = current;
8260
- this.emit("updateCurrentTime", current, delta);
8261
- return this;
8364
+ this.setProperties(properties).append(children);
8262
8365
  }
8263
- _process(delta) {
8264
- super._process(delta);
8265
- this.addTime(delta);
8366
+ apply(renderer, source) {
8367
+ const radians = this.angle * (Math.PI / 180);
8368
+ const uLight = this.parallel ? [Math.cos(radians), Math.sin(radians)] : this.center;
8369
+ source.redraw(renderer, () => {
8370
+ QuadUvGeometry.draw(renderer, exports.GodrayEffect.material, {
8371
+ sampler: 0,
8372
+ uDimensions: [source.width, source.height],
8373
+ uParallel: this.parallel ? 1 : 0,
8374
+ uLight,
8375
+ uAspect: source.height / source.width,
8376
+ uTime: this.time,
8377
+ uRay: [
8378
+ this.gain,
8379
+ this.lacunarity,
8380
+ this.alpha
8381
+ ],
8382
+ uInputSize: [source.width, source.height, 0, 0]
8383
+ });
8384
+ });
8266
8385
  }
8267
8386
  };
8387
+ __publicField$9(exports.GodrayEffect, "material", new Material({
8388
+ vert: `precision mediump float;
8389
+ attribute vec2 position;
8390
+ attribute vec2 uv;
8391
+ varying vec2 vUv;
8392
+ void main() {
8393
+ gl_Position = vec4(position, 0.0, 1.0);
8394
+ vUv = uv;
8395
+ }`,
8396
+ frag: `precision highp float;
8397
+ varying vec2 vUv;
8398
+ uniform sampler2D sampler;
8399
+ uniform vec2 uDimensions;
8400
+ uniform float uParallel;
8401
+ uniform vec2 uLight;
8402
+ uniform float uAspect;
8403
+ uniform float uTime;
8404
+ uniform vec3 uRay;
8405
+ uniform vec4 uInputSize;
8406
+
8407
+ ${perlin}
8408
+
8409
+ void main(void) {
8410
+ bool uParallel = uParallel > 0.5;
8411
+ vec2 coord = vUv * uInputSize.xy / uDimensions;
8412
+
8413
+ float d;
8414
+ if (uParallel) {
8415
+ float _cos = uLight.x;
8416
+ float _sin = uLight.y;
8417
+ d = (_cos * coord.x) + (_sin * coord.y * uAspect);
8418
+ } else {
8419
+ float dx = coord.x - uLight.x / uInputSize.x;
8420
+ float dy = (coord.y - uLight.y / uInputSize.y) * uAspect;
8421
+ float dis = sqrt(dx * dx + dy * dy) + 0.00001;
8422
+ d = dy / dis;
8423
+ }
8424
+
8425
+ float gain = uRay[0];
8426
+ float lacunarity = uRay[1];
8427
+ float alpha = uRay[2];
8428
+
8429
+ vec3 dir = vec3(d, d, 0.0);
8430
+ float noise = turb(dir + vec3(uTime, 0.0, 62.1 + uTime) * 0.05, vec3(480.0, 320.0, 480.0), lacunarity, gain);
8431
+ noise = mix(noise, 0.0, 0.3);
8432
+ vec4 mist = vec4(vec3(noise), 1.0) * (1.0 - coord.y);
8433
+ mist.a = 1.0;
8434
+ mist *= alpha;
8435
+
8436
+ vec4 color = texture2D(sampler, vUv);
8437
+ gl_FragColor = vec4(color.rgb + mist.rgb, color.a);
8438
+ }`
8439
+ }));
8268
8440
  __decorateClass$s([
8269
8441
  property({ default: 0 })
8270
- ], exports.Timeline.prototype, "startTime", 2);
8442
+ ], exports.GodrayEffect.prototype, "time", 2);
8271
8443
  __decorateClass$s([
8272
- property({ default: 0 })
8273
- ], exports.Timeline.prototype, "currentTime", 2);
8444
+ property({ default: 30 })
8445
+ ], exports.GodrayEffect.prototype, "angle", 2);
8274
8446
  __decorateClass$s([
8275
- property({ default: Number.MAX_SAFE_INTEGER })
8276
- ], exports.Timeline.prototype, "endTime", 2);
8447
+ property({ default: 0.5 })
8448
+ ], exports.GodrayEffect.prototype, "gain", 2);
8277
8449
  __decorateClass$s([
8278
- property({ default: false })
8279
- ], exports.Timeline.prototype, "loop", 2);
8280
- exports.Timeline = __decorateClass$s([
8281
- customNode("Timeline")
8282
- ], exports.Timeline);
8450
+ property({ default: 2.5 })
8451
+ ], exports.GodrayEffect.prototype, "lacunarity", 2);
8452
+ __decorateClass$s([
8453
+ property({ default: true })
8454
+ ], exports.GodrayEffect.prototype, "parallel", 2);
8455
+ __decorateClass$s([
8456
+ property({ default: [0, 0] })
8457
+ ], exports.GodrayEffect.prototype, "center", 2);
8458
+ __decorateClass$s([
8459
+ property({ default: 1 })
8460
+ ], exports.GodrayEffect.prototype, "alpha", 2);
8461
+ exports.GodrayEffect = __decorateClass$s([
8462
+ customNode("GodrayEffect")
8463
+ ], exports.GodrayEffect);
8283
8464
 
8284
- var __defProp$j = Object.defineProperty;
8465
+ var __defProp$k = Object.defineProperty;
8466
+ var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
8467
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8285
8468
  var __decorateClass$r = (decorators, target, key, kind) => {
8286
- var result = void 0 ;
8469
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
8287
8470
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8288
8471
  if (decorator = decorators[i])
8289
- result = (decorator(target, key, result) ) || result;
8290
- if (result) __defProp$j(target, key, result);
8472
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8473
+ if (kind && result) __defProp$k(target, key, result);
8291
8474
  return result;
8292
8475
  };
8293
- class SceneTree extends MainLoop {
8294
- input = new Input();
8295
- renderStack = new RenderStack();
8296
- root = new exports.Viewport(true).setTree(this);
8297
- timeline;
8298
- _backgroundColor = new Color();
8299
- _currentViewport;
8300
- getCurrentViewport() {
8301
- return this._currentViewport;
8302
- }
8303
- setCurrentViewport(viewport) {
8304
- this._currentViewport = viewport;
8305
- }
8306
- constructor(timeline = new exports.Timeline()) {
8476
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
8477
+ exports.MaskEffect = class MaskEffect extends exports.Effect {
8478
+ texture;
8479
+ constructor(properties, children = []) {
8307
8480
  super();
8308
- this.timeline = timeline.setTree(this);
8481
+ this.setProperties(properties).append(children);
8482
+ }
8483
+ async load() {
8484
+ this.texture = void 0;
8485
+ if (this.src) {
8486
+ this.texture = await assets.texture.load(this.src);
8487
+ }
8309
8488
  }
8310
8489
  _updateProperty(key, value, oldValue, declaration) {
8311
8490
  super._updateProperty(key, value, oldValue, declaration);
8312
8491
  switch (key) {
8313
- case "backgroundColor":
8314
- this._backgroundColor.value = value;
8492
+ case "src":
8493
+ this.load();
8494
+ break;
8495
+ case "texture":
8496
+ oldValue?.free?.();
8315
8497
  break;
8316
8498
  }
8317
8499
  }
8318
- log(...args) {
8319
- if (this.debug) {
8320
- console.log(`[modern-canvas]`, ...args);
8321
- }
8322
- }
8323
- _process(delta = 0) {
8324
- this.timeline.emit("process", delta);
8325
- this.emit("processing");
8326
- this.root.emit("process", delta);
8327
- this.emit("processed");
8328
- }
8329
- _render(renderer) {
8330
- this.emit("rendering");
8331
- renderer.program.uniforms.projectionMatrix = this.root.toProjectionArray(true);
8332
- this.renderStack.render(renderer);
8333
- this._renderScreen(renderer);
8334
- this.emit("rendered");
8335
- }
8336
- _renderScreen(renderer) {
8337
- renderer.state.reset();
8338
- renderer.framebuffer.bind(null);
8339
- renderer.viewport.bind({
8340
- x: 0,
8341
- y: 0,
8342
- width: this.root.width * renderer.pixelRatio,
8343
- height: this.root.height * renderer.pixelRatio
8344
- });
8345
- if (this.backgroundColor) {
8346
- renderer.gl.clearColor(...this._backgroundColor.toArray());
8347
- }
8348
- renderer.clear();
8349
- if (this.backgroundColor) {
8350
- renderer.gl.clearColor(0, 0, 0, 0);
8500
+ apply(renderer, source, context) {
8501
+ if (this.texture && context.targetArea) {
8502
+ source.redraw(renderer, () => {
8503
+ this.texture.activate(renderer, 1);
8504
+ QuadUvGeometry.draw(renderer, exports.MaskEffect.material, {
8505
+ sampler: 0,
8506
+ mask: 1,
8507
+ area: context.targetArea,
8508
+ rotation: context.target?.globalRotation ?? 0
8509
+ });
8510
+ renderer.texture.unbind(1);
8511
+ });
8351
8512
  }
8352
- const texture = this.root.texture;
8353
- texture.activate(renderer, 0);
8354
- QuadUvGeometry.draw(renderer);
8355
- renderer.texture.unbind(texture);
8356
- }
8357
- free() {
8358
- super.free();
8359
- this.root.getChildren(true).forEach((node) => this.root.removeChild(node));
8360
- this.input.removeEventListeners();
8361
8513
  }
8514
+ };
8515
+ __publicField$8(exports.MaskEffect, "material", new Material({
8516
+ vert: `precision mediump float;
8517
+ attribute vec2 position;
8518
+ attribute vec2 uv;
8519
+ varying vec2 vUv;
8520
+ void main() {
8521
+ gl_Position = vec4(position, 0.0, 1.0);
8522
+ vUv = uv;
8523
+ }`,
8524
+ frag: `varying vec2 vUv;
8525
+ uniform sampler2D sampler;
8526
+ uniform sampler2D mask;
8527
+ uniform float area[4];
8528
+ uniform float rotation;
8529
+
8530
+ vec2 rotateUV(vec2 uv, float angle) {
8531
+ uv -= 0.5;
8532
+ float cosAngle = cos(angle);
8533
+ float sinAngle = sin(angle);
8534
+ mat2 rotationMatrix = mat2(
8535
+ cosAngle, -sinAngle,
8536
+ sinAngle, cosAngle
8537
+ );
8538
+ uv = rotationMatrix * uv;
8539
+ uv += 0.5;
8540
+ return uv;
8362
8541
  }
8542
+
8543
+ void main(void) {
8544
+ if (
8545
+ vUv.x > area[0]
8546
+ && vUv.x < (area[0] + area[2])
8547
+ && (1.0 - vUv.y) > area[1]
8548
+ && (1.0 - vUv.y) < (area[1] + area[3])
8549
+ ) {
8550
+ vec4 color = texture2D(sampler, vUv);
8551
+ vec2 uv = vec2(
8552
+ (vUv.x - area[0]) / area[2],
8553
+ ((1.0 - vUv.y) - area[1]) / area[3]
8554
+ );
8555
+ vec4 maskColor = texture2D(mask, rotateUV(uv, rotation));
8556
+ gl_FragColor = mix(vec4(0.), color, maskColor.a);
8557
+ } else {
8558
+ gl_FragColor = vec4(0.);
8559
+ }
8560
+ }`
8561
+ }));
8363
8562
  __decorateClass$r([
8364
- property({ default: false })
8365
- ], SceneTree.prototype, "processPaused");
8366
- __decorateClass$r([
8367
- property()
8368
- ], SceneTree.prototype, "backgroundColor");
8563
+ protectedProperty()
8564
+ ], exports.MaskEffect.prototype, "texture", 2);
8369
8565
  __decorateClass$r([
8370
- protectedProperty({ default: false })
8371
- ], SceneTree.prototype, "debug");
8566
+ property({ default: "" })
8567
+ ], exports.MaskEffect.prototype, "src", 2);
8568
+ exports.MaskEffect = __decorateClass$r([
8569
+ customNode("MaskEffect")
8570
+ ], exports.MaskEffect);
8372
8571
 
8572
+ var __defProp$j = Object.defineProperty;
8373
8573
  var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
8574
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8374
8575
  var __decorateClass$q = (decorators, target, key, kind) => {
8375
8576
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
8376
8577
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8377
8578
  if (decorator = decorators[i])
8378
- result = (decorator(result)) || result;
8579
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8580
+ if (kind && result) __defProp$j(target, key, result);
8379
8581
  return result;
8380
8582
  };
8381
- exports.Transition = class Transition extends exports.Effect {
8583
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
8584
+ const frag = `precision highp float;
8585
+ varying vec2 vUv;
8586
+ uniform sampler2D sampler;
8587
+ uniform vec2 uThickness;
8588
+ uniform vec3 uColor;
8589
+ uniform float uAlpha;
8590
+ uniform float uKnockout;
8591
+ uniform vec4 uInputClamp;
8592
+
8593
+ const float DOUBLE_PI = 2. * 3.14159265358979323846264;
8594
+ const float ANGLE_STEP = {ANGLE_STEP};
8595
+
8596
+ float outlineMaxAlphaAtPos(vec2 pos) {
8597
+ if (uThickness.x == 0. || uThickness.y == 0.) {
8598
+ return 0.;
8599
+ }
8600
+ vec4 displacedColor;
8601
+ vec2 displacedPos;
8602
+ float maxAlpha = 0.;
8603
+ for (float angle = 0.; angle <= DOUBLE_PI; angle += ANGLE_STEP) {
8604
+ displacedPos.x = vUv.x + uThickness.x * cos(angle);
8605
+ displacedPos.y = vUv.y + uThickness.y * sin(angle);
8606
+ displacedColor = texture2D(sampler, clamp(displacedPos, uInputClamp.xy, uInputClamp.zw));
8607
+ maxAlpha = max(maxAlpha, displacedColor.a);
8608
+ }
8609
+ return maxAlpha;
8610
+ }
8611
+
8612
+ void main(void) {
8613
+ vec4 sourceColor = texture2D(sampler, vUv);
8614
+ vec4 contentColor = sourceColor * float(uKnockout < 0.5);
8615
+ float outlineAlpha = uAlpha * outlineMaxAlphaAtPos(vUv.xy) * (1.-sourceColor.a);
8616
+ vec4 outlineColor = vec4(vec3(uColor) * outlineAlpha, outlineAlpha);
8617
+ gl_FragColor = contentColor + outlineColor;
8618
+ }`;
8619
+ exports.OutlineEffect = class OutlineEffect extends exports.Effect {
8620
+ material;
8621
+ static getAngleStep(quality) {
8622
+ return Number.parseFloat(
8623
+ (Math.PI * 2 / Math.max(
8624
+ quality * exports.OutlineEffect.MAX_SAMPLES,
8625
+ exports.OutlineEffect.MIN_SAMPLES
8626
+ )).toFixed(7)
8627
+ );
8628
+ }
8629
+ _color = new Color();
8382
8630
  constructor(properties, children = []) {
8383
8631
  super();
8384
8632
  this.setProperties(properties).append(children);
8633
+ this.material = new Material({
8634
+ vert: `precision mediump float;
8635
+ attribute vec2 position;
8636
+ attribute vec2 uv;
8637
+ varying vec2 vUv;
8638
+ void main() {
8639
+ gl_Position = vec4(position, 0.0, 1.0);
8640
+ vUv = uv;
8641
+ }`,
8642
+ frag: frag.replace(
8643
+ /\{ANGLE_STEP\}/,
8644
+ exports.OutlineEffect.getAngleStep(this.quality).toFixed(7)
8645
+ )
8646
+ });
8647
+ }
8648
+ apply(renderer, source) {
8649
+ source.redraw(renderer, () => {
8650
+ this._color.value = this.color;
8651
+ QuadUvGeometry.draw(renderer, this.material, {
8652
+ sampler: 0,
8653
+ uThickness: [
8654
+ this.thickness / source.width,
8655
+ this.thickness / source.height
8656
+ ],
8657
+ uColor: this._color.toArray().slice(0, 3),
8658
+ uAlpha: this.alpha,
8659
+ uAngleStep: exports.OutlineEffect.getAngleStep(this.quality),
8660
+ uKnockout: this.knockout ? 1 : 0,
8661
+ uInputClamp: [0, 0, 1, 1]
8662
+ });
8663
+ });
8385
8664
  }
8386
8665
  };
8387
- exports.Transition = __decorateClass$q([
8388
- customNode("Transition", {
8389
- effectMode: "transition",
8390
- processMode: "pausable",
8391
- duration: 2e3
8392
- })
8393
- ], exports.Transition);
8666
+ __publicField$7(exports.OutlineEffect, "MIN_SAMPLES", 1);
8667
+ __publicField$7(exports.OutlineEffect, "MAX_SAMPLES", 100);
8668
+ __decorateClass$q([
8669
+ property({ default: 1 })
8670
+ ], exports.OutlineEffect.prototype, "thickness", 2);
8671
+ __decorateClass$q([
8672
+ property({ default: 0 })
8673
+ ], exports.OutlineEffect.prototype, "color", 2);
8674
+ __decorateClass$q([
8675
+ property({ default: 1 })
8676
+ ], exports.OutlineEffect.prototype, "alpha", 2);
8677
+ __decorateClass$q([
8678
+ property({ default: 0.1 })
8679
+ ], exports.OutlineEffect.prototype, "quality", 2);
8680
+ __decorateClass$q([
8681
+ property({ default: false })
8682
+ ], exports.OutlineEffect.prototype, "knockout", 2);
8683
+ exports.OutlineEffect = __decorateClass$q([
8684
+ customNode("OutlineEffect")
8685
+ ], exports.OutlineEffect);
8394
8686
 
8395
8687
  var __defProp$i = Object.defineProperty;
8396
8688
  var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
@@ -8399,37 +8691,27 @@ var __decorateClass$p = (decorators, target, key, kind) => {
8399
8691
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
8400
8692
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8401
8693
  if (decorator = decorators[i])
8402
- result = (decorator(result)) || result;
8694
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8695
+ if (kind && result) __defProp$i(target, key, result);
8403
8696
  return result;
8404
8697
  };
8405
8698
  var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
8406
- exports.ShadowEffect = class ShadowEffect extends exports.Effect {
8407
- blur = new exports.BlurEffect();
8408
- viewport3 = new exports.Viewport();
8699
+ exports.PixelateEffect = class PixelateEffect extends exports.Effect {
8700
+ constructor(properties, children = []) {
8701
+ super();
8702
+ this.setProperties(properties).append(children);
8703
+ }
8409
8704
  apply(renderer, source) {
8410
- this.viewport3.activateWithCopy(renderer, source);
8411
- this.viewport3.redraw(renderer, () => {
8412
- QuadUvGeometry.draw(renderer, exports.ShadowEffect.material, {
8413
- sampler: 0,
8414
- offset: [1e-3, 1e-3],
8415
- color: [0, 0, 0],
8416
- alpha: 0.5
8417
- });
8418
- });
8419
- this.blur.apply(renderer, this.viewport3);
8420
8705
  source.redraw(renderer, () => {
8421
- this.viewport3.texture.activate(renderer, 1);
8422
- QuadUvGeometry.draw(renderer, UvMaterial.instance, {
8423
- sampler: 1
8424
- });
8425
- QuadUvGeometry.draw(renderer, UvMaterial.instance, {
8426
- sampler: 0
8706
+ QuadUvGeometry.draw(renderer, exports.PixelateEffect.material, {
8707
+ sampler: 0,
8708
+ uSize: [this.strength, this.strength],
8709
+ uInputSize: [source.width, source.height, 1 / source.width, 1 / source.height]
8427
8710
  });
8428
- renderer.texture.unbind(1);
8429
8711
  });
8430
8712
  }
8431
8713
  };
8432
- __publicField$6(exports.ShadowEffect, "material", new Material({
8714
+ __publicField$6(exports.PixelateEffect, "material", new Material({
8433
8715
  vert: `precision mediump float;
8434
8716
  attribute vec2 position;
8435
8717
  attribute vec2 uv;
@@ -8438,23 +8720,40 @@ void main() {
8438
8720
  gl_Position = vec4(position, 0.0, 1.0);
8439
8721
  vUv = uv;
8440
8722
  }`,
8441
- frag: `precision highp float;
8442
- varying vec2 vUv;
8723
+ frag: `varying vec2 vUv;
8443
8724
  uniform sampler2D sampler;
8444
- uniform float alpha;
8445
- uniform vec3 color;
8446
- uniform vec2 offset;
8725
+ uniform vec2 uSize;
8726
+ uniform vec4 uInputSize;
8727
+
8728
+ vec2 mapCoord(vec2 coord) {
8729
+ coord *= uInputSize.xy;
8730
+ coord += uInputSize.zw;
8731
+ return coord;
8732
+ }
8733
+
8734
+ vec2 unmapCoord(vec2 coord) {
8735
+ coord -= uInputSize.zw;
8736
+ coord /= uInputSize.xy;
8737
+ return coord;
8738
+ }
8739
+
8740
+ vec2 pixelate(vec2 coord, vec2 size) {
8741
+ return floor(coord / size) * size;
8742
+ }
8447
8743
 
8448
8744
  void main(void) {
8449
- vec4 sample = texture2D(sampler, vUv - offset);
8450
- sample.rgb = color.rgb * sample.a;
8451
- sample *= alpha;
8452
- gl_FragColor = sample;
8745
+ vec2 coord = mapCoord(vUv);
8746
+ coord = pixelate(coord, uSize);
8747
+ coord = unmapCoord(coord);
8748
+ gl_FragColor = texture2D(sampler, coord);
8453
8749
  }`
8454
8750
  }));
8455
- exports.ShadowEffect = __decorateClass$p([
8456
- customNode("ShadowEffect")
8457
- ], exports.ShadowEffect);
8751
+ __decorateClass$p([
8752
+ property({ default: 10 })
8753
+ ], exports.PixelateEffect.prototype, "strength", 2);
8754
+ exports.PixelateEffect = __decorateClass$p([
8755
+ customNode("PixelateEffect")
8756
+ ], exports.PixelateEffect);
8458
8757
 
8459
8758
  var __defProp$h = Object.defineProperty;
8460
8759
  var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
@@ -8469,19 +8768,19 @@ var __decorateClass$o = (decorators, target, key, kind) => {
8469
8768
  };
8470
8769
  var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, key + "" , value);
8471
8770
  exports.ZoomBlurEffect = class ZoomBlurEffect extends exports.Effect {
8472
- center;
8473
- innerRadius = 20;
8474
- radius = -1;
8475
- strength = 0.1;
8771
+ constructor(properties, children = []) {
8772
+ super();
8773
+ this.setProperties(properties).append(children);
8774
+ }
8476
8775
  apply(renderer, source) {
8477
8776
  source.redraw(renderer, () => {
8478
8777
  QuadUvGeometry.draw(renderer, exports.ZoomBlurEffect.material, {
8479
8778
  sampler: 0,
8480
- center: this.center ?? [source.width / 2, source.height / 2],
8481
- innerRadius: this.innerRadius,
8482
- radius: this.radius,
8483
- strength: this.strength,
8484
- inputSize: [source.width, source.height, 1 / source.width, 1 / source.height]
8779
+ uCenter: this.center ?? [source.width / 2, source.height / 2],
8780
+ uInnerRadius: this.innerRadius,
8781
+ uRadius: this.radius,
8782
+ uStrength: this.strength,
8783
+ uInputSize: [source.width, source.height, 1 / source.width, 1 / source.height]
8485
8784
  });
8486
8785
  });
8487
8786
  }
@@ -8496,12 +8795,12 @@ void main() {
8496
8795
  }`,
8497
8796
  frag: `varying vec2 vUv;
8498
8797
  uniform sampler2D sampler;
8499
- uniform vec4 inputSize;
8798
+ uniform vec4 uInputSize;
8500
8799
 
8501
- uniform vec2 center;
8502
- uniform float strength;
8503
- uniform float innerRadius;
8504
- uniform float radius;
8800
+ uniform vec2 uCenter;
8801
+ uniform float uStrength;
8802
+ uniform float uInnerRadius;
8803
+ uniform float uRadius;
8505
8804
 
8506
8805
  const float MAX_KERNEL_SIZE = 32.0;
8507
8806
 
@@ -8512,18 +8811,18 @@ highp float rand(vec2 co, float seed) {
8512
8811
  }
8513
8812
 
8514
8813
  void main() {
8515
- float minGradient = innerRadius * 0.3;
8516
- float innerRadius1 = (innerRadius + minGradient * 0.5) / inputSize.x;
8814
+ float minGradient = uInnerRadius * 0.3;
8815
+ float innerRadius1 = (uInnerRadius + minGradient * 0.5) / uInputSize.x;
8517
8816
 
8518
- float gradient = radius * 0.3;
8519
- float radius1 = (radius - gradient * 0.5) / inputSize.x;
8817
+ float gradient = uRadius * 0.3;
8818
+ float radius1 = (uRadius - gradient * 0.5) / uInputSize.x;
8520
8819
 
8521
8820
  float countLimit = MAX_KERNEL_SIZE;
8522
8821
 
8523
- vec2 dir = vec2(center.xy / inputSize.xy - vUv);
8524
- float dist = length(vec2(dir.x, dir.y * inputSize.y / inputSize.x));
8822
+ vec2 dir = vec2(uCenter.xy / uInputSize.xy - vUv);
8823
+ float dist = length(vec2(dir.x, dir.y * uInputSize.y / uInputSize.x));
8525
8824
 
8526
- float strength1 = strength;
8825
+ float strength1 = uStrength;
8527
8826
 
8528
8827
  float delta = 0.0;
8529
8828
  float gap;
@@ -8536,7 +8835,7 @@ void main() {
8536
8835
  }
8537
8836
 
8538
8837
  if (delta > 0.0) {
8539
- float normalCount = gap / inputSize.x;
8838
+ float normalCount = gap / uInputSize.x;
8540
8839
  delta = (normalCount - delta) / normalCount;
8541
8840
  countLimit *= delta;
8542
8841
  strength1 *= delta;
@@ -8574,13 +8873,13 @@ __decorateClass$o([
8574
8873
  property()
8575
8874
  ], exports.ZoomBlurEffect.prototype, "center", 2);
8576
8875
  __decorateClass$o([
8577
- property()
8876
+ property({ default: 20 })
8578
8877
  ], exports.ZoomBlurEffect.prototype, "innerRadius", 2);
8579
8878
  __decorateClass$o([
8580
- property()
8879
+ property({ default: -1 })
8581
8880
  ], exports.ZoomBlurEffect.prototype, "radius", 2);
8582
8881
  __decorateClass$o([
8583
- property()
8882
+ property({ default: 0.1 })
8584
8883
  ], exports.ZoomBlurEffect.prototype, "strength", 2);
8585
8884
  exports.ZoomBlurEffect = __decorateClass$o([
8586
8885
  customNode("ZoomBlurEffect")
@@ -8809,7 +9108,7 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
8809
9108
  if (this.style.boxShadow !== "none") {
8810
9109
  const node = this.getNode(nodePath);
8811
9110
  if (node) ; else {
8812
- this.appendChild(new exports.ShadowEffect({ name: nodePath }), "back");
9111
+ this.appendChild(new exports.DropShadowEffect({ name: nodePath }), "back");
8813
9112
  }
8814
9113
  } else {
8815
9114
  const node = this.getNode(nodePath);
@@ -13124,7 +13423,8 @@ class Engine extends SceneTree {
13124
13423
  this.renderer.resize(width, height, updateCss);
13125
13424
  this.root.width = width;
13126
13425
  this.root.height = height;
13127
- this.renderer.program.uniforms.projectionMatrix = this.root.toProjectionArray(true);
13426
+ this.root.requestUpload();
13427
+ this.render();
13128
13428
  return this;
13129
13429
  }
13130
13430
  nextTick() {
@@ -13346,6 +13646,7 @@ exports.WebSound = WebSound;
13346
13646
  exports.WheelInputEvent = WheelInputEvent;
13347
13647
  exports.assets = assets;
13348
13648
  exports.clamp = clamp;
13649
+ exports.clampFrag = clampFrag;
13349
13650
  exports.createHTMLCanvas = createHTMLCanvas;
13350
13651
  exports.createNode = createNode;
13351
13652
  exports.crossOrigin = crossOrigin;
@@ -13360,6 +13661,7 @@ exports.ease = ease;
13360
13661
  exports.easeIn = easeIn;
13361
13662
  exports.easeInOut = easeInOut;
13362
13663
  exports.easeOut = easeOut;
13664
+ exports.frag = frag$1;
13363
13665
  exports.getDeclarations = getDeclarations;
13364
13666
  exports.getDefaultCssPropertyValue = getDefaultCssPropertyValue;
13365
13667
  exports.isCanvasElement = isCanvasElement;