提交 18537f06 编写于 作者: R Ricardo Cabello

Merge pull request #6333 from coballast/lazy-loading

Lazy loading of variables in Matrix4
......@@ -91,15 +91,15 @@ THREE.Matrix4.prototype = {
},
extractBasis: function ( xAxis, yAxis, zAxis ) {
var te = this.elements;
xAxis.set( te[ 0 ], te[ 1 ], te[ 2 ] );
yAxis.set( te[ 4 ], te[ 5 ], te[ 6 ] );
zAxis.set( te[ 8 ], te[ 9 ], te[ 10 ] );
return this;
},
makeBasis: function ( xAxis, yAxis, zAxis ) {
......@@ -117,10 +117,12 @@ THREE.Matrix4.prototype = {
extractRotation: function () {
var v1 = new THREE.Vector3();
var v1;
return function ( m ) {
if ( v1 === undefined ) v1 = new THREE.Vector3();
var te = this.elements;
var me = m.elements;
......@@ -321,12 +323,14 @@ THREE.Matrix4.prototype = {
lookAt: function () {
var x = new THREE.Vector3();
var y = new THREE.Vector3();
var z = new THREE.Vector3();
var x, y, z;
return function ( eye, target, up ) {
if ( x === undefined ) x = new THREE.Vector3();
if ( y === undefined ) y = new THREE.Vector3();
if ( z === undefined ) z = new THREE.Vector3();
var te = this.elements;
z.subVectors( eye, target ).normalize();
......@@ -463,10 +467,11 @@ THREE.Matrix4.prototype = {
applyToVector3Array: function () {
var v1 = new THREE.Vector3();
var v1;
return function ( array, offset, length ) {
if ( v1 === undefined ) v1 = new THREE.Vector3();
if ( offset === undefined ) offset = 0;
if ( length === undefined ) length = array.length;
......@@ -602,10 +607,11 @@ THREE.Matrix4.prototype = {
getPosition: function () {
var v1 = new THREE.Vector3();
var v1;
return function () {
if ( v1 === undefined ) v1 = new THREE.Vector3();
THREE.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' );
var te = this.elements;
......@@ -674,6 +680,7 @@ THREE.Matrix4.prototype = {
this.identity();
return this;
}
this.multiplyScalar( 1 / det );
......@@ -854,11 +861,13 @@ THREE.Matrix4.prototype = {
decompose: function () {
var vector = new THREE.Vector3();
var matrix = new THREE.Matrix4();
var vector, matrix;
return function ( position, quaternion, scale ) {
if ( vector === undefined ) vector = new THREE.Vector3();
if ( matrix === undefined ) matrix = new THREE.Matrix4();
var te = this.elements;
var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
......@@ -868,7 +877,9 @@ THREE.Matrix4.prototype = {
// if determine is negative, we need to invert one scale
var det = this.determinant();
if ( det < 0 ) {
sx = - sx;
}
position.x = te[ 12 ];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册