[x3d-public] Upcoming feature of X3DJSAIL. A Java based X3DJSONLD!

John Carlson yottzumm at gmail.com
Mon Jan 29 14:50:27 PST 2018


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




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180129/a20a8e2a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Nashorn0.x3d
Type: application/octet-stream
Size: 20965 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180129/a20a8e2a/attachment-0001.obj>


More information about the x3d-public mailing list