diff --git a/optuna_dashboard/ts/components/ModelViewer.tsx b/optuna_dashboard/ts/components/ThreejsArtifactViewer.tsx similarity index 94% rename from optuna_dashboard/ts/components/ModelViewer.tsx rename to optuna_dashboard/ts/components/ThreejsArtifactViewer.tsx index 9f97ada1..536f1d91 100644 --- a/optuna_dashboard/ts/components/ModelViewer.tsx +++ b/optuna_dashboard/ts/components/ThreejsArtifactViewer.tsx @@ -6,7 +6,7 @@ import { STLLoader } from "three/examples/jsm/loaders/STLLoader" import { Rhino3dmLoader } from "three/examples/jsm/loaders/3DMLoader" import { PerspectiveCamera } from "three" -interface ModelViewerProps { +interface ThreejsArtifactViewerProps { src: string width: string height: string @@ -14,7 +14,7 @@ interface ModelViewerProps { filetype: string | undefined } -function CustomGizmoHelper(): JSX.Element { +const CustomGizmoHelper: React.FC = () => { return ( { return boundingBox } -export function ModelViewer(props: ModelViewerProps): JSX.Element { +export const ThreejsArtifactViewer: React.FC = ( + props +) => { const [geometry, setGeometry] = useState([]) const [modelSize, setModelSize] = useState( new THREE.Vector3(10, 10, 10) diff --git a/optuna_dashboard/ts/components/TrialList.tsx b/optuna_dashboard/ts/components/TrialList.tsx index be124871..eb700c13 100644 --- a/optuna_dashboard/ts/components/TrialList.tsx +++ b/optuna_dashboard/ts/components/TrialList.tsx @@ -47,7 +47,7 @@ import { artifactIsAvailable } from "../state" import { actionCreator } from "../action" import { useDeleteArtifactDialog } from "./DeleteArtifactDialog" import { TrialFormWidgets } from "./TrialFormWidgets" -import { ModelViewer } from "./ModelViewer" +import { ThreejsArtifactViewer } from "./ThreejsArtifactViewer" const states: TrialState[] = [ "Complete", @@ -336,7 +336,6 @@ const TrialArtifact: FC<{ trial: Trial }> = ({ trial }) => { const width = "200px" const height = "150px" - const modelViewerTargetExt = ["stl", "3dm"] const inputRef = useRef(null) const handleClick: MouseEventHandler = () => { @@ -446,7 +445,8 @@ const TrialArtifact: FC<{ trial: Trial }> = ({ trial }) => { ) } else if ( - modelViewerTargetExt.includes(a.filename.split(".").pop() || "") + a.filename.endsWith(".stl") || + a.filename.endsWith(".3dm") ) { return ( = ({ trial }) => { alignItems: "center", }} > - = ({ trial }) => { onClick={() => { setOpen3dModelViewer(() => { const obj = { ...open3dModelViewer } - obj[a.filename] = true + obj[a.artifact_id] = true return obj }) }} @@ -510,14 +510,14 @@ const TrialArtifact: FC<{ trial: Trial }> = ({ trial }) => { { setOpen3dModelViewer(() => { const obj = { ...open3dModelViewer } - obj[a.filename] = false + obj[a.artifact_id] = false return obj }) }} @@ -532,7 +532,7 @@ const TrialArtifact: FC<{ trial: Trial }> = ({ trial }) => { borderRadius: "15px", }} > -