clipAction method
AnimationAction?
clipAction(
- dynamic clip, [
- dynamic optionalRoot,
- dynamic blendMode
])
Implementation
AnimationAction? clipAction(clip, [optionalRoot, blendMode]) {
var root = optionalRoot ?? _root;
var rootUuid = root.uuid;
AnimationClip? clipObject =
clip is String ? AnimationClip.findByName(root, clip) : clip;
var clipUuid = clipObject != null ? clipObject.uuid : clip;
var actionsForClip = _actionsByClip[clipUuid];
var prototypeAction;
if (blendMode == null) {
if (clipObject != null) {
blendMode = clipObject.blendMode;
} else {
blendMode = NormalAnimationBlendMode;
}
}
if (actionsForClip != null) {
var existingAction = actionsForClip?['actionByRoot'][rootUuid]; //gl
if (existingAction != null && existingAction.blendMode == blendMode) {
return existingAction;
}
// we know the clip, so we don't have to parse all
// the bindings again but can just copy
prototypeAction = actionsForClip.knownActions[0];
// also, take the clip from the prototype action
clipObject ??= prototypeAction._clip;
}
// clip must be known when specified via string
if (clipObject == null) return null;
// allocate all resources required to run it
var newAction = AnimationAction(this, clipObject,
localRoot: optionalRoot, blendMode: blendMode);
_bindAction(newAction, prototypeAction);
// and make the action known to the memory manager
_addInactiveAction(newAction, clipUuid, rootUuid);
return newAction;
}