-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): basic structure of plugin playground (#1036)
- Loading branch information
Showing
17 changed files
with
262 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FC } from "react"; | ||
|
||
const Console: FC = () => { | ||
return <div>Console content</div>; | ||
}; | ||
|
||
export default Console; |
7 changes: 7 additions & 0 deletions
7
web/src/beta/features/PluginPlayground/PluginInspector/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FC } from "react"; | ||
|
||
const PluginInspector: FC = () => { | ||
return <div>Plugin inspector content</div>; | ||
}; | ||
|
||
export default PluginInspector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FC } from "react"; | ||
|
||
const Plugins: FC = () => { | ||
return <div>Plugins content</div>; | ||
}; | ||
|
||
export default Plugins; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useEffect, useMemo, useRef, useState } from "react"; | ||
|
||
import { Camera } from "@reearth/beta/utils/value"; | ||
import { MapRef } from "@reearth/core"; | ||
import { config } from "@reearth/services/config"; | ||
|
||
export default () => { | ||
// Refrence: hooks of Editor/Visualizer/hooks.ts and Publish/hooks.ts | ||
const visualizerRef = useRef<MapRef | null>(null); | ||
const [ready, setReady] = useState(false); | ||
const [currentCamera, setCurrentCamera] = useState<Camera | undefined>(undefined); | ||
|
||
const engineMeta = useMemo( | ||
() => ({ | ||
cesiumIonAccessToken: config()?.cesiumIonAccessToken, | ||
}), | ||
[], | ||
); | ||
|
||
const sceneProperty = useMemo( | ||
() => ({ | ||
tiles: [ | ||
{ | ||
id: "default", | ||
type: "default", | ||
}, | ||
], | ||
}), | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
setReady(true); | ||
}, []); | ||
|
||
return { | ||
visualizerRef, | ||
sceneProperty, | ||
ready, | ||
engineMeta, | ||
currentCamera, | ||
setCurrentCamera, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { FC } from "react"; | ||
|
||
import Visualizer from "@reearth/beta/features/Visualizer"; | ||
|
||
import useHooks from "./hooks"; | ||
|
||
const Viewer: FC = () => { | ||
const { visualizerRef, sceneProperty, ready, engineMeta, currentCamera, setCurrentCamera } = | ||
useHooks(); | ||
|
||
return ( | ||
<Visualizer | ||
engine="cesium" | ||
visualizerRef={visualizerRef} | ||
sceneProperty={sceneProperty} | ||
ready={ready} | ||
engineMeta={engineMeta} | ||
currentCamera={currentCamera} | ||
onCameraChange={setCurrentCamera} | ||
/> | ||
); | ||
}; | ||
|
||
export default Viewer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useMemo } from "react"; | ||
|
||
import { TabItem } from "@reearth/beta/lib/reearth-ui"; | ||
|
||
import Console from "./Console"; | ||
import PluginInspector from "./PluginInspector"; | ||
import Plugins from "./Plugins"; | ||
import Viewer from "./Viewer"; | ||
|
||
export default () => { | ||
// Note: currently we put visualizer in tab content, so better not have more tabs in this area, | ||
// otherwise visualizer will got unmount and mount when switching tabs. | ||
const MainAreaTabs: TabItem[] = useMemo( | ||
() => [ | ||
{ | ||
id: "viewer", | ||
name: "Viewer", | ||
children: <Viewer />, | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
const BottomAreaTabs: TabItem[] = useMemo( | ||
() => [ | ||
{ | ||
id: "console", | ||
name: "Console", | ||
children: <Console />, | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
const SubRightAreaTabs: TabItem[] = useMemo( | ||
() => [ | ||
{ | ||
id: "plugins", | ||
name: "Plugins", | ||
children: <Plugins />, | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
const RightAreaTabs: TabItem[] = useMemo( | ||
() => [ | ||
{ | ||
id: "plugin-inspector", | ||
name: "Plugin Inspector", | ||
children: <PluginInspector />, | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
return { | ||
MainAreaTabs, | ||
BottomAreaTabs, | ||
SubRightAreaTabs, | ||
RightAreaTabs, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { FC } from "react"; | ||
|
||
import { Tabs } from "@reearth/beta/lib/reearth-ui"; | ||
import { Area, Window } from "@reearth/beta/ui/layout"; | ||
|
||
import useHooks from "./hooks"; | ||
|
||
const PluginPlayground: FC = () => { | ||
const { MainAreaTabs, BottomAreaTabs, SubRightAreaTabs, RightAreaTabs } = useHooks(); | ||
|
||
return ( | ||
<Window> | ||
<Area extend asWrapper> | ||
<Area direction="column" extend asWrapper> | ||
<Area extend> | ||
<Tabs position="top" tabs={MainAreaTabs} /> | ||
</Area> | ||
<Area resizableEdge="top" initialHeight={100} storageId="plugin-playground-bottom-area"> | ||
<Tabs position="top" tabs={BottomAreaTabs} /> | ||
</Area> | ||
</Area> | ||
<Area direction="column" resizableEdge="left" storageId="plugin-playground-sub-right-area"> | ||
<Tabs position="top" tabs={SubRightAreaTabs} /> | ||
</Area> | ||
<Area direction="column" resizableEdge="left" storageId="plugin-playground-right-area"> | ||
<Tabs position="top" tabs={RightAreaTabs} /> | ||
</Area> | ||
</Area> | ||
</Window> | ||
); | ||
}; | ||
|
||
export default PluginPlayground; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import PluginPlayground from "@reearth/beta/features/PluginPlayground"; | ||
|
||
type Props = {}; | ||
|
||
const PluginPlaygroundPage: React.FC<Props> = () => { | ||
return <PluginPlayground />; | ||
}; | ||
|
||
export default PluginPlaygroundPage; |
Oops, something went wrong.