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

fix: strict mode #668

Merged
merged 4 commits into from
Jul 24, 2024
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
15 changes: 15 additions & 0 deletions src/Camera/Camera.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { actions } from "@storybook/addon-actions";
import { Meta, StoryObj } from "@storybook/react";
import { Cartesian3 } from "cesium";
import { StrictMode } from "react";

import CameraFlyTo from "../CameraFlyTo";
import Viewer from "../Viewer";
Expand All @@ -22,3 +23,17 @@ export const Basic: Story = {
</Viewer>
),
};

export const Strict: Story = {
render: args => (
<StrictMode>
<Viewer full>
<Camera {...args} {...actions("onMoveEnd", "onMoveStart", "onChange")} />
<CameraFlyTo
duration={5}
destination={Cartesian3.fromDegrees(139.767052, 35.681167, 100)}
/>
</Viewer>
</StrictMode>
),
};
220 changes: 219 additions & 1 deletion src/Entity/Entity.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
// Rectangle,
// Math as CesiumMath,
} from "cesium";
import { useState, useEffect, useRef, useMemo, FC } from "react";
import { useState, useEffect, useRef, useMemo, FC, StrictMode } from "react";

import BillboardGraphics from "../BillboardGraphics";
import BoxGraphics from "../BoxGraphics";
Expand Down Expand Up @@ -391,3 +391,221 @@ export const Graphics: Story = {
</Viewer>
),
};

