[x3d-public] Problems generating files using build.xml target test.nashorn

John Carlson yottzumm at gmail.com
Sun Jan 28 13:42:01 PST 2018


I’ve created a test.nashorn in java/nashorn/build.xml. You may call it if you like.  Make sure the current folder is java/nashorn (I am not sure if you can change current folder from within Java/Ant, except by invoking another virtual machine ala <exec>).

Also, apply this patch, which removes nashorn folder from CreateX3dSceneAccessInterfaceJava.xslt, attached.

I think we need a “Nashorn Folder” configuration property, rather than removing it from the stylesheet.  And/Or a nashorn folder passed after -toJS on the command line.   That way, the intermediate and final  JS files can find the right locations for the JS scripts.   The final JS script should only load X3Dautoclass.js (unless of course, it’s converting to JS yet again).

I think it would be better to invest some time in thinking about how to support a X3dToES5.xslt and X3dToES6.xslt (and X3dToPy.xslt, X3dToC#/C++, etc.  In otherwords, this whole thing with using a JavaScript program from within Java to convert JSON -> DOM -> JS is rather hokey at best.   We should go directly from DOM (probably preferred) or XML to Java, JS, Python, C#, C++, C etc.  I don’t think we should use JavaScript DOM for the final solution for X3DJSAIL.  If my code went directly from JSON -> JS it might make more sense, but right now, I use X3DJSONLD.js (produces JS DOM) for quite a bit of stuff.  In other words, I’m not good at serializing X3D JSON except by going through DOM.  Yes, DOM is a crutch, and convenient. Other pieces of X3DJSONLD, such as the prototype expander and the script handler do rely on JSON manipulation directly.   The prototype expander uses X3DJSONLD.js to convert back to DOM which is sent to X3DOM and and X_ITE (well, Cobweb).

If we make X3D JSON a standard, then other tools will pick it up, and I won’t have to continue supporting the thing, and we’ll get more collective experience handling X3D JSON peculiarities, tips and tricks, etc.   We should probably put more focus on the X3D JSON encoding if we intend to make it a standard—or dump it in favor of XML and DOM, and chalk X3D JSON up as an experiment we are no longer interested in.   Yes, glTF will retain the performance advantage, but I doubt if X3D could ever really meet that—at least with the code I was development translating to DOM.  I’m guessing a direct X3D JSON -> Render would be performant.

I’d like to see if I can create a DOM version of the prototype expander.

In otherwords, don’t feel bad that X3D is going into the DOM sphere.  DOM is a good thing for X3D, IMHO.  However, it’s going to be hard to beat a JSON solution in glTF, so glTF should be leveraged as well.   There will be a DOM standard and a JSON standard that work together, let’s focus on a DOM standard for HTML5 and get it right.   And we’ll still be doing it the web way.

John
Sent from Mail for Windows 10

From: Don Brutzman
Sent: Sunday, January 28, 2018 1:14 PM
To: John Carlson
Cc: x3d-public at web3d.org
Subject: Re: Problems generating files using build.xml target test.nashorn

On 1/26/2018 2:13 AM, John Carlson wrote:
> This works instead of a script in build.xml:
> 
>                  <exec executable="jjs">
> 
>                          <arg value="-J-Djava.class.path=jars/X3DJSAIL.3.3.full.jar"/>
> 
>                          <arg value="nashorn/examples/HelloWorldProgramOutput.Nashorn.js"/>
> 
>                  </exec>
> 
> Everything is checked in.

Confirming yes, it is there and apparently working OK.

Shall I add test.nashorn to the smoke tests?

Here is output that I am currently seeing.  Still getting errors regarding nashorn/jvm-npm.js input.readAllBytes and package.json:

========================================================================
ant -f C:\\x3d-code\\www.web3d.org\\x3d\\stylesheets\\java test.nashorn
test.nashorn:
Compile:
Compiling 2 source files to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\classes
Copy:
Copying 1 file to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples
Copying C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.x3d to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.x3d
Copying 1 file to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples
Copying C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.json to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.json
Run:
parameter: source file HelloWorldProgramOutput.x3d filesize 20771 bytes
parameter: "-toJS" for conversion to X3DJSONLD JavaScript source
parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.js" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn
convert to JS JavaScript:
Warning: nashorn/examples/HelloWorldProgramOutput.Nashorn.js does not meet suggested X3D naming conventions. Output serialization allowed to continue, file may be editable...
Warning: toFileJavaScript() is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Nashorn.js
Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
TypeError: input.readAllBytes is not a function
Error: Cannot read file [C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\node_modules\xmldom\package.json]:
[Error] TODO problem handling local exception within CommandLine, exiting
org.web3d.x3d.sai.X3DException: ScriptException when processing fileName nashorn\examples\HelloWorldProgramOutput.Nashorn.js.intermediate.js, unable to save result: javax.script.ScriptException: Error: Cannot load JSON file in nashorn/jvm-npm.js at line number 216 at column number 8
	at org.web3d.x3d.jsail.Core.X3DObject.toFileJavaScript(X3DObject.java:1602)
	at org.web3d.x3d.jsail.CommandLine.run(CommandLine.java:557)
	at org.web3d.x3d.jsail.Core.X3DObject.handleArguments(X3DObject.java:2572)
	at HelloWorldProgramOutput.main(HelloWorldProgramOutput.java:400)
parameter: source file HelloWorldProgramOutput.x3d filesize 20771 bytes
parameter: "-toJSON" for conversion to JSON encoding
parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.json" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn
convert to JSON:
Warning: nashorn/examples/HelloWorldProgramOutput.Nashorn.json does not meet suggested X3D naming conventions. Output serialization allowed to continue, file may be editable...
Warning: toFileStylesheetConversion(X3dToJson.xslt) is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Nashorn.json
Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
file conversion successful: HelloWorldProgramOutput.Nashorn.json (39182 bytes)
parameter: source file HelloWorldProgramOutput.x3d filesize 20771 bytes
parameter: "-toX3D" for conversion to X3D encoding
parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn
convert to X3D:
Warning: nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d does not meet suggested X3D naming conventions. Output serialization allowed to continue, file may be editable...
Warning: toFileX3D() is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d
file conversion successful: HelloWorldProgramOutput.Nashorn.x3d (20771 bytes)
===========================================
HelloWorldProgramOutput.Nashorn.x3d
1 file(s) have been successfully validated.
1 file(s) have been successfully validated.
matches HelloWorldProgramOutput.x3d: true
===========================================
script:
nashorn/examples/HelloWorldProgramOutput.Nashorn.js:1 TypeError: Cannot load script from node/X3Dautoclass.js
Result: 102
BUILD SUCCESSFUL (total time: 12 seconds)
========================================================================

p.s. this warning is overzealous, will try to tune that better:
"Warning: nashorn/examples/HelloWorldProgramOutput.Nashorn.js does not meet suggested X3D naming conventions."

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/20180128/5c1726d9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CreateX3dSceneAccessInterfaceJava.xslt.patch
Type: application/octet-stream
Size: 3153 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180128/5c1726d9/attachment-0001.obj>


More information about the x3d-public mailing list