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

Script to replicate "Fit Visible" and "Zoom to Part"?

GeorgeG
GeorgeG's picture
Registered: May 21 2008
Posts: 9

Hello,

Would anyone know how to use a javascript to replicate the context menu items:
"Fit Visible" and "Zoom to Part"?

I'm just trying to create a button to allow the user to easily fill the screen with the current or selected objects without having to go to the model tree and opening the context menu.

Any help would be greatly appreciated.

Cheers
George

My Product Information:
Acrobat 3D 9.2, Windows
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
Not easily - the context menus do a lot of math to zoom to something, and there's no exposure of their functions in JS so you'd have to rebuild it. In 9.2 we generally assume that there's a preset view for everything JS might want to display, and selecting those is easy.

The logic for "zoom to part" is relatively straightforward - the bounding box of the mesh node is collected, and the camera's target set to the center of the box. Then, using the field of view of the camera and basic trigonometry, it's moved closer until one corner of the bounding box falls outside the angle (hence the screen). The same function will work for "fit visible", just using the scene's bounding box.

It's more complex than that in practice, as you need to make sure you're not stopping the camera inside another part of the mesh.
hakamhei
hakamhei's picture
Registered: Sep 30 2008
Posts: 1
Hello GeorgeG,

this tutorial shows how to override the camera movement and view management in Acrobat 3D
http://www.acrobatusers.com/tutorials/can-i-add-views-using-camerarotate-javascript
it could give some help

cheers, Heikki