About

VRML (Virtual Reality Modeling Language), often pronounced "vermal" is a standard text file format for representing 3D interactive vector graphics, designed with the World Wide Web in mind. VRML has since been superseded by X3D, however VRML remains widely used as a file format for interchange of 3D models, particular from 3D animation programs and CAD programs. On this page I have listed out websites and code snippets pertaining to VRML. Note that there are two version of VRML - VRML1 (released 1994) and VRML2 (released 1997), and this article focusses mostly on the latter.

Brief History

VRML was first introduced in 1994, a version now known as VRML1 and mostly obsolete. In 1997 a new version of the format, VRML2 (although often called VRML97), was finalized and became an ISO standard. VRML files have a .vrml or .wml extension. Although VRML generated much interest and support in education and research, it has never seen widespread use on the internet. Few web browsers ever allowed native viewing of these 3D files and instead require you to install 3rd party plugins before you can view .vrml and .wrl inside your web browser (which is a bit of a pain). The VRML Consortium changed its name to the Web3D Consortium, and released X3D in 2004 as an XML-based successor to VRML. Although VRML is technically superseded by X3D, and rarely are either seen on the www nowadays, many 3D programs, especially older ones, still support only VRML97 or in rare cases VRML1 for importing and exporting, hence it still an important 3D format for file interchange.

Web Sites

Installing a VRML viewer:

VRML Plugin and Browser Detector - Helps you detect and install a plugin so that you can view VRML files in your browser. This website is supported by NIST, and they actually list about 30 standalone programs and toolkits for VRML and X3D. The one I installed on my Mac is called [FreeWRL] and another popular free tool is [OpenVRML].

FreeWRL/FreeX3D - FreeWRL is a cross platform (window, Mac, Linux), plugin (allows you to view these files inside browser), standalone (allows you to view files outisde the browser) and toolkit for viewing VRML and X3D files. One nice feature is that it comes with a directory containing a few dozen .wrl files and one .x3d file which you can open in FreeWRL to view or open in any text editor to see the source code.

OpenVRML - another free multi-platform plugin for VRML.... but unfortunately is a bit tricky to install.

Learning VRML:

Introduction to VRML 2.0 - a site which is still under construction, but represents and excellent overview of all the main concepts and the basics of VRML, and has some really great examples, including the pyramid I copied below.

Code Snippets

Example 2: Creating a simple mesh

Often you may want to represent complex shapes, and to do this the easiest way is using a "IndexFacSet" geometry, where all the points are first listed in a "point" array, and then sets of points joined together to form each face in the "coordIndex" array. In the example below we have generated a red square-based triangular pyramid with five points, and five faces. You'll notice the bottom face is a square (it lists 4 points instead of 3), but this will effectively get drawn as or converted to two triangules in most 3D programs.

Example 3: Setting up a scene hierarchy and reusing elements with "DEF"

In this next example we build on the previous example, but we want to add three white spheres below the pyramid to look like a head and two eyes. Whenever you want multiple objects to share the same material/appearance, it is tedious and inefficient to list it out each time, so this is a good place to highlight how you can use the "DEF" command to define something - in this case an appearance, but it can also be useful for duplicating shapes or groups of shapes - and then use it multiple times. The DEF tag also gives that object a name in the scene hierarchy, which is useful if you intend to import the VRML file into another program and see logical names. Once something is defined, it can be reused as many times as possible, and although the most code-efficient method would be to create our "MAT_obj2_whiteMat" within the first sphere, it can lok a little messy, so I've instead defined both appearances/materials at the beginning of the file in shape objects which have no geometry.

I designed this file to import nicely into Cinema 4D, although if you use this particular program be sure to uncheck "optimize hierarchy" if you want every level maintained (otherwise it will collapse anything with only one child). The hierarchy of "scene graph" of this file looks like this:

character (transform / null object)

obj1_hat (transform / null object)

pyramid_hat (shape / null object)

poly (indexed face set / polygon)

obj2_head (group / null object)

head (shape / null object)

Sphere (sphere)

left_eye (shape / null object)

Sphere (sphere)

right_eye (shape / null object)

Sphere (sphere)

simple_point_light (shape / null object)

Light (point light)

VRML Format

VRML1 versus VRML2

As mentioned before, VRML1 is obsolete, but for anyone interested in the differences between VRML1 and VRML2 there is a summary below courtesy of VRML Works by Bob Crispen. Briefly, VRML 1.0 worlds are static. VRML 2.0 worlds can move and interact with the visitor to those worlds.

VRML1.0

VMRL2.0

* Standard objects (cube, sphere, cone, cylinder, text)

Arbitrary objects (surfaces, linesets, pointsets)

Lights

Cameras (viewpoints)

Textures on objects

Ability to fly through, walk through, examine scenes

Clickable links

Define and reuse objects

All VRML1.0 features plus:

Animated objects

Sound (.wav and MIDI)

Animated textures

Interpolators (color, position, orientation, etc.)

Switches & sensors & event routing

Extrusions

Background colors and textures

Scripts (Java or JavaScript) for behaviors

Define and reuse behaviors

Add new nodes to the language with PROTO and EXTERNPROTO

See Also

OBJ file format - a 3D vector file format which is easier to read/write than VRML, but is much less versatile.