[x3d-public] CubeMap Textures in X3DJSAIL. Breaking bug! Looks like a problem with handleFieldSynonyms().
John Carlson
yottzumm at gmail.com
Thu Jun 10 08:40:59 PDT 2021
Continuing bug report (apparent bug in ComposedCubeMapTexture.java,
X3DJSAIL. Note that the correctedContainerField variable value will
always "back" or "backTexture". I think it should be a possible 12
different values (front, bottom, etc.), but with different corrected
values based on which X3D version one is using. So the first 8 or so
lines make sense. After that, pretty much nonsense. Perhaps one could
copy lines 2-4 and replace the hard-coded strings with different
hardcoded strings for each side of the cube.
John
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);
}
On 6/9/21 11:24 PM, Don Brutzman wrote:
> First, good news: today updated X3DUOM and X3DJSAIL build to support
> HTML id attribute. This should let you build and use your version,
> instead of deployed version.
>
> Will deploy the new build of X3DJSAIL late tonight (replacement update
> for the still-working prior build).
>
> Second, more good news, use of updated X3D-Edit helped finally isolate
> an elusive bug in X3D Schematron.
>
> Third, more good news, this has led to a fixed X3D Validator. Test
> reports welcome.
>
> * https://savage.nps.edu/X3dValidator
>
> Fourth, a request: hoping to look at your bug but it seems far too
> confusing for me to follow, sorry. Hoping a simpler case with example
> might be possible.
>
> Of note: you should be able to use Netbeans Debug mode of your source
> with visibility into the X3DJSAIL jar, so that should help isolate the
> issue.
>
> Have also updated X3D XML Schema, DOCTYPE, X3D Validator, and X3D4
> Tooltips. This was a good improvement that uncovered some errate.
>
> TODO: X3DPSAIL Python, X3D Ontology (turtle encoding), X3D-Edit
> interface support.
>
> Thanks for all patience and progress. Have fun with X3D!
>
>
>
> On 6/1/2021 9:41 PM, John Carlson wrote:
>>
>> 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>
>>>
>
> all the best, Don
More information about the x3d-public
mailing list