X3D Model Documentation: FilterExamples.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='FilterExamples.x3d'/>
  6            <meta name='description' content='Contains examples for the prototypes defined in the FilterPrototypes.x3d'/>
  7            <meta name='creator' content='Don Brutzman, James Harney, Jane Wu'/>
  8            <meta name='created' content='18 December 2001'/>
  9            <meta name='modified' content='15 October 2023'/>
 10            <meta name='reference' content='https://savage.nps.edu/Savage/Tools/Authoring/FilterPrototypes.x3d'/>
 11            <meta name='subject' content='filter'/>
 12            <meta name='identifier' content='https://savage.nps.edu/Savage/Tools/Authoring/FilterExamples.x3d'/>
 13            <meta name='generator' content='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
 14            <meta name='license' content='../../license.html'/>
 15       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: BooleanFractionRoundOff, BooleanFractionText, BooleanGenerator, FalseEventFilter, FalseLightMaterial, FalseScript, Slider, TrueEventFilter, TrueLightMaterial, TrueScript

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definitions: FilterBooleanPassFalseEvents, FilterBooleanPassTrueEvents, SingleTypeConversion, SliderFloat
-->
 16       <Scene>
 17            <WorldInfo title='FilterExamples.x3d'/>
 18            <ExternProtoDeclare name='FilterBooleanPassTrueEvents'   url=' "FilterPrototypes.x3d#FilterBooleanPassTrueEvents" "https://savage.nps.edu/Savage/Tools/Authoring/FilterPrototypes.x3d#FilterBooleanPassTrueEvents" "FilterPrototypes.wrl#FilterBooleanPassTrueEvents" "https://savage.nps.edu/Savage/Tools/Authoring/FilterPrototypes.wrl#FilterBooleanPassTrueEvents" '>
 19                 <field name='setBoolean' type='SFBool' accessType='inputOnly'/>
 20                 <field name='trueEventOut' type='SFBool' accessType='outputOnly'/>
 21                 <field name='trueEventTime' type='SFTime' accessType='outputOnly'/>
 22            </ExternProtoDeclare>
 23            <ExternProtoDeclare name='FilterBooleanPassFalseEvents'   url=' "FilterPrototypes.x3d#FilterBooleanPassFalseEvents" "https://savage.nps.edu/Savage/Tools/Authoring/FilterPrototypes.x3d#FilterBooleanPassFalseEvents" "FilterPrototypes.wrl#FilterBooleanPassFalseEvents" "https://savage.nps.edu/Savage/Tools/Authoring/FilterPrototypes.wrl#FilterBooleanPassFalseEvents" '>
 24                 <field name='setBoolean' type='SFBool' accessType='inputOnly'/>
 25                 <field name='falseEventOut' type='SFBool' accessType='outputOnly'/>
 26                 <field name='falseEventTime' type='SFTime' accessType='outputOnly'/>
 27            </ExternProtoDeclare>
 28            <ExternProtoDeclare name='SingleTypeConversion' appinfo='SingleTypeConversion converts from a single typed value to various other types of values'   url=' "SingleTypeConversionPrototype.x3d#SingleTypeConversion" "https://savage.nps.edu/Savage/Tools/Authoring/SingleTypeConversionPrototype.x3d#SingleTypeConversion" "SingleTypeConversionPrototype.wrl#SingleTypeConversion" "https://savage.nps.edu/Savage/Tools/Authoring/SingleTypeConversionPrototype.wrl#SingleTypeConversion" '>
 29                 <field name='decimalPlaces' type='SFInt32' accessType='initializeOnly'
                appinfo='decimalPlaces is the number of significant digits after the decimal point, use -1 to indicate no round off'/>
 30                 <field name='setDecimalPlaces' type='SFInt32' accessType='inputOnly'/>
 31                 <field name='BooleanValue' type='SFBool' accessType='inputOnly'/>
 32                 <field name='FloatValue' type='SFFloat' accessType='inputOnly'/>
 33                 <field name='IntegerValue' type='SFInt32' accessType='inputOnly'/>
 34                 <field name='TimeValue' type='SFTime' accessType='inputOnly'/>
 35                 <field name='BooleanResult' type='SFBool' accessType='outputOnly'/>
 36                 <field name='FloatResult' type='SFFloat' accessType='outputOnly'/>
 37                 <field name='IntegerResult' type='SFInt32' accessType='outputOnly'/>
 38                 <field name='TimeResult' type='SFTime' accessType='outputOnly'/>
 39                 <field name='StringResult' type='SFString' accessType='outputOnly'/>
 40                 <field name='StringsResult' type='MFString' accessType='outputOnly'/>
 41            </ExternProtoDeclare>
 42            <ExternProtoDeclare name='SliderFloat' appinfo='Slider user-interface widget that produces floating-point output values'   url=' "../../../Savage/Tools/Animation/SliderFloatPrototype.x3d#SliderFloat" "https://savage.nps.edu/Savage/Tools/Animation/SliderFloatPrototype.x3d#SliderFloat" "../../../Savage/Tools/Animation/SliderFloatPrototype.wrl#SliderFloat" "https://savage.nps.edu/Savage/Tools/Animation/SliderFloatPrototype.wrl#SliderFloat" '>
 43                 <field name='layoutDirection' type='SFString' accessType='initializeOnly'
                appinfo='Allowed values: vertical, horizontal'/>
 44                 <field name='height' type='SFFloat' accessType='initializeOnly'
                appinfo='default value 1.0'/>
 45                 <field name='radius' type='SFFloat' accessType='initializeOnly'
                appinfo='default value 0.1'/>
 46                 <field name='barRadius' type='SFFloat' accessType='initializeOnly'
                appinfo='default value 0.02'/>
 47                 <field name='sliderBarColor' type='SFColor' accessType='initializeOnly'
                appinfo='default value .8 .4 .8'/>
 48                 <field name='sliderBallColor' type='SFColor' accessType='initializeOnly'
                appinfo='default value .3 .4 .8'/>
 49                 <field name='sliderEndColor' type='SFColor' accessType='initializeOnly'
                appinfo='default value .2 .3 .9'/>
 50                 <field name='min' type='SFFloat' accessType='initializeOnly'
                appinfo='default value 0.0'/>
 51                 <field name='max' type='SFFloat' accessType='initializeOnly'
                appinfo='default value 10.0'/>
 52                 <field name='value' type='SFFloat' accessType='initializeOnly'
                appinfo='default value 0.0'/>
 53                 <field name='setMin' type='SFFloat' accessType='inputOnly'
                appinfo='set minimum value for slider bar'/>
 54                 <field name='setMax' type='SFFloat' accessType='inputOnly'
                appinfo='set maximum value for slider bar'/>
 55                 <field name='setValue' type='SFFloat' accessType='inputOnly'
                appinfo='set value for slider bar'/>
 56                 <field name='valueChanged' type='SFFloat' accessType='outputOnly'
                appinfo='output value for slider bar'/>
 57                 <field name='traceEnabled' type='SFBool' accessType='initializeOnly'
                appinfo='enable/disable console output for troubleshooting'/>
 58            </ExternProtoDeclare>
 59            <Viewpoint description='Filter Examples' position='0 0 15'/>
 60            <Billboard axisOfRotation='0 0 0'>
 61                 <Transform translation='0 4 0'>
 62                      <Shape>
 63                           <Appearance>
 64                                <Material diffuseColor='0 1 1'/>
 65                           </Appearance>
 66                           <Text string='"FilterBooleanPassTrueEvents" "FilterBooleanPassFalseEvents:" "" "drag slider to test examples"'>
 67                                <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.8'/>
 68                           </Text>
 69                      </Shape>
 70                 </Transform>
 71                 <Transform translation='0 1 0'>
 72                      <Shape>
 73                           <Appearance>
 74                                <Material/>
 75                           </Appearance>
 76                           <Text string='"BooleanSequencer:" "key {0 0.25 0.5 0.75 1} keyValue {0 1 0 1 0}"'>
 77                                <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.6'/>
 78                           </Text>
 79                      </Shape>
 80 
                    <!-- ROUTE information for BooleanGenerator node:  [from Slider.valueChanged to set_fraction ] [from value_changed to TrueEventFilter.setBoolean ] [from value_changed to FalseEventFilter.setBoolean ] -->
                    <BooleanSequencer DEF='BooleanGenerator' key='0 0.25 0.5 0.75 1' keyValue='false true false true false'/>
 81                 </Transform>
 82                 <Transform translation='-4 -1 0'>
 83                      <Shape>
 84                           <Appearance>
 85                                <Material/>
 86                           </Appearance>
 87                           <Text string='"Fraction:"'>
 88                                <FontStyle size='0.6'/>
 89                           </Text>
 90                      </Shape>
 91                      <Transform translation='3 0 0'>
 92                           <Shape>
 93                                <Appearance>
 94                                     <Material/>
 95                                </Appearance>
 96 
                              <!-- ROUTE information for BooleanFractionText node:  [from BooleanFractionRoundOff.StringsResult to set_string ] -->
                              <Text DEF='BooleanFractionText' string=' "N/A" '>
 97                                     <FontStyle size='0.6'/>
 98                                </Text>
 99                           </Shape>
