Skip to content

Commit

Permalink
feat: add editor fog parser
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxudong committed Mar 8, 2024
1 parent c90f4f0 commit e4ba324
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/loader/src/SceneLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SceneLoader extends Loader<Scene> {
}
}

// parse background
const background = data.scene.background;
scene.background.mode = background.mode;

Expand Down Expand Up @@ -107,6 +108,16 @@ class SceneLoader extends Loader<Scene> {
scene.shadowFadeBorder = shadow.shadowFadeBorder ?? scene.shadowFadeBorder;
}

// parse fog
const fog = data.scene.fog;
if (fog) {
if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
}

return Promise.all(promises).then(() => {
resolve(scene);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BackgroundMode, DiffuseMode, ShadowCascadesMode, ShadowResolution } from "@galacean/engine-core";
import { BackgroundMode, DiffuseMode, FogMode, ShadowCascadesMode, ShadowResolution } from "@galacean/engine-core";
import type { IReferable } from "@galacean/engine-core/types/asset/IReferable";
import type { IColor, IPrefabFile, IVector3 } from "./BasicSchema";

Expand Down Expand Up @@ -36,6 +36,13 @@ export interface IScene extends IPrefabFile {
shadowFourCascadeSplits: IVector3;
shadowFadeBorder: number;
};
fog?: {
fogMode: FogMode;
fogStart: number;
fogEnd: number;
fogDensity: number;
fogColor: IColor;
};
};
files: Array<{ id: string; type: string; virtualPath: string; path: string }>;
}

0 comments on commit e4ba324

Please sign in to comment.