Skip to content

Commit

Permalink
feat: add built field in scene in plugin api (#584)
Browse files Browse the repository at this point in the history
* feat: add built field in scene in plugin api

* fix
  • Loading branch information
rot1024 committed Mar 27, 2023
1 parent 3494b4d commit e8050c6
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/components/molecules/Visualizer/Plugin/api.ts
Expand Up @@ -297,6 +297,7 @@ export function commonReearth({
layersInViewport,
layers,
sceneProperty,
built,
inEditor,
tags,
camera,
Expand Down Expand Up @@ -364,6 +365,7 @@ export function commonReearth({
captureScreen: GlobalThis["reearth"]["scene"]["captureScreen"];
getLocationFromScreen: GlobalThis["reearth"]["scene"]["getLocationFromScreen"];
inEditor: () => GlobalThis["reearth"]["scene"]["inEditor"];
built: () => GlobalThis["reearth"]["scene"]["built"];
enableScreenSpaceCameraController: GlobalThis["reearth"]["camera"]["enableScreenSpaceController"];
lookHorizontal: GlobalThis["reearth"]["camera"]["lookHorizontal"];
lookVertical: GlobalThis["reearth"]["camera"]["lookVertical"];
Expand Down Expand Up @@ -418,6 +420,9 @@ export function commonReearth({
get inEditor() {
return inEditor();
},
get built() {
return built();
},
get property() {
return sceneProperty();
},
Expand Down
4 changes: 4 additions & 0 deletions src/components/molecules/Visualizer/Plugin/context.tsx
Expand Up @@ -48,6 +48,7 @@ export type Props = {
engineName: string;
sceneProperty?: any;
inEditor: boolean;
built: boolean;
tags?: Tag[];
camera?: CameraPosition;
clock: Clock | undefined;
Expand Down Expand Up @@ -113,6 +114,7 @@ export function Provider({
engineName,
sceneProperty,
inEditor,
built,
tags,
camera,
clock,
Expand Down Expand Up @@ -164,6 +166,7 @@ export function Provider({
const getLayers = useGet(layers);
const getSceneProperty = useGet(sceneProperty);
const getInEditor = useGet(inEditor);
const getBuilt = useGet(built);
const getTags = useGet(tags ?? []);
const getCamera = useGet(camera);
const getClock = useGet(clock);
Expand Down Expand Up @@ -192,6 +195,7 @@ export function Provider({
layers: getLayers,
sceneProperty: getSceneProperty,
inEditor: getInEditor,
built: getBuilt,
tags: getTags,
camera: getCamera,
clock: getClock,
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/Visualizer/Plugin/types.ts
Expand Up @@ -120,8 +120,8 @@ export type LatLngHeight = {
};

export type Scene = {
/** Current scene property */
readonly inEditor: boolean;
readonly built: boolean;
readonly property?: any;
readonly overrideProperty: (property: any) => void;
readonly captureScreen: (type?: string, encoderOptions?: number) => string | undefined;
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/Visualizer/hooks.ts
Expand Up @@ -230,6 +230,7 @@ export default ({
engineName: engineType || "",
sceneProperty: overriddenSceneProperty,
inEditor: !!inEditor,
built: !!isBuilt,
tags,
camera: innerCamera,
clock: innerClock,
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/Visualizer/storybook.tsx
Expand Up @@ -59,6 +59,7 @@ export const context: ProviderProps = {
engineName: "cesium",
engine: {},
inEditor: false,
built: false,
hideLayer: act("layers.hide"),
showLayer: act("layers.show"),
selectLayer: act("layers.select"),
Expand Down
3 changes: 1 addition & 2 deletions src/components/pages/Preview/index.tsx
Expand Up @@ -27,8 +27,7 @@ const PreviewPage: React.FC<Props> = () => {
<ThemeProvider>
<DndProvider>
<AuthenticationRequiredPage>
{typeof core === "boolean" &&
(core ? <CoreCanvasArea isBuilt /> : <CanvasArea isBuilt />)}
{typeof core === "boolean" && (core ? <CoreCanvasArea /> : <CanvasArea />)}
</AuthenticationRequiredPage>
</DndProvider>
</ThemeProvider>
Expand Down
5 changes: 5 additions & 0 deletions src/core/Crust/Plugins/api.ts
Expand Up @@ -299,6 +299,7 @@ export function commonReearth({
layers,
sceneProperty,
inEditor,
built,
tags,
camera,
clock,
Expand Down Expand Up @@ -365,6 +366,7 @@ export function commonReearth({
getLocationFromScreen: GlobalThis["reearth"]["scene"]["getLocationFromScreen"];
sampleTerrainHeight: GlobalThis["reearth"]["scene"]["sampleTerrainHeight"];
inEditor: () => GlobalThis["reearth"]["scene"]["inEditor"];
built: () => GlobalThis["reearth"]["scene"]["built"];
enableScreenSpaceCameraController: GlobalThis["reearth"]["camera"]["enableScreenSpaceController"];
lookHorizontal: GlobalThis["reearth"]["camera"]["lookHorizontal"];
lookVertical: GlobalThis["reearth"]["camera"]["lookVertical"];
Expand Down Expand Up @@ -419,6 +421,9 @@ export function commonReearth({
get inEditor() {
return !!inEditor?.();
},
get built() {
return !!built?.();
},
get property() {
return sceneProperty?.();
},
Expand Down
3 changes: 3 additions & 0 deletions src/core/Crust/Plugins/hooks.ts
Expand Up @@ -29,6 +29,7 @@ export default function ({
mapRef,
sceneProperty,
inEditor,
built,
tags,
viewport,
selectedLayer,
Expand All @@ -55,6 +56,7 @@ export default function ({
const getLayers = useGet(layersRef);
const getSceneProperty = useGet(sceneProperty);
const getInEditor = useGet(!!inEditor);
const getBuilt = useGet(!!built);
const getTags = useGet(tags ?? []);
const getCamera = useGet(camera);
const getClock = useCallback(() => {
Expand Down Expand Up @@ -276,6 +278,7 @@ export default function ({
layers: getLayers,
sceneProperty: getSceneProperty,
inEditor: getInEditor,
built: getBuilt,
tags: getTags,
camera: getCamera,
clock: getClock,
Expand Down
2 changes: 1 addition & 1 deletion src/core/Crust/Plugins/plugin_types.ts
Expand Up @@ -112,8 +112,8 @@ export type Reearth = {
};

export type Scene = {
/** Current scene property */
readonly inEditor: boolean;
readonly built: boolean;
readonly property?: any;
readonly overrideProperty: (property: any) => void;
readonly captureScreen: (type?: string, encoderOptions?: number) => string | undefined;
Expand Down
1 change: 1 addition & 0 deletions src/core/Crust/Plugins/storybook.tsx
Expand Up @@ -89,6 +89,7 @@ export const context: Context = {
},
scene: {
inEditor: false,
built: false,
overrideProperty: act("overrideSceneProperty"),
captureScreen: act("captureScreen"),
getLocationFromScreen: act("getLocationFromScreen"),
Expand Down
1 change: 1 addition & 0 deletions src/core/Crust/Plugins/types.ts
Expand Up @@ -16,6 +16,7 @@ export type Props = PropsWithChildren<{
mapRef?: RefObject<MapRef>;
sceneProperty?: any;
inEditor?: boolean;
built?: boolean;
tags?: Tag[];
selectedLayer?: ComputedLayer;
selectedFeature?: ComputedFeature;
Expand Down
1 change: 1 addition & 0 deletions src/core/Crust/index.tsx
Expand Up @@ -175,6 +175,7 @@ export default function Crust({
engineName={engineName}
mapRef={mapRef}
sceneProperty={sceneProperty}
built={isBuilt}
inEditor={inEditor}
tags={tags}
selectedLayer={selectedComputedLayer}
Expand Down

0 comments on commit e8050c6

Please sign in to comment.