Ver Fonte

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

Mr.doob há 11 anos atrás
pai
commit
9050f13a10
2 ficheiros alterados com 12 adições e 0 exclusões
  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 ) {
 
+		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;
 
 		// 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( 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!" );
+});