Skip to content

Commit 489b508

Browse files
committed
Merge remote-tracking branch 'remotes/mrdoob/dev' into dev
2 parents 776d618 + 6aa1ae2 commit 489b508

File tree

9 files changed

+128
-129
lines changed

9 files changed

+128
-129
lines changed

build/Three.js

Lines changed: 23 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/ThreeCanvas.js

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/ThreeDOM.js

Lines changed: 44 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/ThreeExtras.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/ThreeSVG.js

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/ThreeWebGL.js

Lines changed: 15 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cameras/Camera.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ THREE.Camera.prototype.lookAt = function ( vector ) {
2525

2626
if ( this.rotationAutoUpdate ) {
2727

28-
this.rotation.getRotationFromMatrix( this.matrix );
28+
this.rotation.getRotationFromMatrix( this.matrix, this.scale );
2929

3030
}
3131

src/core/Object3D.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ THREE.Object3D.prototype = {
6060

6161
this.matrix.multiply( matrix, this.matrix );
6262

63-
/*
6463
this.position.getPositionFromMatrix( this.matrix );
65-
this.rotation.getRotationFromMatrix( this.matrix );
6664
this.scale.getScaleFromMatrix( this.matrix );
67-
*/
65+
this.rotation.getRotationFromMatrix( this.matrix, this.scale );
6866

67+
/*
6968
this.matrix.decompose( this.position, this.quaternion, this.scale );
7069
this.rotation.getRotationFromQuaternion( this.quaternion );
70+
*/
7171

7272
},
7373

@@ -104,7 +104,7 @@ THREE.Object3D.prototype = {
104104

105105
if ( this.rotationAutoUpdate ) {
106106

107-
this.rotation.getRotationFromMatrix( this.matrix );
107+
this.rotation.getRotationFromMatrix( this.matrix, this.scale );
108108

109109
}
110110

src/core/Vector3.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,30 +277,33 @@ THREE.Vector3.prototype = {
277277

278278
},
279279

280-
getRotationFromMatrix: function ( m ) {
280+
getRotationFromMatrix: function ( m, scale ) {
281281

282-
// TODO: This one doesn't return 100% correct results
282+
var m11 = m.n11 / scale.x, m12 = m.n12 / scale.y, m13 = m.n13 / scale.z;
283+
var m21 = m.n21 / scale.x, m22 = m.n22 / scale.y, m23 = m.n23 / scale.z;
284+
var m33 = m.n33 / scale.z;
283285

284-
this.y = Math.asin( m.n13 );
286+
this.y = Math.asin( m13 );
285287

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

288290
if ( Math.abs( cosY ) > 0.00001 ) {
289291

290-
this.x = Math.atan2( - m.n23 / cosY, m.n33 / cosY );
291-
this.z = Math.atan2( - m.n12 / cosY, m.n11 / cosY );
292+
this.x = Math.atan2( - m23 / cosY, m33 / cosY );
293+
this.z = Math.atan2( - m12 / cosY, m11 / cosY );
292294

293295
} else {
294296

295297
this.x = 0;
296-
this.z = Math.atan2( m.n21, m.n22 );
298+
this.z = Math.atan2( m21, m22 );
297299

298300
}
299301

300302
return this;
301303

302304
},
303305

306+
/*
304307
// from http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm
305308
// assuming heading == y, attitude == z, bank == x
306309
@@ -338,16 +341,17 @@ THREE.Vector3.prototype = {
338341
this.x = Math.atan2( 2 * q.x * q.w - 2 * q.y * q.z, -sqx + sqy - sqz + sqw );
339342
340343
},
344+
*/
341345

342346
getScaleFromMatrix: function ( m ) {
343347

344-
var x = this.set( m.n11, m.n21, m.n31 ).length();
345-
var y = this.set( m.n12, m.n22, m.n32 ).length();
346-
var z = this.set( m.n13, m.n23, m.n33 ).length();
348+
var sx = this.set( m.n11, m.n21, m.n31 ).length();
349+
var sy = this.set( m.n12, m.n22, m.n32 ).length();
350+
var sz = this.set( m.n13, m.n23, m.n33 ).length();
347351

348-
this.x = x;
349-
this.y = y;
350-
this.z = z;
352+
this.x = sx;
353+
this.y = sy;
354+
this.z = sz;
351355

352356
},
353357

0 commit comments

Comments
 (0)