The Annotated VRML 97 Reference

1 Intro     Concepts     3 Nodes     4 Fields/Events    Conformance
A Grammar     B Java     C JavaScript     D Examples     E Related Info    References
Quick Java         Quick JavaScript         Quick Nodes   
 

  About the Book
  
Help
  Copyright © 1997-99
  Purchase the book from Amazon.com

 

 

Chapter 2
Key Concepts

2.1 Intro

2.1.1 Overview
2.1.2 TOC
2.1.3 Conventions

2.2 Overview
2.2.1 File Structure
2.2.2 Header
2.2.3 Scene graph
2.2.4 Prototypes
2.2.5 Routing
2.2.6 Generating files
2.2.7 Presentation
     Interaction
2.2.8 Profiles

2.3 UTF-8 syntax
2.3.1 Clear text
2.3.2 Statements
2.3.3 Node
2.3.4 Field
2.3.5 PROTO
2.3.6 IS
2.3.7 EXTERNPROTO
2.3.8 USE
2.3.9 ROUTE

2.4 Scene graph
2.4.1 Root nodes
2.4.2 Hierarchy
2.4.3 Descendants
       & ancestors
2.4.4 Hierarchy
2.4.5 Units coord sys

2.5 VRML & WWW
2.5.1 MIME type
2.5.2 URLs
2.5.3 Relative URLs
2.5.4 data:
2.5.5 Scripting protocols
2.5.6 URNs

2.6 Nodes
2.6.1 Intro
2.6.2 DEF/USE
2.6.3 Geometry
2.6.4 Bboxes
2.6.5 Grouping & children
2.6.6 Lights
2.6.7 Sensors
2.6.8 Interpolators
2.6.9 Time nodes
2.6.10 Bindable children
2.6.11 Textures

2.7 Field, eventIn,
     eventOut

2.8 PROTO
2.8.1 Declaration
2.8.2 Definition
2.8.3 Scoping

2.9 EXTERNPROTO
2.9.1  Interface
2.9.2  URL
2.9.3 Extensions

2.10 Events
2.10.1 Intro
2.10.2 Routes
2.10.3 Execution
2.10.4 Loops
2.10.5 Fan-in & fan-out

2.11 Time
2.11.1 Intro
2.11.2 Origin
2.11.3 Discrete/cont

2.12 Scripting
2.12.1 Intro
2.12.2 Execution
2.12.3 Initialize/shutdown
2.12.4 eventsProcessed
2.12.5 Direct outputs
2.12.6 Asynchronous
2.12.7 Languages
2.12.8 EventIns
2.12.9 fields events
2.12.10 Browser interface

2.13 Navigation
2.13.1 Intro
2.13.2 Navigation
2.13.3 Viewing
2.13.4 Collisions

2.14 Lighting
2.14.1 Intro
2.14.2 'off'
2.14.3 'on'
2.14.4 Equations
2.14.5 References


+ 2.5 VRML and the World Wide Web

2.5.1 File extension and MIME types

The file extension for VRML files is .wrl (for world).

The official MIME type for VRML files is defined as:

    model/vrml

where the MIME major type for 3D data descriptions is model, and the minor type for VRML documents is vrml.

For compatibility with earlier versions of VRML, the following MIME type shall also be supported:

    x-world/x-vrml

where the MIME major type is x-world, and the minor type for VRML documents is x-vrml.

See [MIME] for details.

design note

MIME types do not encode file format version information, so both the MIME type and the file extension were not changed between VRML 1.0 and VRML 2.0. Changing the MIME type would avoid cryptic error messages like "Not a VRML file" from VRML 1.0 tools that do not understand VRML 2.0. However, this would require that every Web server in the world be configured to support the new file suffix. The most frequently encountered problem with VRML 1.0 files is that Web servers are not configured to serve VRML files. Therefore, changing the MIME type of the suffix would cause more problems than it solved.

tip

