diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/media9')
-rw-r--r-- | Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js | 333 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/media9/media9.sty | 10 |
2 files changed, 166 insertions, 177 deletions
diff --git a/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js b/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js index 20bf5a8a55a..a0b04d915ae 100644 --- a/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js +++ b/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js @@ -4,7 +4,7 @@ // // 3Dmenu.js // -// version 20120912 +// version 20131126 // //////////////////////////////////////////////////////////////////////////////// // @@ -30,13 +30,15 @@ // // Toggle switch to add or remove a cross section into or from the current // view. The cross section can be moved in the x, y, z directions using x, -// y, z and X, Y, Z keys on the keyboard and be tilted against and spun -// around the upright Z axis using the Up/Down and Left/Right arrow keys. +// y, z and X, Y, Z keys on the keyboard, be tilted against and spun +// around the upright Z axis using the Up/Down and Left/Right arrow keys +// and caled using the s and S keys. // -// 2.) Enables manipulation of position and orientation of indiviual parts in -// the 3D scene. Parts which have been selected with the mouse can be -// moved around and rotated like the cross section as described above, as -// well as scaled using the s and S keys. +// 2.) Enables manipulation of position and orientation of indiviual parts and +// groups of parts in the 3D scene. Parts which have been selected with the +// mouse can be scaled moved around and rotated like the cross section as +// described above. To spin the parts around their local up-axis, keep +// Control key pressed while using the Up/Down and Left/Right arrow keys. // // This work may be distributed and/or modified under the // conditions of the LaTeX Project Public License, either version 1.3 @@ -55,7 +57,7 @@ // set of points; see: http://www.inf.ethz.ch/personal/gaertner/miniball.html // //////////////////////////////////////////////////////////////////////////////// -//host.console.show(); +host.console.show(); //constructor for doubly linked list function List(){ @@ -498,78 +500,81 @@ function get3Dview () { } if(defaultrender!='Solid') res+=' RENDERMODE='+defaultrender+'\n'; - for(var i=0;i<scene.meshes.count;i++){ - var mesh=scene.meshes.getByIndex(i); - var meshUTFName = ''; - for (var j=0; j<mesh.name.length; j++) { - var theUnicode = mesh.name.charCodeAt(j).toString(16); + for(var i=0;i<scene.nodes.count;i++){ + var nd=scene.nodes.getByIndex(i); + if(nd.constructor.name!='Mesh'&&nd.constructor.name!='Node3') continue; + var ndUTFName = ''; + for (var j=0; j<nd.name.length; j++) { + var theUnicode = nd.name.charCodeAt(j).toString(16); while (theUnicode.length<4) theUnicode = '0' + theUnicode; - meshUTFName += theUnicode; + ndUTFName += theUnicode; } - var end=mesh.name.lastIndexOf('.'); - if(end>0) var meshUserName=mesh.name.substr(0,end); - else var meshUserName=mesh.name; - respart=' PART='+meshUserName+'\n'; - respart+=' UTF16NAME='+meshUTFName+'\n'; + var end=nd.name.lastIndexOf('.'); + if(end>0) var ndUserName=nd.name.substr(0,end); + else var ndUserName=nd.name; + respart=' PART='+ndUserName+'\n'; + respart+=' UTF16NAME='+ndUTFName+'\n'; defaultvals=true; - if(!mesh.visible){ + if(!nd.visible){ respart+=' VISIBLE=false\n'; defaultvals=false; } - if(mesh.opacity<1.0){ - respart+=' OPACITY='+mesh.opacity+'\n'; + if(nd.opacity<1.0){ + respart+=' OPACITY='+nd.opacity+'\n'; defaultvals=false; } - currender=defaultrender; - switch(mesh.renderMode){ - case scene.RENDER_MODE_BOUNDING_BOX: - currender='BoundingBox';break; - case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX: - currender='TransparentBoundingBox';break; - case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX_OUTLINE: - currender='TransparentBoundingBoxOutline';break; - case scene.RENDER_MODE_VERTICES: - currender='Vertices';break; - case scene.RENDER_MODE_SHADED_VERTICES: - currender='ShadedVertices';break; - case scene.RENDER_MODE_WIREFRAME: - currender='Wireframe';break; - case scene.RENDER_MODE_SHADED_WIREFRAME: - currender='ShadedWireframe';break; - case scene.RENDER_MODE_SOLID: - currender='Solid';break; - case scene.RENDER_MODE_TRANSPARENT: - currender='Transparent';break; - case scene.RENDER_MODE_SOLID_WIREFRAME: - currender='SolidWireframe';break; - case scene.RENDER_MODE_TRANSPARENT_WIREFRAME: - currender='TransparentWireframe';break; - case scene.RENDER_MODE_ILLUSTRATION: - currender='Illustration';break; - case scene.RENDER_MODE_SOLID_OUTLINE: - currender='SolidOutline';break; - case scene.RENDER_MODE_SHADED_ILLUSTRATION: - currender='ShadedIllustration';break; - case scene.RENDER_MODE_HIDDEN_WIREFRAME: - currender='HiddenWireframe';break; - //case scene.RENDER_MODE_DEFAULT: - // currender='Default';break; - } - if(currender!=defaultrender){ - respart+=' RENDERMODE='+currender+'\n'; - defaultvals=false; + if(nd.constructor.name=='Mesh'){ + currender=defaultrender; + switch(nd.renderMode){ + case scene.RENDER_MODE_BOUNDING_BOX: + currender='BoundingBox';break; + case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX: + currender='TransparentBoundingBox';break; + case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX_OUTLINE: + currender='TransparentBoundingBoxOutline';break; + case scene.RENDER_MODE_VERTICES: + currender='Vertices';break; + case scene.RENDER_MODE_SHADED_VERTICES: + currender='ShadedVertices';break; + case scene.RENDER_MODE_WIREFRAME: + currender='Wireframe';break; + case scene.RENDER_MODE_SHADED_WIREFRAME: + currender='ShadedWireframe';break; + case scene.RENDER_MODE_SOLID: + currender='Solid';break; + case scene.RENDER_MODE_TRANSPARENT: + currender='Transparent';break; + case scene.RENDER_MODE_SOLID_WIREFRAME: + currender='SolidWireframe';break; + case scene.RENDER_MODE_TRANSPARENT_WIREFRAME: + currender='TransparentWireframe';break; + case scene.RENDER_MODE_ILLUSTRATION: + currender='Illustration';break; + case scene.RENDER_MODE_SOLID_OUTLINE: + currender='SolidOutline';break; + case scene.RENDER_MODE_SHADED_ILLUSTRATION: + currender='ShadedIllustration';break; + case scene.RENDER_MODE_HIDDEN_WIREFRAME: + currender='HiddenWireframe';break; + //case scene.RENDER_MODE_DEFAULT: + // currender='Default';break; + } + if(currender!=defaultrender){ + respart+=' RENDERMODE='+currender+'\n'; + defaultvals=false; + } } - if(!mesh.transform.isEqual(origtrans[mesh.name])){ - var lvec=mesh.transform.transformDirection(new Vector3(1,0,0)); - var uvec=mesh.transform.transformDirection(new Vector3(0,1,0)); - var vvec=mesh.transform.transformDirection(new Vector3(0,0,1)); + if(!nd.transform.isEqual(origtrans[nd.name])){ + var lvec=nd.transform.transformDirection(new Vector3(1,0,0)); + var uvec=nd.transform.transformDirection(new Vector3(0,1,0)); + var vvec=nd.transform.transformDirection(new Vector3(0,0,1)); respart+=' TRANSFORM=' +lvec.x+' '+lvec.y+' '+lvec.z+' ' +uvec.x+' '+uvec.y+' '+uvec.z+' ' +vvec.x+' '+vvec.y+' '+vvec.z+' ' - +mesh.transform.translation.x+' ' - +mesh.transform.translation.y+' ' - +mesh.transform.translation.z+'\n'; + +nd.transform.translation.x+' ' + +nd.transform.translation.y+' ' + +nd.transform.translation.z+'\n'; defaultvals=false; } respart+=' END\n'; @@ -626,14 +631,14 @@ menuEventHandler.onEvent = function(e) { }; runtime.addEventHandler(menuEventHandler); -//global variable taking reference to currently selected mesh node; -var mshSelected=null; +//global variable taking reference to currently selected node; +var target=null; selectionEventHandler=new SelectionEventHandler(); selectionEventHandler.onEvent=function(e){ - if(e.selected && e.node.constructor.name=="Mesh"){ - mshSelected=e.node; + if(e.selected){ + target=e.node; }else{ - mshSelected=null; + target=null; } } runtime.addEventHandler(selectionEventHandler); @@ -651,18 +656,23 @@ cameraEventHandler.onEvent=function(e){ runtime.addCustomMenuItem("csection", "Cross Section", "checked", 1); } } + + for(var i=0; i<rot4x4.length; i++){ + rot4x4[i].setIdentity() + } } runtime.addEventHandler(cameraEventHandler); -//key event handler for moving, spinning and tilting objects +var rot4x4=new Array(); //keeps track of spin and tilt axes transformations +//key event handler for scaling moving, spinning and tilting objects keyEventHandler=new KeyEventHandler(); keyEventHandler.onEvent=function(e){ - var target=null; var backtrans=new Matrix4x4(); - if(mshSelected){ - target=mshSelected; - var trans=target.transform; - var parent=target.parent; + if(target) { + var backtrans=new Matrix4x4(); + var trgt=target; + var trans=trgt.transform; + var parent=trgt.parent; while(parent.transform){ //build local to world transformation matrix trans.multiplyInPlace(parent.transform); @@ -672,91 +682,92 @@ keyEventHandler.onEvent=function(e){ } backtrans.transposeInPlace(); }else{ + var ndcnt=scene.nodes.count; try { - target=scene.nodes.getByName("Clipping Plane"); + var trgt=scene.nodes.getByName("Clipping Plane"); }catch(e){ - var ndcnt=scene.nodes.count; - target=scene.createClippingPlane(); - if(ndcnt!=scene.nodes.count){ - target.remove(); - target=null; - } + var trgt=scene.createClippingPlane(); } + if(ndcnt==scene.nodes.count){ + var trans=trgt.transform; + }else{ + trgt.remove(); + return; + } + } + + var tname=trgt.name; + if(typeof(rot4x4[tname])=='undefined') rot4x4[tname]=new Matrix4x4(); + var tiltAxis=rot4x4[tname].transformDirection(new Vector3(0,1,0)); + var spinAxis=rot4x4[tname].transformDirection(new Vector3(0,0,1)); + + //get the centre of the mesh + if(trgt.constructor.name=='Mesh'){ + var centre=trans.transformPosition(trgt.computeBoundingBox().center); + }else{ //part group (Node3 parent node) + var centre=new Vector3(trans.translation); } - if(!target) return; switch(e.characterCode){ case 30://tilt up - tiltTarget(target, -Math.PI/900); + rot4x4[tname].rotateAboutLineInPlace(-Math.PI/900,rot4x4[tname].translation,tiltAxis); + trans.rotateAboutLineInPlace(-Math.PI/900,centre,tiltAxis); break; case 31://tilt down - tiltTarget(target, Math.PI/900); + rot4x4[tname].rotateAboutLineInPlace(Math.PI/900,rot4x4[tname].translation,tiltAxis); + trans.rotateAboutLineInPlace(Math.PI/900,centre,tiltAxis); break; case 28://spin right - spinTarget(target, -Math.PI/900); + if(e.ctrlKeyDown&&target){ + rot4x4[tname].rotateAboutLineInPlace(-Math.PI/900,rot4x4[tname].translation,spinAxis); + trans.rotateAboutLineInPlace(-Math.PI/900,centre,spinAxis); + }else{//allow clipping plane be spun around world z only + rot4x4[tname].rotateAboutLineInPlace(-Math.PI/900,rot4x4[tname].translation,new Vector3(0,0,1)); + trans.rotateAboutLineInPlace(-Math.PI/900,centre,new Vector3(0,0,1)); + } break; case 29://spin left - spinTarget(target, Math.PI/900); + if(e.ctrlKeyDown&&target){ + rot4x4[tname].rotateAboutLineInPlace(Math.PI/900,rot4x4[tname].translation,spinAxis); + trans.rotateAboutLineInPlace(Math.PI/900,centre,spinAxis); + }else{ + rot4x4[tname].rotateAboutLineInPlace(Math.PI/900,rot4x4[tname].translation,new Vector3(0,0,1)); + trans.rotateAboutLineInPlace(Math.PI/900,centre,new Vector3(0,0,1)); + } break; case 120: //x - translateTarget(target, new Vector3(1,0,0), e); + translateTarget(trans, new Vector3(1,0,0), e); break; case 121: //y - translateTarget(target, new Vector3(0,1,0), e); + translateTarget(trans, new Vector3(0,1,0), e); break; case 122: //z - translateTarget(target, new Vector3(0,0,1), e); + translateTarget(trans, new Vector3(0,0,1), e); break; case 88: //shift + x - translateTarget(target, new Vector3(-1,0,0), e); + translateTarget(trans, new Vector3(-1,0,0), e); break; case 89: //shift + y - translateTarget(target, new Vector3(0,-1,0), e); + translateTarget(trans, new Vector3(0,-1,0), e); break; case 90: //shift + z - translateTarget(target, new Vector3(0,0,-1), e); + translateTarget(trans, new Vector3(0,0,-1), e); break; case 115: //s - scaleTarget(target, 1, e); + trans.translateInPlace(centre.scale(-1)); + trans.scaleInPlace(1.01); + trans.translateInPlace(centre.scale(1)); break; case 83: //shift + s - scaleTarget(target, -1, e); + trans.translateInPlace(centre.scale(-1)); + trans.scaleInPlace(1/1.01); + trans.translateInPlace(centre.scale(1)); break; } - if(mshSelected) - target.transform.multiplyInPlace(backtrans); + trans.multiplyInPlace(backtrans); } runtime.addEventHandler(keyEventHandler); -function tiltTarget(t,a){ - var centre=new Vector3(); - if(mshSelected) { - centre.set(t.transform.transformPosition(t.computeBoundingBox().center)); - }else{ - centre.set(t.transform.translation); - } - var rotVec=t.transform.transformDirection(new Vector3(0,1,0)); - rotVec.normalize(); - t.transform.translateInPlace(centre.scale(-1)); - t.transform.rotateAboutVectorInPlace(a, rotVec); - t.transform.translateInPlace(centre); -} - -function spinTarget(t,a){ - var centre=new Vector3(); - var rotVec=new Vector3(0,0,1); - if(mshSelected) { - centre.set(t.transform.transformPosition(t.computeBoundingBox().center)); - rotVec.set(t.transform.transformDirection(rotVec)); - rotVec.normalize(); - }else{ - centre.set(t.transform.translation); - } - t.transform.translateInPlace(centre.scale(-1)); - t.transform.rotateAboutVectorInPlace(a, rotVec); - t.transform.translateInPlace(centre); -} - -//translates object by amount calculated based on Canvas size +//translates object by amount calculated from Canvas size function translateTarget(t, d, e){ var cam=scene.cameras.getByIndex(0); if(cam.projectionType==cam.TYPE_PERSPECTIVE){ @@ -767,34 +778,7 @@ function translateTarget(t, d, e){ var scale=cam.viewPlaneSize/2 /Math.min(e.canvasPixelWidth,e.canvasPixelHeight); } - t.transform.translateInPlace(d.scale(scale)); -} - -//scales object by amount calculated based on Canvas size -function scaleTarget(t, d, e){ - if(mshSelected) { - var bbox=t.computeBoundingBox(); - var diag=new Vector3(bbox.max.x, bbox.max.y, bbox.max.z); - diag.subtractInPlace(bbox.min); - var dlen=diag.length; - - var cam=scene.cameras.getByIndex(0); - if(cam.projectionType==cam.TYPE_PERSPECTIVE){ - var scale=Math.tan(cam.fov/2) - *cam.targetPosition.subtract(cam.position).length - /dlen - /Math.min(e.canvasPixelWidth,e.canvasPixelHeight); - }else{ - var scale=cam.viewPlaneSize/2 - /dlen - /Math.min(e.canvasPixelWidth,e.canvasPixelHeight); - } - var centre=new Vector3(); - centre.set(t.transform.transformPosition(t.computeBoundingBox().center)); - t.transform.translateInPlace(centre.scale(-1)); - t.transform.scaleInPlace(1+d*scale); - t.transform.translateInPlace(centre); - } + t.translateInPlace(d.scale(scale)); } function addremoveClipPlane(chk) { @@ -803,21 +787,19 @@ function addremoveClipPlane(chk) { //add Clipping Plane and place its center either into the camera target //position or into the centre of the currently selected mesh node var centre=new Vector3(); - if(mshSelected){ - //local to parent transformation matrix - var trans=mshSelected.transform; - //build local to world transformation matrix by recursively - //multiplying the parent's transf. matrix on the right - var parent=mshSelected.parent; + if(target){ + var trans=target.transform; + var parent=target.parent; while(parent.transform){ trans=trans.multiply(parent.transform); parent=parent.parent; } - //get the centre of the mesh (local coordinates) - centre.set(mshSelected.computeBoundingBox().center); - //transform the local coordinates to world coords - centre.set(trans.transformPosition(centre)); - mshSelected=null; + if(target.constructor.name=='Mesh'){ + var centre=trans.transformPosition(target.computeBoundingBox().center); + }else{ + var centre=new Vector3(trans.translation); + } + target=null; }else{ centre.set(scene.cameras.getByIndex(0).targetPosition); } @@ -829,13 +811,14 @@ function addremoveClipPlane(chk) { } } -//function to store current transformation matrix of all mesh nodes in the scene +//function to store current transformation matrix of all nodes in the scene function getCurTrans() { - var nc=scene.meshes.count; + var nc=scene.nodes.count; var tA=new Array(nc); for(var i=0; i<nc; i++){ - var cm=scene.meshes.getByIndex(i); - tA[cm.name]=new Matrix4x4(cm.transform); + var nd=scene.nodes.getByIndex(i); + if(nd.constructor.name!='Mesh'&&nd.constructor.name!='Node3') continue; + tA[nd.name]=new Matrix4x4(nd.transform); } return tA; } @@ -843,8 +826,8 @@ function getCurTrans() { //function to restore transformation matrices given as arg function restoreTrans(tA) { for(var i=0; i<tA.length; i++){ - var msh=scene.meshes.getByIndex(i); - msh.transform.set(tA[msh.name]); + var nd=scene.nodes.getByIndex(i); + nd.transform.set(tA[nd.name]); } } diff --git a/Master/texmf-dist/tex/latex/media9/media9.sty b/Master/texmf-dist/tex/latex/media9/media9.sty index 0f381901d79..d19a615d251 100644 --- a/Master/texmf-dist/tex/latex/media9/media9.sty +++ b/Master/texmf-dist/tex/latex/media9/media9.sty @@ -42,8 +42,8 @@ \RequirePackage{atbegshi} \RequirePackage{tikz} -\def\g@mix@date@tl{2013/11/15} -\def\g@mix@version@tl{0.35} +\def\g@mix@date@tl{2013/11/26} +\def\g@mix@version@tl{0.36} \def\g@mix@liiikerneldate{2013/07/28} \def\g@mix@liiipkgdate{2013/07/28} @@ -1179,6 +1179,12 @@ \tl_greplace_all:Nnn\g_mix_flashvars_tl{=~}{=} \tl_gtrim_spaces:N\g_mix_flashvars_tl \mix_scale:n{\l_mix_poster_box} + \bool_if:nT{ + \dim_compare_p:n{\l_mix_tt_tl=\c_zero_dim}|| + \dim_compare_p:n{\l_mix_wd_tl=\c_zero_dim} + }{ + \bool_gset_false:N\g_mix_usrpbtn_bool + } \bool_if:NTF\g_mix_usrdraft_bool{ \tl_if_empty:NF\g_mix_usrlabel_tl{ \mix_keytoaux_now:nn{ann@\g_mix_usrlabel_tl}{draft} |