X3D Model Documentation: GridXY_20x20Movable.x3d

  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='GridXY_20x20Movable.x3d'/>
  6            <meta name='creator' content='Don Brutzman'/>
  7            <meta name='created' content='22 November 2000'/>
  8            <meta name='modified' content='28 November 2019'/>
  9            <meta name='description' content='Line grid authoring tool for precise measurement in 3D space: drag plane to move along Z axis, click numbers to hide grid. Oriented along XY plane, size 20m by 20m, default block size 1m by 1m.'/>
 10            <meta name='reference' content='https://savage.nps.edu/Savage/Tools/Authoring/GridsExample.x3d'/>
 11            <meta name='identifier' content='https://savage.nps.edu/Savage/Tools/Authoring/GridXY_20x20Movable.x3d'/>
 12            <meta name='generator' content='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
 13            <meta name='license' content='../../license.html'/>
 14       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: CenterText, CenterTextScript, DefaultAppearance, EndPoints, GridLocation, GridOnOffSwitch, GridSensor, LABEL_APPEARANCE, LABEL_FONT, LinesAlignedAlongX, LinesAlignedAlongZ, LineSensorAxisZ, LowerLeftText, LowerLeftTextScript, LowerRightText, LowerRightTextScript, SwitchTextOnOffScript, TextLabelTouchSensor, UpperLeftText, UpperLeftTextScript, UpperRightText, UpperRightTextScript

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2
-->
 15       <Scene>
 16            <WorldInfo title='GridXY_20x20Movable.x3d'/>
 17            <Viewpoint description='XY grid (0 0 30 relative)' position='0 0 30'/>
 18            <Viewpoint description='XY grid (35 0 20 relative)' orientation='0 1 0 1.06' position='35 0 20'/>
 19 
          <!-- ROUTE information for GridLocation node:  [from LineSensorAxisZ.translation_changed to set_translation ] -->
          <Transform DEF='GridLocation'>
 20                 <Group>
 21 
                    <!-- ROUTE information for TextLabelTouchSensor node:  [from isActive to SwitchTextOnOffScript.isTouched ] -->
                    <TouchSensor DEF='TextLabelTouchSensor' description='select and hold to hide grid'/>
 22                      <Transform translation='0 -0.5 0'>
 23                           <Billboard>
 24                                <Shape>
 25 
                                   <!-- ROUTE information for CenterText node:  [from CenterTextScript.value to string ] -->
                                   <Text DEF='CenterText' string='"origin"'>
 26 
                                        <!-- FontStyle LABEL_FONT is a DEF node that has 6 USE nodes: USE_1, USE_2, USE_3, USE_4, USE_5, USE_6 -->
                                        <FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.4'/>
 27                                     </Text>
 28 
                                   <!-- Appearance DefaultAppearance is a DEF node that has 4 USE nodes: USE_1, USE_2, USE_3, USE_4 -->
                                   <Appearance DEF='DefaultAppearance'>
 29                                          <Material/>
 30                                     </Appearance>
 31                                </Shape>
 32                           </Billboard>
 33                      </Transform>
 34                      <Transform translation='10 10.5 0'>
 35                           <Billboard>
 36                                <Shape>
 37 
                                   <!-- ROUTE information for UpperRightText node:  [from UpperRightTextScript.value to string ] -->
                                   <Text DEF='UpperRightText' string='"10 10 0"'>
 38                                          <FontStyle USE='LABEL_FONT'/>
 39                                     </Text>
 40                                     <Appearance USE='DefaultAppearance'/>
 41                                </Shape>
 42                           </Billboard>
 43                      </Transform>
 44                      <Transform translation='-10 10.5 0'>
 45                           <Billboard>
 46                                <Shape>
 47 
                                   <!-- ROUTE information for UpperLeftText node:  [from UpperLeftTextScript.value to string ] -->
                                   <Text DEF='UpperLeftText' string='"-10 10 0"'>
 48                                          <FontStyle USE='LABEL_FONT'/>
 49                                     </Text>
 50                                     <Appearance USE='DefaultAppearance'/>
 51                                </Shape>
 52                           </Billboard>
 53                      </Transform>
 54                      <Transform translation='-10 -10.5 0'>
 55                           <Billboard>
 56                                <Shape>
 57 
                                   <!-- ROUTE information for LowerLeftText node:  [from LowerLeftTextScript.value to string ] -->
                                   <Text DEF='LowerLeftText' string='"-10 -10 0"'>
 58                                          <FontStyle USE='LABEL_FONT'/>
 59                                     </Text>
 60                                     <Appearance USE='DefaultAppearance'/>
 61                                </Shape>
 62                           </Billboard>
 63                      </Transform>
 64                      <Transform translation='10 -10.5 0'>
 65                           <Billboard>
 66                                <Shape>
 67 
                                   <!-- ROUTE information for LowerRightText node:  [from LowerRightTextScript.value to string ] -->
                                   <Text DEF='LowerRightText' string='"10 -10 0"'>
 68                                          <FontStyle USE='LABEL_FONT'/>
 69                                     </Text>
 70                                     <Appearance USE='DefaultAppearance'/>
 71                                </Shape>
 72                           </Billboard>
 73                      </Transform>
 74                 </Group>
 75 
               <!-- ROUTE information for GridOnOffSwitch node:  [from SwitchTextOnOffScript.touchChoice to whichChoice ] -->
               <Switch DEF='GridOnOffSwitch' whichChoice='0'>
 76                      <Transform rotation='1 0 0 1.57079'>
 77 
                         <!-- ROUTE information for GridSensor node:  [from translation_changed to LineSensorAxisZ.set_translation ] -->
                         <PlaneSensor DEF='GridSensor' description='click and drag to move grid'/>
 78 
 79                                <field name='set_translation' type='SFVec3f' accessType='inputOnly'/>
 80                                <field name='translation_changed' type='SFVec3f' accessType='outputOnly'/>
  <![CDATA[
            
ecmascript:

// local-coordinates vertical Y is world-coordinates axis Z
function set_translation (location, timeStamp)  {
	translation_changed [0] = 0;
	translation_changed [1] = 0;
	translation_changed [2] = location.y;
//	Browser.println ('location=' + location + ', translation_changed=' + translation_changed); 
}

          
]]>
 82                           </Script>
 83 
                         <!-- Shape LinesAlignedAlongZ is a DEF node that has 1 USE node: USE_1 -->
                         <Shape DEF='LinesAlignedAlongZ'>
 84                                <IndexedLineSet colorPerVertex='false' colorIndex='1 0 0 0 0 2 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1' coordIndex='1 22 -1 2 23 -1 3 24 -1 4 25 -1 5 26 -1 6 27 -1 7 28 -1 8 29 -1 9 30 -1 10 31 -1 11 32 -1 12 33 -1 13 34 -1 14 35 -1 15 36 -1 16 37 -1 17 38 -1 18 39 -1 19 40 -1 20 41 -1 21 42 -1'>
 85                                     <Coordinate DEF='EndPoints' point='0 0 0 -10 0 10 -9 0 10 -8 0 10 -7 0 10 -6 0 10 -5 0 10 -4 0 10 -3 0 10 -2 0 10 -1 0 10 0 0 10 1 0 10 2 0 10 3 0 10 4 0 10 5 0 10 6 0 10 7 0 10 8 0 10 9 0 10 10 0 10 -10 0 -10 -9 0 -10 -8 0 -10 -7 0 -10 -6 0 -10 -5 0 -10 -4 0 -10 -3 0 -10 -2 0 -10 -1 0 -10 0 0 -10 1 0 -10 2 0 -10 3 0 -10 4 0 -10 5 0 -10 6 0 -10 7 0 -10 8 0 -10 9 0 -10 10 0 -10'/>
 86                                     <Color color='0.4 0.4 0.4 0.8 0.2 0 0.4 0.1 0.05'/>
 87                                </IndexedLineSet>
 88                           </Shape>
 89                           <Transform DEF='LinesAlignedAlongX' rotation='0 1 0 1.57079'>
 90                                <Shape USE='LinesAlignedAlongZ'/>
 91                           </Transform>
 92                           <Transform rotation='1 0 0 -1.57079' translation='10.5 0 0'>
 93                                <Billboard>
 94                                     <Shape>
 95                                          <Text string='"X"'>
 96                                               <FontStyle USE='LABEL_FONT'/>
 97                                          </Text>
 98 
                                        <!-- Appearance LABEL_APPEARANCE is a DEF node that has 1 USE node: USE_1 -->
                                        <Appearance DEF='LABEL_APPEARANCE'>
 99                                               <Material diffuseColor='1 1 .3' emissiveColor='.33 .33 .1'/>
