Browse Source

Merge pull request #11334 from WestLangley/dev-quat

Object3D: add applyQuaternion()
Mr.doob 8 years ago
parent
commit
83d081ecde
2 changed files with 13 additions and 2 deletions
  1. 4 1
      docs/api/core/Object3D.html
  2. 9 1
      src/core/Object3D.js

+ 4 - 1
docs/api/core/Object3D.html

@@ -196,7 +196,10 @@
 		</div>
 		</div>
 
 
 		<h3>[method:null applyMatrix]( [page:Matrix4 matrix] )</h3>
 		<h3>[method:null applyMatrix]( [page:Matrix4 matrix] )</h3>
-		<div>This updates the position, rotation and scale with the matrix.</div>
+		<div>Applies the matrix transform to the object and updates the object's position, rotation and scale.</div>
+
+		<h3>[method:Object3D applyQuaternion]( [page:Quaternion quaternion] )</h3>
+		<div>Applies the rotation represented by the quaternion to the object.</div>
 
 
 		<h3>[method:Object3D clone]( [page:Boolean recursive] )</h3>
 		<h3>[method:Object3D clone]( [page:Boolean recursive] )</h3>
 		<div>
 		<div>

+ 9 - 1
src/core/Object3D.js

@@ -112,6 +112,14 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 
 	},
 	},
 
 
+	applyQuaternion: function ( q ) {
+
+		this.quaternion.premultiply( q );
+
+		return this;
+
+	},
+
 	setRotationFromAxisAngle: function ( axis, angle ) {
 	setRotationFromAxisAngle: function ( axis, angle ) {
 
 
 		// assumes axis is normalized
 		// assumes axis is normalized
@@ -272,7 +280,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 
 	lookAt: function () {
 	lookAt: function () {
 
 
-		// This routine does not support objects with rotated and/or translated parent(s)
+		// This method does not support objects with rotated and/or translated parent(s)
 
 
 		var m1 = new Matrix4();
 		var m1 = new Matrix4();