[docs] Mention asset lookup in MjSpec construction.

PiperOrigin-RevId: 720671094
Change-Id: I6ba343b37893620ba4f3477e57daa4876805156c
This commit is contained in:
Kevin Zakka
2025-01-28 12:33:04 -08:00
committed by Copybara-Service
parent 0643017346
commit f61973601e
+14
View File
@@ -504,6 +504,20 @@ The ``MjSpec`` object wraps the :ref:`mjSpec` struct and can be constructed in t
Note the ``from_string()`` and ``from_file()`` methods can only be called at construction time.
Assets
^^^^^^
All three methods allow one to specify a dictionary of assets that will be used
to resolve asset references in the XML. The dictionary maps from asset
name (string) to asset data (bytes), and can be assigned to the ``assets``
attribute before calling ``compile()``, as demonstrated below.
.. code-block:: python
assets = {'image.png': b'image_data'}
spec = mujoco.MjSpec.from_string(xml_referencing_image_png, assets=assets)
model = spec.compile()
Save to XML
-----------