[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A hard one on PROTO & vrml/java-script


I've just siubscribed to this list and I've still not recieved any messages,
but I already have two questions. I will post one in this e-mail and the other
in a following e-mail so that people can answer aech one independently.

1. I define a PROTO and I want to create an object out of it from a script. The
example below shows my effort which does not work:

PROTO fooProto[...]

DEF fooEnvironment Group {
   children [
      fooProto{} # This object is created without probles, of course

DEF fooScript Script {
   directOutput TRUE
   eventIn SFBool createObj
   field SFNode obj NULL
   field MFNode newObj []
   field SFNode environment USE fooEnvironment

   url "vrmlscript:
      function createObj (v){
            obj = Browser.createVrmlFromString('fooProto{}');
            newObj = new MFNode(obj);
            environment.addChildren = newObj;

Let us say the script is triggered by a TouchSensor. When I press the
TouchSensor I get a run-time error saying "fooProto{}" is not valid VRML code.

I think this is crazy since the spec of VRML2.0 says that once you have defined
a PROTO, it may be used anywhere to cast an object out of it.

* Anybody has a clue why this error comes up?
* Anybody has alternatives to doing this?

Thank you very much in advance!

Best regards,


1                                          1
1  Narcis Pares i Burgues                  0
0  Coordinator of the VR Lab               0
1  Institut Universitari de l'Audiovisual  1 
0  Universitat Pompeu Fabra                1 
1  Rambla, 31                              0
1  08002 Barcelona                         1 
0  http://www.iua.upf.es/~npares/          1
1                                          0
*** Please send administrative requests to <majordomo@sdsc.edu> ***