diff --git a/python/mujoco/bindings_test.py b/python/mujoco/bindings_test.py
index 6bfebb90..47182aa5 100644
--- a/python/mujoco/bindings_test.py
+++ b/python/mujoco/bindings_test.py
@@ -93,6 +93,19 @@ TEST_XML_PLUGIN = r"""
"""
+TEST_XML_TEXTURE = r"""
+
+
+
+
+
+
+
+
+
+"""
+
@contextlib.contextmanager
def temporary_callback(setter, callback):
@@ -1619,6 +1632,10 @@ Euler integrator, semi-implicit in velocity.
self.assertIsNot(data1.model, data2.model)
self.assertNotEqual(data1.model._address, data2.model._address)
+ def test_texture_size(self):
+ model = mujoco.MjModel.from_xml_string(TEST_XML_TEXTURE)
+ self.assertEqual(model.tex('tex').data.shape, (512, 512, 3))
+
def _assert_attributes_equal(self, actual_obj, expected_obj, attr_to_compare):
for name in attr_to_compare:
actual_value = getattr(actual_obj, name)
diff --git a/python/mujoco/indexers.cc b/python/mujoco/indexers.cc
index 72311a93..158f4cae 100644
--- a/python/mujoco/indexers.cc
+++ b/python/mujoco/indexers.cc
@@ -103,6 +103,7 @@ py::array_t MakeArray(T* base_ptr, int index, std::vector&& shape,
shape.insert(shape.begin(), m.hfield_nrow[index]);
} else if (MjSize == &raw::MjModel::ntexdata) {
offset = m.tex_adr[index];
+ shape.insert(shape.begin(), m.tex_nchannel[index]);
shape.insert(shape.begin(), m.tex_width[index]);
shape.insert(shape.begin(), m.tex_height[index]);
} else if (MjSize == &raw::MjModel::nsensordata) {