Jelajahi Sumber

Revert "Changed GLTF loader to use naming from GLTFTexture. Removed default naming of textures"

This reverts commit 030cc51acf9a0acab4de4ff5ef9710ac7fab7591.
Nicholas Barlow 6 tahun lalu
induk
melakukan
f0c1b36928

+ 2 - 0
loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts

@@ -73,12 +73,14 @@ export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension
 
 
         if (properties.diffuseTexture) {
         if (properties.diffuseTexture) {
             promises.push(this._loader.loadTextureInfoAsync(`${context}/diffuseTexture`, properties.diffuseTexture, (texture) => {
             promises.push(this._loader.loadTextureInfoAsync(`${context}/diffuseTexture`, properties.diffuseTexture, (texture) => {
+                texture.name = `${babylonMaterial.name} (Diffuse)`;
                 babylonMaterial.albedoTexture = texture;
                 babylonMaterial.albedoTexture = texture;
             }));
             }));
         }
         }
 
 
         if (properties.specularGlossinessTexture) {
         if (properties.specularGlossinessTexture) {
             promises.push(this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {
             promises.push(this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {
+                texture.name = `${babylonMaterial.name} (Specular Glossiness)`;
                 babylonMaterial.reflectivityTexture = texture;
                 babylonMaterial.reflectivityTexture = texture;
             }));
             }));
 
 

+ 1 - 0
loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts

@@ -58,6 +58,7 @@ export class KHR_materials_unlit implements IGLTFLoaderExtension {
 
 
             if (properties.baseColorTexture) {
             if (properties.baseColorTexture) {
                 promises.push(this._loader.loadTextureInfoAsync(`${context}/baseColorTexture`, properties.baseColorTexture, (texture) => {
                 promises.push(this._loader.loadTextureInfoAsync(`${context}/baseColorTexture`, properties.baseColorTexture, (texture) => {
+                    texture.name = `${babylonMaterial.name} (Base Color)`;
                     babylonMaterial.albedoTexture = texture;
                     babylonMaterial.albedoTexture = texture;
                 }));
                 }));
             }
             }

+ 5 - 4
loaders/src/glTF/2.0/glTFLoader.ts

@@ -1555,12 +1555,14 @@ export class GLTFLoader implements IGLTFLoader {
 
 
             if (properties.baseColorTexture) {
             if (properties.baseColorTexture) {
                 promises.push(this.loadTextureInfoAsync(`${context}/baseColorTexture`, properties.baseColorTexture, (texture) => {
                 promises.push(this.loadTextureInfoAsync(`${context}/baseColorTexture`, properties.baseColorTexture, (texture) => {
+                    texture.name = `${babylonMaterial.name} (Base Color)`;
                     babylonMaterial.albedoTexture = texture;
                     babylonMaterial.albedoTexture = texture;
                 }));
                 }));
             }
             }
 
 
             if (properties.metallicRoughnessTexture) {
             if (properties.metallicRoughnessTexture) {
                 promises.push(this.loadTextureInfoAsync(`${context}/metallicRoughnessTexture`, properties.metallicRoughnessTexture, (texture) => {
                 promises.push(this.loadTextureInfoAsync(`${context}/metallicRoughnessTexture`, properties.metallicRoughnessTexture, (texture) => {
+                    texture.name = `${babylonMaterial.name} (Metallic Roughness)`;
                     babylonMaterial.metallicTexture = texture;
                     babylonMaterial.metallicTexture = texture;
                 }));
                 }));
 
 
@@ -1697,6 +1699,7 @@ export class GLTFLoader implements IGLTFLoader {
 
 
         if (material.normalTexture) {
         if (material.normalTexture) {
             promises.push(this.loadTextureInfoAsync(`${context}/normalTexture`, material.normalTexture, (texture) => {
             promises.push(this.loadTextureInfoAsync(`${context}/normalTexture`, material.normalTexture, (texture) => {
+                texture.name = `${babylonMaterial.name} (Normal)`;
                 babylonMaterial.bumpTexture = texture;
                 babylonMaterial.bumpTexture = texture;
             }));
             }));
 
 
@@ -1711,6 +1714,7 @@ export class GLTFLoader implements IGLTFLoader {
 
 
         if (material.occlusionTexture) {
         if (material.occlusionTexture) {
             promises.push(this.loadTextureInfoAsync(`${context}/occlusionTexture`, material.occlusionTexture, (texture) => {
             promises.push(this.loadTextureInfoAsync(`${context}/occlusionTexture`, material.occlusionTexture, (texture) => {
+                texture.name = `${babylonMaterial.name} (Occlusion)`;
                 babylonMaterial.ambientTexture = texture;
                 babylonMaterial.ambientTexture = texture;
             }));
             }));
 
 
@@ -1722,6 +1726,7 @@ export class GLTFLoader implements IGLTFLoader {
 
 
         if (material.emissiveTexture) {
         if (material.emissiveTexture) {
             promises.push(this.loadTextureInfoAsync(`${context}/emissiveTexture`, material.emissiveTexture, (texture) => {
             promises.push(this.loadTextureInfoAsync(`${context}/emissiveTexture`, material.emissiveTexture, (texture) => {
+                texture.name = `${babylonMaterial.name} (Emissive)`;
                 babylonMaterial.emissiveTexture = texture;
                 babylonMaterial.emissiveTexture = texture;
             }));
             }));
         }
         }
@@ -1787,10 +1792,6 @@ export class GLTFLoader implements IGLTFLoader {
         const texture = ArrayItem.Get(`${context}/index`, this._gltf.textures, textureInfo.index);
         const texture = ArrayItem.Get(`${context}/index`, this._gltf.textures, textureInfo.index);
         const promise = this._loadTextureAsync(`/textures/${textureInfo.index}`, texture, (babylonTexture) => {
         const promise = this._loadTextureAsync(`/textures/${textureInfo.index}`, texture, (babylonTexture) => {
             babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
             babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
-            if (texture.name)
-            {
-                babylonTexture.name = texture.name;
-            }
 
 
             GLTFLoader.AddPointerMetadata(babylonTexture, context);
             GLTFLoader.AddPointerMetadata(babylonTexture, context);
             this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
             this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);