100                                          </Appearance>
101                                     </Shape>
102                                </Billboard>
103                           </Transform>
104                           <Transform rotation='1 0 0 -1.57079' translation='0 0 -10.5'>
105                                <Billboard>
106                                     <Shape>
107                                          <Text string='"Y"'>
108                                               <FontStyle USE='LABEL_FONT'/>
109                                          </Text>
110                                          <Appearance USE='LABEL_APPEARANCE'/>
111                                     </Shape>
112                                </Billboard>
113                           </Transform>
114                      </Transform>
115                 </Switch>
116            </Transform>
117 
          <!-- ROUTE information for CenterTextScript node:  [from LineSensorAxisZ.translation_changed to set_translation ] [from value to CenterText.string ] -->
          <Script DEF='CenterTextScript'>
118                 <field name='set_translation' type='SFVec3f' accessType='inputOnly'/>
119                 <field name='value' type='MFString' accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:
// eventOut 'value' is an MFString array to match type of destination Text node string field

function initialize ( ) { 
//	Browser.println ('Grid script initialized, print function works');
//	trace ('Grid script initialized, trace function works');
}

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] = (Math.round (location.x * numberOfPlaces) / numberOfPlaces) + ' '
                 + (Math.round (location.y * numberOfPlaces) / numberOfPlaces) + ' '
                 + (Math.round (location.z * numberOfPlaces) / numberOfPlaces); 
