Interface Script

All Superinterfaces:
X3DChildNode, X3DNode, X3DScriptNode, X3DUrlObject
All Known Implementing Classes:
Script

public interface Script
extends X3DScriptNode
Script contains author-programmed event behaviors for a scene.

X3D node tooltip: [X3DScriptNode] Script contains author-programmed event behaviors for a scene. Define the script input-output event interface by including <field/> elements. Scripting code is embedded in a child CDATA node or (deprecated) in the url field. Optionally supported programming languages are ECMAScript (JavaScript) and Java (via url to a myNode.class file).
  • Hint: insert a CDATA block to contain source code embedded within an X3D scene.
  • Hint: a contained CDATA block for source code protects whitespace, line breaks, and literal characters (such as & for ampersand character, < for less-than-sign character, and > for greater-than-sign character) from unintended escape-character modifications by XML parsers.
  • Warning: strict order is required for contained constructs: first field declarations (if any), then IS/connect statements (if any), and finally CDATA source-code block.
  • Hint: X3D Scene Authoring Hints, Scripts https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#Scripts
  • Hint: apply containerField='watchList' when parent node is LoadSensor.

Package hint: This interface is defined by the X3D Java Language Binding Specification for the Scene Authoring Interface (SAI).
See Also:
SAI Java Specification, X3D Abstract Specification: Script, X3D Tooltips: Script, X3D Scene Authoring Hints: Scripts
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getDescription()
    Provide String value from inputOutput SFString field named description.
    boolean getDirectOutput()
    Provide boolean value from initializeOnly SFBool field named directOutput.
    boolean getLoad()
    Provide boolean value from inputOutput SFBool field named load.
    X3DMetadataObject getMetadata()
    Provide org.web3d.x3d.sai.Core.X3DMetadataObject instance (using a properly typed node) from inputOutput SFNode field metadata.
    boolean getMustEvaluate()
    Provide boolean value from initializeOnly SFBool field named mustEvaluate.
    double getRefresh()
    Provide double value in seconds within allowed range of [0,infinity) from inputOutput SFTime field named refresh.
    java.lang.String[] getUrl()
    Provide array of String results from inputOutput MFString field named url.
    Script setDescription​(java.lang.String newValue)
    Accessor method to assign String value to inputOutput SFString field named description.
    Script setDirectOutput​(boolean newValue)
    Accessor method to assign boolean value to initializeOnly SFBool field named directOutput.
    Script setLoad​(boolean newValue)
    Accessor method to assign boolean value to inputOutput SFBool field named load.
    Script setMetadata​(X3DMetadataObject newValue)
    Accessor method to assign org.web3d.x3d.sai.Core.X3DMetadataObject instance (using a properly typed node) to inputOutput SFNode field metadata.
    Script setMustEvaluate​(boolean newValue)
    Accessor method to assign boolean value to initializeOnly SFBool field named mustEvaluate.
    Script setRefresh​(double newValue)
    Accessor method to assign double value in seconds to inputOutput SFTime field named refresh.
    Script setUrl​(java.lang.String[] newValue)
    Accessor method to assign String array to inputOutput MFString field named url.
  • Method Details

    • getDescription

      java.lang.String getDescription()
      Provide String value from inputOutput SFString field named description.

      Tooltip: Author-provided prose that describes intended purpose of the url asset.
      • Hint: many XML tools substitute XML character references for special characters automatically if needed within an attribute value (such as & for & ampersand character, or " for " quotation-mark character).
      Specified by:
      getDescription in interface X3DScriptNode
      Specified by:
      getDescription in interface X3DUrlObject
      Returns:
      value of description field
    • setDescription

      Script setDescription​(java.lang.String newValue)
      Accessor method to assign String value to inputOutput SFString field named description.

      Tooltip: Author-provided prose that describes intended purpose of the url asset.
      • Hint: many XML tools substitute XML character references for special characters automatically if needed within an attribute value (such as & for & ampersand character, or " for " quotation-mark character).
      Specified by:
      setDescription in interface X3DScriptNode
      Specified by:
      setDescription in interface X3DUrlObject
      Parameters:
      newValue - is new value for the description field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • getDirectOutput

      boolean getDirectOutput()
      Provide boolean value from initializeOnly SFBool field named directOutput.

      Tooltip: 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 a Script might directly change attribute values in referenced SFNode/MFNode fields, without a ROUTE connecting output events.
      • Hint: directOutput false means Script cannot modify referenced nodes or change ROUTEs.
      Returns:
      value of directOutput field
    • setDirectOutput

      Script setDirectOutput​(boolean newValue)
      Accessor method to assign boolean value to initializeOnly SFBool field named directOutput.

      Tooltip: 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 a Script might directly change attribute values in referenced SFNode/MFNode fields, without a ROUTE connecting output events.
      • Hint: directOutput false means Script cannot modify referenced nodes or change ROUTEs.
      Parameters:
      newValue - is new value for the directOutput field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • getLoad

      boolean getLoad()
      Provide boolean value from inputOutput SFBool field named load.

      Tooltip: load=true means load immediately, load=false means defer loading or else unload a previously loaded scene.
      • Hint: allows author to design when Inline loading occurs via user interaction, event chains or scripting.
      • Hint: use a separate LoadSensor node to detect when loading is complete.
      Specified by:
      getLoad in interface X3DScriptNode
      Specified by:
      getLoad in interface X3DUrlObject
      Returns:
      value of load field
    • setLoad

      Script setLoad​(boolean newValue)
      Accessor method to assign boolean value to inputOutput SFBool field named load.

      Tooltip: load=true means load immediately, load=false means defer loading or else unload a previously loaded scene.
      • Hint: allows author to design when Inline loading occurs via user interaction, event chains or scripting.
      • Hint: use a separate LoadSensor node to detect when loading is complete.
      Specified by:
      setLoad in interface X3DScriptNode
      Specified by:
      setLoad in interface X3DUrlObject
      Parameters:
      newValue - is new value for the load field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • getMetadata

      X3DMetadataObject getMetadata()
      Provide org.web3d.x3d.sai.Core.X3DMetadataObject instance (using a properly typed node) from inputOutput SFNode field metadata.

      Tooltip: [X3DMetadataObject] Information about this node can be contained in a MetadataBoolean, MetadataDouble, MetadataFloat, MetadataInteger, MetadataString or MetadataSet node.
      Specified by:
      getMetadata in interface X3DChildNode
      Specified by:
      getMetadata in interface X3DNode
      Specified by:
      getMetadata in interface X3DScriptNode
      Returns:
      value of metadata field
      See Also:
      X3D Scene Authoring Hints: Metadata Nodes
    • setMetadata

      Script setMetadata​(X3DMetadataObject newValue)
      Accessor method to assign org.web3d.x3d.sai.Core.X3DMetadataObject instance (using a properly typed node) to inputOutput SFNode field metadata.

      Tooltip: [X3DMetadataObject] Information about this node can be contained in a MetadataBoolean, MetadataDouble, MetadataFloat, MetadataInteger, MetadataString or MetadataSet node.
      Specified by:
      setMetadata in interface X3DChildNode
      Specified by:
      setMetadata in interface X3DNode
      Specified by:
      setMetadata in interface X3DScriptNode
      Parameters:
      newValue - is new value for the metadata field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      See Also:
      X3D Scene Authoring Hints: Metadata Nodes
    • getMustEvaluate

      boolean getMustEvaluate()
      Provide boolean value from initializeOnly SFBool field named mustEvaluate.

      Tooltip: If mustEvaluate false, then the X3D player may delay sending input events to Script until output events are needed. If mustEvaluate true, then Script must receive input events immediately without any event-aggregation delays.
      • Hint: set mustEvaluate true when sending/receiving values via the network.
      Returns:
      value of mustEvaluate field
    • setMustEvaluate

      Script setMustEvaluate​(boolean newValue)
      Accessor method to assign boolean value to initializeOnly SFBool field named mustEvaluate.

      Tooltip: If mustEvaluate false, then the X3D player may delay sending input events to Script until output events are needed. If mustEvaluate true, then Script must receive input events immediately without any event-aggregation delays.
      • Hint: set mustEvaluate true when sending/receiving values via the network.
      Parameters:
      newValue - is new value for the mustEvaluate field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • getRefresh

      double getRefresh()
      Provide double value in seconds within allowed range of [0,infinity) from inputOutput SFTime field named refresh.

      Tooltip: refresh defines interval in seconds before automatic reload of current url asset is performed.
      • Hint: if preceding file loading fails or load field is false, no refresh is performed.
      • Hint: repeated refresh attempts to reload currently loaded entry of url list. If that fails, the browser retries other entries in the url list.
      • Warning: automatically reloading content has security considerations and needs to be considered carefully.
      Specified by:
      getRefresh in interface X3DScriptNode
      Specified by:
      getRefresh in interface X3DUrlObject
      Returns:
      value of refresh field
    • setRefresh

      Script setRefresh​(double newValue)
      Accessor method to assign double value in seconds to inputOutput SFTime field named refresh.

      Tooltip: refresh defines interval in seconds before automatic reload of current url asset is performed.
      • Hint: if preceding file loading fails or load field is false, no refresh is performed.
      • Hint: repeated refresh attempts to reload currently loaded entry of url list. If that fails, the browser retries other entries in the url list.
      • Warning: automatically reloading content has security considerations and needs to be considered carefully.
      Specified by:
      setRefresh in interface X3DScriptNode
      Specified by:
      setRefresh in interface X3DUrlObject
      Parameters:
      newValue - is new value for the refresh field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • getUrl

      java.lang.String[] getUrl()
      Provide array of String results from inputOutput MFString field named url.

      Tooltip: List of address links for runnable script files.
      • Hint: browsers are not required to support any particular scripting language, but ECMAScript (JavaScript) is widely supported.
      • Hint: equivalent script code written in multiple programming languages can be provided for portability, the first runnable version is chosen at run time.
      • Hint: X3D Scene Authoring Hints, Scripts https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#Scripts
      • Warning: source code can be placed in url attribute but may be unparsable due to escaping of special characters and elimination of line breaks (causing comments to nullify follow-on code). Use contained CDATA section instead for embedding source code.
      • Hint: if both url field and CDATA section are provided simultaneously, the url field is processed first. This approach allows utilization of update modifications or live queries in external scripts, while still providing reliable script source as a fallback alternative within the model itself.
      • Hint: X3D XML Encoding, 4.3.13 Encapsulating Script node code https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#EncapsulatingScriptNodeCode
      • Hint: MFString arrays can have multiple values, so separate each individual string by quote marks "https://www.web3d.org" "https://www.web3d.org/about" "etc."
      • Hint: alternative XML encoding for quotation mark " is " (which is an example of a character entity).
      • Warning: strictly match directory and filename capitalization for http links! This is important for portability. Some operating systems are forgiving of capitalization mismatches, but http/https url addresses and paths in Unix-based operating systems are all case sensitive and intolerant of uppercase/lowercase mismatches.
      • Hint: can replace embedded blank(s) in url queries with %20 for each blank character.
      • Hint: X3D Scene Authoring Hints, urls https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#urls
      Specified by:
      getUrl in interface X3DScriptNode
      Specified by:
      getUrl in interface X3DUrlObject
      Returns:
      value of url field
    • setUrl

      Script setUrl​(java.lang.String[] newValue)
      Accessor method to assign String array to inputOutput MFString field named url.

      Tooltip: List of address links for runnable script files.
      • Hint: browsers are not required to support any particular scripting language, but ECMAScript (JavaScript) is widely supported.
      • Hint: equivalent script code written in multiple programming languages can be provided for portability, the first runnable version is chosen at run time.
      • Hint: X3D Scene Authoring Hints, Scripts https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#Scripts
      • Warning: source code can be placed in url attribute but may be unparsable due to escaping of special characters and elimination of line breaks (causing comments to nullify follow-on code). Use contained CDATA section instead for embedding source code.
      • Hint: if both url field and CDATA section are provided simultaneously, the url field is processed first. This approach allows utilization of update modifications or live queries in external scripts, while still providing reliable script source as a fallback alternative within the model itself.
      • Hint: X3D XML Encoding, 4.3.13 Encapsulating Script node code https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#EncapsulatingScriptNodeCode
      • Hint: MFString arrays can have multiple values, so separate each individual string by quote marks "https://www.web3d.org" "https://www.web3d.org/about" "etc."
      • Hint: alternative XML encoding for quotation mark " is " (which is an example of a character entity).
      • Warning: strictly match directory and filename capitalization for http links! This is important for portability. Some operating systems are forgiving of capitalization mismatches, but http/https url addresses and paths in Unix-based operating systems are all case sensitive and intolerant of uppercase/lowercase mismatches.
      • Hint: can replace embedded blank(s) in url queries with %20 for each blank character.
      • Hint: X3D Scene Authoring Hints, urls https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#urls
      Specified by:
      setUrl in interface X3DScriptNode
      Specified by:
      setUrl in interface X3DUrlObject
      Parameters:
      newValue - is new value for the url field.
      Returns:
      Script - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).