[x3d-public] JSON encoding for SFNode: no [array brackets] fixed; warn about developmental version

Don Brutzman brutzman at nps.edu
Fri Feb 19 17:56:12 PST 2016


This meta-warning feature is added, example attached.  Should protect us from stray experimental content drifting and provoking errors for years...

John, I think the stray comma problem preceding Shader #sourceText is fixed too but you will need to test further on your end.

X3D-Edit updated for latest JSON export, tested satisfactorily.

I will run the examples generation again tonight to get the meta warnings in the online examples.

Hope you have a great weekend!


On 2/19/2016 10:50 AM, Don Brutzman wrote:
> Full JSON re-build is uploaded.
>
> I will update X3D-Edit later today with the SFNode corrections; will need more time for including a fix for stray comma preceding Shader source.
>
> Roy and I talked about how to indicate version of the JSON schema being used.
>
> In general we don't have special version numbers for different X3D encodings.  That is our end goal.
>
> What we can do is append appropriate (Dublin core) metadata in the conversion output.
>
>            {
>              "@name":"translated",
>              "@content":"19 February 2016"
>            },
>            {
>              "@name":"generator",
>              "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
>            }
>
> and for the time being
>
>            {
>              "@name":"warning",
>              "@content":"this scene uses an experimental version of X3D JSON encoding, status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
>            },
>
> thus scene users are duly warned, and we can use the conversion date if forensics are ever needed.
>
>
> On 2/19/2016 7:21 AM, Don Brutzman wrote:
>> Thanks for the catch.  Correction checked in, updated test result attached.  Examples should be again updated in time for our weekly JSON teleconference.
>>
>> Another clarification: I got the types from X3DObjectModel-3.3.xml
>>
>>      http://www.web3d.org/x3d/stylesheets/X3DObjectModel-3.3.xml
>>
>> Roy, this is pretty mature, can we also check it into subversion?  The object-model document changes over time may be interesting.
>>
>> On 2/19/2016 5:51 AM, Roy Walmsley wrote:
>>> Hi Don,
>>>
>>> Sorry to say you missed "material". I've changed my Schema, and using your new stylesheet I am regenerating the Basic archive JSON examples. I've started testing and noted that "material" fails. The 'Hello World" example can also be seen to still have the array.
>>>
>>> I'll modify the stylesheet, and rerun the example generation, and do some more testing. Obviously, not going to be ready for full test runs later!
>>>
>>> Roy
>>>
>>> -----Original Message-----
>>> From: Don Brutzman [mailto:brutzman at nps.edu]
>>> Sent: 19 February 2016 08:17
>>> To: John Carlson; Roy Walmsley; X3D Graphics public mailing list
>>> Subject: JSON encoding for SFNode: no [array brackets]
>>>
>>> John, during today's X3D Schema/DTD teleconference Roy observed that our SFNode child nodes were always wrapped in [array brackets] even though there is not an array there.
>>>
>>> This is contrary to our declared design principle that SFNode is always a JSON object.
>>>
>>>     http://www.web3d.org/x3d/stylesheets/X3dToJson.html#values
>>>
>>> That definitely appears to be what we want.  No desire to mislead JSON authors into thinking that another node might appear.
>>>
>>> Fortunately this implementation wasn't too difficult.  Here is the list of SFNode types that I constructed from AllX3dElementsAttributes.3.3.xml
>>>
>>> <xsl:variable name="SFNodeType" select="
>>>     ($fieldName = 'back')               or ($fieldName = 'bottom')            or ($fieldName = 'front')              or
>>>     ($fieldName = 'left')               or ($fieldName = 'right')             or ($fieldName = 'top')                or
>>>     ($fieldName = 'backTexture')        or ($fieldName = 'bottomTexture')     or ($fieldName = 'frontTexture')       or
>>>     ($fieldName = 'leftTexture')        or ($fieldName = 'rightTexture')      or ($fieldName = 'topTexture')         or
>>>     ($fieldName = 'appearance')         or ($fieldName = 'body1')             or ($fieldName = 'body2')              or
>>>     ($fieldName = 'collidable')         or ($fieldName = 'collider')          or
>>>     ($fieldName = 'color')              or ($fieldName = 'colorRamp')         or ($fieldName = 'coord')              or
>>>     ($fieldName = 'controlPoint')       or ($fieldName = 'controlPoints')     or ($fieldName = 'crossSectionCurve')  or
>>>     ($fieldName = 'emitter')            or ($fieldName = 'fillProperties')    or
>>>     ($fieldName = 'fogCoord')           or ($fieldName = 'fontStyle')         or ($fieldName = 'geoOrigin')          or
>>>     ($fieldName = 'geometry')           or ($fieldName = 'geometry1')         or ($fieldName = 'geometry2')          or
>>>     ($fieldName = 'gradients')          or ($fieldName = 'layout')            or ($fieldName = 'lineProperties')     or
>>>     ($fieldName = 'massDensityModel')   or
>>
>> ($fieldName = 'material') or
>>
>>>     ($fieldName = 'metadata')           or ($fieldName = 'normal')            or ($fieldName = 'pickingGeometry')    or
>>>     ($fieldName = 'profileCurve')       or ($fieldName = 'proxy')             or
>>>     ($fieldName = 'renderStyle')        or ($fieldName = 'source')            or
>>>     ($fieldName = 'segmentIdentifiers') or ($fieldName = 'surface')           or ($fieldName = 'surfaceNormals')     or
>>>     ($fieldName = 'targetObject')       or ($fieldName = 'texCoord')          or ($fieldName = 'texCoordRamp')       or
>>>     ($fieldName = 'texture')            or ($fieldName = 'textureProperties') or ($fieldName = 'textureTransform')   or
>>>     ($fieldName = 'trajectoryCurve')    or ($fieldName = 'transferFunction')  or
>>>     ($fieldName = 'viewpoint')          or ($fieldName = 'voxels')            or
>>>     ($fieldName = 'weightTransferFunction1') or ($fieldName = 'weightTransferFunction2') or
>>>     ($parentName='CADFace'         and $fieldName = 'shape') or
>>>     ($parentName='CollidableShape' and $fieldName = 'shape')" />
>>>
>>> So anyway it appears to be working on the first handful of test examples used during development.
>>>
>>> HelloWorld.json example attached, check out SFNode fields -appearance -geometry -material etc.  Output is slightly terser as well.
>>>
>>> No doubt this affects your implementation to but it appears to be an important change.
>>>
>>> Hope this sounds good to you too.  Chalk another win up for Roy's JSON schema!
>>>
>>> Stylesheet modifications checked in.  I'm running the JSON Examples build overnight, should be ready for you and Roy in the morning.
>>>
>>> http://www.web3d.org/x3d/content/examples/X3dResources.html#Examples
>>> "Special testing distribution. A comprehensive collection of all JSON example scenes is available at X3dExampleArchivesJsonScenes.zip (MD5 checksum) plus current output from the X3D JSON build process at build.json.out."
>>
>> all the best, Don
>
>
> all the best, Don


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
-------------- next part --------------
{ "X3D": {
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"HelloWorld.x3d"
          },
          {
            "@name":"description",
            "@content":"Simple X3D scene example: Hello World!"
          },
          {
            "@name":"created",
            "@content":"30 October 2000"
          },
          {
            "@name":"modified",
            "@content":"23 November 2014"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"Image",
            "@content":"HelloWorld.tall.png"
          },
          {
            "@name":"reference",
            "@content":"http://en.wikipedia.org/wiki/Hello_world"
          },
          {
            "@name":"reference",
            "@content":"en.wikipedia.org/wiki/Hello#\"Hello,_World\"_computer_program"
          },
          {
            "@name":"reference",
            "@content":"http://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world"
          },
          {
            "@name":"reference",
            "@content":"http://www.HelloWorldExample.net"
          },
          {
            "@name":"reference",
            "@content":"http://www.web3D.org"
          },
          {
            "@name":"reference",
            "@content":"http://www.web3d.org/realtime-3d/news/internationalization-x3d"
          },
          {
            "@name":"reference",
            "@content":"http://www.web3d.org/x3d/content/examples/HelloWorld.x3d"
          },
          {
            "@name":"reference",
            "@content":"http://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes"
          },
          {
            "@name":"identifier",
            "@content":"http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01-TechnicalOverview/HelloWorld.x3d"
          },
          {
            "@name":"license",
            "@content":"http://www.web3d.org/x3d/content/examples/license.html"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"reference",
            "@content":"HelloWorld.wrl"
          },
          {
            "@name":"reference",
            "@content":"HelloWorld.x3dv"
          },
          {
            "@name":"reference",
            "@content":"HelloWorld.x3db"
          },
          {
            "@name":"reference",
            "@content":"HelloWorld.xhtml"
          },
          {
            "@name":"reference",
            "@content":"HelloWorld.json"
          },
          {
            "@name":"translated",
            "@content":"19 February 2016"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ],
        "-children":[
          { "#comment":"Alternate encodings: VRML97, X3D ClassicVRML Encoding, X3D Compressed Binary Encoding (CBE), X3DOM, JSON"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "#comment":"Example scene to illustrate X3D nodes and fields (XML elements and attributes)"
          },
          { "Group":
            {
              "-children":[
                { "Viewpoint":
                  {
                    "@DEF":"ViewUpClose",
                    "@centerOfRotation":[0,-1,0],
                    "@description":"Hello world!",
                    "@position":[0,-1,7]
                  }
                },
                { "Transform":
                  {
                    "@rotation":[0,1,0,3],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Sphere":
                              {
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@DEF":"MaterialLightBlue",
                                      "@diffuseColor":[0.1,0.5,1]
                                    }
                                  },
                                "-texture":
                                  { "ImageTexture":
                                    {
                                      "@DEF":"ImageCloudlessEarth",
                                      "@url":["earth-topo.png","earth-topo.jpg","earth-topo-small.gif","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg","http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"]
                                    }
                                  }
                              }
                            }
                        }
                      }
                    ]
                  }
                },
                { "Transform":
                  {
                    "@translation":[0,-2,0],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Text":
                              {
                                "@DEF":"TextMessage",
                                "@string":["Hello","world!"],
                                "-fontStyle":
                                  { "FontStyle":
                                    {
                                      "@justify":["MIDDLE","MIDDLE"]
                                    }
                                  }
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@USE":"MaterialLightBlue"
                                    }
                                  }
                              }
                            }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
    }
  }
}


More information about the x3d-public mailing list