//	Browser.println ('location=' + location); 
}

    
]]>
121            </Script>
122 
          <!-- ROUTE information for UpperRightTextScript node:  [from LineSensorAxisZ.translation_changed to set_translation ] [from value to UpperRightText.string ] -->
          <Script DEF='UpperRightTextScript'>
123                 <field name='set_translation' type='SFVec3f' accessType='inputOnly'/>
124                 <field name='value' type='MFString' accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] =  10 + ' ' +  10 + ' '
                 + (Math.round (location.z * numberOfPlaces) / numberOfPlaces); 
}

    
]]>
126            </Script>
127 
          <!-- ROUTE information for UpperLeftTextScript node:  [from LineSensorAxisZ.translation_changed to set_translation ] [from value to UpperLeftText.string ] -->
          <Script DEF='UpperLeftTextScript'>
128                 <field name='set_translation' type='SFVec3f' accessType='inputOnly'/>
129                 <field name='value' type='MFString' accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] =  -10 + ' ' + 10 + ' '
                 + (Math.round (location.z * numberOfPlaces) / numberOfPlaces); 
}

    
]]>
131            </Script>
132 
          <!-- ROUTE information for LowerLeftTextScript node:  [from LineSensorAxisZ.translation_changed to set_translation ] [from value to LowerLeftText.string ] -->
          <Script DEF='LowerLeftTextScript'>
133                 <field name='set_translation' type='SFVec3f' accessType='inputOnly'/>
134                 <field name='value' type='MFString' accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] = -10 + ' ' + -10 + ' '
                 + (Math.round (location.z * numberOfPlaces) / numberOfPlaces); 
}

    
]]>
136            </Script>
137 
          <!-- ROUTE information for LowerRightTextScript node:  [from LineSensorAxisZ.translation_changed to set_translation ] [from value to LowerRightText.string ] -->
          <Script DEF='LowerRightTextScript'>
138                 <field name='set_translation' type='SFVec3f' accessType='inputOnly'/>
139                 <field name='value' type='MFString' accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function set_translation (location, timeStamp)  {
	numberOfPlaces = 1000;
	value[0] = 10 + ' ' +  -10 + ' '
                 + (Math.round (location.z * numberOfPlaces) / numberOfPlaces); 
}

    
]]>
141            </Script>
142 
          <!-- ROUTE information for SwitchTextOnOffScript node:  [from TextLabelTouchSensor.isActive to isTouched ] [from touchChoice to GridOnOffSwitch.whichChoice ] -->
          <Script DEF='SwitchTextOnOffScript'>
