mrdoob/three.js — Issue #1180: Bug in Vector3.setRotationFromMatrix()
Author: WestLangley
Created: 2012-01-24 19:24:57+00:00
State: open

The first line uses the variable `this.y` that has not been set.

THREE.Vector3.prototype.setRotationFromMatrix = function ( m ) {

var cosY = Math.cos( this.y );

this.y = Math.asin( m.n13 );

...

To fix it, it is sufficient to swap the first and second lines like so:

THREE.Vector3.prototype.setRotationFromMatrix = function ( m ) {

this.y = Math.asin( m.n13 );

var cosY = Math.cos( this.y );

...

Also, I hate to beat a dead horse, and I know this issue was brought up by @ch3sn3k in #835 and #836, but `setRotationFromMatrix` does not take the euler order into consideration, and it should if we want `obj.eulerOrder`, `obj.rotation`, and `obj.matrix` to remain internally consistent.