<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<meta name='titlecontent='GridXY_20x20Movable.x3d'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='22 November 2000'/>
<meta name='modifiedcontent='30 March 2016'/>
<meta name='descriptioncontent='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.'/>
<meta name='referencecontent=' https://savage.nps.edu/Savage/Tools/Authoring/GridsExample.x3d '/>
<meta name='identifiercontent=' https://savage.nps.edu/Savage/Tools/Authoring/GridXY_20x20Movable.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../../license.html'/>
</head>
<!-- -->
<Scene>
<Viewpoint description='XY grid (0 0 30 relative)position='0 0 30'/>
<Viewpoint description='XY grid (35 0 20 relative)orientation='0 1 0 1.06position='35 0 20'/>
<!-- ROUTE information for GridLocation node:  [from LineSensorAxisZ.translation_changed to set_translation ] -->
<Transform DEF='GridLocation'>
<Group>
<!-- ROUTE information for TextLabelTouchSensor node:  [from isActive to SwitchTextOnOffScript.isTouched ] -->
<TouchSensor DEF='TextLabelTouchSensordescription='select and hold to hide grid'/>
<Transform translation='0 -0.5 0'>
<Billboard>
<Shape>
<!-- ROUTE information for CenterText node:  [from CenterTextScript.value to string ] -->
<Text DEF='CenterTextstring='"origin"'>
<FontStyle DEF='LABEL_FONTfamily='"SANS"justify='"MIDDLE" "MIDDLE"size='.4'/>
</Text>
<Appearance DEF='DefaultAppearance'>
<Material/>
</Appearance>
</Shape>
</Billboard>
</Transform>
<Transform translation='10 10.5 0'>
<Billboard>
<Shape>
<!-- ROUTE information for UpperRightText node:  [from UpperRightTextScript.value to string ] -->
<Text DEF='UpperRightTextstring='"10 10 0"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
<Transform translation='-10 10.5 0'>
<Billboard>
<Shape>
<!-- ROUTE information for UpperLeftText node:  [from UpperLeftTextScript.value to string ] -->
<Text DEF='UpperLeftTextstring='"-10 10 0"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
<Transform translation='-10 -10.5 0'>
<Billboard>
<Shape>
<!-- ROUTE information for LowerLeftText node:  [from LowerLeftTextScript.value to string ] -->
<Text DEF='LowerLeftTextstring='"-10 -10 0"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
<Transform translation='10 -10.5 0'>
<Billboard>
<Shape>
<!-- ROUTE information for LowerRightText node:  [from LowerRightTextScript.value to string ] -->
<Text DEF='LowerRightTextstring='"10 -10 0"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='DefaultAppearance'/>
</Shape>
</Billboard>
</Transform>
</Group>
<!-- ROUTE information for GridOnOffSwitch node:  [from SwitchTextOnOffScript.touchChoice to whichChoice ] -->
<Switch DEF='GridOnOffSwitchwhichChoice='0'>
<Transform rotation='1 0 0 1.57079'>
<!-- ROUTE information for GridSensor node:  [from translation_changed to LineSensorAxisZ.set_translation ] -->
<PlaneSensor DEF='GridSensordescription='click and drag to move grid'/>
<!-- ROUTE information for LineSensorAxisZ node:  [from GridSensor.translation_changed to set_translation ] [from translation_changed to GridLocation.set_translation ] [from translation_changed to CenterTextScript.set_translation ] [from translation_changed to UpperRightTextScript.set_translation ] [from translation_changed to UpperLeftTextScript.set_translation ] [from translation_changed to LowerLeftTextScript.set_translation ] [from translation_changed to LowerRightTextScript.set_translation ] -->
<Script DEF='LineSensorAxisZ'>
<field name='set_translationtype='SFVec3faccessType='inputOnly'/>
<field name='translation_changedtype='SFVec3faccessType='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.print ('location=' + location + ', translation_changed=' + translation_changed); 
}

          
]]>
</Script>
<Shape DEF='LinesAlignedAlongZ'>
<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'>
<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'/>
<Color color='0.4 0.4 0.4 0.8 0.2 0 0.4 0.1 0.05'/>
</IndexedLineSet>
</Shape>
<Transform DEF='LinesAlignedAlongXrotation='0 1 0 1.57079'>
<Shape USE='LinesAlignedAlongZ'/>
</Transform>
<Transform rotation='1 0 0 -1.57079translation='10.5 0 0'>
<Billboard>
<Shape>
<Text string='"X"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance DEF='LABEL_APPEARANCE'>
<Material diffuseColor='1 1 .3emissiveColor='.33 .33 .1'/>
</Appearance>
</Shape>
</Billboard>
</Transform>
<Transform rotation='1 0 0 -1.57079translation='0 0 -10.5'>
<Billboard>
<Shape>
<Text string='"Y"'>
<FontStyle USE='LABEL_FONT'/>
</Text>
<Appearance USE='LABEL_APPEARANCE'/>
</Shape>
</Billboard>
</Transform>
</Transform>
</Switch>
</Transform>
<!-- ROUTE information for CenterTextScript node:  [from LineSensorAxisZ.translation_changed to set_translation ] [from value to CenterText.string ] -->
<Script DEF='CenterTextScript'>
<field name='set_translationtype='SFVec3faccessType='inputOnly'/>
<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.print ('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.print ('location=' + location); 
}

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

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

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

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

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

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

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

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

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

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

    
]]>
</Script>
<ROUTE fromNode='GridSensorfromField='translation_changedtoNode='LineSensorAxisZtoField='set_translation'/>
<!-- Send changed position to text-construction scripts -->
<ROUTE fromNode='LineSensorAxisZfromField='translation_changedtoNode='GridLocationtoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisZfromField='translation_changedtoNode='CenterTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisZfromField='translation_changedtoNode='UpperRightTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisZfromField='translation_changedtoNode='UpperLeftTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisZfromField='translation_changedtoNode='LowerLeftTextScripttoField='set_translation'/>
<ROUTE fromNode='LineSensorAxisZfromField='translation_changedtoNode='LowerRightTextScripttoField='set_translation'/>
<!-- Send text showing changed position to output Text nodes -->
<ROUTE fromNode='CenterTextScriptfromField='valuetoNode='CenterTexttoField='string'/>
<ROUTE fromNode='UpperRightTextScriptfromField='valuetoNode='UpperRightTexttoField='string'/>
<ROUTE fromNode='UpperLeftTextScriptfromField='valuetoNode='UpperLeftTexttoField='string'/>
<ROUTE fromNode='LowerLeftTextScriptfromField='valuetoNode='LowerLeftTexttoField='string'/>
<ROUTE fromNode='LowerRightTextScriptfromField='valuetoNode='LowerRightTexttoField='string'/>
<!-- Enable/disable grid visibility based on user touching coordinate labels -->
<ROUTE fromNode='TextLabelTouchSensorfromField='isActivetoNode='SwitchTextOnOffScripttoField='isTouched'/>
<ROUTE fromNode='SwitchTextOnOffScriptfromField='touchChoicetoNode='GridOnOffSwitchtoField='whichChoice'/>
</Scene>
</X3D>
<!--

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 images : Viewpoint_1, Viewpoint_2
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->