normal.wrl source
#VRML V2.0 utf8

Viewpoint {
position 0 0 3
}
NavigationInfo {
type "EXAMINE"
}

# 壺
Group {
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.749 0.836 1
specularColor 0.5 0.5 0.5
shininess .15
}
}
geometry Extrusion {
crossSection [ 1 0, 0.991 -0.131, 0.966 -0.259, 0.924 -0.383, 0.866 -0.5, 0.793 -0.609, 0.707 -0.707, 0.609 -0.793, 0.5 -0.866, 0.383 -0.924, 0.259 -0.966, 0.131 -0.991, 0 -1, -0.131 -0.991, -0.259 -0.966, -0.383 -0.924, -0.5 -0.866, -0.609 -0.793, -0.707 -0.707, -0.793 -0.609, -0.866 -0.5, -0.924 -0.383, -0.966 -0.259, -0.991 -0.131, -1 0, -0.991 0.131, -0.966 0.259, -0.924 0.383, -0.866 0.5, -0.793 0.609, -0.707 0.707, -0.609 0.793, -0.5 0.866, -0.383 0.924, -0.259 0.966, -0.131 0.991, 0 1, 0.131 0.991, 0.259 0.966, 0.383 0.924, 0.5 0.866, 0.609 0.793, 0.707 0.707, 0.793 0.609, 0.866 0.5, 0.924 0.383, 0.966 0.259, 0.991 0.131, 1 0 ]
spine [ 0 -0.5 0, 0 -0.495 0, 0 -0.484 0, 0 -0.468 0, 0 -0.447 0, 0 -0.422 0, 0 -0.392 0, 0 -0.358 0, 0 -0.319 0, 0 -0.277 0, 0 -0.231 0, 0 -0.181 0, 0 -0.127 0, 0 -0.077 0, 0 -0.032 0, 0 0.008 0, 0 0.044 0, 0 0.075 0, 0 0.1 0, 0 0.119 0, 0 0.133 0, 0 0.149 0, 0 0.169 0, 0 0.191 0, 0 0.216 0, 0 0.243 0, 0 0.27 0, 0 0.298 0, 0 0.327 0, 0 0.355 0, 0 0.382 0, 0 0.407 0, 0 0.432 0, 0 0.452 0, 0 0.468 0, 0 0.48 0, 0 0.488 0, 0 0.494 0, 0 0.498 0, 0 0.5 0 ]
scale [ 0.311 0.311, 0.324 0.324, 0.35 0.35, 0.388 0.388, 0.439 0.439, 0.485 0.485, 0.525 0.525, 0.56 0.56, 0.589 0.589, 0.611 0.611, 0.626 0.626, 0.635 0.635, 0.637 0.637, 0.628 0.628, 0.61 0.61, 0.581 0.581, 0.542 0.542, 0.502 0.502, 0.461 0.461, 0.42 0.42, 0.378 0.378, 0.341 0.341, 0.309 0.309, 0.283 0.283, 0.261 0.261, 0.253 0.253, 0.257 0.257, 0.275 0.275, 0.305 0.305, 0.324 0.324, 0.33 0.33, 0.325 0.325, 0.308 0.308, 0.287 0.287, 0.263 0.263, 0.235 0.235, 0.205 0.205, 0.181 0.181, 0.166 0.166, 0.158 0.158 ]
endCap FALSE
solid FALSE
creaseAngle 0.785398
}
}
DEF ThS TouchSensor {}
]
}

# 矢印
DEF Arrow-Tf Transform {
children [
Transform {
translation 0 0.05 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0.9 0
}
}
geometry Cylinder {
radius 0.005
height 0.1
}
}
]
}
Transform {
translation 0 0.15 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0.5 0
}
}
geometry Cone {
bottomRadius 0.02
height 0.1
}
}
]
}
]
}

# スクリプト
DEF Sc Script {
eventIn SFVec3f set_hitNormal
eventOut SFRotation rotation
field SFVec3f initDirection 0 1 0
url "javascript:
function set_hitNormal (normal) {

rotation = new SFRotation ( initDirection, normal );

}
"
}

ROUTE ThS.hitPoint_changed TO Arrow-Tf.translation
ROUTE ThS.hitNormal_changed TO Sc.set_hitNormal
ROUTE Sc.rotation TO Arrow-Tf.rotation