Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How to play a range of animation from a 3D model (.u3D) with javascript code ?

New Here ,
Jul 26, 2017 Jul 26, 2017

Hello every one,

I'm creating a pdf with an embedded 3D model for an installation guide.

For every click on the "Next" button, it would show the next task to install.


With the following javascript code, I could create an annotation which shows the name of the current task by implementing an index.

I am able to run the full animation of the 3D model but the annotation is not linked to this animation so it does'nt change...

I've done the animation of the full installation and I would like to split this animation to link these parts with the button actions.
For example : 1st click on the button --> it shows the animation from frame 0 to frame 30
                       2nd click on the button --> it shows the animation from frame 31 to frame 60

                       3rd click.....                         .......... frame XX to XX

And I would like to continue with "Previous task" button too..

Apparently, there are some useful properties :

var _anim = scene.animations.getByIndex();

currentTime

endTime

framesPerSecond

length

startTime

But I am absolutly not able to create this code...

var taskNames = ["task1", "task2", "task3", "task4"];

var taskIndex = 0;

var annot = this.addAnnot({

  page: 0,

  type: "FreeText",

  rect: [60, 100, 780, 120],

  strokeColor: color.white

});

var spans = new Array();

spans[0] = new Object();

spans[0].text = "0 - Foundations";

spans[0].textColor = color.blue;

spans[0].textSize = 15;

spans[0].alignment = "center";

annot.richContents = spans;

function NextTask()

{

 

  if (taskIndex < taskNames.length-1)

  {

taskIndex++;

spans[0].text = taskNames[taskIndex];

    annot.richContents = spans;

  }

}

function PreviousTask()

{

  if (taskIndex > 0)

  { 

taskIndex--;

    spans[0].text = taskNames[taskIndex];

    annot.richContents = spans;

  }

}

Does someone have any idea to help me ?

Thanks in advance for your help

Regards.

TOPICS
Rich media and 3D
836
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2017 Jul 28, 2017
LATEST

To develop a bit more:

I would like to run an animation from #frameXX to #frameZZ for any "taskIndex" from the javascript code.

I need to create a second javascript code for "3D javascript" and to link it with the first one thanks to the index of the tasks.

Something like :

var _anim = scene.animations.getByIndex(taskIndex);

var anim01 = this.playAnimation ({

     anim01.endTime = 3,  // seconds ?

     anim01.startTime = 0, // seconds ?

     anim01.currentTime = 0  // seconds ?

});

var anim02 = this.playAnimation ({

     anim02.endTime = 7, 

     anim02.startTime = 3,

     anim02.currentTime = 3

});

  

var anim03 = this.playAnimation ({

     anim03.endTime = 11,

     anim03.startTime = 7,

     anim03.currentTime = 7

});

var animXX = this.playAnimation ({

     animXX.endTime = Z, 

     animXX.startTime = X,

     animXX.currentTime = X

});

function NextTask()

{

      swith (taskIndex) {

          case 1:

               scene.activateAnimation(anim01);

               runtime.play();

          case 2:

               scene.activateAnimation(anim02);

               runtime.play();

          case 3:

               scene.activateAnimation(anim03);

               runtime.play();

            °

            °

            °

          case X:

               scene.activateAnimation(animX);

               runtime.play();

     }

}

Is this solution possible ? or totally wrong ?

And for the button, is "host.NextTask();" right ?

Thanks in advance for any help..

Regards.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines