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

# 猫の円柱
DEF Cat-Tf Transform {
children[
Shape {
appearance Appearance {
texture ImageTexture {
url "cat.jpg"
}
}
geometry Cylinder {
radius 0.5
height 1.5708
}
}
DEF Cat-SpS SphereSensor {}
]
}

ROUTE Cat-SpS.rotation_changed TO Cat-Tf.rotation

# 赤い球
Transform {
translation 0.2 -1.8 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0 0
}
}
geometry Sphere {
radius 0.1
}
}
DEF RedBall-ThS TouchSensor {}
]
}
# 青い球
Transform {
translation -0.2 -1.8 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0 0 1
}
}
geometry Sphere {
radius 0.1
}
}
DEF BlueBall-ThS TouchSensor {}
]
}

# 位置リセットスクリプト
DEF Sc Script {
eventIn SFTime reset
eventIn SFTime set
eventOut SFRotation resetOrientation
field SFRotation initOri 0 1 0 0
field SFRotation overlookOri 1 0 0 1.2
url "javascript:
function reset () {
resetOrientation = initOri;
}
function set () {
resetOrientation = overlookOri;
}
"
}

ROUTE RedBall-ThS.touchTime TO Sc.reset
ROUTE BlueBall-ThS.touchTime TO Sc.set
ROUTE Sc.resetOrientation TO Cat-Tf.rotation
ROUTE Sc.resetOrientation TO Cat-SpS.offset