8 Feb 2021
Update - found a workaround. Instead of scatter3, convert points to spheres using ellipsoid, then plot using patch. Use semiaxis lengths appropriate for your dimensions, and set axis equal for the spheres before calling patch.
If you assign colour to your points, you'll need to assign colour to lines as well as faces (setting lines to transparent doesn't work, apparently FIGURE2XHTML can't get transparency settings for the axes object passed to it). Otherwise lines default to black, and your points will look black. I also commented out the if statement in L.210 of addmesh.m to avoid adding lines to the spheres (see Oleg's comment 24-Feb-19, below).
Great job Dirk-Jan and Oleg! Really useful function.
8 Feb 2021
Code works for a 3D polygon created using plot3 (matlab R2020a, Win10 64 bit) without any need for edits - nice work, Dirk-Jan.
Unfortunately scatter3 plots aren't supported :-(
25 Jul 2020
Kudos to Dirk-Jan. It works for me, but...
Got it to work with flat and faceted shading, but not interp (web page stuck "Loading..." forever).
None of the axis/text annotations are rendered, so it's pretty stark.
(macOS 10.15.5 (Catalina); Safari 13.1.1; Matlab 2019b)
Is this really the best the Mathworks has to offer for web-accessible graphics content? Some freelancer's posting from 9 years ago? That's pathetic!
Does it works with scatter3 plot?
24 Feb 2019
Works well overall. It's a bit broken in Matlab 2017b, but most things are easy to fix.
(1) reshape error -> insert ... && numel(Obj.VertexNormals) > 0 in line 210 of addmesh.m
(2) Example 3 in line 62 of figure2xhtml.m -> I guess the class of figure handle h changed from earlier Matlab. Partial solution: call struct(h) instead of h.
(3) A folder for resulting files must exist, at least on MacOS.
(4) Call figure2xhtml.m from a file in the "current folder" on the MatLab path.
Note that generated x3d files can be further converted to a 3D pdf e.g. with PDF3D ReportGen (commercial, package, one month trial).
22 Nov 2018
Broken. same RESHAPE problem as below
I get an error if I pass this function gca gcf or the figure itself. Says unkown input. If I pass it nothing, then it creates empty .xhtml files. What am I missing?
25 Jun 2018
+1 for RESHAPE problem here as well
+1 for RESHAPE problem.
Can't seem to get it to work with surfaces loaded from FreeSurfer :( Any ideas on what to do?
[hf,hp,~,~]=mris_display(mris,curv);
Reading curvature file[ ./surf/lh.thickness ]
Number of curv elements [ 137456 ]
Reading mris file[ ./surf/lh.white ]
Size of vert struct [ 137456 x 3 ]
Size of face struct [ 274908 x 3 ]
figure2xhtml('example')
Error using reshape
To RESHAPE the number of elements must not change.
Error in addmesh (line 212)
N=reshape(Obj.VertexNormals,size(V));
Error in figure2xhtml>figurex3d (line 196)
data=addmesh(data,loc_scene,Obj);
Error in figure2xhtml (line 164)
data=figurex3d(haxis,data,loc_scene);
29 Jan 2018
Thanks for the amazing option!!!
Does anyone know how to control the mouse in the XHTML to resize 3D figure without scrolling the page?
Is there an option to scale the 3d object before exporting since in XHTML I always need to resize the 3D object..
Very nice dunction! However i tried exporting a colored surf(X,Y,Z,C) which has some NaNs for some of the Z and C values (as there is no data availbale for these grid points. In MATLAB figure, these areas are not visible, but in the x3d they appear with the lowest colormap value. Anyway to change that?
I located a 2014 version of matlab on my computer and for whatever reason in that version, writexhtmlfile() was able to load the -.mat file on this version, successfully generating the html.
Really thrilled about the prospect of this - it's exactly what I've been looking for to create 3D html of a complex line graph to show to customers at work. Unfortunately, I'm having an error reading the x3dom.mat file in writexhtmlfile.m. I'm assuming this is supposed to be generated earlier in the function since it is a -.mat file, but I haven't found the source of the error yet. Did anyone else solve/experience this?
2 Nov 2016
doesn't work with patch objects. Limited to surfaces only
"Error using horzcat
Dimensions of matrices being concatenated are not consistent."
How to get rid of this error? I tried it on a surface. BTW, your example doesn't work on R2016a :(
29 Jul 2014
My problem is solved, to set options you must create
options = struct('output','both','height',500,...); %names in help or in figure2xhtml.m
figure2xhtml(options,h) % "save as" window is opened
29 Jul 2014
Incredible work!! But could you help me, please? I write:
h=figure;
sphere;
figure2xhtml(h); %I want the dialog
I would like set options.title and options.interactive, but I don't know how I can do it. Could you give an example?
7 Jul 2014
Works great, but can only be used for surfaces defined by 3 matrices surf(X,Y,Z) or one matrix surf(Z), but not 2 vectors and a matrix surf(x,y,Z)
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in surf2FV (line 13)
V=[XData(:) YData(:) ZData(:)];
A remarkable work, and it just works !
However, as the exported files are ASCII based, beware of the size of the object to export.
25 Mar 2013
Thank you for this. Can you make any suggestions about how to extend your code to allow for an animated series to be played?
9 May 2012
amazing!
mini question: is there anyway to get it to work with elements from an hggroup (such as quiver3?).
17 Mar 2012
I ran on a 3-D figure (created with patches) and got the following error:
??? SWITCH expression must be a scalar or string constant.
Error in ==> addmesh at 142
switch(Obj.FaceColor)
Error in ==> figure2xhtml>figurex3d at 196
data=addmesh(data,loc_scene,Obj);
Error in ==> figure2xhtml at 164
data=figurex3d(haxis,data,loc_scene);
The examples provided with the function ran well without errors.
21 Feb 2012
Does this plugin support color images as texture or just grayscale images?
19 Dec 2011
Very good work....I have been searching for saving a MATLAB figure interactively into html. Searched and found the MATLAB builder ja which is bit complicated. My further search landed me here. Very good work.
But I have a problem in this. 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. Flash player is installed.
Why is it? Any solution?
11 Nov 2011
Thanks for the awesome work. I have been looking for this kind of program for a long time. I really want to explore it. However, I cannot get it to work on my computer. Running the matlab code has no problem. When I tried to open the xhtml file using the latest IE with adobe 11 installed, the web page just show X3DOM Loading Scene... and it neven show up.
I tried to open the xhtml file using the lastest Chrome also. The progrom says that Matalb X3D not responsive and nothing show up also.
Does anybody has the same problem I had and happen to know what may be the reasons, how to fix it?
Thanks....
very exciting option.
It can be interesting include of your option as apart of publish MATLAB function.
Or may be you know how to do that ?
*Ben,
The same viewpoint is not supported.
The camera in Matlab is a little bit strange, (almost) orthogonal, allows non-uniform x,y scaling and does some tricks to stay outside the rendered object. Thus porting the viewpoint to X3D gave strange results.
24 Aug 2011
Could I use the same viewpoint as that for the figure?
*Enedino
Do you get an error with your MRI data?, or know what is the problem?
19 Aug 2011
I test it with the MRI brain of Matlab and is not working, but cheek it with your example and is pretty cool. Thanx for sharing
*Ben
The latest version supports options like a title.
15 Aug 2011
Is there a way to specify the title, the header, and the object name? That would be very helpful. Otherwise, one has to modify the xhtml source code every time, which could be tedious...
Give you 4 stars because the tool is cool!
12 Aug 2011
Comments are almost completely absent from the code.
22 Jul 2011
Comments are almost completely absent from the code.
*Sven Körner
Nice tools, Javaview is indeed a very extensive 3D viewer for the web.
I don't know the u3d-file format, but maybe it is possible to include line geometry thus allow axis2lines function.
There are way to many geometry-file formats, hopefully they will merge sometime.
Thank's for update - it works well! For my 3D-HTML version I used javaview - there is the axis option already embedded.(http://wwwpub.zih.tu-dresden.de/~s9034647/peaksurface.html)
But in the tool to embded u3d files in pdf - there is actually also no axis-feature (http://www.mathworks/matlabcentral/fileexchange/27245-generate-vertices-faces-and-color-for-u3d-format). Maybe I can use your axis2lines function?
*Sven Körner
I added an example with axis to xhtml in the last update (is probably online tomorrow).
Absolutely brilliant.
*Sven Körner
Axis are not supported by the x3dom library, but text and lines are.
Thus a solution can be to draw the axis your self using plot3 in Matlab
This is pretty cool.
Is there a way how to get the coordinate system (x,y and z-axis) of a function in the 3D-graph?
更多推荐
html5显示matlab三维,Matlab 3D figure to 3D (X)HTML
发布评论