From 3577c98f821e79ef8a8b440b6628a9d89d24c959 Mon Sep 17 00:00:00 2001 From: Google DeepMind Date: Wed, 5 Nov 2025 11:13:30 -0800 Subject: [PATCH] Refactor Emscripten bindings generation for MuJoCo structs. PiperOrigin-RevId: 828550215 Change-Id: Iab0bf3a9fbaca4d7774f89a4d8977e762aa57629 --- wasm/codegen/generated/bindings.cc | 1012 ++++++++++++++-------------- wasm/codegen/generators/structs.py | 20 +- wasm/codegen/helpers/structs.py | 42 +- wasm/codegen/templates/bindings.cc | 229 +------ 4 files changed, 545 insertions(+), 758 deletions(-) diff --git a/wasm/codegen/generated/bindings.cc b/wasm/codegen/generated/bindings.cc index d0caf055..60cc3cdc 100644 --- a/wasm/codegen/generated/bindings.cc +++ b/wasm/codegen/generated/bindings.cc @@ -8531,20 +8531,6 @@ std::unique_ptr parseXMLString(const std::string &xml) { EMSCRIPTEN_BINDINGS(mujoco_bindings) { function("parseXMLString", &parseXMLString, take_ownership()); - emscripten::class_("MjLROpt") - .constructor<>() - .function("copy", &MjLROpt::copy, take_ownership()) - .property("mode", &MjLROpt::mode, &MjLROpt::set_mode, reference()) - .property("useexisting", &MjLROpt::useexisting, &MjLROpt::set_useexisting, reference()) - .property("uselimit", &MjLROpt::uselimit, &MjLROpt::set_uselimit, reference()) - .property("accel", &MjLROpt::accel, &MjLROpt::set_accel, reference()) - .property("maxforce", &MjLROpt::maxforce, &MjLROpt::set_maxforce, reference()) - .property("timeconst", &MjLROpt::timeconst, &MjLROpt::set_timeconst, reference()) - .property("timestep", &MjLROpt::timestep, &MjLROpt::set_timestep, reference()) - .property("inttotal", &MjLROpt::inttotal, &MjLROpt::set_inttotal, reference()) - .property("interval", &MjLROpt::interval, &MjLROpt::set_interval, reference()) - .property("tolrange", &MjLROpt::tolrange, &MjLROpt::set_tolrange, reference()) - ; emscripten::class_("MjModel") .class_function("loadFromXML", &loadFromXML, take_ownership()) .constructor() @@ -9255,6 +9241,114 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("threadpool", &MjData::threadpool, &MjData::set_threadpool, reference()) .property("signature", &MjData::signature, &MjData::set_signature, reference()) ; + emscripten::class_("MjvScene") + .constructor<>() + .constructor() + .property("maxgeom", &MjvScene::maxgeom, &MjvScene::set_maxgeom, reference()) + .property("ngeom", &MjvScene::ngeom, &MjvScene::set_ngeom, reference()) + .property("geoms", &MjvScene::geoms) + .property("geomorder", &MjvScene::geomorder) + .property("nflex", &MjvScene::nflex, &MjvScene::set_nflex, reference()) + .property("flexedgeadr", &MjvScene::flexedgeadr) + .property("flexedgenum", &MjvScene::flexedgenum) + .property("flexvertadr", &MjvScene::flexvertadr) + .property("flexvertnum", &MjvScene::flexvertnum) + .property("flexfaceadr", &MjvScene::flexfaceadr) + .property("flexfacenum", &MjvScene::flexfacenum) + .property("flexfaceused", &MjvScene::flexfaceused) + .property("flexedge", &MjvScene::flexedge) + .property("flexvert", &MjvScene::flexvert) + .property("flexface", &MjvScene::flexface) + .property("flexnormal", &MjvScene::flexnormal) + .property("flextexcoord", &MjvScene::flextexcoord) + .property("flexvertopt", &MjvScene::flexvertopt, &MjvScene::set_flexvertopt, reference()) + .property("flexedgeopt", &MjvScene::flexedgeopt, &MjvScene::set_flexedgeopt, reference()) + .property("flexfaceopt", &MjvScene::flexfaceopt, &MjvScene::set_flexfaceopt, reference()) + .property("flexskinopt", &MjvScene::flexskinopt, &MjvScene::set_flexskinopt, reference()) + .property("nskin", &MjvScene::nskin, &MjvScene::set_nskin, reference()) + .property("skinfacenum", &MjvScene::skinfacenum) + .property("skinvertadr", &MjvScene::skinvertadr) + .property("skinvertnum", &MjvScene::skinvertnum) + .property("skinvert", &MjvScene::skinvert) + .property("skinnormal", &MjvScene::skinnormal) + .property("nlight", &MjvScene::nlight, &MjvScene::set_nlight, reference()) + .property("lights", &MjvScene::lights) + .property("camera", &MjvScene::camera) + .property("enabletransform", &MjvScene::enabletransform, &MjvScene::set_enabletransform, reference()) + .property("translate", &MjvScene::translate) + .property("rotate", &MjvScene::rotate) + .property("scale", &MjvScene::scale, &MjvScene::set_scale, reference()) + .property("stereo", &MjvScene::stereo, &MjvScene::set_stereo, reference()) + .property("flags", &MjvScene::flags) + .property("framewidth", &MjvScene::framewidth, &MjvScene::set_framewidth, reference()) + .property("framergb", &MjvScene::framergb) + .property("status", &MjvScene::status, &MjvScene::set_status, reference()) + ; + emscripten::class_("MjSpec") + .constructor() + .property("element", &MjSpec::element) + .property("modelname", &MjSpec::modelname, &MjSpec::set_modelname, reference()) + .property("compiler", &MjSpec::compiler) + .property("strippath", &MjSpec::strippath, &MjSpec::set_strippath, reference()) + .property("option", &MjSpec::option) + .property("visual", &MjSpec::visual) + .property("stat", &MjSpec::stat) + .property("memory", &MjSpec::memory, &MjSpec::set_memory, reference()) + .property("nemax", &MjSpec::nemax, &MjSpec::set_nemax, reference()) + .property("nuserdata", &MjSpec::nuserdata, &MjSpec::set_nuserdata, reference()) + .property("nuser_body", &MjSpec::nuser_body, &MjSpec::set_nuser_body, reference()) + .property("nuser_jnt", &MjSpec::nuser_jnt, &MjSpec::set_nuser_jnt, reference()) + .property("nuser_geom", &MjSpec::nuser_geom, &MjSpec::set_nuser_geom, reference()) + .property("nuser_site", &MjSpec::nuser_site, &MjSpec::set_nuser_site, reference()) + .property("nuser_cam", &MjSpec::nuser_cam, &MjSpec::set_nuser_cam, reference()) + .property("nuser_tendon", &MjSpec::nuser_tendon, &MjSpec::set_nuser_tendon, reference()) + .property("nuser_actuator", &MjSpec::nuser_actuator, &MjSpec::set_nuser_actuator, reference()) + .property("nuser_sensor", &MjSpec::nuser_sensor, &MjSpec::set_nuser_sensor, reference()) + .property("nkey", &MjSpec::nkey, &MjSpec::set_nkey, reference()) + .property("njmax", &MjSpec::njmax, &MjSpec::set_njmax, reference()) + .property("nconmax", &MjSpec::nconmax, &MjSpec::set_nconmax, reference()) + .property("nstack", &MjSpec::nstack, &MjSpec::set_nstack, reference()) + .property("comment", &MjSpec::comment, &MjSpec::set_comment, reference()) + .property("modelfiledir", &MjSpec::modelfiledir, &MjSpec::set_modelfiledir, reference()) + .property("hasImplicitPluginElem", &MjSpec::hasImplicitPluginElem, &MjSpec::set_hasImplicitPluginElem, reference()) + ; + emscripten::class_("MjContact") + .constructor<>() + .function("copy", &MjContact::copy, take_ownership()) + .property("dist", &MjContact::dist, &MjContact::set_dist, reference()) + .property("pos", &MjContact::pos) + .property("frame", &MjContact::frame) + .property("includemargin", &MjContact::includemargin, &MjContact::set_includemargin, reference()) + .property("friction", &MjContact::friction) + .property("solref", &MjContact::solref) + .property("solreffriction", &MjContact::solreffriction) + .property("solimp", &MjContact::solimp) + .property("mu", &MjContact::mu, &MjContact::set_mu, reference()) + .property("H", &MjContact::H) + .property("dim", &MjContact::dim, &MjContact::set_dim, reference()) + .property("geom1", &MjContact::geom1, &MjContact::set_geom1, reference()) + .property("geom2", &MjContact::geom2, &MjContact::set_geom2, reference()) + .property("geom", &MjContact::geom) + .property("flex", &MjContact::flex) + .property("elem", &MjContact::elem) + .property("vert", &MjContact::vert) + .property("exclude", &MjContact::exclude, &MjContact::set_exclude, reference()) + .property("efc_address", &MjContact::efc_address, &MjContact::set_efc_address, reference()) + ; + emscripten::class_("MjLROpt") + .constructor<>() + .function("copy", &MjLROpt::copy, take_ownership()) + .property("mode", &MjLROpt::mode, &MjLROpt::set_mode, reference()) + .property("useexisting", &MjLROpt::useexisting, &MjLROpt::set_useexisting, reference()) + .property("uselimit", &MjLROpt::uselimit, &MjLROpt::set_uselimit, reference()) + .property("accel", &MjLROpt::accel, &MjLROpt::set_accel, reference()) + .property("maxforce", &MjLROpt::maxforce, &MjLROpt::set_maxforce, reference()) + .property("timeconst", &MjLROpt::timeconst, &MjLROpt::set_timeconst, reference()) + .property("timestep", &MjLROpt::timestep, &MjLROpt::set_timestep, reference()) + .property("inttotal", &MjLROpt::inttotal, &MjLROpt::set_inttotal, reference()) + .property("interval", &MjLROpt::interval, &MjLROpt::set_interval, reference()) + .property("tolrange", &MjLROpt::tolrange, &MjLROpt::set_tolrange, reference()) + ; emscripten::class_("MjOption") .constructor<>() .function("copy", &MjOption::copy, take_ownership()) @@ -9287,6 +9381,17 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("sdf_initpoints", &MjOption::sdf_initpoints, &MjOption::set_sdf_initpoints, reference()) .property("sdf_iterations", &MjOption::sdf_iterations, &MjOption::set_sdf_iterations, reference()) ; + emscripten::class_("MjSolverStat") + .constructor<>() + .function("copy", &MjSolverStat::copy, take_ownership()) + .property("improvement", &MjSolverStat::improvement, &MjSolverStat::set_improvement, reference()) + .property("gradient", &MjSolverStat::gradient, &MjSolverStat::set_gradient, reference()) + .property("lineslope", &MjSolverStat::lineslope, &MjSolverStat::set_lineslope, reference()) + .property("nactive", &MjSolverStat::nactive, &MjSolverStat::set_nactive, reference()) + .property("nchange", &MjSolverStat::nchange, &MjSolverStat::set_nchange, reference()) + .property("neval", &MjSolverStat::neval, &MjSolverStat::set_neval, reference()) + .property("nupdate", &MjSolverStat::nupdate, &MjSolverStat::set_nupdate, reference()) + ; emscripten::class_("MjStatistic") .constructor<>() .function("copy", &MjStatistic::copy, take_ownership()) @@ -9296,6 +9401,26 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("extent", &MjStatistic::extent, &MjStatistic::set_extent, reference()) .property("center", &MjStatistic::center) ; + emscripten::class_("MjTimerStat") + .constructor<>() + .function("copy", &MjTimerStat::copy, take_ownership()) + .property("duration", &MjTimerStat::duration, &MjTimerStat::set_duration, reference()) + .property("number", &MjTimerStat::number, &MjTimerStat::set_number, reference()) + ; + emscripten::class_("MjVFS") + .constructor<>() + // TODO: .property("impl_", &MjVFS::impl_) + ; + emscripten::class_("MjVisual") + .constructor<>() + .function("copy", &MjVisual::copy, take_ownership()) + .property("global", &MjVisual::global, reference()) + .property("quality", &MjVisual::quality, reference()) + .property("headlight", &MjVisual::headlight, reference()) + .property("map", &MjVisual::map, reference()) + .property("scale", &MjVisual::scale, reference()) + .property("rgba", &MjVisual::rgba, reference()) + ; emscripten::class_("MjVisualGlobal") .constructor<>() .function("copy", &MjVisualGlobal::copy, take_ownership()) @@ -9313,15 +9438,6 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("ellipsoidinertia", &MjVisualGlobal::ellipsoidinertia, &MjVisualGlobal::set_ellipsoidinertia, reference()) .property("bvactive", &MjVisualGlobal::bvactive, &MjVisualGlobal::set_bvactive, reference()) ; - emscripten::class_("MjVisualQuality") - .constructor<>() - .function("copy", &MjVisualQuality::copy, take_ownership()) - .property("shadowsize", &MjVisualQuality::shadowsize, &MjVisualQuality::set_shadowsize, reference()) - .property("offsamples", &MjVisualQuality::offsamples, &MjVisualQuality::set_offsamples, reference()) - .property("numslices", &MjVisualQuality::numslices, &MjVisualQuality::set_numslices, reference()) - .property("numstacks", &MjVisualQuality::numstacks, &MjVisualQuality::set_numstacks, reference()) - .property("numquads", &MjVisualQuality::numquads, &MjVisualQuality::set_numquads, reference()) - ; emscripten::class_("MjVisualHeadlight") .constructor<>() .function("copy", &MjVisualHeadlight::copy, take_ownership()) @@ -9347,26 +9463,14 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("shadowscale", &MjVisualMap::shadowscale, &MjVisualMap::set_shadowscale, reference()) .property("actuatortendon", &MjVisualMap::actuatortendon, &MjVisualMap::set_actuatortendon, reference()) ; - emscripten::class_("MjVisualScale") + emscripten::class_("MjVisualQuality") .constructor<>() - .function("copy", &MjVisualScale::copy, take_ownership()) - .property("forcewidth", &MjVisualScale::forcewidth, &MjVisualScale::set_forcewidth, reference()) - .property("contactwidth", &MjVisualScale::contactwidth, &MjVisualScale::set_contactwidth, reference()) - .property("contactheight", &MjVisualScale::contactheight, &MjVisualScale::set_contactheight, reference()) - .property("connect", &MjVisualScale::connect, &MjVisualScale::set_connect, reference()) - .property("com", &MjVisualScale::com, &MjVisualScale::set_com, reference()) - .property("camera", &MjVisualScale::camera, &MjVisualScale::set_camera, reference()) - .property("light", &MjVisualScale::light, &MjVisualScale::set_light, reference()) - .property("selectpoint", &MjVisualScale::selectpoint, &MjVisualScale::set_selectpoint, reference()) - .property("jointlength", &MjVisualScale::jointlength, &MjVisualScale::set_jointlength, reference()) - .property("jointwidth", &MjVisualScale::jointwidth, &MjVisualScale::set_jointwidth, reference()) - .property("actuatorlength", &MjVisualScale::actuatorlength, &MjVisualScale::set_actuatorlength, reference()) - .property("actuatorwidth", &MjVisualScale::actuatorwidth, &MjVisualScale::set_actuatorwidth, reference()) - .property("framelength", &MjVisualScale::framelength, &MjVisualScale::set_framelength, reference()) - .property("framewidth", &MjVisualScale::framewidth, &MjVisualScale::set_framewidth, reference()) - .property("constraint", &MjVisualScale::constraint, &MjVisualScale::set_constraint, reference()) - .property("slidercrank", &MjVisualScale::slidercrank, &MjVisualScale::set_slidercrank, reference()) - .property("frustum", &MjVisualScale::frustum, &MjVisualScale::set_frustum, reference()) + .function("copy", &MjVisualQuality::copy, take_ownership()) + .property("shadowsize", &MjVisualQuality::shadowsize, &MjVisualQuality::set_shadowsize, reference()) + .property("offsamples", &MjVisualQuality::offsamples, &MjVisualQuality::set_offsamples, reference()) + .property("numslices", &MjVisualQuality::numslices, &MjVisualQuality::set_numslices, reference()) + .property("numstacks", &MjVisualQuality::numstacks, &MjVisualQuality::set_numstacks, reference()) + .property("numquads", &MjVisualQuality::numquads, &MjVisualQuality::set_numquads, reference()) ; emscripten::class_("MjVisualRgba") .constructor<>() @@ -9397,32 +9501,26 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("bv", &MjVisualRgba::bv) .property("bvactive", &MjVisualRgba::bvactive) ; - emscripten::class_("MjVisual") + emscripten::class_("MjVisualScale") .constructor<>() - .function("copy", &MjVisual::copy, take_ownership()) - .property("global", &MjVisual::global, reference()) - .property("quality", &MjVisual::quality, reference()) - .property("headlight", &MjVisual::headlight, reference()) - .property("map", &MjVisual::map, reference()) - .property("scale", &MjVisual::scale, reference()) - .property("rgba", &MjVisual::rgba, reference()) - ; - emscripten::class_("MjSolverStat") - .constructor<>() - .function("copy", &MjSolverStat::copy, take_ownership()) - .property("improvement", &MjSolverStat::improvement, &MjSolverStat::set_improvement, reference()) - .property("gradient", &MjSolverStat::gradient, &MjSolverStat::set_gradient, reference()) - .property("lineslope", &MjSolverStat::lineslope, &MjSolverStat::set_lineslope, reference()) - .property("nactive", &MjSolverStat::nactive, &MjSolverStat::set_nactive, reference()) - .property("nchange", &MjSolverStat::nchange, &MjSolverStat::set_nchange, reference()) - .property("neval", &MjSolverStat::neval, &MjSolverStat::set_neval, reference()) - .property("nupdate", &MjSolverStat::nupdate, &MjSolverStat::set_nupdate, reference()) - ; - emscripten::class_("MjTimerStat") - .constructor<>() - .function("copy", &MjTimerStat::copy, take_ownership()) - .property("duration", &MjTimerStat::duration, &MjTimerStat::set_duration, reference()) - .property("number", &MjTimerStat::number, &MjTimerStat::set_number, reference()) + .function("copy", &MjVisualScale::copy, take_ownership()) + .property("forcewidth", &MjVisualScale::forcewidth, &MjVisualScale::set_forcewidth, reference()) + .property("contactwidth", &MjVisualScale::contactwidth, &MjVisualScale::set_contactwidth, reference()) + .property("contactheight", &MjVisualScale::contactheight, &MjVisualScale::set_contactheight, reference()) + .property("connect", &MjVisualScale::connect, &MjVisualScale::set_connect, reference()) + .property("com", &MjVisualScale::com, &MjVisualScale::set_com, reference()) + .property("camera", &MjVisualScale::camera, &MjVisualScale::set_camera, reference()) + .property("light", &MjVisualScale::light, &MjVisualScale::set_light, reference()) + .property("selectpoint", &MjVisualScale::selectpoint, &MjVisualScale::set_selectpoint, reference()) + .property("jointlength", &MjVisualScale::jointlength, &MjVisualScale::set_jointlength, reference()) + .property("jointwidth", &MjVisualScale::jointwidth, &MjVisualScale::set_jointwidth, reference()) + .property("actuatorlength", &MjVisualScale::actuatorlength, &MjVisualScale::set_actuatorlength, reference()) + .property("actuatorwidth", &MjVisualScale::actuatorwidth, &MjVisualScale::set_actuatorwidth, reference()) + .property("framelength", &MjVisualScale::framelength, &MjVisualScale::set_framelength, reference()) + .property("framewidth", &MjVisualScale::framewidth, &MjVisualScale::set_framewidth, reference()) + .property("constraint", &MjVisualScale::constraint, &MjVisualScale::set_constraint, reference()) + .property("slidercrank", &MjVisualScale::slidercrank, &MjVisualScale::set_slidercrank, reference()) + .property("frustum", &MjVisualScale::frustum, &MjVisualScale::set_frustum, reference()) ; emscripten::class_("MjWarningStat") .constructor<>() @@ -9430,43 +9528,16 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("lastinfo", &MjWarningStat::lastinfo, &MjWarningStat::set_lastinfo, reference()) .property("number", &MjWarningStat::number, &MjWarningStat::set_number, reference()) ; - emscripten::class_("MjContact") - .constructor<>() - .function("copy", &MjContact::copy, take_ownership()) - .property("dist", &MjContact::dist, &MjContact::set_dist, reference()) - .property("pos", &MjContact::pos) - .property("frame", &MjContact::frame) - .property("includemargin", &MjContact::includemargin, &MjContact::set_includemargin, reference()) - .property("friction", &MjContact::friction) - .property("solref", &MjContact::solref) - .property("solreffriction", &MjContact::solreffriction) - .property("solimp", &MjContact::solimp) - .property("mu", &MjContact::mu, &MjContact::set_mu, reference()) - .property("H", &MjContact::H) - .property("dim", &MjContact::dim, &MjContact::set_dim, reference()) - .property("geom1", &MjContact::geom1, &MjContact::set_geom1, reference()) - .property("geom2", &MjContact::geom2, &MjContact::set_geom2, reference()) - .property("geom", &MjContact::geom) - .property("flex", &MjContact::flex) - .property("elem", &MjContact::elem) - .property("vert", &MjContact::vert) - .property("exclude", &MjContact::exclude, &MjContact::set_exclude, reference()) - .property("efc_address", &MjContact::efc_address, &MjContact::set_efc_address, reference()) + emscripten::class_("MjsElement") + .property("elemtype", &MjsElement::elemtype, &MjsElement::set_elemtype, reference()) + .property("signature", &MjsElement::signature, &MjsElement::set_signature, reference()) ; - emscripten::class_("MjvPerturb") - .constructor<>() - .function("copy", &MjvPerturb::copy, take_ownership()) - .property("select", &MjvPerturb::select, &MjvPerturb::set_select, reference()) - .property("flexselect", &MjvPerturb::flexselect, &MjvPerturb::set_flexselect, reference()) - .property("skinselect", &MjvPerturb::skinselect, &MjvPerturb::set_skinselect, reference()) - .property("active", &MjvPerturb::active, &MjvPerturb::set_active, reference()) - .property("active2", &MjvPerturb::active2, &MjvPerturb::set_active2, reference()) - .property("refpos", &MjvPerturb::refpos) - .property("refquat", &MjvPerturb::refquat) - .property("refselpos", &MjvPerturb::refselpos) - .property("localpos", &MjvPerturb::localpos) - .property("localmass", &MjvPerturb::localmass, &MjvPerturb::set_localmass, reference()) - .property("scale", &MjvPerturb::scale, &MjvPerturb::set_scale, reference()) + emscripten::class_("MjsOrientation") + .property("type", &MjsOrientation::type, &MjsOrientation::set_type, reference()) + .property("axisangle", &MjsOrientation::axisangle) + .property("xyaxes", &MjsOrientation::xyaxes) + .property("zaxis", &MjsOrientation::zaxis) + .property("euler", &MjsOrientation::euler) ; emscripten::class_("MjvCamera") .constructor<>() @@ -9480,6 +9551,43 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("elevation", &MjvCamera::elevation, &MjvCamera::set_elevation, reference()) .property("orthographic", &MjvCamera::orthographic, &MjvCamera::set_orthographic, reference()) ; + emscripten::class_("MjvFigure") + .constructor<>() + .function("copy", &MjvFigure::copy, take_ownership()) + .property("flg_legend", &MjvFigure::flg_legend, &MjvFigure::set_flg_legend, reference()) + .property("flg_ticklabel", &MjvFigure::flg_ticklabel) + .property("flg_extend", &MjvFigure::flg_extend, &MjvFigure::set_flg_extend, reference()) + .property("flg_barplot", &MjvFigure::flg_barplot, &MjvFigure::set_flg_barplot, reference()) + .property("flg_selection", &MjvFigure::flg_selection, &MjvFigure::set_flg_selection, reference()) + .property("flg_symmetric", &MjvFigure::flg_symmetric, &MjvFigure::set_flg_symmetric, reference()) + .property("linewidth", &MjvFigure::linewidth, &MjvFigure::set_linewidth, reference()) + .property("gridwidth", &MjvFigure::gridwidth, &MjvFigure::set_gridwidth, reference()) + .property("gridsize", &MjvFigure::gridsize) + .property("gridrgb", &MjvFigure::gridrgb) + .property("figurergba", &MjvFigure::figurergba) + .property("panergba", &MjvFigure::panergba) + .property("legendrgba", &MjvFigure::legendrgba) + .property("textrgb", &MjvFigure::textrgb) + .property("linergb", &MjvFigure::linergb) + .property("range", &MjvFigure::range) + .property("xformat", &MjvFigure::xformat) + .property("yformat", &MjvFigure::yformat) + .property("minwidth", &MjvFigure::minwidth) + .property("title", &MjvFigure::title) + .property("xlabel", &MjvFigure::xlabel) + .property("linename", &MjvFigure::linename) + .property("legendoffset", &MjvFigure::legendoffset, &MjvFigure::set_legendoffset, reference()) + .property("subplot", &MjvFigure::subplot, &MjvFigure::set_subplot, reference()) + .property("highlight", &MjvFigure::highlight) + .property("highlightid", &MjvFigure::highlightid, &MjvFigure::set_highlightid, reference()) + .property("selection", &MjvFigure::selection, &MjvFigure::set_selection, reference()) + .property("linepnt", &MjvFigure::linepnt) + .property("linedata", &MjvFigure::linedata) + .property("xaxispixel", &MjvFigure::xaxispixel) + .property("yaxispixel", &MjvFigure::yaxispixel) + .property("xaxisdata", &MjvFigure::xaxisdata) + .property("yaxisdata", &MjvFigure::yaxisdata) + ; emscripten::class_("MjvGLCamera") .constructor<>() .function("copy", &MjvGLCamera::copy, take_ownership()) @@ -9496,7 +9604,7 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { ; emscripten::class_("MjvGeom") .constructor<>() - .function("copy", &MjvGLCamera::copy, take_ownership()) + .function("copy", &MjvGeom::copy, take_ownership()) .property("type", &MjvGeom::type, &MjvGeom::set_type, reference()) .property("dataid", &MjvGeom::dataid, &MjvGeom::set_dataid, reference()) .property("objtype", &MjvGeom::objtype, &MjvGeom::set_objtype, reference()) @@ -9554,123 +9662,21 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("bvh_depth", &MjvOption::bvh_depth, &MjvOption::set_bvh_depth, reference()) .property("flex_layer", &MjvOption::flex_layer, &MjvOption::set_flex_layer, reference()) ; - - emscripten::class_("MjvScene") + emscripten::class_("MjvPerturb") .constructor<>() - .constructor() - .property("maxgeom", &MjvScene::maxgeom, &MjvScene::set_maxgeom, reference()) - .property("ngeom", &MjvScene::ngeom, &MjvScene::set_ngeom, reference()) - .property("geoms", &MjvScene::geoms) - .property("geomorder", &MjvScene::geomorder) - .property("nflex", &MjvScene::nflex, &MjvScene::set_nflex, reference()) - .property("flexedgeadr", &MjvScene::flexedgeadr) - .property("flexedgenum", &MjvScene::flexedgenum) - .property("flexvertadr", &MjvScene::flexvertadr) - .property("flexvertnum", &MjvScene::flexvertnum) - .property("flexfaceadr", &MjvScene::flexfaceadr) - .property("flexfacenum", &MjvScene::flexfacenum) - .property("flexfaceused", &MjvScene::flexfaceused) - .property("flexedge", &MjvScene::flexedge) - .property("flexvert", &MjvScene::flexvert) - .property("flexface", &MjvScene::flexface) - .property("flexnormal", &MjvScene::flexnormal) - .property("flextexcoord", &MjvScene::flextexcoord) - .property("flexvertopt", &MjvScene::flexvertopt, &MjvScene::set_flexvertopt, reference()) - .property("flexedgeopt", &MjvScene::flexedgeopt, &MjvScene::set_flexedgeopt, reference()) - .property("flexfaceopt", &MjvScene::flexfaceopt, &MjvScene::set_flexfaceopt, reference()) - .property("flexskinopt", &MjvScene::flexskinopt, &MjvScene::set_flexskinopt, reference()) - .property("nskin", &MjvScene::nskin, &MjvScene::set_nskin, reference()) - .property("skinfacenum", &MjvScene::skinfacenum) - .property("skinvertadr", &MjvScene::skinvertadr) - .property("skinvertnum", &MjvScene::skinvertnum) - .property("skinvert", &MjvScene::skinvert) - .property("skinnormal", &MjvScene::skinnormal) - .property("nlight", &MjvScene::nlight, &MjvScene::set_nlight, reference()) - .property("lights", &MjvScene::lights) - .property("camera", &MjvScene::camera) - .property("enabletransform", &MjvScene::enabletransform, &MjvScene::set_enabletransform, reference()) - .property("translate", &MjvScene::translate) - .property("rotate", &MjvScene::rotate) - .property("scale", &MjvScene::scale, &MjvScene::set_scale, reference()) - .property("stereo", &MjvScene::stereo, &MjvScene::set_stereo, reference()) - .property("flags", &MjvScene::flags) - .property("framewidth", &MjvScene::framewidth, &MjvScene::set_framewidth, reference()) - .property("framergb", &MjvScene::framergb) - .property("status", &MjvScene::status, &MjvScene::set_status, reference()) + .function("copy", &MjvPerturb::copy, take_ownership()) + .property("select", &MjvPerturb::select, &MjvPerturb::set_select, reference()) + .property("flexselect", &MjvPerturb::flexselect, &MjvPerturb::set_flexselect, reference()) + .property("skinselect", &MjvPerturb::skinselect, &MjvPerturb::set_skinselect, reference()) + .property("active", &MjvPerturb::active, &MjvPerturb::set_active, reference()) + .property("active2", &MjvPerturb::active2, &MjvPerturb::set_active2, reference()) + .property("refpos", &MjvPerturb::refpos) + .property("refquat", &MjvPerturb::refquat) + .property("refselpos", &MjvPerturb::refselpos) + .property("localpos", &MjvPerturb::localpos) + .property("localmass", &MjvPerturb::localmass, &MjvPerturb::set_localmass, reference()) + .property("scale", &MjvPerturb::scale, &MjvPerturb::set_scale, reference()) ; - - emscripten::class_("MjvFigure") - .constructor<>() - .function("copy", &MjvFigure::copy, take_ownership()) - .property("flg_legend", &MjvFigure::flg_legend, &MjvFigure::set_flg_legend, reference()) - .property("flg_ticklabel", &MjvFigure::flg_ticklabel) - .property("flg_extend", &MjvFigure::flg_extend, &MjvFigure::set_flg_extend, reference()) - .property("flg_barplot", &MjvFigure::flg_barplot, &MjvFigure::set_flg_barplot, reference()) - .property("flg_selection", &MjvFigure::flg_selection, &MjvFigure::set_flg_selection, reference()) - .property("flg_symmetric", &MjvFigure::flg_symmetric, &MjvFigure::set_flg_symmetric, reference()) - .property("linewidth", &MjvFigure::linewidth, &MjvFigure::set_linewidth, reference()) - .property("gridwidth", &MjvFigure::gridwidth, &MjvFigure::set_gridwidth, reference()) - .property("gridsize", &MjvFigure::gridsize) - .property("gridrgb", &MjvFigure::gridrgb) - .property("figurergba", &MjvFigure::figurergba) - .property("panergba", &MjvFigure::panergba) - .property("legendrgba", &MjvFigure::legendrgba) - .property("textrgb", &MjvFigure::textrgb) - .property("linergb", &MjvFigure::linergb) - .property("range", &MjvFigure::range) - .property("xformat", &MjvFigure::xformat) - .property("yformat", &MjvFigure::yformat) - .property("minwidth", &MjvFigure::minwidth) - .property("title", &MjvFigure::title) - .property("xlabel", &MjvFigure::xlabel) - .property("linename", &MjvFigure::linename) - .property("legendoffset", &MjvFigure::legendoffset, &MjvFigure::set_legendoffset, reference()) - .property("subplot", &MjvFigure::subplot, &MjvFigure::set_subplot, reference()) - .property("highlight", &MjvFigure::highlight) - .property("highlightid", &MjvFigure::highlightid, &MjvFigure::set_highlightid, reference()) - .property("selection", &MjvFigure::selection, &MjvFigure::set_selection, reference()) - .property("linepnt", &MjvFigure::linepnt) - .property("linedata", &MjvFigure::linedata) - .property("xaxispixel", &MjvFigure::xaxispixel) - .property("yaxispixel", &MjvFigure::yaxispixel) - .property("xaxisdata", &MjvFigure::xaxisdata) - .property("yaxisdata", &MjvFigure::yaxisdata) - ; - - emscripten::class_("MjSpec") - .constructor() - .property("element", &MjSpec::element) - .property("modelname", &MjSpec::modelname, &MjSpec::set_modelname, reference()) - .property("compiler", &MjSpec::compiler) - .property("strippath", &MjSpec::strippath, &MjSpec::set_strippath, reference()) - .property("option", &MjSpec::option) - .property("visual", &MjSpec::visual) - .property("stat", &MjSpec::stat) - .property("memory", &MjSpec::memory, &MjSpec::set_memory, reference()) - .property("nemax", &MjSpec::nemax, &MjSpec::set_nemax, reference()) - .property("nuserdata", &MjSpec::nuserdata, &MjSpec::set_nuserdata, reference()) - .property("nuser_body", &MjSpec::nuser_body, &MjSpec::set_nuser_body, reference()) - .property("nuser_jnt", &MjSpec::nuser_jnt, &MjSpec::set_nuser_jnt, reference()) - .property("nuser_geom", &MjSpec::nuser_geom, &MjSpec::set_nuser_geom, reference()) - .property("nuser_site", &MjSpec::nuser_site, &MjSpec::set_nuser_site, reference()) - .property("nuser_cam", &MjSpec::nuser_cam, &MjSpec::set_nuser_cam, reference()) - .property("nuser_tendon", &MjSpec::nuser_tendon, &MjSpec::set_nuser_tendon, reference()) - .property("nuser_actuator", &MjSpec::nuser_actuator, &MjSpec::set_nuser_actuator, reference()) - .property("nuser_sensor", &MjSpec::nuser_sensor, &MjSpec::set_nuser_sensor, reference()) - .property("nkey", &MjSpec::nkey, &MjSpec::set_nkey, reference()) - .property("njmax", &MjSpec::njmax, &MjSpec::set_njmax, reference()) - .property("nconmax", &MjSpec::nconmax, &MjSpec::set_nconmax, reference()) - .property("nstack", &MjSpec::nstack, &MjSpec::set_nstack, reference()) - .property("comment", &MjSpec::comment, &MjSpec::set_comment, reference()) - .property("modelfiledir", &MjSpec::modelfiledir, &MjSpec::set_modelfiledir, reference()) - .property("hasImplicitPluginElem", &MjSpec::hasImplicitPluginElem, &MjSpec::set_hasImplicitPluginElem, reference()) - ; - - emscripten::class_("MjsElement") - .property("elemtype", &MjsElement::elemtype, &MjsElement::set_elemtype, reference()) - .property("signature", &MjsElement::signature, &MjsElement::set_signature, reference()) - ; - emscripten::class_("MjsCompiler") .property("autolimits", &MjsCompiler::autolimits, &MjsCompiler::set_autolimits, reference()) .property("boundmass", &MjsCompiler::boundmass, &MjsCompiler::set_boundmass, reference()) @@ -9691,164 +9697,24 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("meshdir", &MjsCompiler::meshdir, &MjsCompiler::set_meshdir, reference()) .property("texturedir", &MjsCompiler::texturedir, &MjsCompiler::set_texturedir, reference()) ; - - emscripten::class_("MjsOrientation") - .property("type", &MjsOrientation::type, &MjsOrientation::set_type, reference()) - .property("axisangle", &MjsOrientation::axisangle) - .property("xyaxes", &MjsOrientation::xyaxes) - .property("zaxis", &MjsOrientation::zaxis) - .property("euler", &MjsOrientation::euler) + emscripten::class_("MjsEquality") + .property("element", &MjsEquality::element, reference()) + .property("type", &MjsEquality::type, &MjsEquality::set_type, reference()) + .property("data", &MjsEquality::data) + .property("active", &MjsEquality::active, &MjsEquality::set_active, reference()) + .property("name1", &MjsEquality::name1, &MjsEquality::set_name1, reference()) + .property("name2", &MjsEquality::name2, &MjsEquality::set_name2, reference()) + .property("objtype", &MjsEquality::objtype, &MjsEquality::set_objtype, reference()) + .property("solref", &MjsEquality::solref) + .property("solimp", &MjsEquality::solimp) + .property("info", &MjsEquality::info, &MjsEquality::set_info, reference()) ; - - emscripten::class_("MjsBody") - .property("element", &MjsBody::element, reference()) - .property("childclass", &MjsBody::childclass, &MjsBody::set_childclass, reference()) - .property("pos", &MjsBody::pos) - .property("quat", &MjsBody::quat) - .property("alt", &MjsBody::alt, reference()) - .property("mass", &MjsBody::mass, &MjsBody::set_mass, reference()) - .property("ipos", &MjsBody::ipos) - .property("iquat", &MjsBody::iquat) - .property("inertia", &MjsBody::inertia) - .property("ialt", &MjsBody::ialt, reference()) - .property("fullinertia", &MjsBody::fullinertia) - .property("mocap", &MjsBody::mocap, &MjsBody::set_mocap, reference()) - .property("gravcomp", &MjsBody::gravcomp, &MjsBody::set_gravcomp, reference()) - .property("userdata", &MjsBody::userdata, reference()) - .property("explicitinertial", &MjsBody::explicitinertial, &MjsBody::set_explicitinertial, reference()) - .property("plugin", &MjsBody::plugin, reference()) - .property("info", &MjsBody::info, &MjsBody::set_info, reference()) + emscripten::class_("MjsExclude") + .property("element", &MjsExclude::element, reference()) + .property("bodyname1", &MjsExclude::bodyname1, &MjsExclude::set_bodyname1, reference()) + .property("bodyname2", &MjsExclude::bodyname2, &MjsExclude::set_bodyname2, reference()) + .property("info", &MjsExclude::info, &MjsExclude::set_info, reference()) ; - - emscripten::class_("MjsGeom") - .property("element", &MjsGeom::element, reference()) - .property("type", &MjsGeom::type, &MjsGeom::set_type, reference()) - .property("pos", &MjsGeom::pos) - .property("quat", &MjsGeom::quat) - .property("alt", &MjsGeom::alt, reference()) - .property("fromto", &MjsGeom::fromto) - .property("size", &MjsGeom::size) - .property("contype", &MjsGeom::contype, &MjsGeom::set_contype, reference()) - .property("conaffinity", &MjsGeom::conaffinity, &MjsGeom::set_conaffinity, reference()) - .property("condim", &MjsGeom::condim, &MjsGeom::set_condim, reference()) - .property("priority", &MjsGeom::priority, &MjsGeom::set_priority, reference()) - .property("friction", &MjsGeom::friction) - .property("solmix", &MjsGeom::solmix, &MjsGeom::set_solmix, reference()) - .property("solref", &MjsGeom::solref) - .property("solimp", &MjsGeom::solimp) - .property("margin", &MjsGeom::margin, &MjsGeom::set_margin, reference()) - .property("gap", &MjsGeom::gap, &MjsGeom::set_gap, reference()) - .property("mass", &MjsGeom::mass, &MjsGeom::set_mass, reference()) - .property("density", &MjsGeom::density, &MjsGeom::set_density, reference()) - .property("typeinertia", &MjsGeom::typeinertia, &MjsGeom::set_typeinertia, reference()) - .property("fluid_ellipsoid", &MjsGeom::fluid_ellipsoid, &MjsGeom::set_fluid_ellipsoid, reference()) - .property("fluid_coefs", &MjsGeom::fluid_coefs) - .property("material", &MjsGeom::material, &MjsGeom::set_material, reference()) - .property("rgba", &MjsGeom::rgba) - .property("group", &MjsGeom::group, &MjsGeom::set_group, reference()) - .property("hfieldname", &MjsGeom::hfieldname, &MjsGeom::set_hfieldname, reference()) - .property("meshname", &MjsGeom::meshname, &MjsGeom::set_meshname, reference()) - .property("fitscale", &MjsGeom::fitscale, &MjsGeom::set_fitscale, reference()) - .property("userdata", &MjsGeom::userdata, reference()) - .property("plugin", &MjsGeom::plugin, reference()) - .property("info", &MjsGeom::info, &MjsGeom::set_info, reference()) - ; - - emscripten::class_("MjsFrame") - .property("element", &MjsFrame::element, reference()) - .property("childclass", &MjsFrame::childclass, &MjsFrame::set_childclass, reference()) - .property("pos", &MjsFrame::pos) - .property("quat", &MjsFrame::quat) - .property("alt", &MjsFrame::alt, reference()) - .property("info", &MjsFrame::info, &MjsFrame::set_info, reference()) - ; - - emscripten::class_("MjsJoint") - .property("element", &MjsJoint::element, reference()) - .property("type", &MjsJoint::type, &MjsJoint::set_type, reference()) - .property("pos", &MjsJoint::pos) - .property("axis", &MjsJoint::axis) - .property("ref", &MjsJoint::ref, &MjsJoint::set_ref, reference()) - .property("align", &MjsJoint::align, &MjsJoint::set_align, reference()) - .property("stiffness", &MjsJoint::stiffness, &MjsJoint::set_stiffness, reference()) - .property("springref", &MjsJoint::springref, &MjsJoint::set_springref, reference()) - .property("springdamper", &MjsJoint::springdamper) - .property("limited", &MjsJoint::limited, &MjsJoint::set_limited, reference()) - .property("range", &MjsJoint::range) - .property("margin", &MjsJoint::margin, &MjsJoint::set_margin, reference()) - .property("solref_limit", &MjsJoint::solref_limit) - .property("solimp_limit", &MjsJoint::solimp_limit) - .property("actfrclimited", &MjsJoint::actfrclimited, &MjsJoint::set_actfrclimited, reference()) - .property("actfrcrange", &MjsJoint::actfrcrange) - .property("armature", &MjsJoint::armature, &MjsJoint::set_armature, reference()) - .property("damping", &MjsJoint::damping, &MjsJoint::set_damping, reference()) - .property("frictionloss", &MjsJoint::frictionloss, &MjsJoint::set_frictionloss, reference()) - .property("solref_friction", &MjsJoint::solref_friction) - .property("solimp_friction", &MjsJoint::solimp_friction) - .property("group", &MjsJoint::group, &MjsJoint::set_group, reference()) - .property("actgravcomp", &MjsJoint::actgravcomp, &MjsJoint::set_actgravcomp, reference()) - .property("userdata", &MjsJoint::userdata, reference()) - .property("info", &MjsJoint::info, &MjsJoint::set_info, reference()) - ; - - emscripten::class_("MjsSite") - .property("element", &MjsSite::element, reference()) - .property("pos", &MjsSite::pos) - .property("quat", &MjsSite::quat) - .property("alt", &MjsSite::alt, reference()) - .property("fromto", &MjsSite::fromto) - .property("size", &MjsSite::size) - .property("type", &MjsSite::type, &MjsSite::set_type, reference()) - .property("material", &MjsSite::material, &MjsSite::set_material, reference()) - .property("group", &MjsSite::group, &MjsSite::set_group, reference()) - .property("rgba", &MjsSite::rgba) - .property("userdata", &MjsSite::userdata, reference()) - .property("info", &MjsSite::info, &MjsSite::set_info, reference()) - ; - - emscripten::class_("MjsCamera") - .property("element", &MjsCamera::element, reference()) - .property("pos", &MjsCamera::pos) - .property("quat", &MjsCamera::quat) - .property("alt", &MjsCamera::alt, reference()) - .property("mode", &MjsCamera::mode, &MjsCamera::set_mode, reference()) - .property("targetbody", &MjsCamera::targetbody, &MjsCamera::set_targetbody, reference()) - .property("orthographic", &MjsCamera::orthographic, &MjsCamera::set_orthographic, reference()) - .property("fovy", &MjsCamera::fovy, &MjsCamera::set_fovy, reference()) - .property("ipd", &MjsCamera::ipd, &MjsCamera::set_ipd, reference()) - .property("intrinsic", &MjsCamera::intrinsic) - .property("sensor_size", &MjsCamera::sensor_size) - .property("resolution", &MjsCamera::resolution) - .property("focal_length", &MjsCamera::focal_length) - .property("focal_pixel", &MjsCamera::focal_pixel) - .property("principal_length", &MjsCamera::principal_length) - .property("principal_pixel", &MjsCamera::principal_pixel) - .property("userdata", &MjsCamera::userdata, reference()) - .property("info", &MjsCamera::info, &MjsCamera::set_info, reference()) - ; - - emscripten::class_("MjsLight") - .property("element", &MjsLight::element, reference()) - .property("pos", &MjsLight::pos) - .property("dir", &MjsLight::dir) - .property("mode", &MjsLight::mode, &MjsLight::set_mode, reference()) - .property("targetbody", &MjsLight::targetbody, &MjsLight::set_targetbody, reference()) - .property("active", &MjsLight::active, &MjsLight::set_active, reference()) - .property("type", &MjsLight::type, &MjsLight::set_type, reference()) - .property("texture", &MjsLight::texture, &MjsLight::set_texture, reference()) - .property("castshadow", &MjsLight::castshadow, &MjsLight::set_castshadow, reference()) - .property("bulbradius", &MjsLight::bulbradius, &MjsLight::set_bulbradius, reference()) - .property("intensity", &MjsLight::intensity, &MjsLight::set_intensity, reference()) - .property("range", &MjsLight::range, &MjsLight::set_range, reference()) - .property("attenuation", &MjsLight::attenuation) - .property("cutoff", &MjsLight::cutoff, &MjsLight::set_cutoff, reference()) - .property("exponent", &MjsLight::exponent, &MjsLight::set_exponent, reference()) - .property("ambient", &MjsLight::ambient) - .property("diffuse", &MjsLight::diffuse) - .property("specular", &MjsLight::specular) - .property("info", &MjsLight::info, &MjsLight::set_info, reference()) - ; - emscripten::class_("MjsFlex") .property("element", &MjsFlex::element, reference()) .property("contype", &MjsFlex::contype, &MjsFlex::set_contype, reference()) @@ -9888,29 +9754,6 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("elemtexcoord", &MjsFlex::elemtexcoord, reference()) .property("info", &MjsFlex::info, &MjsFlex::set_info, reference()) ; - - emscripten::class_("MjsMesh") - .property("element", &MjsMesh::element, reference()) - .property("content_type", &MjsMesh::content_type, &MjsMesh::set_content_type, reference()) - .property("file", &MjsMesh::file, &MjsMesh::set_file, reference()) - .property("refpos", &MjsMesh::refpos) - .property("refquat", &MjsMesh::refquat) - .property("scale", &MjsMesh::scale) - .property("inertia", &MjsMesh::inertia, &MjsMesh::set_inertia, reference()) - .property("smoothnormal", &MjsMesh::smoothnormal, &MjsMesh::set_smoothnormal, reference()) - .property("needsdf", &MjsMesh::needsdf, &MjsMesh::set_needsdf, reference()) - .property("maxhullvert", &MjsMesh::maxhullvert, &MjsMesh::set_maxhullvert, reference()) - .property("uservert", &MjsMesh::uservert, reference()) - .property("usernormal", &MjsMesh::usernormal, reference()) - .property("usertexcoord", &MjsMesh::usertexcoord, reference()) - .property("userface", &MjsMesh::userface, reference()) - .property("userfacenormal", &MjsMesh::userfacenormal, reference()) - .property("userfacetexcoord", &MjsMesh::userfacetexcoord, reference()) - .property("plugin", &MjsMesh::plugin, reference()) - .property("material", &MjsMesh::material, &MjsMesh::set_material, reference()) - .property("info", &MjsMesh::info, &MjsMesh::set_info, reference()) - ; - emscripten::class_("MjsHField") .property("element", &MjsHField::element, reference()) .property("content_type", &MjsHField::content_type, &MjsHField::set_content_type, reference()) @@ -9921,7 +9764,105 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("userdata", &MjsHField::userdata, reference()) .property("info", &MjsHField::info, &MjsHField::set_info, reference()) ; - + emscripten::class_("MjsJoint") + .property("element", &MjsJoint::element, reference()) + .property("type", &MjsJoint::type, &MjsJoint::set_type, reference()) + .property("pos", &MjsJoint::pos) + .property("axis", &MjsJoint::axis) + .property("ref", &MjsJoint::ref, &MjsJoint::set_ref, reference()) + .property("align", &MjsJoint::align, &MjsJoint::set_align, reference()) + .property("stiffness", &MjsJoint::stiffness, &MjsJoint::set_stiffness, reference()) + .property("springref", &MjsJoint::springref, &MjsJoint::set_springref, reference()) + .property("springdamper", &MjsJoint::springdamper) + .property("limited", &MjsJoint::limited, &MjsJoint::set_limited, reference()) + .property("range", &MjsJoint::range) + .property("margin", &MjsJoint::margin, &MjsJoint::set_margin, reference()) + .property("solref_limit", &MjsJoint::solref_limit) + .property("solimp_limit", &MjsJoint::solimp_limit) + .property("actfrclimited", &MjsJoint::actfrclimited, &MjsJoint::set_actfrclimited, reference()) + .property("actfrcrange", &MjsJoint::actfrcrange) + .property("armature", &MjsJoint::armature, &MjsJoint::set_armature, reference()) + .property("damping", &MjsJoint::damping, &MjsJoint::set_damping, reference()) + .property("frictionloss", &MjsJoint::frictionloss, &MjsJoint::set_frictionloss, reference()) + .property("solref_friction", &MjsJoint::solref_friction) + .property("solimp_friction", &MjsJoint::solimp_friction) + .property("group", &MjsJoint::group, &MjsJoint::set_group, reference()) + .property("actgravcomp", &MjsJoint::actgravcomp, &MjsJoint::set_actgravcomp, reference()) + .property("userdata", &MjsJoint::userdata, reference()) + .property("info", &MjsJoint::info, &MjsJoint::set_info, reference()) + ; + emscripten::class_("MjsKey") + .property("element", &MjsKey::element, reference()) + .property("time", &MjsKey::time, &MjsKey::set_time, reference()) + .property("qpos", &MjsKey::qpos, reference()) + .property("qvel", &MjsKey::qvel, reference()) + .property("act", &MjsKey::act, reference()) + .property("mpos", &MjsKey::mpos, reference()) + .property("mquat", &MjsKey::mquat, reference()) + .property("ctrl", &MjsKey::ctrl, reference()) + .property("info", &MjsKey::info, &MjsKey::set_info, reference()) + ; + emscripten::class_("MjsLight") + .property("element", &MjsLight::element, reference()) + .property("pos", &MjsLight::pos) + .property("dir", &MjsLight::dir) + .property("mode", &MjsLight::mode, &MjsLight::set_mode, reference()) + .property("targetbody", &MjsLight::targetbody, &MjsLight::set_targetbody, reference()) + .property("active", &MjsLight::active, &MjsLight::set_active, reference()) + .property("type", &MjsLight::type, &MjsLight::set_type, reference()) + .property("texture", &MjsLight::texture, &MjsLight::set_texture, reference()) + .property("castshadow", &MjsLight::castshadow, &MjsLight::set_castshadow, reference()) + .property("bulbradius", &MjsLight::bulbradius, &MjsLight::set_bulbradius, reference()) + .property("intensity", &MjsLight::intensity, &MjsLight::set_intensity, reference()) + .property("range", &MjsLight::range, &MjsLight::set_range, reference()) + .property("attenuation", &MjsLight::attenuation) + .property("cutoff", &MjsLight::cutoff, &MjsLight::set_cutoff, reference()) + .property("exponent", &MjsLight::exponent, &MjsLight::set_exponent, reference()) + .property("ambient", &MjsLight::ambient) + .property("diffuse", &MjsLight::diffuse) + .property("specular", &MjsLight::specular) + .property("info", &MjsLight::info, &MjsLight::set_info, reference()) + ; + emscripten::class_("MjsMaterial") + .property("element", &MjsMaterial::element, reference()) + .property("textures", &MjsMaterial::textures, reference()) + .property("texuniform", &MjsMaterial::texuniform, &MjsMaterial::set_texuniform, reference()) + .property("texrepeat", &MjsMaterial::texrepeat) + .property("emission", &MjsMaterial::emission, &MjsMaterial::set_emission, reference()) + .property("specular", &MjsMaterial::specular, &MjsMaterial::set_specular, reference()) + .property("shininess", &MjsMaterial::shininess, &MjsMaterial::set_shininess, reference()) + .property("reflectance", &MjsMaterial::reflectance, &MjsMaterial::set_reflectance, reference()) + .property("metallic", &MjsMaterial::metallic, &MjsMaterial::set_metallic, reference()) + .property("roughness", &MjsMaterial::roughness, &MjsMaterial::set_roughness, reference()) + .property("rgba", &MjsMaterial::rgba) + .property("info", &MjsMaterial::info, &MjsMaterial::set_info, reference()) + ; + emscripten::class_("MjsNumeric") + .property("element", &MjsNumeric::element, reference()) + .property("data", &MjsNumeric::data, reference()) + .property("size", &MjsNumeric::size, &MjsNumeric::set_size, reference()) + .property("info", &MjsNumeric::info, &MjsNumeric::set_info, reference()) + ; + emscripten::class_("MjsPair") + .property("element", &MjsPair::element, reference()) + .property("geomname1", &MjsPair::geomname1, &MjsPair::set_geomname1, reference()) + .property("geomname2", &MjsPair::geomname2, &MjsPair::set_geomname2, reference()) + .property("condim", &MjsPair::condim, &MjsPair::set_condim, reference()) + .property("solref", &MjsPair::solref) + .property("solreffriction", &MjsPair::solreffriction) + .property("solimp", &MjsPair::solimp) + .property("margin", &MjsPair::margin, &MjsPair::set_margin, reference()) + .property("gap", &MjsPair::gap, &MjsPair::set_gap, reference()) + .property("friction", &MjsPair::friction) + .property("info", &MjsPair::info, &MjsPair::set_info, reference()) + ; + emscripten::class_("MjsPlugin") + .property("element", &MjsPlugin::element, reference()) + .property("name", &MjsPlugin::name, &MjsPlugin::set_name, reference()) + .property("plugin_name", &MjsPlugin::plugin_name, &MjsPlugin::set_plugin_name, reference()) + .property("active", &MjsPlugin::active, &MjsPlugin::set_active, reference()) + .property("info", &MjsPlugin::info, &MjsPlugin::set_info, reference()) + ; emscripten::class_("MjsSkin") .property("element", &MjsSkin::element, reference()) .property("file", &MjsSkin::file, &MjsSkin::set_file, reference()) @@ -9939,80 +9880,6 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("vertweight", &MjsSkin::vertweight, reference()) .property("info", &MjsSkin::info, &MjsSkin::set_info, reference()) ; - - emscripten::class_("MjsTexture") - .property("element", &MjsTexture::element, reference()) - .property("type", &MjsTexture::type, &MjsTexture::set_type, reference()) - .property("colorspace", &MjsTexture::colorspace, &MjsTexture::set_colorspace, reference()) - .property("builtin", &MjsTexture::builtin, &MjsTexture::set_builtin, reference()) - .property("mark", &MjsTexture::mark, &MjsTexture::set_mark, reference()) - .property("rgb1", &MjsTexture::rgb1) - .property("rgb2", &MjsTexture::rgb2) - .property("markrgb", &MjsTexture::markrgb) - .property("random", &MjsTexture::random, &MjsTexture::set_random, reference()) - .property("height", &MjsTexture::height, &MjsTexture::set_height, reference()) - .property("width", &MjsTexture::width, &MjsTexture::set_width, reference()) - .property("nchannel", &MjsTexture::nchannel, &MjsTexture::set_nchannel, reference()) - .property("content_type", &MjsTexture::content_type, &MjsTexture::set_content_type, reference()) - .property("file", &MjsTexture::file, &MjsTexture::set_file, reference()) - .property("gridsize", &MjsTexture::gridsize) - .property("gridlayout", &MjsTexture::gridlayout) - .property("cubefiles", &MjsTexture::cubefiles, reference()) - .property("data", &MjsTexture::data, reference()) - .property("hflip", &MjsTexture::hflip, &MjsTexture::set_hflip, reference()) - .property("vflip", &MjsTexture::vflip, &MjsTexture::set_vflip, reference()) - .property("info", &MjsTexture::info, &MjsTexture::set_info, reference()) - ; - - emscripten::class_("MjsMaterial") - .property("element", &MjsMaterial::element, reference()) - .property("textures", &MjsMaterial::textures, reference()) - .property("texuniform", &MjsMaterial::texuniform, &MjsMaterial::set_texuniform, reference()) - .property("texrepeat", &MjsMaterial::texrepeat) - .property("emission", &MjsMaterial::emission, &MjsMaterial::set_emission, reference()) - .property("specular", &MjsMaterial::specular, &MjsMaterial::set_specular, reference()) - .property("shininess", &MjsMaterial::shininess, &MjsMaterial::set_shininess, reference()) - .property("reflectance", &MjsMaterial::reflectance, &MjsMaterial::set_reflectance, reference()) - .property("metallic", &MjsMaterial::metallic, &MjsMaterial::set_metallic, reference()) - .property("roughness", &MjsMaterial::roughness, &MjsMaterial::set_roughness, reference()) - .property("rgba", &MjsMaterial::rgba) - .property("info", &MjsMaterial::info, &MjsMaterial::set_info, reference()) - ; - - emscripten::class_("MjsPair") - .property("element", &MjsPair::element, reference()) - .property("geomname1", &MjsPair::geomname1, &MjsPair::set_geomname1, reference()) - .property("geomname2", &MjsPair::geomname2, &MjsPair::set_geomname2, reference()) - .property("condim", &MjsPair::condim, &MjsPair::set_condim, reference()) - .property("solref", &MjsPair::solref) - .property("solreffriction", &MjsPair::solreffriction) - .property("solimp", &MjsPair::solimp) - .property("margin", &MjsPair::margin, &MjsPair::set_margin, reference()) - .property("gap", &MjsPair::gap, &MjsPair::set_gap, reference()) - .property("friction", &MjsPair::friction) - .property("info", &MjsPair::info, &MjsPair::set_info, reference()) - ; - - emscripten::class_("MjsExclude") - .property("element", &MjsExclude::element, reference()) - .property("bodyname1", &MjsExclude::bodyname1, &MjsExclude::set_bodyname1, reference()) - .property("bodyname2", &MjsExclude::bodyname2, &MjsExclude::set_bodyname2, reference()) - .property("info", &MjsExclude::info, &MjsExclude::set_info, reference()) - ; - - emscripten::class_("MjsEquality") - .property("element", &MjsEquality::element, reference()) - .property("type", &MjsEquality::type, &MjsEquality::set_type, reference()) - .property("data", &MjsEquality::data) - .property("active", &MjsEquality::active, &MjsEquality::set_active, reference()) - .property("name1", &MjsEquality::name1, &MjsEquality::set_name1, reference()) - .property("name2", &MjsEquality::name2, &MjsEquality::set_name2, reference()) - .property("objtype", &MjsEquality::objtype, &MjsEquality::set_objtype, reference()) - .property("solref", &MjsEquality::solref) - .property("solimp", &MjsEquality::solimp) - .property("info", &MjsEquality::info, &MjsEquality::set_info, reference()) - ; - emscripten::class_("MjsTendon") .property("element", &MjsTendon::element, reference()) .property("stiffness", &MjsTendon::stiffness, &MjsTendon::set_stiffness, reference()) @@ -10036,13 +9903,88 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("userdata", &MjsTendon::userdata, reference()) .property("info", &MjsTendon::info, &MjsTendon::set_info, reference()) ; - + emscripten::class_("MjsText") + .property("element", &MjsText::element, reference()) + .property("data", &MjsText::data, &MjsText::set_data, reference()) + .property("info", &MjsText::info, &MjsText::set_info, reference()) + ; + emscripten::class_("MjsTexture") + .property("element", &MjsTexture::element, reference()) + .property("type", &MjsTexture::type, &MjsTexture::set_type, reference()) + .property("colorspace", &MjsTexture::colorspace, &MjsTexture::set_colorspace, reference()) + .property("builtin", &MjsTexture::builtin, &MjsTexture::set_builtin, reference()) + .property("mark", &MjsTexture::mark, &MjsTexture::set_mark, reference()) + .property("rgb1", &MjsTexture::rgb1) + .property("rgb2", &MjsTexture::rgb2) + .property("markrgb", &MjsTexture::markrgb) + .property("random", &MjsTexture::random, &MjsTexture::set_random, reference()) + .property("height", &MjsTexture::height, &MjsTexture::set_height, reference()) + .property("width", &MjsTexture::width, &MjsTexture::set_width, reference()) + .property("nchannel", &MjsTexture::nchannel, &MjsTexture::set_nchannel, reference()) + .property("content_type", &MjsTexture::content_type, &MjsTexture::set_content_type, reference()) + .property("file", &MjsTexture::file, &MjsTexture::set_file, reference()) + .property("gridsize", &MjsTexture::gridsize) + .property("gridlayout", &MjsTexture::gridlayout) + .property("cubefiles", &MjsTexture::cubefiles, reference()) + .property("data", &MjsTexture::data, reference()) + .property("hflip", &MjsTexture::hflip, &MjsTexture::set_hflip, reference()) + .property("vflip", &MjsTexture::vflip, &MjsTexture::set_vflip, reference()) + .property("info", &MjsTexture::info, &MjsTexture::set_info, reference()) + ; + emscripten::class_("MjsTuple") + .property("element", &MjsTuple::element, reference()) + .property("objtype", &MjsTuple::objtype, reference()) + .property("objname", &MjsTuple::objname, reference()) + .property("objprm", &MjsTuple::objprm, reference()) + .property("info", &MjsTuple::info, &MjsTuple::set_info, reference()) + ; emscripten::class_("MjsWrap") .property("element", &MjsWrap::element, reference()) .property("type", &MjsWrap::type, &MjsWrap::set_type, reference()) .property("info", &MjsWrap::info, &MjsWrap::set_info, reference()) ; - + emscripten::class_("MjsCamera") + .property("element", &MjsCamera::element, reference()) + .property("pos", &MjsCamera::pos) + .property("quat", &MjsCamera::quat) + .property("alt", &MjsCamera::alt, reference()) + .property("mode", &MjsCamera::mode, &MjsCamera::set_mode, reference()) + .property("targetbody", &MjsCamera::targetbody, &MjsCamera::set_targetbody, reference()) + .property("orthographic", &MjsCamera::orthographic, &MjsCamera::set_orthographic, reference()) + .property("fovy", &MjsCamera::fovy, &MjsCamera::set_fovy, reference()) + .property("ipd", &MjsCamera::ipd, &MjsCamera::set_ipd, reference()) + .property("intrinsic", &MjsCamera::intrinsic) + .property("sensor_size", &MjsCamera::sensor_size) + .property("resolution", &MjsCamera::resolution) + .property("focal_length", &MjsCamera::focal_length) + .property("focal_pixel", &MjsCamera::focal_pixel) + .property("principal_length", &MjsCamera::principal_length) + .property("principal_pixel", &MjsCamera::principal_pixel) + .property("userdata", &MjsCamera::userdata, reference()) + .property("info", &MjsCamera::info, &MjsCamera::set_info, reference()) + ; + emscripten::class_("MjsFrame") + .property("element", &MjsFrame::element, reference()) + .property("childclass", &MjsFrame::childclass, &MjsFrame::set_childclass, reference()) + .property("pos", &MjsFrame::pos) + .property("quat", &MjsFrame::quat) + .property("alt", &MjsFrame::alt, reference()) + .property("info", &MjsFrame::info, &MjsFrame::set_info, reference()) + ; + emscripten::class_("MjsSite") + .property("element", &MjsSite::element, reference()) + .property("pos", &MjsSite::pos) + .property("quat", &MjsSite::quat) + .property("alt", &MjsSite::alt, reference()) + .property("fromto", &MjsSite::fromto) + .property("size", &MjsSite::size) + .property("type", &MjsSite::type, &MjsSite::set_type, reference()) + .property("material", &MjsSite::material, &MjsSite::set_material, reference()) + .property("group", &MjsSite::group, &MjsSite::set_group, reference()) + .property("rgba", &MjsSite::rgba) + .property("userdata", &MjsSite::userdata, reference()) + .property("info", &MjsSite::info, &MjsSite::set_info, reference()) + ; emscripten::class_("MjsActuator") .property("element", &MjsActuator::element, reference()) .property("gaintype", &MjsActuator::gaintype, &MjsActuator::set_gaintype, reference()) @@ -10072,7 +10014,79 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("plugin", &MjsActuator::plugin, reference()) .property("info", &MjsActuator::info, &MjsActuator::set_info, reference()) ; - + emscripten::class_("MjsBody") + .property("element", &MjsBody::element, reference()) + .property("childclass", &MjsBody::childclass, &MjsBody::set_childclass, reference()) + .property("pos", &MjsBody::pos) + .property("quat", &MjsBody::quat) + .property("alt", &MjsBody::alt, reference()) + .property("mass", &MjsBody::mass, &MjsBody::set_mass, reference()) + .property("ipos", &MjsBody::ipos) + .property("iquat", &MjsBody::iquat) + .property("inertia", &MjsBody::inertia) + .property("ialt", &MjsBody::ialt, reference()) + .property("fullinertia", &MjsBody::fullinertia) + .property("mocap", &MjsBody::mocap, &MjsBody::set_mocap, reference()) + .property("gravcomp", &MjsBody::gravcomp, &MjsBody::set_gravcomp, reference()) + .property("userdata", &MjsBody::userdata, reference()) + .property("explicitinertial", &MjsBody::explicitinertial, &MjsBody::set_explicitinertial, reference()) + .property("plugin", &MjsBody::plugin, reference()) + .property("info", &MjsBody::info, &MjsBody::set_info, reference()) + ; + emscripten::class_("MjsGeom") + .property("element", &MjsGeom::element, reference()) + .property("type", &MjsGeom::type, &MjsGeom::set_type, reference()) + .property("pos", &MjsGeom::pos) + .property("quat", &MjsGeom::quat) + .property("alt", &MjsGeom::alt, reference()) + .property("fromto", &MjsGeom::fromto) + .property("size", &MjsGeom::size) + .property("contype", &MjsGeom::contype, &MjsGeom::set_contype, reference()) + .property("conaffinity", &MjsGeom::conaffinity, &MjsGeom::set_conaffinity, reference()) + .property("condim", &MjsGeom::condim, &MjsGeom::set_condim, reference()) + .property("priority", &MjsGeom::priority, &MjsGeom::set_priority, reference()) + .property("friction", &MjsGeom::friction) + .property("solmix", &MjsGeom::solmix, &MjsGeom::set_solmix, reference()) + .property("solref", &MjsGeom::solref) + .property("solimp", &MjsGeom::solimp) + .property("margin", &MjsGeom::margin, &MjsGeom::set_margin, reference()) + .property("gap", &MjsGeom::gap, &MjsGeom::set_gap, reference()) + .property("mass", &MjsGeom::mass, &MjsGeom::set_mass, reference()) + .property("density", &MjsGeom::density, &MjsGeom::set_density, reference()) + .property("typeinertia", &MjsGeom::typeinertia, &MjsGeom::set_typeinertia, reference()) + .property("fluid_ellipsoid", &MjsGeom::fluid_ellipsoid, &MjsGeom::set_fluid_ellipsoid, reference()) + .property("fluid_coefs", &MjsGeom::fluid_coefs) + .property("material", &MjsGeom::material, &MjsGeom::set_material, reference()) + .property("rgba", &MjsGeom::rgba) + .property("group", &MjsGeom::group, &MjsGeom::set_group, reference()) + .property("hfieldname", &MjsGeom::hfieldname, &MjsGeom::set_hfieldname, reference()) + .property("meshname", &MjsGeom::meshname, &MjsGeom::set_meshname, reference()) + .property("fitscale", &MjsGeom::fitscale, &MjsGeom::set_fitscale, reference()) + .property("userdata", &MjsGeom::userdata, reference()) + .property("plugin", &MjsGeom::plugin, reference()) + .property("info", &MjsGeom::info, &MjsGeom::set_info, reference()) + ; + emscripten::class_("MjsMesh") + .property("element", &MjsMesh::element, reference()) + .property("content_type", &MjsMesh::content_type, &MjsMesh::set_content_type, reference()) + .property("file", &MjsMesh::file, &MjsMesh::set_file, reference()) + .property("refpos", &MjsMesh::refpos) + .property("refquat", &MjsMesh::refquat) + .property("scale", &MjsMesh::scale) + .property("inertia", &MjsMesh::inertia, &MjsMesh::set_inertia, reference()) + .property("smoothnormal", &MjsMesh::smoothnormal, &MjsMesh::set_smoothnormal, reference()) + .property("needsdf", &MjsMesh::needsdf, &MjsMesh::set_needsdf, reference()) + .property("maxhullvert", &MjsMesh::maxhullvert, &MjsMesh::set_maxhullvert, reference()) + .property("uservert", &MjsMesh::uservert, reference()) + .property("usernormal", &MjsMesh::usernormal, reference()) + .property("usertexcoord", &MjsMesh::usertexcoord, reference()) + .property("userface", &MjsMesh::userface, reference()) + .property("userfacenormal", &MjsMesh::userfacenormal, reference()) + .property("userfacetexcoord", &MjsMesh::userfacetexcoord, reference()) + .property("plugin", &MjsMesh::plugin, reference()) + .property("material", &MjsMesh::material, &MjsMesh::set_material, reference()) + .property("info", &MjsMesh::info, &MjsMesh::set_info, reference()) + ; emscripten::class_("MjsSensor") .property("element", &MjsSensor::element, reference()) .property("type", &MjsSensor::type, &MjsSensor::set_type, reference()) @@ -10090,40 +10104,6 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("plugin", &MjsSensor::plugin, reference()) .property("info", &MjsSensor::info, &MjsSensor::set_info, reference()) ; - - emscripten::class_("MjsNumeric") - .property("element", &MjsNumeric::element, reference()) - .property("data", &MjsNumeric::data, reference()) - .property("size", &MjsNumeric::size, &MjsNumeric::set_size, reference()) - .property("info", &MjsNumeric::info, &MjsNumeric::set_info, reference()) - ; - - emscripten::class_("MjsText") - .property("element", &MjsText::element, reference()) - .property("data", &MjsText::data, &MjsText::set_data, reference()) - .property("info", &MjsText::info, &MjsText::set_info, reference()) - ; - - emscripten::class_("MjsTuple") - .property("element", &MjsTuple::element, reference()) - .property("objtype", &MjsTuple::objtype, reference()) - .property("objname", &MjsTuple::objname, reference()) - .property("objprm", &MjsTuple::objprm, reference()) - .property("info", &MjsTuple::info, &MjsTuple::set_info, reference()) - ; - - emscripten::class_("MjsKey") - .property("element", &MjsKey::element, reference()) - .property("time", &MjsKey::time, &MjsKey::set_time, reference()) - .property("qpos", &MjsKey::qpos, reference()) - .property("qvel", &MjsKey::qvel, reference()) - .property("act", &MjsKey::act, reference()) - .property("mpos", &MjsKey::mpos, reference()) - .property("mquat", &MjsKey::mquat, reference()) - .property("ctrl", &MjsKey::ctrl, reference()) - .property("info", &MjsKey::info, &MjsKey::set_info, reference()) - ; - emscripten::class_("MjsDefault") .property("element", &MjsDefault::element, reference()) .property("joint", &MjsDefault::joint, reference()) @@ -10140,18 +10120,6 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .property("actuator", &MjsDefault::actuator, reference()) ; - emscripten::class_("MjsPlugin") - .property("element", &MjsPlugin::element, reference()) - .property("name", &MjsPlugin::name, &MjsPlugin::set_name, reference()) - .property("plugin_name", &MjsPlugin::plugin_name, &MjsPlugin::set_plugin_name, reference()) - .property("active", &MjsPlugin::active, &MjsPlugin::set_active, reference()) - .property("info", &MjsPlugin::info, &MjsPlugin::set_info, reference()) - ; - - emscripten::class_("MjVFS").constructor<>() - // TODO: .property("impl_", &MjVFS::impl_) - ; - // TODO: should be generated in future CLs -- // emscripten::register_vector("MjSolverStatVec"); emscripten::register_vector("MjTimerStatVec"); diff --git a/wasm/codegen/generators/structs.py b/wasm/codegen/generators/structs.py index 6cc10e3d..a2f884e6 100644 --- a/wasm/codegen/generators/structs.py +++ b/wasm/codegen/generators/structs.py @@ -58,22 +58,28 @@ class Generator: )) autogenned_struct_source = [] + autogenned_struct_bindings = [] for struct_name in sorted_struct_names: struct_data = self.structs_to_bind_data[struct_name] if struct_data.wrapped_source: autogenned_struct_source.append( struct_data.wrapped_source + "\n" ) - - # Bindings with markers - markers_and_content.append(( - f"// INSERT-GENERATED-{struct_data.wrap_name}-BINDINGS", - [l.binding for l in struct_data.wrapped_fields], - )) + if struct_data.bindings: + autogenned_struct_bindings.append(struct_data.bindings) + else: + # Bindings with markers + markers_and_content.append(( + f"// INSERT-GENERATED-{struct_data.wrap_name}-BINDINGS", + [l.binding for l in struct_data.wrapped_fields], + )) markers_and_content.append(( "// {{ AUTOGENNED_STRUCTS_SOURCE }}", autogenned_struct_source, )) - + markers_and_content.append(( + "// {{ AUTOGENNED_STRUCTS_BINDINGS }}", + autogenned_struct_bindings, + )) return markers_and_content diff --git a/wasm/codegen/helpers/structs.py b/wasm/codegen/helpers/structs.py index 281d4412..3ae27442 100644 --- a/wasm/codegen/helpers/structs.py +++ b/wasm/codegen/helpers/structs.py @@ -69,6 +69,9 @@ class WrappedStructData: # Struct source code wrapped_source: str + # Struct bindings code + bindings: str = "" + # Whether to use shallow copy for this struct use_shallow_copy: bool = True @@ -597,7 +600,7 @@ def build_struct_source( s = struct_name w = common.uppercase_first_letter(s) - is_mjs = "Mjs" in w + is_mjs = w.startswith("Mjs") fields_with_init = _find_fields_with_init(wrapped_fields) shallow_copy = use_shallow_copy(wrapped_fields) @@ -660,6 +663,41 @@ def build_struct_source( return builder.to_string() +def _build_struct_bindings( + struct_name: str, + wrapped_fields: List[WrappedFieldData], +): + """Builds the C++ bindings for a struct.""" + # These structs require specific constructors + # which, for now, are hardcoded in the template file. + if struct_name in [ + "mjData", + "mjModel", + "mjvScene", + "mjSpec", + ]: + return "" + + w = common.uppercase_first_letter(struct_name) + spc = " " + builder = code_builder.CodeBuilder() + builder.line(f"emscripten::class_<{w}>(\"{w}\")") + + is_mjs = w.startswith("Mjs") + if not is_mjs: + builder.line(f"{spc}.constructor<>()") + + shallow_copy = use_shallow_copy(wrapped_fields) + if shallow_copy and not is_mjs: + builder.line(f"{spc}.function(\"copy\", &{w}::copy, take_ownership())") + + for field in wrapped_fields: + if field.binding: + builder.line(f"{spc}{field.binding}") + builder.line(f"{spc};") + return builder.to_string() + + def parse_array_extent( extents: Tuple[Union[str, int], ...], wrapper_name: str, field_name: str ) -> str: @@ -733,12 +771,14 @@ def generate_wasm_bindings( struct_name, wrapped_fields, ) + bindings = _build_struct_bindings(struct_name, wrapped_fields) wrap_data = WrappedStructData( wrap_name=wrapped_name, wrapped_fields=wrapped_fields, wrapped_header=wrapped_header, wrapped_source=wrapped_source, use_shallow_copy=use_shallow_copy(wrapped_fields), + bindings=bindings, ) wrapped_structs[struct_name] = wrap_data diff --git a/wasm/codegen/templates/bindings.cc b/wasm/codegen/templates/bindings.cc index f03030fa..0dfd02f9 100644 --- a/wasm/codegen/templates/bindings.cc +++ b/wasm/codegen/templates/bindings.cc @@ -598,11 +598,6 @@ std::unique_ptr parseXMLString(const std::string &xml) { EMSCRIPTEN_BINDINGS(mujoco_bindings) { function("parseXMLString", &parseXMLString, take_ownership()); - emscripten::class_("MjLROpt") - .constructor<>() - .function("copy", &MjLROpt::copy, take_ownership()) - // INSERT-GENERATED-MjLROpt-BINDINGS - ; emscripten::class_("MjModel") .class_function("loadFromXML", &loadFromXML, take_ownership()) .constructor() @@ -613,238 +608,16 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) { .constructor() // INSERT-GENERATED-MjData-BINDINGS ; - emscripten::class_("MjOption") - .constructor<>() - .function("copy", &MjOption::copy, take_ownership()) - // INSERT-GENERATED-MjOption-BINDINGS - ; - emscripten::class_("MjStatistic") - .constructor<>() - .function("copy", &MjStatistic::copy, take_ownership()) - // INSERT-GENERATED-MjStatistic-BINDINGS - ; - emscripten::class_("MjVisualGlobal") - .constructor<>() - .function("copy", &MjVisualGlobal::copy, take_ownership()) - // INSERT-GENERATED-MjVisualGlobal-BINDINGS - ; - emscripten::class_("MjVisualQuality") - .constructor<>() - .function("copy", &MjVisualQuality::copy, take_ownership()) - // INSERT-GENERATED-MjVisualQuality-BINDINGS - ; - emscripten::class_("MjVisualHeadlight") - .constructor<>() - .function("copy", &MjVisualHeadlight::copy, take_ownership()) - // INSERT-GENERATED-MjVisualHeadlight-BINDINGS - ; - emscripten::class_("MjVisualMap") - .constructor<>() - .function("copy", &MjVisualMap::copy, take_ownership()) - // INSERT-GENERATED-MjVisualMap-BINDINGS - ; - emscripten::class_("MjVisualScale") - .constructor<>() - .function("copy", &MjVisualScale::copy, take_ownership()) - // INSERT-GENERATED-MjVisualScale-BINDINGS - ; - emscripten::class_("MjVisualRgba") - .constructor<>() - .function("copy", &MjVisualRgba::copy, take_ownership()) - // INSERT-GENERATED-MjVisualRgba-BINDINGS - ; - emscripten::class_("MjVisual") - .constructor<>() - .function("copy", &MjVisual::copy, take_ownership()) - // INSERT-GENERATED-MjVisual-BINDINGS - ; - emscripten::class_("MjSolverStat") - .constructor<>() - .function("copy", &MjSolverStat::copy, take_ownership()) - // INSERT-GENERATED-MjSolverStat-BINDINGS - ; - emscripten::class_("MjTimerStat") - .constructor<>() - .function("copy", &MjTimerStat::copy, take_ownership()) - // INSERT-GENERATED-MjTimerStat-BINDINGS - ; - emscripten::class_("MjWarningStat") - .constructor<>() - .function("copy", &MjWarningStat::copy, take_ownership()) - // INSERT-GENERATED-MjWarningStat-BINDINGS - ; - emscripten::class_("MjContact") - .constructor<>() - .function("copy", &MjContact::copy, take_ownership()) - // INSERT-GENERATED-MjContact-BINDINGS - ; - emscripten::class_("MjvPerturb") - .constructor<>() - .function("copy", &MjvPerturb::copy, take_ownership()) - // INSERT-GENERATED-MjvPerturb-BINDINGS - ; - emscripten::class_("MjvCamera") - .constructor<>() - .function("copy", &MjvCamera::copy, take_ownership()) - // INSERT-GENERATED-MjvCamera-BINDINGS - ; - emscripten::class_("MjvGLCamera") - .constructor<>() - .function("copy", &MjvGLCamera::copy, take_ownership()) - // INSERT-GENERATED-MjvGLCamera-BINDINGS - ; - emscripten::class_("MjvGeom") - .constructor<>() - .function("copy", &MjvGLCamera::copy, take_ownership()) - // INSERT-GENERATED-MjvGeom-BINDINGS - ; - emscripten::class_("MjvLight") - .constructor<>() - .function("copy", &MjvLight::copy, take_ownership()) - // INSERT-GENERATED-MjvLight-BINDINGS - ; - emscripten::class_("MjvOption") - .constructor<>() - .function("copy", &MjvOption::copy, take_ownership()) - // INSERT-GENERATED-MjvOption-BINDINGS - ; - emscripten::class_("MjvScene") .constructor<>() .constructor() // INSERT-GENERATED-MjvScene-BINDINGS ; - - emscripten::class_("MjvFigure") - .constructor<>() - .function("copy", &MjvFigure::copy, take_ownership()) - // INSERT-GENERATED-MjvFigure-BINDINGS - ; - emscripten::class_("MjSpec") .constructor() // INSERT-GENERATED-MjSpec-BINDINGS ; - - emscripten::class_("MjsElement") - // INSERT-GENERATED-MjsElement-BINDINGS - ; - - emscripten::class_("MjsCompiler") - // INSERT-GENERATED-MjsCompiler-BINDINGS - ; - - emscripten::class_("MjsOrientation") - // INSERT-GENERATED-MjsOrientation-BINDINGS - ; - - emscripten::class_("MjsBody") - // INSERT-GENERATED-MjsBody-BINDINGS - ; - - emscripten::class_("MjsGeom") - // INSERT-GENERATED-MjsGeom-BINDINGS - ; - - emscripten::class_("MjsFrame") - // INSERT-GENERATED-MjsFrame-BINDINGS - ; - - emscripten::class_("MjsJoint") - // INSERT-GENERATED-MjsJoint-BINDINGS - ; - - emscripten::class_("MjsSite") - // INSERT-GENERATED-MjsSite-BINDINGS - ; - - emscripten::class_("MjsCamera") - // INSERT-GENERATED-MjsCamera-BINDINGS - ; - - emscripten::class_("MjsLight") - // INSERT-GENERATED-MjsLight-BINDINGS - ; - - emscripten::class_("MjsFlex") - // INSERT-GENERATED-MjsFlex-BINDINGS - ; - - emscripten::class_("MjsMesh") - // INSERT-GENERATED-MjsMesh-BINDINGS - ; - - emscripten::class_("MjsHField") - // INSERT-GENERATED-MjsHField-BINDINGS - ; - - emscripten::class_("MjsSkin") - // INSERT-GENERATED-MjsSkin-BINDINGS - ; - - emscripten::class_("MjsTexture") - // INSERT-GENERATED-MjsTexture-BINDINGS - ; - - emscripten::class_("MjsMaterial") - // INSERT-GENERATED-MjsMaterial-BINDINGS - ; - - emscripten::class_("MjsPair") - // INSERT-GENERATED-MjsPair-BINDINGS - ; - - emscripten::class_("MjsExclude") - // INSERT-GENERATED-MjsExclude-BINDINGS - ; - - emscripten::class_("MjsEquality") - // INSERT-GENERATED-MjsEquality-BINDINGS - ; - - emscripten::class_("MjsTendon") - // INSERT-GENERATED-MjsTendon-BINDINGS - ; - - emscripten::class_("MjsWrap") - // INSERT-GENERATED-MjsWrap-BINDINGS - ; - - emscripten::class_("MjsActuator") - // INSERT-GENERATED-MjsActuator-BINDINGS - ; - - emscripten::class_("MjsSensor") - // INSERT-GENERATED-MjsSensor-BINDINGS - ; - - emscripten::class_("MjsNumeric") - // INSERT-GENERATED-MjsNumeric-BINDINGS - ; - - emscripten::class_("MjsText") - // INSERT-GENERATED-MjsText-BINDINGS - ; - - emscripten::class_("MjsTuple") - // INSERT-GENERATED-MjsTuple-BINDINGS - ; - - emscripten::class_("MjsKey") - // INSERT-GENERATED-MjsKey-BINDINGS - ; - - emscripten::class_("MjsDefault") - // INSERT-GENERATED-MjsDefault-BINDINGS - ; - - emscripten::class_("MjsPlugin") - // INSERT-GENERATED-MjsPlugin-BINDINGS - ; - - emscripten::class_("MjVFS").constructor<>() - // INSERT-GENERATED-MjVFS-BINDINGS - ; + // {{ AUTOGENNED_STRUCTS_BINDINGS }} // TODO: should be generated in future CLs -- // emscripten::register_vector("MjSolverStatVec");