Skip to main content
Awesaurus
Participant
March 19, 2018
Answered

Set a 3D Object to Spin Slowly inside a PDF

  • March 19, 2018
  • 2 replies
  • 1540 views

Is there any way to set a constant rotation on a 3D object inside a PDF?

I'm trying to make it so that when you open the document my object is rotating gradually to show off the fact that it's 3D and give it a really dynamic feel. I can place my object just fine, but there doesn't seem to be an option to set any kind of spin outside of actually moving it myself.

Is this even possible?

This topic has been closed for replies.
Correct answer Joel Geraci

You'd adapt the following to suit your needs. The idea is that you want to set an interval that changes the camera position slightly. You can control the smoothness and speed by adjusting the interval time in line 6.

function startSpinning() {

     annot3D = this.getAnnots3D(this.pageNum)[0].context3D

     camera = annot3D.scene.cameras.getByIndex(0)

     camera.targetPosition.set(annot3D.scene.computeBoundingBox().center);

     camera.transform.rotateAboutZInPlace( 14 * Math.PI / 180);

     spinner = app.setInterval("spin()", 5)

}

function spin(){

     annot3D = this.getAnnots3D(this.pageNum)[0].context3D

     camera = annot3D.scene.cameras.getByIndex(0)

     camera.transform.rotateAboutZInPlace( .25 * Math.PI / 180);

}

function stopSpinning() {

     app.clearInterval(spinner)

}

J-

2 replies

Awesaurus
AwesaurusAuthor
Participant
March 20, 2018

Thank you, this is perfect. The people that would be receiving the document are constant customers anyway!

Do you have any idea where I might find a script that would achieve the effect I'm looking for?

Joel Geraci
Community Expert
Joel GeraciCommunity ExpertCorrect answer
Community Expert
March 20, 2018

You'd adapt the following to suit your needs. The idea is that you want to set an interval that changes the camera position slightly. You can control the smoothness and speed by adjusting the interval time in line 6.

function startSpinning() {

     annot3D = this.getAnnots3D(this.pageNum)[0].context3D

     camera = annot3D.scene.cameras.getByIndex(0)

     camera.targetPosition.set(annot3D.scene.computeBoundingBox().center);

     camera.transform.rotateAboutZInPlace( 14 * Math.PI / 180);

     spinner = app.setInterval("spin()", 5)

}

function spin(){

     annot3D = this.getAnnots3D(this.pageNum)[0].context3D

     camera = annot3D.scene.cameras.getByIndex(0)

     camera.transform.rotateAboutZInPlace( .25 * Math.PI / 180);

}

function stopSpinning() {

     app.clearInterval(spinner)

}

J-

Joel Geraci
Community Expert
Community Expert
March 19, 2018

Yes and no.

You can add a script to the 3D object that will rotate the camera. However, the user will be prompted to trust the document before the 3D annotation will activate so you won't be able to achieve the effect you are looking for on first open and will need to instruct users to "Trust Always" for it to work on any subsequent open.

Is that acceptable behavior?