This is an excerpt from the VRML 1.0 Specification, located at the VRML Repository.
| version | Syntax | Example |
| 1 | #VRML V1.0 ascii | |
| 2 | ||
Coordinates(local,world,camera) TOP of page Elements |
||
| X: right Y:up Z:toward
viewer distance in meters angles in radians |
direction 0 0 -1 | |
| USE nodename | ||
| newTypeName {fields[fieldtype fieldname,...]} | Cube {fields [ SFFloat
width, SFFloat height, SFFloat depth ] width 10 height 4 depth 3} |
|
| newTypeName {fields[fieldtype fieldname,...] isA["existingType"] fieldname fieldvalue} |
ExtendedMaterial { fields [ MFString isA, MFFloat indexOfRefraction, MFColor diffuseColor, MFFloat transparency ] isA [ "Material" ] indexOfRefraction .34 diffuseColor .8 .54 1 } |
|
| 1 | SFBitMask ( flag1 | flag2 | ... ) | SFBitMask [(1,2,3)] |
| SFBool 0 | 1 | TRUE | FALSE | SFBool 0 | |
| SFColor [R G B] | SFColor [1 2 1] | |
| MFColor [R G B,R G B,...] | MFColor[ 1.0 0. 0.0, 0 1 0, 0 0 1 ] | |
| SFEnum SFmnemonicName | SFEnum SFmnemonicName [ 1.0 0. 0.0, 0 1 0, 0 0 1 ] | |
| SFFloat [ansiCfloat] | SFFloat [ 3.1415926] | |
| MFFloat [ansiCfloat,ansiCfloat,...] | MFFloat [ 3.1415926, 12.5e-3, .0001 ] | |
| SFImage | ||
| SFLong | ||
| MFLong | ||
| SFMatrix | ||
| SFRotation | ||
| SFString | ||
| MFString | ||
| SFVec2f | ||
| MFVec2f | ||
| SFVec3f | ||
| MFVec3f | ||
Shapes TOP of page Elements |
||
| AsciiText | ||
| Cone | ||
| Cube | ||
| Cylinder | ||
| IndexedFaceSet | ||
| IndexedLineSet | ||
| PointSet | ||
| Sphere | ||
Properties TOP of page Elements |
||
| Coordinate3 | ||
| FontStyle | ||
| Info | ||
| Material | ||
| MaterialBinding | ||
| Normal | ||
| NormalBinding | ||
| Texture2 | ||
| Texture2Transform | ||
| TextureCoordinate2 | ||
| ShapeHints | ||
| MatrixTransform | ||
| Rotation | ||
| Scale | ||
| Transform | ||
| Translation | ||
Groups TOP of page Elements |
||
| Separator | ||
| Switch | ||
| WWWAnchor | ||
| LOD | ||
Misc TOP of page Elements |
||
| OrthographicCamera | ||
| PerspectiveCamera | ||
| DirectionalLight | ||
| PointLight | ||
| SpotLight | ||
| WWWInline
{ "theName" bboxsize 0 0 0 bboxcenter 0 0 0} |
WWWInline {"test.wrl"} | |
A node has the following characteristics:
- What kind of object it is. A node might be a cube, a sphere, a texture map, a transformation, etc.
- The parameters that distinguish this node from other nodes of the same type. For example, each Sphere node might have a different radius, and different texture maps nodes will certainly contain different images to use as the texture maps. These parameters are called Fields. A node can have 0 or more fields.
- A name to identify this node. Being able to name nodes and refer to them elsewhere is very powerful; it allows a scene's author to give hints to applications using the scene about what is in the scene, and creates possibilities for very powerful scripting extensions. Nodes do not have to be named, but if they are named, they can have only one name. However, names do not have to be unique-- several different nodes may be given the same name.
- Child nodes. Object hierarchy is implemented by allowing some types of nodes to contain other nodes. Parent nodes traverse their children in order during rendering. Nodes that may have children are referred to as group nodes. Group nodes can have zero or more children.
The syntax chosen to represent these pieces of information is straightforward:
DEF objectname objecttype { fields children }
Only the object type and curly braces are required; nodes may or may not have a name, fields, and children.
Node names must not begin with a digit, and must not contain spaces or control characters, single or double quote characters, backslashes, curly braces, the plus character or the period character.
General Syntax
For easy identification of VRML files, every VRML file must begin with the characters:
#VRML V1.0 asciiAny characters after these on the same line are ignored. The line is terminated by either the ASCII newline or carriage-return characters.
The '#' character begins a comment; all characters until the next newline or carriage return are ignored. The only exception to this is within string fields, where the '#' character will be part of the string.
Note: Comments and whitespace may not be preserved; in particular, a VRML document server may strip comments and extraneous whitespace from a VRML file before transmitting it. Info nodes should be used for persistent information like copyrights or author information. Info nodes could also be used for object descriptions.
Blanks, tabs, newlines and carriage returns are whitespace characters wherever they appear outside of string fields. One or more whitespace characters separates the syntactical entities in VRML files, where necessary.
After the required header, a VRML file contains exactly one VRML node. That node may of course be a group node, containing any number of other nodes.
Coordinate System
VRML uses a cartesian, right-handed, 3-dimensional coordinate system. By default, objects are projected onto a 2-dimensional device by projecting them in the direction of the positive Z axis, with the positive X axis to the right and the positive Y axis up. A camera or modeling transformation may be used to alter this default projection.
The standard unit for lengths and distances specified is meters. The standard unit for angles is radians.
Fields
There are two general classes of fields; fields that contain a single value (where a value may be a single number, a vector, or even an image), and fields that contain multiple values. Single-valued fields all have names that begin with "SF", multiple-valued fields have names that begin with "MF". Each field type defines the format for the values it writes.
Multiple-valued fields are written as a series of values separated by commas, all enclosed in square brackets. If the field has zero values then only the square brackets ("[]") are written. The last may optionally be followed by a comma. If the field has exactly one value, the brackets may be omitted and just the value written. For example, all of the following are valid for a multiple-valued field containing the single integer value 1:
1 [1,] [ 1 ]
[Modified By] Tuesday, April 07, 1998 01:17 AM Eastern Daylight Time