<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<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 ' >
<head>
<meta name='titlecontent=' MaterialModulatorExamples.x3d '/>
<meta name='descriptioncontent='Demonstrate multiple instances of an external prototype.'/>
<meta name='hintcontent='Learning suggestion for authors: try changing the modulation script so that it goes from [0 ... 1] and then [1 ... 0] alternating, rather than abruptly shifting from 1 immediately back to 0.'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='7 September 2017'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='subjectcontent='X3D prototype instances DEF USE'/>
<meta name='Imagecontent='MaterialModulator.png' />
<meta name='Imagecontent='MaterialModulatorExamples.png' />
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamples.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: EventToggler, MaterialModulatorInstance, ModulatingBoxShape, TextAppearance, TouchTextInterface Index for ExternProtoDeclare definition: MaterialModulator
-->
<Scene>
<WorldInfo title='MaterialModulatorExamples.x3d'/>
<ExternProtoDeclare name='MaterialModulatorappinfo='mimic a Material node and modulate the diffuseColor field as an animation effect'  documentation=' https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html '
  url=' "MaterialModulator.x3d#MaterialModulator" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulator.x3d#MaterialModulator" ' >
<field name='enabledtype='SFBoolaccessType='inputOutput'
 appinfo='default value true' />

<field name='diffuseColortype='SFColoraccessType='inputOutput'
 appinfo='default value 0.8 0.8 0.8' />

<field name='emissiveColortype='SFColoraccessType='inputOutput'
 appinfo='default value 0 0 0' />

<field name='specularColortype='SFColoraccessType='inputOutput'
 appinfo='default value 0 0 0' />

<field name='transparencytype='SFFloataccessType='inputOutput'
 appinfo='default value 0.0' />

<field name='shininesstype='SFFloataccessType='inputOutput'
 appinfo='default value 0.2' />

<field name='ambientIntensitytype='SFFloataccessType='inputOutput'
 appinfo='default value 0.2' />
</ExternProtoDeclare>
<!-- Rendered geometry for the ProtoInstance now follows external prototype declaration -->
<Transform rotation='-0.8 0.93923 0.18785 5.759586translation='-2 1 0'>
<Shape DEF='ModulatingBoxShape'>
<Box/>
<Appearance>
<!-- ROUTE information for MaterialModulatorInstance node:  [from EventToggler.toggle to enabled ] -->
<ProtoInstance name='MaterialModulatorDEF='MaterialModulatorInstancecontainerField='material'>
<fieldValue name='enabledvalue='true'/>
<fieldValue name='diffuseColorvalue='0.5 0.1 0.1'/>
<!-- fieldValue declarations for other Material attributes can appear here -->
</ProtoInstance>
</Appearance>
</Shape>
</Transform>
<Transform rotation='1 0 0 0.523599translation='2 1 0'>
<Shape>
<Cylinder/>
<Appearance>
<!-- note that ProtoInstance USE does not require name='MaterialModulator' -->
<ProtoInstance USE=' MaterialModulatorInstancecontainerField='material'/>
</Appearance>
</Shape>
</Transform>
<Transform translation='-2 3.5 0'>
<Shape>
<Text string='"DEF original"'>
<FontStyle family='"SANS"justify='"MIDDLE" "MIDDLE"size='0.5style='BOLD'/>
</Text>
<Appearance DEF='TextAppearance'>
<Material diffuseColor='0.9 0.9 0.9'/>
</Appearance>
</Shape>
</Transform>
<Transform translation='2 3.5 0'>
<Shape>
<Text string='"USE copy"'>
<FontStyle family='"SANS"justify='"MIDDLE" "MIDDLE"size='0.5style='BOLD'/>
</Text>
<Appearance USE=' TextAppearance'/>
</Shape>
</Transform>
<Transform translation='0 -2 0'>
<Shape>
<Text string=' "enable/disable"
"MaterialModulator"
'>
<FontStyle family='"SANS"justify='"MIDDLE" "MIDDLE"style='BOLD'/>
</Text>
<Appearance USE=' TextAppearance'/>
</Shape>
<!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip -->
<Shape>
<Box size='8 2 .001'/>
<Appearance>
<Material transparency='1'/>
</Appearance>
</Shape>
<!-- Toggle text to enable/disable MaterialModulator -->
<!-- ROUTE information for TouchTextInterface node:  [from isActive to EventToggler.set_boolean ] -->
<TouchSensor DEF='TouchTextInterfacedescription='Select text to enable/disable MaterialModulator'/>

<!-- ROUTE information for EventToggler node:  [from TouchTextInterface.isActive to set_boolean ] [from toggle to MaterialModulatorInstance.enabled ] -->
<BooleanToggle DEF='EventTogglercontainerField='children'/>

< ROUTE  fromNode=' TouchTextInterface' fromField='isActive' toNode=' EventToggler' toField='set_boolean'/>
< ROUTE  fromNode=' EventToggler' fromField='toggle' toNode=' MaterialModulatorInstance' toField='enabled'/>
</Transform>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: EventToggler, MaterialModulatorInstance, ModulatingBoxShape, TextAppearance, TouchTextInterface Index for ExternProtoDeclare definition: MaterialModulator
-->

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

TouchTextInterface
TouchSensor
isActive
SFBool

ROUTE
event to
(1)
EventToggler
BooleanToggle
set_boolean
SFBool

 
 
then
EventToggler
BooleanToggle
toggle
SFBool

ROUTE
event to
(2)
MaterialModulatorInstance
ProtoInstance
enabled
SFBool


      MaterialModulatorInstance
ProtoInstance
MaterialModulator
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamplesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamples.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)
    <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. -->