[x3d-public] X3DJSAIL: Re-report. Missing IS in XML and JSON output

Don Brutzman brutzman at nps.edu
Sun Apr 9 19:08:38 PDT 2017


summary: found and fixed, thanks for subtle test case (ProtoInstance/IS).

fix checked in and deployed, also improved several prototype diagnostic messages.

p.s. note that the library is still not able to check the type of an ExternProtoDeclare at run time.  am wondering if we should come up with a MetadataString convention or somesuch.

code-sleuthing details follow.


On 4/7/2017 7:07 AM, yottzumm at gmail.com wrote:
>
> Attached.  Note difference in display of abox.x3d and abox.new.x3d.

OK it looks like you have two different IS/connect definitions, one within a TransformObject and one within a ProtoInstanceObject.

I modified the names in the connect definitions to make them less confusing and support debugging.

Problem diagnosis: the IS/connect within the ProtoInstanceObject is not getting serialized out to the abox.new.json.intermediate.x3d file.

Looking at source code for TransformObject.toStringX3D() reveals

	if (getIS() != null)
		stringX3D.append(getIS().toStringX3D(level + indentIncrement));

Looking at source code for ProtoInstanceObject.toStringX3D() reveals that the IS serialization is also included there, with a comment, indicating separate generation logic:

	if (getIS() != null)
		stringX3D.append(getIS().toStringX3D(level + indentIncrement)); // IS follows fieldValue definitions

However this ProtoInstanceObject run-time serialization output is not getting reached for your test case because of an incorrectly computed boolean prerequisite, also visible in the source code:

	boolean      hasChild = (!fieldValueList.isEmpty()) || (metadata != null) || !commentsList.isEmpty();

i found and fixed the insufficient hasChild logic for toStringX3D, and similarly for toStringClassicVRML/toStringVRML97.

	http://www.web3d.org/specifications/java/src/org/web3d/x3d/jsail/Core/ProtoInstanceObject.java
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/ProtoInstanceObject.html#toStringX3D-int-

corrected example test output attached.

> JavaScript not attached.  Planning another extension besides .js

??

Meanwhile, also of note in abox.java:

>         ConfigurationProperties.setIndentCharacter(ConfigurationProperties.indentCharacter_DEFAULT);
>         ConfigurationProperties.setIndentIncrement(ConfigurationProperties.indentIncrement_DEFAULT);
>         ConfigurationProperties.setX3dCanonicalForm();

these are defaults already.. then

>         ConfigurationProperties.initialize();

.. occurs automatically on first loading.  Calling it again will reset any prior properties you might configure to initial defaults.

another one done!

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: abox.testProtoInstanceIS.json.intermediate.x3d
Type: model/x3d+xml
Size: 1783 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170409/4287d396/attachment-0001.x3d>
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "Scene": {
        "-children":[
          { "ProtoDeclare":
            {
              "@name":"anyShape",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"myShape",
                      "@accessType":"inputOutput",
                      "@type":"MFNode",
                      "-children":[
                        { "Shape":
                          {
                            "-geometry":
                              { "Sphere":
                                {
                                }
                              }
                          }
                        }
                      ]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Transform":
                      {
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"children-connection1",
                                "@protoField":"myShape"
                              }
                            ]
                        }
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoDeclare":
            {
              "@name":"one",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"myShape",
                      "@accessType":"inputOutput",
                      "@type":"MFNode",
                      "-children":[
                        { "Shape":
                          {
                            "-geometry":
                              { "Cylinder":
                                {
                                }
                              }
                          }
                        }
                      ]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Transform":
                      {
                        "-children":[
                          { "ProtoInstance":
                            {
                              "@name":"anyShape",
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"myShape-connection2",
                                      "@protoField":"myShape"
                                    }
                                  ]
                              }
                            }
                          }
                        ]
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoInstance":
            {
              "@name":"one",
              "fieldValue": [
                {
                  "@name":"myShape",
                  "-children":[
                    { "Shape":
                      {
                        "-geometry":
                          { "Box":
                            {
                              "@size":[1,1,1]
                            }
                          }
                      }
                    }
                  ]
                }
              ]
            }
          }
        ]
    }
  }
}


More information about the x3d-public mailing list