100                      </Transform>
101                      <Transform translation='6 0.15 0'>
102 
                         <!-- ROUTE information for Slider node:  [from valueChanged to BooleanGenerator.set_fraction ] [from valueChanged to BooleanFractionRoundOff.FloatValue ] -->
                         <ProtoInstance name='SliderFloat' DEF='Slider'>
103                                <fieldValue name='layoutDirection' value='horizontal'/>
104                                <fieldValue name='min' value='0'/>
105                                <fieldValue name='max' value='1'/>
106                                <fieldValue name='height' value='4'/>
107                           </ProtoInstance>
108                           < ROUTE  fromNode='Slider' fromField='valueChanged' toNode='BooleanGenerator' toField='set_fraction'/>
109                      </Transform>
110 
                    <!-- ROUTE information for BooleanFractionRoundOff node:  [from Slider.valueChanged to FloatValue ] [from StringsResult to BooleanFractionText.set_string ] -->
                    <ProtoInstance name='SingleTypeConversion' DEF='BooleanFractionRoundOff'>
111                           <fieldValue name='decimalPlaces' value='2'/>
112                      </ProtoInstance>
113                      < ROUTE  fromNode='Slider' fromField='valueChanged' toNode='BooleanFractionRoundOff' toField='FloatValue'/>
114                      < ROUTE  fromNode='BooleanFractionRoundOff' fromField='StringsResult' toNode='BooleanFractionText' toField='set_string'/>
115                 </Transform>
116                 <Transform translation='-5 -3 0'>
117                      <Shape>
118                           <Appearance>
119                                <Material/>
120                           </Appearance>
121                           <Text string='"PassTrueEvents:"'>
122                                <FontStyle size='0.6'/>
123                           </Text>
124                      </Shape>
125                      <Transform translation='3.85 0.15 0'>
126                           <Shape>
127                                <Appearance>
128 
                                   <!-- ROUTE information for TrueLightMaterial node:  [from TrueScript.colorChanged to diffuseColor ] [from TrueScript.colorChanged to emissiveColor ] -->
                                   <Material DEF='TrueLightMaterial' diffuseColor='0.45 0.45 0.45' emissiveColor='0.45 0.45 0.45'/>
