Search code examples
helix-3d-toolkit

How to add an image as texture on a MeshElement3D?


I've been able to add images as textures on ViewPort2DVisual3D by simply setting the 'Value' field with an Image.

But now I'm trying to use the helix tools and I can't find a way to do the same on a MeshElement3D.

I've been trying with a RectangleVisual3D, but there's nothing such as a 'Visual' field on it.

I bet I should try with the 'Material' field, but all I found is the ImageMaterialExtension object. But it is not inheriting from Material so I can't give it to my RectangleVisual3D.

Any advice?


Solution

  • I found the solution, we can just use the Material Helper such as :

    var mat = MaterialHelper.CreateImageMaterial("img.png", 1, UriKind.Absolute);
    

    and add it to the Material of the MeshElement3D