Преглед изворни кода

Merge pull request #13552 from takahirox/GLTFExporterWeakMap

GLTFExporter: Use Map for cache.
Mr.doob пре 7 година
родитељ
комит
669396fca7
1 измењених фајлова са 8 додато и 8 уклоњено
  1. 8 8
      examples/js/exporters/GLTFExporter.js

+ 8 - 8
examples/js/exporters/GLTFExporter.js

@@ -102,8 +102,8 @@ THREE.GLTFExporter.prototype = {
 		var skins = [];
 		var skins = [];
 		var cachedData = {
 		var cachedData = {
 
 
-			materials: {},
-			textures: {}
+			materials: new Map(),
+			textures: new Map()
 
 
 		};
 		};
 
 
@@ -593,9 +593,9 @@ THREE.GLTFExporter.prototype = {
 		 */
 		 */
 		function processTexture( map ) {
 		function processTexture( map ) {
 
 
-			if ( cachedData.textures[ map.uuid ] !== undefined ) {
+			if ( cachedData.textures.has( map ) ) {
 
 
-				return cachedData.textures[ map.uuid ];
+				return cachedData.textures.get( map );
 
 
 			}
 			}
 
 
@@ -615,7 +615,7 @@ THREE.GLTFExporter.prototype = {
 			outputJSON.textures.push( gltfTexture );
 			outputJSON.textures.push( gltfTexture );
 
 
 			var index = outputJSON.textures.length - 1;
 			var index = outputJSON.textures.length - 1;
-			cachedData.textures[ map.uuid ] = index;
+			cachedData.textures.set( map, index );
 
 
 			return index;
 			return index;
 
 
@@ -628,9 +628,9 @@ THREE.GLTFExporter.prototype = {
 		 */
 		 */
 		function processMaterial( material ) {
 		function processMaterial( material ) {
 
 
-			if ( cachedData.materials[ material.uuid ] !== undefined ) {
+			if ( cachedData.materials.has( material ) ) {
 
 
-				return cachedData.materials[ material.uuid ];
+				return cachedData.materials.get( material );
 
 
 			}
 			}
 
 
@@ -810,7 +810,7 @@ THREE.GLTFExporter.prototype = {
 			outputJSON.materials.push( gltfMaterial );
 			outputJSON.materials.push( gltfMaterial );
 
 
 			var index = outputJSON.materials.length - 1;
 			var index = outputJSON.materials.length - 1;
-			cachedData.materials[ material.uuid ] = index;
+			cachedData.materials.set( material, index );
 
 
 			return index;
 			return index;