129                                </Appearance>
130                                <Sphere radius='0.2'/>
131                           </Shape>
132 
                         <!-- ROUTE information for TrueScript node:  [from TrueEventFilter.trueEventOut to setTrue ] [from colorChanged to TrueLightMaterial.diffuseColor ] [from colorChanged to TrueLightMaterial.emissiveColor ] -->
                         <Script DEF='TrueScript'>
133                                <field name='setTrue' type='SFBool' accessType='inputOnly'/>
134                                <field name='colorChanged' type='SFColor' accessType='outputOnly'/>
  <![CDATA[
            
ecmascript:

var r, g, b;
function initialize()
{
	r = 0;
	g = 0;
	b = 0;
}

function setTrue(value, timeStamp)
{
	if ( r >= 0.5)
		r = 0.25;
	else
		r = r + 0.25;

	if ( b >= 0.5)
		b = 0.25;
	else
		b = b + 0.25;

	colorChanged = new SFColor(r, g, b);
}

          
]]>
136                           </Script>
137 
                         <!-- ROUTE information for TrueEventFilter node:  [from BooleanGenerator.value_changed to setBoolean ] [from trueEventOut to TrueScript.setTrue ] -->
                         <ProtoInstance name='FilterBooleanPassTrueEvents' DEF='TrueEventFilter'/>
