mrdoob/three.js — Issue #1393: setRotationFromMatrix locks the matrix
Author: homam
Created: 2012-02-24 22:01:01+00:00
State: open

Following the method described here: [Issue #1219](https://github.com/mrdoob/three.js/issues/1219#issuecomment-3750958)
I can rotate my object as expected, but in one case, when I'm rotating the object only around the world's Y axis, the object locks (stops rotating) when its matrix (mesh.matrix) is like:

```Matrix:
0	0	1	0
0	1	0	0
-1	0	0	0
0	0	0	1
```
Here's a sample rotation_matrix:

```Matrix:
1	0	0.03	0
0	1	0	0
-0.03	0	1	0
0	0	0	1
```

And I'm running this line in every tick:
```javascript
mesh.rotation.setRotationFromMatrix(rotation_matrix);
```
When you run the above line multiple times, the object rotates a little bit in the right direction then it rotates back to the initial state and this continues to rotate in this pattern.

I was able to fix the issue by modifying Vector3.setRotationFromMatrix(), by changing this condition:

```javascript
if ( Math.abs( cosY ) > 0.0001 ) { ...
//to
if ( Math.abs( cosY ) > 0 ) { ...
```

I wonder why there was such a condition and if I'm breaking anything by this change.