Rename TrackPath methods (#9086)

This commit is contained in:
Leslie Leigh (李的序)
2021-07-29 10:06:36 +08:00
committed by GitHub
parent d755243688
commit 8a8a1230ba
5 changed files with 19 additions and 16 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ export class AnimationClip extends Asset {
clip.duration = spriteFrames.length / clip.sample;
const step = 1 / clip.sample;
const track = new ObjectTrack<SpriteFrame>();
track.path = new TrackPath().component('cc.Sprite').property('spriteFrame');
track.path = new TrackPath().toComponent('cc.Sprite').toProperty('spriteFrame');
const curve = track.channels()[0].curve;
curve.assignSorted(spriteFrames.map((spriteFrame, index) => [step * index, spriteFrame]));
return clip;
@@ -785,7 +785,7 @@ function createExoticTrackEvaluationRecord<TValue> (
binder: Binder,
) {
const trackBinding = new TrackBinding();
trackBinding.path = new TrackPath().hierarchy(path).property(property);
trackBinding.path = new TrackPath().toHierarchy(path).toProperty(property);
const runtimeBinding = binder(trackBinding);
if (!runtimeBinding) {
return null;
+5 -5
View File
@@ -189,15 +189,15 @@ export class AnimationClipLegacyData {
const trackPath = new TrackPath();
for (const modifier of modifiers) {
if (typeof modifier === 'string') {
trackPath.property(modifier);
trackPath.toProperty(modifier);
} else if (typeof modifier === 'number') {
trackPath.element(modifier);
trackPath.toElement(modifier);
} else if (modifier instanceof HierarchyPath) {
trackPath.hierarchy(modifier.path);
trackPath.toHierarchy(modifier.path);
} else if (modifier instanceof ComponentPath) {
trackPath.component(modifier.component);
trackPath.toComponent(modifier.component);
} else {
trackPath.customized(modifier);
trackPath.toCustomized(modifier);
}
}
track.path = trackPath;
+9 -6
View File
@@ -150,28 +150,31 @@ class TrackPath {
return this._paths.length;
}
public property (name: string) {
public toProperty (name: string) {
this._paths.push(name);
return this;
}
public element (index: number) {
public toElement (index: number) {
this._paths.push(index);
return this;
}
public hierarchy (nodePath: string) {
public toHierarchy (nodePath: string) {
this._paths.push(new HierarchyPath(nodePath));
return this;
}
public component<T extends Component> (constructor: Constructor<T> | string) {
public toComponent<T extends Component> (constructor: Constructor<T> | string) {
const path = new ComponentPath(typeof constructor === 'string' ? constructor : js.getClassName(constructor));
this._paths.push(path);
return this;
}
public customized (resolver: CustomizedTrackPathResolver) {
/**
* @internal Reserved for backward compatibility. DO NOT USE IT IN YOUR CODE.
*/
public toCustomized (resolver: CustomizedTrackPathResolver) {
this._paths.push(resolver);
return this;
}
@@ -222,7 +225,7 @@ class TrackPath {
return trackPath;
}
public follow (object: unknown, beginIndex?: number, endIndex?: number) {
public trace (object: unknown, beginIndex?: number, endIndex?: number) {
beginIndex ??= 0;
endIndex ??= this._paths.length;
return this[normalizedFollowTag](object, beginIndex, endIndex);
+3 -3
View File
@@ -36,7 +36,7 @@ describe('Animation Clip', () => {
function createClipWithPath (path: TargetPath[]) {
const clip = new AnimationClip();
const track = new RealTrack();
track.path = new TrackPath().hierarchy('Foo');
track.path = new TrackPath().toHierarchy('Foo');
clip.addTrack(track);
return clip;
}
@@ -47,7 +47,7 @@ describe('Animation Clip', () => {
const clip = new AnimationClip();
for (const path of paths) {
const track = new VectorTrack();
track.path = new TrackPath().hierarchy(path).property('position');
track.path = new TrackPath().toHierarchy(path).toProperty('position');
clip.addTrack(track);
}
return clip[searchForRootBonePathSymbol]();
@@ -70,7 +70,7 @@ describe('Animation Clip', () => {
const rootBoneTranslationTrack = new VectorTrack();
{
rootBoneTranslationTrack.componentsCount = 3;
rootBoneTranslationTrack.path = new TrackPath().hierarchy(rootJointName).property('position');
rootBoneTranslationTrack.path = new TrackPath().toHierarchy(rootJointName).toProperty('position');
const [x, _y, _z] = rootBoneTranslationTrack.channels();
x.curve.assignSorted([
[0.4, ({ value: 0.4 })],