@galacean/effects-threejs 2.1.0-alpha.11 → 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 threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.1.0-alpha.11
6
+ * Version: v2.1.0-alpha.13
7
7
  */
8
8
 
9
9
  'use strict';
@@ -6967,6 +6967,28 @@ exports.MaterialRenderType = void 0;
6967
6967
  this.shaderDirty = true;
6968
6968
  }
6969
6969
  },
6970
+ {
6971
+ key: "mainTexture",
6972
+ get: /**
6973
+ * 材质的主纹理
6974
+ */ function get() {
6975
+ return this.getTexture("_MainTex");
6976
+ },
6977
+ set: function set(value) {
6978
+ this.setTexture("_MainTex", value);
6979
+ }
6980
+ },
6981
+ {
6982
+ key: "color",
6983
+ get: /**
6984
+ * 材质的主颜色
6985
+ */ function get() {
6986
+ return this.getColor("_Color");
6987
+ },
6988
+ set: function set(value) {
6989
+ this.setColor("_Color", value);
6990
+ }
6991
+ },
6970
6992
  {
6971
6993
  key: "blending",
6972
6994
  set: /******** effects-core 中会调用 引擎必须实现 ***********************/ /**
@@ -10103,7 +10125,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10103
10125
 
10104
10126
  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}";
10105
10127
 
10106
- 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;}";
10128
+ 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;}";
10107
10129
 
10108
10130
  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";
10109
10131
 
@@ -10632,6 +10654,9 @@ var seed$6 = 1;
10632
10654
  this.renderer = renderer;
10633
10655
  if (postProcessingEnabled) {
10634
10656
  var enableHDR = true;
10657
+ if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
10658
+ throw new Error("Half float texture is not supported.");
10659
+ }
10635
10660
  // 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
10636
10661
  var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
10637
10662
  attachments = [
@@ -11352,7 +11377,7 @@ var FinalCopyRP = /*#__PURE__*/ function(RenderPass) {
11352
11377
  var GlobalUniforms = function GlobalUniforms() {
11353
11378
  this.floats = {};
11354
11379
  this.ints = {};
11355
- // vector3s: Record<string, vec3> = {};
11380
+ this.vector3s = {};
11356
11381
  this.vector4s = {};
11357
11382
  this.matrices = {};
11358
11383
  //...
@@ -11593,6 +11618,9 @@ var Renderer = /*#__PURE__*/ function() {
11593
11618
  _proto.setGlobalVector4 = function setGlobalVector4(name, value) {
11594
11619
  // OVERRIDE
11595
11620
  };
11621
+ _proto.setGlobalVector3 = function setGlobalVector3(name, value) {
11622
+ // OVERRIDE
11623
+ };
11596
11624
  _proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
11597
11625
  // OVERRIDE
11598
11626
  };
@@ -13258,10 +13286,10 @@ var Vector4Curve = /*#__PURE__*/ function(ValueGetter) {
13258
13286
  }
13259
13287
  var _proto = Vector4Curve.prototype;
13260
13288
  _proto.onCreate = function onCreate(arg) {
13261
- this.xCurve = createValueGetter(arg.x);
13262
- this.yCurve = createValueGetter(arg.y);
13263
- this.zCurve = createValueGetter(arg.z);
13264
- this.wCurve = createValueGetter(arg.w);
13289
+ this.xCurve = createValueGetter(arg[0]);
13290
+ this.yCurve = createValueGetter(arg[1]);
13291
+ this.zCurve = createValueGetter(arg[2]);
13292
+ this.wCurve = createValueGetter(arg[3]);
13265
13293
  };
13266
13294
  _proto.getValue = function getValue(t) {
13267
13295
  var x = this.xCurve.getValue(t);
@@ -13361,10 +13389,10 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13361
13389
  }
13362
13390
  var _proto = ColorCurve.prototype;
13363
13391
  _proto.onCreate = function onCreate(arg) {
13364
- this.rCurve = createValueGetter(arg.r);
13365
- this.gCurve = createValueGetter(arg.g);
13366
- this.bCurve = createValueGetter(arg.b);
13367
- this.aCurve = createValueGetter(arg.a);
13392
+ this.rCurve = createValueGetter(arg[0]);
13393
+ this.gCurve = createValueGetter(arg[1]);
13394
+ this.bCurve = createValueGetter(arg[2]);
13395
+ this.aCurve = createValueGetter(arg[3]);
13368
13396
  };
13369
13397
  _proto.getValue = function getValue(t) {
13370
13398
  var r = this.rCurve.getValue(t);
@@ -13466,7 +13494,7 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13466
13494
  * @param texture - 纹理对象
13467
13495
  */ _proto.setTexture = function setTexture(texture) {
13468
13496
  this.renderer.texture = texture;
13469
- this.material.setTexture("uSampler0", texture);
13497
+ this.material.setTexture("_MainTex", texture);
13470
13498
  };
13471
13499
  /**
13472
13500
  * @internal
@@ -13545,15 +13573,7 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13545
13573
  geometry.setIndexData(indexData);
13546
13574
  geometry.setAttributeData("atlasOffset", attributes.atlasOffset);
13547
13575
  geometry.setDrawCount(data.index.length);
13548
- for(var i = 0; i < textures.length; i++){
13549
- var texture1 = textures[i];
13550
- material.setTexture("uSampler" + i, texture1);
13551
- }
13552
- // FIXME: 内存泄漏的临时方案,后面再调整
13553
- var emptyTexture = this.emptyTexture;
13554
- for(var k = textures.length; k < exports.maxSpriteMeshItemCount; k++){
13555
- material.setTexture("uSampler" + k, emptyTexture);
13556
- }
13576
+ material.setTexture("_MainTex", texture);
13557
13577
  };
13558
13578
  _proto.getItemGeometryData = function getItemGeometryData() {
13559
13579
  var renderer = this.renderer;
@@ -13671,7 +13691,7 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13671
13691
  setBlendMode(material, states.blendMode);
13672
13692
  setMaskMode(material, states.maskMode);
13673
13693
  setSideMode(material, states.side);
13674
- material.shader.shaderData.properties = 'uSampler0("uSampler0",2D) = "white" {}';
13694
+ material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
13675
13695
  if (!material.hasUniform("_Color")) {
13676
13696
  material.setVector4("_Color", new Vector4(0, 0, 0, 1));
13677
13697
  }
@@ -15409,6 +15429,329 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15409
15429
  return PolyStar;
15410
15430
  }(ShapePrimitive);
15411
15431
 
15432
+ // const tempPoints = [new Point(), new Point(), new Point(), new Point()];
15433
+ /**
15434
+ * The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
15435
+ * point (`x`, `y`) and by its `width` and its `height`.
15436
+ */ var Rectangle$1 = /*#__PURE__*/ function(ShapePrimitive) {
15437
+ _inherits(Rectangle, ShapePrimitive);
15438
+ function Rectangle(x, y, width, height) {
15439
+ if (x === void 0) x = 0;
15440
+ if (y === void 0) y = 0;
15441
+ if (width === void 0) width = 0;
15442
+ if (height === void 0) height = 0;
15443
+ var _this;
15444
+ _this = ShapePrimitive.call(this) || this;
15445
+ _this.x = Number(x);
15446
+ _this.y = Number(y);
15447
+ _this.width = Number(width);
15448
+ _this.height = Number(height);
15449
+ return _this;
15450
+ }
15451
+ var _proto = Rectangle.prototype;
15452
+ /** Determines whether the Rectangle is empty. */ _proto.isEmpty = function isEmpty() {
15453
+ return this.left === this.right || this.top === this.bottom;
15454
+ };
15455
+ /**
15456
+ * Creates a clone of this Rectangle
15457
+ * @returns a copy of the rectangle
15458
+ */ _proto.clone = function clone() {
15459
+ return new Rectangle(this.x, this.y, this.width, this.height);
15460
+ };
15461
+ /**
15462
+ * Converts a Bounds object to a Rectangle object.
15463
+ * @param bounds - The bounds to copy and convert to a rectangle.
15464
+ * @returns Returns itself.
15465
+ */ // copyFromBounds (bounds: Bounds): this {
15466
+ // this.x = bounds.minX;
15467
+ // this.y = bounds.minY;
15468
+ // this.width = bounds.maxX - bounds.minX;
15469
+ // this.height = bounds.maxY - bounds.minY;
15470
+ // return this;
15471
+ // }
15472
+ /**
15473
+ * Copies another rectangle to this one.
15474
+ * @param rectangle - The rectangle to copy from.
15475
+ * @returns Returns itself.
15476
+ */ _proto.copyFrom = function copyFrom(rectangle) {
15477
+ this.x = rectangle.x;
15478
+ this.y = rectangle.y;
15479
+ this.width = rectangle.width;
15480
+ this.height = rectangle.height;
15481
+ return this;
15482
+ };
15483
+ /**
15484
+ * Copies this rectangle to another one.
15485
+ * @param rectangle - The rectangle to copy to.
15486
+ * @returns Returns given parameter.
15487
+ */ _proto.copyTo = function copyTo(rectangle) {
15488
+ rectangle.copyFrom(this);
15489
+ return rectangle;
15490
+ };
15491
+ /**
15492
+ * Checks whether the x and y coordinates given are contained within this Rectangle
15493
+ * @param x - The X coordinate of the point to test
15494
+ * @param y - The Y coordinate of the point to test
15495
+ * @returns Whether the x/y coordinates are within this Rectangle
15496
+ */ _proto.contains = function contains(x, y) {
15497
+ if (this.width <= 0 || this.height <= 0) {
15498
+ return false;
15499
+ }
15500
+ if (x >= this.x && x < this.x + this.width) {
15501
+ if (y >= this.y && y < this.y + this.height) {
15502
+ return true;
15503
+ }
15504
+ }
15505
+ return false;
15506
+ };
15507
+ /**
15508
+ * Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
15509
+ * @param x - The X coordinate of the point to test
15510
+ * @param y - The Y coordinate of the point to test
15511
+ * @param strokeWidth - The width of the line to check
15512
+ * @returns Whether the x/y coordinates are within this rectangle
15513
+ */ _proto.strokeContains = function strokeContains(x, y, strokeWidth) {
15514
+ var _this = this, width = _this.width, height = _this.height;
15515
+ if (width <= 0 || height <= 0) {
15516
+ return false;
15517
+ }
15518
+ var _x = this.x;
15519
+ var _y = this.y;
15520
+ var outerLeft = _x - strokeWidth / 2;
15521
+ var outerRight = _x + width + strokeWidth / 2;
15522
+ var outerTop = _y - strokeWidth / 2;
15523
+ var outerBottom = _y + height + strokeWidth / 2;
15524
+ var innerLeft = _x + strokeWidth / 2;
15525
+ var innerRight = _x + width - strokeWidth / 2;
15526
+ var innerTop = _y + strokeWidth / 2;
15527
+ var innerBottom = _y + height - strokeWidth / 2;
15528
+ return x >= outerLeft && x <= outerRight && y >= outerTop && y <= outerBottom && !(x > innerLeft && x < innerRight && y > innerTop && y < innerBottom);
15529
+ };
15530
+ /**
15531
+ * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
15532
+ * Returns true only if the area of the intersection is >0, this means that Rectangles
15533
+ * sharing a side are not overlapping. Another side effect is that an arealess rectangle
15534
+ * (width or height equal to zero) can't intersect any other rectangle.
15535
+ * @param {Rectangle} other - The Rectangle to intersect with `this`.
15536
+ * @param {Matrix} transform - The transformation matrix of `other`.
15537
+ * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
15538
+ */ // intersects (other: Rectangle, transform?: Matrix4): boolean {
15539
+ // if (!transform) {
15540
+ // const x0 = this.x < other.x ? other.x : this.x;
15541
+ // const x1 = this.right > other.right ? other.right : this.right;
15542
+ // if (x1 <= x0) {
15543
+ // return false;
15544
+ // }
15545
+ // const y0 = this.y < other.y ? other.y : this.y;
15546
+ // const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;
15547
+ // return y1 > y0;
15548
+ // }
15549
+ // const x0 = this.left;
15550
+ // const x1 = this.right;
15551
+ // const y0 = this.top;
15552
+ // const y1 = this.bottom;
15553
+ // if (x1 <= x0 || y1 <= y0) {
15554
+ // return false;
15555
+ // }
15556
+ // const lt = tempPoints[0].set(other.left, other.top);
15557
+ // const lb = tempPoints[1].set(other.left, other.bottom);
15558
+ // const rt = tempPoints[2].set(other.right, other.top);
15559
+ // const rb = tempPoints[3].set(other.right, other.bottom);
15560
+ // if (rt.x <= lt.x || lb.y <= lt.y) {
15561
+ // return false;
15562
+ // }
15563
+ // const s = Math.sign((transform.a * transform.d) - (transform.b * transform.c));
15564
+ // if (s === 0) {
15565
+ // return false;
15566
+ // }
15567
+ // transform.apply(lt, lt);
15568
+ // transform.apply(lb, lb);
15569
+ // transform.apply(rt, rt);
15570
+ // transform.apply(rb, rb);
15571
+ // if (Math.max(lt.x, lb.x, rt.x, rb.x) <= x0
15572
+ // || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1
15573
+ // || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0
15574
+ // || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1) {
15575
+ // return false;
15576
+ // }
15577
+ // const nx = s * (lb.y - lt.y);
15578
+ // const ny = s * (lt.x - lb.x);
15579
+ // const n00 = (nx * x0) + (ny * y0);
15580
+ // const n10 = (nx * x1) + (ny * y0);
15581
+ // const n01 = (nx * x0) + (ny * y1);
15582
+ // const n11 = (nx * x1) + (ny * y1);
15583
+ // if (Math.max(n00, n10, n01, n11) <= (nx * lt.x) + (ny * lt.y)
15584
+ // || Math.min(n00, n10, n01, n11) >= (nx * rb.x) + (ny * rb.y)) {
15585
+ // return false;
15586
+ // }
15587
+ // const mx = s * (lt.y - rt.y);
15588
+ // const my = s * (rt.x - lt.x);
15589
+ // const m00 = (mx * x0) + (my * y0);
15590
+ // const m10 = (mx * x1) + (my * y0);
15591
+ // const m01 = (mx * x0) + (my * y1);
15592
+ // const m11 = (mx * x1) + (my * y1);
15593
+ // if (Math.max(m00, m10, m01, m11) <= (mx * lt.x) + (my * lt.y)
15594
+ // || Math.min(m00, m10, m01, m11) >= (mx * rb.x) + (my * rb.y)) {
15595
+ // return false;
15596
+ // }
15597
+ // return true;
15598
+ // }
15599
+ /**
15600
+ * Pads the rectangle making it grow in all directions.
15601
+ * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
15602
+ * @param paddingX - The horizontal padding amount.
15603
+ * @param paddingY - The vertical padding amount.
15604
+ * @returns Returns itself.
15605
+ */ _proto.pad = function pad(paddingX, paddingY) {
15606
+ if (paddingX === void 0) paddingX = 0;
15607
+ if (paddingY === void 0) paddingY = paddingX;
15608
+ this.x -= paddingX;
15609
+ this.y -= paddingY;
15610
+ this.width += paddingX * 2;
15611
+ this.height += paddingY * 2;
15612
+ return this;
15613
+ };
15614
+ /**
15615
+ * Fits this rectangle around the passed one.
15616
+ * @param rectangle - The rectangle to fit.
15617
+ * @returns Returns itself.
15618
+ */ _proto.fit = function fit(rectangle) {
15619
+ var x1 = Math.max(this.x, rectangle.x);
15620
+ var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
15621
+ var y1 = Math.max(this.y, rectangle.y);
15622
+ var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
15623
+ this.x = x1;
15624
+ this.width = Math.max(x2 - x1, 0);
15625
+ this.y = y1;
15626
+ this.height = Math.max(y2 - y1, 0);
15627
+ return this;
15628
+ };
15629
+ /**
15630
+ * Enlarges rectangle that way its corners lie on grid
15631
+ * @param resolution - resolution
15632
+ * @param eps - precision
15633
+ * @returns Returns itself.
15634
+ */ _proto.ceil = function ceil(resolution, eps) {
15635
+ if (resolution === void 0) resolution = 1;
15636
+ if (eps === void 0) eps = 0.001;
15637
+ var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;
15638
+ var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
15639
+ this.x = Math.floor((this.x + eps) * resolution) / resolution;
15640
+ this.y = Math.floor((this.y + eps) * resolution) / resolution;
15641
+ this.width = x2 - this.x;
15642
+ this.height = y2 - this.y;
15643
+ return this;
15644
+ };
15645
+ /**
15646
+ * Enlarges this rectangle to include the passed rectangle.
15647
+ * @param rectangle - The rectangle to include.
15648
+ * @returns Returns itself.
15649
+ */ _proto.enlarge = function enlarge(rectangle) {
15650
+ var x1 = Math.min(this.x, rectangle.x);
15651
+ var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
15652
+ var y1 = Math.min(this.y, rectangle.y);
15653
+ var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
15654
+ this.x = x1;
15655
+ this.width = x2 - x1;
15656
+ this.y = y1;
15657
+ this.height = y2 - y1;
15658
+ return this;
15659
+ };
15660
+ /**
15661
+ * Returns the framing rectangle of the rectangle as a Rectangle object
15662
+ * @param out - optional rectangle to store the result
15663
+ * @returns The framing rectangle
15664
+ */ _proto.getBounds = function getBounds(out) {
15665
+ out = out || new Rectangle();
15666
+ out.copyFrom(this);
15667
+ return out;
15668
+ };
15669
+ _proto.getX = function getX() {
15670
+ return this.x;
15671
+ };
15672
+ _proto.getY = function getY() {
15673
+ return this.y;
15674
+ };
15675
+ _proto.build = function build(points) {
15676
+ var x = this.x;
15677
+ var y = this.y;
15678
+ var width = this.width;
15679
+ var height = this.height;
15680
+ if (!(width >= 0 && height >= 0)) {
15681
+ return points;
15682
+ }
15683
+ points[0] = x;
15684
+ points[1] = y;
15685
+ points[2] = x + width;
15686
+ points[3] = y;
15687
+ points[4] = x + width;
15688
+ points[5] = y + height;
15689
+ points[6] = x;
15690
+ points[7] = y + height;
15691
+ return points;
15692
+ };
15693
+ _proto.triangulate = function triangulate(points, vertices, verticesOffset, indices, indicesOffset) {
15694
+ var count = 0;
15695
+ var verticesStride = 2;
15696
+ verticesOffset *= verticesStride;
15697
+ vertices[verticesOffset + count] = points[0];
15698
+ vertices[verticesOffset + count + 1] = points[1];
15699
+ count += verticesStride;
15700
+ vertices[verticesOffset + count] = points[2];
15701
+ vertices[verticesOffset + count + 1] = points[3];
15702
+ count += verticesStride;
15703
+ vertices[verticesOffset + count] = points[6];
15704
+ vertices[verticesOffset + count + 1] = points[7];
15705
+ count += verticesStride;
15706
+ vertices[verticesOffset + count] = points[4];
15707
+ vertices[verticesOffset + count + 1] = points[5];
15708
+ count += verticesStride;
15709
+ var verticesIndex = verticesOffset / verticesStride;
15710
+ // triangle 1
15711
+ indices[indicesOffset++] = verticesIndex;
15712
+ indices[indicesOffset++] = verticesIndex + 1;
15713
+ indices[indicesOffset++] = verticesIndex + 2;
15714
+ // triangle 2
15715
+ indices[indicesOffset++] = verticesIndex + 1;
15716
+ indices[indicesOffset++] = verticesIndex + 3;
15717
+ indices[indicesOffset++] = verticesIndex + 2;
15718
+ };
15719
+ _create_class(Rectangle, [
15720
+ {
15721
+ key: "left",
15722
+ get: /** Returns the left edge of the rectangle. */ function get() {
15723
+ return this.x;
15724
+ }
15725
+ },
15726
+ {
15727
+ key: "right",
15728
+ get: /** Returns the right edge of the rectangle. */ function get() {
15729
+ return this.x + this.width;
15730
+ }
15731
+ },
15732
+ {
15733
+ key: "top",
15734
+ get: /** Returns the top edge of the rectangle. */ function get() {
15735
+ return this.y;
15736
+ }
15737
+ },
15738
+ {
15739
+ key: "bottom",
15740
+ get: /** Returns the bottom edge of the rectangle. */ function get() {
15741
+ return this.y + this.height;
15742
+ }
15743
+ }
15744
+ ], [
15745
+ {
15746
+ key: "EMPTY",
15747
+ get: /** A constant empty rectangle. This is a new object every time the property is accessed */ function get() {
15748
+ return new Rectangle(0, 0, 0, 0);
15749
+ }
15750
+ }
15751
+ ]);
15752
+ return Rectangle;
15753
+ }(ShapePrimitive);
15754
+
15412
15755
  var ShapePath = /*#__PURE__*/ function() {
15413
15756
  function ShapePath(graphicsPath) {
15414
15757
  this.graphicsPath = graphicsPath;
@@ -15445,6 +15788,11 @@ var ShapePath = /*#__PURE__*/ function() {
15445
15788
  this.polyStar(data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
15446
15789
  break;
15447
15790
  }
15791
+ case "rect":
15792
+ {
15793
+ this.rect(data[0], data[1], data[2], data[3], data[4]);
15794
+ break;
15795
+ }
15448
15796
  }
15449
15797
  }
15450
15798
  this.endPoly();
@@ -15490,6 +15838,18 @@ var ShapePath = /*#__PURE__*/ function() {
15490
15838
  return this;
15491
15839
  };
15492
15840
  /**
15841
+ * Draws a rectangle shape. This method adds a new rectangle path to the current drawing.
15842
+ * @param x - The x-coordinate of the upper-left corner of the rectangle.
15843
+ * @param y - The y-coordinate of the upper-left corner of the rectangle.
15844
+ * @param w - The width of the rectangle.
15845
+ * @param h - The height of the rectangle.
15846
+ * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
15847
+ * @returns The instance of the current object for chaining.
15848
+ */ _proto.rect = function rect(x, y, w, h, transform) {
15849
+ this.drawShape(new Rectangle$1(x, y, w, h), transform);
15850
+ return this;
15851
+ };
15852
+ /**
15493
15853
  * Draws a given shape on the canvas.
15494
15854
  * This is a generic method that can draw any type of shape specified by the `ShapePrimitive` parameter.
15495
15855
  * An optional transformation matrix can be applied to the shape, allowing for complex transformations.
@@ -15625,8 +15985,8 @@ var GraphicsPath = /*#__PURE__*/ function() {
15625
15985
  };
15626
15986
  /**
15627
15987
  * Draws a rectangle shape. This method adds a new rectangle path to the current drawing.
15628
- * @param x - The x-coordinate of the top-left corner of the rectangle.
15629
- * @param y - The y-coordinate of the top-left corner of the rectangle.
15988
+ * @param x - The x-coordinate of the upper-left corner of the rectangle.
15989
+ * @param y - The y-coordinate of the upper-left corner of the rectangle.
15630
15990
  * @param w - The width of the rectangle.
15631
15991
  * @param h - The height of the rectangle.
15632
15992
  * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
@@ -15852,7 +16212,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15852
16212
  case 1:
15853
16213
  {
15854
16214
  var rectangleData = shapeData;
15855
- this.path.rect(-rectangleData.width / 2, rectangleData.height / 2, rectangleData.width, rectangleData.height);
16215
+ this.path.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
15856
16216
  this.setFillColor(rectangleData.fill);
15857
16217
  break;
15858
16218
  }
@@ -16414,6 +16774,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16414
16774
  0
16415
16775
  ]
16416
16776
  };
16777
+ _this.duringPlay = false;
16417
16778
  /** 是否响应点击和拖拽交互事件 */ _this._interactive = true;
16418
16779
  _this.getHitTestParams = function(force) {
16419
16780
  if (!_this.clickable) {
@@ -16478,7 +16839,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16478
16839
  _proto.onDisable = function onDisable() {
16479
16840
  if (this.item && this.item.composition) {
16480
16841
  var _this_previewContent;
16481
- this.item.composition.removeInteractiveItem(this.item, this.item.props.content.options.type);
16842
+ if (this.duringPlay && !this.item.transform.getValid()) {
16843
+ this.item.composition.removeInteractiveItem(this.item, this.item.props.content.options.type);
16844
+ this.duringPlay = false;
16845
+ }
16482
16846
  this.clickable = false;
16483
16847
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.mesh.dispose();
16484
16848
  this.endDragTarget();
@@ -16489,15 +16853,15 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16489
16853
  if (type === InteractType.CLICK) {
16490
16854
  this.clickable = true;
16491
16855
  }
16492
- var options = this.item.props.content.options;
16493
- if (this.item.composition) {
16494
- this.item.composition.addInteractiveItem(this.item, options.type);
16495
- }
16496
16856
  };
16497
16857
  _proto.onUpdate = function onUpdate(dt) {
16498
16858
  var _this_previewContent;
16499
- if (!this.isActiveAndEnabled) {
16500
- return;
16859
+ this.duringPlay = true;
16860
+ // trigger messageBegin when item enter
16861
+ if (this.item.time > 0 && this.item.time - dt / 1000 <= 0) {
16862
+ var _this_item_composition;
16863
+ var options = this.item.props.content.options;
16864
+ (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
16501
16865
  }
16502
16866
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
16503
16867
  if (!this.dragEvent || !this.bouncingArg) {
@@ -16678,10 +17042,10 @@ function shouldIgnoreBouncing(arg, mul) {
16678
17042
  return this.boundingBoxData;
16679
17043
  };
16680
17044
  _proto.getBoundingBox = function getBoundingBox() {
16681
- var maxX = 0;
16682
- var maxY = 0;
16683
- var minX = 0;
16684
- var minY = 0;
17045
+ var maxX = -Number.MAX_VALUE;
17046
+ var maxY = -Number.MAX_VALUE;
17047
+ var minX = Number.MAX_VALUE;
17048
+ var minY = Number.MAX_VALUE;
16685
17049
  for(var _iterator = _create_for_of_iterator_helper_loose(this.boundingBoxData.area), _step; !(_step = _iterator()).done;){
16686
17050
  var triangle = _step.value;
16687
17051
  maxX = Math.max(triangle.p0.x, triangle.p1.x, triangle.p2.x, maxX);
@@ -18098,7 +18462,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
18098
18462
  options: {}
18099
18463
  };
18100
18464
  }
18101
- if (duration <= 0) {
18465
+ if (duration < 0) {
18102
18466
  throw new Error("Item duration can't be less than 0, see " + HELP_LINK["Item duration can't be less than 0"] + ".");
18103
18467
  }
18104
18468
  this.rendererComponents.length = 0;
@@ -18459,6 +18823,16 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
18459
18823
  }
18460
18824
  var life = Math.min(Math.max(time / duration, 0.0), 1.0);
18461
18825
  var ta = this.textureSheetAnimation;
18826
+ var video = this.renderer.texture.source.video;
18827
+ if (video) {
18828
+ if (time === 0) {
18829
+ video.pause();
18830
+ } else {
18831
+ video.play().catch(function(e) {
18832
+ _this.engine.renderErrors.add(e);
18833
+ });
18834
+ }
18835
+ }
18462
18836
  if (ta) {
18463
18837
  var _this_material_getVector4;
18464
18838
  var total = ta.total || ta.row * ta.col;
@@ -18513,16 +18887,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
18513
18887
  dy
18514
18888
  ]);
18515
18889
  }
18516
- var video = this.renderer.texture.source.video;
18517
- if (video) {
18518
- if (time === 0 || time === this.item.duration) {
18519
- video.pause();
18520
- } else {
18521
- video.play().catch(function(e) {
18522
- _this.engine.renderErrors.add(e);
18523
- });
18524
- }
18525
- }
18526
18890
  };
18527
18891
  _proto.onDestroy = function onDestroy() {
18528
18892
  if (this.item && this.item.composition) {
@@ -24019,6 +24383,51 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24019
24383
  return Vector4PropertyMixerPlayable;
24020
24384
  }(Playable);
24021
24385
 
24386
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24387
+ _inherits(ColorPropertyMixerPlayable, Playable);
24388
+ function ColorPropertyMixerPlayable() {
24389
+ var _this;
24390
+ _this = Playable.apply(this, arguments) || this;
24391
+ _this.propertyName = "";
24392
+ return _this;
24393
+ }
24394
+ var _proto = ColorPropertyMixerPlayable.prototype;
24395
+ _proto.processFrame = function processFrame(context) {
24396
+ var boundObject = context.output.getUserData();
24397
+ if (!boundObject) {
24398
+ return;
24399
+ }
24400
+ var hasInput = false;
24401
+ var value = boundObject[this.propertyName];
24402
+ if (!_instanceof1(value, Color)) {
24403
+ return;
24404
+ }
24405
+ value.setZero();
24406
+ // evaluate the curve
24407
+ for(var i = 0; i < this.getInputCount(); i++){
24408
+ var weight = this.getInputWeight(i);
24409
+ if (weight > 0) {
24410
+ var propertyClipPlayable = this.getInput(i);
24411
+ if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24412
+ console.error("ColorPropertyMixerPlayable received incompatible input");
24413
+ continue;
24414
+ }
24415
+ var curveValue = propertyClipPlayable.value;
24416
+ value.r += curveValue.r * weight;
24417
+ value.g += curveValue.g * weight;
24418
+ value.b += curveValue.b * weight;
24419
+ value.a += curveValue.a * weight;
24420
+ hasInput = true;
24421
+ }
24422
+ }
24423
+ // set value
24424
+ if (hasInput) {
24425
+ boundObject[this.propertyName] = value;
24426
+ }
24427
+ };
24428
+ return ColorPropertyMixerPlayable;
24429
+ }(Playable);
24430
+
24022
24431
  var PropertyTrack = /*#__PURE__*/ function(TrackAsset) {
24023
24432
  _inherits(PropertyTrack, TrackAsset);
24024
24433
  function PropertyTrack() {
@@ -24178,7 +24587,7 @@ exports.ColorPropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24178
24587
  }
24179
24588
  var _proto = ColorPropertyTrack.prototype;
24180
24589
  _proto.createTrackMixer = function createTrackMixer(graph) {
24181
- var mixer = new FloatPropertyMixerPlayable(graph);
24590
+ var mixer = new ColorPropertyMixerPlayable(graph);
24182
24591
  var propertyNames = this.propertyNames;
24183
24592
  if (propertyNames.length > 0) {
24184
24593
  var propertyName = propertyNames[propertyNames.length - 1];
@@ -24192,6 +24601,27 @@ exports.ColorPropertyTrack = __decorate([
24192
24601
  effectsClass(DataType.ColorPropertyTrack)
24193
24602
  ], exports.ColorPropertyTrack);
24194
24603
 
24604
+ exports.ColorPropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
24605
+ _inherits(ColorPropertyPlayableAsset, PlayableAsset);
24606
+ function ColorPropertyPlayableAsset() {
24607
+ return PlayableAsset.apply(this, arguments);
24608
+ }
24609
+ var _proto = ColorPropertyPlayableAsset.prototype;
24610
+ _proto.createPlayable = function createPlayable(graph) {
24611
+ var clipPlayable = new PropertyClipPlayable(graph);
24612
+ clipPlayable.curve = createValueGetter(this.curveData);
24613
+ clipPlayable.value = clipPlayable.curve.getValue(0);
24614
+ return clipPlayable;
24615
+ };
24616
+ return ColorPropertyPlayableAsset;
24617
+ }(PlayableAsset);
24618
+ __decorate([
24619
+ serialize()
24620
+ ], exports.ColorPropertyPlayableAsset.prototype, "curveData", void 0);
24621
+ exports.ColorPropertyPlayableAsset = __decorate([
24622
+ effectsClass(DataType.ColorPropertyPlayableAsset)
24623
+ ], exports.ColorPropertyPlayableAsset);
24624
+
24195
24625
  exports.FloatPropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
24196
24626
  _inherits(FloatPropertyPlayableAsset, PlayableAsset);
24197
24627
  function FloatPropertyPlayableAsset() {
@@ -24396,6 +24826,27 @@ function compareTracks(a, b) {
24396
24826
  }
24397
24827
  }
24398
24828
 
24829
+ exports.Vector4PropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
24830
+ _inherits(Vector4PropertyPlayableAsset, PlayableAsset);
24831
+ function Vector4PropertyPlayableAsset() {
24832
+ return PlayableAsset.apply(this, arguments);
24833
+ }
24834
+ var _proto = Vector4PropertyPlayableAsset.prototype;
24835
+ _proto.createPlayable = function createPlayable(graph) {
24836
+ var clipPlayable = new PropertyClipPlayable(graph);
24837
+ clipPlayable.curve = createValueGetter(this.curveData);
24838
+ clipPlayable.value = clipPlayable.curve.getValue(0);
24839
+ return clipPlayable;
24840
+ };
24841
+ return Vector4PropertyPlayableAsset;
24842
+ }(PlayableAsset);
24843
+ __decorate([
24844
+ serialize()
24845
+ ], exports.Vector4PropertyPlayableAsset.prototype, "curveData", void 0);
24846
+ exports.Vector4PropertyPlayableAsset = __decorate([
24847
+ effectsClass("Vector4PropertyPlayableAsset")
24848
+ ], exports.Vector4PropertyPlayableAsset);
24849
+
24399
24850
  exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24400
24851
  _inherits(ObjectBindingTrack, TrackAsset1);
24401
24852
  function ObjectBindingTrack() {
@@ -24633,6 +25084,8 @@ exports.TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
24633
25084
  /**
24634
25085
  * 文本行数
24635
25086
  */ _this.lineCount = 0;
25087
+ _this.SCALE_FACTOR = 0.1;
25088
+ _this.ALPHA_FIX_VALUE = 1 / 255;
24636
25089
  _this.name = "MText" + seed$2++;
24637
25090
  _this.geometry = _this.createGeometry(glContext.TRIANGLES);
24638
25091
  if (props) {
@@ -24998,7 +25451,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
24998
25451
  }
24999
25452
  //与 toDataURL() 两种方式都需要像素读取操作
25000
25453
  var imageData = context.getImageData(0, 0, this.canvas.width, this.canvas.height);
25001
- this.material.setTexture("uSampler0", Texture.createWithData(this.engine, {
25454
+ this.material.setTexture("_MainTex", Texture.createWithData(this.engine, {
25002
25455
  data: new Uint8Array(imageData.data),
25003
25456
  width: imageData.width,
25004
25457
  height: imageData.height
@@ -28196,7 +28649,7 @@ var listOrder = 0;
28196
28649
  var itemProps = sourceItemData;
28197
28650
  if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
28198
28651
  itemProps.listIndex = listOrder++;
28199
- if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || //@ts-expect-error
28652
+ if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || //@ts-expect-error
28200
28653
  itemProps.type === ItemType.shape) {
28201
28654
  for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
28202
28655
  var componentPath = _step2.value;
@@ -28237,8 +28690,10 @@ var listOrder = 0;
28237
28690
  shapeData = shape;
28238
28691
  }
28239
28692
  if (shapeData !== undefined) {
28240
- // @ts-expect-error 类型转换问题
28241
- renderContent.renderer.shape = getGeometryByShape(shapeData, split);
28693
+ if (!("aPoint" in shapeData && "index" in shapeData)) {
28694
+ // @ts-expect-error 类型转换问题
28695
+ renderContent.renderer.shape = getGeometryByShape(shapeData, split);
28696
+ }
28242
28697
  }
28243
28698
  }
28244
28699
  if ("trails" in renderContent && renderContent.trails !== undefined) {
@@ -31154,7 +31609,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
31154
31609
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
31155
31610
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
31156
31611
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
31157
- var version$1 = "2.1.0-alpha.11";
31612
+ var version$1 = "2.1.0-alpha.13";
31158
31613
  logger.info("Core version: " + version$1 + ".");
31159
31614
 
31160
31615
  var _obj;
@@ -31190,22 +31645,7 @@ var _obj3;
31190
31645
  * 必须初始化的 uniform 的 map 对象(THREE 必须在初始化的时候赋值)
31191
31646
  */ var TEXTURE_UNIFORM_MAP = [
31192
31647
  "uMaskTex",
31193
- "uSampler0",
31194
- "uSampler1",
31195
- "uSampler2",
31196
- "uSampler3",
31197
- "uSampler4",
31198
- "uSampler5",
31199
- "uSampler6",
31200
- "uSampler7",
31201
- "uSampler8",
31202
- "uSampler9",
31203
- "uSampler10",
31204
- "uSampler11",
31205
- "uSampler12",
31206
- "uSampler13",
31207
- "uSampler14",
31208
- "uSampler15",
31648
+ "_MainTex",
31209
31649
  "uColorOverLifetime",
31210
31650
  "uColorOverTrail"
31211
31651
  ];
@@ -31236,9 +31676,7 @@ var _obj3;
31236
31676
  vertex: (_shader_vertex = shader == null ? void 0 : shader.vertex) != null ? _shader_vertex : "",
31237
31677
  fragment: (_shader_fragment = shader == null ? void 0 : shader.fragment) != null ? _shader_fragment : ""
31238
31678
  });
31239
- for(var i = 0; i < exports.maxSpriteMeshItemCount; i++){
31240
- _this.uniforms["uSampler" + i] = new THREE__namespace.Uniform(null);
31241
- }
31679
+ _this.uniforms["_MainTex"] = new THREE__namespace.Uniform(null);
31242
31680
  _this.uniforms["uEditorTransform"] = new THREE__namespace.Uniform([
31243
31681
  1,
31244
31682
  1,
@@ -32798,7 +33236,7 @@ setMaxSpriteMeshItemCount(8);
32798
33236
  */ Mesh.create = function(engine, props) {
32799
33237
  return new ThreeMesh(engine, props);
32800
33238
  };
32801
- var version = "2.1.0-alpha.11";
33239
+ var version = "2.1.0-alpha.13";
32802
33240
  logger.info("THREEJS plugin version: " + version + ".");
32803
33241
 
32804
33242
  exports.AbstractPlugin = AbstractPlugin;