Explorar o código

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Mr.doob %!s(int64=11) %!d(string=hai) anos
pai
achega
9050f13a10
Modificáronse 2 ficheiros con 12 adicións e 0 borrados
  1. 4 0
      src/math/Quaternion.js
  2. 8 0
      test/unit/math/Quaternion.js

+ 4 - 0
src/math/Quaternion.js

@@ -399,6 +399,10 @@ THREE.Quaternion.prototype = {
 
 
 	slerp: function ( qb, t ) {
 	slerp: function ( qb, t ) {
 
 
+		if ( t === 0 ) return this;
+
+		if ( t === 1 ) return this.copy( qb );
+
 		var x = this._x, y = this._y, z = this._z, w = this._w;
 		var x = this._x, y = this._y, z = this._z, w = this._w;
 
 
 		// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
 		// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/

+ 8 - 0
test/unit/math/Quaternion.js

@@ -209,3 +209,11 @@ test( "equals", function() {
 	ok( a.equals( b ), "Passed!" );
 	ok( a.equals( b ), "Passed!" );
 	ok( b.equals( a ), "Passed!" );
 	ok( b.equals( a ), "Passed!" );
 });
 });
+
+test( "slerp", function() {
+	var a = new THREE.Quaternion( 0.675341, 0.408783, 0.328567, 0.518512 );
+	var b = new THREE.Quaternion( 0.660279, 0.436474, 0.35119, 0.500187 );
+
+	ok( a.slerp( b, 0 ).equals( a ), "Passed!" );
+	ok( a.slerp( b, 1 ).equals( b ), "Passed!" );
+});