@galacean/engine-core 1.3.6 → 1.3.8

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/main.js CHANGED
@@ -2252,7 +2252,7 @@ var size_over_lifetime_module = "#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MO
2252
2252
 
2253
2253
  var color_over_lifetime_module = "#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=alphaKeys[0].y;}else{vec2 lastKey=alphaKeys[i-1];float lastTime=lastKey.x;float age=(alphaAge-lastTime)/(time-lastTime);value.a=mix(lastKey.y,key.y,age);}break;}}float colorAge=min(normalizedAge,colorKeysMaxTime);for(int i=0;i<4;i++){vec4 key=colorKeys[i];float time=key.x;if(colorAge<=time){if(i==0){value.rgb=colorKeys[0].yzw;}else{vec4 lastKey=colorKeys[i-1];float lastTime=lastKey.x;float age=(colorAge-lastTime)/(time-lastTime);value.rgb=mix(lastKey.yzw,key.yzw,age);}break;}}return value;}\n#endif\nvec4 computeParticleColor(in vec4 color,in float normalizedAge){\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 gradientColor=evaluateParticleGradient(renderer_COLMaxGradientColor,renderer_COLGradientKeysMaxTime.z,renderer_COLMaxGradientAlpha,renderer_COLGradientKeysMaxTime.w,normalizedAge);\n#endif\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\ngradientColor=mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x,renderer_COLMinGradientAlpha,renderer_COLGradientKeysMaxTime.y,normalizedAge),gradientColor,a_Random0.y);\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\ncolor*=gradientColor;\n#endif\nreturn color;}"; // eslint-disable-line
2254
2254
 
2255
- var texture_sheet_animation_module = "#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nuniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4];\n#endif\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge){\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nfloat scaledNormalizedAge=normalizedAge*renderer_TSACycles;float cycleNormalizedAge=scaledNormalizedAge-floor(scaledNormalizedAge);float normalizedFrame=evaluateParticleCurve(renderer_TSAFrameMaxCurve,cycleNormalizedAge);\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nnormalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormalizedAge),normalizedFrame,a_Random1.x);\n#endif\nfloat frame=floor(normalizedFrame*renderer_TSATillingParams.z);float totalULength=frame*renderer_TSATillingParams.x;float floorTotalULength=floor(totalULength);uv.x+=totalULength-floorTotalULength;uv.y+=floorTotalULength*renderer_TSATillingParams.y;\n#endif\nreturn uv;}"; // eslint-disable-line
2255
+ var texture_sheet_animation_module = "#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nuniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4];\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\n#endif\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge){\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nfloat scaledNormalizedAge=normalizedAge*renderer_TSACycles;float cycleNormalizedAge=scaledNormalizedAge-floor(scaledNormalizedAge);float normalizedFrame=evaluateParticleCurve(renderer_TSAFrameMaxCurve,cycleNormalizedAge);\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nnormalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormalizedAge),normalizedFrame,a_Random1.x);\n#endif\nfloat frame=floor(normalizedFrame*renderer_TSATillingParams.z);float tileRow=frame*renderer_TSATillingParams.x;float floorTotalULength=floor(tileRow);uv.x+=tileRow-tileRowIndex;uv.y+=tileRowIndex*renderer_TSATillingParams.y;\n#endif\nreturn uv;}"; // eslint-disable-line
2256
2256
 
2257
2257
  var sphere_billboard = "#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 sideVector=normalize(cross(camera_Forward,camera_Up));vec3 upVector=normalize(cross(sideVector,camera_Forward));corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);}else{float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#else\nif(renderer_ThreeDStartRotation){center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);}else{float c=cos(a_StartRotation0.x);float s=sin(a_StartRotation0.x);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#endif\n#endif\n"; // eslint-disable-line
2258
2258
 
@@ -18839,39 +18839,43 @@ var ObjectPool = /*#__PURE__*/ function() {
18839
18839
  return null;
18840
18840
  };
