castle-model-viewer
castle-model-viewer copied to clipboard
Create better error description if field is access type InputOnly in a PROTO
Working example below. Try changing the accessType of the PROTO fields to inputOnly and see the warnings:
castle-model-converter: Warning: X3D: X3D XML: <fieldValue> element references unknown field name "desc" castle-model-converter: Warning: X3D: X3D XML: <fieldValue> element references unknown field name "str"
A better warning might suggest a change to the accessType to inputOutput, or perhaps suggest making the field visible to the outside of the ProtoDeclare by changing accessType.
IDK, I figured it out. Now to see if the PROTO does something.
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "https://www.web3d.org/specifications/x3d-4.0.dtd">
<X3D profile='Immersive' version='4.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.0.xsd'>
<head>
<component name='HAnim' level='1'/>
<meta content='billboardPROTO.x3d' name='title'/>
<meta name='identifier' content='file://C:/Users/john/jaminate/Jaminate/app/billboardPROTO.x3d'/>
<meta name='description' content='A partial humanoid, with a PROTO at an HAnimSite'/>
<meta name='generator' content='Jaminate, Just Humans'/>
</head>
<Scene>
<ProtoDeclare name='TouchAndBillboard'>
<ProtoInterface>
<field name='str' accessType='inputOutput' type='MFString' value='"-1"'/>
<field name='desc' accessType='inputOutput' type='SFString' value='HAnim Feature Point Description'/>
</ProtoInterface>
<ProtoBody>
<Transform>
<TouchSensor>
<IS>
<connect nodeField='description' protoField='desc'/>
</IS>
</TouchSensor>
<Billboard>
<Shape>
<Text>
<IS>
<connect nodeField='string' protoField='str'/>
</IS>
</Text>
</Shape>
</Billboard>
</Transform>
</ProtoBody>
</ProtoDeclare>
<HAnimHumanoid DEF='hanim_humanoid' name='humanoid' loa='4' version='2.0'>
<HAnimJoint DEF='hanim_humanoid_root' name='humanoid_root' containerField='skeleton' center='0 0.77 0'>
<HAnimJoint DEF='hanim_sacroiliac' name='sacroiliac' center='0 0.826 0.02'>
<HAnimSegment DEF='hanim_pelvis' name='pelvis'>
<HAnimSite DEF='hanim_l_iliocristale_pt' name='l_iliocristale' translation='0.13 0.92 0.0035'>
<ProtoInstance name='TouchAndBillboard'>
<fieldValue name='desc' value='HAnimSite 33 hanim_l_iliocristale_pt'/>
<fieldValue name='str' value='"33"'/>
</ProtoInstance>
</HAnimSite>
</HAnimSegment>
</HAnimJoint>
</HAnimJoint>
<HAnimJoint USE='hanim_humanoid_root' containerField='joints'/>
<HAnimJoint USE='hanim_sacroiliac' containerField='joints'/>
</HAnimHumanoid>
</Scene>
</X3D>
Success. See pictures on discord under x3d channel
Done, thank you. Indeed, our previous warning could be misleading (when the name refers to an event, not a field).
Now we will display something like this:
X3D: X3D XML: <fieldValue> references an event name "desc". This is invalid, as only fields (not events) can have values assigned at prototype instantiation. Consider changing prototype definition to use "inputOutput" or "initializeOnly" instead.
X3D: X3D XML: <fieldValue> references an event name "str". This is invalid, as only fields (not events) can have values assigned at prototype instantiation. Consider changing prototype definition to use "inputOutput" or "initializeOnly" instead.