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='titlecontent=' FilterExamples.x3d '/>
  6            <meta name='descriptioncontent=' Contains examples for the prototypes defined in the FilterPrototypes.x3d '/>
  7            <meta name='creatorcontent='Don Brutzman, James Harney, Jane Wu'/>
  8            <meta name='createdcontent='18 December 2001'/>
  9            <meta name='modifiedcontent='15 October 2023'/>
 10            <meta name='referencecontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterPrototypes.x3d '/>
 11            <meta name='subjectcontent='filter'/>
 12            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterExamples.x3d '/>
 13            <meta name='generatorcontent='X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 14            <meta name='licensecontent='../../license.html'/>
 15       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: 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://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterPrototypes.x3d#FilterBooleanPassTrueEvents" "FilterPrototypes.wrl#FilterBooleanPassTrueEvents" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterPrototypes.wrl#FilterBooleanPassTrueEvents" '>
 19                 <field name='setBooleantype='SFBoolaccessType='inputOnly'/>
 20                 <field name='trueEventOuttype='SFBoolaccessType='outputOnly'/>
 21                 <field name='trueEventTimetype='SFTimeaccessType='outputOnly'/>
 22            </ExternProtoDeclare>
 23            <ExternProtoDeclare name='FilterBooleanPassFalseEvents'   url=' "FilterPrototypes.x3d#FilterBooleanPassFalseEvents" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterPrototypes.x3d#FilterBooleanPassFalseEvents" "FilterPrototypes.wrl#FilterBooleanPassFalseEvents" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterPrototypes.wrl#FilterBooleanPassFalseEvents" '>
 24                 <field name='setBooleantype='SFBoolaccessType='inputOnly'/>
 25                 <field name='falseEventOuttype='SFBoolaccessType='outputOnly'/>
 26                 <field name='falseEventTimetype='SFTimeaccessType='outputOnly'/>
 27            </ExternProtoDeclare>
 28            <ExternProtoDeclare name='SingleTypeConversionappinfo='SingleTypeConversion converts from a single typed value to various other types of values'   url=' "SingleTypeConversionPrototype.x3d#SingleTypeConversion" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/SingleTypeConversionPrototype.x3d#SingleTypeConversion" "SingleTypeConversionPrototype.wrl#SingleTypeConversion" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/SingleTypeConversionPrototype.wrl#SingleTypeConversion" '>
 29                 <field name='decimalPlacestype='SFInt32accessType='initializeOnly'
                appinfo='decimalPlaces is the number of significant digits after the decimal point, use -1 to indicate no round off'/>
 30                 <field name='setDecimalPlacestype='SFInt32accessType='inputOnly'/>
 31                 <field name='BooleanValuetype='SFBoolaccessType='inputOnly'/>
 32                 <field name='FloatValuetype='SFFloataccessType='inputOnly'/>
 33                 <field name='IntegerValuetype='SFInt32accessType='inputOnly'/>
 34                 <field name='TimeValuetype='SFTimeaccessType='inputOnly'/>
 35                 <field name='BooleanResulttype='SFBoolaccessType='outputOnly'/>
 36                 <field name='FloatResulttype='SFFloataccessType='outputOnly'/>
 37                 <field name='IntegerResulttype='SFInt32accessType='outputOnly'/>
 38                 <field name='TimeResulttype='SFTimeaccessType='outputOnly'/>
 39                 <field name='StringResulttype='SFStringaccessType='outputOnly'/>
 40                 <field name='StringsResulttype='MFStringaccessType='outputOnly'/>
 41            </ExternProtoDeclare>
 42            <ExternProtoDeclare name='SliderFloatappinfo='Slider user-interface widget that produces floating-point output values'   url=' "../../../Savage/Tools/Animation/SliderFloatPrototype.x3d#SliderFloat" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/SliderFloatPrototype.x3d#SliderFloat" "../../../Savage/Tools/Animation/SliderFloatPrototype.wrl#SliderFloat" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/SliderFloatPrototype.wrl#SliderFloat" '>
 43                 <field name='layoutDirectiontype='SFStringaccessType='initializeOnly'
                appinfo='Allowed values: vertical, horizontal'/>
 44                 <field name='heighttype='SFFloataccessType='initializeOnly'
                appinfo='default value 1.0'/>
 45                 <field name='radiustype='SFFloataccessType='initializeOnly'
                appinfo='default value 0.1'/>
 46                 <field name='barRadiustype='SFFloataccessType='initializeOnly'
                appinfo='default value 0.02'/>
 47                 <field name='sliderBarColortype='SFColoraccessType='initializeOnly'
                appinfo='default value .8 .4 .8'/>
 48                 <field name='sliderBallColortype='SFColoraccessType='initializeOnly'
                appinfo='default value .3 .4 .8'/>
 49                 <field name='sliderEndColortype='SFColoraccessType='initializeOnly'
                appinfo='default value .2 .3 .9'/>
 50                 <field name='mintype='SFFloataccessType='initializeOnly'
                appinfo='default value 0.0'/>
 51                 <field name='maxtype='SFFloataccessType='initializeOnly'
                appinfo='default value 10.0'/>
 52                 <field name='valuetype='SFFloataccessType='initializeOnly'
                appinfo='default value 0.0'/>
 53                 <field name='setMintype='SFFloataccessType='inputOnly'
                appinfo='set minimum value for slider bar'/>
 54                 <field name='setMaxtype='SFFloataccessType='inputOnly'
                appinfo='set maximum value for slider bar'/>
 55                 <field name='setValuetype='SFFloataccessType='inputOnly'
                appinfo='set value for slider bar'/>
 56                 <field name='valueChangedtype='SFFloataccessType='outputOnly'
                appinfo='output value for slider bar'/>
 57                 <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                appinfo='enable/disable console output for troubleshooting'/>
 58            </ExternProtoDeclare>
 59            <Viewpoint description='Filter Examplesposition='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='BooleanGeneratorkey='0 0.25 0.5 0.75 1keyValue='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='BooleanFractionTextstring=' "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='SliderFloatDEF='Slider'>
103                                <fieldValue name='layoutDirectionvalue='horizontal'/>
104                                <fieldValue name='minvalue='0'/>
105                                <fieldValue name='maxvalue='1'/>
106                                <fieldValue name='heightvalue='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='SingleTypeConversionDEF='BooleanFractionRoundOff'>
111                           <fieldValue name='decimalPlacesvalue='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='TrueLightMaterialdiffuseColor='0.45 0.45 0.45emissiveColor='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='setTruetype='SFBoolaccessType='inputOnly'/>
134                                <field name='colorChangedtype='SFColoraccessType='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='FilterBooleanPassTrueEventsDEF='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='FalseLightMaterialdiffuseColor='0.45 0.45 0.45emissiveColor='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='setFalsetype='SFBoolaccessType='inputOnly'/>
162                                <field name='colorChangedtype='SFColoraccessType='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='FilterBooleanPassFalseEventsDEF='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 DEF nodes index: 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://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterExamplesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/FilterExamples.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)
    <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. -->