@reearth/core 0.0.7-alpha.75 → 0.0.7-alpha.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reearth/core",
3
- "version": "0.0.7-alpha.75",
3
+ "version": "0.0.7-alpha.76",
4
4
  "author": "Re:Earth contributors <community@reearth.io>",
5
5
  "license": "Apache-2.0",
6
6
  "description": "A library that abstracts a map engine as one common API.",
@@ -1,5 +1,5 @@
1
1
  import { Cartesian3, Color, DirectionalLight, SceneMode, SunLight, Viewer } from "cesium";
2
- import { RefObject, useMemo } from "react";
2
+ import { RefObject, useEffect, useMemo } from "react";
3
3
  import { CesiumComponentRef } from "resium";
4
4
 
5
5
  import { ViewerProperty } from "../..";
@@ -61,6 +61,20 @@ export default ({
61
61
  [property?.scene?.backgroundColor],
62
62
  );
63
63
 
64
+ const showSkyBox = property?.sky?.skyBox?.show ?? true;
65
+
66
+ useEffect(() => {
67
+ const scene = cesium.current?.cesiumElement?.scene;
68
+ if (!scene) return;
69
+ // set backgroundColor
70
+ scene.backgroundColor = sceneBackgroundColor ?? Color.BLACK;
71
+ // Cesium 1.139 bug: SkyBox.show does not forward to _panorama.show,
72
+ // so we must set it directly.
73
+ const panorama = (scene.skyBox as any)?._panorama;
74
+ if (panorama) panorama.show = showSkyBox;
75
+ scene.requestRender();
76
+ }, [cesium, sceneBackgroundColor, showSkyBox]);
77
+
64
78
  const sceneMsaaSamples = useMemo(() => {
65
79
  // TODO: FXAA doesn't support alpha blending in Cesium, so we will enable FXAA when this is fixed.
66
80
  // viewer.scene.postProcessStages.fxaa.enabled = property?.render?.antialias === "high";
@@ -86,5 +100,6 @@ export default ({
86
100
  sceneBackgroundColor,
87
101
  sceneMsaaSamples,
88
102
  sceneMode,
103
+ showSkyBox,
89
104
  };
90
105
  };
@@ -732,10 +732,11 @@ export default ({
732
732
  });
733
733
  }, [time, timelineManagerRef]);
734
734
 
735
- const { sceneLight, sceneBackgroundColor, sceneMsaaSamples, sceneMode } = useViewerProperty({
736
- property,
737
- cesium,
738
- });
735
+ const { sceneLight, sceneBackgroundColor, sceneMsaaSamples, sceneMode, showSkyBox } =
736
+ useViewerProperty({
737
+ property,
738
+ cesium,
739
+ });
739
740
 
740
741
  useLayerDragDrop({ cesium, onLayerDrag, onLayerDrop, isLayerDraggable });
741
742
 
@@ -792,6 +793,7 @@ export default ({
792
793
  sceneBackgroundColor,
793
794
  sceneMsaaSamples,
794
795
  sceneMode,
796
+ showSkyBox,
795
797
  cameraViewBoundaries,
796
798
  cameraViewOuterBoundaries,
797
799
  cameraViewBoundariesMaterial,
@@ -80,6 +80,7 @@ const Cesium: React.ForwardRefRenderFunction<EngineRef, EngineProps> = (
80
80
  sceneBackgroundColor,
81
81
  sceneMsaaSamples,
82
82
  sceneMode,
83
+ showSkyBox,
83
84
  cameraViewBoundaries,
84
85
  cameraViewOuterBoundaries,
85
86
  cameraViewBoundariesMaterial,
@@ -261,7 +262,7 @@ const Cesium: React.ForwardRefRenderFunction<EngineRef, EngineProps> = (
261
262
  verticalExaggerationRelativeHeight={property?.scene?.verticalExaggerationRelativeHeight}
262
263
  verticalExaggeration={verticalExaggeration}
263
264
  />
264
- <SkyBox show={property?.sky?.skyBox?.show ?? true} />
265
+ <SkyBox show={showSkyBox} />
265
266
  <Fog enabled={property?.sky?.fog?.enabled ?? true} density={property?.sky?.fog?.density} />
266
267
  <Sun show={property?.sky?.sun?.show ?? true} />
267
268
  <Moon show={property?.sky?.moon?.show ?? true} />