The Moving Worlds VRML 2.0 Specification

External API Reference

Draft 2b, June 4, 1996

This section describes the external application programming interface to the VRML browser.

For communication between a VRML world and "the outside" an external API for VRML is needed. By "the outside" I mean whatever environment the VRML browser is running in. In this proposal the interface internal to the VRML world (the internal interface)is separated from the interface on the outside (the external interface). The external interface must be bound to the environment, whether this is Java or some other language, or some sort of network aware socket interface. I will describe the internal interface here and give semantics (but not syntax) for the external interface. A separate document will explore some potential external bindings.

VRML 2.0 API

Nodes in VRML can be named using the "DEF" construct. This naming gives a convenient mechanism for accessing nodes from an external interface. Any node named with the DEF construct can be accessed from outside the VRML world. A node so named is referred to as an accessible node. Access to the node's internal data structures from the external API is limited to the eventIns and eventOuts of that node. The external API can send an eventIn to a accessible node and that node will receive that event just as if that event had come through a ROUTE. When an eventOut is sent from an accessible node that event is sent through the external API for handling.

Language Access

One of the expected bindings to the external API is through a language API. In Netscape this would allow Java or JavaScript to exchange events with a VRML world on the same page, perhaps in a different frame. Events would be sent into the world through an interface giving 4 pieces of information: frame (or other world identifier), DEF name, eventIn name, and data. Events coming out of the world would be handled by the same mechanism that is used for other events on the page such as button presses and mouse movement. The details of these bindings for a few languages is given in the VRML External API Bindings document

Network Access

TBD

Additional API

In addition to the interface to the accessible nodes, the Browser API (used by scripts internal to the Script node) can be used. With a language binding this can be done with methods on a static Browser class or object, or with individual procedure calls. With a network binding this would be done with some sort of bidirectional transaction, a request from the server followed by a response from the browser. See the Browser API section of the VRML spec for details on the Browser API.

 Contact rikk@best.com , cmarrin@sgi.com, or gavin@acm.org with questions or comments.
This URL: http://vrml.sgi.com/moving-worlds/spec/scriptref.html.