Refactor model loading APIs.

There are three ways to load a model: from a file, from a buffer, or an
"empty" model. Instead of overloading a single function to do all three,
provide three separate functions.

Also disable model loading functions that will not work for emscripten.

PiperOrigin-RevId: 859051341
Change-Id: I71557d31d0e7c9c6882895c36116d300f19e255d
This commit is contained in:
Haroon Qureshi
2026-01-21 05:24:18 -08:00
committed by Copybara-Service
parent e2180ff744
commit 2cc2e579f1
5 changed files with 227 additions and 142 deletions
+7 -1
View File
@@ -105,7 +105,13 @@ int main(int argc, char** argv, char** envp) {
// If the model file is not specified, try to load it from the first argument
std::string model_file = absl::GetFlag(FLAGS_model_file);
if (model_file.empty() && argc > 1 && argv[1][0] != '-') model_file = argv[1];
app.LoadModel(model_file, mujoco::studio::App::ContentType::kFilepath);
if (model_file.empty()) {
app.InitEmptyModel();
} else {
app.LoadModelFromFile(model_file);
}
while (app.Update()) {
app.BuildGui();
app.Render();