18841
18841
  _proto._freeArea = function _freeArea(area) {
18842
- var areas = this.vertexFreeAreas;
18843
- var areaLen = areas.length;
18844
- if (areaLen === 0) {
18845
- areas.push(area);
18846
- return;
18847
- }
18842
+ var start = area.start, size = area.size;
18843
+ var freeAreas = this.vertexFreeAreas;
18844
+ var end = start + size;
18848
18845
  var pool = PrimitiveChunk.areaPool;
18849
- var preArea = area;
18850
- var notMerge = true;
18851
- for(var i = 0; i < areaLen; ++i){
18852
- var curArea = areas[i];
18853
- var preStart = preArea.start, size = preArea.size;
18854
- var curStart = curArea.start;
18855
- var preEnd = preStart + size;
18856
- var curEnd = curStart + curArea.size;
18857
- if (preEnd < curStart) {
18858
- notMerge && areas.splice(i, 0, preArea);
18846
+ for(var i = 0, areaLen = freeAreas.length; i < areaLen; ++i){
18847
+ var curFreeArea = freeAreas[i];
18848
+ var curStart = curFreeArea.start;
18849
+ var curEnd = curStart + curFreeArea.size;
18850
+ if (end < curStart) {
18851
+ // The area to be freed is to the left of the current free area and is not connected
18852
+ freeAreas.splice(i, 0, area);
18853
+ return;
18854
+ } else if (end === curStart) {
18855
+ // The area to be freed is to the left of the current free area and is connected
18856
+ curFreeArea.start = start;
18857
+ curFreeArea.size += size;
18858
+ pool.return(area);
18859
+ return;
18860
+ } else if (start === curEnd) {
18861
+ // The area to be freed is to the right of the current free area and is connected
18862
+ curFreeArea.size += size;
18863
+ pool.return(area);
18864
+ var nextIndex = i + 1;
18865
+ if (nextIndex < areaLen) {
18866
+ var nextFreeArea = freeAreas[nextIndex];
18867
+ if (end === nextFreeArea.start) {
18868
+ // The cur free area after merge is to the left of the next free area and is connected
18869
+ curFreeArea.size += nextFreeArea.size;
18870
+ freeAreas.splice(nextIndex, 1);
18871
+ pool.return(nextFreeArea);
18872
+ }
18873
+ }
18859
18874
  return;
18860
- } else if (preEnd === curStart) {
18861
- curArea.start = preStart;
18862
- curArea.size += size;
18863
- pool.return(preArea);
18864
- preArea = curArea;
18865
- notMerge = false;
18866
- } else if (preStart === curEnd) {
18867
- curArea.size += size;
18868
- pool.return(preArea);
18869
- preArea = curArea;
18870
- notMerge = false;
18871
- } else if (preStart > curEnd) {
18872
- i + 1 === areaLen && areas.push(preArea);
18873
18875
  }
18874
18876
  }
18877
+ // The area to be freed is to the right of the last free area and is not connected or free areas is empty
18878
+ freeAreas.push(area);
18875
18879
  };
18876
18880
  return PrimitiveChunk;
18877
18881
  }();
@@ -32213,7 +32217,6 @@ __decorate([
32213
32217
  function TextureSheetAnimationModule() {
32214
32218
  var _this;
32215
32219
  _this = ParticleGeneratorModule1.apply(this, arguments) || this;
32216
- /** Start frame of the texture sheet. */ _this.startFrame = new ParticleCompositeCurve(0);
32217
32220
  /** Frame over time curve of the texture sheet. */ _this.frameOverTime = new ParticleCompositeCurve(new ParticleCurve(new CurveKey(0, 0), new CurveKey(1, 1)));
32218
32221
  /** Texture sheet animation type. */ _this.type = /** Animate over the whole texture sheet from left to right, top to bottom. */ 0;
32219
32222
  /** Cycle count. */ _this.cycleCount = 1;
@@ -32243,7 +32246,7 @@ __decorate([
32243
32246
  shaderData.setVector3(TextureSheetAnimationModule._tillingParamsProperty, this._tillingInfo);
32244
32247
  }
32245
32248
  }
32246
- this._textureSheetMacro = this._enableMacro(shaderData, this._textureSheetMacro, frameMacro);
32249
+ this._frameCurveMacro = this._enableMacro(shaderData, this._frameCurveMacro, frameMacro);
32247
32250
  };
32248
32251
  /**
32249
32252
  * @internal
@@ -32273,20 +32276,17 @@ __decorate([
32273
32276
  TextureSheetAnimationModule._frameRandomCurvesMacro = ShaderMacro.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES");
32274
32277
  })();
32275
32278
  (function() {
32276
- TextureSheetAnimationModule._cycleCountProperty = ShaderProperty.getByName("renderer_TSACycles");
32279
+ TextureSheetAnimationModule._frameMinCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMinCurve");
32277
32280
  })();
32278
32281
  (function() {
32279
- TextureSheetAnimationModule._tillingParamsProperty = ShaderProperty.getByName("renderer_TSATillingParams");
32282
+ TextureSheetAnimationModule._frameMaxCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMaxCurve");
32280
32283
  })();
32281
32284
  (function() {
32282
- TextureSheetAnimationModule._frameMinCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMinCurve");
32285
+ TextureSheetAnimationModule._cycleCountProperty = ShaderProperty.getByName("renderer_TSACycles");
32283
32286
  })();
32284
32287
  (function() {
32285
- TextureSheetAnimationModule._frameMaxCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMaxCurve");
32288
+ TextureSheetAnimationModule._tillingParamsProperty = ShaderProperty.getByName("renderer_TSATillingParams");
32286
32289
  })();
32287
- __decorate([
32288
- deepClone
32289
- ], TextureSheetAnimationModule.prototype, "startFrame", void 0);
32290
32290
  __decorate([
32291
32291
  deepClone
32292
32292
  ], TextureSheetAnimationModule.prototype, "frameOverTime", void 0);
@@ -32301,7 +32301,7 @@ __decorate([
32301
32301
  ], TextureSheetAnimationModule.prototype, "_tiling", void 0);
32302
32302
  __decorate([
32303
32303
  ignoreClone
32304
- ], TextureSheetAnimationModule.prototype, "_textureSheetMacro", void 0);
32304
+ ], TextureSheetAnimationModule.prototype, "_frameCurveMacro", void 0);
32305
32305
  var TextureSheetAnimationType;
32306
32306
  (function(TextureSheetAnimationType) {
32307
32307
  TextureSheetAnimationType[TextureSheetAnimationType["WholeSheet"] = 0] = "WholeSheet";
@@ -33035,12 +33035,18 @@ __decorate([
33035
33035
  instanceVertices[offset + 33] = rot.w;
33036
33036
  }
33037
33037
  // Simulation UV
33038
- if (this.textureSheetAnimation.enabled) {
33039
- var tillingInfo = this.textureSheetAnimation._tillingInfo;
33040
- instanceVertices[offset + ParticleBufferUtils.simulationUVOffset] = tillingInfo.x;
33041
- instanceVertices[offset + 35] = tillingInfo.y;
33042
- instanceVertices[offset + 36] = 0;
33043
- instanceVertices[offset + 37] = 0;
33038
+ if (textureSheetAnimation.enabled) {
33039
+ var frameOverTime = textureSheetAnimation.frameOverTime;
33040
+ var _textureSheetAnimation__tillingInfo = textureSheetAnimation._tillingInfo, x = _textureSheetAnimation__tillingInfo.x, y = _textureSheetAnimation__tillingInfo.y, z = _textureSheetAnimation__tillingInfo.z;
33041
+ var tileRow = 0;
33042
+ if (frameOverTime.mode === exports.ParticleCurveMode.Constant || frameOverTime.mode === exports.ParticleCurveMode.TwoConstants) {
33043
+ tileRow = Math.floor(frameOverTime.evaluate(undefined, textureSheetAnimation._frameOverTimeRand.random()) * z) * x;
33044
+ }
33045
+ var tileRowIndex = Math.floor(tileRow);
33046
+ instanceVertices[offset + ParticleBufferUtils.simulationUVOffset] = x;
33047
+ instanceVertices[offset + 35] = y;
33048
+ instanceVertices[offset + 36] = tileRow - tileRowIndex;
33049
+ instanceVertices[offset + 37] = tileRowIndex * y;
33044
33050
  } else {
33045
33051
  instanceVertices[offset + ParticleBufferUtils.simulationUVOffset] = 1;
33046
33052
  instanceVertices[offset + 35] = 1;