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

“Go to a 3D view” Javascript

cshively
cshively's picture
Registered: Dec 3 2007
Posts: 9

I am looking for a way to change 3D views using JavaScript. I want to obtain similar result as the predefine action (Go to a 3D view) but with code that is embedded with a combo-box.
I have a JS that populates a combo-box from an attached xml doc. I am looking to use a similar “Go to a 3D view” function with this selection list.
Are there any examples of a JS that would run the same as the “Go to a 3D view”?

My Product Information:
Acrobat 3D 8.0999999999999996447286321199499070644378662109375, Windows
pddesigner
pddesigner's picture
Registered: Jul 9 2006
Posts: 858
Take a look at this Adobe site.

Download the Javascript Reference Manual for Acrobat 3D. Review the sections on Event Handlers.

[url=http://www.adobe.com/devnet/acrobat/javascript3d.php]http://www.adobe.com/devnet/acrobat/javascript3d.php[/url]

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
pddesigner's picture
Registered: Jul 9 2006
Posts: 858
Hello cshively,
I also use Acrobat 3D but have not used this function in my developments.

I did find some information on JavaScripting this function in the links I've added to this comment.

I hope they help.

[url=http://www.adobe.com/designcenter/acrobat/articles/acr7sd3dcontent.php]http://www.adobe.com/designcenter/acrobat/articles/acr7sd3dcontent.php[/url]

[url=http://www.box.net/shared/static/b05zheq88k.pdf]http://www.box.net/shared/static/b05zheq88k.pdf[/url]

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
pddesigner's picture
Registered: Jul 9 2006
Posts: 858
I've found what I believe is the answer but I've got to test it to make sure it does what you want.

Expect an answer posted here tomorrow.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

cshively
cshively's picture
Registered: Dec 3 2007
Posts: 9
I have looked at using the camera event handler; however we would like to use the views that have been created in acrobat, and not create the 3D view from a new camera creation using JavaScript.

An example of how we would like this to be used would be for a house that has a drop down list that lists all of the rooms in that house. An individual could then interact w/ the 3D through the Combo-Box by selecting the room and activating a predefined view of the room. This could make it much easier for an end user to be able to view the different rooms with ease.

However with all of the research I have completed the camera events do not interact with the views they are more about creating a new camera or controlling the current active camera and how it works.

I appreciate the information you have posted and have read it all, still doing research on this end.

Have you been able to find out any additional information on this?
pddesigner
pddesigner's picture
Registered: Jul 9 2006
Posts: 858
I've sucessfully implemented a 3D annotation using this Acrobat 3D tutorial which is my best offer for a solution to what you're trying to do.

[url=http://www.box.net/shared/static/yda2e0easw.pdf]http://www.box.net/shared/static/yda2e0easw.pdf[/url]

From my preliminary research, I've not found a way to do this using javascript in a combo box.

You could add a 3D view to a bookmark or link by following these instructions.

1. Right-click (Windows) or Control-click (Mac OS) the bookmark or link, and choose Properties.
2. Click the Actions tab.
3. From the Select Action menu, select Go To A 3D View, and then click Add.
4. In the Select A 3D View dialog box, select the view you want, click OK, and then click Close.

If this doesn't provide the solution you're seeking, try posting the question on the Acrobat User Community Forum [url=http://www.acrobatusers.com/forums/aucbb/]http://www.acrobatusers.com/forums/aucbb/[/url] - Acrobat 3D

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

cshively
cshively's picture
Registered: Dec 3 2007
Posts: 9
Eugene,
Thank you for your efforts on this, I will take a look at the recommendation that you have posted, and see if it will meet our needs.
cshively
cshively's picture
Registered: Dec 3 2007
Posts: 9
Eugene,
I wanted to let you know that we have come up with a solution for what we are trying to achieve.

We created a series of buttons that will be stacked on each other. Each of these buttons has a unique name i.e. VIEW-01 and each as a specific view associated with it. We then wrote a function that is tied to the combo box. This function changes the all of the buttons to be a hidden button, except for the one that has been selected in the combo box.

So the user will select the item in the combo box then click on the VIEW button and it will take the user to the pre-defined view associate with the visible button.

It is not as good of a flow as we would like, but it works. I just wanted you to know for future reference.

Again, thank you for your help on this.
onionmon
onionmon's picture
Registered: Oct 9 2007
Posts: 8
I have a very similar problem. I'm not sure where to look under event handlers, I'm not understanding the CameraEventHandler.
onionmon
onionmon's picture
Registered: Oct 9 2007
Posts: 8
In reply to Eugene's comment. Upon an event occurring (like a click of a mouse), a function needs to triggered.

The main question is: what is the function that executes the predefined "Go to a 3D view"?
onionmon
onionmon's picture
Registered: Oct 9 2007
Posts: 8
Eugene, I read the documents you have linked. I appreciate your time in finding these articles, but I still do not know the JS function that allows a 3D view change. The articles document how to implement said function, but does not specify what the function is called.

Another line of my thinking is: When you go to:

3D properties on the 3DAnnot > Manage Views > NEW VIEW. What does Adobe 3D save this newly-created view as? What does Adobe 3D store the name of the view as? The clincher is: Is there a way to retrieve the view in JS form?
Forrest Gimp
Forrest Gimp's picture
Registered: Mar 4 2010
Posts: 7
Has this problem been solved?
I would need to access a view via JS as well, as I have programmed my interface in flash. I trigger various JS-actions from there, whcih works smoothly, and the one thing left to do is triggering a view-change to "fly" to a certain predefined view. But so far I have found no way to do so by a script-command.

So what I need is the syntax to make the active (default) camera move to the position of a predifined view, much the same as the "Go To A 3D View"-command.

Any suggestions?
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
Within your 3D context, you can use the runtime object's setView() function to switch to one of the stored views in the scene. For example if from the context of your document you call


var c3d = getAnnots3D(this.pageNum)[0].context3D; c3d.runtime.setView(3,true);

the first 3D scene on the current page will switch to the fourth stored view in the list (it counts from zero), and will go there using the default flying animation. Set the 2nd parameter to false to disable that animation.


You can also use the name of the view as the first parameter if you prefer.


See http://www.acrobatusers.com/tutorials/using-flash-3d-material-part-2-2 for more info on the JS-SWF-3D interface
Forrest Gimp
Forrest Gimp's picture
Registered: Mar 4 2010
Posts: 7
Thanx a lot! That was just what I was looking for.

As for the Flash-stuff: So far I use flash only for the gui, as it is too complex for using acrobat-forms (it's some kind of konfigurator, changing meshes and colors around and stuff like that.... and flash looks much nicer anyway). I don't use it within the actual 3d-annotation, but separately. Still, very interesting stuff. I might find use for it in future projects!
Forrest Gimp
Forrest Gimp's picture
Registered: Mar 4 2010
Posts: 7
Ok, apparently I'm running into a new problem now. Changing to a view does not move the default-camera there. It rather creates some kind of virtual camera that flies to the view-position. If the user however tries to use pan/zoom/rotate, the view snaps back to the original cameraposition..... Is there a way to move the camera along with the view?

I tried to set the coordinates of the camera after the "fly-to-view"-call, but this leads to an ugly zapping-effect, as the execution of the "fly to view" seems to be delayed, so the moving of the camera is actually executed before the flight starts. This is unacceptable.
salyhpos
salyhpos's picture
Registered: Mar 5 2010
Posts: 1
3D is a interesting topic for discussion,recently i see that many people use it.many movie make in 3D. i think that in future we can see only 3D movies.
http://acaimax-cleanse.blogspot.com
Forrest Gimp
Forrest Gimp's picture
Registered: Mar 4 2010
Posts: 7
All right.... Some important points to take note of:

1. Using the function to fly to a view like described above works.

2. Setting the camera to the position of a view does not work, as the view-object refuses to reveal its camera coordinates, which is very inconveniant.

3. You can work around this by first moving the camera to the coordinates where you want to end up, take a note of the coordinates and THEN create a view from that exact camera-angle.

4. To prevent the camera from flashing to the end-coordinates before your fly-to-view animation even starts properly, you can use a timeout function. It will delay the execution for a given amount of milliseconds (something like this: app.setTimeOut("context.moveCamera(12,7.23,10)",500); ) Not a very clean solution, but it works for now. [Any ideas of how to do that better would be extremely appreciated!]

5. All this works, when the viewchange is triggered by an acrobat-form-button. If you try to trigger the same function from a Flash action-script, the timeout-procedure will not be executed at all, and suddenly the performance of the fly-to-view-animation will be much worse. (I lack an explanation for both, as the function executed runs wither in a document-scope or the annotation-scope. So once triggered, flash is not really involved in the execution of any of those functions. Still it seems to intervene to screw them up.... )