group
Transform {
children [
DEF toc-switch-1-0 Switch {
whichChoice -1
choice [
DEF toc-transform-1-0 Transform {
translation 0 0 0
scale 1 1 1
rotation 0 1 0 0
children [
Text { string "text" fontStyle FontStyle { justify "MIDDLE" } }
] }
] } ## end switch
Transform {
children [
Shape {
appearance Appearance {
material DEF toc-mat-1-0 Material {
diffuseColor 1 0 0
transparency 1
}
}
geometry Box { size 3 3 0.5 }
}
DEF toc-touch-1-0 TouchSensor { }
] }
DEF toc-script-1-0 Script {
directOutput TRUE
field SFNode me USE toc-script-1-0
field SFNode xswitch USE toc-switch-1-0
field SFNode transform USE toc-transform-1-0
field SFNode sensor USE toc-touch-1-0
field SFNode mat USE toc-mat-1-0
field SFNode view USE view
field SFInt32 state 0
eventIn SFBool touch
eventIn SFBool over
url "vrmlscript:
function initialize() {
Browser.addRoute(sensor,'isActive',me,'touch');
Browser.addRoute(sensor,'isOver',me,'over');
}
function shutdown() {
Browser.deleteRoute(sensor,'isActive',me,'touch');
Browser.deleteRoute(sensor,'isOver',me,'over');
}
function touch(value,time) {
if (value && state == 0) {
xswitch.whichChoice = 0;
//transform.translation = new SFVec3f(1.5,1,0);
transform.scale = new SFVec3f(0.8,0.8,1);
state = 1;
} else if (value && state == 1) {
//transform.translation = new SFVec3f(0,0,0);
transform.scale = new SFVec3f(5,5,1);
state = 2;
} else if (value && state == 2) {
xswitch.whichChoice = -1;
view.position = new SFVec3f(0,0,10);
state = 0;
}
}
function over(value,time) {
if (value) {
mat.transparency = 0.5;
} else {
mat.transparency = 1;
}
}
"
}
] }