@reearth/core 0.0.7-alpha.17 → 0.0.7-alpha.18

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.17",
3
+ "version": "0.0.7-alpha.18",
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.",
@@ -500,8 +500,9 @@ export const useHooks = ({
500
500
  return prevPlanes.current;
501
501
  }, [_planes]);
502
502
  const clipDirection = direction === "inside" ? -1 : 1;
503
+
503
504
  // Create immutable object
504
- const [clippingPlanes] = useState(
505
+ const [clippingPlanes, setClippingPlanes] = useState<CesiumClippingPlaneCollection>(
505
506
  () =>
506
507
  new CesiumClippingPlaneCollection({
507
508
  planes: planes?.map(
@@ -516,6 +517,27 @@ export const useHooks = ({
516
517
  edgeColor: toColor(edgeColor),
517
518
  }),
518
519
  );
520
+ // Initialize clipping planes
521
+ // This is workaround to reinitialize ClippingPlanes in strict mode.
522
+ useEffect(
523
+ () => () => {
524
+ setClippingPlanes(
525
+ new CesiumClippingPlaneCollection({
526
+ planes: planes?.map(
527
+ plane =>
528
+ new ClippingPlane(
529
+ new Cartesian3(plane.normal?.x, plane.normal?.y, plane.normal?.z),
530
+ (plane.distance || 0) * clipDirection,
531
+ ),
532
+ ),
533
+ unionClippingRegions: direction === "outside",
534
+ edgeWidth: edgeWidth,
535
+ edgeColor: toColor(edgeColor),
536
+ }),
537
+ );
538
+ },
539
+ [], // eslint-disable-line react-hooks/exhaustive-deps
540
+ );
519
541
 
520
542
  const { drawClippingEnabled, drawClippingEdgeProps } = useDrawClipping({
521
543
  ...experimental_clipping?.draw,