switch_0.wrl source
#VRML V2.0 utf8
Viewpoint {
position 0 0 5
}
NavigationInfo {
type "EXAMINE"
}

Group {
children [
DEF Sw Switch {
whichChoice 0
choice [
# 0 球
Shape {
appearance Appearance {
material Material {
diffuseColor 1 1 0
}
}
geometry Sphere {}
}
# 1 円錐
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0 1
}
}
geometry Cone {}
}
# 2 円柱
Shape {
appearance Appearance {
material Material {
diffuseColor 0 1 1
}
}
geometry Cylinder {}
}
]
}

# タッチセンサー
DEF ThS TouchSensor {}
]
}

DEF Sc Script {
eventIn SFTime changeShape
field SFNode Sw USE Sw
directOutput TRUE
url "javascript:
function changeShape () {

Sw.whichChoice++;
Sw.whichChoice %= Sw.choice.length;

}
"
}

ROUTE ThS.touchTime TO Sc.changeShape