These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Setting center of rotation via 3D JavaScript?

DBriggs
DBriggs's picture
Registered: Dec 16 2008
Posts: 10

Interactively a user can select an object to be the center of rotation. For example, the Zoom to Part function will result in the scene rotating around the selected part.

Is it possible via 3D JavaScript to set the center of rotation? I've looked at the definition of several objects (camera, matrix, view, scene) and I don't see a way to set this. The closest I've found is the camera.target property which doesn't specify if it has any effect on rotation.

Can anyone point me in the right direction or is this not possible via scripting?

Thanks.

My Product Information:
Acrobat Pro Extended 9.1, Windows
itsraghuin
itsraghuin's picture
Registered: Sep 8 2009
Posts: 18
Hi, did you get any replies on this? I'm also trying to achieve the same.
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
Yep, it's the camera targetPosition you need to set, by creating a Vector3 and assigning it using the .set method. Here's an example that moves the camera rotation pivot to the point (0,0,5) - which is 5 units vertically up from the origin.

var camera = scene.cameras.getByIndex( 0 );cameraV3 = new Vector3( 0 , 0 , 5 );camera.targetPosition.set( cameraV3 );

If you want to test the script in the Acrobat debug console (cmd-J) you need to scope it to the 3D scene:

var c3d = getAnnots3D( 0 )[ 0 ].context3D;var camera = c3d.scene.cameras.getByIndex( 0 );cameraV3 = new c3d.Vector3( 0 , 0 , 5 );camera.targetPosition.set( cameraV3 );

Paste that into the console, select all 4 lines and press CTRL-ENTER to run it (assuming of course there's a 3D viewport active in page 1 of your document!
itsraghuin
itsraghuin's picture
Registered: Sep 8 2009
Posts: 18
UVSAR, thanks for your prompt help on this!
itsraghuin
itsraghuin's picture
Registered: Sep 8 2009
Posts: 18
Is there a way to select nodes programatically in 3D just like it happens when we click it?