media @ VU
web3d-x-script.vr
web3d-x-script.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
Web3D/VR
script example
script
DEF SCRIPT Script {
eventIn SFTime touchTime
field SFInt32 touchCount 0
field SFInt32 eventCount 0
field MFString tempString ""
eventOut MFString outputString
url "javascript:
function initialize() {
outputString = new MFString('','');
tempString = new MFString('','');
print('Script initialised');
outputString[0] = 'Ready...';
}
function touchTime(value, time) {
print('touchTime eventIn received');
touchCount++;
tempString[0] = 'touchCount: ' + touchCount.toString();
}
function eventsProcessed() {
print('eventsProcessed called');
eventCount++;
tempString[1] = 'eventCount: ' + eventCount.toString();
outputString = tempString;
}
"
}
sensor
Transform {
translation -7 5 0
children [
DEF SENSOR TouchSensor {
}
Shape {
appearance Appearance {
material Material {
emissiveColor 1 0 0
}
}
geometry Sphere {
radius 0.1
}
}
]
}
text
Shape {
geometry DEF TEXT Text {
fontStyle FontStyle {
justify "MIDDLE"
family "TYPEWRITER"
}
}
}
event routing
ROUTE SENSOR.touchTime TO SCRIPT.touchTime
ROUTE SCRIPT.outputString TO TEXT.string
(C) A. Eliëns
21/5/2007
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.