[x3d-public] questions on X3DJSAIL usage.

Leonard Daly Leonard.Daly at realism.com
Mon May 6 16:16:10 PDT 2019


John,

I guess I am not sure what setUSE is suppose to do. I my world of 3D 
graphics (note that this is not X3D), a node may only have a single 
parent. If the intent of setUse is to duplicate the content tree 
starting with another node, I would need to decide if that is better 
done as a deep copy (independent content) or the DEF node is to be 
sub-classed. Also note that for me, SAI === DOM + some 3D interfaces.

A deep copy would need to copy the node and attribute structure and 
content starting with the identified node. I would need to modify the ID 
attribute values so there were no duplicates, probably defining a unique 
suffix at the start of the copy operation and appending that to each ID 
value from the original tree. Note that the copy operation needs to 
avoid copying any non-DOM-tree objects. I would likely first consider 
converting the DOM-tree from the source ID to an HTML string, then parse 
that into a DOM-tree not connected (yet) to the document. At that point, 
updating the IDs is easier. Once the copying is complete and the DOM 
updated, there is no relationship between the original source nodes and 
the new nodes. There are situations where this works well, and there are 
times when it doesn't really work at all.

The other choice is more programmatic in nature. It would create 3D 
objects/structure, but not directly include those objects in the 
DOM-tree. It would probably be easier to established the original nodes 
as a (non-X3D) prototype that is not directly instantiated. "USE" 
references references would sub-class the prototype and instantiate the 
sub-class, potentially overriding some "methods" or "data". Changes to 
the prototype would be propagated to all of the sub-classes. This method 
is more complex, and I have not thought it out as well (and deeply).

I am not sure if this answers your question/request.

Leonard Daly



> Leonard, can you explain for us how we can write an SAI program 
> avoiding setUSE()?  Apparently, my explanations aren’t getting through.
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
> *Sent: *Monday, May 6, 2019 2:18 AM
> *To: *John Carlson <mailto:yottzumm at gmail.com>; aono at tut.jp 
> <mailto:aono at tut.jp>
> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *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:
>
> http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview
>
> HelloWorld.x3d
>
>        <Transform translation='0 -2 0'>
>
>          <Shape>
>
>            <Text DEF='TextMessage' string='"Hello" "world!"'>
>
>              <FontStyle justify='"MIDDLE" "MIDDLE"'/>
>
>            </Text>
>
>            <Appearance>
>
>              <Material USE='MaterialLightBlue'/>
>
>            </Appearance>
>
>          </Shape>
>
>        </Transform>
>
> HelloWorld.java
>
>        .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")))))));
>
> HelloWorld.py
>
>       .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
>
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org


-- 
*Leonard Daly*
3D Systems & Cloud Consultant
LA ACM SIGGRAPH Past Chair
President, Daly Realism - /Creating the Future/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190506/507ac4b9/attachment.html>


More information about the x3d-public mailing list