I have this very simple LaTeX file that uses the media9 package to insert 3D objects. I want to animate parts of the 3D object using Javascript, preferably on a button click.
My problem is that when I call my Javascript function through a TimeEventHandler or a MouseClickEvent, the animation works well. But when I create a \mediabutton
to call the very same function, I get an error.
The following is a part of my LaTeX code (where animate()
is a function defined in animation.js):
\includemedia[
label=model,
activate=pageopen,
add3Djscript=animation.js
]{}{model.u3d}
\mediabutton[
jsaction=model:{annotRM[`model'].context3D.animate();}
]{\fbox{Play Animation}}
Here is the simplest version of my JS code that still fails:
cube=scene.meshes.getByName("Cube");
function animate(){
cube.visible=false;
}
While debugging, I found that I get the following error in JS and I have no idea why.
SyntaxError: illegal character
1:Field:Mouse Up
I even tried using media9's sample code and files, and I get the same error even though they should work perfectly. (The error only happens with the sample files that use \mediabutton
with Javascript; the other samples work properly.)
I've been trying to figure out whether this was a problem with LaTeX or JS, and seeing that the JS code works perfectly as long as I don't use the button, I figured I'd try to find any solutions here.
No one else seems to have any problems attaching JS functions to media buttons. Any insight would be very much appreciated.
If it matters, I'm using MikTeX pdflatex.
animation.js
which is part of themedia9
package doesn't define a functionanimate()
.`model'
is the character that JS complains about. Replace it with a single quote.