[x3d-public] X3DJSail Texture coordinates

Don Brutzman brutzman at nps.edu
Fri Jul 20 03:33:31 PDT 2018

Laurent, thanks for this helpful issue report and subsequent permission to share the information.

Your diagnosis was accurate.  Indeed there was an ambiguity in X3DLoaderObject (which uses DOM and Java reflection to create Java out of X3D source).  Now fixed, updates uploaded.

ant -f C:\\x3d-code\\www.web3d.org\\x3d\\stylesheets test.TestSurface
translation input: test/TestSurface.x3d
..expected output: test/TestSurface.java
Deleting: C:\x3d-code\www.web3d.org\x3d\stylesheets\test\TestSurface.java
Compiling 1 source file to C:\x3d-code\www.web3d.org\x3d\stylesheets\test
test TestSurface execution and self-validation:
Java program "TestSurface" self-validation test results: success
BUILD SUCCESSFUL (total time: 3 seconds)
     <target name="test.TestSurface" >
		<echo message="==========================================="/>
         <echo message="translation input: test/TestSurface.x3d"/>
         <echo message="..expected output: test/TestSurface.java"/>
         <delete file="test/TestSurface.java" failonerror="false"/>
         <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
             <!-- <arg value="-t"/>  timing information -->
             <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
             <arg value="-expand:on"/>  <!-- force insertion of default attribute values found in DTD -->
             <arg value="-s:test/TestSurface.x3d"/>  <!-- source-doc -->
             <arg value="-o:test/TestSurface.java"/> <!-- output-doc -->
             <arg value="-xsl:X3dToJava.xslt"/> <!-- style-doc -->
             <arg value="className=TestSurface"/> <!-- parameter -->
		<echo message="compile..."/>
         <javac includes="TestSurface.java"
                 includeantruntime="false" fork="${fork}">
			<!-- -Xlint reports problem with direct object invocation of .isNode() or isStatement()
			<compilerarg value="-Xlint"/>
		<!-- self-validation test -->
		<echo message="test TestSurface execution and self-validation:"/>
		<java classname="TestSurface"
			  classpath="test;${java.jars.dir}/${jsai.full.archive.jar.name};" fork="${fork}">
		<echo message="==========================================="/>

Not sure why this important TextureCoordinate case wasn't caught earlier by unit tests, will investigate further.

If you like, I'll add this model to the X3DJSAIL examples test suite.  In any case will make sure there is coverage.

Again thanks, good luck with your experimentation.  All feedback welcome, have fun with X3DJSAIL!  8)

On 7/18/2018 2:56 AM, Laurent Renard wrote:
> Hi,
> I am experimenting with X3DJSail. Unfortunately, I am facing an issue with texture coordinates.
> When I export my model I set texture coordinates to a IndexedFaceSetObject
> /TextureCoordinateObject texCoords = new TextureCoordinateObject();
>          texCoords.setPoint(refValues);
> /
> /IndexedFaceSetObject faceset = new IndexedFaceSetObject();
>          CoordinateObject x3dCoords = new CoordinateObject();
>          x3dCoords.setPoint(refCoords);
>          faceset.setCoord(x3dCoords);
> *        faceset.setTexCoord(texCoords);*/
> But when I try to load the file I reach a class cast exception :
> [X3DLoaderObject error] Incorrectly handled object construction, current elementObject=IndexedFaceSet (IndexedFaceSet), child=TextureCoordinate, java.lang.ClassCastException: org.web3d.x3d.jsail.Texturing.TextureCoordinateObject cannot be cast to org.web3d.x3d.sai.Rendering.X3DCoordinateNode
> java.lang.ClassCastException: org.web3d.x3d.jsail.Texturing.TextureCoordinateObject cannot be cast to org.web3d.x3d.sai.Rendering.X3DCoordinateNode
>      at org.web3d.x3d.jsail.X3DLoaderObject.toX3dObjectTree(X3DLoaderObject.java:765)
> It is as if every time an IndexedFaceSet has a child which name contains "coordinate" it is treated has Coordinate. Therefore TextureCoordinate node can't be restored.
> Perhaps I am doing something wrong. Can you help me with my issue ?
> (You will find attached to this mail the file that I can't load).
> Regards,
> Laurent Renard
> /Project Manager at INT France
> +33 6 64 92 01 43
> /
> /
> /
> /Technopole Hélioparc
> 4 rue Jules Ferry
> CS 99207
> 64053 PAU Cedex 9/
> /www.int.com <http://www.int.com/>/

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 --------------
A non-text attachment was scrubbed...
Name: testSurface.x3d
Type: model/x3d+xml
Size: 1660 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180720/3c1f706f/attachment.x3d>

More information about the x3d-public mailing list