-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathFog.ts
50 lines (42 loc) · 1.15 KB
/
Fog.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Fog as CesiumFog } from "cesium";
import { createCesiumComponent, PickCesiumProps } from "../core";
/*
@summary
`Fog` can operate the fog of the scene.
All properties are applied to single fog of the scene.
*/
/*
@scope
Fog can be mounted inside[Viewer](/components/Viewer) or [CesiumWidget](/components/CesiumWidget) components.
It can not be mounted more than once for each Viewer or CesiumWidget.
*/
export type FogCesiumProps = PickCesiumProps<CesiumFog, typeof cesiumProps>;
export type FogProps = FogCesiumProps;
const cesiumProps = [
"density",
"enabled",
"minimumBrightness",
"screenSpaceErrorFactor",
"heightScalar",
"maxHeight",
"visualDensityScalar",
"heightFalloff",
"renderable",
] as const;
const Fog = createCesiumComponent<CesiumFog, FogProps>({
name: "Fog",
create(context) {
if (!context.scene) return;
const element = new CesiumFog();
context.scene.fog = element;
return element;
},
destroy(_element, context) {
if (context.scene && !context.scene.isDestroyed()) {
context.scene.fog = new CesiumFog();
}
},
cesiumProps,
setCesiumPropsAfterCreate: true,
});
export default Fog;