@galacean/effects-threejs 2.3.0-alpha.0 → 2.3.0-alpha.1

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.3.0-alpha.0
6
+ * Version: v2.3.0-alpha.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -10208,7 +10208,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10208
10208
 
10209
10209
  var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec3 _Scale;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;\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);if(texParams.z==1.0){vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}else{mat4 view=effects_MatrixV;vec3 camRight=vec3(view[0][0],view[1][0],view[2][0]);vec3 camUp=vec3(view[0][1],view[1][1],view[2][1]);vec3 worldPosition=vec3(effects_ObjectToWorld*vec4(0.0,0.0,0.0,1.0));vec3 vertexPosition=worldPosition+camRight*aPos.x*_Size.x*_Scale.x+camUp*aPos.y*_Size.y*_Scale.y;gl_Position=effects_MatrixVP*vec4(vertexPosition,1.0);}\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
10210
10210
 
10211
- 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));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10211
+ 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.);\n#ifdef TRANSPARENT_VIDEO\nvec2 uv_rgb=vec2(vTexCoord.x*0.5000,vTexCoord.y);vec2 uv_alpha=vec2(vTexCoord.x*0.5000+0.5000,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=texture2D(_MainTex,uv_alpha).r;vec4 texColor=vec4(rgb/alpha,alpha);\n#else\nvec4 texColor=texture2D(_MainTex,vTexCoord.xy);\n#endif\ncolor=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10212
10212
 
10213
10213
  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";
10214
10214
 
@@ -13590,11 +13590,14 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13590
13590
  maxVertex: 4
13591
13591
  });
13592
13592
  };
13593
- _proto.createMaterial = function createMaterial(renderInfo, count) {
13594
- var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13595
- var materialProps = {
13593
+ _proto.getMaterialProps = function getMaterialProps(renderInfo, count) {
13594
+ return {
13596
13595
  shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1)
13597
13596
  };
13597
+ };
13598
+ _proto.createMaterial = function createMaterial(renderInfo, count) {
13599
+ var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13600
+ var materialProps = this.getMaterialProps(renderInfo, count);
13598
13601
  this.preMultiAlpha = getPreMultiAlpha(blending);
13599
13602
  var material = Material.create(this.engine, materialProps);
13600
13603
  var states = {
@@ -16463,6 +16466,13 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16463
16466
  join: "miter",
16464
16467
  miterLimit: 10
16465
16468
  };
16469
+ _this.shapeAttribute = {
16470
+ type: ShapePrimitiveType.Custom,
16471
+ points: [],
16472
+ easingIns: [],
16473
+ easingOuts: [],
16474
+ shapes: []
16475
+ };
16466
16476
  return _this;
16467
16477
  }
16468
16478
  var _proto = ShapeComponent.prototype;
@@ -16471,7 +16481,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16471
16481
  };
16472
16482
  _proto.onUpdate = function onUpdate(dt) {
16473
16483
  if (this.shapeDirty) {
16474
- this.buildPath(this.data);
16484
+ this.buildPath(this.shapeAttribute);
16475
16485
  this.buildGeometryFromPath(this.graphicsPath.shapePath);
16476
16486
  this.shapeDirty = false;
16477
16487
  }
@@ -16529,17 +16539,16 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16529
16539
  this.geometry.setIndexData(indexArray);
16530
16540
  this.geometry.setDrawCount(indices.length);
16531
16541
  };
