[x3d-public] CubeMap Textures in X3DJSAIL. Breaking bug! back/backTexture used 6 times instead of once. Please fix very soon, so I can use X3DJSAIL
John Carlson
yottzumm at gmail.com
Tue Jun 1 21:41:38 PDT 2021
So let's look at some of the products of X3DJSAIL and X3DJSONLD (either
through Java or Node.js). I backed out my change in the XML back to 3.3
~/X3DJSONLD/src/main/data$ egrep ImageTexture ball.x3d ball.x3d.new
ball.newPrettyPrint.intermediate.x3d ball.new.x3d
[ this is the original XML file. See the 6 different containerFields ]
ball.x3d: <ImageTexture
url='"../resources/images/all_probes/stpeters_cross/stpeters_back.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_back.png"'
containerField="backTexture"/>
ball.x3d: <ImageTexture
url='"../resources/images/all_probes/stpeters_cross/stpeters_bottom.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_bottom.png"'
containerField="bottomTexture"/>
ball.x3d: <ImageTexture
url='"../resources/images/all_probes/stpeters_cross/stpeters_front.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_front.png"'
containerField="frontTexture"/>
ball.x3d: <ImageTexture
url='"../resources/images/all_probes/stpeters_cross/stpeters_left.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_left.png"'
containerField="leftTexture"/>
ball.x3d: <ImageTexture
url='"../resources/images/all_probes/stpeters_cross/stpeters_right.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_right.png"'
containerField="rightTexture"/>
ball.x3d: <ImageTexture
url='"../resources/images/all_probes/stpeters_cross/stpeters_top.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_top.png"'
containerField="topTexture"/>
[ this is the XML after the JSON goes through X3DJSONLD.js. Notice that
containerField names are preserved. ]
ball.x3d.new:<ComposedCubeMapTexture containerField="texture"
DEF="texture"><ImageTexture containerField="backTexture"
url=""../resources/images/all_probes/stpeters_cross/stpeters_back.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_back.png""></ImageTexture>
ball.x3d.new:<ImageTexture containerField="bottomTexture"
url=""../resources/images/all_probes/stpeters_cross/stpeters_bottom.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_bottom.png""></ImageTexture>
ball.x3d.new:<ImageTexture containerField="frontTexture"
url=""../resources/images/all_probes/stpeters_cross/stpeters_front.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_front.png""></ImageTexture>
ball.x3d.new:<ImageTexture containerField="leftTexture"
url=""../resources/images/all_probes/stpeters_cross/stpeters_left.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_left.png""></ImageTexture>
ball.x3d.new:<ImageTexture containerField="rightTexture"
url=""../resources/images/all_probes/stpeters_cross/stpeters_right.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_right.png""></ImageTexture>
ball.x3d.new:<ImageTexture containerField="topTexture"
url=""../resources/images/all_probes/stpeters_cross/stpeters_top.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_top.png""></ImageTexture>
[ this is the intermediate output from X3DJSAIL Note a single
containerField. ]
ball.newPrettyPrint.intermediate.x3d: <ImageTexture
containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_back.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_back.png"'/>
ball.newPrettyPrint.intermediate.x3d: <ImageTexture
containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_bottom.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_bottom.png"'/>
ball.newPrettyPrint.intermediate.x3d: <ImageTexture
containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_front.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_front.png"'/>
ball.newPrettyPrint.intermediate.x3d: <ImageTexture
containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_left.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_left.png"'/>
ball.newPrettyPrint.intermediate.x3d: <ImageTexture
containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_right.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_right.png"'/>
ball.newPrettyPrint.intermediate.x3d: <ImageTexture
containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_top.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_top.png"'/>
[ This is the output from Node.js/X3DJSAIL, I believe. Note that the
containerField's echo the above intermediate form. ]
ball.new.x3d: <ImageTexture containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_back.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_back.png"'/>
ball.new.x3d: <ImageTexture containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_bottom.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_bottom.png"'/>
ball.new.x3d: <ImageTexture containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_front.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_front.png"'/>
ball.new.x3d: <ImageTexture containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_left.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_left.png"'/>
ball.new.x3d: <ImageTexture containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_right.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_right.png"'/>
ball.new.x3d: <ImageTexture containerField='back'
url='"../resources/images/all_probes/stpeters_cross/stpeters_top.png"
"https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_top.png"'/>
Note that if I call "setFront()" or "setFrontTexture()" I expect the
containerField to be set. So I wrote Java like this:
.addChild(new Transform()
.addChild(new Shape()
.setGeometry(new Sphere())
.setAppearance(new Appearance()
.setMaterial(new Material().setDiffuseColor(new float[]
{0.7f,0.7f,0.7f}).setSpecularColor(new float[] {0.5f,0.5f,0.5f}))
.setTexture(new ComposedCubeMapTexture().setDEF("texture")
.setBackTexture(new ImageTexture().setUrl(new
MFString6().getArray()))
.setBottomTexture(new ImageTexture().setUrl(new
MFString7().getArray()))
.setFrontTexture(new ImageTexture().setUrl(new
MFString8().getArray()))
.setLeftTexture(new ImageTexture().setUrl(new
MFString9().getArray()))
.setRightTexture(new ImageTexture().setUrl(new
MFString10().getArray()))
.setTopTexture(new ImageTexture().setUrl(new
MFString11().getArray())))
And Node.js like this:
.addChild((new autoclass.Shape())
.setGeometry((new autoclass.Sphere()))
.setAppearance((new autoclass.Appearance())
.setMaterial((new
autoclass.Material()).setDiffuseColor(java.newArray("float",
[java.newFloat(0.7), java.newFloat(0.7),
java.newFloat(0.7)])).setSpecularColor(java.newArray("float",
[java.newFloat(0.5), java.newFloat(0.5), java.newFloat(0.5)])))
.setTexture((new
autoclass.ComposedCubeMapTexture()).setDEF("texture")
.setBackTexture((new
autoclass.ImageTexture()).setUrl(java.newArray("java.lang.String",
["../resources/images/all_probes/stpeters_cross/stpeters_back.png","https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_back.png"])))
.setBottomTexture((new
autoclass.ImageTexture()).setUrl(java.newArray("java.lang.String",
["../resources/images/all_probes/stpeters_cross/stpeters_bottom.png","https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_bottom.png"])))
.setFrontTexture((new
autoclass.ImageTexture()).setUrl(java.newArray("java.lang.String",
["../resources/images/all_probes/stpeters_cross/stpeters_front.png","https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_front.png"])))
.setLeftTexture((new
autoclass.ImageTexture()).setUrl(java.newArray("java.lang.String",
["../resources/images/all_probes/stpeters_cross/stpeters_left.png","https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_left.png"])))
.setRightTexture((new
autoclass.ImageTexture()).setUrl(java.newArray("java.lang.String",
["../resources/images/all_probes/stpeters_cross/stpeters_right.png","https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_right.png"])))
.setTopTexture((new
autoclass.ImageTexture()).setUrl(java.newArray("java.lang.String",
["../resources/images/all_probes/stpeters_cross/stpeters_top.png","https://coderextreme.net/X3DJSONLD/images/all_probes/stpeters_cross/stpeters_top.png"]))))
Here's what's normally done to get a backTexture. These look fairly
good, I haven't found a bug in these methods for the containerFields.
public ComposedCubeMapTexture setBackTexture(
org.web3d.x3d.sai.Texturing.X3DTexture2DNode newValue)
{
// set-newValue-validity-checks #0
backTexture = newValue;
if (newValue != null)
{
((X3DConcreteElement)
backTexture).setParent(this); // parentTest15
((X3DConcreteNode)backTexture).setContainerFieldOverride("backTexture");
}
if (backTextureProtoInstance != null)
{
backTextureProtoInstance.setParent(null); //
housekeeping, clear prior object
backTextureProtoInstance = null;
}
return this;
}
But I just found this. Looks not very good at all, and potentially why
we get 6 back containerFields or 6 backTexture containerFields:
ComposedCubeMapTexture.java (from X3DJSAIL source, please code review
this, thanks):
private void handleFieldSynonyms()
{
String correctedContainerField;
if (hasAncestorX3D() &&
findAncestorX3D().getVersion().startsWith("3"))
correctedContainerField = "back";
else correctedContainerField = "backTexture";
if (getBackTexture() != null)
((X3DConcreteNode)
getBackTexture()).setContainerFieldOverride(correctedContainerField);
else if (getBackTextureProtoInstance() != null)
((X3DConcreteNode)
getBackTextureProtoInstance()).setContainerFieldOverride(correctedContainerField);
if (getBottomTexture() != null)
((X3DConcreteNode)
getBottomTexture()).setContainerFieldOverride(correctedContainerField);
else if (getBottomTextureProtoInstance() != null)
((X3DConcreteNode)
getBottomTextureProtoInstance()).setContainerFieldOverride(correctedContainerField);
if (getFrontTexture() != null)
((X3DConcreteNode)
getFrontTexture()).setContainerFieldOverride(correctedContainerField);
else if (getFrontTextureProtoInstance() != null)
((X3DConcreteNode)
getFrontTextureProtoInstance()).setContainerFieldOverride(correctedContainerField);
if (getLeftTexture() != null)
((X3DConcreteNode)
getLeftTexture()).setContainerFieldOverride(correctedContainerField);
else if (getLeftTextureProtoInstance() != null)
((X3DConcreteNode)
getLeftTextureProtoInstance()).setContainerFieldOverride(correctedContainerField);
if (getRightTexture() != null)
((X3DConcreteNode)
getRightTexture()).setContainerFieldOverride(correctedContainerField);
else if (getRightTextureProtoInstance() != null)
((X3DConcreteNode)
getRightTextureProtoInstance()).setContainerFieldOverride(correctedContainerField);
if (getTopTexture() != null)
((X3DConcreteNode)
getTopTexture()).setContainerFieldOverride(correctedContainerField);
else if (getTopTextureProtoInstance() != null)
((X3DConcreteNode)
getTopTextureProtoInstance()).setContainerFieldOverride(correctedContainerField);
}
If someone could at least confirm the bug, that would be cool.
John
On 5/28/21 2:08 PM, John Carlson wrote:
> I haven’t seen any validation problems when I changed the version of
> the JSON file to 4.0, JSON parser errors started when I changed the
> XML to 4.0.
>
> Hopefully that is clear. My thinking is kind of muggy right now.
>
> John
>
>
>
> On Fri, May 28, 2021 at 10:56 AM Don Brutzman <brutzman at nps.edu
> <mailto:brutzman at nps.edu>> wrote:
>
> Thanks John. Yes there are a few differences in field names from
> X3D3 to X3D4, for improved object-model consistency. Summarized at
>
> * X3D Scene Authoring Hints: Field name changes planned for
> improved consistency
> https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#fieldNameChanges
> <https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#fieldNameChanges>
>
> We should be able to confirm correctness of X3DUOM 3.3 next week,
> am thinking that prior-version names/synonyms should be something
> to include in X3DUOM 4.0 as well.
>
>
> On 5/27/2021 11:12 PM, John Carlson wrote:
> > Report (still on old version of X3DJSAIL):
> >
> > These files are the one's I'm trying to get translations working
> for:
> >
> > /X3DJSONLD/src/main/data$ grep -l ComposedCubeMapTexture *.x3d|
> grep -v new
> >
> > ball.x3d
> > bubbles.x3d
> > bub.x3d
> > flowerproto.x3d
> > flowers4.x3d
> > flowers7.x3d
> > flowers.x3d
> > geo.x3d
> > mirror2.x3d
> > mirror.x3d
> >
> > Here are the JSON files that don't parse:
> >
> > ~/X3DJSONLD/src/main/data$ for i in *.json; do jsonlint $i 2>
> /dev/null 1> /dev/null|| echo $i; done
> > ball.new.json
> > bubbles.new.json
> > bub.new.json
> > flowerproto.new.json
> > flowers4.new.json
> > flowers7.new.json
> > flowers.new.json
> > geo.new.json
> > mirror2.new.json
> > mirror.new.json
> > SpatialAudioCameraAnimation.json
> > SplitChannels.json
> > text.new.json
> >
> >
> > The new.json files are created from my generated Java code. So
> either my code is wrong, or there's something wrong with X3DJSAIL.
> >
> >
> > My code looks like this:
> >
> >
> > .setTexture(new ComposedCubeMapTexture().setDEF("texture")
> > .setBackTexture(new ImageTexture().setUrl(new
> MFString6().getArray()))
> > .setBottomTexture(new ImageTexture().setUrl(new
> MFString7().getArray()))
> > .setFrontTexture(new ImageTexture().setUrl(new
> MFString8().getArray()))
> > .setLeftTexture(new ImageTexture().setUrl(new
> MFString9().getArray()))
> > .setRightTexture(new ImageTexture().setUrl(new
> MFString10().getArray()))
> > .setTopTexture(new ImageTexture().setUrl(new
> MFString11().getArray())))
> >
> >
> > with setUSE below.
> >
> >
> > John
> >
> > On 5/27/21 10:52 PM, John Carlson wrote:
> >> A somewhat significant change to X3DUOM 3.3 causes generated
> X3D JSON schema 3.3 to reject files.
> >>
> >> That is, there is no longer a bottomTexture, topTexture,
> frontTexture, etc. for ComposedCubeMapTexture. Instead, "Texture"
> is left off of these fields.
> >>
> >>
> >> 4.0 has the Texture added.
> >>
> >>
> >> 2 suggestions:
> >>
> >> Update your files to X3D4.
> >>
> >> OR:
> >>
> >> Add these fields to X3DUOM 3.3 or find some way to get the old
> fields into X3D JSON schema 3.3 during schema generation (help!).
> >>
> >> I am not sure what the standard or the browsers do at this point.
> >>
> >> I'm upgrading my files to X3D4 and see if they work in various
> browsers.
> >>
> >> Help!
> >>
> >> John
> >>
> >
> > _______________________________________________
> > x3d-public mailing list
> > x3d-public at web3d.org <mailto:x3d-public at web3d.org>
> > http://web3d.org/mailman/listinfo/x3d-public_web3d.org
> <http://web3d.org/mailman/listinfo/x3d-public_web3d.org>
>
> 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 <http://faculty.nps.edu/brutzman>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20210601/489107cc/attachment-0001.html>
More information about the x3d-public
mailing list