Export U3D files

From JReality Wiki
Jump to: navigation, search

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.

ViewerApp with U3D export menu

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:

\title{U3D Tutorial}
\author{Stefan Sechelmann}
\section{U3D Export}
\subsection{Pdflatex movie15 package}
	\frametitle{U3D Dodecahedron Example}
		{ 0.7\textwidth }
		{ 0.5\textwidth }

You will need the movie15[1] package to compile this example.

Acrobat Reader with U3D content

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;
	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);