Home > Applications > x3d_version3g > figure2xhtml.m

iFit/figure2xhtml

PURPOSE ^

This function FIGURE2XHTML converts the 3D objects of a Matlab figure

SYNOPSIS ^

function figure2xhtml(varargin)

DESCRIPTION ^

 This function FIGURE2XHTML converts the 3D objects of a Matlab figure
 to an in XHTML embedded X3D file. In a modern browser, you can now view
 your figure interactively because of the great X3DOM Library
 (Instant 3D the HTML way! http://www.x3dom.org/).

 Currently the function supports: Axes, Patch, Line, Surface, Text, Image
 and Light objects.

 Browsers supported:
 - Google Chrome 9.x and above
 - Firefox 4.x and above
 - Webkit nightly builds
 - InstantReality-plugin or Flash11-plugin needed for Internet explorer


  figure2xhtml(filename,handle,options)

   Note : All input arguments are optional, and sorting doesn't matter
          thus figure2xhtml(); is valid but also
          figurexhtml(options,handle);

 inputs,
    filename : Name of the XHTML file (also an X3D file is created).
           When empty or not known a File-Dialog is shown
    handle : Figure handle or axis handle
           When empty or not known the current axis (GCA) is used
    options : A struct with options
      options.output : Produce output files 'x3d', 'xhtml' or 'both' (default)
      options.width : Width of X3D render object in pixels default 500 
      options.height : Height of X3D render object in pixels default 500 
      options.headlight : Enable Camera head light, boolean true/false
                           (default true)
      options.embedimages : Instead of using separate .png files embed 
                            the images in xhtml (Not supported bij IE9)
                           (default false)
      options.title : Title of xhtml page, default 'Matlab X3D'
      options.interactive : Make mesh/surface objects clickable in xhtml,
                          boolean true/false (default false)
                           

 Example, Click-able patch, with face color
  load('functions\exampledata');
  figure, hold on; axis equal;
  patch(FV,'facecolor',[1 0 0],'facealpha',0.5);
  FV.vertices(:,1)=FV.vertices(:,1)+80;
  patch(FV,'FaceColor','interp','FaceVertexCData',rand(size(FV.vertices)),'edgecolor','none');
  FV.vertices(:,1)=FV.vertices(:,1)+80;
  patch(FV,'FaceColor','flat','FaceVertexCData',rand(size(FV.faces)),'edgecolor','none');
  figure2xhtml('test/example1',struct('interactive',true))

Example, Lights and surface
   logo
   if(exist('l1','var'))
     set(l1,'Position',[40 100 20]*2);
     set(l2,'Position',[.5 -1 .4]*30);
   end
   figure2xhtml('test/example2.xhtml')

Example, Surf with colors
   h=figure, hold on; sphere;
   figure2xhtml('test/example3',h)

Example, Mesh
   figure, axis([-3 3 -3 3 -10 5])
   [X,Y] = meshgrid(-3:.125:3);
   Z = peaks(X,Y);
   mesh(X,Y,Z);
   figure2xhtml('test/example4')

Example, Surf
   figure,
   [X,Y] = meshgrid(-3:.125:3);
   Z = peaks(X,Y);
   surf(X,Y,Z);
   figure2xhtml;

Example, Lines
   figure, hold on;
   plot3([1 10 30]*4,[1 20 30]*4,[1 10 30]*4,'r:');
   plot3([1 10 30]'*4,[1 20 30]'*4,[10 30 1]'*4,'g*');
   plot3([1 5 20]'*4,[1 5 20]'*4,[3 20 1]'*4,'-g*','MarkerEdgeColor',[1 0 0]);
   figure2xhtml('test/example5')

Example, Points
   L = 40*membrane(1,25);
   [X,Y]=ndgrid(1:size(L,1),1:size(L,2));
   figure, plot3(X(:),Y(:),L(:),'r.');
   figure2xhtml('test/example6')

Example, Texture on Surface
   figure, hold on;
   load('functions\exampledata');
   surface(peaks,flipud(X),'FaceColor','texturemap','EdgeColor','none', 'CDataMapping','direct')
   colormap(map)
   view(-35,45)
   figure2xhtml('test/example7')

Example, Axis
   h=figure, hold on; sphere;
   addpath([cd '/functions'])
   axis2lines
   figure2xhtml('test/example8',h)

 Function is written by D.Kroon University of Twente (July 2011)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Tue 27-Nov-2018 10:56:24 by m2html © 2005. iFit (c) E.Farhi/ILL EUPL 1.1