[x3d-public] X3DJSAIL updated; python pyjnius mapping, javascript warnings,cleaner .py export syntax

John Carlson yottzumm at gmail.com
Sun May 12 20:49:39 PDT 2019


Very clever adding a () around the entire expression!  I like it!  What a stroke of inspiration!

Would you prefer something like X3Dautoclass.py instead of  org/…

Loren suggested adding a prefix, say x3dpsail to each variable, so we only expose one thing to the python namespace.  But we have to change all the generated code in that case to have a prefix before each constructor.

Can we do both?

Thinking.  Maybe I will arrive at a compromise if you don’t have a good idea.

John
Sent from Mail for Windows 10

From: Brutzman, Donald (Don) (CIV)
Sent: Sunday, May 12, 2019 2:39 PM
To: John Carlson
Cc: X3D Graphics public mailing list
Subject: Re: X3DJSAIL updated; python pyjnius mapping, javascript warnings,cleaner .py export syntax

On 5/11/2019 6:46 PM, John Carlson wrote:
> Fixed, checked in.

thank you.

Found some issues with PythonPipeliningSerializer.js:

- Netbeans provides a number of warnings, worked as follows to clear them.
- semicolons added where indicated

- printSubArray method had a number of issues
-- nested variable v defined multiple times, renamed it to vv within nested scope
-- irregular indentation led to variable v later being out of scope;
-- reason was premature completion of integer "for (var v in values)" loop
-- moved closing } to put everything appropriate within loop, please check

- thanks for fixing "if (attrType.startsWith("SF"))"

- changed some identity operators == to equality operators ===
	https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons
note that Douglas Crockford is quoted as
	"JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. [...] The lack of transitivity is alarming. My advice is to never use the evil twins. Instead, always use === and !==."

- i worked on removing line-continuation characters completely by wrapping entire expression in one extra set of parentheses
- comments now appear on a new line for readability
- changed \r\n to \n for consistency throughout, seemed OK
- output line breaks inserted between sections and otherwise minimized for readability

Still getting an error: Unexpected 'const'
const DOUBLE_SUFFIX = '';

Checked in these changes to PythonPipeliningSerializer.js.

Clean example attached - better and better.

> Do you have an example we can test with?

I continue focusing on HelloWorld.x3d and corresponding HelloWorld.py

Moving around and removing sections of .x3d source can push the error around...

Each time, am only able to get errors in .py file of the form

     .addChild(Viewpoint().setDEF("ViewUpClose").setCenterOfRotation(0,-1,0).setDescription("Hello world!").setPosition(0,-1,7))
     AttributeError: 'org.web3d.x3d.sai.Navigation.X3DViewpointNode' object has no attribute 'setCenterOfRotation'

     .setMaterial(Material().setDEF("MaterialLightBlue").setDiffuseColor(0.1,0.5,1))
     AttributeError: 'org.web3d.x3d.sai.Shape.X3DMaterialNode' object has no attribute 'setDiffuseColor'

     .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"]))))))))
     AttributeError: 'org.web3d.x3d.sai.Texturing.X3DTextureNode' object has no attribute 'setUrl'

so it sure looks like it has something to do with incorrect handling of direct methods, it seems OK when a method is found in abstract parent of an object class.

> Thanks,
> 
> John
> 
> Index: PythonPipeliningSerializer.js
> 
> ===================================================================
> 
> --- PythonPipeliningSerializer.js       (revision 28463)
> 
> +++ PythonPipeliningSerializer.js       (working copy)
> 
> @@ -82,7 +82,7 @@
> 
>                          values.pop();
> 
>                  }
> 
> -               if (type.startsWith("SF")) // TODO fix this javascript, test is not working
> 
> +               if (attrType.startsWith("SF"))
> 
>               return     lead+values.join(j)+trail; // avoid array brackets on SF types
> 
>           else
> 
>               return '['+lead+values.join(j)+trail+']';
> 
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
> 
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Saturday, May 11, 2019 8:39 PM
> *To: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *Subject: *RE: X3DJSAIL updated support for setting with doubles; pythonpyjniusmapping
> 
> ==========================================
> 
>  >2. Also tried to get PythonPipeliningSerializer.js to avoid brackets on simple and numeric types.
> 
>  >Checked in block that didn't work, please fix and check back in:
> 
>                                  if (type.startsWith("SF")) // TODO fix this javascript, test is not working
> 
>               return     lead+values.join(j)+trail; // avoid array brackets on SF types
> 
>           else
> 
>               return '['+lead+values.join(j)+trail+']';
> 
> ==========================================
> 
> I logged type, and these appear to be Java types.  So we’ll have to change type to attrType or something. Will do.
> 
> John
> 


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/20190512/3d7f9555/attachment.html>


More information about the x3d-public mailing list