Almost all VRML 1.0 files can be transparently converted into VRML 2.0. There are VRML 1.0-to-2.0 file translators available from both Silicon Graphics (http://vrml.sgi.com) and Sony (http://vs.sony.co.jp/VS-E/vstop.html). Also, if you are using VRML 1.0, it is recommended that you avoid MatrixTransform and TransformSeparator since both of these nodes do not translate into VRML 2.0 very well.

2.5.2 URLs

A URL (Uniform Resource Locator), described in [URL], specifies a file located on a particular server and accessed through a specified protocol (e.g., http). The upper-case term URL refers to a Uniform Resource Locator, while the italicized lower-case version url refers to a field which may contain URLs, URNs, or in-line encoded data.

All url fields are of type MFString. The strings in these fields indicate multiple locations to look for data in decreasing order of preference. If the browser cannot locate the data specified by the first location, it shall try the second and subsequent locations in order. The url field entries are delimited by double quotation marks " ". Due to the "2.5.4 Data Protocol" and the "2.5.5 Scripting Language Protocols" url fields use a superset of the standard URL syntax (IETF RFC 1738). Details on the string field are located in "4.9 SFString and MFString."

More general information on URLs is described in [URL].

design note

Allowing multiple locations to be specified wherever a VRML file refers to some other file adds some useful features:

  • forward and backward compatibility between browsers as new protocols are created and deployed across the Internet. You can specify the new protocol as the first (most desirable) string in the url field and specify a more standard protocol as a backup in case the new protocol isn't understood by the browser. For example:
           url [ "new://www.vrml.org/foo.wrl"
                 "http://www.other.org/foo.wrl" ] 
  • "fault-tolerant" URLs. You can store a file on several different servers around the Web, then have the url field point to all of them. If one of the servers goes down, the VRML browser will simply use one of the other servers. For example:
           url [ "http://server1.com/foo.wrl"
                 "http://server2.com/foo.wrl" ] 

2.5.3 Relative URLs

Relative URLs are handled as described in [RURL]. The base document for EXTERNPROTO statements or Anchor, AudioClip, ImageTexture, Inline, MovieTexture, and Script node statements is:

  1. The file in which the prototype is instantiated, if the statement is part of a prototype definition.
  2. The file containing the script code, if the statement is part of a string passed to the createVrmlFromURL() or createVrmlFromString() browser calls in a Script node.
  3. Otherwise, the file from which the statement is read, in which case the RURL information provides the data itself.

2.5.4 Data protocol

The IETF is in the process of standardizing a "Data:" URL to be used for in-line inclusion of base64 encoded data, such as JPEG images. This capability shall be supported as specified in [DATA].

design note

The data: URL scheme is meant to be used for small pieces of data when the overhead of establishing a network connection is much greater than the time it takes to send the data. Some other uses for data: URLs include

  • low-resolution stand-ins. Using the multiple-strings URL feature, specify the full-resolution URL first and give an inline low-resolution version of the data as the second URL. Smart VRML browsers can display the low-resolution version to the user while the full-resolution version is being fetched across the network.
  • stand-alone VRML files. Sometimes it is convenient to bundle up a VRML world into one single file. This can be done by recursively replacing any URLs in the main VRML file with inline data: URLs. This is generally a bad idea if the VRML file will be delivered by a network, since it is much better if the user doesn't have to wait for a huge file to download before interacting with a world, but it can be very convenient for moderate-size VRML worlds distributed on (for example) CD-ROM.

2.5.5 Scripting language protocols

The Script node's url field may also support custom protocols for the various scripting languages. For example, a script url prefixed with javascript: shall contain JavaScript source, with line terminators allowed in the string. A script prefixed with javabc: shall contain Java bytecodes using a base64 encoding. The details of each language protocol are defined in the appendix for each language. Browsers are not required to support any specific scripting language. However, browsers shall adhere to the protocol for any scripting language which is supported. The following example illustrates the use of mixing custom protocols and standard protocols in a single url (order of precedence determines priority):

    #VRML V2.0 utf8 
    Script {
      url [ "javascript: ...",           # custom protocol
            "http://bar.com/foo.js",     # std protocol
            "http://bar.com/foo.class" ] # std protocol
    }

In the example above, the "..." represents in-line JavaScript source code.

design note

These new VRML-specific "protocols" were added to make it easier to create behaviors with a text editor and they don't follow the strict URL syntax as specified by the IETF (which requires certain common punctuation to be encoded, for example).

2.5.6 URNs

URNs are location-independent pointers to a file or to different representations of the same content. In most ways, URNs can be used like URLs except that, when fetched, a smart browser should fetch them from the closest source. URN resolution over the Internet has not yet been standardized. However, URNs may be used now as persistent unique identifiers for referenced entities such as files, EXTERNPROTOs, and textures. General information on URNs is available at [URN].

URNs may be assigned by anyone with a domain name. For example, if the company Foo owns foo.com, it may allocate URNs that begin with "urn:inet:foo.com:". An example of such usage is "urn:inet:foo.com:texture:wood001". See the draft specification referenced in [URN] for a description of the legal URN syntax.

To reference a texture, EXTERNPROTO, or other file by a URN, the URN is included in the url field of another node. For example:

    ImageTexture {
      url [ "http://www.foo.com/textures/wood_floor.gif",
            "urn:inet:foo.com:textures:wood001" ]
    }

specifies a URL file as the first choice and a URN as the second choice.

design note

It is hoped that eventually there will be a standard set of VRML data files that will be widely distributed and frequently used by world creators—a standard library of objects, textures, sounds, and so forth. If a common set of resources are agreed on, they could be distributed and loaded from a CD-ROM or hard disk on a user's local machine, resulting in much faster load times. The world creator would merely refer to things by their standard URN name. The VRML browser will know the location of the "nearest" copy, whether already loaded into memory, on a CD in the local CD-ROM drive, or located somewhere on the network.