# 3D PDF cycling between views animation

I'm creating a 3D pdf with latex and movie15 and I added some views for my u3d object... Then I added turntable.js to manually change a view of the object... till now everything is fine

It is possible to add a jscript to automatically cycle all the views i.e. changing the view each second?

The best would be to associate the start stop to the standard animation toolbar button

here is the code

\documentclass{article}
\usepackage[3D]{movie15}
\usepackage{hyperref}
\begin{document}
\includemovie[
poster,
toolbar,
label=dice,
text=(dice.u3d),
3Droo=27,
3Dlights=Cube,
3Djscript=turntable.js,
3Dviews2=dice.vws
]{.5\linewidth}{.5\linewidth}{dice.u3d}\\
\end{document}

• Please provide the code, so that we can play with the code. So its impossible to help you (from my side).... – Peter Ebelsberger May 4 '16 at 21:46
• the code is just "turntable.js" from movie15 package mirrors.ctan.org/macros/latex/contrib/movie15/doc/javascript/… – maui May 4 '16 at 22:00
• A minimal working example is required. I suggest also to remove movie15 and replace to media9 package. The community for sure need a so called Minimal working example. Show, how you have tried so solve your problem and provide code, so that we can copy and past. So we ware able to play with the code... – Peter Ebelsberger May 4 '16 at 22:05
• @PeterEbelsberger the code is just "turntable.js" from movie15 package mirrors.ctan.org/macros/latex/contrib/movie15/doc/javascript/… and the code is the "dice" example in movie15.pdf \includemovie[ poster, toolbar, label=dice, text=(dice.u3d), 3Droo=27, 3Dlights=Cube, 3Djscript=turntable.js, 3Dviews2=dice.vws ]{ .5\linewidth }{ .5\linewidth }{dice.u3d} \movieref[ 3Dviewindex=N ]{dice}{Click here} (I would prefer to stay on movie15 for some compatibility issues on pdf viewers) I just would need to animate automatically the dice among the views... – maui May 4 '16 at 22:08
• Sorry, please read this meta.tex.stackexchange.com/questions/3300/… currently I am not able to help you unless you provide code which is compileable like "pdflatex mwe.tex" this is too less information for me. Maybe other users can help you. – Peter Ebelsberger May 4 '16 at 22:29

The media9 package should be used instead of the obsolete movie15, as in the example below.

Here is a JavaScript that cycles through the predefined views. The view changes every 5 seconds. As requested, the toolbar Play/Pause button can be used to pause/resume the animation. For further info about 3D JavaScript, see here.

var time=0;
var curViewIdx=0;

timeEvHnd=new TimeEventHandler();
timeEvHnd.onEvent=function(event) {
time += event.deltaTime;
if (time>=5) {
time = 0;
curViewIdx++;
if(curViewIdx == runtime.viewCount) curViewIdx=0;
runtime.setView(curViewIdx, true);
}
}

// runtime.pause();


The complete example (except dice.u3d)

\documentclass{article}
\usepackage{media9}
\usepackage{mwe} %example image file used as poster for 3D content
\usepackage{graphicx}
\usepackage{filecontents}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents*}{changeView.js}
var time=0;
var curViewIdx=0;

timeEvHnd=new TimeEventHandler();
timeEvHnd.onEvent=function(event) {
time += event.deltaTime;
if (time>=5) {
time = 0;
curViewIdx++;
if(curViewIdx == runtime.viewCount) curViewIdx=0;
runtime.setView(curViewIdx, true);
}
}

// runtime.pause();
\end{filecontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents*}{dice.vws}
VIEW=Front
ROO=27
END
VIEW=Back
ROO=27
C2C=0 1 0
END
VIEW=Left
ROO=27
C2C=-1 0 0
END
VIEW=Right
ROO=27
C2C=1 0 0
END
VIEW=Top
ROO=27
C2C=0 0 1
END
VIEW=Bottom
ROO=27
C2C=0 0 -1
END
VIEW=Fish Eye at Centre
AAC=130
END
\end{filecontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\includemedia[
width=0.5\linewidth,height=0.5\linewidth,
activate=pageopen,

• @user3084508 The poster image/text is inserted in the first mandatory argument. Here it is empty and you won't see anything in alternative readers or in AR with disabled 3D content. Just use \includegraphics{...} in the poster argument to provide a poster image. – AlexG May 9 '16 at 8:00
• Hi @AlexG I can confirm that I cannot see the background image using media9 not using \includegraphics nor using wallpaper package in Foxit Reader windows 8... \documentclass[a4paper]{article} \usepackage{media9} \usepackage{wallpaper} \addtolength{\wpXoffset}{-0.8cm} \addtolength{\wpYoffset}{2cm} \begin{document} \includemedia[ .... .... ]{\includegraphics{dice-bg.png}}{dice.u3d} \ThisCenterWallPaper{1.0}{frame.png} \end{document} the area where the 3d object is on, will not displayed correctly (the strange is that I can see it on the Thumbnails) ... – maui May 9 '16 at 13:03