[x3d-public] Proto field default value question

Don Brutzman brutzman at nps.edu
Sat Jun 6 11:53:49 PDT 2020


[summary: you are correct again]

On 6/5/2020 12:49 PM, Andreas Plesch wrote:
> Probably I missed something. Anyways, in my x3dom efforts the node
> field value is always ignored if there is a default value in the
> ProtoInterface.


On 6/4/2020 10:30 AM, Andreas Plesch wrote:
> While adding limited Proto functionality to x3dom, I came across the
> question what to do in in the situation where a node in a ProtoBody
> has an IS field connection to a ProtoField with an initial value, but
> also has a field value for the same field. Here is an example:
> 
> <ProtoInterface>
>    <field accessType='inputOutput' name='color' type='SFColor' value='0,0,0'/>
> ...
> 
> <ProtoBody>
>    <Material diffuseColor='1,0,0'>
>       <IS>
>          <connect protoField='color' nodeField='diffuseColor' />
> ...
> 
> Is the initial color 0,0,0 (black) or 1,0,0 (red) ?
> 
> This ambiguity occurs only in the XML encoding.
> 
> https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#IS_ConnectStatementSyntax
> 
> is quiet on this. The intention is probably to use the ProtoInterface
> default value.
> 
> Is that correct ?

Yes that is correct.  Please be aware that XML node encodings have default values for each field defined by XML Schema and DOCTYPE.  So, if a validating parser is utilized, those default values get filled in.  Validation is optional, not required, but this remains a common occurrence for many applications.  This is carefully designed so that default value (if any) gets overwritten by the IS/connect value.

The outer definition explicitly represents author's intent for how the prototype should be instantiated - whatever the encoding - so having the ProtoInstance fieldValue overwrite the IS/connect field exactly matches specification functionality and logical usage by authors.

Have added an X3D Tooltip hint (or tongue twister, maybe) to reflect this:

* Extensible 3D (X3D) 4.0 Tooltips: IS, connect
   https://www.web3d.org/x3d/tooltips/X3dTooltips.html#connect
   https://www.web3d.org/x3d/tooltips/X3dTooltips.html#IS.connect

"Hint: if provided, value of the outer ProtoInstance fieldValue overrides default value of inner IS/connect nodeField (defined within the original prototype declaration) when first creating a new ProtoInstance node."

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