143                 <field name='isTouched' type='SFBool' accessType='inputOnly'/>
144                 <field name='touchChoice' type='SFInt32' accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function isTouched (value, timeStamp)  {
	if (value == true)
		touchChoice = -1;
	else	touchChoice =  0; 
}

    
]]>
146            </Script>
147            < ROUTE  fromNode='GridSensor' fromField='translation_changed' toNode='LineSensorAxisZ' toField='set_translation'/>
148            <!-- Send changed position to text-construction scripts -->
149            < ROUTE  fromNode='LineSensorAxisZ' fromField='translation_changed' toNode='GridLocation' toField='set_translation'/>
150            < ROUTE  fromNode='LineSensorAxisZ' fromField='translation_changed' toNode='CenterTextScript' toField='set_translation'/>
151            < ROUTE  fromNode='LineSensorAxisZ' fromField='translation_changed' toNode='UpperRightTextScript' toField='set_translation'/>
152            < ROUTE  fromNode='LineSensorAxisZ' fromField='translation_changed' toNode='UpperLeftTextScript' toField='set_translation'/>
153            < ROUTE  fromNode='LineSensorAxisZ' fromField='translation_changed' toNode='LowerLeftTextScript' toField='set_translation'/>
154            < ROUTE  fromNode='LineSensorAxisZ' fromField='translation_changed' toNode='LowerRightTextScript' toField='set_translation'/>
155            <!-- Send text showing changed position to output Text nodes -->
156            < ROUTE  fromNode='CenterTextScript' fromField='value' toNode='CenterText' toField='string'/>
157            < ROUTE  fromNode='UpperRightTextScript' fromField='value' toNode='UpperRightText' toField='string'/>
158            < ROUTE  fromNode='UpperLeftTextScript' fromField='value' toNode='UpperLeftText' toField='string'/>
159            < ROUTE  fromNode='LowerLeftTextScript' fromField='value' toNode='LowerLeftText' toField='string'/>
160            < ROUTE  fromNode='LowerRightTextScript' fromField='value' toNode='LowerRightText' toField='string'/>
161            <!-- Enable/disable grid visibility based on user touching coordinate labels -->
162            < ROUTE  fromNode='TextLabelTouchSensor' fromField='isActive' toNode='SwitchTextOnOffScript' toField='isTouched'/>
163            < ROUTE  fromNode='SwitchTextOnOffScript' fromField='touchChoice' toNode='GridOnOffSwitch' toField='whichChoice'/>
164       </Scene>
165  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: CenterText, CenterTextScript, DefaultAppearance, EndPoints, GridLocation, GridOnOffSwitch, GridSensor, LABEL_APPEARANCE, LABEL_FONT, LinesAlignedAlongX, LinesAlignedAlongZ, LineSensorAxisZ, LowerLeftText, LowerLeftTextScript, LowerRightText, LowerRightTextScript, SwitchTextOnOffScript, TextLabelTouchSensor, UpperLeftText, UpperLeftTextScript, UpperRightText, UpperRightTextScript

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2
-->
X3D Tooltips element index: Appearance, Billboard, Color, Coordinate, field, FontStyle, Group, head, IndexedLineSet, Material, meta, PlaneSensor, ROUTE, Scene, Script, Shape, Switch, Text, TouchSensor, Transform, Viewpoint, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

Event Graph ROUTE Table entries with 14 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.

TextLabelTouchSensor
TouchSensor
isActive
SFBool
→
ROUTE
event to
(1)
SwitchTextOnOffScript
Script
isTouched
SFBool
then
 
 
 
SwitchTextOnOffScript
Script
touchChoice
SFInt32
→
ROUTE
event to
(2)
GridOnOffSwitch
Switch
whichChoice
SFInt32

GridSensor
PlaneSensor
translation_changed
SFVec3f
→
ROUTE
event to
(1)
LineSensorAxisZ
Script
set_translation
SFVec3f
then
 
 
 
LineSensorAxisZ
Script
translation_changed
SFVec3f
→
ROUTE
event to
(2)
GridLocation
Transform
set_translation
SFVec3f
  then
 
 
 
LineSensorAxisZ
Script
translation_changed
SFVec3f
→
ROUTE
event to
(2)
CenterTextScript
Script
set_translation
SFVec3f
then
 
 
 
CenterTextScript
Script
value
MFString
→
ROUTE
event to
(3)
CenterText
Text
string
MFString
  then
 
 
 
LineSensorAxisZ
Script
translation_changed
SFVec3f
→
ROUTE
event to
(2)
UpperRightTextScript
Script
set_translation
SFVec3f
then
 
 
 
UpperRightTextScript
Script
value
MFString
→
ROUTE
event to
(3)
UpperRightText
Text
string
MFString
  then
 
 
 
LineSensorAxisZ
Script
translation_changed
SFVec3f
→
ROUTE
event to
(2)
UpperLeftTextScript
Script
set_translation
SFVec3f
then
 
 
 
UpperLeftTextScript
Script
value
MFString
→
ROUTE
event to
(3)
UpperLeftText
Text
string
MFString
  then
 
 
 
LineSensorAxisZ
Script
translation_changed
SFVec3f
→
ROUTE
event to
(2)
LowerLeftTextScript
Script
set_translation
SFVec3f
then
 
 
 
LowerLeftTextScript
Script
value
MFString
→
ROUTE
event to
(3)
LowerLeftText
Text
string
MFString
  then
 
 
 
LineSensorAxisZ
Script
translation_changed
SFVec3f
→
ROUTE
event to
(2)
LowerRightTextScript
Script
set_translation
SFVec3f
then
 
 
 
LowerRightTextScript
Script
value
MFString
→
ROUTE
event to
(3)
LowerRightText
Text
string
MFString

Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://savage.nps.edu/Savage/Tools/Authoring/GridXY_20x20MovableIndex.html -->
<!-- Version control at
https://gitlab.nps.edu/Savage/Savage/Tools/Authoring/GridXY_20x20Movable.x3d -->

<!-- Color-coding 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)
-->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->