[x3d-public] Upcoming feature of X3DJSAIL. A Java based X3DJSONLD!
Don Brutzman
brutzman at nps.edu
Sun Apr 1 08:25:31 PDT 2018
John, this emerging X3D interoperability between java/javascript/.x3d/.json seems really significant. Can we make sure that it is properly & consistently documented in X3DJSAIL to correspond with X3DJSONLD?
Alternately a few more TODO items will emerge... probably crafting and exposing a few examples that deliberately try to "ring all the bells at once" will be a useful exercise to share.
Thanks for your efforts.
On 1/29/2018 2:50 PM, John Carlson wrote:
> I can now put this at the bottom of a Nashorn file, say HelloWorldProgramOutput.Nashorn.js:
>
> X3D0.toFileJSON("Nashorn.json");
>
> var X3DJSONLD = Java.type("net.coderextreme.X3DJSONLD")
>
> var loader = new X3DJSONLD();
>
> var File = Java.type("java.io.File")
>
> var jsobj = loader.readJsonFile(new File("Nashorn.json"));
>
> var document = loader.loadJsonIntoDocument(jsobj);
>
> print(loader.serializeDOM(loader.getX3DVersion(jsobj), document));
>
> Then run to get XML output:
>
> $ jjs -J-Djava.class.path=../../jars/X3DJSAIL.3.3.full.jar";../../classes" HelloWorldProgramOutput.Nashorn.js > Nashorn0.x3d
>
> Nothing has been validated yet, but output is attached! I think it may still be messy, but I’m mildly pleased I got as far as I did.
>
> The real amazing thing is you don’t need javax.json on the classpath, as far as I can tell! I did put it under java/lib for compiling.
>
> Source code:
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/java/net/coderextreme/X3DJSONLD.java
>
> License is under main repository.
>
> Next: tying DOM document into main X3DJSAIL.
>
> If you add these line to the end of the JavaScript, you can create an X3D from the DOM you loaded in another way:
>
> var X3DLoaderObject = Java.type("org.web3d.x3d.jsail.X3DLoaderObject")
>
> var xmlLoader = new X3DLoaderObject();
>
> X3D0 = xmlLoader.toX3dObjectTree(document);
>
> X3D0.toFileX3D("./examples/Nashorn.x3d");
>
> Have fun with X3DJSONLD!
>
> John
>
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