-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyComponentNode.js
90 lines (64 loc) · 1.83 KB
/
MyComponentNode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* MyComponentNode class, representing an intermediate node in the scene graph.
* @constructor
**/
function MyComponentNode(graph, nodeID) {
this.graph = graph;
this.nodeID = nodeID;
// IDs of child nodes.
this.children = [];
// IDs of child nodes.
this.leaves = [];
// The material ID.
this.materialID = null;
// The texture ID.
this.textureID = null;
//The animations this node has
//this.animations = [];
//the animation ID
this.animationID = null;
this.transformMatrix = mat4.create();
mat4.identity(this.transformMatrix);
this.animRefs = [];
this.animMatrix = mat4.create();
mat4.identity(this.animMatrix);
this.time = 0;
this.currAnimation = 0;
this.combIte = 0;
this.currentSection = 0;
}
/**
* Adds the reference (ID) of another node to this node's children array.
*/
MyComponentNode.prototype.addChild = function(nodeID) {
this.children.push(nodeID);
}
/**
* Adds a leaf to this node's leaves array.
*/
MyComponentNode.prototype.addLeaf = function(leaf) {
this.leaves.push(leaf);
}
/**
* Adds an animation reference to this node's animation references array.
*/
MyComponentNode.prototype.addAnim = function(animRef) {
this.animRefs.push(animRef);
}
/**
* Gets this node's children
*/
MyComponentNode.prototype.getChildren = function() {
return this.children;
}
/**
* Updates the Animation Matrix for the Node
* @param dt Time between interrupts in miliseconds
*/
MyComponentNode.prototype.updateAnim = function(dt) {
for (var i = 0; i < this.animations.length; i++) { //POR CAUSA DESTE FOR FAZia UMA ANIMAÇÃO DE CADA VEZ
var animation = this.graph.animations[this.animations[i]];
animation.update(this, dt); //este chama o "circular"/"linear"
animation.apply(this);
}
}