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