snowman_1.wrl source
#VRML V2.0 utf8

Viewpoint {}

NavigationInfo {
type "EXAMINE"
headlight FALSE
}

# 日光
DirectionalLight {
direction 0 -1 -1
ambientIntensity 1
}

# 背景
Background {
skyAngle [ 1.5 1.57 1.5708 ]
skyColor [
0.5 0.5 1
0.7 0.8 1
1 1 1
1 1 1
]
}

# 頭
DEF Head-Tf Transform {
translation 0 0.5 0
children [
Shape {
appearance DEF White-Ap Appearance {
material Material {
diffuseColor 1 1 1
}
}
geometry Sphere {}
}
DEF PlS PlaneSensor {
minPosition -1 -0.1
maxPosition 1 0.5
}
DEF ThS TouchSensor {}
DEF Sw Switch {
whichChoice 0
choice [
# 0 普通の顔
Group {
children [
# 右目
Transform {
translation -0.4 0.2 0.85
rotation 1 0 0 1.5708
children [
DEF Eye-Sp Shape {
appearance DEF Black-Ap Appearance {
material Material {
diffuseColor 0.1 0.1 0.1
}
}
geometry Cylinder {
radius 0.1
height 0.2
}
}
]
}
# 左目
Transform {
translation 0.4 0.2 0.85
rotation 1 0 0 1.5708
children USE Eye-Sp
}
# 鼻
Transform {
translation 0 -0.1 1.1
rotation 1 0 0 1.5708
children [
DEF Nose-Sp Shape {
appearance Appearance {
material Material {
diffuseColor 1 0.6 0.1
}
}
geometry Cone {
bottomRadius 0.1
height 0.3
}
}
]
}
# 口
Transform {
translation 0 -0.5 0.82
rotation 0 0 1 1.5708
children [
Shape {
appearance USE Black-Ap
geometry Cylinder {
radius 0.08
height 0.4
}
}
]
}
]
}

# 1 驚いた顔
Group {
children [
# 右目
Transform {
translation -0.4 0.2 0.85
rotation 1 0 0 1.5708
scale 1.5 1.0 1.5
children USE Eye-Sp
}
# 左目
Transform {
translation 0.4 0.2 0.85
rotation 1 0 0 1.5708
scale 1.5 1.0 1.5
children USE Eye-Sp
}
# 鼻
Transform {
translation 0 -0.1 1.1
rotation 1 0 0 1.5708
scale 1.5 1.0 1.5
children USE Nose-Sp
}
# 口
Transform {
translation 0 -0.5 0.82
rotation 1 0 0 1.9
children [
Shape {
appearance USE Black-Ap
geometry Cylinder {
radius 0.2
height 0.2
}
}
]
}
]
}
]
}
]
}

# 体
Transform {
translation 0 -1.6 0
children [
Shape {
appearance USE White-Ap
geometry Sphere {
radius 1.5
}
}
]
}

# 地面の雪
Transform {
translation 0 -3.1 0
scale 1 0.1 1
children [
Shape {
appearance USE White-Ap
geometry Sphere {
radius 5
}
}
]
}

# スクリプト
DEF Sc Script {
eventIn SFBool change_Face
eventOut SFInt32 whichChoice
eventIn SFVec3f translation_Head
eventOut SFRotation rotation_Head
field SFBool isCortona FALSE
url "javascript:
function initialize () {
isCortona = (Browser.getName() == 'Cortona VRML Client');
}
function change_Face (val) {
whichChoice = val;
}
function translation_Head (val) {
var ry = new SFRotation (0, 1, 0, val.x);
var rx = new SFRotation (1, 0, 0, -val.y);
rotation_Head = isCortona ? ry.multiply(rx) : rx.multiply(ry);
}
"
}

ROUTE ThS.isOver TO Sc.change_Face
ROUTE Sc.whichChoice TO Sw.whichChoice

ROUTE PlS.translation_changed TO Sc.translation_Head
ROUTE Sc.rotation_Head TO Head-Tf.rotation