[x3d-public] Forgot what we did Re: ProtoInstance for material in X3DUOM.

Don Brutzman brutzman at nps.edu
Tue Sep 5 07:57:38 PDT 2017


Thanks for test case.  As indicated by url in the meta identifier value, the current versions are online and excerpts follow.

=============================================================================

http://www.web3d.org/x3d
/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamplesIndex.html

http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.x3d

<Shape>
   <Appearance>
	<ProtoInstance containerField='material' name='EmissiveMaterial'>
	  <fieldValue name='onlyColor' value='0.2 0.6 0.6'/>
	</ProtoInstance>
   </Appearance>
   <Text string='"X3D Header Prototype syntax examples" "(view console for EXTERNPROTO output)"'>
	<FontStyle justify='"MIDDLE" "MIDDLE"' size='0.6'/>
   </Text>
</Shape>

checkmark icon
https://savage.nps.edu/X3dValidator?url=http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.x3d

throws an error:
  <ROUTE fromNode='StayInPlace' fromField='value_changed' toNode='someInlineRoot' toField='set_translation'/> has no corresponding toNode with DEF='someInlineRoot' [/X3D/Scene/ROUTE[4], error] Error(s) detected during this validation test.
X3D Schematron check: fail.

which is a false positive (X3D Schematron rule needs correction) since it is not finding the statement

	<IMPORT AS='someInlineRoot'/>

=============================================================================

http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.x3dv

       Shape {
         appearance Appearance {
           material  EmissiveMaterial {
             onlyColor  0.2 0.6 0.6
           }
         }
         geometry Text {
           string [ "X3D Header Prototype syntax examples" "(view console for EXTERNPROTO output)" ]
           fontStyle FontStyle {
             justify [ "MIDDLE" "MIDDLE"  ]
             size 0.6
           }
         }
       }

=============================================================================

http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.json

     "Shape": {
         "-appearance": {
             "Appearance": {
                 "-material": {
                     "ProtoInstance": {
                         "@name": "EmissiveMaterial",
                         "fieldValue": [
                             {
                                 "@name": "onlyColor",
                                 "@value": [
                                     0.2,
                                     0.6,
                                     0.6
                                 ]
                             }
                         ]
                     }
                 }
             }
         },
         "-geometry": {
             "Text": {
                 "@string": [
                     "X3D Header Prototype syntax examples",
                     "(view console for EXTERNPROTO output)"
                 ],
                 "-fontStyle": {
                     "FontStyle": {
                         "@justify": [
                             "MIDDLE",
                             "MIDDLE"
                         ],
                         "@size": 0.6
                     }
                 }
             }
         }
     }

syntax checker
https://jsonlint.com/?json=http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.json

reports "valid JSON" (though this is a jsonlint syntax check, not a json schema validation)

Current published JSON schema (Roy's working copy may be different)

http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json

"Appearance": {
	"type": "object",
	"properties": {
		"@DEF": {
			"type": "string"
		},
		"@USE": {
			"type": "string"
		},
		"IS": {
			"$ref": "#/definitions/IS"
		},
		"-fillProperties": {
			"type": "object",
			"properties": {
				"FillProperties": {
					"$ref": "#/definitions/FillProperties"
				},
				"ProtoInstance": {
					"$ref": "#/definitions/ProtoInstance"
				}
			},
			"additionalProperties": false
		},
		"-lineProperties": {
			"type": "object",
			"properties": {
				"LineProperties": {
					"$ref": "#/definitions/LineProperties"
				},
				"ProtoInstance": {
					"$ref": "#/definitions/ProtoInstance"
				}
			},
			"additionalProperties": false
		},
		"-material": {
			"$ref": "#/definitions/-material"
		},
		"-metadata": {
			"$ref": "#/definitions/-metadata"
		},
		"-shaders": {
			"$ref": "#/definitions/-shaders"
		},
		"-texture": {
			"$ref": "#/definitions/-texture"
		},
		"-textureTransform": {
			"$ref": "#/definitions/-textureTransform"
		},
		"-children": {
			"$ref": "#/definitions/-commentRoute"
		}
	},
	"additionalProperties": false
},

JSON Schema documentation:
http://www.web3d.org/specifications/X3dJsonSchemaDocumentation3.3/x3d-3.3-JSONSchema_Appearance.html#Link3

=============================================================================

http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.java

   .addChild(new ShapeObject()
	.setAppearance(new AppearanceObject()
	  .setMaterial(new ProtoInstanceObject().setName("EmissiveMaterial")
		.addFieldValue(new fieldValueObject().setName("onlyColor").setValue("0.2 0.6 0.6"))))
	.setGeometry(new TextObject().setString(new MFStringObject("\"X3D Header Prototype syntax examples\" \"(view console for EXTERNPROTO output)\""))
	  .setFontStyle(new FontStyleObject().setJustify(new MFStringObject("\"MIDDLE\" \"MIDDLE\"")).setSize(0.6f)))))

seems OK, apparently passed compilation and self-validation run-time test as indicated by corresponding Javadoc
http://www.web3d.org/x3d/content/examples/Basic/javadoc/index.html?Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.html

