瀏覽代碼

add rotateOnWorldAxis method to Object3D

MichaelHazani 7 年之前
父節點
當前提交
65ea3db93a
共有 2 個文件被更改,包括 29 次插入0 次删除
  1. 9 0
      docs/api/core/Object3D.html
  2. 20 0
      src/core/Object3D.js

+ 9 - 0
docs/api/core/Object3D.html

@@ -320,6 +320,15 @@
 		Rotate an object along an axis in object space. The axis is assumed to be normalized.
 		</div>
 
+		<h3>[method:Object3D rotateOnWorldAxis]( [page:Vector3 axis], [page:Float angle] )</h3>
+		<div>
+		axis -- A normalized vector in world space. <br />
+		angle -- The angle in radians.<br /><br />
+
+		Rotate an object along an axis in world space. The axis is assumed to be normalized.
+		Method Assumes no rotated parent.
+		</div>
+
 		<h3>[method:null rotateX]( [page:Float rad] )</h3>
 		<div>
 		rad - the angle to rotate in radians.<br /><br />

+ 20 - 0
src/core/Object3D.js

@@ -170,6 +170,26 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 	}(),
 
+	rotateOnWorldAxis: function () {
+		
+		// rotate object on axis in world space
+		// axis is assumed to be normalized
+		// method assumes no rotated parent
+
+		var q1 = new Quaternion();
+		
+		return function rotateOnWorldAxis(axis, angle) {
+		
+			q1.setFromAxisAngle(axis, angle);
+		
+			this.quaternion.premultiply(q1);
+		
+			return this;
+		
+		};
+		
+	}(),
+
 	rotateX: function () {
 
 		var v1 = new Vector3( 1, 0, 0 );