[x3d-public] questions on X3DJSAIL usage.

John Carlson yottzumm at gmail.com
Mon May 6 14:44:07 PDT 2019

I am not being clear perhaps.  I would replace a constructor().setUSE() pair with a variable, where a lookup symbol table is constructed from DEF nodes and variable names.   The variable would refer to the DEF node instead of the using a USE.  I think your explanation (1) below is incomplete?  What I am implying is we don’t need setUSE() in programs in most cases, we can use a symbol table for code generation to look up DEFs.  I need to look up how you implemented setUSE.

You wrote: “- no apparent need to wrap SFString() in python syntax.”  Yes, we do need that to avoid AttributeErrors in HelloWorld.future.py (your HelloWorld.py).    See a previous email (I will reforward to the list).    We are conflicting with typical SAI usage doing that however.  SAI alone doesn’t work.  Sorry, I haven’t been clear on my fixes.  Wrapping strings, arrays, etc.  stop AttributeErrrors.

You have wrapping in Java, but you don’t need it.   That is the difference between Java and Python. I think you’ll discover this when you rerun perhaps, if you’ve modified or replaced my Python serializer.

If my previous email does indeed work on your system, I need to adapt my system somehow.  Hmm.

Sent from Mail for Windows 10

From: Brutzman, Donald (Don) (CIV)
Sent: Monday, May 6, 2019 2:18 AM
To: John Carlson; aono at tut.jp
Cc: X3D Graphics public mailing list
Subject: Re: questions on X3DJSAIL usage.

On 5/4/2019 4:15 PM, John Carlson wrote:
> I’m waiting for a response on whether I should stop using setUSE() (except in cases where > 1 fields are used in a node) in programs using X3DJSAIL.
> Thanks!
> John

Hmmm, perhaps I'm not understanding your question... but here is an attempt at a simple answer.  Plus some additional syntactic sugar.

1. I think a programmer utilizes setUSE() whenever you need to set a USE value on a node.

Example excerpts:


       <Transform translation='0 -2 0'>
           <Text DEF='TextMessage' string='"Hello" "world!"'>
             <FontStyle justify='"MIDDLE" "MIDDLE"'/>
             <Material USE='MaterialLightBlue'/>


       .addChild(new TransformObject().setTranslation(0.0f,-2.0f,0.0f)
         .addChild(new ShapeObject()
           .setGeometry(new TextObject("TextMessage").setString(new MFStringObject("\"Hello\" \"world!\""))
             .setFontStyle(new FontStyleObject().setJustify(FontStyleObject.JUSTIFY_MIDDLE_MIDDLE)))
           .setAppearance(new AppearanceObject()
             .setMaterial(new MaterialObject().setUSE("MaterialLightBlue")))))));


      .addChild(Transform() \
       .setTranslation(SFVec3f([0,-2,0])) \
       .addChild(Shape() \
        .setGeometry(Text() \
         .setDEF(SFString("TextMessage")) \
         .setString(MFString(["Hello","world!"])) \
         .setFontStyle(FontStyle() \
          .setJustify(MFString(["MIDDLE","MIDDLE"])) \
         ) \
        ) \
        .setAppearance(Appearance() \
         .setMaterial(Material() \
          .setUSE(SFString("MaterialLightBlue")) \
         ) \
        ) \
       ) \

2. Note that if we start putting field adjustments on the same line, the structure for .java and .py are nearly identical.

Other syntax tightening is further possible in .py version:
- no apparent need to wrap SFString() in python syntax
- I suspect that MFString() wrapping is also superfluous, hopefully we can just use ["Hello","world!"]
- Similarly might try replacing SFVec3f([0,-2,0]) with [0,-2,0] - we're getting more Pythonic now!
- indenting with two space characters makes scene-graph structure more evident.

3. Spent the day refactoring the X3D Examples Archive projects from Netbeans plain-old freeform projects to Netbeans Java freeform projects.  This doesn't limit any functionality but it does make Java experimentation much simpler... menu items now include Compile/Run/Debug options.

4. Am further noticing from above that the following single-string .java construct

	.setString(new MFStringObject("\"Hello\" \"world!\""))

is more readable as a String array instead:

	.setString(new MFStringObject(new String[] {"Hello","world!"}))

or even more simply as:

	.setString(new String[] {"Hello","world!"})

Have improved X3dToJava.xslt conversions to simplify accordingly.  Will rerun all java conversions tonight and hopefully redeploy Web3D example archives tomorrow.  Then retest python build tomorrow night.

Also will redeploy X3DJSAIL with this improvement tonight.  Have also added initial PointProperties validation for X3Dv4, included source in full.jar for IDE javadoc/debugging, and fixed a number of X3DLoaderDOM geospatial errors.

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/20190506/4f29b0ba/attachment.html>

More information about the x3d-public mailing list