Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JPEG environment texture #12617

Merged
merged 15 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/dev/core/src/Materials/Textures/cubeTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ export class CubeTexture extends BaseTexture {

private _noMipmap: boolean;

/** @hidden */
@serialize("files")
private _files: Nullable<string[]> = null;
public _files: Nullable<string[]> = null;
sebavan marked this conversation as resolved.
Show resolved Hide resolved

@serialize("forcedExtension")
protected _forcedExtension: Nullable<string> = null;
Expand Down
8 changes: 6 additions & 2 deletions packages/dev/core/src/Misc/sceneSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down