| jo4545 2005-04-05, 12:34 pm |
| I have an animation which is basically a rotation. i want to ba able to start and stop the animation with a mouse click. This works with the below script. However, the animation is already on when i open the file so the first click turns it off and the second click turns it on. i want it so that the first click starts the animation but i cant get it to work
DEF blades Transform {
translation -50.03 26.05 -23.47
rotation -1 0 0 -3.142
scale 0.009063 0.009063 0.009063
scaleOrientation 0.04126 -0.2057 0.9778 -0.3803
children [
DEF blades-TIMER TimeSensor { loop TRUE cycleInterval 3.333 },
DEF blades-POS-INTERP PositionInterpolator {
##coordinates
DEF fan-SENSOR TouchSensor { enabled TRUE }
DEF sc Script {
eventIn SFBool click
field SFNode Timer USE blades-TIMER
field SFInt32 time 100
directOutput FALSE
url "java script:
function click(value) {
if (value==true)
{
if (Timer.enabled==true)
time=Timer.fraction_changed;
else
Timer.fraction_changed=time;
Timer.enabled =!
Timer.enabled;
} }"
}
]
ROUTE fan-SENSOR.isActive TO sc.click
ROUTE blades-TIMER.fraction_changed TO blades-POS-INTERP.set_fraction
ROUTE blades-POS-INTERP.value_changed TO blades.set_translation
ROUTE blades-TIMER.fraction_changed TO blades-ROT-INTERP.set_fraction
ROUTE blades-ROT-INTERP.value_changed TO blades.set_rotation
} |