Class dnx.lr.node.ScriptNode
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class dnx.lr.node.ScriptNode

java.lang.Object
   |
   +----dnx.util.DNXObject
           |
           +----dnx.lr.Node
                   |
                   +----dnx.lr.node.ScriptNode

public class ScriptNode
extends Node
 Script {
    field        MFString     url             []
    field        SFBool       directOutput    FALSE
    field        SFBool       mustEvaluate    FALSE
  And any number of:
    eventIn      eventTypeName eventName
    field        fieldTypeName fieldName initialValue
    eventOut     eventTypeName eventName
 }

The Script node is used to program behavior in a scene. Script nodes typically receive events that signify a change or user action, contain a program module that performs some computation, and effect change somewhere else in the scene by sending output events. Each Script node has associated programming language code, referenced by the url field, that is executed to carry out the Script node's function. That code will be referred to as "the script" in the rest of this description.

Browsers are not required to support any specific language. See the section in "Concepts - Scripting" for general information on scripting languages. Browsers are required to adhere to the language bindings of languages specified in annexes of the specification. See the section "Concepts - URLs and URNs" for details on the url field.

When the script is created, any language-dependent or user-defined initialization is performed. The script is able to receive and process events that are sent to it. Each event that can be received must be declared in the Script node using the same syntax as is used in a prototype definition:

    eventIn type name

The type can be any of the standard VRML fields (see "Field Reference"), and name must be an identifier that is unique for this Script node.

The Script node should be able to generate events in response to the incoming events. Each event that can be generated must be declared in the Script node using the following syntax:

    eventOut type name

Script nodes cannot have exposedFields. The implementation ramifications of exposedFields is far too complex and thus not allowed.

If the Script node's mustEvaluate field is FALSE, the browser can delay sending input events to the script until its outputs are needed by the browser. If the mustEvaluate field is TRUE, the browser should send input events to the script as soon as possible, regardless of whether the outputs are needed. The mustEvaluate field should be set to TRUE only if the Script has effects that are not known to the browser (such as sending information across the network); otherwise, poor performance may result.

Once the script has access to a VRML node (via an SFNode or MFNode value either in one of the Script node's fields or passed in as an eventIn), the script should be able to read the contents of that node's exposed field. If the Script node's directOutput field is TRUE, the script may also send events directly to any node to which it has access, and may dynamically establish or break routes. If directOutput is FALSE (the default), then the script may only affect the rest of the world via events sent through its eventOuts.

A script is able to communicate directly with the VRML browser to get and set global information such as navigation information, the current time, the current world URL, and so on. This is strictly defined by the API for the specific language being used.

It is expected that all other functionality (such as networking capabilities, multi-threading capabilities, and so on) will be provided by the scripting language.


Variable Index

 o directOutput
 o mustEvaluate
 o url

Constructor Index

 o ScriptNode()

Method Index

 o createNodeDefinition(NodeDefinition)
Create the node definition.
 o finalize()
 o handleAddToScene()
The handleAddToScene method is called when a node has just been added to a scene.
 o handleEvent(SceneEvent)
Handle an event.
 o handleFieldChange(Field)
Handle a field change.
 o initFields()
Initialize field values.

Variables

 o url
  public MFString url
 o directOutput
  public SFBool directOutput
 o mustEvaluate
  public SFBool mustEvaluate

Constructors

 o ScriptNode
  public ScriptNode()

Methods

 o createNodeDefinition
  protected void createNodeDefinition(NodeDefinition def)
Create the node definition.
Overrides:
createNodeDefinition in class Node
 o initFields
  protected void initFields()
Initialize field values.
Overrides:
initFields in class Node
 o handleAddToScene
  protected void handleAddToScene()
The handleAddToScene method is called when a node has just been added to a scene.
Overrides:
handleAddToScene in class Node
 o handleFieldChange
  protected void handleFieldChange(Field f)
Handle a field change.
Overrides:
handleFieldChange in class Node
 o handleEvent
  protected void handleEvent(SceneEvent ev)
Handle an event.
Overrides:
handleEvent in class Node
 o finalize
  protected void finalize()
Overrides:
finalize in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index