#VRML V2.0 utf8
Viewpoint {
description "initial"
}
NavigationInfo {
avatarSize [
0.25 1.6 0.75 0 0 0
]
type "EXAMINE"
}
Transform {
children [
DEF Sw Switch {
whichChoice 0
choice [
# 0 箱
Shape {
appearance DEF Ap Appearance {
texture ImageTexture {
url "map.gif"
}
material Material {
diffuseColor 1 1 1
}
}
geometry Box {}
}
# 1 円筒
Shape {
appearance USE Ap
geometry Cylinder {}
}
# 2 円錐
Shape {
appearance USE Ap
geometry Cone {}
}
# 3 球
Shape {
appearance USE Ap
geometry Sphere {}
}
]
}
DEF ThS TouchSensor {}
]
}
# テクスチャー座標表示
DEF Console-Tf Transform {
children [
Transform {
translation -5 3 -10
children [
Shape {
appearance Appearance {
material Material {
emissiveColor 1 1 0.999
}
}
geometry DEF Tx Text {
string [
"x = 0"
"y = 0"
]
}
}
]
}
]
}
# ビューア位置と向き検出用近接度センサー
DEF PrS ProximitySensor {
size 1000 1000 1000
}
ROUTE PrS.position_changed TO Console-Tf.set_translation
ROUTE PrS.orientation_changed TO Console-Tf.set_rotation
# テクスチャーコード表示及び形状切り替えスクリプト
DEF Sc Script {
eventIn SFVec2f set_hitTexCoord
eventOut MFString string
eventIn SFTime changeShape
eventOut SFInt32 whichChoice
field SFNode Sw USE Sw
url "javascript:
function set_hitTexCoord (v) {
string[0] = 'x = ' + v.x;
string[1] = 'y = ' + v.y;
}
function changeShape () {
whichChoice++;
whichChoice %= Sw.choice.length;
}
"
}
ROUTE ThS.hitTexCoord_changed TO Sc.set_hitTexCoord
ROUTE Sc.string TO Tx.string
ROUTE ThS.touchTime TO Sc.changeShape
ROUTE Sc.whichChoice TO Sw.whichChoice