* Sets the angles of this Euler instance from a pure rotation matrix. * * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled). * @param {string} [order] - A string representing the order that the rotations are applied. * @param {boolea
( m, order = this._order, update = true )
| 187 | * @return {Euler} A reference to this Euler instance. |
| 188 | */ |
| 189 | setFromRotationMatrix( m, order = this._order, update = true ) { |
| 190 | |
| 191 | const te = m.elements; |
| 192 | const m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ]; |
| 193 | const m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ]; |
| 194 | const m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; |
| 195 | |
| 196 | switch ( order ) { |
| 197 | |
| 198 | case 'XYZ': |
| 199 | |
| 200 | this._y = Math.asin( clamp( m13, - 1, 1 ) ); |
| 201 | |
| 202 | if ( Math.abs( m13 ) < 0.9999999 ) { |
| 203 | |
| 204 | this._x = Math.atan2( - m23, m33 ); |
| 205 | this._z = Math.atan2( - m12, m11 ); |
| 206 | |
| 207 | } else { |
| 208 | |
| 209 | this._x = Math.atan2( m32, m22 ); |
| 210 | this._z = 0; |
| 211 | |
| 212 | } |
| 213 | |
| 214 | break; |
| 215 | |
| 216 | case 'YXZ': |
| 217 | |
| 218 | this._x = Math.asin( - clamp( m23, - 1, 1 ) ); |
| 219 | |
| 220 | if ( Math.abs( m23 ) < 0.9999999 ) { |
| 221 | |
| 222 | this._y = Math.atan2( m13, m33 ); |
| 223 | this._z = Math.atan2( m21, m22 ); |
| 224 | |
| 225 | } else { |
| 226 | |
| 227 | this._y = Math.atan2( - m31, m11 ); |
| 228 | this._z = 0; |
| 229 | |
| 230 | } |
| 231 | |
| 232 | break; |
| 233 | |
| 234 | case 'ZXY': |
| 235 | |
| 236 | this._x = Math.asin( clamp( m32, - 1, 1 ) ); |
| 237 | |
| 238 | if ( Math.abs( m32 ) < 0.9999999 ) { |
| 239 | |
| 240 | this._y = Math.atan2( - m31, m33 ); |
| 241 | this._z = Math.atan2( - m12, m22 ); |
| 242 | |
| 243 | } else { |
| 244 | |
| 245 | this._y = 0; |
| 246 | this._z = Math.atan2( m21, m11 ); |
no test coverage detected