@galacean/engine-core 1.3.12 → 1.3.15

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.
@@ -3192,8 +3192,11 @@ var ShaderFactory = /*#__PURE__*/ function() {
3192
3192
  */ _proto._destroy = function _destroy() {
3193
3193
  var shaderProgramPools = this._shaderProgramPools;
3194
3194
  for(var i = 0, n = shaderProgramPools.length; i < n; i++){
3195
- shaderProgramPools[i]._destroy();
3195
+ var shaderProgramPool = shaderProgramPools[i];
3196
+ shaderProgramPool._destroy();
3197
+ delete shaderProgramPool.engine._shaderProgramPools[this._shaderPassId];
3196
3198
  }
3199
+ // Clear array storing multiple engine shader program pools
3197
3200
  shaderProgramPools.length = 0;
3198
3201
  };
3199
3202
  /**
@@ -23177,7 +23180,8 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
23177
23180
  * Shader program pool.
23178
23181
  * @internal
23179
23182
  */ var ShaderProgramPool = /*#__PURE__*/ function() {
23180
- function ShaderProgramPool() {
23183
+ function ShaderProgramPool(engine) {
23184
+ this.engine = engine;
23181
23185
  this._cacheHierarchyDepth = 1;
23182
23186
  this._cacheMap = Object.create(null);
23183
23187
  }
@@ -23582,7 +23586,7 @@ ShaderPool.init();
23582
23586
  if (length > shaderProgramPools.length) {
23583
23587
  shaderProgramPools.length = length;
23584
23588
  }
23585
- shaderProgramPools[index] = pool = new ShaderProgramPool();
23589
+ shaderProgramPools[index] = pool = new ShaderProgramPool(this);
23586
23590
  shaderPass._shaderProgramPools.push(pool);
23587
23591
  }
23588
23592
  return pool;
@@ -28283,7 +28287,8 @@ exports.AnimatorLayerBlendingMode = void 0;
28283
28287
  var _proto = AnimatorStatePlayData.prototype;
28284
28288
  _proto.reset = function reset(state, stateData, offsetFrameTime) {
28285
28289
  this.state = state;
28286
- this.frameTime = offsetFrameTime;
28290
+ this.playedTime = 0;
28291
+ this.offsetFrameTime = offsetFrameTime;
28287
28292
  this.stateData = stateData;
28288
28293
  this.playState = AnimatorStatePlayState.UnStarted;
28289
28294
  this.clipTime = state.clipStartTime * state.clip.length;
@@ -28302,9 +28307,9 @@ exports.AnimatorLayerBlendingMode = void 0;
28302
28307
  }
28303
28308
  };
28304
28309
  _proto.update = function update(deltaTime) {
28305
- this.frameTime += deltaTime;
28310
+ this.playedTime += deltaTime;
28306
28311
  var state = this.state;
28307
- var time = this.frameTime;
28312
+ var time = this.playedTime + this.offsetFrameTime;
28308
28313
  var duration = state._getDuration();
28309
28314
  this.playState = AnimatorStatePlayState.Playing;
28310
28315
  if (state.wrapMode === exports.WrapMode.Loop) {
@@ -28639,8 +28644,9 @@ exports.AnimatorLayerBlendingMode = void 0;
28639
28644
  eventHandler.event = event;
28640
28645
  handlers.length = 0;
28641
28646
  for(var j = scriptCount - 1; j >= 0; j--){
28647
+ var _script_funcName;
28642
28648
  var script = scripts[j];
28643
- var handler = script[funcName].bind(script);
28649
+ var handler = (_script_funcName = script[funcName]) == null ? void 0 : _script_funcName.bind(script);
28644
28650
  handler && handlers.push(handler);
28645
28651
  }
28646
28652
  eventHandlers.push(eventHandler);
@@ -28750,9 +28756,8 @@ exports.AnimatorLayerBlendingMode = void 0;
28750
28756
  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);
28751
28757
  var playCostTime;
28752
28758
  if (transition) {
28753
- var clipDuration = state.clip.length;
28754
- var clipEndTime = state.clipEndTime * clipDuration;
28755
- var exitTime = transition.exitTime * state._getDuration();
28759
+ var clipEndTime = state._getClipActualEndTime();
28760
+ var exitTime = transition.exitTime * state._getDuration() + state._getClipActualStartTime();
28756
28761
  if (isForwards) {
28757
28762
  if (exitTime < lastClipTime) {
28758
28763
  playCostTime = exitTime + clipEndTime - lastClipTime;
@@ -28760,7 +28765,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28760
28765
  playCostTime = exitTime - lastClipTime;
28761
28766
  }
28762
28767
  } else {
28763
- var startTime = state.clipStartTime * clipDuration;
28768
+ var startTime = state._getClipActualStartTime();
28764
28769
  if (lastClipTime < exitTime) {
28765
28770
  playCostTime = clipEndTime - exitTime + lastClipTime - startTime;
28766
28771
  } else {
@@ -28822,20 +28827,22 @@ exports.AnimatorLayerBlendingMode = void 0;
28822
28827
  var lastDestClipTime = destPlayData.clipTime, lastDstPlayState = destPlayData.playState;
28823
28828
  var dstPlayCostTime;
28824
28829
  if (destPlayData.isForwards) {
28825
- dstPlayCostTime = lastDestClipTime + dstPlayDeltaTime > transitionDuration ? transitionDuration - lastDestClipTime : dstPlayDeltaTime;
28830
+ // The time that has been played
28831
+ var playedTime = destPlayData.playedTime;
28832
+ dstPlayCostTime = playedTime + dstPlayDeltaTime > transitionDuration ? transitionDuration - playedTime : dstPlayDeltaTime;
28826
28833
  } else {
28827
28834
  // The time that has been played
28828
- var playedTime = destStateDuration - lastDestClipTime;
28829
- dstPlayCostTime = // -actualDestDeltaTime: The time that will be played, negative are meant to make ite be a periods
28835
+ var playedTime1 = destPlayData.playedTime;
28836
+ dstPlayCostTime = // -dstPlayDeltaTime: The time that will be played, negative are meant to make it be a periods
28830
28837
  // > transition: The time that will be played is enough to finish the transition
28831
- playedTime - dstPlayDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28832
- playedTime - transitionDuration : dstPlayDeltaTime;
28838
+ playedTime1 - dstPlayDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28839
+ playedTime1 - transitionDuration : dstPlayDeltaTime;
28833
28840
  }
28834
28841
  var actualCostTime = dstPlaySpeed === 0 ? deltaTime : dstPlayCostTime / dstPlaySpeed;
28835
28842
  var srcPlayCostTime = actualCostTime * srcPlaySpeed;
28836
28843
  srcPlayData.update(srcPlayCostTime);
28837
28844
  destPlayData.update(dstPlayCostTime);
28838
- var crossWeight = Math.abs(destPlayData.frameTime) / transitionDuration;
28845
+ var crossWeight = Math.abs(destPlayData.playedTime) / transitionDuration;
28839
28846
  (crossWeight >= 1.0 - miniprogram.MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
28840
28847
  var crossFadeFinished = crossWeight === 1.0;
28841
28848
  if (crossFadeFinished) {
@@ -28885,18 +28892,20 @@ exports.AnimatorLayerBlendingMode = void 0;
28885
28892
  var lastDestClipTime = destPlayData.clipTime, lastPlayState = destPlayData.playState;
28886
28893
  var dstPlayCostTime;
28887
28894
  if (destPlayData.isForwards) {
28888
- dstPlayCostTime = lastDestClipTime + playDeltaTime > transitionDuration ? transitionDuration - lastDestClipTime : playDeltaTime;
28895
+ // The time that has been played
28896
+ var playedTime = destPlayData.playedTime;
28897
+ dstPlayCostTime = playedTime + playDeltaTime > transitionDuration ? transitionDuration - playedTime : playDeltaTime;
28889
28898
  } else {
28890
28899
  // The time that has been played
28891
- var playedTime = stateDuration - lastDestClipTime;
28900
+ var playedTime1 = destPlayData.playedTime;
28892
28901
  dstPlayCostTime = // -actualDestDeltaTime: The time that will be played, negative are meant to make ite be a periods
28893
28902
  // > transition: The time that will be played is enough to finish the transition
28894
- playedTime - playDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28895
- playedTime - transitionDuration : playDeltaTime;
28903
+ playedTime1 - playDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28904
+ playedTime1 - transitionDuration : playDeltaTime;
28896
28905
  }
28897
28906
  var actualCostTime = playSpeed === 0 ? deltaTime : dstPlayCostTime / playSpeed;
28898
28907
  destPlayData.update(dstPlayCostTime);
28899
- var crossWeight = Math.abs(destPlayData.frameTime) / transitionDuration;
28908
+ var crossWeight = Math.abs(destPlayData.playedTime) / transitionDuration;
28900
28909
  (crossWeight >= 1.0 - miniprogram.MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
28901
28910
  var crossFadeFinished = crossWeight === 1.0;
28902
28911
  if (crossFadeFinished) {
@@ -29024,10 +29033,9 @@ exports.AnimatorLayerBlendingMode = void 0;
29024
29033
  _proto._checkSubTransition = function _checkSubTransition(layerIndex, layerData, layer, playState, transitions, lastClipTime, curClipTime, aniUpdate) {
29025
29034
  var state = playState.state;
29026
29035
  var transitionIndex = playState.currentTransitionIndex;
29027
- var duration = state._getDuration();
29028
29036
  for(var n = transitions.length; transitionIndex < n; transitionIndex++){
29029
29037
  var transition = transitions[transitionIndex];
29030
- var exitTime = transition.exitTime * duration;
29038
+ var exitTime = transition.exitTime * state._getDuration() + state._getClipActualStartTime();
29031
29039
  if (exitTime > curClipTime) {
29032
29040
  break;
29033
29041
  }
@@ -29047,10 +29055,9 @@ exports.AnimatorLayerBlendingMode = void 0;
29047
29055
  _proto._checkBackwardsSubTransition = function _checkBackwardsSubTransition(layerIndex, layerData, layer, playState, transitions, lastClipTime, curClipTime, aniUpdate) {
29048
29056
  var state = playState.state;
29049
29057
  var transitionIndex = playState.currentTransitionIndex;
29050
- var duration = playState.state._getDuration();
29051
29058
  for(; transitionIndex >= 0; transitionIndex--){
29052
29059
  var transition = transitions[transitionIndex];
29053
- var exitTime = transition.exitTime * duration;
29060
+ var exitTime = transition.exitTime * state._getDuration() + state._getClipActualStartTime();
29054
29061
  if (exitTime < curClipTime) {
29055
29062
  break;
29056
29063
  }
@@ -29681,6 +29688,16 @@ function _possible_constructor_return(self, call) {
29681
29688
  }
29682
29689
  }
29683
29690
  };
29691
+ /**
29692
+ * @internal
29693
+ */ _proto._getClipActualStartTime = function _getClipActualStartTime() {
29694
+ return this._clipStartTime * this.clip.length;
29695
+ };
29696
+ /**
29697
+ * @internal
29698
+ */ _proto._getClipActualEndTime = function _getClipActualEndTime() {
29699
+ return this._clipEndTime * this.clip.length;
29700
+ };
29684
29701
  _create_class(AnimatorState, [
29685
29702
  {
29686
29703
  key: "transitions",
package/dist/module.js CHANGED
@@ -3187,8 +3187,11 @@ var ShaderFactory = /*#__PURE__*/ function() {
3187
3187
  */ _proto._destroy = function _destroy() {
3188
3188
  var shaderProgramPools = this._shaderProgramPools;
3189
3189
  for(var i = 0, n = shaderProgramPools.length; i < n; i++){
3190
- shaderProgramPools[i]._destroy();
3190
+ var shaderProgramPool = shaderProgramPools[i];
3191
+ shaderProgramPool._destroy();
3192
+ delete shaderProgramPool.engine._shaderProgramPools[this._shaderPassId];
3191
3193
  }
3194
+ // Clear array storing multiple engine shader program pools
3192
3195
  shaderProgramPools.length = 0;
3193
3196
  };
3194
3197
  /**
@@ -23172,7 +23175,8 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
23172
23175
  * Shader program pool.
23173
23176
  * @internal
23174
23177
  */ var ShaderProgramPool = /*#__PURE__*/ function() {
23175
- function ShaderProgramPool() {
23178
+ function ShaderProgramPool(engine) {
23179
+ this.engine = engine;
23176
23180
  this._cacheHierarchyDepth = 1;
23177
23181
  this._cacheMap = Object.create(null);
23178
23182
  }
@@ -23577,7 +23581,7 @@ ShaderPool.init();
23577
23581
  if (length > shaderProgramPools.length) {
23578
23582
  shaderProgramPools.length = length;
23579
23583
  }
23580
- shaderProgramPools[index] = pool = new ShaderProgramPool();
23584
+ shaderProgramPools[index] = pool = new ShaderProgramPool(this);
23581
23585
  shaderPass._shaderProgramPools.push(pool);
23582
23586
  }
23583
23587
  return pool;
@@ -28278,7 +28282,8 @@ var AnimatorLayerBlendingMode;
28278
28282
  var _proto = AnimatorStatePlayData.prototype;
28279
28283
  _proto.reset = function reset(state, stateData, offsetFrameTime) {
28280
28284
  this.state = state;
28281
- this.frameTime = offsetFrameTime;
28285
+ this.playedTime = 0;
28286
+ this.offsetFrameTime = offsetFrameTime;
28282
28287
  this.stateData = stateData;
28283
28288
  this.playState = AnimatorStatePlayState.UnStarted;
28284
28289
  this.clipTime = state.clipStartTime * state.clip.length;
@@ -28297,9 +28302,9 @@ var AnimatorLayerBlendingMode;
28297
28302
  }
28298
28303
  };
28299
28304
  _proto.update = function update(deltaTime) {
28300
- this.frameTime += deltaTime;
28305
+ this.playedTime += deltaTime;
28301
28306
  var state = this.state;
28302
- var time = this.frameTime;
28307
+ var time = this.playedTime + this.offsetFrameTime;
28303
28308
  var duration = state._getDuration();
28304
28309
  this.playState = AnimatorStatePlayState.Playing;
28305
28310
  if (state.wrapMode === WrapMode.Loop) {
@@ -28634,8 +28639,9 @@ var AnimatorLayerBlendingMode;
28634
28639
  eventHandler.event = event;
28635
28640
  handlers.length = 0;
28636
28641
  for(var j = scriptCount - 1; j >= 0; j--){
28642
+ var _script_funcName;
28637
28643
  var script = scripts[j];
28638
- var handler = script[funcName].bind(script);
28644
+ var handler = (_script_funcName = script[funcName]) == null ? void 0 : _script_funcName.bind(script);
28639
28645
  handler && handlers.push(handler);
28640
28646
  }
28641
28647
  eventHandlers.push(eventHandler);
@@ -28745,9 +28751,8 @@ var AnimatorLayerBlendingMode;
28745
28751
  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);
28746
28752
  var playCostTime;
28747
28753
  if (transition) {
28748
- var clipDuration = state.clip.length;
28749
- var clipEndTime = state.clipEndTime * clipDuration;
28750
- var exitTime = transition.exitTime * state._getDuration();
28754
+ var clipEndTime = state._getClipActualEndTime();
28755
+ var exitTime = transition.exitTime * state._getDuration() + state._getClipActualStartTime();
28751
28756
  if (isForwards) {
28752
28757
  if (exitTime < lastClipTime) {
28753
28758
  playCostTime = exitTime + clipEndTime - lastClipTime;
@@ -28755,7 +28760,7 @@ var AnimatorLayerBlendingMode;
28755
28760
  playCostTime = exitTime - lastClipTime;
28756
28761
  }
28757
28762
  } else {
28758
- var startTime = state.clipStartTime * clipDuration;
28763
+ var startTime = state._getClipActualStartTime();
28759
28764
  if (lastClipTime < exitTime) {
28760
28765
  playCostTime = clipEndTime - exitTime + lastClipTime - startTime;
28761
28766
  } else {
@@ -28817,20 +28822,22 @@ var AnimatorLayerBlendingMode;
28817
28822
  var lastDestClipTime = destPlayData.clipTime, lastDstPlayState = destPlayData.playState;
28818
28823
  var dstPlayCostTime;
28819
28824
  if (destPlayData.isForwards) {
28820
- dstPlayCostTime = lastDestClipTime + dstPlayDeltaTime > transitionDuration ? transitionDuration - lastDestClipTime : dstPlayDeltaTime;
28825
+ // The time that has been played
28826
+ var playedTime = destPlayData.playedTime;
28827
+ dstPlayCostTime = playedTime + dstPlayDeltaTime > transitionDuration ? transitionDuration - playedTime : dstPlayDeltaTime;
28821
28828
  } else {
28822
28829
  // The time that has been played
28823
- var playedTime = destStateDuration - lastDestClipTime;
28824
- dstPlayCostTime = // -actualDestDeltaTime: The time that will be played, negative are meant to make ite be a periods
28830
+ var playedTime1 = destPlayData.playedTime;
28831
+ dstPlayCostTime = // -dstPlayDeltaTime: The time that will be played, negative are meant to make it be a periods
28825
28832
  // > transition: The time that will be played is enough to finish the transition
28826
- playedTime - dstPlayDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28827
- playedTime - transitionDuration : dstPlayDeltaTime;
28833
+ playedTime1 - dstPlayDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28834
+ playedTime1 - transitionDuration : dstPlayDeltaTime;
28828
28835
  }
28829
28836
  var actualCostTime = dstPlaySpeed === 0 ? deltaTime : dstPlayCostTime / dstPlaySpeed;
28830
28837
  var srcPlayCostTime = actualCostTime * srcPlaySpeed;
28831
28838
  srcPlayData.update(srcPlayCostTime);
28832
28839
  destPlayData.update(dstPlayCostTime);
28833
- var crossWeight = Math.abs(destPlayData.frameTime) / transitionDuration;
28840
+ var crossWeight = Math.abs(destPlayData.playedTime) / transitionDuration;
28834
28841
  (crossWeight >= 1.0 - MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
28835
28842
  var crossFadeFinished = crossWeight === 1.0;
28836
28843
  if (crossFadeFinished) {
@@ -28880,18 +28887,20 @@ var AnimatorLayerBlendingMode;
28880
28887
  var lastDestClipTime = destPlayData.clipTime, lastPlayState = destPlayData.playState;
28881
28888
  var dstPlayCostTime;
28882
28889
  if (destPlayData.isForwards) {
28883
- dstPlayCostTime = lastDestClipTime + playDeltaTime > transitionDuration ? transitionDuration - lastDestClipTime : playDeltaTime;
28890
+ // The time that has been played
28891
+ var playedTime = destPlayData.playedTime;
28892
+ dstPlayCostTime = playedTime + playDeltaTime > transitionDuration ? transitionDuration - playedTime : playDeltaTime;
28884
28893
  } else {
28885
28894
  // The time that has been played
28886
- var playedTime = stateDuration - lastDestClipTime;
28895
+ var playedTime1 = destPlayData.playedTime;
28887
28896
  dstPlayCostTime = // -actualDestDeltaTime: The time that will be played, negative are meant to make ite be a periods
28888
28897
  // > transition: The time that will be played is enough to finish the transition
28889
- playedTime - playDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28890
- playedTime - transitionDuration : playDeltaTime;
28898
+ playedTime1 - playDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28899
+ playedTime1 - transitionDuration : playDeltaTime;
28891
28900
  }
28892
28901
  var actualCostTime = playSpeed === 0 ? deltaTime : dstPlayCostTime / playSpeed;
28893
28902
  destPlayData.update(dstPlayCostTime);
28894
- var crossWeight = Math.abs(destPlayData.frameTime) / transitionDuration;
28903
+ var crossWeight = Math.abs(destPlayData.playedTime) / transitionDuration;
28895
28904
  (crossWeight >= 1.0 - MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
28896
28905
  var crossFadeFinished = crossWeight === 1.0;
28897
28906
  if (crossFadeFinished) {
@@ -29019,10 +29028,9 @@ var AnimatorLayerBlendingMode;
29019
29028
  _proto._checkSubTransition = function _checkSubTransition(layerIndex, layerData, layer, playState, transitions, lastClipTime, curClipTime, aniUpdate) {
29020
29029
  var state = playState.state;
29021
29030
  var transitionIndex = playState.currentTransitionIndex;
29022
- var duration = state._getDuration();
29023
29031
  for(var n = transitions.length; transitionIndex < n; transitionIndex++){
29024
29032
  var transition = transitions[transitionIndex];
29025
- var exitTime = transition.exitTime * duration;
29033
+ var exitTime = transition.exitTime * state._getDuration() + state._getClipActualStartTime();
29026
29034
  if (exitTime > curClipTime) {
29027
29035
  break;
29028
29036
  }
@@ -29042,10 +29050,9 @@ var AnimatorLayerBlendingMode;
29042
29050
  _proto._checkBackwardsSubTransition = function _checkBackwardsSubTransition(layerIndex, layerData, layer, playState, transitions, lastClipTime, curClipTime, aniUpdate) {
29043
29051
  var state = playState.state;
29044
29052
  var transitionIndex = playState.currentTransitionIndex;
29045
- var duration = playState.state._getDuration();
29046
29053
  for(; transitionIndex >= 0; transitionIndex--){
29047
29054
  var transition = transitions[transitionIndex];
29048
- var exitTime = transition.exitTime * duration;
29055
+ var exitTime = transition.exitTime * state._getDuration() + state._getClipActualStartTime();
29049
29056
  if (exitTime < curClipTime) {
29050
29057
  break;
29051
29058
  }
@@ -29676,6 +29683,16 @@ function _possible_constructor_return(self, call) {
29676
29683
  }
29677
29684
  }
29678
29685
  };
29686
+ /**
29687
+ * @internal
29688
+ */ _proto._getClipActualStartTime = function _getClipActualStartTime() {
29689
+ return this._clipStartTime * this.clip.length;
29690
+ };
29691
+ /**
29692
+ * @internal
29693
+ */ _proto._getClipActualEndTime = function _getClipActualEndTime() {
29694
+ return this._clipEndTime * this.clip.length;
29695
+ };
29679
29696
  _create_class(AnimatorState, [
29680
29697
  {
29681
29698
  key: "transitions",