PDF Configuration > Interactive Graphics
  
Interactive Graphics
U3D Graphic Support
You can import an Universal 3D (U3D) graphic into PTC Arbortext Layout Developer, or link to an external U3D file. A list of available views is loaded with the graphic, and you can select which view should be used as the default. If no view is selected, the first view from the U3D file is used.
Once imported or linked, the graphic can be referenced inline in content or added to a frame.
The U3D graphic is embedded as a 3D object in PDF output of a document. If you open the PDF in an applicable version of Adobe Reader or Acrobat, you can use Adobe’s controls to view and interact with the 3D graphic.
Load U3D Graphics
You can load U3D graphics into PTC ALD using standard raster graphic import functionality - the tfr macro or the fContent.importRaster() method. You can set the graphic type to U3D when using either of these methods.
For example, when working with the Formatting Object Model / JavaScript, the graphic type is fRaster.FT_U3D. This JavaScript code will load U3D graphic my3D.u3d graphic into PTC ALD:
var g;
g = template.content.getRaster("my3D");
if (!g) {
g = template.content.importRaster("my3D",
"D:/my3D.u3d",
fRaster.FT_U3D,
true);
When the U3D graphic is loaded, you can use the fRaster.u3dViews property to provide the names of its available views as an array.
Add 3D Graphic to a Page
U3D graphics are raster graphics so they be placed both inline and in frames.
To place a U3D inline, use the fFormatting.addU3D() method. The method has some U3D-specific options, such as parameters to control the view and the default animation behavior and an option to run a PDF action to the U3D when it becomes active in the PDF.
For example, this code will place the graphic rg1 as a block sized at 50mm wide.
* 
PTC ALD assumes that all U3D graphics are 100mm x 100mm as it cannot gather size information from the file.
var gr = template.content.getRaster("rg1");

formatting.addU3D(gr,
fFormatting.PLACE_BLOCK,
fFormatting.SCALE_ABSOLUTE,
"50mm",
fFormatting.SCALE_PRESERVE,
"",
0,
0,
true,
"WorldCamera",
"my3D",
2,
1,
fFormatting.ANIMATION_LINEAR,
"u3dAction",
"myPDFLayer"
);
The 3D-specific properties in this snippet are:
“WorldCamera” — The view to use when the U3D is opened (viewName parameter for method)
“my3D” — A name for the U3D graphic in output PDF name so it can be referred to by scripting in actions (pdfName parameter for method)
2— The number of times to play the animation (animationCount parameter for method)
1 — The speed of the animation. 1 equals normal speed (animationSpeed parameter for method)
fFormatting.ANIMATION_LINEAR — The animation style (animationStyle parameter for method)
The allowed values of this argument are listed on the fFormatting.PDFAnimationStyles constant:
fFormatting.ANIMATION_NONE = 0 — Do not play the animation
fFormatting.ANIMATION_LINEAR = 1 — Play the animation from start to finish only
fFormatting.ANIMATION_OSCILLATING = 2 — Play the animation from start to finish and then back again
"u3dAction" — The PDF action (fPDFAction object) to run when the U3D object is activated in the PDF (script parameter for method)
This action can be used to allow interaction between the 3D graphic and text, for example, by capturing mouse events
"myPDFLayer" — The PDF layer fPDFLayer object) on which the graphic should appear (pdfLayer parameter for method)
When placing a U3D in a frame, use the rasterPDFName, pdfLayer, and rasterViewName properties for fFrame. The animation and action properties are not available.
Views for U3D Graphics
Views for U3D graphics are typically provided by the illustration package. PTC ALD also supports the definition of new views for the U3D graphics in the PDF with the PTC ALD object fPDFU3DView. These objects, when they exist in an PTC ALD document, are added to all U3D graphics included in the output PDF. The fPDFU3DView object represents a control stream type tag and has these properties:
backgroundEntire — Controls how the background fill color is applied to the U3D graphic
If the property is set to true, the colour is applied to everything. If the property is false, the color is only applied to the graphic box.
backgroundFillColor — An fColor object used to specify the background color of the U3D graphic
camera2world — An array which represents the matrix which would be applied to the 3D model to specify the camera position
cameraDistance — The distance between the camera and the centre of the model
crease — The angle (between 0 and 180) for the appearance of lines when in render mode Illustration
faceColor — An fColor object used for the faces of the objects when in render mode Illustration
By default, the background color is used.
lighting — The lighting scheme to use when rendering the U3D graphic
Allowed values are listed on the fPDFU3DView.LightingModes constant and include all the lighting modes available in Adobe Acrobat.
opacity — Sets the level of opacity between 0 and 1, when using some render modes in which the parts are transparent, for example Transparent Wireframe
renderColor — An fColor object to provide the color used to render the lines in the graphic
renderType — The render mode for the view
Allowed values are listed on the fPDFU3DView.RenderMode constant and represent all the rendering modes available in Adobe Acrobat, for example such as illustration, wireframe and bounding box.
The default is the mode specified in the graphic.
viewName — The name to give the view in the list, to be used in go to actions
For example, this code will create the view object myView as a tag:
var v;
v = template.content.getPDFU3DView("myView");
if (!v) v = template.content.createPDFU3DView("myVIew");
The fRaster.u3dViews property of the fRaster object is a list of the built-in views in a U3D graphic. When scripting PDF to go to a specific view, custom views should also be taken into account as they will not appear on the fRaster object.
UI Enhancements Supporting this Feature
The Insert Raster Graphic dialog box includes an option View Name
The Frame Contents dialog box includes an option View
With these options, you can select the default view of the graphic.
Macros and Processing Instructions Supporting this Feature
The tfr macro includes the option view, which loads or assigns a raster file to the currently selected frame
The option takes a view name as its value, to define the default view that should be used for the graphic.
For more information, see tfr.