mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 01:43:27 +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 jointMapping;
|
||||||
|
|
||||||
|
var frameIndex = 0.0;
|
||||||
|
|
||||||
|
var FRAME_RATE = 30.0; // frames per second
|
||||||
|
|
||||||
Script.update.connect(function(deltaTime) {
|
Script.update.connect(function(deltaTime) {
|
||||||
if (!jointMapping) {
|
if (!jointMapping) {
|
||||||
var avatarJointNames = Avatar.jointNames;
|
var avatarJointNames = Avatar.jointNames;
|
||||||
|
@ -26,9 +30,19 @@ Script.update.connect(function(deltaTime) {
|
||||||
if (avatarJointNames === 0 || animationJointNames.length === 0) {
|
if (avatarJointNames === 0 || animationJointNames.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print(avatarJointNames);
|
jointMapping = new Array(avatarJointNames.length);
|
||||||
print(animationJointNames);
|
for (var i = 0; i < avatarJointNames.length; i++) {
|
||||||
jointMapping = { };
|
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