diff options
author | Karl Berry <karl@freefriends.org> | 2013-12-05 00:08:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-12-05 00:08:32 +0000 |
commit | 1f584cd4b06d66903c0ff82dcd1a7f03066a081d (patch) | |
tree | 54fabb586c1fb7ec0003185f09e4427d9d2a06d1 /Master/texmf-dist/tex/latex/media9 | |
parent | 827aa8a6199555795f58fb9d81e0c69c11c09ce6 (diff) |
media9 (4dec13)
git-svn-id: svn://tug.org/texlive/trunk@32322 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/media9')
-rw-r--r-- | Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js | 118 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/media9/media9.sty | 21 |
2 files changed, 78 insertions, 61 deletions
diff --git a/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js b/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js index 8d791a9734f..17dd99b60b0 100644 --- a/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js +++ b/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js @@ -1,10 +1,10 @@ //////////////////////////////////////////////////////////////////////////////// // -// (C) 2012, Alexander Grahn +// (C) 2012--today, Alexander Grahn // // 3Dmenu.js // -// version 20131127 +// version 20131204 // //////////////////////////////////////////////////////////////////////////////// // @@ -500,10 +500,17 @@ function get3Dview () { } if(defaultrender!='Solid') res+=' RENDERMODE='+defaultrender+'\n'; + + //detect existing Clipping Plane (3D Cross Section) + var clip=null; + if( + clip=scene.nodes.getByName('$$$$$$')|| + clip=scene.nodes.getByName('Clipping Plane') + ); 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 = ''; + if(nd==clip||nd.name=='') 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; @@ -564,7 +571,7 @@ function get3Dview () { defaultvals=false; } } - if(!nd.transform.isEqual(origtrans[nd.name])){ + if(origtrans[nd.name]&&!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)); @@ -580,17 +587,6 @@ function get3Dview () { respart+=' END\n'; if(!defaultvals) res+=respart; } - - //detect existing Clipping Plane (3D Cross Section) - var clip=null; - for(i=0; i<scene.nodes.count; i++){ - if( - scene.nodes.getByIndex(i).name == '$$$$$$' || - scene.nodes.getByIndex(i).name == 'Clipping Plane' - ) { - clip=scene.nodes.getByIndex(i); - } - } if(clip){ var centre=clip.transform.translation; var normal=clip.transform.transformDirection(new Vector3(0,0,1)); @@ -635,7 +631,7 @@ runtime.addEventHandler(menuEventHandler); var target=null; selectionEventHandler=new SelectionEventHandler(); selectionEventHandler.onEvent=function(e){ - if(e.selected){ + if(e.selected&&e.node.name!=''){ target=e.node; }else{ target=null; @@ -645,21 +641,22 @@ runtime.addEventHandler(selectionEventHandler); cameraEventHandler=new CameraEventHandler(); cameraEventHandler.onEvent=function(e){ + var clip=null; runtime.removeCustomMenuItem("csection"); runtime.addCustomMenuItem("csection", "Cross Section", "checked", 0); - for(i=0; i<scene.nodes.count; i++){ - if( - scene.nodes.getByIndex(i).name == '$$$$$$' || - scene.nodes.getByIndex(i).name == 'Clipping Plane' - ) { - runtime.removeCustomMenuItem("csection"); - runtime.addCustomMenuItem("csection", "Cross Section", "checked", 1); - } + if(clip=scene.nodes.getByName('$$$$$$')|| + scene.nodes.getByName('Clipping Plane')){ + runtime.removeCustomMenuItem("csection"); + runtime.addCustomMenuItem("csection", "Cross Section", "checked", 1); } - - for(var i=0; i<rot4x4.length; i++){ - rot4x4[i].setIdentity() + if(clip){//plane in predefined views must be rotated by 90 deg around normal + clip.transform.rotateAboutLineInPlace( + Math.PI/2,clip.transform.translation, + clip.transform.transformDirection(new Vector3(0,0,1)) + ); } + for(var i=0; i<rot4x4.length; i++){rot4x4[i].setIdentity()} + target=null; } runtime.addEventHandler(cameraEventHandler); @@ -668,9 +665,10 @@ var rot4x4=new Array(); //keeps track of spin and tilt axes transformations keyEventHandler=new KeyEventHandler(); keyEventHandler.onEvent=function(e){ var backtrans=new Matrix4x4(); + var trgt=null; if(target) { + trgt=target; var backtrans=new Matrix4x4(); - var trgt=target; var trans=trgt.transform; var parent=trgt.parent; while(parent.transform){ @@ -682,55 +680,53 @@ keyEventHandler.onEvent=function(e){ } backtrans.transposeInPlace(); }else{ - var ndcnt=scene.nodes.count; - try { - var trgt=scene.nodes.getByName("Clipping Plane"); - }catch(e){ - var trgt=scene.createClippingPlane(); - } - if(ndcnt==scene.nodes.count){ - var trans=trgt.transform; - }else{ - trgt.remove(); - return; - } + if( + trgt=scene.nodes.getByName('$$$$$$')|| + trgt=scene.nodes.getByName('Clipping Plane') + ) var trans=trgt.transform; } + if(!trgt) return; var tname=trgt.name; if(typeof(rot4x4[tname])=='undefined') rot4x4[tname]=new Matrix4x4(); - var tiltAxis=rot4x4[tname].transformDirection(new Vector3(0,1,0)); + if(target) + var tiltAxis=rot4x4[tname].transformDirection(new Vector3(0,1,0)); + else + var tiltAxis=trans.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'){ + if(target&&trgt.constructor.name=='Mesh'){ var centre=trans.transformPosition(trgt.computeBoundingBox().center); - }else{ //part group (Node3 parent node) + }else{ //part group (Node3 parent node, clipping plane) var centre=new Vector3(trans.translation); } switch(e.characterCode){ case 30://tilt up - rot4x4[tname].rotateAboutLineInPlace(-Math.PI/900,rot4x4[tname].translation,tiltAxis); + rot4x4[tname].rotateAboutLineInPlace( + -Math.PI/900,rot4x4[tname].translation,tiltAxis); trans.rotateAboutLineInPlace(-Math.PI/900,centre,tiltAxis); break; case 31://tilt down - rot4x4[tname].rotateAboutLineInPlace(Math.PI/900,rot4x4[tname].translation,tiltAxis); + rot4x4[tname].rotateAboutLineInPlace( + Math.PI/900,rot4x4[tname].translation,tiltAxis); trans.rotateAboutLineInPlace(Math.PI/900,centre,tiltAxis); break; case 28://spin right 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)); + }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 29://spin left 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)); + 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; @@ -782,6 +778,7 @@ function translateTarget(t, d, e){ } function addremoveClipPlane(chk) { + var curTrans=getCurTrans(); var clip=scene.createClippingPlane(); if(chk){ //add Clipping Plane and place its center either into the camera target @@ -807,17 +804,22 @@ function addremoveClipPlane(chk) { new Vector3(0,0,0), new Vector3(1,0,0), new Vector3(0,1,0)); clip.transform.translateInPlace(centre); }else{ - clip.remove(); + if( + scene.nodes.getByName('$$$$$$')|| + scene.nodes.getByName('Clipping Plane') + ){ + clip.remove(); + } } + restoreTrans(curTrans); } //function to store current transformation matrix of all nodes in the scene function getCurTrans() { - var nc=scene.nodes.count; - var tA=new Array(nc); - for(var i=0; i<nc; i++){ + var tA=new Array(); + 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; + if(nd.name=='') continue; tA[nd.name]=new Matrix4x4(nd.transform); } return tA; @@ -825,9 +827,9 @@ function getCurTrans() { //function to restore transformation matrices given as arg function restoreTrans(tA) { - for(var i=0; i<tA.length; i++){ + for(var i=0; i<scene.nodes.count; i++){ var nd=scene.nodes.getByIndex(i); - nd.transform.set(tA[nd.name]); + if(tA[nd.name]) 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 23f9cdb07da..1bb6ab1b1b2 100644 --- a/Master/texmf-dist/tex/latex/media9/media9.sty +++ b/Master/texmf-dist/tex/latex/media9/media9.sty @@ -4,7 +4,7 @@ % % multimedia inclusion package % -% Copyright 2012--\today Alexander Grahn +% Copyright 2012--\today, Alexander Grahn % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -42,8 +42,8 @@ \RequirePackage{atbegshi} \RequirePackage{tikz} -\def\g@mix@date@tl{2013/11/27} -\def\g@mix@version@tl{0.37} +\def\g@mix@date@tl{2013/12/04} +\def\g@mix@version@tl{0.38} \def\g@mix@liiikerneldate{2013/07/28} \def\g@mix@liiipkgdate{2013/07/28} @@ -1047,6 +1047,15 @@ } } +\msg_set:nnn{media9}{zero~size}{ + Media~annotation~\msg_line_context:\ has~zero\\ + size~in~at~least~one~dimension.\\\\ + Provide~a~poster~text~with~non-zero~width~and\\ + height,~or~specify~a~suitable~size~via~`width'\\ + and~`height'~options. +} + + %calculates widget dimensions from natural ones, taking resizing options %into account \int_new:N\g_mix_resizeflag_int% resizing flags according to options given @@ -1136,6 +1145,12 @@ }{ \box_resize:Nnn#1{\l_mix_wd_tl}{\l_mix_tt_tl} } + \bool_if:nT{ + \dim_compare_p:n{\l_mix_wd_tl=\c_zero_dim} || + \dim_compare_p:n{\l_mix_tt_tl=\c_zero_dim} + }{ + \msg_warning:nn{media9}{zero~size} + } } \bool_new:N\g_mix_iiid_bool |