소스 검색

GLTFExporter: Add texture cache.

Takahiro 8 년 전
부모
커밋
3b8f635e6b
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 12 2
      examples/js/exporters/GLTFExporter.js

+ 12 - 2
examples/js/exporters/GLTFExporter.js

@@ -99,7 +99,8 @@ THREE.GLTFExporter.prototype = {
 		var cachedData = {
 
 			images: {},
-			materials: {}
+			materials: {},
+			textures: {}
 
 		};
 
@@ -533,6 +534,12 @@ THREE.GLTFExporter.prototype = {
 		 */
 		function processTexture( map ) {
 
+			if ( cachedData.textures[ map.uuid ] !== undefined ) {
+
+				return cachedData.textures[ map.uuid ];
+
+			}
+
 			if ( ! outputJSON.textures ) {
 
 				outputJSON.textures = [];
@@ -548,7 +555,10 @@ THREE.GLTFExporter.prototype = {
 
 			outputJSON.textures.push( gltfTexture );
 
-			return outputJSON.textures.length - 1;
+			var index = outputJSON.textures.length - 1;
+			cachedData.textures[ map.uuid ] = index;
+
+			return index;
 
 		}
 

粤ICP备19079148号