|
@@ -78,6 +78,12 @@ THREE.GLTFExporter.prototype = {
|
|
|
|
|
|
var byteOffset = 0;
|
|
var byteOffset = 0;
|
|
var dataViews = [];
|
|
var dataViews = [];
|
|
|
|
+ var cachedData = {
|
|
|
|
+
|
|
|
|
+ images: {},
|
|
|
|
+ materials: {}
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
/**
|
|
* Compare two arrays
|
|
* Compare two arrays
|
|
@@ -318,6 +324,12 @@ THREE.GLTFExporter.prototype = {
|
|
*/
|
|
*/
|
|
function processImage ( map ) {
|
|
function processImage ( map ) {
|
|
|
|
|
|
|
|
+ if ( cachedData.images[ map.uuid ] ) {
|
|
|
|
+
|
|
|
|
+ return cachedData.images[ map.uuid ];
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
if ( !outputJSON.images ) {
|
|
if ( !outputJSON.images ) {
|
|
|
|
|
|
outputJSON.images = [];
|
|
outputJSON.images = [];
|
|
@@ -339,7 +351,10 @@ THREE.GLTFExporter.prototype = {
|
|
|
|
|
|
outputJSON.images.push( gltfImage );
|
|
outputJSON.images.push( gltfImage );
|
|
|
|
|
|
- return outputJSON.images.length - 1;
|
|
|
|
|
|
+ var index = outputJSON.images.length - 1;
|
|
|
|
+ cachedData.images[ map.uuid ] = index;
|
|
|
|
+
|
|
|
|
+ return index;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -404,6 +419,12 @@ THREE.GLTFExporter.prototype = {
|
|
*/
|
|
*/
|
|
function processMaterial ( material ) {
|
|
function processMaterial ( material ) {
|
|
|
|
|
|
|
|
+ if ( cachedData.materials[ material.uuid ] ) {
|
|
|
|
+
|
|
|
|
+ return cachedData.materials[ material.uuid ];
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
if ( !outputJSON.materials ) {
|
|
if ( !outputJSON.materials ) {
|
|
|
|
|
|
outputJSON.materials = [];
|
|
outputJSON.materials = [];
|
|
@@ -539,7 +560,10 @@ THREE.GLTFExporter.prototype = {
|
|
|
|
|
|
outputJSON.materials.push( gltfMaterial );
|
|
outputJSON.materials.push( gltfMaterial );
|
|
|
|
|
|
- return outputJSON.materials.length - 1;
|
|
|
|
|
|
+ var index = outputJSON.materials.length - 1;
|
|
|
|
+ cachedData.materials[ material.uuid ] = index;
|
|
|
|
+
|
|
|
|
+ return index;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|