|
|
@@ -1,6 +1,12 @@
|
|
|
import { WebGLCoordinateSystem } from '../constants.js';
|
|
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
|
import { Object3D } from '../core/Object3D.js';
|
|
|
+import { Vector3 } from '../math/Vector3.js';
|
|
|
+import { Quaternion } from '../math/Quaternion.js';
|
|
|
+
|
|
|
+const _position = /*@__PURE__*/ new Vector3();
|
|
|
+const _quaternion = /*@__PURE__*/ new Quaternion();
|
|
|
+const _scale = /*@__PURE__*/ new Vector3();
|
|
|
|
|
|
/**
|
|
|
* Abstract base class for cameras. This class should always be inherited
|
|
|
@@ -107,7 +113,19 @@ class Camera extends Object3D {
|
|
|
|
|
|
super.updateMatrixWorld( force );
|
|
|
|
|
|
- this.matrixWorldInverse.copy( this.matrixWorld ).invert();
|
|
|
+ // exclude scale from view matrix to be glTF conform
|
|
|
+
|
|
|
+ this.matrixWorld.decompose( _position, _quaternion, _scale );
|
|
|
+
|
|
|
+ if ( _scale.x === 1 && _scale.y === 1 && _scale.z === 1 ) {
|
|
|
+
|
|
|
+ this.matrixWorldInverse.copy( this.matrixWorld ).invert();
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this.matrixWorldInverse.compose( _position, _quaternion, _scale.set( 1, 1, 1 ) ).invert();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -115,7 +133,19 @@ class Camera extends Object3D {
|
|
|
|
|
|
super.updateWorldMatrix( updateParents, updateChildren );
|
|
|
|
|
|
- this.matrixWorldInverse.copy( this.matrixWorld ).invert();
|
|
|
+ // exclude scale from view matrix to be glTF conform
|
|
|
+
|
|
|
+ this.matrixWorld.decompose( _position, _quaternion, _scale );
|
|
|
+
|
|
|
+ if ( _scale.x === 1 && _scale.y === 1 && _scale.z === 1 ) {
|
|
|
+
|
|
|
+ this.matrixWorldInverse.copy( this.matrixWorld ).invert();
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this.matrixWorldInverse.compose( _position, _quaternion, _scale.set( 1, 1, 1 ) ).invert();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|