diff options
author | Karl Berry <karl@freefriends.org> | 2012-03-28 23:00:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-03-28 23:00:05 +0000 |
commit | 91307a06cac2f83e7c0a0b36a2251a5af82f5852 (patch) | |
tree | 198c63b033b12fffb20134b042103e53000ddf8f /Master/texmf-dist/doc/latex/movie15/javascript | |
parent | 75cc2384b2e4ec2e62318ca65c602628ef4e7640 (diff) |
restore movie15, apparently poppler+okular support pdf movies
git-svn-id: svn://tug.org/texlive/trunk@25767 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/movie15/javascript')
3 files changed, 214 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/movie15/javascript/animation.js b/Master/texmf-dist/doc/latex/movie15/javascript/animation.js new file mode 100644 index 00000000000..f0789891f44 --- /dev/null +++ b/Master/texmf-dist/doc/latex/movie15/javascript/animation.js @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////// +// +// animation.js +// +// JavaScript for use with `3Djscript' option of \includemovie +// +// * Activates keyframe animation embedded in the u3d file. +// * Arrow keys `Down', `Up' can be used for speeding up and +// slowing down a running animation, key `Home' for reverting +// to the default speed. +// +// * Adjustable parameters: +var rate = 1; // 1 --> use original speed as default +var palindrome = true; // true --> play forth and back +// +///////////////////////////////////////////////////////////////// + +//get the first animation in the scene +var myAnim = scene.animations.getByIndex(0); +myAnim.wallTime = 0; +myAnim.speed = 1; +myAnim.myLength = myAnim.endTime - myAnim.startTime; +scene.activateAnimation(myAnim); + +//method to set animation speed +myAnim.setSpeed = function (speed) { + speed = Math.abs(speed); + this.wallTime /= speed/this.speed; //correct the walltime + this.speed = speed; +}; + +//method to change animation speed by a factor +myAnim.changeSpeed = function (mult) { + this.wallTime /= mult; //correct the walltime + this.speed *= mult; +}; + +//set default speed +myAnim.setSpeed(rate); + +//menu items +runtime.addCustomMenuItem("faster", "Faster (Key Up)", "default", 0); +runtime.addCustomMenuItem("slower", "Slower (Key Down)", "default", 0); +runtime.addCustomMenuItem("default", "Default Speed (Key Home)", "default", 0); + +//menu handler to control speed +menuEventHandler = new MenuEventHandler(); +menuEventHandler.onEvent = function(e) { + if (e.menuItemName == "faster") { + myAnim.changeSpeed(1.25); + } + else if (e.menuItemName == "slower") { + myAnim.changeSpeed(1/1.25); + } + else if (e.menuItemName == "default") { + myAnim.setSpeed(rate); + } +}; +runtime.addEventHandler(menuEventHandler); + +//key handler to control speed +keyEventHandler = new KeyEventHandler(); +keyEventHandler.onKeyDown = true; +keyEventHandler.onEvent = function(e) { + switch(e.characterCode) { + case 30: //key up + myAnim.changeSpeed(1.05); + break; + + case 31: //key down + myAnim.changeSpeed(1/1.05); + break; + + case 4: //key home + myAnim.setSpeed(rate); + break; + + case 1: //key end + myAnim.setSpeed(rate); + break; + } +}; +runtime.addEventHandler(keyEventHandler); + +//run the animation using a TimeEventHandler +myTimer = new TimeEventHandler(); +myTimer.onTimeChange = true; +myTimer.onEvent = function(e) { + myAnim.wallTime += e.deltaTime; + if (palindrome == true) { + myAnim.currentTime = + myAnim.startTime + + myAnim.myLength/2 + * (1 - Math.cos(Math.PI * myAnim.speed/myAnim.myLength * myAnim.wallTime)); + } else { + myAnim.currentTime = myAnim.startTime + + (myAnim.speed * myAnim.wallTime % myAnim.myLength); + } +}; +runtime.addEventHandler(myTimer); diff --git a/Master/texmf-dist/doc/latex/movie15/javascript/lights.js b/Master/texmf-dist/doc/latex/movie15/javascript/lights.js new file mode 100644 index 00000000000..ba367dfbb6b --- /dev/null +++ b/Master/texmf-dist/doc/latex/movie15/javascript/lights.js @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////// +// +// lights.js +// +// example JavaScript for use with `3Djscript' option of \includemovie +// +// * Adds light sources around the object for better illumination. +// +//////////////////////////////////////////////////////////////////////// +console.println(scene.lightScheme); +////first remove any scene lights +//for (var i = scene.lights.count - 1; i >= 0; i--) { +// scene.lights.removeByIndex(i); +//} +// +////new lights +////from left +//l1 = scene.createLight(); +//l1.color.set(1,1,1); +//l1.brightness = .4; +//l1.direction.set(1,0,0); +// +////from right +//l2 = scene.createLight(); +//l2.color.set(1,1,1); +//l2.brightness = .4; +//l2.direction.set(-1,0,0); +// +////from bottom +//l3 = scene.createLight(); +//l3.color.set(1,1,1); +//l3.brightness = .4; +//l3.direction.set(0,0,1); +// +////from top +//l4 = scene.createLight(); +//l4.color.set(1,1,1); +//l4.brightness = .4; +//l4.direction.set(0,0,-1); +// +////from front +//l5 = scene.createLight(); +//l5.color.set(1,1,1); +//l5.brightness = .4; +//l5.direction.set(0,1,0); +// +////from back +//l6 = scene.createLight(); +//l6.color.set(1,1,1); +//l6.brightness = .4; +//l6.direction.set(0,-1,0); diff --git a/Master/texmf-dist/doc/latex/movie15/javascript/turntable.js b/Master/texmf-dist/doc/latex/movie15/javascript/turntable.js new file mode 100644 index 00000000000..f839c5c3326 --- /dev/null +++ b/Master/texmf-dist/doc/latex/movie15/javascript/turntable.js @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////// +// +// turntable.js +// +// JavaScript for use with `3Djscript' option of \includemovie +// +// * Greatly improves the rotational behaviour of the 3D object, +// prevents it from tilting to the side while dragging the mouse. +// This is achieved by suppressing the rolling of the camera about +// its optical axis. +// +///////////////////////////////////////////////////////////////////// + +// maximum pitch (degrees from horizontal) of the camera +var max_alpha = 88; +var min_beta = 90 - max_alpha; // the complement +var cos_min_beta = Math.cos(min_beta * Math.PI/180); +var tan_min_beta = Math.tan(min_beta * Math.PI/180); + +var camera = scene.cameras.getByIndex(0); +camera.axis_up = camera.up.subtract(camera.position); +camera.axis_up.normalize(); + +//updates the vertical axis of rotation whenever a predefined view +//is selected from the drop down list in the 3D toolbar +var cameraEventHandler = new CameraEventHandler(); +cameraEventHandler.onEvent = function (e) { + camera.axis_up = camera.up.subtract(camera.position); + camera.axis_up.normalize(); +} +runtime.addEventHandler(cameraEventHandler); + +//suppresses camera rolling and limits camera pitch +var mouseEventHandler = new MouseEventHandler(); +mouseEventHandler.onMouseMove = true; +mouseEventHandler.onEvent = function (e) { + runtime.setCurrentTool(runtime.TOOL_NAME_ROTATE); + var c2c = camera.position.subtract(camera.targetPosition); + var roo = c2c.length; + c2c.normalize(); + cos_beta = c2c.dot(camera.axis_up); //cos of enclosed angle + + //correct the camera position if it is too high or too low + if(Math.abs(cos_beta) > cos_min_beta) { + //auxiliary vectors a & b + var a = camera.axis_up.scale(cos_beta); + var b = c2c.subtract(a); + b.normalize(); + b.scaleInPlace(tan_min_beta * a.length); + + c2c.set(a.add(b)); + c2c.normalize(); + + camera.position.set(camera.targetPosition.add(c2c.scale(roo))); + cos_beta = c2c.dot(camera.axis_up); + } + + //suppress rolling + camera.up.set( + camera.position.add(camera.axis_up).add(c2c.scale(-cos_beta)) + ); +}; +runtime.addEventHandler(mouseEventHandler); |