This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > January 2004 > how to include a script within a script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to include a script within a script
|
|
| Unregistered 2004-01-10, 9:03 am |
| Hi,
I need to dynamically create a button and within this button, I need to detect the TouchSensor and perform according. How do I include a script inside another script? To create the button dynamically, I use createvrmlfromstring and within I need to include a PROTO.
Example :
.......
url "vrmlscript:
function set_time() {
newvrml = 'DEF ' + node_name + ' Transform {';
newvrml +='translation 0.6 0 0';
newvrml +=' children [';
newvvrml+=' TouchSensor{}
......
createvrmlfromscript(newvrml);
I need to implement script to handle TouchSensor. How can I do it. Any idea? | |
| Cecile Muller 2004-01-10, 8:30 pm |
| When doing the createVrmlFromString, it return nodes, and you can
access those nodes for either storing them, copy its properties,
adding a route or, the most common, adding it to the scene.
This might be what you're looking for:
-------------------------
#VRML V2.0 utf8
Viewpoint{}
PointLight{location 0 0 10}
DEF gr Group{}
DEF brain Script{
field SFNode self USE brain
eventIn SFTime touched
eventOut MFNode addChildren
url "java script:
function touched(){trace('Clicked !');}
function initialize(){
nodes = Browser.createVrmlFromString('TouchSensor{}
Shape{appearance Appearance{material Material{}} geometry Box{}}');
Browser.addRoute(nodes[0], 'touchTime', self, 'touched');
addChildren = nodes;
}
"
}
ROUTE brain.addChildren TO gr.addChildren
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|