Skip to content

Commit

Permalink
chore(web): add some atmosphere properties (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
keiya01 committed Sep 6, 2023
1 parent 9972e66 commit caee550
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
7 changes: 6 additions & 1 deletion web/src/beta/lib/core/Map/types/index.ts
Expand Up @@ -288,20 +288,25 @@ export type SceneProperty = {
terrain?: TerrainProperty;
atmosphere?: {
enable_sun?: boolean;
enableMoon?: boolean;
enable_lighting?: boolean;
ground_atmosphere?: boolean;
sky_atmosphere?: boolean;
shadows?: boolean;
shadowResolution?: 1024 | 2048 | 4096;
softShadow?: boolean;
shadowDarkness?: number;
shadowMaximumDistance?: number;
fog?: boolean;
fog_density?: number;
brightness_shift?: number;
hue_shift?: number;
brightness_shift?: number;
surturation_shift?: number;
skyboxBrightnessShift?: number;
skyboxSurturationShift?: number;
globeShadowDarkness?: number;
globeImageBasedLighting?: boolean;
globeBaseColor?: string;
};
timeline?: {
animation?: boolean;
Expand Down
7 changes: 7 additions & 0 deletions web/src/beta/lib/core/engines/Cesium/core/Globe.tsx
Expand Up @@ -12,6 +12,7 @@ import { Globe as CesiumGlobe } from "resium";
import { objKeys } from "@reearth/beta/utils/util";

import type { SceneProperty, TerrainProperty } from "../..";
import { toColor } from "../common";

export type Props = {
property?: SceneProperty;
Expand Down Expand Up @@ -49,8 +50,14 @@ export default function Globe({ property, cesiumIonAccessToken }: Props): JSX.El
cesiumIonAccessToken,
]);

const baseColor = useMemo(
() => toColor(property?.atmosphere?.globeBaseColor),
[property?.atmosphere?.globeBaseColor],
);

return (
<CesiumGlobe
baseColor={baseColor}
enableLighting={!!property?.atmosphere?.enable_lighting}
showGroundAtmosphere={property?.atmosphere?.ground_atmosphere ?? true}
atmosphereSaturationShift={property?.atmosphere?.surturation_shift}
Expand Down
3 changes: 2 additions & 1 deletion web/src/beta/lib/core/engines/Cesium/hooks.ts
Expand Up @@ -166,7 +166,7 @@ export default ({
shadowMap.darkness = property?.atmosphere?.shadowDarkness ?? 0.3;
shadowMap.size = property?.atmosphere?.shadowResolution ?? 2048;
shadowMap.fadingEnabled = true;
shadowMap.maximumDistance = 5000;
shadowMap.maximumDistance = property?.atmosphere?.shadowMaximumDistance ?? 5000;
shadowMap.normalOffset = true;

// bias
Expand Down Expand Up @@ -222,6 +222,7 @@ export default ({
property?.atmosphere?.softShadow,
property?.atmosphere?.shadowDarkness,
property?.atmosphere?.shadowResolution,
property?.atmosphere?.shadowMaximumDistance,
]);

useEffect(() => {
Expand Down
8 changes: 7 additions & 1 deletion web/src/beta/lib/core/engines/Cesium/index.tsx
Expand Up @@ -13,6 +13,7 @@ import {
ScreenSpaceCameraController,
Entity,
PolylineGraphics,
Moon,
} from "resium";

import type { Engine, EngineProps, EngineRef } from "..";
Expand Down Expand Up @@ -193,7 +194,12 @@ const Cesium: React.ForwardRefRenderFunction<EngineRef, EngineProps> = (
density={property?.atmosphere?.fog_density}
/>
<Sun show={property?.atmosphere?.enable_sun ?? true} />
<SkyAtmosphere show={property?.atmosphere?.sky_atmosphere ?? true} />
<Moon show={property?.atmosphere?.enableMoon} />
<SkyAtmosphere
show={property?.atmosphere?.sky_atmosphere ?? true}
saturationShift={property?.atmosphere?.skyboxSurturationShift}
brightnessShift={property?.atmosphere?.skyboxBrightnessShift}
/>
<Globe property={property} cesiumIonAccessToken={cesiumIonAccessToken} />
<featureContext.Provider value={context}>{ready ? children : null}</featureContext.Provider>
<AmbientOcclusion
Expand Down

0 comments on commit caee550

Please sign in to comment.