Export U3D files
U3D stands for Universal 3D and is an ECMA standardized file format. The files created by the jReality U3D exporter can be embedded into PDF documents and are viewable since release 7 of the acrobat reader. U3D content can be combined with java script programs to create interactive 3D applications inside a PDF document. This example gives a short introduction of to the necessary steps needed to create such a document.
Take the dodecahedron from the geometry/appearance examples and choose File->Export->U3D from the menu. Save the file as dodec.u3d for example. Common applications that view u3d file are Deep Exploration or the Adobe 3D Toolkit which is a light version of Deep Exploration. However all these programs are Windows only.
To create a PDF that contains this file you need Adobe Acrobat 3D of pdflatex.
The resulting PDF is then viewable with linux's acroread.
Here is a tex-file with our dodecahedron in a latex beamer environment:
\documentclass{beamer} \usepackage[3D]{movie15} \usetheme{Berlin} \title{U3D Tutorial} \author{Stefan Sechelmann} \begin{document} \section{U3D Export} \subsection{Pdflatex movie15 package} \frame{ \frametitle{U3D Dodecahedron Example} \begin{center} \includemovie[ mimetype=model/u3d, 3Djscript=u3d/Encompass.js ] { 0.7\textwidth } { 0.5\textwidth } {u3d/dodec.u3d} \end{center} } \end{document}
You will need the movie15[1] package to compile this example.
In this demonstration we use the java script file Encompass.js to calculate the default camera position.
camera = scene.cameras.getByIndex(0); bb = scene.computeBoundingBox(); //-------------------------- // calculate dimensions of the bounding box //-------------------------- xDist = bb.max.x - bb.min.x; yDist = bb.max.y - bb.min.y; zDist = bb.max.z - bb.min.z; //-------------------------- // scale the distance between camera and target object //-------------------------- a = 0; b = 0; if (xDist > yDist) a = xDist; else a = yDist; b = a / Math.tan(camera.fov); dist = b + zDist/2; if(dist > 2*bb.max.subtract(bb.min).length){ dist = bb.max.subtract(bb.min).length; } pos = new Vector3(dist, 0, 0).add(bb.center); camera.position.set(pos); camera.targetPosition.set(bb.center); scene.update();