import { action } from "@storybook/addon-actions"; import { Meta, StoryObj } from "@storybook/react"; import { Cartesian2, Cartesian3, Color, CornerType, LabelStyle, Plane, PolylineDashMaterialProperty, // Rectangle, // Math as CesiumMath, } from "cesium"; import { useState, useEffect, useRef, useMemo, FC } from "react"; import BillboardGraphics from "../BillboardGraphics"; import BoxGraphics from "../BoxGraphics"; import { events } from "../core/storybook"; import CorridorGraphics from "../CorridorGraphics"; import CylinderGraphics from "../CylinderGraphics"; import EllipseGraphics from "../EllipseGraphics"; import EllipsoidGraphics from "../EllipsoidGraphics"; import EntityDescription from "../EntityDescription"; import LabelGraphics from "../LabelGraphics"; import ModelGraphics from "../ModelGraphics"; import PathGraphics from "../PathGraphics"; import PlaneGraphics from "../PlaneGraphics"; import PointGraphics from "../PointGraphics"; import PolygonGraphics from "../PolygonGraphics"; import PolylineGraphics from "../PolylineGraphics"; import Viewer from "../Viewer"; import Entity, { EntityProps } from "./Entity"; // import PolylineVolumeGraphics from "../PolylineVolumeGraphics"; // import RectangleGraphics from "../RectangleGraphics"; // import WallGraphics from "../WallGraphics"; type Story = StoryObj; export default { title: "Entity", component: Entity, } as Meta; const initCanvas = () => { const can = document.createElement("canvas"); can.width = 100; can.height = 100; return can; }; const renderCanvas = (can: HTMLCanvasElement, p: number) => { const c = can.getContext("2d"); if (!c) return; c.clearRect(0, 0, can.width, can.height); c.fillStyle = "rgba(100,0,0,0.8)"; c.beginPath(); c.arc(can.width / 2, can.height / 2, (p * can.width) / 2, 0, Math.PI * 2, false); c.fill(); }; const CanvasEntity: FC = props => { const c1 = useMemo(initCanvas, []); const c2 = useMemo(initCanvas, []); const [image, setImage] = useState(); const progress = useRef(0); useEffect(() => { const i = window.setInterval(() => { progress.current = Math.min(progress.current + 0.01, 1); setImage(image => { const canvas = image === c1 ? c2 : c1; if (canvas) { renderCanvas(canvas, progress.current); } return canvas; }); if (progress.current >= 1) { clearInterval(i); } }, 10); return () => window.clearInterval(i); }, [c1, c2]); return ; }; export const Basic: Story = { render: args => ( ), }; export const Description: Story = { render: args => { // eslint-disable-next-line react-hooks/rules-of-hooks const [count, setCount] = useState(0); return (

Hello!

Hello!

This is description. It can be described with React!

); }, }; export const SelectedAndTracked: Story = { render: args => ( ), }; export const AnimatedCanvas: Story = { render: () => ( ), }; export const Events: Story = { render: args => ( ), }; export const Graphics: Story = { render: args => ( {/* */} {/* */} {/* */} ), };