This page describes the text syntax of VRML 1.0 as the Web3D Consortium’s archived specification and the files on this machine show it. Where the explorer’s behaviour is described, it is the explorer’s, and says so.
Header line, comments and separators
The first line is #VRML V1.0 ascii. Anywhere else, # starts a
comment that runs to the end of the line. White space and commas separate tokens.
Names and nodes
A node is its type name followed by braces holding its fields and, for group nodes,
its children: Separator { Material { diffuseColor 1 0 0 } Cube { } }. A field
is its name followed by a value. A name must not start with a digit or contain white
space or any of " ' # , . [ \ ] { } ( ) |. DEF name before a
node gives it a name; USE name where a node is expected is the same node
again, not a copy. The names are case sensitive.
Field types
| Type | Written as |
|---|---|
SFBool | TRUE or FALSE (also 0 and 1) |
SFColor, MFColor | three numbers from 0 to 1 for red, green and blue; a list is in brackets |
SFEnum | one bare word from the field’s list, such as PER_FACE |
SFBitMask | one or more bare words joined with | in parentheses, such as (SIDES | BOTTOM), or one word |
SFFloat, MFFloat | a number, or a list of them |
SFLong, MFLong | an integer, or a list; indices use -1 to end a face or line |
SFImage | width, height and number of components (1 to 4), then width × height pixel values, usually in hexadecimal such as 0xFF0000 |
SFMatrix | sixteen numbers, written row by row, for row vectors (translation in the last row) |
SFRotation | an axis (x y z) and an angle in radians |
SFString, MFString | text in double quotes, or a list of them |
SFVec2f, MFVec2f | two numbers, or a list of pairs |
SFVec3f, MFVec3f | three numbers, or a list of triples |
A multiple-value field with one value may leave out the brackets. Numbers are decimal,
with an optional sign, fraction and exponent, or hexadecimal with 0x.
Traversal and state
A scene is drawn by walking the nodes in order, depth first, while keeping a state.
A property node changes the state for every node after it, until the end of the
enclosing Separator (or, for a TransformSeparator, until the
end of it for transformations only).
- Transformation nodes (
Transform,Translation,Rotation,Scale,MatrixTransform) multiply the current transform. Coordinate3,Normal,TextureCoordinate2set the vertex data that the next face, line or point set indexes.Material,MaterialBinding,NormalBinding,Texture2,Texture2Transform,ShapeHintsandFontStyleset the appearance.- Shape nodes draw with the state:
Cube,Sphere,Cone,Cylinder,IndexedFaceSet,IndexedLineSet,PointSet,AsciiText. Grouptraverses its children without saving anything.Switchtraverses the child numbered bywhichChild(−1 for none, −3 for all).LODchooses one child by the distance of the viewer.- The first camera (
PerspectiveCameraorOrthographicCamera) in the scene is the one the browser starts with.
Bindings
A Material may hold several values in each field. MaterialBinding says how they are spread over a shape; NormalBinding does the same for normals.
| Value | Meaning |
|---|---|
DEFAULT | the default for the shape (overall for materials) |
OVERALL | the first value for the whole shape |
PER_PART, PER_PART_INDEXED | one value for each part of a primitive (cylinder sides, top, bottom), in order or by materialIndex |
PER_FACE, PER_FACE_INDEXED | one value for each face or line, in order or by materialIndex |
PER_VERTEX, PER_VERTEX_INDEXED | one value for each vertex, in order or by materialIndex |
The explorer draws OVERALL, PER_FACE, PER_FACE_INDEXED, PER_VERTEX and PER_VERTEX_INDEXED for face sets from the diffuse colours, and ignores normals, ambient, specular and emissive colours and transparency.
Example
From a ray-tracing test scene exported by the VModel program (Illum2.wrl), which
draws two spheres in a room:
#VRML V1.0 ascii
#
#converted by VModel V0.60
Separator {
PerspectiveCamera {
position 1.270000 1.250000 3.000000
orientation 0.000000 1.000000 0.000000 2.670331
heightAngle 0.733038
}
Separator {
Info {
string "Stand"
}
Material {
diffuseColor 0.900000 0.600000 0.300000
Not described
What this page and the explorer leave out.
- Reference: not checked against the specification. How a browser picks a camera, the rules for normals and for part bindings, and the
fieldsextension mechanism are not described. - Viewer: the text is read with these rules and the traversal is followed for transforms, Separator, Switch, Material and the bindings listed above; everything else in the state is ignored.