16532
- _proto.buildPath = function buildPath(data) {
16542
+ _proto.buildPath = function buildPath(shapeAttribute) {
16533
16543
  this.graphicsPath.clear();
16534
- var shapeData = data;
16535
- switch(shapeData.type){
16544
+ switch(shapeAttribute.type){
16536
16545
  case ShapePrimitiveType.Custom:
16537
16546
  {
16538
- var customData = shapeData;
16539
- var points = customData.points;
16540
- var easingIns = customData.easingIns;
16541
- var easingOuts = customData.easingOuts;
16542
- for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
16547
+ var customShapeAtribute = this.shapeAttribute;
16548
+ var points = customShapeAtribute.points;
16549
+ var easingIns = customShapeAtribute.easingIns;
16550
+ var easingOuts = customShapeAtribute.easingOuts;
16551
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeAtribute.shapes), _step; !(_step = _iterator()).done;){
16543
16552
  var shape = _step.value;
16544
16553
  this.curveValues = [];
16545
16554
  this.setFillColor(shape.fill);
@@ -16572,28 +16581,28 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16572
16581
  }
16573
16582
  case ShapePrimitiveType.Ellipse:
16574
16583
  {
16575
- var ellipseData = shapeData;
16584
+ var ellipseData = shapeAttribute;
16576
16585
  this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16577
16586
  this.setFillColor(ellipseData.fill);
16578
16587
  break;
16579
16588
  }
16580
16589
  case ShapePrimitiveType.Rectangle:
16581
16590
  {
16582
- var rectangleData = shapeData;
16591
+ var rectangleData = shapeAttribute;
16583
16592
  this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16584
16593
  this.setFillColor(rectangleData.fill);
16585
16594
  break;
16586
16595
  }
16587
16596
  case ShapePrimitiveType.Star:
16588
16597
  {
16589
- var starData = shapeData;
16598
+ var starData = shapeAttribute;
16590
16599
  this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16591
16600
  this.setFillColor(starData.fill);
16592
16601
  break;
16593
16602
  }
16594
16603
  case ShapePrimitiveType.Polygon:
16595
16604
  {
16596
- var polygonData = shapeData;
16605
+ var polygonData = shapeAttribute;
16597
16606
  this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16598
16607
  this.setFillColor(polygonData.fill);
16599
16608
  break;
@@ -16608,13 +16617,93 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16608
16617
  };
16609
16618
  _proto.fromData = function fromData(data) {
16610
16619
  MeshComponent.prototype.fromData.call(this, data);
16611
- this.data = data;
16612
16620
  this.shapeDirty = true;
16613
16621
  var strokeParam = data.stroke;
16614
16622
  if (strokeParam) {
16615
16623
  this.isStroke = true;
16616
16624
  this.strokeAttributes.width = strokeParam.width;
16617
16625
  }
16626
+ switch(data.type){
16627
+ case ShapePrimitiveType.Custom:
16628
+ {
16629
+ this.shapeAttribute = {
16630
+ type: ShapePrimitiveType.Custom,
16631
+ points: [],
16632
+ easingIns: [],
16633
+ easingOuts: [],
16634
+ shapes: []
16635
+ };
16636
+ var customShapeData = data;
16637
+ var customShapeAttribute = this.shapeAttribute;
16638
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeData.points), _step; !(_step = _iterator()).done;){
16639
+ var point = _step.value;
16640
+ customShapeAttribute.points.push(new Vector2(point.x, point.y));
16641
+ }
16642
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(customShapeData.easingIns), _step1; !(_step1 = _iterator1()).done;){
16643
+ var easingIn = _step1.value;
16644
+ customShapeAttribute.easingIns.push(new Vector2(easingIn.x, easingIn.y));
16645
+ }
16646
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(customShapeData.easingOuts), _step2; !(_step2 = _iterator2()).done;){
16647
+ var easingOut = _step2.value;
16648
+ customShapeAttribute.easingOuts.push(new Vector2(easingOut.x, easingOut.y));
16649
+ }
16650
+ customShapeAttribute.shapes = customShapeData.shapes;
16651
+ break;
16652
+ }
16653
+ case ShapePrimitiveType.Ellipse:
16654
+ {
16655
+ var ellipseData = data;
16656
+ var ellipseAttribute = {
16657
+ type: ShapePrimitiveType.Ellipse,
16658
+ xRadius: ellipseData.xRadius,
16659
+ yRadius: ellipseData.yRadius,
16660
+ fill: ellipseData.fill
16661
+ };
16662
+ this.shapeAttribute = ellipseAttribute;
16663
+ break;
16664
+ }
16665
+ case ShapePrimitiveType.Rectangle:
16666
+ {
16667
+ var rectangleData = data;
16668
+ var rectangleAttribute = {
16669
+ type: ShapePrimitiveType.Rectangle,
16670
+ width: rectangleData.width,
16671
+ height: rectangleData.height,
16672
+ roundness: rectangleData.roundness,
16673
+ fill: rectangleData.fill
16674
+ };
16675
+ this.shapeAttribute = rectangleAttribute;
16676
+ break;
16677
+ }
16678
+ case ShapePrimitiveType.Star:
16679
+ {
16680
+ var starData = data;
16681
+ var starAttribute = {
16682
+ type: ShapePrimitiveType.Star,
16683
+ pointCount: starData.pointCount,
16684
+ innerRadius: starData.innerRadius,
16685
+ outerRadius: starData.outerRadius,
16686
+ innerRoundness: starData.innerRoundness,
16687
+ outerRoundness: starData.outerRoundness,
16688
+ fill: starData.fill
16689
+ };
16690
+ this.shapeAttribute = starAttribute;
16691
+ break;
16692
+ }
16693
+ case ShapePrimitiveType.Polygon:
16694
+ {
16695
+ var polygonData = data;
16696
+ var polygonAttribute = {
16697
+ type: ShapePrimitiveType.Polygon,
16698
+ pointCount: polygonData.pointCount,
16699
+ radius: polygonData.radius,
16700
+ roundness: polygonData.roundness,
16701
+ fill: polygonData.fill
16702
+ };
16703
+ this.shapeAttribute = polygonAttribute;
16704
+ break;
16705
+ }
16706
+ }
16618
16707
  var material = this.material;
16619
16708
  //@ts-expect-error // TODO 新版蒙版上线后重构
