[X3D-Public] Any way to get 'this' proto instance inside itself?

Dave A dave at realmofconcepts.com
Sun Oct 31 22:53:47 PDT 2010


What I ended up doing was adding

inputOutput SFNode thisInstance NULL

to the proto def, and all instances must reference itself:

DEF p1 myproto { thisInstance USE p1 }

If there's a better way, I'd like to hear it. If not, would like to 
request it as a feature for next go-around.

Dave A


On 10/31/2010 7:53 PM, Braden McDaniel wrote:
> On Sun, 2010-10-31 at 10:51 -0700, Dave A wrote:
>> I may be missing something obvious, but please enlighten me:
>>
>> Is there a way to get a handle on 'this' proto's instance from within
>> a script in that proto?
> Not exactly...
>
>> Ex:
>>
>> PROTO myproto [
>>      inputOutput SFString s ""
>> ]
>> {
>>      DEF pscript Script {
>>      url [ "ecmascript:
>>          function initialize()
>>          {
>>              Browser.addRoute ( somenode, 'somefield', I NEED TO ACCESS
>> THIS PROTO INSTANCE NODE HERE, 's');
>>          }
>>
>> I'm using Contact FWIW. I can see that Contact has a lovely external
>> 'get node by DEF name' feature, not available in internal script. I
>> don't see any API which takes DEF name strings and creates routes.
>> I'd really like to avoid having to crawl the scene graph looking for
>> my instance by name (that name being a proto field set same as the DEF
>> name for it).
> You just need to IS 's' to some interface in the PROTO definition and
> route to that.
>



More information about the X3D-Public mailing list