mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
The actual animation business.
This commit is contained in:
parent
0f69bbe23f
commit
00829e0289
1 changed files with 17 additions and 3 deletions
|
@ -19,6 +19,10 @@ Agent.isAvatar = true;
|
|||
|
||||
var jointMapping;
|
||||
|
||||
var frameIndex = 0.0;
|
||||
|
||||
var FRAME_RATE = 30.0; // frames per second
|
||||
|
||||
Script.update.connect(function(deltaTime) {
|
||||
if (!jointMapping) {
|
||||
var avatarJointNames = Avatar.jointNames;
|
||||
|
@ -26,9 +30,19 @@ Script.update.connect(function(deltaTime) {
|
|||
if (avatarJointNames === 0 || animationJointNames.length === 0) {
|
||||
return;
|
||||
}
|
||||
print(avatarJointNames);
|
||||
print(animationJointNames);
|
||||
jointMapping = { };
|
||||
jointMapping = new Array(avatarJointNames.length);
|
||||
for (var i = 0; i < avatarJointNames.length; i++) {
|
||||
jointMapping[i] = animationJointNames.indexOf(avatarJointNames[i]);
|
||||
}
|
||||
}
|
||||
frameIndex += deltaTime * FRAME_RATE;
|
||||
var frames = animation.frames;
|
||||
var rotations = frames[Math.floor(frameIndex) % frames.length].rotations;
|
||||
for (var j = 0; j < jointMapping.length; j++) {
|
||||
var rotationIndex = jointMapping[j];
|
||||
if (rotationIndex != -1) {
|
||||
Avatar.setJointData(j, rotations[rotationIndex]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue