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

John Carlson yottzumm at gmail.com
Sun May 21 02:20:58 PDT 2017


Another patch

Sent from Mail for Windows 10

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

Small patch to JavaScript instructions.  I use x3djsonld folder for JavaScript generated by stylesheet.

Sent from Mail for Windows 10

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

Sorry for the extra lines.  I cannot delete them.

No, it uses the JVM to run Nashorn JavaScript.  Yes, it uses X3Dautoclass.js.  If you need running instructions, let me know (they are on the website).

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

sh build.sh

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

#!/bin/bash
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"
# NASHORN DOES NOT TAKE C:
export NASHORN_CLASSPATH="${CLASSPATH};${X3DJSONLD}/src/main/nashorn"

cd src/main/shell

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

OR
---------------------------------------------------------------------------------------------------------------------------------------------
#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/json2js.js

After converting to JavaScript, run it:
cd ../nashorn

jjs -J-Xss1g -J-Xmx4g -cp "${NASHORN_CLASSPATH}" net/coderextreme/data/abox.sail.js


OR:

#Then to include in your environment

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

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

After converting to JavaScript, run it:
cd ../nashorn

jjs -J-Xss1g -J-Xmx4g -cp "${NASHORN_CLASSPATH}" net/x3djsonld/data/abox.sail.js

---------------------------------------------------------------------------------------------------------------------------------------------

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

Another tutorial will be soon be available for Java.  Python doesn’t work yet.


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/3e90ccd8/attachment.html>


More information about the x3d-public mailing list