@galacean/effects-core 2.1.0-alpha.12 → 2.1.0-alpha.13

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.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.1.0-alpha.12
6
+ * Version: v2.1.0-alpha.13
7
7
  */
8
8
 
9
9
  'use strict';
@@ -6945,6 +6945,28 @@ exports.MaterialRenderType = void 0;
6945
6945
  this.shaderDirty = true;
6946
6946
  }
6947
6947
  },
6948
+ {
6949
+ key: "mainTexture",
6950
+ get: /**
6951
+ * 材质的主纹理
6952
+ */ function get() {
6953
+ return this.getTexture("_MainTex");
6954
+ },
6955
+ set: function set(value) {
6956
+ this.setTexture("_MainTex", value);
6957
+ }
6958
+ },
6959
+ {
6960
+ key: "color",
6961
+ get: /**
6962
+ * 材质的主颜色
6963
+ */ function get() {
6964
+ return this.getColor("_Color");
6965
+ },
6966
+ set: function set(value) {
6967
+ this.setColor("_Color", value);
6968
+ }
6969
+ },
6948
6970
  {
6949
6971
  key: "blending",
6950
6972
  set: /******** effects-core 中会调用 引擎必须实现 ***********************/ /**
@@ -10081,7 +10103,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10081
10103
 
10082
10104
  var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(atlasOffset.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(0.0,texParams.y,texParams.x);vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
10083
10105
 
10084
- var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D uSampler0;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);vec4 texColor=texture2D(uSampler0,vTexCoord.xy);color=blendColor(texColor,vColor,floor(0.5+vParams.y));if(vParams.z==0.&&color.a<0.04){discard;}color.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10106
+ var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);vec4 texColor=texture2D(_MainTex,vTexCoord.xy);color=blendColor(texColor,vColor,floor(0.5+vParams.y));if(vParams.z==0.&&color.a<0.04){discard;}color.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10085
10107
 
10086
10108
  var particleFrag = "#version 100\nprecision mediump float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nvarying vec4 vTexCoordBlend;\n#endif\nvarying float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){gl_FragColor=uPreviewColor;}\n#else\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}if(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);gl_FragColor=color;}\n#endif\n";
10087
10109
 
@@ -10610,6 +10632,9 @@ var seed$5 = 1;
10610
10632
  this.renderer = renderer;
10611
10633
  if (postProcessingEnabled) {
10612
10634
  var enableHDR = true;
10635
+ if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
10636
+ throw new Error("Half float texture is not supported.");
10637
+ }
10613
10638
  // 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
10614
10639
  var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
10615
10640
  attachments = [
@@ -11330,7 +11355,7 @@ var FinalCopyRP = /*#__PURE__*/ function(RenderPass) {
11330
11355
  var GlobalUniforms = function GlobalUniforms() {
11331
11356
  this.floats = {};
11332
11357
  this.ints = {};
11333
- // vector3s: Record<string, vec3> = {};
11358
+ this.vector3s = {};
11334
11359
  this.vector4s = {};
11335
11360
  this.matrices = {};
11336
11361
  //...
@@ -11571,6 +11596,9 @@ var Renderer = /*#__PURE__*/ function() {
11571
11596
  _proto.setGlobalVector4 = function setGlobalVector4(name, value) {
11572
11597
  // OVERRIDE
11573
11598
  };
11599
+ _proto.setGlobalVector3 = function setGlobalVector3(name, value) {
11600
+ // OVERRIDE
11601
+ };
11574
11602
  _proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
11575
11603
  // OVERRIDE
11576
11604
  };
@@ -13236,10 +13264,10 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
13236
13264
  }
13237
13265
  var _proto = Vector4Curve.prototype;
13238
13266
  _proto.onCreate = function onCreate(arg) {
13239
- this.xCurve = createValueGetter(arg.x);
13240
- this.yCurve = createValueGetter(arg.y);
13241
- this.zCurve = createValueGetter(arg.z);
13242
- this.wCurve = createValueGetter(arg.w);
13267
+ this.xCurve = createValueGetter(arg[0]);
13268
+ this.yCurve = createValueGetter(arg[1]);
13269
+ this.zCurve = createValueGetter(arg[2]);
13270
+ this.wCurve = createValueGetter(arg[3]);
13243
13271
  };
13244
13272
  _proto.getValue = function getValue(t) {
13245
13273
  var x = this.xCurve.getValue(t);
@@ -13339,10 +13367,10 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13339
13367
  }
13340
13368
  var _proto = ColorCurve.prototype;
13341
13369
  _proto.onCreate = function onCreate(arg) {
13342
- this.rCurve = createValueGetter(arg.r);
13343
- this.gCurve = createValueGetter(arg.g);
13344
- this.bCurve = createValueGetter(arg.b);
13345
- this.aCurve = createValueGetter(arg.a);
13370
+ this.rCurve = createValueGetter(arg[0]);
13371
+ this.gCurve = createValueGetter(arg[1]);
13372
+ this.bCurve = createValueGetter(arg[2]);
13373
+ this.aCurve = createValueGetter(arg[3]);
13346
13374
  };
13347
13375
  _proto.getValue = function getValue(t) {
13348
13376
  var r = this.rCurve.getValue(t);
@@ -13444,7 +13472,7 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13444
13472
  * @param texture - 纹理对象
13445
13473
  */ _proto.setTexture = function setTexture(texture) {
13446
13474
  this.renderer.texture = texture;
13447
- this.material.setTexture("uSampler0", texture);
13475
+ this.material.setTexture("_MainTex", texture);
13448
13476
  };
13449
13477
  /**
13450
13478
  * @internal
@@ -13523,15 +13551,7 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13523
13551
  geometry.setIndexData(indexData);
13524
13552
  geometry.setAttributeData("atlasOffset", attributes.atlasOffset);
13525
13553
  geometry.setDrawCount(data.index.length);
13526
- for(var i = 0; i < textures.length; i++){
13527
- var texture1 = textures[i];
13528
- material.setTexture("uSampler" + i, texture1);
13529
- }
13530
- // FIXME: 内存泄漏的临时方案,后面再调整
13531
- var emptyTexture = this.emptyTexture;
13532
- for(var k = textures.length; k < exports.maxSpriteMeshItemCount; k++){
13533
- material.setTexture("uSampler" + k, emptyTexture);
13534
- }
13554
+ material.setTexture("_MainTex", texture);
13535
13555
  };
13536
13556
  _proto.getItemGeometryData = function getItemGeometryData() {
13537
13557
  var renderer = this.renderer;
@@ -13649,7 +13669,7 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13649
13669
  setBlendMode(material, states.blendMode);
13650
13670
  setMaskMode(material, states.maskMode);
13651
13671
  setSideMode(material, states.side);
13652
- material.shader.shaderData.properties = 'uSampler0("uSampler0",2D) = "white" {}';
13672
+ material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
13653
13673
  if (!material.hasUniform("_Color")) {
13654
13674
  material.setVector4("_Color", new Vector4(0, 0, 0, 1));
13655
13675
  }
@@ -15387,6 +15407,329 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15387
15407
  return PolyStar;
15388
15408
  }(ShapePrimitive);
15389
15409
 
15410
+ // const tempPoints = [new Point(), new Point(), new Point(), new Point()];
15411
+ /**
15412
+ * The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
15413
+ * point (`x`, `y`) and by its `width` and its `height`.
15414
+ */ var Rectangle$1 = /*#__PURE__*/ function(ShapePrimitive) {
15415
+ _inherits(Rectangle, ShapePrimitive);
15416
+ function Rectangle(x, y, width, height) {
15417
+ if (x === void 0) x = 0;
15418
+ if (y === void 0) y = 0;
15419
+ if (width === void 0) width = 0;
15420
+ if (height === void 0) height = 0;
15421
+ var _this;
15422
+ _this = ShapePrimitive.call(this) || this;
15423
+ _this.x = Number(x);
15424
+ _this.y = Number(y);
15425
+ _this.width = Number(width);
15426
+ _this.height = Number(height);
15427
+ return _this;
15428
+ }
15429
+ var _proto = Rectangle.prototype;
15430
+ /** Determines whether the Rectangle is empty. */ _proto.isEmpty = function isEmpty() {
15431
+ return this.left === this.right || this.top === this.bottom;
15432
+ };
15433
+ /**
15434
+ * Creates a clone of this Rectangle
15435
+ * @returns a copy of the rectangle
15436
+ */ _proto.clone = function clone() {
15437
+ return new Rectangle(this.x, this.y, this.width, this.height);
15438
+ };
15439
+ /**
15440
+ * Converts a Bounds object to a Rectangle object.
15441
+ * @param bounds - The bounds to copy and convert to a rectangle.
15442
+ * @returns Returns itself.
15443
+ */ // copyFromBounds (bounds: Bounds): this {
15444
+ // this.x = bounds.minX;
15445
+ // this.y = bounds.minY;
15446
+ // this.width = bounds.maxX - bounds.minX;
15447
+ // this.height = bounds.maxY - bounds.minY;
15448
+ // return this;
15449
+ // }
15450
+ /**
15451
+ * Copies another rectangle to this one.
15452
+ * @param rectangle - The rectangle to copy from.
15453
+ * @returns Returns itself.
15454
+ */ _proto.copyFrom = function copyFrom(rectangle) {
15455
+ this.x = rectangle.x;
15456
+ this.y = rectangle.y;
15457
+ this.width = rectangle.width;
15458
+ this.height = rectangle.height;
15459
+ return this;
15460
+ };
15461
+ /**
15462
+ * Copies this rectangle to another one.
15463
+ * @param rectangle - The rectangle to copy to.
15464
+ * @returns Returns given parameter.
15465
+ */ _proto.copyTo = function copyTo(rectangle) {
15466
+ rectangle.copyFrom(this);
15467
+ return rectangle;
15468
+ };
15469
+ /**
15470
+ * Checks whether the x and y coordinates given are contained within this Rectangle
15471
+ * @param x - The X coordinate of the point to test
15472
+ * @param y - The Y coordinate of the point to test
15473
+ * @returns Whether the x/y coordinates are within this Rectangle
15474
+ */ _proto.contains = function contains(x, y) {
15475
+ if (this.width <= 0 || this.height <= 0) {
15476
+ return false;
15477
+ }
15478
+ if (x >= this.x && x < this.x + this.width) {
15479
+ if (y >= this.y && y < this.y + this.height) {
15480
+ return true;
15481
+ }
15482
+ }
15483
+ return false;
15484
+ };
15485
+ /**
15486
+ * Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
15487
+ * @param x - The X coordinate of the point to test
15488
+ * @param y - The Y coordinate of the point to test
15489
+ * @param strokeWidth - The width of the line to check
15490
+ * @returns Whether the x/y coordinates are within this rectangle
15491
+ */ _proto.strokeContains = function strokeContains(x, y, strokeWidth) {
15492
+ var _this = this, width = _this.width, height = _this.height;
15493
+ if (width <= 0 || height <= 0) {
15494
+ return false;
15495
+ }
15496
+ var _x = this.x;
15497
+ var _y = this.y;
15498
+ var outerLeft = _x - strokeWidth / 2;
15499
+ var outerRight = _x + width + strokeWidth / 2;
15500
+ var outerTop = _y - strokeWidth / 2;
15501
+ var outerBottom = _y + height + strokeWidth / 2;
15502
+ var innerLeft = _x + strokeWidth / 2;
15503
+ var innerRight = _x + width - strokeWidth / 2;
15504
+ var innerTop = _y + strokeWidth / 2;
15505
+ var innerBottom = _y + height - strokeWidth / 2;
15506
+ return x >= outerLeft && x <= outerRight && y >= outerTop && y <= outerBottom && !(x > innerLeft && x < innerRight && y > innerTop && y < innerBottom);
15507
+ };
15508
+ /**
15509
+ * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
15510
+ * Returns true only if the area of the intersection is >0, this means that Rectangles
15511
+ * sharing a side are not overlapping. Another side effect is that an arealess rectangle
15512
+ * (width or height equal to zero) can't intersect any other rectangle.
15513
+ * @param {Rectangle} other - The Rectangle to intersect with `this`.
15514
+ * @param {Matrix} transform - The transformation matrix of `other`.
15515
+ * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
15516
+ */ // intersects (other: Rectangle, transform?: Matrix4): boolean {
15517
+ // if (!transform) {
15518
+ // const x0 = this.x < other.x ? other.x : this.x;
15519
+ // const x1 = this.right > other.right ? other.right : this.right;
15520
+ // if (x1 <= x0) {
15521
+ // return false;
15522
+ // }
15523
+ // const y0 = this.y < other.y ? other.y : this.y;
15524
+ // const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;
15525
+ // return y1 > y0;
15526
+ // }
15527
+ // const x0 = this.left;
15528
+ // const x1 = this.right;
15529
+ // const y0 = this.top;
15530
+ // const y1 = this.bottom;
15531
+ // if (x1 <= x0 || y1 <= y0) {
15532
+ // return false;
15533
+ // }
15534
+ // const lt = tempPoints[0].set(other.left, other.top);
15535
+ // const lb = tempPoints[1].set(other.left, other.bottom);
15536
+ // const rt = tempPoints[2].set(other.right, other.top);
15537
+ // const rb = tempPoints[3].set(other.right, other.bottom);
15538
+ // if (rt.x <= lt.x || lb.y <= lt.y) {
15539
+ // return false;
15540
+ // }
15541
+ // const s = Math.sign((transform.a * transform.d) - (transform.b * transform.c));
15542
+ // if (s === 0) {
15543
+ // return false;
15544
+ // }
15545
+ // transform.apply(lt, lt);
15546
+ // transform.apply(lb, lb);
15547
+ // transform.apply(rt, rt);
15548
+ // transform.apply(rb, rb);
15549
+ // if (Math.max(lt.x, lb.x, rt.x, rb.x) <= x0
15550
+ // || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1
15551
+ // || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0
15552
+ // || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1) {
15553
+ // return false;
15554
+ // }
15555
+ // const nx = s * (lb.y - lt.y);
15556
+ // const ny = s * (lt.x - lb.x);
15557
+ // const n00 = (nx * x0) + (ny * y0);
15558
+ // const n10 = (nx * x1) + (ny * y0);
15559
+ // const n01 = (nx * x0) + (ny * y1);
15560
+ // const n11 = (nx * x1) + (ny * y1);
15561
+ // if (Math.max(n00, n10, n01, n11) <= (nx * lt.x) + (ny * lt.y)
15562
+ // || Math.min(n00, n10, n01, n11) >= (nx * rb.x) + (ny * rb.y)) {
15563
+ // return false;
15564
+ // }
15565
+ // const mx = s * (lt.y - rt.y);
15566
+ // const my = s * (rt.x - lt.x);
15567
+ // const m00 = (mx * x0) + (my * y0);
15568
+ // const m10 = (mx * x1) + (my * y0);
15569
+ // const m01 = (mx * x0) + (my * y1);
15570
+ // const m11 = (mx * x1) + (my * y1);
15571
+ // if (Math.max(m00, m10, m01, m11) <= (mx * lt.x) + (my * lt.y)
15572
+ // || Math.min(m00, m10, m01, m11) >= (mx * rb.x) + (my * rb.y)) {
15573
+ // return false;
15574
+ // }
15575
+ // return true;
15576
+ // }
15577
+ /**
15578
+ * Pads the rectangle making it grow in all directions.
15579
+ * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
15580
+ * @param paddingX - The horizontal padding amount.
15581
+ * @param paddingY - The vertical padding amount.
15582
+ * @returns Returns itself.
15583
+ */ _proto.pad = function pad(paddingX, paddingY) {
15584
+ if (paddingX === void 0) paddingX = 0;
15585
+ if (paddingY === void 0) paddingY = paddingX;
15586
+ this.x -= paddingX;
15587
+ this.y -= paddingY;
15588
+ this.width += paddingX * 2;
15589
+ this.height += paddingY * 2;
15590
+ return this;
15591
+ };
15592
+ /**
15593
+ * Fits this rectangle around the passed one.
15594
+ * @param rectangle - The rectangle to fit.
15595
+ * @returns Returns itself.
15596
+ */ _proto.fit = function fit(rectangle) {
15597
+ var x1 = Math.max(this.x, rectangle.x);
15598
+ var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
15599
+ var y1 = Math.max(this.y, rectangle.y);
15600
+ var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
15601
+ this.x = x1;
15602
+ this.width = Math.max(x2 - x1, 0);
15603
+ this.y = y1;
15604
+ this.height = Math.max(y2 - y1, 0);
15605
+ return this;
15606
+ };
15607
+ /**
15608
+ * Enlarges rectangle that way its corners lie on grid
15609
+ * @param resolution - resolution
15610
+ * @param eps - precision
15611
+ * @returns Returns itself.
15612
+ */ _proto.ceil = function ceil(resolution, eps) {
15613
+ if (resolution === void 0) resolution = 1;
15614
+ if (eps === void 0) eps = 0.001;
15615
+ var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;
15616
+ var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
15617
+ this.x = Math.floor((this.x + eps) * resolution) / resolution;
15618
+ this.y = Math.floor((this.y + eps) * resolution) / resolution;
15619
+ this.width = x2 - this.x;
15620
+ this.height = y2 - this.y;
15621
+ return this;
15622
+ };
15623
+ /**
15624
+ * Enlarges this rectangle to include the passed rectangle.
15625
+ * @param rectangle - The rectangle to include.
15626
+ * @returns Returns itself.
15627
+ */ _proto.enlarge = function enlarge(rectangle) {
15628
+ var x1 = Math.min(this.x, rectangle.x);
15629
+ var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
15630
+ var y1 = Math.min(this.y, rectangle.y);
15631
+ var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
15632
+ this.x = x1;
15633
+ this.width = x2 - x1;
15634
+ this.y = y1;
15635
+ this.height = y2 - y1;
15636
+ return this;
15637
+ };
15638
+ /**
15639
+ * Returns the framing rectangle of the rectangle as a Rectangle object
15640
+ * @param out - optional rectangle to store the result
15641
+ * @returns The framing rectangle
15642
+ */ _proto.getBounds = function getBounds(out) {
15643
+ out = out || new Rectangle();
15644
+ out.copyFrom(this);
15645
+ return out;
15646
+ };
15647
+ _proto.getX = function getX() {
15648
+ return this.x;
15649
+ };
15650
+ _proto.getY = function getY() {
15651
+ return this.y;
15652
+ };
15653
+ _proto.build = function build(points) {
15654
+ var x = this.x;
15655
+ var y = this.y;
15656
+ var width = this.width;
15657
+ var height = this.height;
15658
+ if (!(width >= 0 && height >= 0)) {
15659
+ return points;
15660
+ }
15661
+ points[0] = x;
15662
+ points[1] = y;
15663
+ points[2] = x + width;
15664
+ points[3] = y;
15665
+ points[4] = x + width;
15666
+ points[5] = y + height;
15667
+ points[6] = x;
15668
+ points[7] = y + height;
15669
+ return points;
15670
+ };
15671
+ _proto.triangulate = function triangulate(points, vertices, verticesOffset, indices, indicesOffset) {
15672
+ var count = 0;
15673
+ var verticesStride = 2;
15674
+ verticesOffset *= verticesStride;
15675
+ vertices[verticesOffset + count] = points[0];
15676
+ vertices[verticesOffset + count + 1] = points[1];
15677
+ count += verticesStride;
15678
+ vertices[verticesOffset + count] = points[2];
15679
+ vertices[verticesOffset + count + 1] = points[3];
15680
+ count += verticesStride;
15681
+ vertices[verticesOffset + count] = points[6];
15682
+ vertices[verticesOffset + count + 1] = points[7];
15683
+ count += verticesStride;
15684
+ vertices[verticesOffset + count] = points[4];
15685
+ vertices[verticesOffset + count + 1] = points[5];
15686
+ count += verticesStride;
15687
+ var verticesIndex = verticesOffset / verticesStride;
15688
+ // triangle 1
15689
+ indices[indicesOffset++] = verticesIndex;
15690
+ indices[indicesOffset++] = verticesIndex + 1;
15691
+ indices[indicesOffset++] = verticesIndex + 2;
15692
+ // triangle 2
15693
+ indices[indicesOffset++] = verticesIndex + 1;
15694
+ indices[indicesOffset++] = verticesIndex + 3;
15695
+ indices[indicesOffset++] = verticesIndex + 2;
15696
+ };
15697
+ _create_class(Rectangle, [
15698
+ {
15699
+ key: "left",
15700
+ get: /** Returns the left edge of the rectangle. */ function get() {
15701
+ return this.x;
15702
+ }
15703
+ },
15704
+ {
15705
+ key: "right",
15706
+ get: /** Returns the right edge of the rectangle. */ function get() {
15707
+ return this.x + this.width;
15708
+ }
15709
+ },
15710
+ {
15711
+ key: "top",
15712
+ get: /** Returns the top edge of the rectangle. */ function get() {
15713
+ return this.y;
15714
+ }
15715
+ },
15716
+ {
15717
+ key: "bottom",
15718
+ get: /** Returns the bottom edge of the rectangle. */ function get() {
15719
+ return this.y + this.height;
15720
+ }
15721
+ }
15722
+ ], [
15723
+ {
15724
+ key: "EMPTY",
15725
+ get: /** A constant empty rectangle. This is a new object every time the property is accessed */ function get() {
15726
+ return new Rectangle(0, 0, 0, 0);
15727
+ }
15728
+ }
15729
+ ]);
15730
+ return Rectangle;
15731
+ }(ShapePrimitive);
15732
+
15390
15733
  var ShapePath = /*#__PURE__*/ function() {
15391
15734
  function ShapePath(graphicsPath) {
15392
15735
  this.graphicsPath = graphicsPath;
@@ -15423,6 +15766,11 @@ var ShapePath = /*#__PURE__*/ function() {
15423
15766
  this.polyStar(data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
15424
15767
  break;
15425
15768
  }
15769
+ case "rect":
15770
+ {
15771
+ this.rect(data[0], data[1], data[2], data[3], data[4]);
15772
+ break;
15773
+ }
15426
15774
  }
15427
15775
  }
15428
15776
  this.endPoly();
@@ -15468,6 +15816,18 @@ var ShapePath = /*#__PURE__*/ function() {
15468
15816
  return this;
15469
15817
  };
15470
15818
  /**
15819
+ * Draws a rectangle shape. This method adds a new rectangle path to the current drawing.
15820
+ * @param x - The x-coordinate of the upper-left corner of the rectangle.
15821
+ * @param y - The y-coordinate of the upper-left corner of the rectangle.
15822
+ * @param w - The width of the rectangle.
15823
+ * @param h - The height of the rectangle.
15824
+ * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
15825
+ * @returns The instance of the current object for chaining.
15826
+ */ _proto.rect = function rect(x, y, w, h, transform) {
15827
+ this.drawShape(new Rectangle$1(x, y, w, h), transform);
15828
+ return this;
15829
+ };
15830
+ /**
15471
15831
  * Draws a given shape on the canvas.
15472
15832
  * This is a generic method that can draw any type of shape specified by the `ShapePrimitive` parameter.
15473
15833
  * An optional transformation matrix can be applied to the shape, allowing for complex transformations.
@@ -15603,8 +15963,8 @@ var GraphicsPath = /*#__PURE__*/ function() {
15603
15963
  };
15604
15964
  /**
15605
15965
  * Draws a rectangle shape. This method adds a new rectangle path to the current drawing.
15606
- * @param x - The x-coordinate of the top-left corner of the rectangle.
15607
- * @param y - The y-coordinate of the top-left corner of the rectangle.
15966
+ * @param x - The x-coordinate of the upper-left corner of the rectangle.
15967
+ * @param y - The y-coordinate of the upper-left corner of the rectangle.
15608
15968
  * @param w - The width of the rectangle.
15609
15969
  * @param h - The height of the rectangle.
15610
15970
  * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
@@ -15830,7 +16190,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15830
16190
  case 1:
15831
16191
  {
15832
16192
  var rectangleData = shapeData;
15833
- this.path.rect(-rectangleData.width / 2, rectangleData.height / 2, rectangleData.width, rectangleData.height);
16193
+ this.path.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
15834
16194
  this.setFillColor(rectangleData.fill);
15835
16195
  break;
15836
16196
  }
@@ -16457,7 +16817,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16457
16817
  _proto.onDisable = function onDisable() {
16458
16818
  if (this.item && this.item.composition) {
16459
16819
  var _this_previewContent;
16460
- if (this.duringPlay) {
16820
+ if (this.duringPlay && !this.item.transform.getValid()) {
16461
16821
  this.item.composition.removeInteractiveItem(this.item, this.item.props.content.options.type);
16462
16822
  this.duringPlay = false;
16463
16823
  }
@@ -16660,10 +17020,10 @@ function shouldIgnoreBouncing(arg, mul) {
16660
17020
  return this.boundingBoxData;
16661
17021
  };
16662
17022
  _proto.getBoundingBox = function getBoundingBox() {
16663
- var maxX = 0;
16664
- var maxY = 0;
16665
- var minX = 0;
16666
- var minY = 0;
17023
+ var maxX = -Number.MAX_VALUE;
17024
+ var maxY = -Number.MAX_VALUE;
17025
+ var minX = Number.MAX_VALUE;
17026
+ var minY = Number.MAX_VALUE;
16667
17027
  for(var _iterator = _create_for_of_iterator_helper_loose(this.boundingBoxData.area), _step; !(_step = _iterator()).done;){
16668
17028
  var triangle = _step.value;
16669
17029
  maxX = Math.max(triangle.p0.x, triangle.p1.x, triangle.p2.x, maxX);
@@ -18080,7 +18440,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
18080
18440
  options: {}
18081
18441
  };
18082
18442
  }
18083
- if (duration <= 0) {
18443
+ if (duration < 0) {
18084
18444
  throw new Error("Item duration can't be less than 0, see " + HELP_LINK["Item duration can't be less than 0"] + ".");
18085
18445
  }
18086
18446
  this.rendererComponents.length = 0;
@@ -18441,6 +18801,16 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
18441
18801
  }
18442
18802
  var life = Math.min(Math.max(time / duration, 0.0), 1.0);
18443
18803
  var ta = this.textureSheetAnimation;
18804
+ var video = this.renderer.texture.source.video;
18805
+ if (video) {
18806
+ if (time === 0) {
18807
+ video.pause();
18808
+ } else {
18809
+ video.play().catch(function(e) {
18810
+ _this.engine.renderErrors.add(e);
18811
+ });
18812
+ }
18813
+ }
18444
18814
  if (ta) {
18445
18815
  var _this_material_getVector4;
18446
18816
  var total = ta.total || ta.row * ta.col;
@@ -18495,16 +18865,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
18495
18865
  dy
18496
18866
  ]);
18497
18867
  }
18498
- var video = this.renderer.texture.source.video;
18499
- if (video) {
18500
- if (time === 0 || time === this.item.duration) {
18501
- video.pause();
18502
- } else {
18503
- video.play().catch(function(e) {
18504
- _this.engine.renderErrors.add(e);
18505
- });
18506
- }
18507
- }
18508
18868
  };
18509
18869
  _proto.onDestroy = function onDestroy() {
18510
18870
  if (this.item && this.item.composition) {
@@ -24001,6 +24361,51 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24001
24361
  return Vector4PropertyMixerPlayable;
24002
24362
  }(Playable);
24003
24363
 
24364
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24365
+ _inherits(ColorPropertyMixerPlayable, Playable);
24366
+ function ColorPropertyMixerPlayable() {
24367
+ var _this;
24368
+ _this = Playable.apply(this, arguments) || this;
24369
+ _this.propertyName = "";
24370
+ return _this;
24371
+ }
24372
+ var _proto = ColorPropertyMixerPlayable.prototype;
24373
+ _proto.processFrame = function processFrame(context) {
24374
+ var boundObject = context.output.getUserData();
24375
+ if (!boundObject) {
24376
+ return;
24377
+ }
24378
+ var hasInput = false;
24379
+ var value = boundObject[this.propertyName];
24380
+ if (!_instanceof1(value, Color)) {
24381
+ return;
24382
+ }
24383
+ value.setZero();
24384
+ // evaluate the curve
24385
+ for(var i = 0; i < this.getInputCount(); i++){
24386
+ var weight = this.getInputWeight(i);
24387
+ if (weight > 0) {
24388
+ var propertyClipPlayable = this.getInput(i);
24389
+ if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24390
+ console.error("ColorPropertyMixerPlayable received incompatible input");
24391
+ continue;
24392
+ }
24393
+ var curveValue = propertyClipPlayable.value;
24394
+ value.r += curveValue.r * weight;
24395
+ value.g += curveValue.g * weight;
24396
+ value.b += curveValue.b * weight;
24397
+ value.a += curveValue.a * weight;
24398
+ hasInput = true;
24399
+ }
24400
+ }
24401
+ // set value
24402
+ if (hasInput) {
24403
+ boundObject[this.propertyName] = value;
24404
+ }
24405
+ };
24406
+ return ColorPropertyMixerPlayable;
24407
+ }(Playable);
24408
+
24004
24409
  var PropertyTrack = /*#__PURE__*/ function(TrackAsset) {
24005
24410
  _inherits(PropertyTrack, TrackAsset);
24006
24411
  function PropertyTrack() {
@@ -24160,7 +24565,7 @@ exports.ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24160
24565
  }
24161
24566
  var _proto = ColorPropertyTrack.prototype;
24162
24567
  _proto.createTrackMixer = function createTrackMixer(graph) {
24163
- var mixer = new FloatPropertyMixerPlayable(graph);
24568
+ var mixer = new ColorPropertyMixerPlayable(graph);
24164
24569
  var propertyNames = this.propertyNames;
24165
24570
  if (propertyNames.length > 0) {
24166
24571
  var propertyName = propertyNames[propertyNames.length - 1];
@@ -24174,6 +24579,27 @@ exports.ColorPropertyTrack = __decorate([
24174
24579
  effectsClass(DataType.ColorPropertyTrack)
24175
24580
  ], exports.ColorPropertyTrack);
24176
24581
 
24582
+ exports.ColorPropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
24583
+ _inherits(ColorPropertyPlayableAsset, PlayableAsset);
24584
+ function ColorPropertyPlayableAsset() {
24585
+ return PlayableAsset.apply(this, arguments);
24586
+ }
24587
+ var _proto = ColorPropertyPlayableAsset.prototype;
24588
+ _proto.createPlayable = function createPlayable(graph) {
24589
+ var clipPlayable = new PropertyClipPlayable(graph);
24590
+ clipPlayable.curve = createValueGetter(this.curveData);
24591
+ clipPlayable.value = clipPlayable.curve.getValue(0);
24592
+ return clipPlayable;
24593
+ };
24594
+ return ColorPropertyPlayableAsset;
24595
+ }(PlayableAsset);
24596
+ __decorate([
24597
+ serialize()
24598
+ ], exports.ColorPropertyPlayableAsset.prototype, "curveData", void 0);
24599
+ exports.ColorPropertyPlayableAsset = __decorate([
24600
+ effectsClass(DataType.ColorPropertyPlayableAsset)
24601
+ ], exports.ColorPropertyPlayableAsset);
24602
+
24177
24603
  exports.FloatPropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
24178
24604
  _inherits(FloatPropertyPlayableAsset, PlayableAsset);
24179
24605
  function FloatPropertyPlayableAsset() {
@@ -24378,6 +24804,27 @@ function compareTracks(a, b) {
24378
24804
  }
24379
24805
  }
24380
24806
 
24807
+ exports.Vector4PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
24808
+ _inherits(Vector4PropertyPlayableAsset, PlayableAsset);
24809
+ function Vector4PropertyPlayableAsset() {
24810
+ return PlayableAsset.apply(this, arguments);
24811
+ }
24812
+ var _proto = Vector4PropertyPlayableAsset.prototype;
24813
+ _proto.createPlayable = function createPlayable(graph) {
24814
+ var clipPlayable = new PropertyClipPlayable(graph);
24815
+ clipPlayable.curve = createValueGetter(this.curveData);
24816
+ clipPlayable.value = clipPlayable.curve.getValue(0);
24817
+ return clipPlayable;
24818
+ };
24819
+ return Vector4PropertyPlayableAsset;
24820
+ }(PlayableAsset);
24821
+ __decorate([
24822
+ serialize()
24823
+ ], exports.Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
24824
+ exports.Vector4PropertyPlayableAsset = __decorate([
24825
+ effectsClass("Vector4PropertyPlayableAsset")
24826
+ ], exports.Vector4PropertyPlayableAsset);
24827
+
24381
24828
  exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24382
24829
  _inherits(ObjectBindingTrack, TrackAsset1);
24383
24830
  function ObjectBindingTrack() {
@@ -24982,7 +25429,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
24982
25429
  }
24983
25430
  //与 toDataURL() 两种方式都需要像素读取操作
24984
25431
  var imageData = context.getImageData(0, 0, this.canvas.width, this.canvas.height);
24985
- this.material.setTexture("uSampler0", Texture.createWithData(this.engine, {
25432
+ this.material.setTexture("_MainTex", Texture.createWithData(this.engine, {
24986
25433
  data: new Uint8Array(imageData.data),
24987
25434
  width: imageData.width,
24988
25435
  height: imageData.height
@@ -28180,7 +28627,7 @@ var listOrder = 0;
28180
28627
  var itemProps = sourceItemData;
28181
28628
  if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
28182
28629
  itemProps.listIndex = listOrder++;
28183
- if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || //@ts-expect-error
28630
+ if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || //@ts-expect-error
28184
28631
  itemProps.type === ItemType.shape) {
28185
28632
  for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
28186
28633
  var componentPath = _step2.value;
@@ -28221,8 +28668,10 @@ var listOrder = 0;
28221
28668
  shapeData = shape;
28222
28669
  }
28223
28670
  if (shapeData !== undefined) {
28224
- // @ts-expect-error 类型转换问题
28225
- renderContent.renderer.shape = getGeometryByShape(shapeData, split);
28671
+ if (!("aPoint" in shapeData && "index" in shapeData)) {
28672
+ // @ts-expect-error 类型转换问题
28673
+ renderContent.renderer.shape = getGeometryByShape(shapeData, split);
28674
+ }
28226
28675
  }
28227
28676
  }
28228
28677
  if ("trails" in renderContent && renderContent.trails !== undefined) {
@@ -31138,7 +31587,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
31138
31587
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
31139
31588
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
31140
31589
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
31141
- var version = "2.1.0-alpha.12";
31590
+ var version = "2.1.0-alpha.13";
31142
31591
  logger.info("Core version: " + version + ".");
31143
31592
 
31144
31593
  exports.AbstractPlugin = AbstractPlugin;