16620
16709
  material.stencilRef = data.renderer.mask !== undefined ? [
@@ -16626,10 +16715,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16626
16715
  };
16627
16716
  _create_class(ShapeComponent, [
16628
16717
  {
16629
- key: "path",
16718
+ key: "shape",
16630
16719
  get: function get() {
16631
16720
  this.shapeDirty = true;
16632
- return this.data;
16721
+ return this.shapeAttribute;
16633
16722
  }
16634
16723
  }
16635
16724
  ]);
@@ -21034,19 +21123,17 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21034
21123
  rotation: rotation,
21035
21124
  path: path
21036
21125
  };
21037
- var parentTransform = this.transform.parentTransform;
21038
21126
  var selfPos = position.clone();
21039
21127
  if (path) {
21040
21128
  selfPos.add(path.getValue(0));
21041
21129
  }
21042
21130
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
21043
- if (this.options.particleFollowParent && parentTransform) {
21044
- var worldMatrix = parentTransform.getWorldMatrix();
21131
+ if (this.options.particleFollowParent) {
21132
+ var worldMatrix = this.transform.getWorldMatrix();
21045
21133
  this.renderer.updateWorldMatrix(worldMatrix);
21046
21134
  }
21047
21135
  };
21048
21136
  _proto.updateEmitterTransform = function updateEmitterTransform(time) {
21049
- var parentTransform = this.transform.parentTransform;
21050
21137
  var _this_basicTransform = this.basicTransform, path = _this_basicTransform.path, position = _this_basicTransform.position;
21051
21138
  var selfPos = position.clone();
21052
21139
  if (path) {
@@ -21054,8 +21141,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21054
21141
  selfPos.add(path.getValue(time / duration));
21055
21142
  }
21056
21143
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
21057
- if (this.options.particleFollowParent && parentTransform) {
21058
- var worldMatrix = parentTransform.getWorldMatrix();
21144
+ if (this.options.particleFollowParent) {
21145
+ var worldMatrix = this.transform.getWorldMatrix();
21059
21146
  this.renderer.updateWorldMatrix(worldMatrix);
21060
21147
  }
21061
21148
  };
@@ -21443,7 +21530,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21443
21530
  var lifetime = this.lifetime;
21444
21531
  var shape = this.shape;
21445
21532
  var speed = options.startSpeed.getValue(lifetime);
21446
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
21533
+ var matrix4 = options.particleFollowParent ? Matrix4.IDENTITY : this.transform.getWorldMatrix();
21447
21534
  var pointPosition = data.position;
21448
21535
  // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
21449
21536
  var position = matrix4.transformPoint(pointPosition, new Vector3());
@@ -24265,7 +24352,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
24265
24352
  this.timelinePlayable.setTime(time);
24266
24353
  // The properties of the object may change dynamically,
24267
24354
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
24268
- // this.resolveBindings();
24355
+ this.resolveBindings();
24269
24356
  this.timelinePlayable.evaluate();
24270
24357
  this.graph.evaluate(dt);
24271
24358
  };
@@ -24504,7 +24591,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable)
24504
24591
  }
24505
24592
  var _proto = Vector4PropertyMixerPlayable.prototype;
24506
24593
  _proto.resetPropertyValue = function resetPropertyValue() {
24507
- this.propertyValue.setZero();
24594
+ this.propertyValue.x = 0;
24595
+ this.propertyValue.y = 0;
24596
+ this.propertyValue.z = 0;
24597
+ this.propertyValue.w = 0;
24508
24598
  };
24509
24599
  _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24510
24600
  var result = this.propertyValue;
@@ -24522,7 +24612,8 @@ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable)
24522
24612
  }
24523
24613
  var _proto = Vector2PropertyMixerPlayable.prototype;
24524
24614
  _proto.resetPropertyValue = function resetPropertyValue() {
24525
- this.propertyValue.setZero();
24615
+ this.propertyValue.x = 0;
24616
+ this.propertyValue.y = 0;
24526
24617
  };
24527
24618
  _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24528
24619
  var result = this.propertyValue;
@@ -32009,7 +32100,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
32009
32100
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
32010
32101
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
32011
32102
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
32012
- var version$1 = "2.3.0-alpha.0";
32103
+ var version$1 = "2.3.0-alpha.1";
32013
32104
  logger.info("Core version: " + version$1 + ".");
32014
32105
 
32015
32106
  var _obj;
@@ -33642,7 +33733,7 @@ setMaxSpriteMeshItemCount(8);
33642
33733
  */ Mesh.create = function(engine, props) {
33643
33734
  return new ThreeMesh(engine, props);
33644
33735
  };
33645
- var version = "2.3.0-alpha.0";
33736
+ var version = "2.3.0-alpha.1";
33646
33737
  logger.info("THREEJS plugin version: " + version + ".");
33647
33738
 
33648
33739
  exports.AbstractPlugin = AbstractPlugin;