File Exchange Pick of the Week

July 22nd, 2011

MATLAB 3D Figure to 3D (X)HTML

Eric’s pick this week is MATLAB 3D Figure to 3D (X)HTML by Dirk-Jan Kroon.

Dirk-Jan Kroon’s submission makes it easy to transfer 3D MATLAB plots to an interactive graphic on a web page. The tool doesn’t just translate geometry – it even includes transparency and lighting effects! You can build a complex scientific visualization in MATLAB and share it on your research web page.

Dirk-Jan says that the tool currently supports "Axes, Patch, Line, Surface and Light" objects. I decided to try this out on my favorite 3D model, a human femur bone, and added lighting and material effects for good measure. The model has an interesting back story...

In grad school I needed an accurate 3D model of a human femur bone for a project. Somehow, I convinced the university med school to loan me a real human femur bone! I don’t know where this thing came from, but I did get a great 3D scan from it.

Here's the model in MATLAB:

And here's the model in my web browser, where the resulting visualization supports zoom, pan, and rotate operations:

The tool creates both the 3D model as well as a sample web page with the model embedded into it. You can view the page with any of these popular web browsers:

The visualization is based on the x3dom framework. Be sure to read the x3dom supported browser page if you have difficulties displaying the example that Dirk-Jan provided with his submission. Also, if you have an older graphics driver you may need to update it.

Leave us a comment with your thoughts here, or leave a comment for Dirk-Jan.


Get the MATLAB code

Published with MATLAB® 7.12

4 Responses to “MATLAB 3D Figure to 3D (X)HTML”

  1. Petter replied on :

    Why to link to an actual homepage, instead of a screenshot?

  2. Siva Srinivas Kolukula replied on :

    Hi
    I ran these files and saved html version in test folder. I tried to open it with chrome and mozilla which are leatest, I get a blank screen showing X3DOM downloading the secene, but never I am getting the interactive image.
    Why is it? Any solution?
    Sreenu

  3. Brett Shoelson replied on :

    Siva,
    I’m sorry you’re having problems with the function. Have you considered posting your question directly to the author’s submission?
    Brett

  4. Siva Srinivas Kolukula replied on :

    Hi Brett….
    I have posted the question directly at the submission…just now..
    Thanks
    Sreenu

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.