[x3d-public] [x3dom-users] simple X3D -> JSON -> X3DOM, D3.js

Don Brutzman brutzman at nps.edu
Mon Feb 23 13:43:30 PST 2015


Thanks for your note.

The files are intentionally saved as .json for the time being since they are experimental and not necessarily intended for programmatic use as written.  The right file extension will ultimately need to be part of the X3D JSON encoding specification.

Our goal with trying to find a good X3D encoding using JSON is to support programmers who might want to load scene data into a javascript program.  Our objective is to represent the scene graph information, no more no less, just like the XML and ClassicVRML and Compressed Binary programs.  How that information is utilized and adapted by the programmer (or library loader) is up to them.

Many XML documents have duplicates of elements and attributes, so trying to create unique keys for each repeated element and attribute doesn't seem meaningful or round-trippable.

I would assume that more than one kind of javascript loader is available that can open and parse such a file.  Certainly using the most common is important, just wondering.

Not sure I understand the value in applying "use strict"; to automatically make this JSON source unparsable.  That would also seem to invalidate other XML to JSON approaches.

The .js attachment you sent was savable and viewable in a source editor without problems.

Getting a short set of examples illustrating the various design patterns is helpful, not sure we need a vast variety.  In any case the X3dToJson.xslt can generate several thousand whenever needed, so we will have no shortage of test cases once we get clear on the best approaches.


On 2/23/2015 11:40 AM, John Carlson wrote:
> Note if you send a .json file to node.js, it's going to bomb out.  You need to rename .json to .js if your going to use the same file without resaving.  Opening it with a parser in node.js should be fine without renaming, it's just if you've edited .json to add .js constructs.
>
> John
>
> On Mon, Feb 23, 2015 at 1:18 PM, John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>
>     Hi Don,
>
>     Thanks for all the hard work you are putting into the JSON encoding.  I think we will achieve something that is doable for JavaScript programmers.   Here is a JavaScript file with a recent downloaded HelloWorld.json converted to HelloWorld.js (not quite sure how JS attachments work, let me know if you get it).  Here's the error I get when running it through node.js.  Let me know if you've got this "use strict" well in hand.  I'm going to go back to converting more files to JSON and start reporting on more files.
>
>     /Users/johncarlson/X3DJSONTOD3/HelloWorld.js:68
>
>          "Transform": [
>
>          ^^^^^^^^^^^
>
>     SyntaxError: Duplicate data property in object literal not allowed in strict mode
>
>          at Module._compile (module.js:439:25)
>
>          at Object.Module._extensions..js (module.js:474:10)
>
>          at Module.load (module.js:356:32)
>
>          at Function.Module._load (module.js:312:12)
>
>          at Function.Module.runMain (module.js:497:10)
>
>          at startup (node.js:119:16)
>
>          at node.js:906:3
> [...]

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