DEF Tf Transform {
translation IS ballPosition
children [
DEF Float-Tf Transform {
children [
Shape {
appearance Appearance {
material DEF Mt Material {
diffuseColor 1 0 0
}
}
geometry Sphere {
radius 0.1
}
}
]
}
]
}
DEF Sc Script {
eventIn SFVec3f set_translation
eventOut SFColor diffuseColor
url "javascript:
function set_translation (vec) {
var h = Math.cos ( vec.x ) * 0.5 + 0.5;
var s = Math.cos ( vec.z ) * 0.4 + 0.6;
diffuseColor = new SFColor ();
diffuseColor.setHSV( h, s, 1 );
}
"
}
ROUTE Tf.
translation TO Sc.
set_translation
ROUTE Sc.
diffuseColor TO Mt.
diffuseColor
DEF TiS TimeSensor {
startTime IS startFloat
cycleInterval 20
}
DEF PI PositionInterpolator {
key [ 0.0 0.25 0.5 0.75 1.0 ]
keyValue [ 0 0 0, 0 1 0, 0 4 0, 0 9 0, 0 16 0 ]
}
ROUTE TiS.
fraction_changed TO PI.
set_fraction
ROUTE PI.
value_changed TO Float-Tf.
translation
}