create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.
https://create3000.github.io/x_ite/
Other
66 stars 13 forks source link

xml x3d serialization of Proto Node field with init. value #143

Closed andreasplesch closed 11 months ago

andreasplesch commented 11 months ago

An edge case I discovered while trying to convert .wrl from http://bulatov.org/vrml/ to .x3d with x_ite.

If the Proto has a SF/MFNode field with a default value, the converted .xml is missing a closing bracket for the opening field tag.

Example attached wrl: HeadsUpDisplayPrototype.wrl.txt converted x3d: HeadsUpDisplayPrototype.x3d.txt

wrl:

  # [appinfo] Heads-up display (HUD) keeps child geometry aligned on screen in a consistent location

  exposedField SFVec3f  screenOffset 0 0 -5    # [appinfo] offset position for HUD relative to current view location, default 0 0 -5
  exposedField MFNode   children [      # [appinfo] X3D content positioned at HUD offset
    # initialization nodes (if any) go here
        Group {}  
   ]
   eventOut     SFVec3f position_changed    # [appinfo] HUD position update (in world coordinates) relative to original location
   eventOut     SFRotation  orientation_changed    # [appinfo] HUD orientation update relative to original location
]
...

converted x3d:

<ProtoDeclare name='HeadsUpDisplay'>
      <ProtoInterface>
        <field accessType='inputOutput' type='SFVec3f' name='screenOffset' value='0 0 -5'/>
        <field accessType='inputOutput' type='MFNode' name='children'
          <Group/>
        </field>
        <field accessType='outputOnly' type='SFVec3f' name='position_changed'/>
        <field accessType='outputOnly' type='SFRotation' name='orientation_changed'/>
      </ProtoInterface>...
andreasplesch commented 11 months ago

https://github.com/create3000/x_ite/blob/4e416a8f87f5e891bcf396ed8f3b23ca9a36ac7c/src/x_ite/Prototype/X3DProtoDeclaration.js#L221-L227

may be the place to add the bracket before the field value is appended:

generator .string += ">";
create3000 commented 11 months ago

Thank's Andreas again for submitting this bug. A fixed version 8.11.16 has just released.