Browse Source

Handle comments

Popov72 4 years ago
parent
commit
d703e73520

+ 2 - 2
loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts

@@ -85,7 +85,7 @@ export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
         }
 
         if (properties.clearcoatRoughnessTexture) {
-            (properties.clearcoatRoughnessTexture as ITextureInfo).isNotColorData = true;
+            (properties.clearcoatRoughnessTexture as ITextureInfo).nonColorData = true;
             promises.push(this._loader.loadTextureInfoAsync(`${context}/clearcoatRoughnessTexture`, properties.clearcoatRoughnessTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (ClearCoat Roughness)`;
                 babylonMaterial.clearCoat.textureRoughness = texture;
@@ -93,7 +93,7 @@ export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
         }
 
         if (properties.clearcoatNormalTexture) {
-            (properties.clearcoatNormalTexture as ITextureInfo).isNotColorData = true;
+            (properties.clearcoatNormalTexture as ITextureInfo).nonColorData = true;
             promises.push(this._loader.loadTextureInfoAsync(`${context}/clearcoatNormalTexture`, properties.clearcoatNormalTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (ClearCoat Normal)`;
                 babylonMaterial.clearCoat.bumpTexture = texture;

+ 1 - 1
loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts

@@ -82,7 +82,7 @@ export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension
         }
 
         if (properties.specularGlossinessTexture) {
-            (properties.specularGlossinessTexture as ITextureInfo).isNotColorData = true;
+            (properties.specularGlossinessTexture as ITextureInfo).nonColorData = true;
             promises.push(this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (Specular Glossiness)`;
                 babylonMaterial.reflectivityTexture = texture;

+ 1 - 1
loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts

@@ -85,7 +85,7 @@ export class KHR_materials_sheen implements IGLTFLoaderExtension {
         }
 
         if (properties.sheenRoughnessTexture) {
-            (properties.sheenRoughnessTexture as ITextureInfo).isNotColorData = true;
+            (properties.sheenRoughnessTexture as ITextureInfo).nonColorData = true;
             promises.push(this._loader.loadTextureInfoAsync(`${context}/sheenRoughnessTexture`, properties.sheenRoughnessTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (Sheen Roughness)`;
                 babylonMaterial.sheen.textureRoughness = texture;

+ 1 - 1
loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts

@@ -69,7 +69,7 @@ export class KHR_materials_specular implements IGLTFLoaderExtension {
         }
 
         if (properties.specularTexture) {
-            (properties.specularTexture as ITextureInfo).isNotColorData = true;
+            (properties.specularTexture as ITextureInfo).nonColorData = true;
             promises.push(this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (Specular F0 Color)`;
                 babylonMaterial.metallicReflectanceTexture = texture;

+ 1 - 1
loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts

@@ -324,7 +324,7 @@ export class KHR_materials_transmission implements IGLTFLoaderExtension {
         }
 
         if (extension.transmissionTexture) {
-            (extension.transmissionTexture as ITextureInfo).isNotColorData = true;
+            (extension.transmissionTexture as ITextureInfo).nonColorData = true;
             return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined)
                 .then((texture: BaseTexture) => {
                     pbrMaterial.subSurface.thicknessTexture = texture;

+ 3 - 3
loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts

@@ -19,7 +19,6 @@ export class KHR_texture_basisu implements IGLTFLoaderExtension {
     public enabled: boolean;
 
     private _loader: GLTFLoader;
-    private _textureInfo: ITextureInfo;
 
     /** @hidden */
     constructor(loader: GLTFLoader) {
@@ -34,7 +33,8 @@ export class KHR_texture_basisu implements IGLTFLoaderExtension {
 
     /** @hidden */
     public loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {
-        this._textureInfo = textureInfo; // need to save this for use in _loadTextureAsync below
+        const texture = ArrayItem.Get(`${context}/index`, this._loader.gltf.textures, textureInfo.index);
+        texture._textureInfo = textureInfo; // need to save this for use in _loadTextureAsync below
         return this._loader.loadTextureInfoAsync(context, textureInfo, assign);
     }
 
@@ -45,7 +45,7 @@ export class KHR_texture_basisu implements IGLTFLoaderExtension {
             const image = ArrayItem.Get(`${extensionContext}/source`, this._loader.gltf.images, extension.source);
             return this._loader._createTextureAsync(context, sampler, image, (babylonTexture) => {
                 assign(babylonTexture);
-            }, this._textureInfo.isNotColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined);
+            }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined);
         });
     }
 }

+ 3 - 3
loaders/src/glTF/2.0/glTFLoader.ts

@@ -1710,7 +1710,7 @@ export class GLTFLoader implements IGLTFLoader {
             }
 
             if (properties.metallicRoughnessTexture) {
-                properties.metallicRoughnessTexture.isNotColorData = true;
+                properties.metallicRoughnessTexture.nonColorData = true;
                 promises.push(this.loadTextureInfoAsync(`${context}/metallicRoughnessTexture`, properties.metallicRoughnessTexture, (texture) => {
                     texture.name = `${babylonMaterial.name} (Metallic Roughness)`;
                     babylonMaterial.metallicTexture = texture;
@@ -1852,7 +1852,7 @@ export class GLTFLoader implements IGLTFLoader {
         }
 
         if (material.normalTexture) {
-            material.normalTexture.isNotColorData = true;
+            material.normalTexture.nonColorData = true;
             promises.push(this.loadTextureInfoAsync(`${context}/normalTexture`, material.normalTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (Normal)`;
                 babylonMaterial.bumpTexture = texture;
@@ -1868,7 +1868,7 @@ export class GLTFLoader implements IGLTFLoader {
         }
 
         if (material.occlusionTexture) {
-            material.occlusionTexture.isNotColorData = true;
+            material.occlusionTexture.nonColorData = true;
             promises.push(this.loadTextureInfoAsync(`${context}/occlusionTexture`, material.occlusionTexture, (texture) => {
                 texture.name = `${babylonMaterial.name} (Occlusion)`;
                 babylonMaterial.ambientTexture = texture;

+ 3 - 1
loaders/src/glTF/2.0/glTFLoaderInterfaces.ts

@@ -211,6 +211,8 @@ export interface ISkin extends GLTF2.ISkin, IArrayItem {
  * Loader interface with additional members.
  */
 export interface ITexture extends GLTF2.ITexture, IArrayItem {
+    /** @hidden */
+    _textureInfo: ITextureInfo;
 }
 
 /**
@@ -218,7 +220,7 @@ export interface ITexture extends GLTF2.ITexture, IArrayItem {
  */
 export interface ITextureInfo extends GLTF2.ITextureInfo {
     /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
-    isNotColorData?: boolean;
+    nonColorData?: boolean;
 }
 
 /**