@galacean/engine-core 0.0.0-experimental-shaderlab.2 → 0.0.0-experimental-stateMachine.0
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 +403 -74
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +403 -74
- package/dist/module.js +403 -74
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/animation/Animator.d.ts +30 -1
- package/types/animation/AnimatorCondition.d.ts +13 -0
- package/types/animation/AnimatorController.d.ts +21 -2
- package/types/animation/AnimatorControllerParameter.d.ts +10 -0
- package/types/animation/AnimatorState.d.ts +17 -4
- package/types/animation/AnimatorStateMachine.d.ts +39 -0
- package/types/animation/AnimatorTransition.d.ts +33 -0
- package/types/asset/AssetType.d.ts +0 -4
- package/types/RenderPipeline/MeshRenderData.d.ts +0 -17
- package/types/RenderPipeline/RenderPass.d.ts +0 -55
- package/types/physics/PhysicsManager.d.ts +0 -76
- package/types/renderingHardwareInterface/IHardwareRenderer.d.ts +0 -6
- /package/types/RenderPipeline/{Index.d.ts → index.d.ts} +0 -0
package/dist/module.js
CHANGED
|
@@ -4936,7 +4936,8 @@ __decorate([
|
|
|
4936
4936
|
}
|
|
4937
4937
|
var shaderInfo = Shader._shaderLab.parseShader(nameOrShaderSource);
|
|
4938
4938
|
if (shaderMap[shaderInfo.name]) {
|
|
4939
|
-
|
|
4939
|
+
console.error('Shader named "' + shaderInfo.name + '" already exists.');
|
|
4940
|
+
return;
|
|
4940
4941
|
}
|
|
4941
4942
|
var subShaderList = shaderInfo.subShaders.map(function(subShaderInfo) {
|
|
4942
4943
|
var passList = subShaderInfo.passes.map(function(passInfo) {
|
|
@@ -4975,7 +4976,8 @@ __decorate([
|
|
|
4975
4976
|
return shader;
|
|
4976
4977
|
} else {
|
|
4977
4978
|
if (shaderMap[nameOrShaderSource]) {
|
|
4978
|
-
|
|
4979
|
+
console.error('Shader named "' + nameOrShaderSource + '" already exists.');
|
|
4980
|
+
return;
|
|
4979
4981
|
}
|
|
4980
4982
|
if (typeof vertexSourceOrShaderPassesOrSubShaders === "string") {
|
|
4981
4983
|
var shaderPass = new ShaderPass(vertexSourceOrShaderPassesOrSubShaders, fragmentSource);
|
|
@@ -16081,8 +16083,6 @@ var TextRenderData = /*#__PURE__*/ function(RenderData1) {
|
|
|
16081
16083
|
AssetType[/** 2D Texture. */ "Texture2D"] = "Texture2D";
|
|
16082
16084
|
AssetType[/** Cube Texture. */ "TextureCube"] = "TextureCube";
|
|
16083
16085
|
AssetType[/** Material. */ "Material"] = "Material";
|
|
16084
|
-
AssetType[/** Shader */ "Shader"] = "Shader";
|
|
16085
|
-
AssetType[/** Shader Chunk */ "ShaderChunk"] = "ShaderChunk";
|
|
16086
16086
|
AssetType[/** Mesh. */ "Mesh"] = "Mesh";
|
|
16087
16087
|
AssetType[/** AnimationClip. */ "AnimationClip"] = "AnimationClip";
|
|
16088
16088
|
AssetType[/** AnimatorController. */ "AnimatorController"] = "AnimatorController";
|
|
@@ -22124,9 +22124,10 @@ __decorate([
|
|
|
22124
22124
|
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
22125
22125
|
var _this = this, spotLight = _this._spotLights, pointLight = _this._pointLights, directLight = _this._directLights;
|
|
22126
22126
|
var _this1 = this, spotData = _this1._spotData, pointData = _this1._pointData, directData = _this1._directData;
|
|
22127
|
-
var
|
|
22128
|
-
var
|
|
22129
|
-
var
|
|
22127
|
+
var maxLight = LightManager._maxLight;
|
|
22128
|
+
var spotLightCount = Math.min(spotLight.length, maxLight);
|
|
22129
|
+
var pointLightCount = Math.min(pointLight.length, maxLight);
|
|
22130
|
+
var directLightCount = Math.min(directLight.length, maxLight);
|
|
22130
22131
|
for(var i = 0; i < spotLightCount; i++){
|
|
22131
22132
|
spotLight.get(i)._appendData(i, spotData);
|
|
22132
22133
|
}
|
|
@@ -26948,13 +26949,71 @@ var AnimatorLayerBlendingMode;
|
|
|
26948
26949
|
}();
|
|
26949
26950
|
|
|
26950
26951
|
/**
|
|
26951
|
-
*
|
|
26952
|
-
*/ var
|
|
26953
|
-
/** The duration of the transition. This is represented in normalized time. */ this.duration = 0;
|
|
26954
|
-
/** The time at which the destination state will start. This is represented in normalized time. */ this.offset = 0;
|
|
26955
|
-
/** ExitTime represents the exact time at which the transition can take effect. This is represented in normalized time. */ this.exitTime = 1;
|
|
26952
|
+
* Condition that is used to determine if a transition must be taken.
|
|
26953
|
+
*/ var AnimatorCondition = function AnimatorCondition() {
|
|
26956
26954
|
};
|
|
26957
26955
|
|
|
26956
|
+
/**
|
|
26957
|
+
* Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.
|
|
26958
|
+
*/ var AnimatorStateTransition = /*#__PURE__*/ function() {
|
|
26959
|
+
function AnimatorStateTransition() {
|
|
26960
|
+
/** The duration of the transition. This is represented in normalized time. */ this.duration = 0;
|
|
26961
|
+
/** The time at which the destination state will start. This is represented in normalized time. */ this.offset = 0;
|
|
26962
|
+
/** ExitTime represents the exact time at which the transition can take effect. This is represented in normalized time. */ this.exitTime = 1;
|
|
26963
|
+
/** Mutes the transition. The transition will never occur. */ this.mute = false;
|
|
26964
|
+
/** Is the transition destination the exit of the current state machine. */ this.isExit = false;
|
|
26965
|
+
this._conditions = [];
|
|
26966
|
+
this._solo = false;
|
|
26967
|
+
}
|
|
26968
|
+
var _proto = AnimatorStateTransition.prototype;
|
|
26969
|
+
_proto.addCondition = function addCondition(param, parameter, threshold) {
|
|
26970
|
+
if (typeof param === "object") {
|
|
26971
|
+
this._conditions.push(param);
|
|
26972
|
+
return param;
|
|
26973
|
+
} else {
|
|
26974
|
+
var condition = new AnimatorCondition();
|
|
26975
|
+
condition.mode = param;
|
|
26976
|
+
condition.parameter = parameter;
|
|
26977
|
+
condition.threshold = threshold;
|
|
26978
|
+
this._conditions.push(condition);
|
|
26979
|
+
return condition;
|
|
26980
|
+
}
|
|
26981
|
+
};
|
|
26982
|
+
/**
|
|
26983
|
+
* Remove a condition from the transition.
|
|
26984
|
+
* @param condition - The condition to remove
|
|
26985
|
+
*/ _proto.removeCondition = function removeCondition(condition) {
|
|
26986
|
+
var index = this._conditions.indexOf(condition);
|
|
26987
|
+
index !== -1 && this._conditions.splice(index, 1);
|
|
26988
|
+
};
|
|
26989
|
+
_create_class(AnimatorStateTransition, [
|
|
26990
|
+
{
|
|
26991
|
+
key: "solo",
|
|
26992
|
+
get: /** Mutes all other transitions in the source state. */ function get() {
|
|
26993
|
+
return this._solo;
|
|
26994
|
+
},
|
|
26995
|
+
set: function set(value) {
|
|
26996
|
+
if (this._solo === value) return;
|
|
26997
|
+
this._solo = value;
|
|
26998
|
+
if (value) {
|
|
26999
|
+
this._srcState && this._srcState._updateSoloTransition(true);
|
|
27000
|
+
} else {
|
|
27001
|
+
this._srcState && this._srcState._updateSoloTransition();
|
|
27002
|
+
}
|
|
27003
|
+
}
|
|
27004
|
+
},
|
|
27005
|
+
{
|
|
27006
|
+
key: "conditions",
|
|
27007
|
+
get: /**
|
|
27008
|
+
* The conditions in the transition.
|
|
27009
|
+
*/ function get() {
|
|
27010
|
+
return this._conditions;
|
|
27011
|
+
}
|
|
27012
|
+
}
|
|
27013
|
+
]);
|
|
27014
|
+
return AnimatorStateTransition;
|
|
27015
|
+
}();
|
|
27016
|
+
|
|
26958
27017
|
/**
|
|
26959
27018
|
* Animation wrap mode.
|
|
26960
27019
|
*/ var WrapMode;
|
|
@@ -27030,6 +27089,16 @@ var AnimatorLayerBlendingMode;
|
|
|
27030
27089
|
this.eventHandlers = [];
|
|
27031
27090
|
};
|
|
27032
27091
|
|
|
27092
|
+
var AnimatorConditionMode;
|
|
27093
|
+
(function(AnimatorConditionMode) {
|
|
27094
|
+
AnimatorConditionMode[AnimatorConditionMode["If"] = 0] = "If";
|
|
27095
|
+
AnimatorConditionMode[AnimatorConditionMode["IfNot"] = 1] = "IfNot";
|
|
27096
|
+
AnimatorConditionMode[AnimatorConditionMode["Greater"] = 2] = "Greater";
|
|
27097
|
+
AnimatorConditionMode[AnimatorConditionMode["Less"] = 3] = "Less";
|
|
27098
|
+
AnimatorConditionMode[AnimatorConditionMode["Equals"] = 4] = "Equals";
|
|
27099
|
+
AnimatorConditionMode[AnimatorConditionMode["NotEquals"] = 5] = "NotEquals";
|
|
27100
|
+
})(AnimatorConditionMode || (AnimatorConditionMode = {}));
|
|
27101
|
+
|
|
27033
27102
|
/**
|
|
27034
27103
|
* The controller of the animation system.
|
|
27035
27104
|
*/ var Animator = /*#__PURE__*/ function(Component1) {
|
|
@@ -27082,26 +27151,29 @@ var AnimatorLayerBlendingMode;
|
|
|
27082
27151
|
animatorLayerData.srcPlayData.reset(state, animatorStateData, state._getDuration() * normalizedTimeOffset);
|
|
27083
27152
|
this.update(0);
|
|
27084
27153
|
};
|
|
27085
|
-
|
|
27086
|
-
* Create a cross fade from the current state to another state.
|
|
27087
|
-
* @param stateName - The state name
|
|
27088
|
-
* @param normalizedTransitionDuration - The duration of the transition (normalized)
|
|
27089
|
-
* @param layerIndex - The layer index(default -1). If layer is -1, play the first state with the given state name
|
|
27090
|
-
* @param normalizedTimeOffset - The time offset between 0 and 1(default 0)
|
|
27091
|
-
*/ _proto.crossFade = function crossFade(stateName, normalizedTransitionDuration, layerIndex, normalizedTimeOffset) {
|
|
27154
|
+
_proto.crossFade = function crossFade(stateNameOrTransition, normalizedTransitionDurationOrLayerIndex, layerIndex, normalizedTimeOffset) {
|
|
27092
27155
|
if (layerIndex === void 0) layerIndex = -1;
|
|
27093
27156
|
if (normalizedTimeOffset === void 0) normalizedTimeOffset = 0;
|
|
27094
|
-
var
|
|
27095
|
-
|
|
27096
|
-
|
|
27157
|
+
var state;
|
|
27158
|
+
var playLayerIndex;
|
|
27159
|
+
var normalizedTransitionDuration;
|
|
27160
|
+
var transition;
|
|
27161
|
+
if (typeof stateNameOrTransition === "string") {
|
|
27162
|
+
var info = this._getAnimatorStateInfo(stateNameOrTransition, layerIndex);
|
|
27163
|
+
state = info.state;
|
|
27164
|
+
playLayerIndex = info.layerIndex;
|
|
27165
|
+
normalizedTransitionDuration = normalizedTransitionDurationOrLayerIndex;
|
|
27166
|
+
var manuallyTransition = this._getAnimatorLayerData(playLayerIndex).manuallyTransition;
|
|
27167
|
+
manuallyTransition.duration = normalizedTransitionDuration;
|
|
27168
|
+
manuallyTransition.offset = normalizedTimeOffset;
|
|
27169
|
+
manuallyTransition.destinationState = state;
|
|
27170
|
+
transition = manuallyTransition;
|
|
27171
|
+
} else {
|
|
27172
|
+
state = stateNameOrTransition.destinationState;
|
|
27173
|
+
playLayerIndex = normalizedTransitionDurationOrLayerIndex != null ? normalizedTransitionDurationOrLayerIndex : this._getAnimatorStateInfo(state.name, playLayerIndex).layerIndex;
|
|
27174
|
+
transition = stateNameOrTransition;
|
|
27097
27175
|
}
|
|
27098
|
-
this.
|
|
27099
|
-
var _this__getAnimatorStateInfo = this._getAnimatorStateInfo(stateName, layerIndex), state = _this__getAnimatorStateInfo.state, playLayerIndex = _this__getAnimatorStateInfo.layerIndex;
|
|
27100
|
-
var manuallyTransition = this._getAnimatorLayerData(playLayerIndex).manuallyTransition;
|
|
27101
|
-
manuallyTransition.duration = normalizedTransitionDuration;
|
|
27102
|
-
manuallyTransition.offset = normalizedTimeOffset;
|
|
27103
|
-
manuallyTransition.destinationState = state;
|
|
27104
|
-
if (this._crossFadeByTransition(manuallyTransition, playLayerIndex)) {
|
|
27176
|
+
if (this._crossFadeByTransition(transition, playLayerIndex)) {
|
|
27105
27177
|
this.update(0);
|
|
27106
27178
|
}
|
|
27107
27179
|
};
|
|
@@ -27128,7 +27200,7 @@ var AnimatorLayerBlendingMode;
|
|
|
27128
27200
|
return;
|
|
27129
27201
|
}
|
|
27130
27202
|
if ((_this__controllerUpdateFlag = this._controllerUpdateFlag) == null ? void 0 : _this__controllerUpdateFlag.flag) {
|
|
27131
|
-
this.
|
|
27203
|
+
this._checkEntryState();
|
|
27132
27204
|
return;
|
|
27133
27205
|
}
|
|
27134
27206
|
this._updateMark++;
|
|
@@ -27156,9 +27228,31 @@ var AnimatorLayerBlendingMode;
|
|
|
27156
27228
|
return this._getAnimatorStateInfo(stateName, layerIndex).state;
|
|
27157
27229
|
};
|
|
27158
27230
|
/**
|
|
27231
|
+
* Get the layer by name.
|
|
27232
|
+
* @param name - The layer's name.
|
|
27233
|
+
*/ _proto.findLayerByName = function findLayerByName(name1) {
|
|
27234
|
+
return this._animatorController._layersMap[name1];
|
|
27235
|
+
};
|
|
27236
|
+
/**
|
|
27237
|
+
* Get the parameter by name.
|
|
27238
|
+
* @param name - The name of the parameter
|
|
27239
|
+
*/ _proto.getParameter = function getParameter(name1) {
|
|
27240
|
+
return this._animatorController._parametersMap[name1] || null;
|
|
27241
|
+
};
|
|
27242
|
+
/**
|
|
27243
|
+
* Set the value of the given parameter.
|
|
27244
|
+
* @param name - The name of the parameter
|
|
27245
|
+
*/ _proto.setParameter = function setParameter(name1, value) {
|
|
27246
|
+
var controller = this._animatorController;
|
|
27247
|
+
var parameter = controller._parametersMap[name1];
|
|
27248
|
+
if (parameter) {
|
|
27249
|
+
parameter.value = value;
|
|
27250
|
+
}
|
|
27251
|
+
};
|
|
27252
|
+
/**
|
|
27159
27253
|
* @internal
|
|
27160
27254
|
*/ _proto._onEnable = function _onEnable() {
|
|
27161
|
-
this.animatorController && this.
|
|
27255
|
+
this.animatorController && this._checkEntryState();
|
|
27162
27256
|
this._entity.getComponentsIncludeChildren(Renderer, this._controlledRenderers);
|
|
27163
27257
|
};
|
|
27164
27258
|
/**
|
|
@@ -27232,20 +27326,19 @@ var AnimatorLayerBlendingMode;
|
|
|
27232
27326
|
var relativePath = curve.relativePath;
|
|
27233
27327
|
var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
|
|
27234
27328
|
if (targetEntity) {
|
|
27235
|
-
var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners,
|
|
27236
|
-
var propertyPath = "" + curve.typeIndex + "." + curve.property;
|
|
27329
|
+
var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
|
|
27237
27330
|
var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
|
|
27238
27331
|
if (!component) {
|
|
27239
27332
|
continue;
|
|
27240
27333
|
}
|
|
27241
27334
|
var property = curve.property;
|
|
27242
|
-
var instanceId =
|
|
27335
|
+
var instanceId = component.instanceId;
|
|
27243
27336
|
// Get owner
|
|
27244
27337
|
var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
|
|
27245
27338
|
var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity, component));
|
|
27246
27339
|
// Get layer owner
|
|
27247
27340
|
var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
|
|
27248
|
-
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[
|
|
27341
|
+
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
|
|
27249
27342
|
if (mask && mask.pathMasks.length) {
|
|
27250
27343
|
var _mask_getPathMask;
|
|
27251
27344
|
var _mask_getPathMask_active;
|
|
@@ -27350,7 +27443,8 @@ var AnimatorLayerBlendingMode;
|
|
|
27350
27443
|
return animatorLayerData;
|
|
27351
27444
|
};
|
|
27352
27445
|
_proto._updateLayer = function _updateLayer(layerIndex, firstLayer, deltaTime, aniUpdate) {
|
|
27353
|
-
var _this__animatorController_layers_layerIndex = this._animatorController.layers[layerIndex], blendingMode = _this__animatorController_layers_layerIndex.blendingMode, weight = _this__animatorController_layers_layerIndex.weight;
|
|
27446
|
+
var _this__animatorController_layers_layerIndex = this._animatorController.layers[layerIndex], blendingMode = _this__animatorController_layers_layerIndex.blendingMode, weight = _this__animatorController_layers_layerIndex.weight, stateMachine = _this__animatorController_layers_layerIndex.stateMachine;
|
|
27447
|
+
if (!stateMachine) return;
|
|
27354
27448
|
var layerData = this._animatorLayersData[layerIndex];
|
|
27355
27449
|
var srcPlayData = layerData.srcPlayData, destPlayData = layerData.destPlayData;
|
|
27356
27450
|
var additive = blendingMode === AnimatorLayerBlendingMode.Additive;
|
|
@@ -27375,6 +27469,7 @@ var AnimatorLayerBlendingMode;
|
|
|
27375
27469
|
var state = playData.state, lastPlayState = playData.playState, lastClipTime = playData.clipTime;
|
|
27376
27470
|
var transitions = state.transitions;
|
|
27377
27471
|
var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
|
|
27472
|
+
var anyStateTransitions = this.layers[layerIndex].stateMachine.anyStateTransitions;
|
|
27378
27473
|
var speed = state.speed * this.speed;
|
|
27379
27474
|
playData.frameTime += speed * delta;
|
|
27380
27475
|
playData.update(speed < 0);
|
|
@@ -27407,10 +27502,10 @@ var AnimatorLayerBlendingMode;
|
|
|
27407
27502
|
} else {
|
|
27408
27503
|
this._callAnimatorScriptOnUpdate(state, layerIndex);
|
|
27409
27504
|
}
|
|
27410
|
-
if (transitions.length) {
|
|
27505
|
+
if (transitions.length || anyStateTransitions.length) {
|
|
27411
27506
|
var layerState = layerData.layerState;
|
|
27412
27507
|
if (layerState !== LayerState.CrossFading && layerState !== LayerState.FixedCrossFading) {
|
|
27413
|
-
this._checkTransition(playData, transitions, layerIndex, lastClipTime, clipTime);
|
|
27508
|
+
this._checkTransition(playData, transitions, anyStateTransitions, layerIndex, lastClipTime, clipTime);
|
|
27414
27509
|
}
|
|
27415
27510
|
}
|
|
27416
27511
|
};
|
|
@@ -27556,43 +27651,61 @@ var AnimatorLayerBlendingMode;
|
|
|
27556
27651
|
}
|
|
27557
27652
|
}
|
|
27558
27653
|
};
|
|
27559
|
-
_proto._checkTransition = function _checkTransition(playState, transitions, layerIndex, lastClipTime, clipTime) {
|
|
27654
|
+
_proto._checkTransition = function _checkTransition(playState, transitions, anyStateTransitions, layerIndex, lastClipTime, clipTime) {
|
|
27560
27655
|
var state = playState.state;
|
|
27561
27656
|
var clipDuration = state.clip.length;
|
|
27657
|
+
var targetTransition = null;
|
|
27562
27658
|
if (this.speed * state.speed >= 0) {
|
|
27563
27659
|
if (clipTime < lastClipTime) {
|
|
27564
|
-
this._checkSubTransition(playState, transitions, layerIndex, lastClipTime, state.clipEndTime * clipDuration);
|
|
27565
|
-
|
|
27566
|
-
|
|
27660
|
+
targetTransition = this._checkSubTransition(playState, transitions, layerIndex, lastClipTime, state.clipEndTime * clipDuration);
|
|
27661
|
+
if (!targetTransition) {
|
|
27662
|
+
playState.currentTransitionIndex = 0;
|
|
27663
|
+
targetTransition = this._checkSubTransition(playState, transitions, layerIndex, state.clipStartTime * clipDuration, clipTime);
|
|
27664
|
+
}
|
|
27567
27665
|
} else {
|
|
27568
|
-
this._checkSubTransition(playState, transitions, layerIndex, lastClipTime, clipTime);
|
|
27666
|
+
targetTransition = this._checkSubTransition(playState, transitions, layerIndex, lastClipTime, clipTime);
|
|
27569
27667
|
}
|
|
27570
27668
|
} else {
|
|
27571
27669
|
if (clipTime > lastClipTime) {
|
|
27572
|
-
this._checkBackwardsSubTransition(playState, transitions, layerIndex, lastClipTime, state.clipStartTime * clipDuration);
|
|
27573
|
-
|
|
27574
|
-
|
|
27670
|
+
targetTransition = this._checkBackwardsSubTransition(playState, transitions, layerIndex, lastClipTime, state.clipStartTime * clipDuration);
|
|
27671
|
+
if (!targetTransition) {
|
|
27672
|
+
playState.currentTransitionIndex = transitions.length - 1;
|
|
27673
|
+
targetTransition = this._checkBackwardsSubTransition(playState, transitions, layerIndex, clipTime, state.clipEndTime * clipDuration);
|
|
27674
|
+
}
|
|
27575
27675
|
} else {
|
|
27576
|
-
this._checkBackwardsSubTransition(playState, transitions, layerIndex, lastClipTime, clipTime);
|
|
27676
|
+
targetTransition = this._checkBackwardsSubTransition(playState, transitions, layerIndex, lastClipTime, clipTime);
|
|
27677
|
+
}
|
|
27678
|
+
}
|
|
27679
|
+
if (!targetTransition) {
|
|
27680
|
+
for(var i = 0, n = anyStateTransitions.length; i < n; ++i){
|
|
27681
|
+
var transition = anyStateTransitions[i];
|
|
27682
|
+
if (this._checkConditions(state, transition)) {
|
|
27683
|
+
this._crossFadeByTransition(transition, layerIndex);
|
|
27684
|
+
break;
|
|
27685
|
+
}
|
|
27577
27686
|
}
|
|
27578
27687
|
}
|
|
27579
27688
|
};
|
|
27580
27689
|
_proto._checkSubTransition = function _checkSubTransition(playState, transitions, layerIndex, lastClipTime, curClipTime) {
|
|
27690
|
+
var state = playState.state;
|
|
27581
27691
|
var transitionIndex = playState.currentTransitionIndex;
|
|
27582
|
-
var duration =
|
|
27692
|
+
var duration = state._getDuration();
|
|
27583
27693
|
for(var n = transitions.length; transitionIndex < n; transitionIndex++){
|
|
27584
27694
|
var transition = transitions[transitionIndex];
|
|
27585
27695
|
var exitTime = transition.exitTime * duration;
|
|
27586
27696
|
if (exitTime > curClipTime) {
|
|
27587
27697
|
break;
|
|
27588
27698
|
}
|
|
27589
|
-
if (exitTime >= lastClipTime) {
|
|
27590
|
-
this._crossFadeByTransition(transition, layerIndex);
|
|
27699
|
+
if (exitTime >= lastClipTime && this._checkConditions(state, transition)) {
|
|
27591
27700
|
playState.currentTransitionIndex = Math.min(transitionIndex + 1, n - 1);
|
|
27701
|
+
this._applyTransition(transition, layerIndex);
|
|
27702
|
+
return transition;
|
|
27592
27703
|
}
|
|
27593
27704
|
}
|
|
27705
|
+
return null;
|
|
27594
27706
|
};
|
|
27595
27707
|
_proto._checkBackwardsSubTransition = function _checkBackwardsSubTransition(playState, transitions, layerIndex, lastClipTime, curClipTime) {
|
|
27708
|
+
var state = playState.state;
|
|
27596
27709
|
var transitionIndex = playState.currentTransitionIndex;
|
|
27597
27710
|
var duration = playState.state._getDuration();
|
|
27598
27711
|
for(; transitionIndex >= 0; transitionIndex--){
|
|
@@ -27601,14 +27714,76 @@ var AnimatorLayerBlendingMode;
|
|
|
27601
27714
|
if (exitTime < curClipTime) {
|
|
27602
27715
|
break;
|
|
27603
27716
|
}
|
|
27604
|
-
if (exitTime <= lastClipTime) {
|
|
27605
|
-
this._crossFadeByTransition(transition, layerIndex);
|
|
27717
|
+
if (exitTime <= lastClipTime && this._checkConditions(state, transition)) {
|
|
27606
27718
|
playState.currentTransitionIndex = Math.max(transitionIndex - 1, 0);
|
|
27719
|
+
this._applyTransition(transition, layerIndex);
|
|
27720
|
+
return transition;
|
|
27721
|
+
}
|
|
27722
|
+
}
|
|
27723
|
+
return null;
|
|
27724
|
+
};
|
|
27725
|
+
_proto._applyTransition = function _applyTransition(transition, layerIndex) {
|
|
27726
|
+
if (transition.isExit) {
|
|
27727
|
+
this._checkEntryState();
|
|
27728
|
+
return;
|
|
27729
|
+
}
|
|
27730
|
+
this._crossFadeByTransition(transition, layerIndex);
|
|
27731
|
+
};
|
|
27732
|
+
_proto._checkConditions = function _checkConditions(state, transition) {
|
|
27733
|
+
var mute = transition.mute, conditions = transition.conditions, solo = transition.solo;
|
|
27734
|
+
if (mute) return false;
|
|
27735
|
+
if (state && state._hasSoloTransition && !solo) return false;
|
|
27736
|
+
var allPass = true;
|
|
27737
|
+
for(var i = 0, n = conditions.length; i < n; ++i){
|
|
27738
|
+
var pass = false;
|
|
27739
|
+
var _conditions_i = conditions[i], mode = _conditions_i.mode, name1 = _conditions_i.parameter, threshold = _conditions_i.threshold;
|
|
27740
|
+
var parameter = this.getParameter(name1);
|
|
27741
|
+
switch(mode){
|
|
27742
|
+
case AnimatorConditionMode.Equals:
|
|
27743
|
+
if (parameter.value === threshold) {
|
|
27744
|
+
pass = true;
|
|
27745
|
+
}
|
|
27746
|
+
break;
|
|
27747
|
+
case AnimatorConditionMode.Greater:
|
|
27748
|
+
if (parameter.value > threshold) {
|
|
27749
|
+
pass = true;
|
|
27750
|
+
}
|
|
27751
|
+
break;
|
|
27752
|
+
case AnimatorConditionMode.Less:
|
|
27753
|
+
if (parameter.value < threshold) {
|
|
27754
|
+
pass = true;
|
|
27755
|
+
}
|
|
27756
|
+
break;
|
|
27757
|
+
case AnimatorConditionMode.NotEquals:
|
|
27758
|
+
if (parameter.value !== threshold) {
|
|
27759
|
+
pass = true;
|
|
27760
|
+
}
|
|
27761
|
+
break;
|
|
27762
|
+
case AnimatorConditionMode.If:
|
|
27763
|
+
if (parameter.value === true) {
|
|
27764
|
+
pass = true;
|
|
27765
|
+
}
|
|
27766
|
+
break;
|
|
27767
|
+
case AnimatorConditionMode.IfNot:
|
|
27768
|
+
if (parameter.value === false) {
|
|
27769
|
+
pass = true;
|
|
27770
|
+
}
|
|
27771
|
+
break;
|
|
27772
|
+
}
|
|
27773
|
+
if (!pass) {
|
|
27774
|
+
allPass = false;
|
|
27775
|
+
break;
|
|
27607
27776
|
}
|
|
27608
27777
|
}
|
|
27778
|
+
return allPass;
|
|
27609
27779
|
};
|
|
27610
27780
|
_proto._crossFadeByTransition = function _crossFadeByTransition(transition, layerIndex) {
|
|
27781
|
+
var _this__controllerUpdateFlag;
|
|
27611
27782
|
var crossState = transition.destinationState;
|
|
27783
|
+
if ((_this__controllerUpdateFlag = this._controllerUpdateFlag) == null ? void 0 : _this__controllerUpdateFlag.flag) {
|
|
27784
|
+
this._reset();
|
|
27785
|
+
}
|
|
27786
|
+
this._playFrameCount = this.engine.time.frameCount;
|
|
27612
27787
|
if (!crossState) {
|
|
27613
27788
|
return false;
|
|
27614
27789
|
}
|
|
@@ -27719,13 +27894,24 @@ var AnimatorLayerBlendingMode;
|
|
|
27719
27894
|
scripts[i].onStateExit(this, state, layerIndex);
|
|
27720
27895
|
}
|
|
27721
27896
|
};
|
|
27722
|
-
_proto.
|
|
27897
|
+
_proto._checkEntryState = function _checkEntryState() {
|
|
27723
27898
|
var layers = this._animatorController.layers;
|
|
27724
27899
|
for(var i = 0, n = layers.length; i < n; ++i){
|
|
27725
|
-
var _stateMachine;
|
|
27726
27900
|
var stateMachine = layers[i].stateMachine;
|
|
27727
|
-
if (
|
|
27728
|
-
|
|
27901
|
+
if (!stateMachine) continue;
|
|
27902
|
+
var entryTransitions = stateMachine._entryTransitions;
|
|
27903
|
+
var length = entryTransitions.length;
|
|
27904
|
+
if (length) {
|
|
27905
|
+
for(var j = 0, m = length; j < m; j++){
|
|
27906
|
+
var transition = entryTransitions[j];
|
|
27907
|
+
if (this._checkConditions(null, transition)) {
|
|
27908
|
+
this.crossFade(transition, i);
|
|
27909
|
+
break;
|
|
27910
|
+
}
|
|
27911
|
+
}
|
|
27912
|
+
} else {
|
|
27913
|
+
var defaultState = stateMachine.defaultState;
|
|
27914
|
+
defaultState && this.play(defaultState.name, i);
|
|
27729
27915
|
}
|
|
27730
27916
|
}
|
|
27731
27917
|
};
|
|
@@ -27751,6 +27937,22 @@ var AnimatorLayerBlendingMode;
|
|
|
27751
27937
|
this._animatorController = animatorController;
|
|
27752
27938
|
}
|
|
27753
27939
|
}
|
|
27940
|
+
},
|
|
27941
|
+
{
|
|
27942
|
+
key: "layers",
|
|
27943
|
+
get: /**
|
|
27944
|
+
* The layers in the animator's controller.
|
|
27945
|
+
*/ function get() {
|
|
27946
|
+
return this._animatorController._layers;
|
|
27947
|
+
}
|
|
27948
|
+
},
|
|
27949
|
+
{
|
|
27950
|
+
key: "parameters",
|
|
27951
|
+
get: /**
|
|
27952
|
+
* The parameters in the animator's controller.
|
|
27953
|
+
*/ function get() {
|
|
27954
|
+
return this._animatorController._parameters;
|
|
27955
|
+
}
|
|
27754
27956
|
}
|
|
27755
27957
|
]);
|
|
27756
27958
|
return Animator;
|
|
@@ -27780,15 +27982,46 @@ __decorate([
|
|
|
27780
27982
|
ignoreClone
|
|
27781
27983
|
], Animator.prototype, "_controlledRenderers", void 0);
|
|
27782
27984
|
|
|
27985
|
+
/**
|
|
27986
|
+
* Used to communicate between scripting and the controller, parameters can be set in scripting and used by the controller.
|
|
27987
|
+
*/ var AnimatorControllerParameter = function AnimatorControllerParameter() {
|
|
27988
|
+
};
|
|
27989
|
+
|
|
27783
27990
|
/**
|
|
27784
27991
|
* Store the data for Animator playback.
|
|
27785
27992
|
*/ var AnimatorController = /*#__PURE__*/ function() {
|
|
27786
27993
|
function AnimatorController() {
|
|
27994
|
+
/** @internal */ this._parameters = [];
|
|
27995
|
+
/** @internal */ this._parametersMap = {};
|
|
27996
|
+
/** @internal */ this._layers = [];
|
|
27997
|
+
/** @internal */ this._layersMap = {};
|
|
27787
27998
|
this._updateFlagManager = new UpdateFlagManager();
|
|
27788
|
-
this._layers = [];
|
|
27789
|
-
this._layersMap = {};
|
|
27790
27999
|
}
|
|
27791
28000
|
var _proto = AnimatorController.prototype;
|
|
28001
|
+
_proto.addParameter = function addParameter(param, defaultValue) {
|
|
28002
|
+
if (typeof param === "string") {
|
|
28003
|
+
var parameter = new AnimatorControllerParameter();
|
|
28004
|
+
parameter.name = param;
|
|
28005
|
+
parameter.value = defaultValue;
|
|
28006
|
+
this._parametersMap[param] = parameter;
|
|
28007
|
+
this._parameters.push(parameter);
|
|
28008
|
+
return parameter;
|
|
28009
|
+
} else {
|
|
28010
|
+
this._parametersMap[param.name] = param;
|
|
28011
|
+
this._parameters.push(param);
|
|
28012
|
+
return param;
|
|
28013
|
+
}
|
|
28014
|
+
};
|
|
28015
|
+
/**
|
|
28016
|
+
* Remove a parameter from the controller.
|
|
28017
|
+
* @param parameter - The parameter
|
|
28018
|
+
*/ _proto.removeParameter = function removeParameter(parameter) {
|
|
28019
|
+
var index = this._parameters.indexOf(parameter);
|
|
28020
|
+
if (index !== -1) {
|
|
28021
|
+
this._parameters.splice(index, 1);
|
|
28022
|
+
delete this._parametersMap[parameter.name];
|
|
28023
|
+
}
|
|
28024
|
+
};
|
|
27792
28025
|
/**
|
|
27793
28026
|
* Get the layer by name.
|
|
27794
28027
|
* @param name - The layer's name.
|
|
@@ -27834,6 +28067,14 @@ __decorate([
|
|
|
27834
28067
|
*/ function get() {
|
|
27835
28068
|
return this._layers;
|
|
27836
28069
|
}
|
|
28070
|
+
},
|
|
28071
|
+
{
|
|
28072
|
+
key: "parameters",
|
|
28073
|
+
get: /**
|
|
28074
|
+
* The parameters in the controller.
|
|
28075
|
+
*/ function get() {
|
|
28076
|
+
return this._parameters;
|
|
28077
|
+
}
|
|
27837
28078
|
}
|
|
27838
28079
|
]);
|
|
27839
28080
|
return AnimatorController;
|
|
@@ -27895,16 +28136,22 @@ __decorate([
|
|
|
27895
28136
|
this./** @internal */ _onStateUpdateScripts = [];
|
|
27896
28137
|
this./** @internal */ _onStateExitScripts = [];
|
|
27897
28138
|
this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
28139
|
+
this./** @internal */ _hasSoloTransition = false;
|
|
27898
28140
|
this._clipStartTime = 0;
|
|
27899
28141
|
this._clipEndTime = 1;
|
|
27900
28142
|
this._transitions = [];
|
|
27901
28143
|
this._onClipChanged = this._onClipChanged.bind(this);
|
|
27902
28144
|
}
|
|
27903
28145
|
var _proto = AnimatorState.prototype;
|
|
27904
|
-
|
|
27905
|
-
|
|
27906
|
-
|
|
27907
|
-
|
|
28146
|
+
_proto.addTransition = function addTransition(transitionOrAnimatorState) {
|
|
28147
|
+
var transition;
|
|
28148
|
+
if (_instanceof(transitionOrAnimatorState, AnimatorState)) {
|
|
28149
|
+
transition = new AnimatorStateTransition();
|
|
28150
|
+
transition.destinationState = transitionOrAnimatorState;
|
|
28151
|
+
} else {
|
|
28152
|
+
transition = transitionOrAnimatorState;
|
|
28153
|
+
}
|
|
28154
|
+
transition._srcState = this;
|
|
27908
28155
|
var transitions = this._transitions;
|
|
27909
28156
|
var count = transitions.length;
|
|
27910
28157
|
var time = transition.exitTime;
|
|
@@ -27916,6 +28163,10 @@ __decorate([
|
|
|
27916
28163
|
while(--index >= 0 && time < transitions[index].exitTime);
|
|
27917
28164
|
transitions.splice(index + 1, 0, transition);
|
|
27918
28165
|
}
|
|
28166
|
+
if (transition.solo) {
|
|
28167
|
+
!this._hasSoloTransition && this._updateSoloTransition(true);
|
|
28168
|
+
}
|
|
28169
|
+
return transition;
|
|
27919
28170
|
};
|
|
27920
28171
|
/**
|
|
27921
28172
|
* Remove a transition from the state.
|
|
@@ -27923,6 +28174,7 @@ __decorate([
|
|
|
27923
28174
|
*/ _proto.removeTransition = function removeTransition(transition) {
|
|
27924
28175
|
var index = this._transitions.indexOf(transition);
|
|
27925
28176
|
index !== -1 && this._transitions.splice(index, 1);
|
|
28177
|
+
this._updateSoloTransition();
|
|
27926
28178
|
};
|
|
27927
28179
|
/**
|
|
27928
28180
|
* Adds a state machine script class of type T to the AnimatorState.
|
|
@@ -27977,6 +28229,21 @@ __decorate([
|
|
|
27977
28229
|
*/ _proto._onClipChanged = function _onClipChanged() {
|
|
27978
28230
|
this._updateFlagManager.dispatch();
|
|
27979
28231
|
};
|
|
28232
|
+
/**
|
|
28233
|
+
* @internal
|
|
28234
|
+
*/ _proto._updateSoloTransition = function _updateSoloTransition(hasSolo) {
|
|
28235
|
+
if (hasSolo !== undefined) {
|
|
28236
|
+
this._hasSoloTransition = hasSolo;
|
|
28237
|
+
} else {
|
|
28238
|
+
this._hasSoloTransition = false;
|
|
28239
|
+
for(var i = 0, n = this.transitions.length; i < n; ++i){
|
|
28240
|
+
if (this.transitions[i].solo) {
|
|
28241
|
+
this._hasSoloTransition = true;
|
|
28242
|
+
return;
|
|
28243
|
+
}
|
|
28244
|
+
}
|
|
28245
|
+
}
|
|
28246
|
+
};
|
|
27980
28247
|
_create_class(AnimatorState, [
|
|
27981
28248
|
{
|
|
27982
28249
|
key: "transitions",
|
|
@@ -28007,10 +28274,26 @@ __decorate([
|
|
|
28007
28274
|
clip && clip._updateFlagManager.addListener(this._onClipChanged);
|
|
28008
28275
|
}
|
|
28009
28276
|
},
|
|
28277
|
+
{
|
|
28278
|
+
key: "startTime",
|
|
28279
|
+
get: /**
|
|
28280
|
+
* The start time of this state's clip
|
|
28281
|
+
*/ function get() {
|
|
28282
|
+
return this._clip.length * this._clipStartTime;
|
|
28283
|
+
}
|
|
28284
|
+
},
|
|
28285
|
+
{
|
|
28286
|
+
key: "endTime",
|
|
28287
|
+
get: /**
|
|
28288
|
+
* The end time of this state's clip
|
|
28289
|
+
*/ function get() {
|
|
28290
|
+
return this._clip.length * this._clipEndTime;
|
|
28291
|
+
}
|
|
28292
|
+
},
|
|
28010
28293
|
{
|
|
28011
28294
|
key: "clipStartTime",
|
|
28012
28295
|
get: /**
|
|
28013
|
-
* The start time of the clip, the range is 0 to 1, default is 0.
|
|
28296
|
+
* The normalized start time of the clip, the range is 0 to 1, default is 0.
|
|
28014
28297
|
*/ function get() {
|
|
28015
28298
|
return this._clipStartTime;
|
|
28016
28299
|
},
|
|
@@ -28021,7 +28304,7 @@ __decorate([
|
|
|
28021
28304
|
{
|
|
28022
28305
|
key: "clipEndTime",
|
|
28023
28306
|
get: /**
|
|
28024
|
-
* The end time of the clip, the range is 0 to 1, default is 1.
|
|
28307
|
+
* The normalized end time of the clip, the range is 0 to 1, default is 1.
|
|
28025
28308
|
*/ function get() {
|
|
28026
28309
|
return this._clipEndTime;
|
|
28027
28310
|
},
|
|
@@ -28038,6 +28321,8 @@ __decorate([
|
|
|
28038
28321
|
*/ var AnimatorStateMachine = /*#__PURE__*/ function() {
|
|
28039
28322
|
function AnimatorStateMachine() {
|
|
28040
28323
|
/** The list of states. */ this.states = [];
|
|
28324
|
+
/** @internal */ this._entryTransitions = [];
|
|
28325
|
+
/** @internal */ this._anyStateTransitions = [];
|
|
28041
28326
|
/** @internal */ this._statesMap = {};
|
|
28042
28327
|
}
|
|
28043
28328
|
var _proto = AnimatorStateMachine.prototype;
|
|
@@ -28086,19 +28371,63 @@ __decorate([
|
|
|
28086
28371
|
}
|
|
28087
28372
|
return name;
|
|
28088
28373
|
};
|
|
28374
|
+
_proto.addEntryStateTransition = function addEntryStateTransition(transitionOrAnimatorState) {
|
|
28375
|
+
var transition;
|
|
28376
|
+
if (_instanceof(transitionOrAnimatorState, AnimatorState)) {
|
|
28377
|
+
transition = new AnimatorStateTransition();
|
|
28378
|
+
transition.destinationState = transitionOrAnimatorState;
|
|
28379
|
+
} else {
|
|
28380
|
+
transition = transitionOrAnimatorState;
|
|
28381
|
+
}
|
|
28382
|
+
this._entryTransitions.push(transition);
|
|
28383
|
+
return transition;
|
|
28384
|
+
};
|
|
28385
|
+
/**
|
|
28386
|
+
* Remove an entry transition.
|
|
28387
|
+
* @param transition - The transition
|
|
28388
|
+
*/ _proto.removeEntryStateTransition = function removeEntryStateTransition(transition) {
|
|
28389
|
+
var index = this._entryTransitions.indexOf(transition);
|
|
28390
|
+
index !== -1 && this._entryTransitions.splice(index, 1);
|
|
28391
|
+
};
|
|
28392
|
+
_proto.addAnyStateTransition = function addAnyStateTransition(transitionOrAnimatorState) {
|
|
28393
|
+
var transition;
|
|
28394
|
+
if (_instanceof(transitionOrAnimatorState, AnimatorState)) {
|
|
28395
|
+
transition = new AnimatorStateTransition();
|
|
28396
|
+
transition.destinationState = transitionOrAnimatorState;
|
|
28397
|
+
} else {
|
|
28398
|
+
transition = transitionOrAnimatorState;
|
|
28399
|
+
}
|
|
28400
|
+
this._anyStateTransitions.push(transition);
|
|
28401
|
+
return transition;
|
|
28402
|
+
};
|
|
28403
|
+
/**
|
|
28404
|
+
* Remove an any transition.
|
|
28405
|
+
* @param transition - The transition
|
|
28406
|
+
*/ _proto.removeAnyStateTransition = function removeAnyStateTransition(transition) {
|
|
28407
|
+
var index = this._anyStateTransitions.indexOf(transition);
|
|
28408
|
+
index !== -1 && this._anyStateTransitions.splice(index, 1);
|
|
28409
|
+
};
|
|
28410
|
+
_create_class(AnimatorStateMachine, [
|
|
28411
|
+
{
|
|
28412
|
+
key: "entryTransitions",
|
|
28413
|
+
get: /**
|
|
28414
|
+
* The list of entry transitions in the state machine.
|
|
28415
|
+
*/ function get() {
|
|
28416
|
+
return this._entryTransitions;
|
|
28417
|
+
}
|
|
28418
|
+
},
|
|
28419
|
+
{
|
|
28420
|
+
key: "anyStateTransitions",
|
|
28421
|
+
get: /**
|
|
28422
|
+
* The list of AnyState transitions.
|
|
28423
|
+
*/ function get() {
|
|
28424
|
+
return this._anyStateTransitions;
|
|
28425
|
+
}
|
|
28426
|
+
}
|
|
28427
|
+
]);
|
|
28089
28428
|
return AnimatorStateMachine;
|
|
28090
28429
|
}();
|
|
28091
28430
|
|
|
28092
|
-
var AnimatorConditionMode;
|
|
28093
|
-
(function(AnimatorConditionMode) {
|
|
28094
|
-
AnimatorConditionMode[AnimatorConditionMode["If"] = 0] = "If";
|
|
28095
|
-
AnimatorConditionMode[AnimatorConditionMode["IfNot"] = 1] = "IfNot";
|
|
28096
|
-
AnimatorConditionMode[AnimatorConditionMode["Greater"] = 2] = "Greater";
|
|
28097
|
-
AnimatorConditionMode[AnimatorConditionMode["Less"] = 3] = "Less";
|
|
28098
|
-
AnimatorConditionMode[AnimatorConditionMode["Equals"] = 4] = "Equals";
|
|
28099
|
-
AnimatorConditionMode[AnimatorConditionMode["NotEquals"] = 5] = "NotEquals";
|
|
28100
|
-
})(AnimatorConditionMode || (AnimatorConditionMode = {}));
|
|
28101
|
-
|
|
28102
28431
|
/**
|
|
28103
28432
|
* Keyframe.
|
|
28104
28433
|
* @typeParam V - Type of Keyframe value
|