colorchange_0.wrl source
#VRML V2.0 utf8

Viewpoint {}
NavigationInfo {
type "EXAMINE"
}

Group {
children [
Shape {
appearance Appearance {
# (8)
material DEF Ball-Mt Material {
diffuseColor 1 0 0
}
}
geometry Sphere {}
}
# (1)
DEF ThS TouchSensor {}
]
}

DEF Sc Script {
# (3)
eventIn SFTime colorChange

# (6)
eventOut SFColor diffuseColorOfBall

url "javascript:

// (4)
function colorChange () {
var r = Math.random();
var g = Math.random();
var b = Math.random();

// (5)
diffuseColorOfBall = new SFColor (r,g,b);
}
"
}

# (2)
ROUTE ThS.touchTime TO Sc.colorChange

# (7)
ROUTE Sc.diffuseColorOfBall TO Ball-Mt.diffuseColor