modern-canvas 0.4.20 → 0.4.22

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