Hey @bghgary … I need your advise on loading CubeTextures in GLTF. I have added support for lightmapTextures and reflectionTextures by way of my GLTF Extension.
Since the lightmapTexture is a standard image (png/jpg) i can use the loadTextureAsync so the texture size for download is taken into account. So this works for lightmaps
promises.push(this._loader.loadTextureInfoAsync(context + "/lightmapTexture", commonConstant.lightmapTexture, (texture) => {
texture.name = `${sourceMaterial.name} (Light Map)`;
texture.level = (commonConstant.lightmapLevel) ? commonConstant.lightmapLevel : 1;
texture.gammaSpace = false;
// ..
// Setup HDR Lightmap Flag On Loaded
// ..
const realTexture:BABYLON.Texture = texture as BABYLON.Texture;
realTexture.onLoadObservable.addOnce(()=>{
if (realTexture.isReady()) {
realTexture.isRGBD = true;
} else {
BABYLON.Tools.Warn("Failed to register texture as RGBD: " + realTexture.name);
}
});
commonMaterial.lightmapTexture = texture;
commonMaterial.useLightmapAsShadowmap = true;
if (BABYLON.Utilities.HasOwnProperty(commonMaterial, "ambientColor")) {
commonMaterial.ambientColor = BABYLON.Color3.White();
}
}));
Now i need to load reflectionTextures… with DDS/ENV file formats that go into a CubeTexture.
I think the loadTextureInfoAsync eventually call loadImageAsync… which get the array buffer data…Create a Texture (with no url) and then use texture.updateURL(dataUrl, binData) to actually assign the image data to the texture.
How would i handle something like this for a cubeTexture… is there a way to manually assign the image data (dds/env) you get from in the arraybuffer you download to a new CubeTexture like we do for regular textures ???
I basically need a way to account for the extra reflection texture file sizes in the SceneLoader.Load onProgess event… The only way i see that is to have ALL downloads go thru the GLTF loader _loadFile or _requestFile … So it calculates the evt.loaded and evt.total in the progress event…
How should i handle that ???
Thanks in advance