[x3d-public] X3DJSAIL. Use of fields in ProtoInterface. addField() nolongerworks.

yottzumm at gmail.com yottzumm at gmail.com
Wed Feb 15 16:08:02 PST 2017


JSON attached.

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Wednesday, February 15, 2017 5:25 PM
To: Don Brutzman
Cc: X3D Graphics public mailing list; Roy Walmsley
Subject: Re: X3DJSAIL. Use of fields in ProtoInterface. addField() nolongerworks.

What I'm trying to do: add an MFNode or SFNode typed field to a ProtoInterface with addField().  If this is not the right thing to do, let me know.   Apparently, when you add the field, it validates it, then calls setValue.   SetValue is not the right thing to call for a SFNode or MFNode, afaik.   I am just reading the error message and not the X3DJSAIL code.

I hope this helps!

BTW, if you want to use my JavaSerializer.js, I should be able to give you any license you want.   It's currently licensed with a BSD license.   It does the job of DOM -> Java program   Obviously a rewrite in Java is desirable, especially the mapToMethod could be improved.  If you are going to write something using reflection, I encourage you to provide an output Java version for source code control.

Oh, and I heartily disagree with creating a Java version by hand :).  It will likely get blown away next time I convert from JSON.  I regularly remove all java files except the for those used by running the X3dToJson.xslt

You probably have an attachment with abox.json in it, but I will try to provide a copy.
John

On Feb 15, 2017 12:32 PM, "Don Brutzman" <brutzman at nps.edu> wrote:
On 2/14/2017 8:08 PM, yottzumm at gmail.com wrote:
Don,

Are you requiring the Java 8 syntax for X3DJSAIL application programmers?  Thanks!

No restrictions.  The declarative approach is an interesting style and no backwards compatibility with classical programming practice is sacrificed.

also: Thank You for continuing reports such as the following, John.  i first need to get out of "tall grass" of DOM + Java Reflection but will keep getting back to these and sorting each one out, they are very important.
*From: *yottzumm at gmail.com <mailto:yottzumm at gmail.com>
*Sent: *Tuesday, February 14, 2017 11:00 PM
*To: *Don Brutzman <mailto:brutzman at nps.edu>; Roy Walmsley <mailto:roy.walmsley at ntlworld.com>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
*Subject: *X3DJSAIL. Use of fields in ProtoInterface. addField() no longerworks.


Please provide example of calling setChildren() with multiple field objects, or perhaps allow addChildren().  Haven’t spent too much time on this, addChildren() may work.  Perhaps fix addField() to allow MFNode and SFNode, or remove from API??  Have validate call setChildren or addChildren for MFNodes and SFNodes?  Many choices here. Modify fieldObject to not throw an exception of addChildren() is called on fieldObject?

preliminary answer: please see the HelloWorldProgram.java for many example invocations.

secondary answer:  the pre-existing Java SAI interfaces are sometimes more restrictive that we might hope.  Working document to keep track of issues at

        http://www.web3d.org/specifications/java/X3dJavaSceneAuthoringInterface.html#SpecificationChanges

        http://www.web3d.org/specifications/java/X3dJavaSpecificationChangesAndIssues.txt

third answer: have been experimenting with JSAIL utility methods, such as pipelined addChild which can be easier to use sometimes.

        http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Grouping/GroupObject.html#addChild-org.web3d.x3d.sai.Core.X3DChildNode-

fourth answer: protos are especially tricky but definitely converging to meet use cases.  work in progress, let's keep pushing!!  8)


Abox.java (attached)

Exception in thread "main" org.web3d.x3d.sai.InvalidProtoException: field name='myShape' with type='MFNode' cannot have any simple-type value (newValue='').  Use setChildren() method instead.

        at org.web3d.x3d.jsail.Core.fieldObject.setValue(fieldObject.java:770)
        at org.web3d.x3d.jsail.Core.fieldObject.validate(fieldObject.java:1044)
        at org.web3d.x3d.jsail.Core.ProtoInterfaceObject.addField(ProtoInterfaceObject.java:466)
        at abox.main(abox.java:88)

not quite understanding what you are trying to do here...

suggested approach:
- you will hopefully find an existing pattern (or TODO comment) in HelloWorldProgram
- show regular-encoding version of your goal scene for understanding (.x3d or .json or .x3dv or .wrl)
- let's build the java manually to match, once understood then go for the pattern

I noted the change to the package structure.

glad to hear, again thanks.

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/20170215/25a8f005/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abox.json
Type: application/json
Size: 3797 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170215/25a8f005/attachment-0001.json>


More information about the x3d-public mailing list