Skip to content

Commit b4c3e25

Browse files
authored
Rename Key and Node classes (#7653)
* Rename Key and Node classes * Improve AnimationNode class description * Improve class description of Animation
1 parent 48a2276 commit b4c3e25

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

src/deprecated/deprecated.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { VertexFormat } from '../platform/graphics/vertex-format.js';
2020
import { BlendState } from '../platform/graphics/blend-state.js';
2121
import { DepthState } from '../platform/graphics/depth-state.js';
2222

23+
import { AnimationKey, AnimationNode } from '../scene/animation/animation.js';
24+
import { Geometry } from '../scene/geometry/geometry.js';
2325
import { CylinderGeometry } from '../scene/geometry/cylinder-geometry.js';
2426
import { BoxGeometry } from '../scene/geometry/box-geometry.js';
2527
import { CapsuleGeometry } from '../scene/geometry/capsule-geometry.js';
@@ -57,7 +59,6 @@ import {
5759
} from '../framework/components/rigid-body/constants.js';
5860
import { RigidBodyComponent } from '../framework/components/rigid-body/component.js';
5961
import { RigidBodyComponentSystem } from '../framework/components/rigid-body/system.js';
60-
import { Geometry } from '../scene/geometry/geometry.js';
6162
import { CameraComponent } from '../framework/components/camera/component.js';
6263

6364
// MATH
@@ -408,6 +409,9 @@ GraphicsDevice.prototype.getCullMode = function () {
408409

409410
// SCENE
410411

412+
export const Key = AnimationKey;
413+
export const Node = AnimationNode;
414+
411415
export const LitOptions = LitShaderOptions;
412416

413417
Object.defineProperty(Scene.prototype, 'defaultMaterial', {

src/framework/handlers/animation.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { path } from '../../core/path.js';
22
import { Quat } from '../../core/math/quat.js';
33
import { Vec3 } from '../../core/math/vec3.js';
44
import { http, Http } from '../../platform/net/http.js';
5-
import { Animation, Key, Node } from '../../scene/animation/animation.js';
5+
import { Animation, AnimationKey, AnimationNode } from '../../scene/animation/animation.js';
66
import { AnimEvents } from '../anim/evaluator/anim-events.js';
77
import { GlbParser } from '../parsers/glb-parser.js';
88
import { ResourceHandler } from './handler.js';
@@ -89,7 +89,7 @@ class AnimationHandler extends ResourceHandler {
8989
anim.duration = animData.duration;
9090

9191
for (let i = 0; i < animData.nodes.length; i++) {
92-
const node = new Node();
92+
const node = new AnimationNode();
9393

9494
const n = animData.nodes[i];
9595
node._name = n.name;
@@ -105,7 +105,7 @@ class AnimationHandler extends ResourceHandler {
105105
const rot = new Quat().setFromEulerAngles(r[0], r[1], r[2]);
106106
const scl = new Vec3(s[0], s[1], s[2]);
107107

108-
const key = new Key(t, pos, rot, scl);
108+
const key = new AnimationKey(t, pos, rot, scl);
109109

110110
node._keys.push(key);
111111
}
@@ -124,7 +124,7 @@ class AnimationHandler extends ResourceHandler {
124124
anim.duration = animData.duration;
125125

126126
for (let i = 0; i < animData.nodes.length; i++) {
127-
const node = new Node();
127+
const node = new AnimationNode();
128128

129129
const n = animData.nodes[i];
130130
node._name = n.name;
@@ -144,7 +144,7 @@ class AnimationHandler extends ResourceHandler {
144144
const rot = new Quat().setFromEulerAngles(r[0], r[1], r[2]);
145145
const scl = new Vec3(s[0], s[1], s[2]);
146146

147-
const key = new Key(t, pos, rot, scl);
147+
const key = new AnimationKey(t, pos, rot, scl);
148148

149149
node._keys.push(key);
150150
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export { StencilParameters } from './platform/graphics/stencil-parameters.js';
189189
export { TextureAtlas } from './scene/texture-atlas.js';
190190

191191
// SCENE / ANIMATION
192-
export { Animation, Key, Node } from './scene/animation/animation.js';
192+
export { Animation, AnimationKey, AnimationNode } from './scene/animation/animation.js';
193193
export { Skeleton } from './scene/animation/skeleton.js';
194194

195195
// SCENE / GRAPHICS

src/scene/animation/animation.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Key {
1+
class AnimationKey {
22
constructor(time, position, rotation, scale) {
33
this.time = time;
44
this.position = position;
@@ -8,13 +8,15 @@ class Key {
88
}
99

1010
/**
11-
* A animation node has a name and contains an array of keyframes.
11+
* AnimationNode represents an array of keyframes that animate the transform of a {@link GraphNode}
12+
* over time. Typically, an {@link Animation} maintains a collection of AnimationNodes, one for
13+
* each GraphNode in a {@link Skeleton}.
1214
*
1315
* @category Animation
1416
*/
15-
class Node {
17+
class AnimationNode {
1618
/**
17-
* Create a new Node instance.
19+
* Create a new AnimationNode instance.
1820
*/
1921
constructor() {
2022
this._name = '';
@@ -23,8 +25,11 @@ class Node {
2325
}
2426

2527
/**
26-
* An animation is a sequence of keyframe arrays which map to the nodes of a skeletal hierarchy. It
27-
* controls how the nodes of the hierarchy are transformed over time.
28+
* An Animation contains the data that defines how a {@link Skeleton} animates over time. The
29+
* Animation contains an array of {@link AnimationNode}s, where each AnimationNode targets a
30+
* specific {@link GraphNode} referenced by a {@link Skeleton}.
31+
*
32+
* An Animation can be played back by an {@link AnimationComponent}.
2833
*
2934
* @category Animation
3035
*/
@@ -52,10 +57,10 @@ class Animation {
5257
}
5358

5459
/**
55-
* Gets a {@link Node} by name.
60+
* Gets a {@link AnimationNode} by name.
5661
*
57-
* @param {string} name - The name of the {@link Node}.
58-
* @returns {Node} The {@link Node} with the specified name.
62+
* @param {string} name - The name of the {@link AnimationNode}.
63+
* @returns {AnimationNode} The {@link AnimationNode} with the specified name.
5964
*/
6065
getNode(name) {
6166
return this._nodeDict[name];
@@ -64,7 +69,7 @@ class Animation {
6469
/**
6570
* Adds a node to the internal nodes array.
6671
*
67-
* @param {Node} node - The node to add.
72+
* @param {AnimationNode} node - The node to add.
6873
*/
6974
addNode(node) {
7075
this._nodes.push(node);
@@ -74,11 +79,11 @@ class Animation {
7479
/**
7580
* A read-only property to get array of animation nodes.
7681
*
77-
* @type {Node[]}
82+
* @type {AnimationNode[]}
7883
*/
7984
get nodes() {
8085
return this._nodes;
8186
}
8287
}
8388

84-
export { Animation, Key, Node };
89+
export { Animation, AnimationKey, AnimationNode };

0 commit comments

Comments
 (0)