[x3d-public] [x3d] Script Node and JSON encoding for X3D

Don Brutzman brutzman at nps.edu
Mon May 4 16:28:03 PDT 2015


cc: x3d-public (hope copying this answer out to community is OK with you Aaron, apologies if not)

On 5/3/2015 10:13 PM, Aaron Bergstrom wrote:
> Is there an example of a Script node in X3D JSON format that I can look at?

All of the source examples in the following include JSON (draft encoding) conversions.

X3D Example Archives: X3D for Web Authors, Chapter 09 - Event Utilities Scripting
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter09-EventUtilitiesScripting/

Example:
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter09-EventUtilitiesScripting/ScriptControlEvents.x3d
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter09-EventUtilitiesScripting/ScriptControlEvents.js

and
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter09-EventUtilitiesScripting/ScriptControlEvents.json

JSON excerpt below.

We do not yet have a final convention for the best way to handle
- Script/field*
- ProtoDeclare/ProtoInterface/field*
- ProtoInterface/fieldValue*

I doubt the following will change a whole lot.  Probably more interesting is how people will write native Javascript up at the HTML level to animate a scene graph- we could use more examples like that.  Maybe this scene is good for starting that.

Also interesting is whether X3DOM might be able to load and execute Javascript in the X3D Script node without having to otherwise convert it.  I believe that is possible... with a SMOP.   8)

Small matter of programming (SMOP)
https://en.wikipedia.org/wiki/Small_matter_of_programming

Others mileage may vary regarding JSON/HTML/X3D integration... these ideas will be really interesting to develop and test out.  As with most other "hard" parts of X3D, implementation evaluation and spiral improvement will get us to creating another "easy" part of X3D.

===========================
         { "Script":
           {
             "@DEF":"ControlScript",
             "@url":["ScriptControlEvents.js", "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter09-EventUtilitiesScripting/ScriptControlEvents.js"],
             "@directOutput":false,
             "@mustEvaluate":false,
             "-childNodeFieldNameNotFound":[
       ,
               { "field":
                 {
                   "@accessType":"inputOnly",
                   "@name":"buttonMotionDone",
                   "@type":"SFBool"
                 }
               },
               { "field":
                 {
                   "@accessType":"outputOnly",
                   "@name":"motion",
                   "@type":"MFVec3f"
                 }
               },
               { "field":
                 {
                   "@accessType":"initializeOnly",
                   "@name":"buttonDown",
                   "@type":"SFBool",
                   "@value":true
                 }
               },
               { "field":
                 {
                   "@accessType":"outputOnly",
                   "@name":"lightColor",
                   "@type":"SFColor"
                 }
               }
             ]
             "-field":[
               { "field":
                 {
                   "@accessType":"inputOnly",
                   "@name":"buttonMotionDone",
                   "@type":"SFBool"
                 }
               },
               { "field":
                 {
                   "@accessType":"outputOnly",
                   "@name":"motion",
                   "@type":"MFVec3f"
                 }
               },
               { "field":
                 {
                   "@accessType":"initializeOnly",
                   "@name":"buttonDown",
                   "@type":"SFBool",
                   "@value":true
                 }
               },
               { "field":
                 {
                   "@accessType":"outputOnly",
                   "@name":"lightColor",
                   "@type":"SFColor"
                 }
               }
             ]
           }
         },
         { "ROUTE":
           {
             "@fromField":"isActive",
             "@fromNode":"ButtonTimer",
             "@toField":"buttonMotionDone",
             "@toNode":"ControlScript"
           }
         },
===========================

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list