From: Clayton C. <drf...@gm...> - 2014-09-23 18:38:27
|
Unless you really want to do this in js you could use a touchsensor Sorry away from comp I think theres a few example on x3dom.org simple examples page or try searching for x3d touchsensor I'll take a look at your code later n have more insights On 23 September, 2014 2:19:35 AM PDT, Philipp Lebrenz <phi...@un...> wrote: >Hello, > >i want to animate a hand gear. In this example I have tried it with a >cylinder. Onclick the cylinder should perform a quarter rotation and >stop there (no looping). When I'm now going to click on the cylinder >once more, he should move back to the basic postion. I've tried this so >far: > >var down = false; > ><x3d width='500px' height='400px'> > <scene> > <transform DEF="cyl" translation='3 0 0'> > <shape onclick="hand_gear();"> > <appearance> > <material diffuseColor='0 0 1'></material> > </appearance> > <cylinder radius='0.2' height='4'></cylinder> > </shape> > </transform> > ><timeSensor id="time_cyl" DEF="time_cyl" cycleInterval="inf" >loop="true"></timeSensor> ><orientationInterpolator id="rot_cyl" DEF='rot_cyl' key='0 1' >keyValue='1 0 0 0 1 0 0 1.57079'></orientationInterpolator> ><Route fromNode="time_cyl" fromField ="fraction_changed" >toNode="rot_cyl" toField="set_fraction"></Route> ><Route fromNode="rot_cyl" fromField ="value_changed" toNode="cyl" >toField="set_rotation"></Route> > </scene> ></x3d> > >And here is the JavaScript part: > >function hand_gear() { > /*-------------------------- > document.getElementById("time_cyl").setAttribute("enabled", "false"); > if(down) { >document.getElementById("rot_cyl").setAttribute("keyValue", '0 1 0 >1.57079 0 1 0 0'); > } else { >document.getElementById("rot_cyl").setAttribute("keyValue", '0 1 0 0 0 >1 0 1.57079'); > } > document.getElementById("time_cyl").setAttribute("enabled", "true"); > ------------------------------*/ > >document.getElementById("time_cyl").setAttribute("cycleInterval", "3"); > document.getElementById("time_cyl").setAttribute("loop", "false"); > > //down=!down; > } > >When I execute the code without the parts which are commented out, the >cylinder performs a quarter rotation and is stops then there. >Unfortunately when I'm clicking again at the cyliner the animation >starts not at the basic position. >When I'm not comment the parts out, then nothing works. But with those >part I wanted to add the "toogle" behaviour. >Any ideas, how to solve this problem? >Thank you!! > >Best regards, >Philipp Lebrenz > > >------------------------------------------------------------------------ > >------------------------------------------------------------------------------ >Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer >Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS >Reports >Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper >Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer >http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk > >------------------------------------------------------------------------ > >_______________________________________________ >X3dom-users mailing list >X3d...@li... >https://lists.sourceforge.net/lists/listinfo/x3dom-users -- Sent from my Android |