export const Strict: Story = {
render: args => (
<StrictMode>
<Viewer full onMouseEnter={action("mouseenter")}>
<Entity
{...args}
name="BillboardGraphics"
description="BillboardGraphics!!"
position={Cartesian3.fromDegrees(-40.0707383, 40.7117244, 100)}
selected>
<BillboardGraphics image="example.png" scale={0.05} />
</Entity>
<Entity
{...args}
name="BoxGraphics"
description="BoxGraphics!!"
position={Cartesian3.fromDegrees(0.0707383, 40.7117244, 100)}>
<BoxGraphics
material={Color.RED}
dimensions={new Cartesian3(400000.0, 300000.0, 500000.0)}
/>
</Entity>
<Entity
{...args}
name="CorridorGraphics"
description="CorridorGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<CorridorGraphics
material={Color.YELLOW}
positions={
Cartesian3.fromDegreesArray([-100.0, 40.0, -105.0, 40.0, -105.0, 35.0]) as any
} // WORKAROUND
height={200000.0}
extrudedHeight={100000.0}
width={200000.0}
cornerType={CornerType.BEVELED}
outline // height or extrudedHeight must be set for outlines to display
outlineColor={Color.WHITE}
/>
</Entity>
<Entity
{...args}
name="CylinderGraphics"
description="CylinderGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 20.7117244, 100)}>
<CylinderGraphics
length={400000.0}
topRadius={200000.0}
bottomRadius={200000.0}
material={Color.GREEN.withAlpha(0.5)}
outline
outlineColor={Color.DARKGREEN}
/>
</Entity>
<Entity
{...args}
name="EllipseGraphics"
description="EllipseGraphics!!"
position={Cartesian3.fromDegrees(-34.0707383, 60.7117244, 100)}>
<EllipseGraphics
material={Color.RED}
semiMinorAxis={150000.0}
semiMajorAxis={300000.0}
extrudedHeight={200000.0}
rotation={0.78539}
outline
/>
</Entity>
<Entity
{...args}
name="EllipsoidGraphics"
description="EllipsoidGraphics!!"
position={Cartesian3.fromDegrees(-14.0707383, 0.7117244, 100)}>
<EllipsoidGraphics
material={Color.BLUEVIOLET}
radii={new Cartesian3(300000.0, 300000.0, 300000.0)}
fill
outline
outlineColor={new Color(0, 0, 0, 1)}
/>
</Entity>
<Entity
{...args}
name="LabelGraphics"
description="LabelGraphics!!"
position={Cartesian3.fromDegrees(-34.0707383, 5.7117244, 100)}>
<LabelGraphics
text="LabelGraphics"
font="24px Helvetica"
fillColor={Color.SKYBLUE}
outlineColor={Color.BLACK}
outlineWidth={2}
style={LabelStyle.FILL_AND_OUTLINE}
/>
</Entity>
<Entity
{...args}
name="ModelGraphics"
description="ModelGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<ModelGraphics uri="Cesium_Air.glb" minimumPixelSize={128} maximumScale={20000} />
</Entity>
<Entity
{...args}
name="PathGraphics"
description="PathGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<PathGraphics
material={Color.RED}
width={8}
leadTime={10}
trailTime={1000}
resolution={5}
/>
</Entity>
<Entity
{...args}
name="PlaneGraphics"
description="PlaneGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 50.7117244, 100)}>
<PlaneGraphics
plane={new Plane(Cartesian3.UNIT_Z, 0.0)}
dimensions={new Cartesian2(400000.0, 300000.0)}
fill={false}
outline
outlineColor={Color.YELLOW}
/>
</Entity>
<Entity
{...args}
name="PointGraphics"
description="PointGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 60.7117244, 100)}>
<PointGraphics color={Color.BISQUE} pixelSize={10} />
</Entity>
<Entity {...args} name="PolygonGraphics" description="PolygonGraphics!!">
<PolygonGraphics
hierarchy={
Cartesian3.fromDegreesArray([-108.0, 42.0, -100.0, 42.0, -104.0, 40.0]) as any
} // WORKAROUND
material={Color.GREEN}
/>
</Entity>
<Entity
{...args}
name="PolylineGraphics"
description="PolylineGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<PolylineGraphics
positions={Cartesian3.fromDegreesArrayHeights([-75, 45, 500000, -125, 45, 500000])}
width={4}
material={
new PolylineDashMaterialProperty({
color: Color.CYAN,
})
}
/>
</Entity>
{/* <Entity
{...args}
name="PolylineVolumeGraphics"
description="PolylineVolumeGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<PolylineVolumeGraphics
positions={Cartesian3.fromDegreesArrayHeights([
-90.0, 32.0, 0.0, -90.0, 36.0, 100000.0, -94.0, 36.0, 0.0,
])}
shape={[
new Cartesian2(-50000, -50000),
new Cartesian2(50000, -50000),
new Cartesian2(50000, 50000),
new Cartesian2(-50000, 50000),
]}
cornerType={CornerType.BEVELED}
material={Color.GREEN.withAlpha(0.5)}
outline
outlineColor={Color.BLACK}
/>
</Entity> */}
{/* <Entity
{...args}
name="RectangleGraphics"
description="RectangleGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<RectangleGraphics
coordinates={Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0)}
material={Color.PEACHPUFF.withAlpha(0.5)}
rotation={CesiumMath.toRadians(45)}
extrudedHeight={300000.0}
height={100000.0}
outline // height must be set for outline to display
outlineColor={Color.BLACK}
/>
</Entity> */}
{/* <Entity
{...args}
name="WallGraphics"
description="WallGraphics!!"
position={Cartesian3.fromDegrees(-74.0707383, 40.7117244, 100)}>
<WallGraphics
positions={Cartesian3.fromDegreesArray([
-115.0, 50.0, -112.5, 50.0, -110.0, 50.0, -107.5, 50.0, -105.0, 50.0, -102.5, 50.0,
-100.0, 50.0, -97.5, 50.0, -95.0, 50.0, -92.5, 50.0, -90.0, 50.0,
])}
maximumHeights={[
100000, 200000, 100000, 200000, 100000, 200000, 100000, 200000, 100000, 200000, 100000,
]}
minimumHeights={[0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]}
material={Color.BLUE.withAlpha(0.5)}
outline
outlineColor={Color.BLACK}
/>
</Entity> */}
</Viewer>
</StrictMode>
),
};
10 changes: 6 additions & 4 deletions src/Entity/Entity.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ it("should mount", async () => {
</Provider>,
);

expect(ctx.entityCollection?.add).toBeCalledWith(expect.any(CesiumEntity));
expect(ref.current?.cesiumElement).toBeInstanceOf(CesiumEntity);
expect(ref.current?.cesiumElement?.name).toBe("test");
expect(ref.current?.cesiumElement?.definitionChanged.numberOfListeners).toBe(1);
await waitFor(() => {
expect(ctx.entityCollection?.add).toBeCalledWith(expect.any(CesiumEntity));
expect(ref.current?.cesiumElement).toBeInstanceOf(CesiumEntity);
expect(ref.current?.cesiumElement?.name).toBe("test");
expect(ref.current?.cesiumElement?.definitionChanged.numberOfListeners).toBe(1);
});
});

it("should unmount", () => {
Expand Down
Loading
Loading