@galacean/engine-core 1.3.5 → 1.3.7

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
 
@@ -10759,6 +10759,9 @@ var SubRenderElement = /*#__PURE__*/ function() {
10759
10759
  __decorate([
10760
10760
  assignmentClone
10761
10761
  ], SpriteMask.prototype, "influenceLayers", void 0);
10762
+ __decorate([
10763
+ ignoreClone
10764
+ ], SpriteMask.prototype, "_renderElement", void 0);
10762
10765
  __decorate([
10763
10766
  ignoreClone
10764
10767
  ], SpriteMask.prototype, "_subChunk", void 0);
@@ -20929,6 +20932,8 @@ var Collision = function Collision() {
20929
20932
  _this._setUpDirection = _this._setUpDirection.bind(_assert_this_initialized(_this));
20930
20933
  //@ts-ignore
20931
20934
  _this._upDirection._onValueChanged = _this._setUpDirection;
20935
+ // sync world position to physical space
20936
+ _this._onUpdate();
20932
20937
  return _this;
20933
20938
  }
20934
20939
  var _proto = CharacterController.prototype;
@@ -20939,7 +20944,9 @@ var Collision = function Collision() {
20939
20944
  * @param elapsedTime - Time elapsed since last call
20940
20945
  * @return flags - The ControllerCollisionFlag
20941
20946
  */ _proto.move = function move(disp, minDist, elapsedTime) {
20942
- return this._nativeCollider.move(disp, minDist, elapsedTime);
20947
+ var flags = this._nativeCollider.move(disp, minDist, elapsedTime);
20948
+ this._syncWorldPositionFromPhysicalSpace();
20949
+ return flags;
20943
20950
  };
20944
20951
  /**
20945
20952
  * Add collider shape on this controller.
@@ -20975,8 +20982,7 @@ var Collision = function Collision() {
20975
20982
  /**
20976
20983
  * @internal
20977
20984
  */ _proto._onLateUpdate = function _onLateUpdate() {
20978
- var position = this.entity.transform.worldPosition;
20979
- this._nativeCollider.getWorldPosition(position);
20985
+ this._syncWorldPositionFromPhysicalSpace();
20980
20986
  this._updateFlag.flag = false;
20981
20987
  };
20982
20988
  /**
@@ -20999,6 +21005,9 @@ var Collision = function Collision() {
20999
21005
  physics._removeColliderShape(shapes[i]);
21000
21006
  }
21001
21007
  };
21008
+ _proto._syncWorldPositionFromPhysicalSpace = function _syncWorldPositionFromPhysicalSpace() {
21009
+ this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition);
21010
+ };
21002
21011
  _proto._setUpDirection = function _setUpDirection() {
21003
21012
  this._nativeCollider.setUpDirection(this._upDirection);
21004
21013
  };
@@ -28683,7 +28692,9 @@ exports.AnimatorLayerBlendingMode = void 0;
28683
28692
  // Precalculate to get the transition
28684
28693
  srcPlayData.update(playDeltaTime);
28685
28694
  var clipTime = srcPlayData.clipTime, isForwards = srcPlayData.isForwards;
28686
- var transition = this._applyTransitionsByCondition(layerIndex, layerData, layer, state, layer.stateMachine.anyStateTransitions, aniUpdate) || this._applyStateTransitions(layerIndex, layerData, layer, isForwards, srcPlayData, state.transitions, lastClipTime, clipTime, playDeltaTime, aniUpdate);
28695
+ var transitions = state.transitions;
28696
+ var anyStateTransitions = layer.stateMachine.anyStateTransitions;
28697
+ var transition = anyStateTransitions.length && this._applyTransitionsByCondition(layerIndex, layerData, layer, state, anyStateTransitions, aniUpdate) || transitions.length && this._applyStateTransitions(layerIndex, layerData, layer, isForwards, srcPlayData, transitions, lastClipTime, clipTime, playDeltaTime, aniUpdate);
28687
28698
  var playCostTime;
28688
28699
  if (transition) {
28689
28700
  var clipDuration = state.clip.length;
@@ -28767,7 +28778,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28767
28778
  playedTime - dstPlayDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28768
28779
  playedTime - transitionDuration : dstPlayDeltaTime;
28769
28780
  }
28770
- var actualCostTime = dstPlaySpeed === 0 ? 0 : dstPlayCostTime / dstPlaySpeed;
28781
+ var actualCostTime = dstPlaySpeed === 0 ? deltaTime : dstPlayCostTime / dstPlaySpeed;
28771
28782
  var srcPlayCostTime = actualCostTime * srcPlaySpeed;
28772
28783
  srcPlayData.update(srcPlayCostTime);
28773
28784
  destPlayData.update(dstPlayCostTime);
@@ -28775,6 +28786,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28775
28786
  (crossWeight >= 1.0 - engineMath.MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
28776
28787
  var crossFadeFinished = crossWeight === 1.0;
28777
28788
  if (crossFadeFinished) {
28789
+ srcPlayData.playState = AnimatorStatePlayState.Finished;
28778
28790
  this._preparePlayOwner(layerData, destState);
28779
28791
  this._evaluatePlayingState(destPlayData, weight, additive, aniUpdate);
28780
28792
  } else {
@@ -28829,7 +28841,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28829
28841
  playedTime - playDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28830
28842
  playedTime - transitionDuration : playDeltaTime;
28831
28843
  }
28832
- var actualCostTime = playSpeed === 0 ? 0 : dstPlayCostTime / playSpeed;
28844
+ var actualCostTime = playSpeed === 0 ? deltaTime : dstPlayCostTime / playSpeed;
28833
28845
  destPlayData.update(dstPlayCostTime);
28834
28846
  var crossWeight = Math.abs(destPlayData.frameTime) / transitionDuration;
28835
28847
  (crossWeight >= 1.0 - engineMath.MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
@@ -28869,14 +28881,16 @@ exports.AnimatorLayerBlendingMode = void 0;
28869
28881
  }
28870
28882
  };
28871
28883
  _proto._updateFinishedState = function _updateFinishedState(layerIndex, layerData, layer, weight, additive, deltaTime, aniUpdate) {
28872
- var stateMachine = layer.stateMachine;
28884
+ layer.stateMachine;
28873
28885
  var playData = layerData.srcPlayData;
28874
28886
  var state = playData.state;
28875
28887
  var actualSpeed = state.speed * this.speed;
28876
28888
  var actualDeltaTime = actualSpeed * deltaTime;
28877
28889
  playData.updateOrientation(actualDeltaTime);
28878
28890
  var clipTime = playData.clipTime, isForwards = playData.isForwards;
28879
- var transition = this._applyTransitionsByCondition(layerIndex, layerData, layer, state, stateMachine.anyStateTransitions, aniUpdate) || this._applyStateTransitions(layerIndex, layerData, layer, isForwards, playData, state.transitions, clipTime, clipTime, actualDeltaTime, aniUpdate);
28891
+ var transitions = state.transitions;
28892
+ var anyStateTransitions = layer.stateMachine.anyStateTransitions;
28893
+ var transition = anyStateTransitions.length && this._applyTransitionsByCondition(layerIndex, layerData, layer, state, anyStateTransitions, aniUpdate) || transitions.length && this._applyStateTransitions(layerIndex, layerData, layer, isForwards, playData, transitions, clipTime, clipTime, actualDeltaTime, aniUpdate);
28880
28894
  if (transition) {
28881
28895
  this._updateState(layerIndex, layerData, layer, deltaTime, aniUpdate);
28882
28896
  } else {
@@ -32199,7 +32213,6 @@ __decorate([
32199
32213
  function TextureSheetAnimationModule() {
32200
32214
  var _this;
32201
32215
  _this = ParticleGeneratorModule1.apply(this, arguments) || this;
32202
- /** Start frame of the texture sheet. */ _this.startFrame = new ParticleCompositeCurve(0);
32203
32216
  /** Frame over time curve of the texture sheet. */ _this.frameOverTime = new ParticleCompositeCurve(new ParticleCurve(new CurveKey(0, 0), new CurveKey(1, 1)));
32204
32217
  /** Texture sheet animation type. */ _this.type = /** Animate over the whole texture sheet from left to right, top to bottom. */ 0;
32205
32218
  /** Cycle count. */ _this.cycleCount = 1;
@@ -32229,7 +32242,7 @@ __decorate([
32229
32242
  shaderData.setVector3(TextureSheetAnimationModule._tillingParamsProperty, this._tillingInfo);
32230
32243
  }
32231
32244
  }
32232
- this._textureSheetMacro = this._enableMacro(shaderData, this._textureSheetMacro, frameMacro);
32245
+ this._frameCurveMacro = this._enableMacro(shaderData, this._frameCurveMacro, frameMacro);
32233
32246
  };
32234
32247
  /**
32235
32248
  * @internal
@@ -32259,20 +32272,17 @@ __decorate([
32259
32272
  TextureSheetAnimationModule._frameRandomCurvesMacro = ShaderMacro.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES");
32260
32273
  })();
32261
32274
  (function() {
32262
- TextureSheetAnimationModule._cycleCountProperty = ShaderProperty.getByName("renderer_TSACycles");
32275
+ TextureSheetAnimationModule._frameMinCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMinCurve");
32263
32276
  })();
32264
32277
  (function() {
32265
- TextureSheetAnimationModule._tillingParamsProperty = ShaderProperty.getByName("renderer_TSATillingParams");
32278
+ TextureSheetAnimationModule._frameMaxCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMaxCurve");
32266
32279
  })();
32267
32280
  (function() {
32268
- TextureSheetAnimationModule._frameMinCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMinCurve");
32281
+ TextureSheetAnimationModule._cycleCountProperty = ShaderProperty.getByName("renderer_TSACycles");
32269
32282
  })();
32270
32283
  (function() {
32271
- TextureSheetAnimationModule._frameMaxCurveProperty = ShaderProperty.getByName("renderer_TSAFrameMaxCurve");
32284
+ TextureSheetAnimationModule._tillingParamsProperty = ShaderProperty.getByName("renderer_TSATillingParams");
32272
32285
  })();
32273
- __decorate([
32274
- deepClone
32275
- ], TextureSheetAnimationModule.prototype, "startFrame", void 0);
32276
32286
  __decorate([
32277
32287
  deepClone
32278
32288
  ], TextureSheetAnimationModule.prototype, "frameOverTime", void 0);
@@ -32287,7 +32297,7 @@ __decorate([
32287
32297
  ], TextureSheetAnimationModule.prototype, "_tiling", void 0);
32288
32298
  __decorate([
32289
32299
  ignoreClone
32290
- ], TextureSheetAnimationModule.prototype, "_textureSheetMacro", void 0);
32300
+ ], TextureSheetAnimationModule.prototype, "_frameCurveMacro", void 0);
32291
32301
  var TextureSheetAnimationType;
32292
32302
  (function(TextureSheetAnimationType) {
32293
32303
  TextureSheetAnimationType[TextureSheetAnimationType["WholeSheet"] = 0] = "WholeSheet";
@@ -33021,12 +33031,18 @@ __decorate([
33021
33031
  instanceVertices[offset + 33] = rot.w;
33022
33032
  }
33023
33033
  // Simulation UV
33024
- if (this.textureSheetAnimation.enabled) {
33025
- var tillingInfo = this.textureSheetAnimation._tillingInfo;
33026
- instanceVertices[offset + ParticleBufferUtils.simulationUVOffset] = tillingInfo.x;
33027
- instanceVertices[offset + 35] = tillingInfo.y;
33028
- instanceVertices[offset + 36] = 0;
33029
- instanceVertices[offset + 37] = 0;
33034
+ if (textureSheetAnimation.enabled) {
33035
+ var frameOverTime = textureSheetAnimation.frameOverTime;
33036
+ var _textureSheetAnimation__tillingInfo = textureSheetAnimation._tillingInfo, x = _textureSheetAnimation__tillingInfo.x, y = _textureSheetAnimation__tillingInfo.y, z = _textureSheetAnimation__tillingInfo.z;
33037
+ var tileRow = 0;
33038
+ if (frameOverTime.mode === exports.ParticleCurveMode.Constant || frameOverTime.mode === exports.ParticleCurveMode.TwoConstants) {
33039
+ tileRow = Math.floor(frameOverTime.evaluate(undefined, textureSheetAnimation._frameOverTimeRand.random()) * z) * x;
33040
+ }
33041
+ var tileRowIndex = Math.floor(tileRow);
33042
+ instanceVertices[offset + ParticleBufferUtils.simulationUVOffset] = x;
33043
+ instanceVertices[offset + 35] = y;
33044
+ instanceVertices[offset + 36] = tileRow - tileRowIndex;
33045
+ instanceVertices[offset + 37] = tileRowIndex * y;
33030
33046
  } else {
33031
33047
  instanceVertices[offset + ParticleBufferUtils.simulationUVOffset] = 1;
33032
33048
  instanceVertices[offset + 35] = 1;