138                           < ROUTE  fromNode='BooleanGenerator' fromField='value_changed' toNode='TrueEventFilter' toField='setBoolean'/>
139                           < ROUTE  fromNode='TrueEventFilter' fromField='trueEventOut' toNode='TrueScript' toField='setTrue'/>
140                           < ROUTE  fromNode='TrueScript' fromField='colorChanged' toNode='TrueLightMaterial' toField='diffuseColor'/>
141                           < ROUTE  fromNode='TrueScript' fromField='colorChanged' toNode='TrueLightMaterial' toField='emissiveColor'/>
142                      </Transform>
143                 </Transform>
144                 <Transform translation='0 -3 0'>
145                      <Shape>
146                           <Appearance>
147                                <Material/>
148                           </Appearance>
149                           <Text string='"PassFalseEvents:"'>
150                                <FontStyle size='0.6'/>
151                           </Text>
152                      </Shape>
153                      <Transform translation='4 0.15 0'>
154                           <Shape>
155                                <Appearance>
156 
                                   <!-- ROUTE information for FalseLightMaterial node:  [from FalseScript.colorChanged to diffuseColor ] [from FalseScript.colorChanged to emissiveColor ] -->
                                   <Material DEF='FalseLightMaterial' diffuseColor='0.45 0.45 0.45' emissiveColor='0.45 0.45 0.45'/>
157                                </Appearance>
158                                <Sphere radius='0.2'/>
159                           </Shape>
160 
                         <!-- ROUTE information for FalseScript node:  [from FalseEventFilter.falseEventOut to setFalse ] [from colorChanged to FalseLightMaterial.diffuseColor ] [from colorChanged to FalseLightMaterial.emissiveColor ] -->
                         <Script DEF='FalseScript'>
161                                <field name='setFalse' type='SFBool' accessType='inputOnly'/>
162                                <field name='colorChanged' type='SFColor' accessType='outputOnly'/>
  <![CDATA[
            
ecmascript:

var r, g, b;
function initialize()
{
	r = 0;
	g = 0;
	b = 0;
}

function setFalse(value, timeStamp)
{
	if ( g >= 0.5)
		g = 0.25;
	else
		g = r + 0.25;

	if ( b >= 0.5)
		b = 0.25;
	else
		b = b + 0.25;

	colorChanged = new SFColor(r, g, b);
}

          
]]>
164                           </Script>
165 
                         <!-- ROUTE information for FalseEventFilter node:  [from BooleanGenerator.value_changed to setBoolean ] [from falseEventOut to FalseScript.setFalse ] -->
                         <ProtoInstance name='FilterBooleanPassFalseEvents' DEF='FalseEventFilter'/>
166                           < ROUTE  fromNode='BooleanGenerator' fromField='value_changed' toNode='FalseEventFilter' toField='setBoolean'/>
167                           < ROUTE  fromNode='FalseEventFilter' fromField='falseEventOut' toNode='FalseScript' toField='setFalse'/>
168                           < ROUTE  fromNode='FalseScript' fromField='colorChanged' toNode='FalseLightMaterial' toField='diffuseColor'/>
169                           < ROUTE  fromNode='FalseScript' fromField='colorChanged' toNode='FalseLightMaterial' toField='emissiveColor'/>
170                      </Transform>
171                 </Transform>
172            </Billboard>
173       </Scene>
174  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: BooleanFractionRoundOff, BooleanFractionText, BooleanGenerator, FalseEventFilter, FalseLightMaterial, FalseScript, Slider, TrueEventFilter, TrueLightMaterial, TrueScript

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definitions: FilterBooleanPassFalseEvents, FilterBooleanPassTrueEvents, SingleTypeConversion, SliderFloat
-->
X3D Tooltips element index: Appearance, Billboard, BooleanSequencer, ExternProtoDeclare, field, fieldValue, FontStyle, head, Material, meta, ProtoInstance, ROUTE, Scene, Script, Shape, Sphere, Text, Transform, Viewpoint, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

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

      FalseScript
