Skip to content

Commit 729dc55

Browse files
authored
Merge pull request #20470 from linbingquan/dev-gltf-exporter
GLTFExporter: Clean up.
2 parents 63ecf2b + 2da766e commit 729dc55

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

examples/js/exporters/GLTFExporter.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var WEBGL_CONSTANTS = {
3131
REPEAT: 10497
3232
};
3333

34+
var identityArray = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ];
35+
3436
var THREE_TO_WEBGL = {};
3537

3638
THREE_TO_WEBGL[ THREE.NearestFilter ] = WEBGL_CONSTANTS.NEAREST;
@@ -152,6 +154,18 @@ THREE.GLTFExporter.prototype = {
152154

153155
}
154156

157+
/**
158+
* Is identity matrix
159+
*
160+
* @param {THREE.Matrix4} matrix
161+
* @returns {Boolean} Returns true, if parameter is identity matrix
162+
*/
163+
function isIdentityMatrix( matrix ) {
164+
165+
return equalArray( matrix.elements, identityArray );
166+
167+
}
168+
155169
/**
156170
* Converts a string to an ArrayBuffer.
157171
* @param {string} text
@@ -1777,7 +1791,7 @@ THREE.GLTFExporter.prototype = {
17771791

17781792
}
17791793

1780-
if ( ! equalArray( object.matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) ) {
1794+
if ( isIdentityMatrix( object.matrix ) === false ) {
17811795

17821796
gltfNode.matrix = object.matrix.elements;
17831797

examples/jsm/exporters/GLTFExporter.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ var WEBGL_CONSTANTS = {
5151
REPEAT: 10497
5252
};
5353

54+
var identityArray = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ];
55+
5456
var THREE_TO_WEBGL = {};
5557

5658
THREE_TO_WEBGL[ NearestFilter ] = WEBGL_CONSTANTS.NEAREST;
@@ -172,6 +174,18 @@ GLTFExporter.prototype = {
172174

173175
}
174176

177+
/**
178+
* Is identity matrix
179+
*
180+
* @param {THREE.Matrix4} matrix
181+
* @returns {Boolean} Returns true, if parameter is identity matrix
182+
*/
183+
function isIdentityMatrix( matrix ) {
184+
185+
return equalArray( matrix.elements, identityArray );
186+
187+
}
188+
175189
/**
176190
* Converts a string to an ArrayBuffer.
177191
* @param {string} text
@@ -1797,7 +1811,7 @@ GLTFExporter.prototype = {
17971811

17981812
}
17991813

1800-
if ( ! equalArray( object.matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) ) {
1814+
if ( isIdentityMatrix( object.matrix ) === false ) {
18011815

18021816
gltfNode.matrix = object.matrix.elements;
18031817

0 commit comments

Comments
 (0)