[x3d-public] X3DJSAIL updated support for setting with doubles; python pyjnius mapping

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Sat May 11 17:00:25 PDT 2019

Hi John, have made some more progress.


1. Added autogeneration of a lot of new methods to X3DJSAIL field-object constructors to allow flexibility in using either floats or doubles.  Also corresponding unit tests, looks pretty thorough.  These should help Plain Old Java programmers too.

Build updates checked in and currently uploading.



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
             return '['+lead+values.join(j)+trail+']';


3. Also have turned off field-object casting in order to chase duck typing:

	// Object typing when setting values:
//	setstr += '.'+method+"("+attrType+"("+strval+"))";// field type casting
	setstr += '.'+method+"("+             strval+")"; // avoid type casting


4. Rename possibility: since

	fieldTypes.py  creates fieldTypes.js
	mapToMethod.py creates mapToMethod.js

recommend we get clearer about functionality by renaming two files:

	fieldTypes.py renamed as fieldTypesGenerator.py

	mapToMethod.py renamed as mapToMethodGenerator.py


5. we're still having trouble with pyjnius finding the appropriate method:

- - - - - -
Loading HelloWorld.py (pipeline syntax) with python, if successful then saving and validating as HelloWorld_RoundTrip2.x3d version:
Traceback (most recent call last):
   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//HelloWorld.py", line 74, in <module>
     .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'
- - - - - -

As before, not clear why parent X3DViewpointNode object gets tagged.   Suspect it is because pyjnius can't find the correct method signature in ViewpointObject, and so goes to parent abstract class.


6. Looking at set methods, there is now a rich choice available in underlying X3DJSAIL ViewpointObject class:


public ViewpointObject setCenterOfRotation(float[] newValue)
public ViewpointObject setCenterOfRotation(double[] newArray)

public ViewpointObject setCenterOfRotation(float x,float y,float z)
public ViewpointObject setCenterOfRotation(double x, double y, double z)

public ViewpointObject setCenterOfRotation(SFVec3fObject newValue)

Thus it is puzzling why the pyjnius exception for   .setCenterOfRotation([0,-1,0]) occurs.

Also got same pyjnius exception for non-array form, .setCenterOfRotation(0,-1,0) also.


7.  So, if the target setSomeFieldName(double) methods are available in the X3DJSAIL Java API, then the pyjnius mapping must have a twist in its knickers.

Pretty twisty syntax, certainly:




I think you perform incantations + hand waving in the script pynius/reflect.py but pretty hard to follow...


8. Conclusions for now:

- You should find a rich set of float and double methods available to set values.

- We need to take a close look at pyjnius mapping to non-node fields.  Not much else left to get wrong on this problem, so this is probably where the problem lies.

Incremental improvements remain welcome.  Back to you sir.

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

More information about the x3d-public mailing list