LiveGraphics3D

Introduction

The LiveGraphics3D applet has been in use for many years. Martin Kraus wrote the applet originally to allow Mathematica graphics to be displayed and rotated (using the mouse) from a web page. Later, he added a link to J/Link to let people use its functionality directly from Mathematica. This example shows you how to use the SuperWidgetLiveGraphics3D super widget to embed this applet in a more general GUI. You will get a diagnostic if you attempt to run this example without first installing the LiveGraphics3D applet.

Code

Needs["SuperWidgetPackage`"];

lg=Graphics3D[Plot3D[Sin[x y],{x,-4,4},{y,-4,4},DisplayFunction->Identity],ImageSize->{1024,800},ViewPoint->{1,1,1},ViewVertical->{0,0,1}];

vp=ViewPoint/.Options[Plot3D,ViewPoint];
θ=0.0;
rotate[v_]:=Module[{applet=LiveGraphics3DApplet[lg],vp1},
vp1=Dot[{{Cos[θ],Sin[θ],0},{-Sin[θ],Cos[θ],0},{0,0,1}},vp];
applet@rotateToViewPointAndViewVertical[Sequence@@Join[vp1,{0,0,1}]];
];

zoom˘out[v_]:=Module[{applet=LiveGraphics3DApplet[lg],mag},
mag=applet@getMagnification[];

applet@setMagnification[mag*0.7];
];

zoom˘in[v_]:=Module[{applet=LiveGraphics3DApplet[lg],mag},
mag=applet@getMagnification[];

applet@setMagnification[mag/0.7];
];

SuperGUIRunModal[SuperWidgetFrame[Null,{SuperWidgetLiveGraphics3D[lg,Pixel˘Width->800,Pixel˘Height->600],(Subscript[¶, 10]),
SuperWidgetHorizontalSlider[θ,0,2π,ChangeFunction->rotate],(Subscript[¶, 10]),
{(Subscript[¶, 0]),SuperWidgetButton[Null,"OK",1],(Subscript[¶, 0])},(Subscript[¶, 10])},Tool˘Bar->{
SuperWidgetButton[Null,"Zoom out",zoom˘out],SuperWidgetButton[Null,"Zoom in",zoom˘in]
}
]
]

Comments

The plot can be rotated by moving the slider. To be more precise, it is the viewpoint that is being moved in a circle about the plot.  It can also be manipulated directly in the traditional LiveGraphics3D way. Note also, the zoom buttons on the toolbar.