1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
|
3 | <X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'> |
4 | <head> |
5 | <meta name='title' content='ScriptNodeFieldControl_EcmaScript.x3d'/> |
6 | <meta name='description' content='Script node interface between VRML and EcmaScript: this conformance example tests field-based VRML-EcmaScript functionality.'/> |
7 | <meta name='creator' content='Don Brutzman'/> |
8 | <meta name='created' content='30 November 1997'/> |
9 | <meta name='translated' content='13 May 2001'/> |
10 | <meta name='modified' content='20 October 2019'/> |
11 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/ScriptNodeFieldControl_EcmaScript.x3d'/> |
12 | <meta name='reference' content='VRML 97 Specification, Annex C, ECMAScript scripting reference'/> |
13 | <meta name='reference' content='https://www.web3d.org/technicalinfo/specifications/vrml97/part1/javascript.html'/> |
14 | <meta name='reference' content='https://www.web3d.org/technicalinfo/specifications/vrml97/part1/javascript.html#AccessingFields'/> |
15 | <meta name='reference' content='Makefile'/> |
16 | <meta name='reference' content='Makefile.out'/> |
17 | <meta name='reference' content='ScriptNodeFieldControl_EcmaScript-VrmlConsoleOutput.txt'/> |
18 | <meta name='reference' content='ScriptNodeFieldControl_EcmaScriptSnapshots.html'/> |
19 | <meta name='reference' content='ScriptNodeFieldControl_Java.x3d'/> |
20 | <meta name='subject' content='VRML X3D EcmaScript Script conformance'/> |
21 | <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/> |
22 | <meta name='license' content='../license.html'/> |
23 | </head> |
24 | <Scene> |
25 | <WorldInfo title='ScriptNodeFieldControl_EcmaScript.x3d'/> |
26 | <Viewpoint description='View test' position='0 0 12'/> |
27 | <Group> |
28 |
<!-- ROUTE information for ClickTextToTest node:
[from touchTime to InterfaceScriptNode.startTime
]
-->
<TouchSensor DEF='ClickTextToTest' description='Click text to test'/> |
29 |
<!-- Transform
TextPosition is a DEF node that has 1 USE node: USE_1 -->
<Transform DEF='TextPosition'> |
30 | <!-- TextPosition translation is modified by InterfaceScriptNode. --> |
31 | <Shape> |
32 |
<!-- Text
MessageToUser is a DEF node that has 1 USE node: USE_1 -->
<Text DEF='MessageToUser' string='"Default text in VRML scene will be replaced by" "Java initialize() in Script using EventOut control." "This text appears first, if Java initialization fails." ""'> |
33 | <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.8'/> |
34 | </Text> |
35 | <Appearance> |
36 |
<!-- Material
TextMaterial is a DEF node that has 1 USE node: USE_1 --> <Material DEF='TextMaterial' diffuseColor='0.8 0.2 0.2' shininess='0.9'/> |
37 | </Appearance> |
38 | </Shape> |
39 | </Transform> |
40 |
<!-- ROUTE information for InterfaceScriptNode node:
[from ClickTextToTest.touchTime to startTime
]
-->
<Script DEF='InterfaceScriptNode' directOutput='true'> |
41 | <!-- No default values are allowed for eventIn or eventOut. --> |
42 | <field name='startTime' type='SFTime' accessType='inputOnly'/> |
43 | <field name='sceneText' type='SFNode' accessType='initializeOnly'> |
44 | <Text USE='MessageToUser'/> |
45 | </field> |
46 | <field name='sceneTransform' type='SFNode' accessType='initializeOnly'> |
47 | <Transform USE='TextPosition'/> |
48 | </field> |
49 | <field name='sceneMaterial' type='SFNode' accessType='initializeOnly'> |
50 | <Material USE='TextMaterial'/> |
51 | </field> |
<![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 ('=============================='); }
]]>
|
|
53 | </Script> |
54 | </Group> |
55 | < ROUTE fromNode='ClickTextToTest' fromField='touchTime' toNode='InterfaceScriptNode' toField='startTime'/> |
56 | </Scene> |
57 | </X3D> |
Event Graph ROUTE Table with 1 ROUTE connection 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 events from this node. Contains SFNode fields with direct access to another node. |
<!--
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. -->