Tutorial: Animating Vibrations in 3D PDF Documents



Load output file with frequencies calculation into Jamberoo. Tick Animate Vibrations check box in the Vibrations Control dialog.

Save molecular scene in the VRML format and insert the file into the PDF document. Now we delete some nodes from the 3D scene. After activation of 3D object right-buttom mouse click on the object to open a popup menu and select the Edit in 3D Reviewer menu item

In 3D Reviewer right-buttom mouse click on the node:(10) node to open a popup menu and select Delete menu item

Return back to Adobe Acrobat

You can see in the Model Tree panel that 3D object has 10 frames

Add two buttons (see Adding Buttons tutorial) and name them Animate and Stop Animation

Right-buttom mouse click on the 3D object to open popup menu and select Properties

Select 3D tab and load jamberoo.js JavaScript (Browse button in the Script panel)

Switch to the Select Object mode

Double click on the Animate button to open Button Properties dialog. Select Run a JavaScript in the Select Action combo box.

Press Add.. button

to open the JavaScript Editor dialog

Select and copy JavaScript code below and paste it into the JavaScript Editor dialog// Get index of page containing the Annot3D object (count starts at 0).

// Get index of page containing the Annot3D object (count starts at 0).
pageIndex = this.pageNum;

// Index of the Annot3D (count starts at 0).
annotIndex = 0;

if (getAnnots3D(pageIndex)[annotIndex].activated) {
c3d = getAnnots3D(pageIndex)[annotIndex].context3D;
c3d.doAnimation = true;
play();
}

function play() {
c3d = getAnnots3D(pageIndex)[annotIndex].context3D;
if ( !c3d.doAnimation ) {
return;
}
//console.println("Animatining Frame...");
if ( c3d.rendering ) {
anim = app.setTimeOut("play()",50);
anim;
}
else {
c3d.animate();
anim = app.setTimeOut("play()",50);
anim;
}
}

Now open the JavaScript Editor dialog for the Stop Animation button. Select and copy JavaScript code below and paste it into the JavaScript Editor dialog

// Get index of page containing the Annot3D object (count starts at 0).
pageIndex = this.pageNum;

// Index of the Annot3D (count starts at 0).
annotIndex = 0;

if (getAnnots3D(pageIndex)[annotIndex].activated) {
c3d = getAnnots3D(pageIndex)[annotIndex].context3D;
c3d.stopAnimation();
c3d.setOneFrameVisible(5);
}

The last function, setOneFrameVisible(4), sets visible frame #4 after stoping animation.

The final 3D PDF document is here

[Tutorial Home]


Send all questions, suggestions and comments to Vlad (vvv900@gmail.com)

Dr. Vladislav Vasilyev

Supercomputer Facility,

The Australian National University,

Canberra, ACT, 0200, Australia