2024-01-23 17:26:59 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import { SceneMangerStore } from "./scene_manager_store";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
import { useParams } from "react-router-dom";
|
2024-04-09 16:31:30 +03:00
|
|
|
import { MainPage } from "../../../core/ui/pages/main_page";
|
2024-01-23 17:26:59 +03:00
|
|
|
|
|
|
|
export const SceneManagerPath = "/scene/manager/";
|
|
|
|
|
|
|
|
export const SceneManger = observer(() => {
|
|
|
|
const canvasRef = React.useRef<HTMLCanvasElement>(null);
|
2024-02-16 14:16:35 +03:00
|
|
|
const [store] = React.useState(() => new SceneMangerStore());
|
2024-01-23 17:26:59 +03:00
|
|
|
const id = useParams().id as string;
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
2024-02-16 14:16:35 +03:00
|
|
|
store.init();
|
2024-04-09 16:31:25 +03:00
|
|
|
store.loadScene(canvasRef.current!);
|
2024-01-23 17:26:59 +03:00
|
|
|
document.body.style.overflow = "hidden";
|
|
|
|
return () => {
|
|
|
|
document.body.style.overflow = "scroll";
|
2024-02-16 14:16:35 +03:00
|
|
|
store.dispose();
|
2024-01-23 17:26:59 +03:00
|
|
|
};
|
2024-02-16 14:16:35 +03:00
|
|
|
}, [id, store]);
|
2024-01-23 17:26:59 +03:00
|
|
|
|
|
|
|
return (
|
2024-04-09 16:31:30 +03:00
|
|
|
<MainPage
|
|
|
|
page={"Сцена"}
|
|
|
|
bodyChildren={
|
|
|
|
<>
|
|
|
|
<canvas ref={canvasRef} style={{ overflow: "hidden" }} />
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "row",
|
|
|
|
alignContent: "center",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
position: "absolute",
|
|
|
|
width: "100vw",
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{/* <div>
|
|
|
|
{sceneIcons.map((el) => {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
backgroundColor: store.sceneMode === el.name ? "aqua" : "ActiveBorder",
|
|
|
|
}}
|
|
|
|
onClick={() => {
|
|
|
|
el.clickHandel();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{el.name}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
2024-01-23 17:26:59 +03:00
|
|
|
<div
|
|
|
|
style={{
|
2024-04-09 16:31:30 +03:00
|
|
|
marginTop: "10px",
|
|
|
|
backgroundColor: "GrayText",
|
|
|
|
border: "solid",
|
|
|
|
borderRadius: "10px",
|
|
|
|
padding: "8px",
|
|
|
|
borderColor: "white",
|
2024-01-23 17:26:59 +03:00
|
|
|
}}
|
|
|
|
>
|
2024-04-09 16:31:30 +03:00
|
|
|
{/* <div style={{ color: "white" }}>Scene manager</div>
|
|
|
|
{store.isVisibleSaveButton ? (
|
|
|
|
<>
|
|
|
|
<Button onClick={() => store.onTapSave()}>Save</Button>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
)}
|
|
|
|
{store.isLoading ? <>Loading...</> : <></>}
|
|
|
|
{store.sceneMode === SceneMode.ADD_CAMERA ? (
|
|
|
|
<div>
|
|
|
|
<Formik
|
|
|
|
initialValues={CameraViewModel.empty()}
|
|
|
|
onSubmit={async (model, actions) => {
|
|
|
|
store.addNewCamera(model);
|
|
|
|
actions.setSubmitting(false);
|
|
|
|
actions.resetForm();
|
|
|
|
}}
|
|
|
|
validate={(model) => {
|
|
|
|
return model.validate(store.getCameraLinkNames());
|
|
|
|
}}
|
|
|
|
render={() => (
|
|
|
|
<Form>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
background: "white",
|
|
|
|
flex: 1,
|
|
|
|
padding: 40,
|
|
|
|
width: "400px",
|
2024-01-23 17:26:59 +03:00
|
|
|
}}
|
|
|
|
>
|
2024-04-09 16:31:30 +03:00
|
|
|
<Input name="cameraLink" placeholder="Camera link" />
|
|
|
|
<Input name="topicImage" placeholder="Topic Image" />
|
|
|
|
<Input name="topicCameraInfo" placeholder="Topic Camera Info" />
|
|
|
|
<Input name="topicDepth" placeholder="Topic Depth" />
|
2024-02-16 14:16:35 +03:00
|
|
|
|
2024-04-09 16:31:30 +03:00
|
|
|
<ResetButton>Reset</ResetButton>
|
|
|
|
<SubmitButton>Submit</SubmitButton>
|
|
|
|
</div>
|
|
|
|
</Form>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</div>
|
2024-02-16 14:16:35 +03:00
|
|
|
) : (
|
2024-04-09 16:31:30 +03:00
|
|
|
<></>
|
|
|
|
)}
|
|
|
|
{store.sceneMode === SceneMode.MOVING || SceneMode.ROTATE ? (
|
|
|
|
<>
|
|
|
|
{store.robossemblerAssets?.assets.map((el) => {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div style={{ color: "white", marginLeft: "10px", marginRight: "10px", display: "contents" }}>
|
|
|
|
{el.name}
|
|
|
|
{store.isRenderedAsset(el.name) ? (
|
|
|
|
<></>
|
|
|
|
) : (
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
store.loadSceneRobossemblerAsset(el.name);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
add scene
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<></>
|
2024-02-16 14:16:35 +03:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-09 16:31:30 +03:00
|
|
|
<div>
|
|
|
|
{store.sceneModels.map((el) => {
|
|
|
|
return <StaticAssetModelView onTap={() => store.deleteSceneItem(el)} model={el} />;
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{store.sceneMode === SceneMode.MAGNETISM_MARKING ? (
|
|
|
|
<>
|
|
|
|
<div style={{ backgroundColor: "white" }}>
|
|
|
|
<div>completion of objects</div>
|
|
|
|
<div>
|
|
|
|
{store.objectMagnetism ? (
|
|
|
|
<>{store.objectMagnetism}</>
|
|
|
|
) : (
|
|
|
|
<Button>Selects an object for magnetism</Button>
|
|
|
|
)}
|
|
|
|
{store.objectForMagnetism ? (
|
|
|
|
<>{store.objectForMagnetism}</>
|
|
|
|
) : (
|
|
|
|
<Button>Selects an object magnet</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
)} */}
|
|
|
|
{/* </div> */}
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
2024-01-23 17:26:59 +03:00
|
|
|
);
|
|
|
|
});
|