This document can be found at http://reality.sgi.com/employees/gavin/vrml/Scripts.html. It was last updated on Dec. 11, 1995.
Behavior files are referenced through a new Script node:
Script { behavior "" # MFString field scriptType "" # SFString field optimization # SFBitMask field: (UNKNOWNOUTPUTS | ALWAYSEVAL Mitra/Sony: | CULLEVENTS | LODEVENTS | WORLDINOUT ) # And any number of: eventIn eventTypeName eventName field fieldTypeName fieldName initialValue eventOut eventTypeName eventName }
For example:
Script { behavior "http://foo.com/bar.class" ; MFSTRING scriptType "JAVA" ; SFSTRING eventIn SFString name eventIn PICK selected eventOut SFString lookto field SFLong currentState 0 optimization ALWAYSEVAL }
A Script node instance may consist of:
ALWAYSEVAL
or UNKNOWNOUTPUTS
optimization flags are not set) then the source of the eventIn may not
need to be evaluated.
Note that multiple outputs can be fanned into a single eventIn. Also note the example of specifing the type as PICK, which is a hint to the authoring system that it should only attach this eventIn to a ClickSensor.
Gavin: Defines a VisibilitySensor that takes the place of the CULL/LOD events functionality; script init/destroy calls and ProximitySensors that enclose the entire world take the place of WORLD events.
Sony/Mitra: Script nodes can only appear as children of Frames, and have an implicit object which they are attached to. They should be thought of as implementing the behavior of the real-world object.
SGI/Gavin: Script nodes can appear anywhere a node can appear in the VRML file, but Script nodes are conceptually NOT part of the scene parent/child hierarchy. Instead, Script nodes should be thought of as nodes that live "to the side" of the scene graph structure, orchestrating the flow of events from Sensors, which are part of the scene's structure and which DO have a particular place in the virtual world, or from the real world (if the Script node is a source of real-world events), into changes to the virtual world. Scripts may be combined with geometry using the prototyping mechanism to create real-world-like objects that encapsulate behavior.
A Script node is "executed" after it has received one or more events. When it executes, it may process the events received, update its internal and/or persistent state, generate output events, and make API calls to find out information about or change the virtual world.
A Script node may also run asynchronously, in which case it may spontaneously generate events.
The Script API document describes in detail the types of operations a Script node may perform.
To deal with concerns about optimisation, some rules must be laid down about when a browser can, and when it cannot, optimise away, or cull, a behavior (or a node).