=============================================================================

X3D unified object model (file and schema likely need renaming) does not list ProtoInstance explicitly in fields, since the general rule is that a ProtoInstance can replace any node.
http://www.web3d.org/specifications/X3DObjectModel-3.3.xml

<ConcreteNode name="Appearance">
    <InterfaceDefinition specificationUrl="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/shape.html#Appearance">
	  <componentInfo name="Shape" level="1"/>
	  <Inheritance baseType="X3DAppearanceNode"/>
	  <field type="SFNode"
			 accessType="inputOutput"
			 name="fillProperties"
			 default="NULL"
			 acceptableNodeTypes="FillProperties">
		 <componentInfo name="Shape" level="3"/>
	  </field>
	  <field type="SFNode"
			 accessType="inputOutput"
			 name="lineProperties"
			 default="NULL"
			 acceptableNodeTypes="LineProperties">
		 <componentInfo name="Shape" level="2"/>
	  </field>
	  <field type="SFNode"
			 accessType="inputOutput"
			 name="material"
			 default="NULL"
			 acceptableNodeTypes="X3DMaterialNode"/>
	  <field type="SFNode"
			 accessType="inputOutput"
			 name="metadata"
			 default="NULL"
			 acceptableNodeTypes="X3DMetadataObject"
			 inheritedFrom="X3DNode"/>
	  <field type="MFNode"
			 accessType="inputOutput"
			 name="shaders"
			 acceptableNodeTypes="X3DShaderNode">
		 <componentInfo name="Shape" level="3"/>
	  </field>
	  <field type="SFNode"
			 accessType="inputOutput"
			 name="texture"
			 default="NULL"
			 acceptableNodeTypes="X3DTextureNode"/>
	  <field type="SFNode"
			 accessType="inputOutput"
			 name="textureTransform"
			 default="NULL"
			 acceptableNodeTypes="X3DTextureTransformNode">
		 <componentInfo name="Shape" level="2"/>
	  </field>
	  <field type="SFString"
			 accessType="inputOutput"
			 name="DEF"
			 inheritedFrom="DEF_USE"/>
	  <field type="SFString"
			 accessType="inputOutput"
			 name="USE"
			 inheritedFrom="DEF_USE"/>
	  <field type="SFString"
			 accessType="inputOutput"
			 name="class"
			 inheritedFrom="globalAttributes"/>
	  <containerFieldDefault name="appearance"/>
	  <ContentModel>
		 <GroupContentModel name="AppearanceChildContentModel"
							minOccurs="0"
							maxOccurs="unbounded"/>
		 <GroupContentModel name="ChildContentModelCore" minOccurs="0"/>
	  </ContentModel>
    </InterfaceDefinition>
</ConcreteNode>

=============================================================================


On 9/5/2017 2:30 AM, John Carlson wrote:
> I forgot what we did to support ProtoInstance under X3DMaterialNode under Appearance.

as above

> I don’t see much support for ProtoInstance in material fields in Appearance in X3DUOM. 

correct, it is implicit

> Is it valid to have a material which is a ProtoInstance? 

yes, as above

> I need some way of generating it in the JSON schema from X3DUOM.

cool.

in X3DJSAIL you can distinguish whether an object is an X3D node or X3D statement by seeing if it is instanceof X3DConcreteNode or X3DConcreteStatement.

if you think it helpful, i can add utility methods isNode() and isStatement() in these abstract classes.
  
> See attached files.  Also, run the X3D file through X3DJSAIL and see if it produces similar JSON.  I see two differences (ProtoInstance is in an array, containerField is -children instead of -material), but my serializers may be off.

handing back off to you now... gotta go.  Worthy deep dive, thank for continued scrutiny.

> $ node ../node/jsondiff.js X3dHeaderPrototypeSyntaxExamples.json X3dHeaderPrototypeSyntaxExamples.new.json
> 
> ================================================================================
> 
> C:\Users\coderextreme\X3DJSONLD\src\main\node\jsondiff.js X3dHeaderPrototypeSyntaxExamples.json X3dHeaderPrototypeSyntaxExamples.new.json
> 
> @5 /X3D/Scene/-children/11/Transform/-children/0/Shape/-appearance/Appearance/-material
> 
> < {"ProtoInstance":{"@name":"EmissiveMaterial","fieldValue":[{"@name":"onlyColor","@value":[0.2,0.6,0.6]}]}}
> 
> @7 /X3D/Scene/-children/11/Transform/-children/0/Shape/-appearance/Appearance/-children
> 
>  > [{"ProtoInstance":{"@name":"EmissiveMaterial","fieldValue":[{"@name":"onlyColor","@value":[0.2,0.6,0.6]}]}}]
> 
> Related Java:
> 
>                .setMaterial(ProtoInstance2 = new ProtoInstanceObject().setName("EmissiveMaterial")))
> 
> See, containerField is material. However the ProtoBody has two children, the first is a comment, so -children may be correct???
> 
> Rescue me from my confusion!
> 
> John


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