[x3d-public] Improvements to the unofficial *X3D* JSON loader

Don Brutzman brutzman at nps.edu
Mon Nov 16 20:52:34 PST 2015


Sorry - a bug crept in last night. Fixed. Will be deploying corrected versions late tonight that have arrays of strings, such as the following excerpt.

"-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"]
     }
   }
]


On 11/16/2015 8:48 AM, John Carlson wrote:
> Further enhancements include the ability to load X3D files and images based on the URL of the JSON file.   There’s a bit of confusion on the @url attributes MFString right now, so I have coded it for what’s currently in the JSON files in the X3D Resources examples, A single long string within an array.
>
> John
>> On Nov 13, 2015, at 4:23 PM, John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>>
>> I have added improvements to my unofficial X3D JSON to X3DOM loader.  Please test against your X3D JSON scenes.
>>
>> Loader (and license) is at:
>>
>> https://github.com/coderextreme/X3DJSONLD
>>
>>
>> You can do:
>>
>> $ git clone https://github.com/coderextreme/X3DJSONLD
>>
>> then
>>
>> $ cd X3DJSONLD
>> $ unzip http://www.web3d.org/x3d/content/examples/X3dExampleArchivesJsonScenes.zip
>> or actually something like:
>> $ unzip ~/Downloads/X3dExampleArchivesJsonScenes.zip
>> $ ln -s www.web3d.org/x3d/content/examples/ <http://www.web3d.org/x3d/content/examples/>
>> $ python -m SimpleHTTPServer
>>
>> You should be able to go to http://localhost:8000 <http://localhost:8000/> to see the loader in action.  I have moved several large scenes to the top of the select list.
>>
>> Alternatively, instead of running python, you can run node.js, available from https://nodejs.org/
>>
>> Change config.js to point to you examples folder.
>>
>> $ npm install
>> $ node app.js
>>
>> Then go to http://localhost:3000 <http://localhost:3000/> to see the loader in action.
>>
>> Alternatively, change the name of X3DJSONLD/index.html to X3DJSONLD.html, then copy X3DJSONLD.html, flipper.json and X3DJSONLD.js to www.web3d.org/x3d/content/ <http://www.web3d.org/x3d/content/> (beware of overwrites) and go to web server at http://www.web3d.org/x3d/content/X3DJSONLD.html (Don, you can try this).  I will probably make the index.html name change permanent at some point, but I need Don to tell me a good name that is available for me to use under x3d/content/ (or exactly where he wants to put the loader, if anywhere).
>>
>> If someone wants to add a typeahead search pane for the select list, please do.  Forks and pull requests are welcome.
>>
>>
>> I view this code as fairly simple to review and not a large security risk, as long as you insure that the JSON you load does not contain security holes.  That is, watch out for embedded script tags and other nasties.  No attempt to validate the JSON is made at this point, so my loader will load ANY DOM found in the JSON, including SVG, HTML, etc.  About the only thing to watch out for is the @, - and # prefixes.  If you do want to load SVG or HTML JSON, you will need to make sure your JSON has those prefixes.
>>
>> John
>>
>>
>>
>
>
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>


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