[x3d-public] Running Nashorn JavaScript in X3DJSONLD environment for X3DJSAIL

John Carlson yottzumm at gmail.com
Sun May 21 02:22:48 PDT 2017

Patch to Java version for generated folder

Sent from Mail for Windows 10

From: John Carlson
Sent: Sunday, May 21, 2017 5:16 AM
To: Don Brutzman
Cc: X3D Graphics public mailing list
Subject: RE: Running Nashorn JavaScript in X3DJSONLD environment for X3DJSAIL

And here’s the Java

Sent from Mail for Windows 10

Sorry for the extra lines.  I cannot delete them.

Install X3D.3.3.classes.jar in ~/pythonSAI

sh build.sh

In  ~/X3DJSONLD/src/main/shell/classpath, set the environmental variables:

export PYTHONSAI=/Users/coderextreme/pythonSAI
export X3DJSONLD=/Users/coderextreme/X3DJSONLD
export CLASSPATH=".;${PYTHONSAI}/X3DJSAIL.3.3.classes.jar;${X3DJSONLD}/saxon9he.jar;${X3DJSONLD}/target/X3DJSONLD-1.0-SNAPSHOT.jar"
export NASHORN_CLASSPATH="${CLASSPATH};${X3DJSONLD}/src/main/nashorn"

cd src/main/shell

#Then do one of the following:
sh several.sh ../data/abox.x3d

#Then to include in your environment

.  ~/X3DJSONLD/src/main/shell/classpath

# convert X3D to JSON to JavaScript

$ java net.coderextreme.RunSaxon ---../ ---overwrite --../lib/stylesheets/X3dToJson.xslt -json ../data/abox.x3d | xargs node ../node/json2java.js

cd ../java

javac -J-Xss1g -J-Xmx4g net/coderextreme/data/abox.java

java -Xss1g -Xmx4g -cp "${CLASSPATH}" net/coderextreme/data/abox


#Then to include in your environment

.  ~/X3DJSONLD/src/main/shell/classpath

# Convert X3D to JavaScript
java net.coderextreme.RunSaxon ---overwrite  --../lib/stylesheets/X3dToJava.xslt -sail.js ---../java/net/x3djsonld/

cd ../java

javac -J-Xss1g -J-Xmx4g net/x3djsonld/data/abox.java

java -Xss1g -Xmx4g -cp "${CLASSPATH}" net/x3djsonld/data/abox

Results are in ../data/abox.new.json

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Sunday, May 21, 2017 4:06 AM
To: John Carlson
Cc: X3D Graphics public mailing list
Subject: Re: move validateSelf() from X3dToJava.xslt to X3DObject.java classin X3DJSAIL

On 5/18/2017 9:40 PM, John Carlson wrote:
> See subject.  Seems like a waste to repeat the code everywhere, when it could be shared.  I could use it in my serializer as well…  I would like validateSelf() from X3dToJava.xslt in X3DJSAIL’s X3DObject.java.  You can keep the call to validate self in the main() of course.

sounds very logical.  will try refactoring as you suggest in a future session.

> Also attached is the X3dToES5.xslt (Nashorn) code generator.  You can download X3Dautoclass.js from https://coderextreme.net/X3DJSONLD/  It takes the same parameters as X3dToJava.xslt, but does not use the package (but it should, working on namespaces, I think).
> This works with X3DJSAIL.
> Happy Nashing!
> John

hoping i understand... please confirm.  This takes an .x3d scene and converts it to javascript, utilizing X3Dautoclass.js to run?  presumably can run in node.js?

hoping you might provide an example from beginning to end.  HelloWorld.x3d -> HelloWorldNashorn.js perhaps?

looking forward to understanding better, and preparing for Web3D 2017 Master Class on these topics.  TIA.

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 --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170521/264ba91d/attachment-0001.html>

More information about the x3d-public mailing list