From 65ea3db93aa8ea6cdff9f9dce185b936840f79af Mon Sep 17 00:00:00 2001 From: MichaelHazani Date: Sat, 7 Oct 2017 17:33:54 -0700 Subject: [PATCH] add rotateOnWorldAxis method to Object3D --- docs/api/core/Object3D.html | 9 +++++++++ src/core/Object3D.js | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/docs/api/core/Object3D.html b/docs/api/core/Object3D.html index 814a95c7df..27d3cd7744 100644 --- a/docs/api/core/Object3D.html +++ b/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. +

[method:Object3D rotateOnWorldAxis]( [page:Vector3 axis], [page:Float angle] )

+
+ axis -- A normalized vector in world space.
+ angle -- The angle in radians.

+ + Rotate an object along an axis in world space. The axis is assumed to be normalized. + Method Assumes no rotated parent. +
+

[method:null rotateX]( [page:Float rad] )

rad - the angle to rotate in radians.

diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 318bd23426..6d508d1074 100644 --- a/src/core/Object3D.js +++ b/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 ); -- GitLab