<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<![CDATA[
ecmascript: function initialize () { DEBUG = true; mode = 1; if (DEBUG) Browser.println ('initialize ():'); sceneText.string = new MFString ( 'EcmaScript initialize () with field control', 'has reinitialized the changedText node.', '', 'Please click text for additional results.'); sceneTransform.translation = new SFVec3f ( 0, 3, 0 ); sceneMaterial.diffuseColor = new SFColor ( 0.8, 0.8, 0.2 ); if (DEBUG) Browser.println ('sceneText.string =' + sceneText.string); if (DEBUG) Browser.println ('sceneTransform.translation =' + sceneTransform.translation); if (DEBUG) Browser.println ('sceneMaterial.diffuseColor =' + sceneMaterial.diffuseColor); } function startTime (value, timestamp) { if (DEBUG) Browser.println ('=============================='); if (DEBUG) Browser.println ('touchEvent startTime =' + value); mode = (mode + 1) % 3; if (DEBUG) Browser.println ('mode =' + mode); switch (mode) { case 0: // pre-initialize error messsage sceneText.string = new MFString ( 'Default text in VRML scene will be replaced by', 'EcmaScript initialize() in Script using field control.', 'This text appears first, if EcmaScript initialization fails.', ''); sceneTransform.translation = new SFVec3f ( 0, 1, 0 ); sceneMaterial.diffuseColor = new SFColor ( 0.8, 0.2, 0.2 ); break; case 1: // post-initialize ready-to-click message initialize (); break; case 2: // post-click all-done message sceneText.string = new MFString ( 'User click on text seen by EcmaScript', 'function via Script node eventIn.', 'Text & position successfully changed', 'via field control. Test passed.'); sceneTransform.translation = new SFVec3f ( 0, -1, 0 ); sceneMaterial.diffuseColor = new SFColor ( 0.2, 0.8, 0.2 ); break; } if (mode != 1) { if (DEBUG) Browser.println ('sceneText.string =' + sceneText.string); if (DEBUG) Browser.println ('sceneTransform.translation =' + sceneTransform.translation); if (DEBUG) Browser.println ('sceneMaterial.diffuseColor =' + sceneMaterial.diffuseColor); if (DEBUG) Browser.println (); } } function shutdown() { if (DEBUG) Browser.println ('=============================='); if (DEBUG) Browser.println ('script shutdown.'); if (DEBUG) Browser.println ('=============================='); }
]]>
Event Graph ROUTE Table with 1 ROUTE connections total, showing X3D event-model relationships for this scene.
Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.
ClickTextToTest
TouchSensor touchTime SFTime |
InterfaceScriptNode
Script startTime SFTime |
InterfaceScriptNode
Script |
No ROUTE connection found for output from this node. Contains SFNode field with indirect access to another node. |
<!--
Online at
https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/ScriptNodeFieldControl_EcmaScriptIndex.html
-->
<!--
Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/ScriptConformance/ScriptNodeFieldControl_EcmaScript.x3d
-->
<!--
Color legend: X3D terminology
<X3dNode
DEF='idName' field='value'/>
matches XML terminology
<XmlElement
DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement)
(Grey background inside box: inserted documentation)
(Magenta background: X3D Extensibility)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->