This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a VRML97 (Virtual Reality Modeling Language) parser implementation in C#. It parses 3D scene descriptions conforming to the VRML97 specification (http://tecfa.unige.ch/guides/vrml/vrml97/spec/).
dotnet build Graph3D.Vrml.slndotnet test Graph3D.Vrml.Test/Graph3D.Vrml.Test.csprojdotnet test Graph3D.Vrml.Test/Graph3D.Vrml.Test.csproj --filter "FullyQualifiedName~VRMLTokenizerTest.TokenizerTest"dotnet build Graph3D.Vrml.sln -c ReleaseThe parsing process follows a two-stage pipeline:
-
Tokenization (
Graph3D.Vrml/Tokenizer/): Converts VRML text into tokens using a state machine patternVrml97Tokenizeris the main tokenizer entry point- Different states handle numbers, strings, comments, punctuation, etc.
- Produces
VRML97Tokenobjects with types defined inVRML97TokenType
-
Parsing (
Graph3D.Vrml/Parser/): Converts tokens into a scene graphVrmlParserorchestrates the parsing processParserContextmaintains parsing state, named node registry, and field/node container stacksFieldParserhandles field value parsingNodeFactorycreates node instances from type identifiers
All VRML nodes inherit from BaseNode (Graph3D.Vrml/Nodes/BaseNode.cs):
- Manages fields, exposed fields, event inputs/outputs via dictionaries
- Supports node naming, parent tracking, cloning
- Uses visitor pattern for traversal (
INodeVisitor)
Node categories in Graph3D.Vrml/Nodes/:
- Grouping (
Grouping/): Transform, Group, Anchor - nodes that contain children - Geometry (
Geometry/): Box, Sphere, Cone, Cylinder, IndexedFaceSet, etc. - Appearance (
Appearance/): Material, Texture nodes, TextureTransform - Bindable (
Bindable/): Viewpoint, NavigationInfo, Background - Light Sources (
LightSources/): DirectionalLight, PointLight - Sensors (
Sensors/): TimeSensor and other interaction nodes - Interpolation (
Interpolation/): Animation interpolators
Fields represent node properties (Graph3D.Vrml/Fields/):
- SF (Single-valued): SFBool, SFColor, SFFloat, SFInt32, SFNode, SFRotation, SFString, SFTime, SFVec2f, SFVec3f, SFImage
- MF (Multi-valued): MFColor, MFFloat, MFInt32, MFNode, MFRotation, MFString, MFVec2f, MFVec3f
- All inherit from
Fieldbase class - Use visitor pattern (
IFieldVisitor) for type-safe field operations - Access types defined in
FieldAccessType: Field, ExposedField, EventIn, EventOut
Entry point is VrmlScene which contains a root SceneGraphNode. The parser populates this tree structure by:
- Creating nodes via
NodeFactory - Registering named nodes (DEF) in
ParserContext.namedNodes - Resolving node references (USE) during parsing
- Supporting PROTO/EXTERNPROTO for custom node types
- Main library:
net9.0 - Test project:
net9.0
Tests are in Graph3D.Vrml.Test/ and use NUnit. Test VRML files (.wrl) are embedded resources:
D2.wrl,D3.wrl,D4.wrl- Examples from VRML97 specificationAnt.WRL- Large example file for comprehensive testingrose.wrl- Additional test scene
Tests are organized by functionality matching the source structure (e.g., Parser/Nodes/Geometry/BoxNodeTest.cs).