VRML:
Virtual Reality Modeling Language

CS 6204: Java and the WWW


References


Background


Use of Web with VRML


Some Examples


Typical Navigation


Using VRML from HTML


A Simple VRML Example

Step 1: Create file simple.wrl

#VRML V1.0 ascii.
Material {
    emissiveColor 1.0 1.0 1.0
}
Sphere {
    radius 2
}
Draws white sphere of radius 2 meters in the center of the world.

Step 2: Reference .wrl file from HTML file

Put a line like the following into an HTML file:

<EMBED SRC="simple.wrl" WIDTH=400 HEIGHT=200>

Here's the result:


Structure of VRML File

Example

#VRML V1.0 ascii.
Separator {
  Material  { emissiveColor 1.0 1.0 1.0 }
  Sphere    { radius 2 }
  Transform { translation 5 0 0 }
  Sphere    { radius 1 }
}


Notes on Above Example

#VRML V1.0 ascii.
Separator {
  Material  { emissiveColor 1.0 1.0 1.0 }
  Sphere    { radius 2 }
  Transform { translation 5 0 0 }
  Sphere    { radius 1 }
  }
}

Miscellaneous Points


More Complex Example

Here is a more complex example from the VRML 1.0 spec.  " It contains a simple model of a track-light consisting of


Click here to see the resulting world!

#VRML V1.0 ascii
     Separator {
         Separator {       # Simple track-light geometry:
             Translation { translation 0 4 0 }
             Separator {
                 Material { emissiveColor 0.1 0.3 0.3 }
                 Cube {
                     width   0.1
                     height  0.1
                     depth   4
                 }
             }
             Rotation { rotation 0 1 0  1.57079 }
             Separator {
                 Material { emissiveColor 0.3 0.1 0.3 }
                 Cylinder {
                     radius  0.1
                     height  .2
                 }
             }
             Rotation { rotation -1 0 0  1.57079 }
             Separator {
                 Material { emissiveColor 0.3 0.3 0.1 }
                 Rotation { rotation 1 0 0  1.57079 }
                 Translation { translation 0 -.2 0 }
                 Cone {
                     height  .4
                     bottomRadius .2
                 }
                 Translation { translation 0 .4 0 }
                 Cylinder {
                     radius  0.02
                     height  .4
                 }
             }
         }
         SpotLight {      # Light from above
             location 0 4 0
             direction 0 -1 0
             intensity       0.9
             cutOffAngle     0.7
         }
         Separator {      # Wall geometry; just three flat polygons
             Coordinate3 {
                 point [
                        -2 0 -2, -2 0 2, 2 0 2, 2 0 -2,
                        -2 4 -2, -2 4 2, 2 4 2, 2 4 -2]
             }
             IndexedFaceSet {
                 coordIndex [ 0, 1, 2, 3, -1,
                             0, 4, 5, 1, -1,
                             0, 3, 7, 4, -1
                             ]
             }
         }
         WWWAnchor {   # A hyper-linked cow:
             name "http://www.foo.edu/CowProject/AboutCows.html"
             Separator {
                 Translation { translation 0 1 0 }
                 WWWInline {   # Reference another object
                     name "http://www.foo.edu/3DObjects/cow.wrl"
                 }
             }
         }
     }


Exercise

Try creating a file named vrml.wrl, embedded in a html document called problem.html.  When you view file problem.html, you should see something identical to this.

Stuck?  Click here for a vrml model that solves the problem (but as a text file).


Last modified on 14 September 1999 by abrams@vt.edu