A node referenced form another node by USE statement, is copied by value, when passed to eventIn of Script...
Thus, next code does not work. BS Contact and Octaga works fine...
#VRML V2.0 utf8
PROTO Signal [ exposedField SFBool processed FALSE ] {}
PROTO Wrapper [ field SFNode nodeRef NULL ] {}
DEF S1 Signal {}
DEF W1 Wrapper { nodeRef USE S1 }
DEF Script1 Script {
directOutput TRUE mustEvaluate TRUE
eventIn SFNode processSignal
url "javascript:
function processSignal ( v ) {
// referenced node S1 is copied by value...
v.nodeRef.processed = true;
}
"
}
DEF Script2 Script {
directOutput TRUE mustEvaluate TRUE
field SFNode w USE W1
field SFNode s USE Script1
eventIn SFTime sendSignal
url "javascript:
function sendSignal () {
s.processSignal = w;
print (w.nodeRef.processed);
// Octaga prints 'true' and BS Contact - '1'
}
"
}
DEF PS ProximitySensor {
size 1e36 1e36 1e36
enabled TRUE
}
ROUTE PS.enterTime TO Script2.sendSignal
|
|