diff --git a/packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts b/packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts index 42317e3d095..709e9f9d755 100644 --- a/packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts +++ b/packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts @@ -178,7 +178,10 @@ const loadAssetContainer = (scene: Scene, data: string, rootUrl: string, onError } scene.environmentTexture = hdrTexture; } else { - if ((parsedData.environmentTexture as string).endsWith(".env")) { + if (typeof parsedData.environmentTexture === "object") { + const environmentTexture = CubeTexture.Parse(parsedData.environmentTexture, scene, rootUrl); + scene.environmentTexture = environmentTexture; + } else if ((parsedData.environmentTexture as string).endsWith(".env")) { const compressedTexture = new CubeTexture( (parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, diff --git a/packages/dev/core/src/Materials/Textures/cubeTexture.ts b/packages/dev/core/src/Materials/Textures/cubeTexture.ts index e7c62cd704c..1c22e64fdf6 100644 --- a/packages/dev/core/src/Materials/Textures/cubeTexture.ts +++ b/packages/dev/core/src/Materials/Textures/cubeTexture.ts @@ -91,8 +91,9 @@ export class CubeTexture extends BaseTexture { private _noMipmap: boolean; + /** @hidden */ @serialize("files") - private _files: Nullable = null; + public _files: Nullable = null; @serialize("forcedExtension") protected _forcedExtension: Nullable = null; diff --git a/packages/dev/core/src/Misc/sceneSerializer.ts b/packages/dev/core/src/Misc/sceneSerializer.ts index ec32c42d12d..65c49a41c51 100644 --- a/packages/dev/core/src/Misc/sceneSerializer.ts +++ b/packages/dev/core/src/Misc/sceneSerializer.ts @@ -243,8 +243,12 @@ export class SceneSerializer { // Environment texture if (scene.environmentTexture) { - serializationObject.environmentTexture = scene.environmentTexture.name; - serializationObject.environmentTextureRotationY = (scene.environmentTexture as CubeTexture).rotationY; + if ((scene.environmentTexture as CubeTexture)._files) { + serializationObject.environmentTexture = scene.environmentTexture.serialize(); + } else { + serializationObject.environmentTexture = scene.environmentTexture.name; + serializationObject.environmentTextureRotationY = (scene.environmentTexture as CubeTexture).rotationY; + } } // Environment Intensity diff --git a/packages/dev/materials/readme.md b/packages/dev/materials/readme.md index d92228c8f6d..58a4ca3beb0 100644 --- a/packages/dev/materials/readme.md +++ b/packages/dev/materials/readme.md @@ -1,6 +1,6 @@ # Materials library -To get a detailed tutorial, please read the [documentation](https://doc.babylonjs.com/how_to/how_to_create_a_material_for_materialslibrary) +To get a detailed tutorial, please read the [documentation](https://doc.babylonjs.com/divingDeeper/developWithBjs/matForMatLibrary) For every material, you can find a detailled documentation [here](https://doc.babylonjs.com/extensions) under **materials library** tag.