|
@@ -57,29 +57,6 @@ interface IRegisteredExtension {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Type of data held by a texture
|
|
|
- * @hidden
|
|
|
- */
|
|
|
-export enum TextureDataType {
|
|
|
- /** color data (albedo, emissive, ...) */
|
|
|
- Color,
|
|
|
- /** roughness data */
|
|
|
- Roughness,
|
|
|
- /** normal map */
|
|
|
- Normal,
|
|
|
- /** glossiness data */
|
|
|
- Glossiness,
|
|
|
- /** specular map */
|
|
|
- Specular,
|
|
|
- /** transmission map (thickness) */
|
|
|
- Transmission,
|
|
|
- /** metallic/roughness data */
|
|
|
- MetallicRoughness,
|
|
|
- /** occlusion data */
|
|
|
- Occlusion
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
* Helper class for working with arrays when loading the glTF asset
|
|
|
*/
|
|
|
export class ArrayItem {
|
|
@@ -1736,7 +1713,7 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
promises.push(this.loadTextureInfoAsync(`${context}/metallicRoughnessTexture`, properties.metallicRoughnessTexture, (texture) => {
|
|
|
texture.name = `${babylonMaterial.name} (Metallic Roughness)`;
|
|
|
babylonMaterial.metallicTexture = texture;
|
|
|
- }, TextureDataType.MetallicRoughness));
|
|
|
+ }, false));
|
|
|
|
|
|
babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
|
|
|
babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
|
|
@@ -1877,7 +1854,7 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
promises.push(this.loadTextureInfoAsync(`${context}/normalTexture`, material.normalTexture, (texture) => {
|
|
|
texture.name = `${babylonMaterial.name} (Normal)`;
|
|
|
babylonMaterial.bumpTexture = texture;
|
|
|
- }, TextureDataType.Normal));
|
|
|
+ }, false));
|
|
|
|
|
|
babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem;
|
|
|
babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem;
|
|
@@ -1892,7 +1869,7 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
promises.push(this.loadTextureInfoAsync(`${context}/occlusionTexture`, material.occlusionTexture, (texture) => {
|
|
|
texture.name = `${babylonMaterial.name} (Occlusion)`;
|
|
|
babylonMaterial.ambientTexture = texture;
|
|
|
- }, TextureDataType.Occlusion));
|
|
|
+ }, false));
|
|
|
|
|
|
babylonMaterial.useAmbientInGrayScale = true;
|
|
|
if (material.occlusionTexture.strength != undefined) {
|
|
@@ -1955,11 +1932,11 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
* @param context The context when loading the asset
|
|
|
* @param textureInfo The glTF texture info property
|
|
|
* @param assign A function called synchronously after parsing the glTF properties
|
|
|
- * @param textureDataType type of data held by the texture
|
|
|
+ * @param isColorData true if the texture held color data, else false
|
|
|
* @returns A promise that resolves with the loaded Babylon texture when the load is complete
|
|
|
*/
|
|
|
- public loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void = () => { }, textureDataType: TextureDataType = TextureDataType.Color): Promise<BaseTexture> {
|
|
|
- const extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign, textureDataType);
|
|
|
+ public loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void = () => { }, isColorData = true): Promise<BaseTexture> {
|
|
|
+ const extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign, isColorData);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
|
}
|
|
@@ -1976,7 +1953,7 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
GLTFLoader.AddPointerMetadata(babylonTexture, context);
|
|
|
this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
|
|
|
assign(babylonTexture);
|
|
|
- }, textureDataType);
|
|
|
+ }, isColorData);
|
|
|
|
|
|
this.logClose();
|
|
|
|
|
@@ -1984,8 +1961,8 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
}
|
|
|
|
|
|
/** @hidden */
|
|
|
- public _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void = () => { }, textureDataType: TextureDataType = TextureDataType.Color): Promise<BaseTexture> {
|
|
|
- const extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign, textureDataType);
|
|
|
+ public _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void = () => { }, isColorData = true): Promise<BaseTexture> {
|
|
|
+ const extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign, isColorData);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
|
}
|
|
@@ -2362,12 +2339,12 @@ export class GLTFLoader implements IGLTFLoader {
|
|
|
return this._applyExtensions(material, "loadMaterialProperties", (extension) => extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, textureDataType: TextureDataType): Nullable<Promise<BaseTexture>> {
|
|
|
- return this._applyExtensions(textureInfo, "loadTextureInfo", (extension) => extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign, textureDataType));
|
|
|
+ private _extensionsLoadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, isColorData: boolean): Nullable<Promise<BaseTexture>> {
|
|
|
+ return this._applyExtensions(textureInfo, "loadTextureInfo", (extension) => extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign, isColorData));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, textureDataType: TextureDataType): Nullable<Promise<BaseTexture>> {
|
|
|
- return this._applyExtensions(texture, "loadTexture", (extension) => extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign, textureDataType));
|
|
|
+ private _extensionsLoadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, isColorData: boolean): Nullable<Promise<BaseTexture>> {
|
|
|
+ return this._applyExtensions(texture, "loadTexture", (extension) => extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign, isColorData));
|
|
|
}
|
|
|
|
|
|
private _extensionsLoadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {
|