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='title' content='MaterialModulatorPrototypeExpanded.x3d'/> |
6 | <meta name='description' content='Provide example for expansion of a MaterialModulator as regular X3D nodes, rather than a ProtoDeclare/ProtoInstance combination. MaterialModulator mimics a Material node and modulates diffuseColor field as an animation effect.'/> |
7 | <meta name='creator' content='Don Brutzman, John Carlson, Roy Walmsley'/> |
8 | <meta name='created' content='2 July 2016'/> |
9 | <meta name='modified' content='20 October 2019'/> |
10 | <meta name='subject' content='X3D prototype expander, IS/connect, Script inputOutput field'/> |
11 | <meta name='Image' content='MaterialModulator.png'/> |
12 | <meta name='reference' content='MaterialModulator.x3d'/> |
13 | <meta name='reference' content='JSON prototype expander https://github.com/coderextreme/X3DJSONLD'/> |
14 | <meta name=' TODO ' content=' Create corresponding web page describing Prototype Expander design. '/> |
15 | <meta name=' TODO ' content=' Create stylesheet converter matching this Prototype Expander design pattern. '/> |
16 | <meta name=' TODO ' content=' Add external ROUTEs to original example as a further test case for Prototype Expander design. '/> |
17 | <meta name='reference' content='https://github.com/coderextreme/X3DJSONLD/blob/master/PrototypeExpander.js'/> |
18 | <meta name='reference' content='https://github.com/coderextreme/X3DJSONLD/blob/master/ServerPrototypeExpander.js'/> |
19 | <meta name='reference' content='X3D Tooltips: ProtoBody https://www.web3d.org/x3d/content/X3dTooltips.html#ProtoBody'/> |
20 | <meta name='reference' content='4.4.4.3 PROTO definition semantics https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/concepts.html#PROTOdefinitionsemantics'/> |
21 | <meta name='reference' content='[x3d-public] Prototype Expander, Question on design of instance expansions: http://web3d.org/pipermail/x3d-public_web3d.org/2016-July/004982.html'/> |
22 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorPrototypeExpanded.x3d'/> |
23 | <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/> |
24 | <meta name='license' content='../license.html'/> |
25 | </head> |
26 | <Scene> |
27 | <WorldInfo title='MaterialModulatorPrototypeExpanded.x3d'/> |
28 | <Shape> |
29 | <Sphere/> |
30 | <Appearance> |
31 | <!-- Prototype Expander design note: only first node (the node type) of the prototype is substituted here. --> |
32 |
<!-- ROUTE information for MaterialModulatorNodeExpanded1 node:
[from MaterialModulatorScriptExpanded1.newColor to diffuseColor
]
-->
<Material DEF='MaterialModulatorNodeExpanded1' diffuseColor='0.5 0.1 0.1'> |
33 | <!-- Prototype Expander design note: no children nodes found in originally defined initial ProtoBody node, so no contained child nodes appear here --> |
34 | </Material> |
35 | </Appearance> |
36 | </Shape> |
37 | <!-- Prototype Expander design note: only first node (the node type) of the prototype is renderable above. when Switch is first allowed --> |
38 | <Switch DEF='HideAdditionalPrototypeBodyNodesExpanded1' whichChoice='-1'> |
39 | <!-- Prototype Expander design note: all children inside a Switch continue to receive/send events. --> |
40 | <Group> |
41 | <!-- Prototype Expander design note: additional follow-on nodes from the original ProtoBody are placed here. --> |
42 |
<!-- ROUTE information for MaterialModulatorScriptExpanded1 node:
[from ModulationClockExpanded1.cycleTime to clockTrigger
]
[from newColor to MaterialModulatorNodeExpanded1.diffuseColor
]
-->
<Script DEF='MaterialModulatorScriptExpanded1'> |
43 | <field name='enabled' type='SFBool' value='true' accessType='inputOutput'/> |
44 | <field name='diffuseColor' type='SFColor' value='0.5 0.1 0.1' accessType='inputOutput'/> |
45 | <field name='newColor' type='SFColor' accessType='outputOnly'/> |
46 | <field name='clockTrigger' type='SFTime' accessType='inputOnly'/> |
<![CDATA[
ecmascript: function initialize () { newColor = diffuseColor; // start with correct color } function clockTrigger (timeValue) { if (!enabled) return; red = newColor.r; green = newColor.g; blue = newColor.b; // note different modulation rates for each color component, % is modulus operator newColor = new SFColor ((red + 0.02) % 1, (green + 0.03) % 1, (blue + 0.04) % 1); Browser.println ('diffuseColor=(' + red +',' + green + ',' + blue + ') newColor=' + newColor.toString()); }
]]>
|
|
48 | </Script> |
49 | <!-- Clock tickles Script to wake up and compute a new value --> |
50 | < ROUTE fromNode='MaterialModulatorScriptExpanded1' fromField='newColor' toNode='MaterialModulatorNodeExpanded1' toField='diffuseColor'/> |
51 |
<!-- ROUTE information for ModulationClockExpanded1 node:
[from cycleTime to MaterialModulatorScriptExpanded1.clockTrigger
]
-->
<TimeSensor DEF='ModulationClockExpanded1' cycleInterval='0.1' loop='true'/> |
52 | < ROUTE fromNode='ModulationClockExpanded1' fromField='cycleTime' toNode='MaterialModulatorScriptExpanded1' toField='clockTrigger'/> |
53 | </Group> |
54 | </Switch> |
55 | </Scene> |
56 | </X3D> |
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.
MaterialModulatorScriptExpanded1
Script newColor SFColor |
MaterialModulatorNodeExpanded1
Material diffuseColor SFColor |
<!--
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)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->