resetPlaneSensor_1.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 Box {
size 1 1 0.01
}
}
DEF Cat-PlS PlaneSensor {}
]
}

ROUTE Cat-PlS.translation_changed TO Cat-Tf.translation

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

# 位置リセットスクリプト
DEF Sc Script {
eventIn SFTime reset
eventOut SFVec3f resetPosition
field SFVec3f initPos 0 0 0
url "javascript:
function reset () {
resetPosition = initPos;
}
"
}

ROUTE Ball-ThS.touchTime TO Sc.reset
ROUTE Sc.resetPosition TO Cat-Tf.translation
ROUTE Sc.resetPosition TO Cat-PlS.offset