<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here’s the MaterialModulatorPrototypeExpanded.x3d from my code. Please try in all browsers. I think there’s a problem with the BooleanToggle—there’s no toggle in X3DOM or Cobweb. I wll test in some browsers.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><?xml version="1.0" encoding="UTF-8"?></p><p class=MsoNormal><!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd"></p><p class=MsoNormal><X3D profile="Immersive" version="3.3" ><head><meta name="title" content="MaterialModulator.x3d"></meta></p><p class=MsoNormal><meta name="description" content="Mimic a Material node and modulate fields as an animation effect"></meta></p><p class=MsoNormal><meta name="hint" content="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></p><p class=MsoNormal><meta name="creator" content="Don Brutzman"></meta></p><p class=MsoNormal><meta name="created" content="10 March 2008"></meta></p><p class=MsoNormal><meta name="modified" content="28 November 2014"></meta></p><p class=MsoNormal><meta name="subject" content="X3D prototype requiring Script inputOutput fields"></meta></p><p class=MsoNormal><meta name="Image" content="MaterialModulator.png"></meta></p><p class=MsoNormal><meta name="identifier" content="http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14-Prototypes/MaterialModulator.x3d"></meta></p><p class=MsoNormal><meta name="generator" content="X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"></meta></p><p class=MsoNormal><meta name="license" content="../license.html"></meta></p><p class=MsoNormal></head></p><p class=MsoNormal><Scene><!--Rendered geometry for the ProtoInstance now follows prototype declaration--><Transform translation="0 1 0"><Shape><Sphere containerField="geometry"></Sphere></p><p class=MsoNormal><Appearance containerField="appearance"><Material containerField="material" DEF="DECLMaterialModulator_MaterialModulatorInstance_MaterialNode" diffuseColor="0.5 0.1 0.1" emissiveColor="0 0 0" specularColor="0 0 0" transparency="0" shininess="0.2" ambientIntensity="0.2"></Material></p><p class=MsoNormal></Appearance></p><p class=MsoNormal></Shape></p><p class=MsoNormal><Switch whichChoice="-1"><Group><!--Only first node (the node type) is renderable, others are along for the ride--><Script DEF="DECLMaterialModulator_MaterialModulatorInstance_MaterialModulatorScript"><field name="enabled" accessType="inputOutput" type="SFBool" value="true"></field></p><p class=MsoNormal><field name="diffuseColor" accessType="inputOutput" type="SFColor" value="0.5 0.1 0.1"></field></p><p class=MsoNormal><field name="newColor" accessType="outputOnly" type="SFColor"></field></p><p class=MsoNormal><field name="clockTrigger" accessType="inputOnly" type="SFTime"></field></p><p class=MsoNormal><![CDATA[ecmascript:</p><p class=MsoNormal>function initialize ()</p><p class=MsoNormal>{</p><p class=MsoNormal> newColor = diffuseColor; // start with correct color</p><p class=MsoNormal>}</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>function clockTrigger (timeValue)</p><p class=MsoNormal>{</p><p class=MsoNormal> if (!enabled) return;</p><p class=MsoNormal> red = newColor.r;</p><p class=MsoNormal> green = newColor.g;</p><p class=MsoNormal> blue = newColor.b;</p><p class=MsoNormal> </p><p class=MsoNormal> // note different modulation rates for each color component, % is modulus operator</p><p class=MsoNormal> newColor = new SFColor ((red + 0.02) % 1, (green + 0.03) % 1, (blue + 0.04) % 1);</p><p class=MsoNormal> if (enabled)</p><p class=MsoNormal> {</p><p class=MsoNormal> Browser.print ('diffuseColor=(' + red +',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\');</p><p class=MsoNormal> }</p><p class=MsoNormal>}</p><p class=MsoNormal>]]></Script></p><p class=MsoNormal><!--Clock tickles Script to wake up and compute a new value--><ROUTE fromNode="DECLMaterialModulator_MaterialModulatorInstance_MaterialModulatorScript" fromField="newColor" toNode="DECLMaterialModulator_MaterialModulatorInstance_MaterialNode" toField="diffuseColor"></ROUTE></p><p class=MsoNormal><TimeSensor DEF="DECLMaterialModulator_MaterialModulatorInstance_ModulationClock" cycleInterval="0.1" loop="true" enabled="true"></TimeSensor></p><p class=MsoNormal><ROUTE fromNode="DECLMaterialModulator_MaterialModulatorInstance_ModulationClock" fromField="cycleTime" toNode="DECLMaterialModulator_MaterialModulatorInstance_MaterialModulatorScript" toField="clockTrigger"></ROUTE></p><p class=MsoNormal></Group></p><p class=MsoNormal></Switch></p><p class=MsoNormal></Transform></p><p class=MsoNormal><!--Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip--><Transform translation="0 -2 0"><Shape><Text containerField="geometry" string=""enable/disable" "MaterialModulator""><FontStyle containerField="fontStyle" family=""SANS"" justify=""MIDDLE" "MIDDLE"" style="BOLD"></FontStyle></p><p class=MsoNormal></Text></p><p class=MsoNormal><Appearance containerField="appearance"><Material containerField="material" diffuseColor="0.9 0.9 0.9"></Material></p><p class=MsoNormal></Appearance></p><p class=MsoNormal></Shape></p><p class=MsoNormal><Shape><Box containerField="geometry" size="8 2 0.001"></Box></p><p class=MsoNormal><Appearance containerField="appearance"><Material containerField="material" transparency="1"></Material></p><p class=MsoNormal></Appearance></p><p class=MsoNormal></Shape></p><p class=MsoNormal><!--Toggle text to enable/disable MaterialModulator--><TouchSensor DEF="TouchTextInterface" description="Select to enable/disable MaterialModulator"></TouchSensor></p><p class=MsoNormal><BooleanToggle DEF="EventToggler"></BooleanToggle></p><p class=MsoNormal><ROUTE fromNode="TouchTextInterface" fromField="isActive" toNode="EventToggler" toField="set_boolean"></ROUTE></p><p class=MsoNormal><ROUTE fromNode="EventToggler" fromField="toggle" toNode="DECLMaterialModulator_MaterialModulatorInstance_MaterialModulatorScript" toField="enabled"></ROUTE></p><p class=MsoNormal></Transform></p><p class=MsoNormal></Scene></p><p class=MsoNormal></X3D></p></div></body></html>