Titania X3D Editor

It starts with you!

Titania v3.0.4

It starts with you!

X3D Reference

Script

Script

Script provides programmed behavior for a scene. Define the script interface with <field> elements. Scripting code is embedded in a child CDATA node or (deprecated) in the url field. Optionally supported programming languages: ECMAScript (JavaScript) and (via url to a myNode.class file) Java.

The Script node belongs to the Scripting component and its container field is children. It is available since X3D version 3.0 or later.

Hierarchy

* Derived from multiple interfaces.

Fields

SFNode [in, out] metadata NULL [X3DMetadataObject]

Metadata are not part of the X3D world and not interpreted by the X3D browser, but they can be accessed via the ECMAScript interface.

MFString [in, out] url [ ] [URI]

Points to a script file url. Also (as deprecated alternative to CDATA block) can contain ecmascript: source as a quoted SFString within the url array.

Hint

If Script contains both external url reference and internal CDATA source then external url takes precedence, but will fall back to contained CDATA source if no external script is found.

Warnings

Do not use the ecmascript: protocol prefix within external script files. Replace javascript: or vrmlscript: protocol prefix with ecmascript: for source code embedded within an X3D scene.

See Also

ECMAScript is the ISO standard version of JavaScript. VrmlScript was a subset of JavaScript originally proposed for use with VRML 97. X3D Scene Authoring Hints, urls

SFBool [ ] directOutput 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.

Hints

Set directOutput true if Script dynamically establishes or breaks ROUTEs. DirectOutput is a browser hint to avoid overoptimizing referenced nodes, since the Script may change their attribute values without ROUTEd events. DirectOutput false means Script cannot modify referenced nodes or change ROUTEs.

SFBool [ ] mustEvaluate 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.

Description

Hints

  • Insert a CDATA node to contain source code embedded within an X3D scene.
  • CDATA blocks can protect literal characters (such as & < and >) in source code from unintended escape-character modifications by XML parsers.

Browser Compatibility

Titania X_ITE
yes yes