1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/Cubiks-2048_ynh.git synced 2024-09-03 18:25:55 +02:00
cubiks-2048_ynh/sources/js/rotation_anim.js
2015-03-10 12:36:06 +01:00

32 lines
No EOL
1,000 B
JavaScript

function rot_animation(angle_in) {
this.animation_duration = 10; // 2 seconds apprx
this.angle = angle_in;
this.animation_residue = 0;
this.rotate_x = false;
this.rotate_y = false;
this.rotate_z = false;
this.rotation_direction = +1;
}
rot_animation.prototype.is_animating = function () {
return (this.rotate_x || this.rotate_y || this.rotate_z || CUBE2048.showing_view );
};
rot_animation.prototype.get_offset = function () {
return this.angle / this.animation_duration;
};
var rotation_animation = new rot_animation(Math.PI / 2);
// Utility Functions.
var rotWorldMatrix;
// Rotate an object around an arbitrary axis in world space
function rotateAroundWorldAxis(object, axis, radians) {
rotWorldMatrix = new THREE.Matrix4();
rotWorldMatrix.makeRotationAxis(axis.normalize(), radians);
rotWorldMatrix.multiply(object.matrix); // pre-multiply
object.matrix = rotWorldMatrix;
object.rotation.setFromRotationMatrix(object.matrix);
}