[x3d-public] JSON Encoding - Taking Don's idea one step further

John Carlson yottzumm at gmail.com
Mon Dec 21 13:25:32 PST 2015


Actually, I don’t think that -children, -content etc matter to me, I will have to check to make sure.  What does matter is that I can stop moving ROUTEs to the end of a node.

Sent from Mail for Windows 10


From: Roy Walmsley
Sent: Monday, December 21, 2015 2:46 PM
To: Don Brutzman; John Carlson
Cc: x3d-public at web3d.org
Subject: JSON Encoding - Taking Don's idea one step further

Don and John,

I can see the benefit of Don’s idea. So, I have been trying to give it some thought, and would like to make the following very radical, iffy, suggestion:

Don’s idea was to introduce a “-children” to accommodate ROUTES and comments.

The current (or alternative) JSON encoding tends to treat it like a Classic VRML encoding, in the sense of specifying the xFNode field names and then adding the children.

My thought is, can we, say, add a “-content” field, and then add the content more in the XML encoding style. So comments and ROUTEs become content, just like child nodes. All nodes that have any children have a “-content”.

Take a snippet from the HelloWorld example. This is Don’s latest incarnation:

   { "Shape":
      {
        "-children":[
          { "#comment":"Sphere begin"},
          { "#comment":"Sphere complete, Appearance begin"},
          { "#comment":"Appearance complete"}
        ],
        "-geometry":[
          { "Sphere":
            {
            }
          }
        ],
        "-appearance":[
          { "Appearance":
            {
              "-children":[
               { "#comment":"Material begin"},
               { "#comment":"Material complete, ImageTexture begin"},
               { "#comment":"ImageTexture complete"}
              ],
              "-material":[
                { "Material":
                  {
                    "@DEF":"MaterialLightBlue",
                    "@diffuseColor":[0.1,0.5,1]
                  }
                }
              ],
              "-texture":[
                { "ImageTexture":
                  {
                    "@DEF":"ImageCloudlessEarth",
                    "@url":["earth-topo.png”]
                  }
                }
              ]
            }
          }
        ]
      }
    }

And this is what my idea would produce:

   { "Shape":
      {
        "-content":[
          { "#comment":"Sphere begin"},
          { "Sphere":
            {
            }
          }
          { "#comment":"Sphere complete, Appearance begin"},
          { "Appearance":
            {
              "-content":[
               { "#comment":"Material begin"},
                { "Material":
                  {
                    "@DEF":"MaterialLightBlue",
                    "@diffuseColor":[0.1,0.5,1]
                  }
                }
               { "#comment":"Material complete, ImageTexture begin"},
                { "ImageTexture":
                  {
                    "@DEF":"ImageCloudlessEarth",
                    "@url":["earth-topo.png”]
                  }
                }
               { "#comment":"ImageTexture complete"}
              ]
            }
          }
          { "#comment":"Appearance complete"}
        ]
      }
    }

I don’t know if it is valid JSON, but I hope it gives you the idea. @containerFields would be added if required.

Pros and cons:

PRO: All comments remain in exactly the right places (so would also apply to  ROUTEs)
PRO: Uses the term “-content” which is not a term used elsewhere

CON: Would mean a complete rethink/rewrite of development tools.

Anyway, just an idea …

Regards,

Roy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20151221/fd09ca47/attachment-0001.html>


More information about the x3d-public mailing list