Script
Script provides programmed behavior for a scene. Define the script interface with "field" tags. Scripting code is embedded in a child CDATA node or (deprecated) in the url field. Optionally supported languages: ECMAScript/JavaScript and (via url to a myNode.class file) Java.
Inheritance
Code
XML encoding
<Script url='' directOutput='FALSE' mustEvaluate='FALSE' triggerName='Timer' logFeature='' />
Classic encoding
Script { url [""] directOutput FALSE mustEvaluate FALSE triggerName "Timer" logFeature [""] }
Interface
Filter: X3D only | Avalon only | All
id | Name | DataType | PartType | Default | ValueType | Description |
---|---|---|---|---|---|---|
directOutput | SFBool | initializeOnly | FALSE | Set directOutput true if Script has field reference(s) of type SFNode/MFNode, and also uses direct access to modify attributes of a referenced node in the Scene. Hint: set directOutput true if Script dynamically establishes or breaks ROUTEs. Hint: directOutput is a browser hint to avoid overoptimizing referenced nodes, since the Script may change their attribute values without ROUTEd events. Hint: directOutput false means Script cannot modify referenced nodes or change ROUTEs. | ||
mustEvaluate | SFBool | initializeOnly | FALSE | If mustEvaluate false, then browser may delay sending input events to Script until outputs are needed. If mustEvaluate true, then Script must receive input events immediately without browser delays. Hint: set mustEvaluate true when sending/receiving values via the network. | ||
triggerName | SFString | initializeOnly | Timer | name of the dynamic context-slot which is used by the run-time environment (e.g. Jobs) to trigger the node. Life-Nodes will automatically connect the context-eventOutut to the triggerSlot-eventInput Slot. | ||
logFeature | MFString | inputOutput | state, child, parent, route, eventIn, eventOut | controls the logging of changes, state: log state changes (e.g. live), child: log child add/remove, parent: log parent add/remove, route: log route add/remove; eventIn: log receiving of events, eventOut: log sending of events: guiView, runtime system should create node-view, guiEdit: runtime system should create node-editeverything: log everything | ||
metadata | SFNode | inputOutput | MetadataObject | container for payload metadata inside MetadataSet element | ||
url | MFString | inputOutput | cdata | points to a script file or contains scripting code. Preferred alternative to url scripts: insert a CDATA node to contain embedded source code. CDATA can protect literals like less then and greater then from syntax checkers. Hint: ECMAScript is the same as JavaScript. |