[x3d-public] questions on X3DJSAIL usage.

Leonard Daly Leonard.Daly at realism.com
Wed May 8 18:17:55 PDT 2019


John,

Are you referring to:

DOM does not support elements with multiple parents. Each element can 
have at most one parent (see second paragraph at 
https://dom.spec.whatwg.org/#trees or if you don't want the living spec 
then use https://www.w3.org/TR/dom/#trees).

and for X3D

http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/concepts.html#DEFL_USESemantics

"The USE statement does not create a copy of the node. Instead, the same 
node is inserted into the scene graph a second time, resulting in the 
node having multiple parents..."


Leonard Daly


> Leonard, can you repost the link to the standard where it talks about 
> the multiparent (not parent reference) situation when setting the USE 
> field.
>
> I do feel we can serialize a multiparent tree using a symbol table
> https://en.m.wikipedia.org/wiki/Symbol_table
> .   I have been discussing potential solutions in my emails, as has 
> Leonard.  We have 3-4 solutions, where a symbol table is preferred for 
> JavaScript translator programs.   I am not sure about import/export 
> and stylesheets as I have not looked into those.   Leonard suggested 
> 1) a deep copy and 2) subclassing the USE node from the DEF node.
>
> According to your SAI code, setUSE can only take a string, not a node, 
> hence my suggestion to (nearly) obliviate setUSE, if indeed we support 
> multiparent.
>
> Another option is to set a flag somewhere when you write out a DEF, so 
> the next time you reach the DEF node, you will print out a USE.  
> Again, I am not sure if stylesheets handle these.
>
> On Wed, May 8, 2019 at 5:16 PM John Carlson <yottzumm at gmail.com 
> <mailto:yottzumm at gmail.com>> wrote:
>
>     Leonard pointed out that setting USE according to the standard
>     created a multiparent situation.  I was merely trying to respond
>     to that. Perhaps the standard needs changing?
>
>     On Wed, May 8, 2019 at 11:25 AM Brutzman, Donald (Don) (CIV)
>     <brutzman at nps.edu <mailto:brutzman at nps.edu>> wrote:
>
>         OK thanks John, I now see where you are going on this.
>
>         The existing .setUse(someDefString) method simply applies a
>         string to the scene graph.
>
>         Next: I am renaming your DEF label to avoid ambiguity.  For
>         your constructs
>
>                 MaterialLightBlue = None;
>         ...
>                 .setMaterial(MaterialLightBlue =
>         Material().setDEF("MaterialLightBlueLabel").setDiffuseColor([0.1,0.5,1])
>         ...
>         .setAppearance(Appearance().setMaterial(MaterialLightBlue)
>         ...
>
>         the third line could be rewritten today as
>
>         .setAppearance(Appearance().setMaterial(Material().setUSE(MaterialLightBlue.getDEF())
>
>         Programming hint: the key to thinking about any scene graph
>         you construct programmatically is to consider how it will
>         serialize out to the .x3d or .x3dv file encoding.  That is how
>         I disambiguate mysterious cases.
>
>         Looking forward: the approach you describe is pretty
>         interesting.  I think the way you have written it, each
>         occurrence of MaterialLightBlue would be written out
>         explicitly and the results would have the DEF value of
>         MaterialLightBlueLabel recurring multiple times (thus causing
>         a duplicate DEF error in the .x3d file).  Might other utility
>         methods be possible?  Not yet clear...  So it is not clear
>         that a further approach is yet achievable but certainly worth
>         thinking about.  Thanks.
>
>
>         On 5/6/2019 3:23 PM, John Carlson wrote:
>         > Here’s a an example removing setUSE().  See uses of
>         MaterialLightBlue.
>         >
>         > import classpath
>         >
>         > from org.web3d.x3d.jsail.Core.X3DObject import X3DObject as X3D
>         >
>         > from org.web3d.x3d.jsail.fields.SFStringObject import
>         SFStringObject as SFString
>         >
>         > from org.web3d.x3d.jsail.Core.headObject import headObject
>         as head
>         >
>         > from org.web3d.x3d.jsail.Core.metaObject import metaObject
>         as meta
>         >
>         > from org.web3d.x3d.jsail.Core.SceneObject import SceneObject
>         as Scene
>         >
>         > from org.web3d.x3d.jsail.Grouping.GroupObject import
>         GroupObject as Group
>         >
>         > from org.web3d.x3d.jsail.Navigation.ViewpointObject import
>         ViewpointObject as Viewpoint
>         >
>         > from org.web3d.x3d.jsail.fields.SFVec3fObject import
>         SFVec3fObject as SFVec3f
>         >
>         > from org.web3d.x3d.jsail.Grouping.TransformObject import
>         TransformObject as Transform
>         >
>         > from org.web3d.x3d.jsail.fields.SFRotationObject import
>         SFRotationObject as SFRotation
>         >
>         > from org.web3d.x3d.jsail.Shape.ShapeObject import
>         ShapeObject as Shape
>         >
>         > from org.web3d.x3d.jsail.Geometry3D.SphereObject import
>         SphereObject as Sphere
>         >
>         > from org.web3d.x3d.jsail.Shape.AppearanceObject import
>         AppearanceObject as Appearance
>         >
>         > from org.web3d.x3d.jsail.Shape.MaterialObject import
>         MaterialObject as Material
>         >
>         > from org.web3d.x3d.jsail.fields.SFColorObject import
>         SFColorObject as SFColor
>         >
>         > from org.web3d.x3d.jsail.Texturing.ImageTextureObject import
>         ImageTextureObject as ImageTexture
>         >
>         > from org.web3d.x3d.jsail.fields.MFStringObject import
>         MFStringObject as MFString
>         >
>         > from org.web3d.x3d.jsail.Text.TextObject import TextObject
>         as Text
>         >
>         > from org.web3d.x3d.jsail.Text.FontStyleObject import
>         FontStyleObject as FontStyle
>         >
>         > MaterialLightBlue = None;
>         >
>         > X3D0 = X3D() \
>         >
>         >     .setProfile("Immersive") \
>         >
>         >     .setVersion("3.3") \
>         >
>         >     .setHead(head() \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.x3d") \
>         >
>         >       .setName("title") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("Simple X3D scene example: Hello World!") \
>         >
>         >       .setName("description") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("30 October 2000") \
>         >
>         >       .setName("created") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("28 July 2015") \
>         >
>         >       .setName("modified") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("Don Brutzman") \
>         >
>         >       .setName("creator") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.tall.png") \
>         >
>         >       .setName("Image") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("http://en.wikipedia.org/wiki/Hello_world") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("https://en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program")
>         \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("https://en.wikipedia.org/wiki/\
>         <https://en.wikipedia.org/wiki/%5C>"Hello,_World!\"_program") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("http://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world")
>         \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("http://www.HelloWorldExample.net") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("http://www.web3D.org") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("http://www.web3d.org/realtime-3d/news/internationalization-x3d")
>         \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("http://www.web3d.org/x3d/content/examples/HelloWorld.x3d")
>         \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("http://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes")
>         \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d")
>         \
>         >
>         >       .setName("identifier") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >      
>         .setContent("http://www.web3d.org/x3d/content/examples/license.html")
>         \
>         >
>         >       .setName("license") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("X3D-Edit 3.3,
>         https://savage.nps.edu/X3D-Edit") \
>         >
>         >       .setName("generator") \
>         >
>         >      ) \
>         >
>         > # Alternate encodings: VRML97, X3D ClassicVRML Encoding, X3D
>         Compressed Binary Encoding (CBE), X3DOM, JSON
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.wrl") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.x3dv") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.x3db") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.xhtml") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >      .addMeta(meta() \
>         >
>         >       .setContent("HelloWorld.json") \
>         >
>         >       .setName("reference") \
>         >
>         >      ) \
>         >
>         >     ) \
>         >
>         >     .setScene(Scene() \
>         >
>         > # Example scene to illustrate X3D nodes and fields (XML
>         elements and attributes)
>         >
>         >      .addChild(Group() \
>         >
>         >       .addChild(Viewpoint() \
>         >
>         >        .setDEF("ViewUpClose") \
>         >
>         >        .setCenterOfRotation([0,-1,0]) \
>         >
>         >        .setDescription("Hello world!") \
>         >
>         >        .setPosition([0,-1,7]) \
>         >
>         >       ) \
>         >
>         >       .addChild(Transform() \
>         >
>         >        .setRotation([0,1,0,3]) \
>         >
>         >        .addChild(Shape() \
>         >
>         >         .setGeometry(Sphere() \
>         >
>         >         ) \
>         >
>         >         .setAppearance(Appearance() \
>         >
>         >          .setMaterial(MaterialLightBlue = Material() \
>         >
>         >           .setDEF("MaterialLightBlue") \
>         >
>         >           .setDiffuseColor([0.1,0.5,1]) \
>         >
>         >          ) \
>         >
>         >          .setTexture(ImageTexture() \
>         >
>         >           .setDEF("ImageCloudlessEarth") \
>         >
>         >
>         .setUrl(["earth-topo.png","earth-topo.jpg","earth-topo-small.gif","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg","http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"])
>         \
>         >
>         >          ) \
>         >
>         >         ) \
>         >
>         >        ) \
>         >
>         >       ) \
>         >
>         >       .addChild(Transform() \
>         >
>         >        .setTranslation([0,-2,0]) \
>         >
>         >        .addChild(Shape() \
>         >
>         >         .setGeometry(Text() \
>         >
>         >          .setDEF("TextMessage") \
>         >
>         >          .setString(["Hello","world!"]) \
>         >
>         >          .setFontStyle(FontStyle() \
>         >
>         >           .setJustify(["MIDDLE","MIDDLE"]) \
>         >
>         >          ) \
>         >
>         >         ) \
>         >
>         >         .setAppearance(Appearance() \
>         >
>         >          .setMaterial(MaterialLightBlue)
>         >
>         >          ) \
>         >
>         >         ) \
>         >
>         >        ) \
>         >
>         >       ) \
>         >
>         >      ) \
>         >
>         >     ) \
>         >
>         > X3D0.toFileX3D("HelloWorld_RoundTrip.x3d")
>         >
>         > Sent from Mail
>         <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>         >
>         > *From: *John Carlson <mailto:yottzumm at gmail.com
>         <mailto:yottzumm at gmail.com>>
>         > *Sent: *Monday, May 6, 2019 4:52 PM
>         > *To: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu
>         <mailto:brutzman at nps.edu>>; aono at tut.jp <mailto:aono at tut.jp>
>         <mailto:aono at tut.jp <mailto:aono at tut.jp>>; Leonard Daly
>         <mailto:Leonard.Daly at realism.com
>         <mailto:Leonard.Daly at realism.com>>
>         > *Cc: *X3D Graphics public mailing list
>         <mailto:x3d-public at web3d.org <mailto:x3d-public at web3d.org>>
>         > *Subject: *RE: questions on X3DJSAIL usage.
>         >
>         > 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 <mailto:brutzman at nps.edu>>
>         > *Sent: *Monday, May 6, 2019 2:18 AM
>         > *To: *John Carlson <mailto:yottzumm at gmail.com
>         <mailto:yottzumm at gmail.com>>; aono at tut.jp <mailto:aono at tut.jp>
>         <mailto:aono at tut.jp <mailto:aono at tut.jp>>
>         > *Cc: *X3D Graphics public mailing list
>         <mailto:x3d-public at web3d.org <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 <mailto: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
>         >
>
>
>         all the best, Don
>         -- 
>         Don Brutzman  Naval Postgraduate School, Code USW/Br
>         brutzman at nps.edu <mailto: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/20190508/92c2a33b/attachment-0001.html>


More information about the x3d-public mailing list