X3D Model Documentation: TextureAngleViewer.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'>
  4       <head>
  5            <meta name='titlecontent='TextureAngleViewer.x3d'/>
  6            <meta name='descriptioncontent='View a given texture from different angles to judge readability, example use is a QR code.'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='23 April 2013'/>
  9            <meta name='modifiedcontent='20 April 2020'/>
 10            <meta name=' TODO content=' color mapper in scene for varying Background contrast '/>
 11            <meta name=' TODO content=' second X-axis angle slider '/>
 12            <meta name='Imagecontent='TextureAngleViewer36degrees.png'/>
 13            <meta name='Imagecontent='images/QrNpsEduCode.png'/>
 14            <meta name='referencecontent='http://qr.nps.edu'/>
 15            <meta name='referencecontent='https://zxing.appspot.com/generator'/>
 16            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/TextureMapping/TextureAngleViewer.x3d'/>
 17            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 18            <meta name='licensecontent='../license.html'/>
 19       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: AngleOutputText, ImageTransform, Metals13Appearance, NavigationInfoFinal, SliderBar, SliderKnob, SliderKnobTransform, SliderPlaneSensor, SliderScript, SliderSituated

Index for Viewpoint node: Viewpoint_1
-->
 20       <Scene>
 21            <!-- ================================ -->
 22            <WorldInfo title='Texture Angle Viewer'/>
 23            <Background skyColor='0.72549 1 0.721569'/>
 24            <Viewpoint description='Texture angle viewerposition='0 0 11'/>
 25            <NavigationInfo DEF='NavigationInfoFinaltype='"NONE"'/>
 26            <!-- <NavigationInfo DEF='NavigationInfoDebug' type='"EXAMINE" "ANY"'/> -->
 27            <!-- ================================ -->
 28            <Transform translation='0 3.6 0'>
 29                 <Shape>
 30 
                    <!-- ROUTE information for AngleOutputText node:  [from SliderScript.angleMFString_changed to string ] -->
                    <Text DEF='AngleOutputTextstring='"Texture angle viewer"'>
 31                           <FontStyle justify='"MIDDLE" "MIDDLE"size='0.7'/>
 32                      </Text>
 33                      <Appearance>
 34                           <Material diffuseColor='0.2 0.4 0.8'/>
 35                      </Appearance>
 36                 </Shape>
 37            </Transform>
 38            <!-- ================================ -->
 39            <Anchor description='this QR code links to http://qr.nps.edu'   url=' "http://qr.nps.edu" '>
 40 
               <!-- ROUTE information for ImageTransform node:  [from SliderScript.rotation_changed to rotation ] -->
               <Transform DEF='ImageTransform'>
 41                      <Shape>
 42                           <!-- TODO add a single geometry node here -->
 43                           <IndexedFaceSet coordIndex='1 0 2 3 0 -1'>
 44                                <Coordinate point='-3 -3 0 3 -3 0 3 3 0 -3 3 0 -3 -3 0'/>
 45                           </IndexedFaceSet>
 46                           <Appearance>
 47                                <Material/>
 48                                <ImageTexture   url=' "images/QrNpsEduCode.png " "https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/TextureMapping/images/QrNpsEduCode.png " '/>
 49                           </Appearance>
 50                      </Shape>
 51                 </Transform>
 52            </Anchor>
 53            <!-- ================================ -->
 54            <Transform DEF='SliderSituatedtranslation='0 -3.6 0'>
 55 
               <!-- ROUTE information for SliderKnobTransform node:  [from SliderScript.translation_changed to translation ] -->
               <Transform DEF='SliderKnobTransform'>
 56 
                    <!-- ROUTE information for SliderPlaneSensor node:  [from translation_changed to SliderScript.set_translation ] -->
                    <PlaneSensor DEF='SliderPlaneSensordescription='select and drag to change angle valuesmaxPosition='3 0minPosition='-3 0'/>
 57                      <Transform rotation='0 0 1 1.570796'>
 58                           <Shape>
 59                                <Cylinder DEF='SliderKnobheight='0.2radius='0.2'/>
 60 
                              <!-- Appearance Metals13Appearance is a DEF node that has 1 USE node: USE_1 -->
                              <Appearance DEF='Metals13Appearance'>
 61                                     <Material ambientIntensity='0.25641diffuseColor='0.222308 0.15428 0specularColor='0.882653 0.860832 0.687861'>
 62                                          <!-- Universal Media Library: Metals 13 -->
 63                                     </Material>
 64                                </Appearance>
 65                           </Shape>
 66                      </Transform>
 67                 </Transform>
 68                 <!-- SliderBar does not rotate or drag with SliderKnob -->
 69                 <Transform DEF='SliderBarrotation='0 0 1 1.570796'>
 70                      <Shape>
 71                           <Cylinder height='6radius='0.05'/>
 72                           <Appearance USE='Metals13Appearance'/>
 73                      </Shape>
 74                 </Transform>
 75            </Transform>
 76            <!-- ================================ -->
 77 
 78                 <field name='set_translationtype='SFVec3faccessType='inputOnly'
                appinfo='input provided by SliderKnobTransform PlaneSensor output'/>
 79                 <field name='angletype='SFFloatvalue='0.0accessType='initializeOnly'/>
 80                 <field name='ytype='SFFloatvalue='0.0accessType='initializeOnly'/>
 81                 <field name='rotation_changedtype='SFRotationaccessType='outputOnly'
                appinfo='output provided for ImageTransform rotation'/>
 82                 <!-- Note that trackPoint_changed events represent unclamped intersection points on plane surface. Browsers can interpret drags off of the surface in various ways. Note that translation_changed events are clamped by minPosition/maxPosition and thus may be preferable. -->
 83                 <field name='translation_changedtype='SFVec3faccessType='outputOnly'
                appinfo='output provided for SliderKnobTransform translation'/>
 84                 <field name='angleMFString_changedtype='MFStringaccessType='outputOnly'
                appinfo='output provided for degrees of rotation in Text node'/>
 85                 <field name='tracePrinttype='SFBoolvalue='trueaccessType='initializeOnly'
                appinfo='console output for debugging'/>
  <![CDATA[
      
ecmascript:

function set_translation (eventValue)
{
   x = eventValue.x;
   if (tracePrint)
   {
      Browser.println ("========================");
      Browser.println ('                  x=' + x);
   }
   // clamp values to prevent overrun/underrun, in case minPosition/maxPosition fail
   if (x >  3.0) x =  3.0;
   if (x < -3.0) x = -3.0;

   translation_changed = eventValue;
   angle = Math.round(x * 90.0 / 3.0);
   rotation_changed = new SFRotation (0, 1, 0, angle * Math.PI / 180.0);
   var angleString = angle.toString() + ' degrees'; // JavaScript string
   
// angleMFString_changed = new MFString (new SFString(angleString)); // only works in InstantReality
   angleMFString_changed = new MFString (angleString); // works in several players but not all
// angleMFString_changed = [ angleString ]; // Use JavaScript string array instead of MFString doesn't work
   
   if (tracePrint)
   {
      Browser.println ('          clamped x=' + x);
      Browser.println ("    set_translation=" + eventValue);
      Browser.println ("translation_changed=" + translation_changed.toString() + ", rotation_changed=" + rotation_changed.toString());
      Browser.println ("angle=" + angle + ", angleString=" + angleString + ", angleMFString_changed=" + angleMFString_changed.toString());
   }
/*
example console excerpt:
========================
                  x=-0.05248255282640457
          clamped x=-0.05248255282640457
    set_translation=-0.05248255282640457 0 0
translation_changed=-0.05248255282640457 0 0, rotation_changed=0 1 0 -0.03490658503988659
angle=-2, angleString=-2 degrees, angleMFString_changed="-2 degrees"
========================
*/
}

    
]]>
 87            </Script>
 88            < ROUTE  fromNode='SliderPlaneSensor' fromField='translation_changed' toNode='SliderScript' toField='set_translation'/>
 89            < ROUTE  fromNode='SliderScript' fromField='translation_changed' toNode='SliderKnobTransform' toField='translation'/>
 90            < ROUTE  fromNode='SliderScript' fromField='rotation_changed' toNode='ImageTransform' toField='rotation'/>
 91            < ROUTE  fromNode='SliderScript' fromField='angleMFString_changed' toNode='AngleOutputText' toField='string'/>
 92       </Scene>
 93  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: AngleOutputText, ImageTransform, Metals13Appearance, NavigationInfoFinal, SliderBar, SliderKnob, SliderKnobTransform, SliderPlaneSensor, SliderScript, SliderSituated

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Anchor, Appearance, Background, Coordinate, Cylinder, field, FontStyle, head, ImageTexture, IndexedFaceSet, Material, meta, NavigationInfo, PlaneSensor, ROUTE, Scene, Script, Shape, Text, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

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

SliderPlaneSensor
PlaneSensor
translation_changed
SFVec3f

ROUTE
event to
(1)
SliderScript
Script
set_translation
SFVec3f
then
 
 
 
SliderScript
Script
angleMFString_changed
MFString

ROUTE
event to
(2)
AngleOutputText
Text
string
MFString
  then
 
 
 
SliderScript
Script
rotation_changed
SFRotation

ROUTE
event to
(2)
ImageTransform
Transform
rotation
SFRotation
  then
 
 
 
SliderScript
Script
translation_changed
SFVec3f

ROUTE
event to
(2)
SliderKnobTransform
Transform
translation
SFVec3f


Anchor
description='this QR code links to http://qr.nps.edu' 
User-interaction hint for this node. 
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/X3dForAdvancedModeling/TextureMapping/TextureAngleViewerIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/TextureMapping/TextureAngleViewer.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)
-->

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