| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 * Pre-composes the local matrix of this Transform with a rotation around the | 825 * Pre-composes the local matrix of this Transform with a rotation around the |
| 826 * given axis. For example, if the local matrix is a translation, the new | 826 * given axis. For example, if the local matrix is a translation, the new |
| 827 * local matrix will rotate around the given axis and then translate. | 827 * local matrix will rotate around the given axis and then translate. |
| 828 * | 828 * |
| 829 * @param {number} angle The number of radians to rotate. | 829 * @param {number} angle The number of radians to rotate. |
| 830 * @param {!o3d.math.Vector3} axis a non-zero vector representing the axis | 830 * @param {!o3d.math.Vector3} axis a non-zero vector representing the axis |
| 831 * around which to rotate. | 831 * around which to rotate. |
| 832 */ | 832 */ |
| 833 o3d.Transform.prototype.axisRotate = | 833 o3d.Transform.prototype.axisRotate = |
| 834 function(axis, angle) { | 834 function(axis, angle) { |
| 835 var m = this.localMatrix; | 835 o3d.Transform.axisRotateMatrix(this.localMatrix, axis, angle); |
| 836 }; |
| 836 | 837 |
| 838 o3d.Transform.axisRotateMatrix = |
| 839 function(m, axis, angle, opt_target) { |
| 840 opt_target = opt_target || m; |
| 837 var x = axis[0]; | 841 var x = axis[0]; |
| 838 var y = axis[1]; | 842 var y = axis[1]; |
| 839 var z = axis[2]; | 843 var z = axis[2]; |
| 840 var n = Math.sqrt(x * x + y * y + z * z); | 844 var n = Math.sqrt(x * x + y * y + z * z); |
| 841 x /= n; | 845 x /= n; |
| 842 y /= n; | 846 y /= n; |
| 843 z /= n; | 847 z /= n; |
| 844 var xx = x * x; | 848 var xx = x * x; |
| 845 var yy = y * y; | 849 var yy = y * y; |
| 846 var zz = z * z; | 850 var zz = z * z; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 873 var m13 = m1[3]; | 877 var m13 = m1[3]; |
| 874 var m20 = m2[0]; | 878 var m20 = m2[0]; |
| 875 var m21 = m2[1]; | 879 var m21 = m2[1]; |
| 876 var m22 = m2[2]; | 880 var m22 = m2[2]; |
| 877 var m23 = m2[3]; | 881 var m23 = m2[3]; |
| 878 var m30 = m3[0]; | 882 var m30 = m3[0]; |
| 879 var m31 = m3[1]; | 883 var m31 = m3[1]; |
| 880 var m32 = m3[2]; | 884 var m32 = m3[2]; |
| 881 var m33 = m3[3]; | 885 var m33 = m3[3]; |
| 882 | 886 |
| 883 m0.splice(0, 4, | 887 opt_target[0].splice(0, 4, |
| 884 r00 * m00 + r01 * m10 + r02 * m20, | 888 r00 * m00 + r01 * m10 + r02 * m20, |
| 885 r00 * m01 + r01 * m11 + r02 * m21, | 889 r00 * m01 + r01 * m11 + r02 * m21, |
| 886 r00 * m02 + r01 * m12 + r02 * m22, | 890 r00 * m02 + r01 * m12 + r02 * m22, |
| 887 r00 * m03 + r01 * m13 + r02 * m23); | 891 r00 * m03 + r01 * m13 + r02 * m23); |
| 888 | 892 |
| 889 m1.splice(0, 4, | 893 opt_target[1].splice(0, 4, |
| 890 r10 * m00 + r11 * m10 + r12 * m20, | 894 r10 * m00 + r11 * m10 + r12 * m20, |
| 891 r10 * m01 + r11 * m11 + r12 * m21, | 895 r10 * m01 + r11 * m11 + r12 * m21, |
| 892 r10 * m02 + r11 * m12 + r12 * m22, | 896 r10 * m02 + r11 * m12 + r12 * m22, |
| 893 r10 * m03 + r11 * m13 + r12 * m23); | 897 r10 * m03 + r11 * m13 + r12 * m23); |
| 894 | 898 |
| 895 m2.splice(0, 4, | 899 opt_target[2].splice(0, 4, |
| 896 r20 * m00 + r21 * m10 + r22 * m20, | 900 r20 * m00 + r21 * m10 + r22 * m20, |
| 897 r20 * m01 + r21 * m11 + r22 * m21, | 901 r20 * m01 + r21 * m11 + r22 * m21, |
| 898 r20 * m02 + r21 * m12 + r22 * m22, | 902 r20 * m02 + r21 * m12 + r22 * m22, |
| 899 r20 * m03 + r21 * m13 + r22 * m23); | 903 r20 * m03 + r21 * m13 + r22 * m23); |
| 900 }; | 904 }; |
| 901 | 905 |
| 902 | 906 |
| 903 /** | 907 /** |
| 904 * Pre-composes the local matrix of this Transform with a rotation defined by | 908 * Pre-composes the local matrix of this Transform with a rotation defined by |
| 905 * the given quaternion. | 909 * the given quaternion. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 for (var i = 0; i < shapes.length; ++i) { | 1056 for (var i = 0; i < shapes.length; ++i) { |
| 1053 shapes[i].writeToDrawLists(remainingDrawListInfos, this.worldMatrix, this); | 1057 shapes[i].writeToDrawLists(remainingDrawListInfos, this.worldMatrix, this); |
| 1054 } | 1058 } |
| 1055 | 1059 |
| 1056 for (var i = 0; i < children.length; ++i) { | 1060 for (var i = 0; i < children.length; ++i) { |
| 1057 children[i].traverse(remainingDrawListInfos, this.worldMatrix); | 1061 children[i].traverse(remainingDrawListInfos, this.worldMatrix); |
| 1058 } | 1062 } |
| 1059 }; | 1063 }; |
| 1060 | 1064 |
| 1061 | 1065 |
| OLD | NEW |