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

chore(web): add some atmosphere properties #663

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion web/src/beta/lib/core/Map/types/index.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading