From 11331b682dd0fe81895c69596e3b5936187e5a78 Mon Sep 17 00:00:00 2001 From: Benjamin Bolte Date: Sun, 10 Nov 2024 01:55:23 -0800 Subject: [PATCH] no more humanoid --- .../src/components/files/FileRenderer.tsx | 3 +- .../src/components/files/MJCFRenderer.tsx | 12 +- .../src/components/files/demo/humanoid.xml | 238 ------------------ .../src/components/files/mujoco/mujoco.ts | 9 +- 4 files changed, 13 insertions(+), 249 deletions(-) delete mode 100644 frontend/src/components/files/demo/humanoid.xml diff --git a/frontend/src/components/files/FileRenderer.tsx b/frontend/src/components/files/FileRenderer.tsx index bbbd743e..b4faf2d7 100644 --- a/frontend/src/components/files/FileRenderer.tsx +++ b/frontend/src/components/files/FileRenderer.tsx @@ -35,8 +35,7 @@ const FileRenderer: React.FC<{ // funky about the way the MJCF files are being generated by the // K-Scale Onshape Library that isn't working well with the current // renderer. - // return ; - return ; + return ; } else { return (
diff --git a/frontend/src/components/files/MJCFRenderer.tsx b/frontend/src/components/files/MJCFRenderer.tsx index 3a758f79..f596e14d 100644 --- a/frontend/src/components/files/MJCFRenderer.tsx +++ b/frontend/src/components/files/MJCFRenderer.tsx @@ -9,7 +9,6 @@ import { FaUndo, } from "react-icons/fa"; -import humanoid from "@/components/files/demo/humanoid.xml"; import { MujocoRefs, cleanupMujoco, @@ -29,7 +28,7 @@ import * as THREE from "three"; import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"; interface Props { - mjcfContent?: string; + mjcfContent: string; files: UntarredFile[]; useControls?: boolean; } @@ -218,8 +217,7 @@ const MJCFRenderer = ({ mjcfContent, files, useControls = true }: Props) => { // Initialize MuJoCo with the humanoid model const { mj, model, state, simulation } = await initializeMujoco({ - modelXML: - mjcfContent || (await fetch(humanoid).then((r) => r.text())), + modelXML: mjcfContent, files, }); @@ -317,10 +315,8 @@ const MJCFRenderer = ({ mjcfContent, files, useControls = true }: Props) => { {/* Add notification banner */}

- The MuJoCo renderer is currently under development. A - placeholder humanoid model is being used for demonstration - purposes. If you would like to contribute, see the project - repository{" "} + The MuJoCo renderer is currently under development. If you + would like to contribute, see the project repository{" "} - - diff --git a/frontend/src/components/files/mujoco/mujoco.ts b/frontend/src/components/files/mujoco/mujoco.ts index a9c5a85c..c9f78c2a 100644 --- a/frontend/src/components/files/mujoco/mujoco.ts +++ b/frontend/src/components/files/mujoco/mujoco.ts @@ -40,8 +40,15 @@ export const initializeMujoco = async ({ // Write all asset files to the filesystem for (const file of files) { + // Skip non-mesh files + if ( + !file.name.toLowerCase().endsWith(".stl") && + !file.name.toLowerCase().endsWith(".obj") + ) { + continue; + } + const filePath = `${MODEL_DIR}/${file.name}`; - // Create subdirectories if needed const dirs = file.name.split("/"); if (dirs.length > 1) { let currentPath = MODEL_DIR;