X3D Model Documentation: GridYZ_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='titlecontent=' GridYZ_20x20Movable.x3d '/>
  6            <meta name='creatorcontent='Don Brutzman'/>
  7            <meta name='createdcontent='8 November 2000'/>
  8            <meta name='modifiedcontent='28 November 2019'/>
  9            <meta name='descriptioncontent='Line grid authoring tool for precise measurement in 3D space: drag plane to move along X axis, click numbers to hide grid. Oriented along YZ plane, size 20m by 20m, default block size 1m by 1m.'/>
 10            <meta name='referencecontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridsExample.x3d '/>
 11            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridYZ_20x20Movable.x3d '/>
 12            <meta name='generatorcontent='X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 13            <meta name='licensecontent='../../license.html'/>
 14       </head>
<!--

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

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

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

          
]]>
 83                           </Script>
 84 
                         <!-- Shape LinesAlignedAlongZ is a DEF node that has 1 USE node: USE_1 -->
                         <Shape DEF='LinesAlignedAlongZ'>
 85                                <IndexedLineSet colorPerVertex='falsecolorIndex='1 0 0 0 0 2 0 0 0 0 1 0 0 0 0 2 0 0 0 0 1coordIndex='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'>
 86                                     <Coordinate DEF='EndPointspoint='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'/>
 87                                     <Color color='0.4 0.4 0.4 0.8 0.2 0 0.4 0.1 0.05'/>
 88                                </IndexedLineSet>
 89                           </Shape>
 90                           <Transform DEF='LinesAlignedAlongXrotation='0 1 0 1.57079'>
 91                                <Shape USE='LinesAlignedAlongZ'/>
 92                           </Transform>
 93                           <Transform rotation='0 0 1 1.57079translation='-10.5 0 0'>
 94                                <Billboard>
 95                                     <Shape>
 96                                          <Text string='"Y"'>
 97                                               <FontStyle USE='LABEL_FONT'/>
 98                                          </Text>
 99 
                                        <!-- Appearance LABEL_APPEARANCE is a DEF node that has 1 USE node: USE_1 -->
                                        <Appearance DEF='LABEL_APPEARANCE'>
100                                               <Material diffuseColor='1 1 .3emissiveColor='.33 .33 .1'/>
101                                          </Appearance>
102                                     </Shape>
103                                </Billboard>
104                           </Transform>
105                           <Transform rotation='0 0 1 1.57079translation='0 0 10.5'>
106                                <Billboard>
107                                     <Shape>
108                                          <Text string='"Z"'>
109                                               <FontStyle USE='LABEL_FONT'/>
110                                          </Text>
111                                          <Appearance USE='LABEL_APPEARANCE'/>
112                                     </Shape>
113                                </Billboard>
114                           </Transform>
115                      </Transform>
116                 </Switch>
117            </Transform>
118 
          <!-- ROUTE information for CenterTextScript node:  [from LineSensorAxisX.translation_changed to set_translation ] [from value to CenterText.string ] -->
          <Script DEF='CenterTextScript'>
119                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
120                 <field name='valuetype='MFStringaccessType='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); 
}

    
]]>
122            </Script>
123 
          <!-- ROUTE information for UpperRightTextScript node:  [from LineSensorAxisX.translation_changed to set_translation ] [from value to UpperRightText.string ] -->
          <Script DEF='UpperRightTextScript'>
124                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
125                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

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

    
]]>
127            </Script>
128 
          <!-- ROUTE information for UpperLeftTextScript node:  [from LineSensorAxisX.translation_changed to set_translation ] [from value to UpperLeftText.string ] -->
          <Script DEF='UpperLeftTextScript'>
129                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
130                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

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

    
]]>
132            </Script>
133 
          <!-- ROUTE information for LowerLeftTextScript node:  [from LineSensorAxisX.translation_changed to set_translation ] [from value to LowerLeftText.string ] -->
          <Script DEF='LowerLeftTextScript'>
134                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
135                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

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

    
]]>
137            </Script>
138 
          <!-- ROUTE information for LowerRightTextScript node:  [from LineSensorAxisX.translation_changed to set_translation ] [from value to LowerRightText.string ] -->
          <Script DEF='LowerRightTextScript'>
139                 <field name='set_translationtype='SFVec3faccessType='inputOnly'/>
140                 <field name='valuetype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

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

    
]]>
142            </Script>
143 
          <!-- ROUTE information for SwitchTextOnOffScript node:  [from TextLabelTouchSensor.isActive to isTouched ] [from touchChoice to GridOnOffSwitch.whichChoice ] -->
          <Script DEF='SwitchTextOnOffScript'>
144                 <field name='isTouchedtype='SFBoolaccessType='inputOnly'/>
145                 <field name='touchChoicetype='SFInt32accessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

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

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

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

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2, Viewpoint_3
-->
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)
LineSensorAxisX
Script
set_translation
SFVec3f
then
 
 
 
LineSensorAxisX
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
GridLocation
Transform
set_translation
SFVec3f
  then
 
 
 
LineSensorAxisX
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
 
 
 
LineSensorAxisX
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
 
 
 
LineSensorAxisX
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
 
 
 
LineSensorAxisX
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
 
 
 
LineSensorAxisX
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://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridYZ_20x20MovableIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridYZ_20x20Movable.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idNamefield='value'/> matches XML terminology <XmlElement  DEF='idNameattribute='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. -->