Get from Ico-github-logo

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Plot mesh as interactive html

  • x3mesh(f,v, varargin)
    A simple function to convert a matlab mesh consisting of faces (f) and
  • demo1.m
    This file demo the mesh to html export
  • demo2.m
    demo 2 shows how to export a surface mesh
  • View all files
5.0 | 4 ratings Rate this file 10 Downloads (last 30 days) File Size: 0 Bytes File ID: #40942 Version: 1.6
image thumbnail

Plot mesh as interactive html


Benjamin I (view profile)


25 Mar 2013 (Updated )

A simple script to convert a mesh consisting of faces and vertices to an interactive html document.

| Watch this File

File Information

x3mesh is a small and simple script for converting a Matlab mesh consisting of faces and vertices into an x3dom object in an html file.
This allows 3d objects to be displayed and interacted with on the web (rotate and zoom).

Run demo1.m and demo2.m to try it out. The script produces a .html files which can be opened in a browser.

An example of the output can be found here:

The script takes advantage of the x3dom web format. More details can be found here:

Not supported by internet explorer. Use a recent Firefox, Chrome or Safari browser.

1) Added better optional argument parser
2) Added option to set vertex color
3) Added option so set mesh to auto-rotate

MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
13 Apr 2013 Scott Richardson

Hi Ben, awesome program!

06 Apr 2013 Scott Richardson

27 Mar 2013 Benjamin I

Benjamin I (view profile)

Hi Scott. Thanks. This version doesn't support color unless you manually edit the html file... But that sounds like a good idea. I will update it to support face color when I get a chance (give me a few days).

Comment only
27 Mar 2013 Scott Richardson

Hi, very nice, thank you. Is it possible to have a different color assigned to each face which could be viewed in the html file?

26 Mar 2013 Benjamin I

Benjamin I (view profile)

Hi Dan,

Thanks. The easiest way to create a mesh from is a volume using isosurface.

For example see Example 1:

You can plot a mesh in matlab using:
[x,y,z,v] = flow;
p = patch(isosurface(x,y,z,v,-3));
view(3); axis tight
lighting gouraud

You can export this same mesh to html using something like:
[x,y,z,v] = flow;
x3mesh(fv.faces, fv.vertices, 'Matlab_flow', 0.3, 'some more text')

I think I will add this as another example.

Comment only
26 Mar 2013 Dan

Dan (view profile)

Great idea, Ben. But how do you get the data in the mesh structure example_mesh.mat

Thanks a lot,

26 Mar 2013 1.1

added note about internet explorer not being supported

26 Mar 2013 1.2

update title to make it clearer

27 Mar 2013 1.3

added a second demo file

01 Apr 2013 1.4

added ability to set mesh color and autorotation. Improved function parsing using inputParser.

12 Apr 2013 1.5

added better demo files and surf export example

23 Aug 2015 1.6

Linked to github

Contact us