Script
colorChanged
SFColor
→
ROUTE
event to
(1)
FalseLightMaterial
Material
diffuseColor
SFColor
FalseScript
Script
colorChanged
SFColor
→
ROUTE
event to
(1)
FalseLightMaterial
Material
emissiveColor
SFColor

      TrueScript
Script
colorChanged
SFColor
→
ROUTE
event to
(1)
TrueLightMaterial
Material
diffuseColor
SFColor
TrueScript
Script
colorChanged
SFColor
→
ROUTE
event to
(1)
TrueLightMaterial
Material
emissiveColor
SFColor

      BooleanFractionRoundOff
ProtoInstance
StringsResult
MFString
→
ROUTE
event to
(1)
BooleanFractionText
Text
set_string
MFString

      FalseEventFilter
ProtoInstance
falseEventOut
SFBool
→
ROUTE
event to
(1)
FalseScript
Script
setFalse
SFBool
then
 
 
 
FalseScript
Script
colorChanged
SFColor
→
ROUTE
event to
(2)
FalseLightMaterial
Material
diffuseColor
SFColor
  then
 
 
 
FalseScript
Script
colorChanged
SFColor
→
ROUTE
event to
(2)
FalseLightMaterial
Material
emissiveColor
SFColor

Slider
ProtoInstance
valueChanged
SFFloat
→
ROUTE
event to
(1)
BooleanGenerator
BooleanSequencer
set_fraction
SFFloat
then
 
 
 
BooleanGenerator
BooleanSequencer
value_changed
SFBool
→
ROUTE
event to
(2)
TrueEventFilter
ProtoInstance
setBoolean
SFBool
then
 
 
 
TrueEventFilter
ProtoInstance
trueEventOut
SFBool
→
ROUTE
event to
(3)
TrueScript
Script
setTrue
SFBool
then
 
 
 
TrueScript
Script
colorChanged
SFColor
→
ROUTE
event to
(4)
TrueLightMaterial
Material
diffuseColor
SFColor
  then
 
 
 
TrueScript
Script
colorChanged
SFColor
→
ROUTE
event to
(4)
TrueLightMaterial
Material
emissiveColor
SFColor
  then
 
 
 
BooleanGenerator
BooleanSequencer
value_changed
SFBool
→
ROUTE
event to
(2)
FalseEventFilter
ProtoInstance
setBoolean
SFBool
then
 
 
 
FalseEventFilter
ProtoInstance
falseEventOut
SFBool
→
ROUTE
event to
(3)
FalseScript
Script
setFalse
SFBool
then
 
 
 
FalseScript
Script
colorChanged
SFColor
→
ROUTE
event to
(4)
FalseLightMaterial
Material
diffuseColor
SFColor
  then
 
 
 
FalseScript
Script
colorChanged
SFColor
→
ROUTE
event to
(4)
FalseLightMaterial
Material
emissiveColor
SFColor
Slider
ProtoInstance
valueChanged
SFFloat
→
ROUTE
event to
(1)
BooleanFractionRoundOff
ProtoInstance
FloatValue
SFFloat
then
 
 
 
BooleanFractionRoundOff
ProtoInstance
StringsResult
MFString
→
ROUTE
event to
(2)
BooleanFractionText
Text
set_string
MFString

      TrueEventFilter
ProtoInstance
trueEventOut
SFBool
→
ROUTE
event to
(1)
TrueScript
Script
setTrue
SFBool
then
 
 
 
TrueScript
Script
colorChanged
SFColor
→
ROUTE
event to
(2)
TrueLightMaterial
Material
diffuseColor
SFColor
  then
 
 
 
TrueScript
Script
colorChanged
SFColor
→
ROUTE
event to
(2)
TrueLightMaterial
Material
emissiveColor
SFColor

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/FilterExamplesIndex.html -->
<!-- Version control at
https://gitlab.nps.edu/Savage/Savage/Tools/Authoring/FilterExamples.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)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

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