[x3d-public] questions on X3DJSAIL usage.

John Carlson yottzumm at gmail.com
Mon May 6 14:52:08 PDT 2019

Leonard, can you explain for us how we can write an SAI program avoiding setUSE()?  Apparently, my explanations aren’t getting through.


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/391cffae/attachment-0001.html>

More information about the x3d-public mailing list