3D PDF 视图间循环动画

3D PDF 视图间循环动画

我正在用 latex 和 movie15 创建 3D pdf,并为我的 u3d 对象添加了一些视图...然后我添加了turntable.js手动更改对象的视图...到目前为止一切都很好

是否可以添加一个 jscript 来自动循环所有视图,即每秒更改一次视图?

最好的方法是将开始停止与标准动画工具栏按钮关联起来

这是代码

\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}\\
\movieref[3Dviewindex=N]{dice}{Click here} ...\\
\movieref[3Dcalculate=60]{dice}{This link} ...
\end{document}
  1. 骰子.u3d
  2. 骰子
  3. 转盘.js

答案1

media9应该使用 包而不是过时的 包,movie15如下例所示。

以下是循环显示预定义视图的 JavaScript。视图每 5 秒更改一次。根据要求,工具栏的“播放/暂停”按钮可用于暂停/恢复动画。有关 3D JavaScript 的更多信息,请参阅这里

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.addEventHandler(timeEvHnd);
// runtime.pause();

完整示例(除骰子.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.addEventHandler(timeEvHnd);
// 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,
  3Dtoolbar, 3Dmenu,
  3Dviews=dice.vws,
  add3Djscript=3Dspin­tool.js, % turntable rotation of 3D object
  add3Djscript=changeView.js
]{\includegraphics{example-image}}{dice.u3d}

\end{document}

相关内容