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='MaterialModulatorExamples.x3d'/> |
6 | <meta name='description' content='Demonstrate multiple instances of an external prototype.'/> |
7 | <meta name='hint' content='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.'/> |
8 | <meta name='creator' content='Don Brutzman'/> |
9 | <meta name='created' content='7 September 2017'/> |
10 | <meta name='modified' content='2 January 2025'/> |
11 | <meta name='subject' content='X3D prototype instances DEF USE'/> |
12 |
<meta name='Image' content='MaterialModulator.png'![]() |
13 |
<meta name='Image' content='MaterialModulatorExamples.png'![]() |
14 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamples.x3d'/> |
15 | <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/> |
16 | <meta name='license' content='../license.html'/> |
17 | </head> |
18 | <Scene> |
19 | <WorldInfo title='MaterialModulatorExamples.x3d'/> |
20 | <ExternProtoDeclare name='MaterialModulator' appinfo='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" '> |
21 |
<field name='enabled' type='SFBool' accessType='inputOutput'
appinfo='default value true'/> |
22 |
<field name='diffuseColor' type='SFColor' accessType='inputOutput'
appinfo='default value 0.8 0.8 0.8'/> |
23 |
<field name='emissiveColor' type='SFColor' accessType='inputOutput'
appinfo='default value 0 0 0'/> |
24 |
<field name='specularColor' type='SFColor' accessType='inputOutput'
appinfo='default value 0 0 0'/> |
25 |
<field name='transparency' type='SFFloat' accessType='inputOutput'
appinfo='default value 0.0'/> |
26 |
<field name='shininess' type='SFFloat' accessType='inputOutput'
appinfo='default value 0.2'/> |
27 |
<field name='ambientIntensity' type='SFFloat' accessType='inputOutput'
appinfo='default value 0.2'/> |
28 | </ExternProtoDeclare> |
29 | <!-- Rendered geometry for the ProtoInstance now follows external prototype declaration --> |
30 | <Transform rotation='-0.8 0.93923 0.18785 5.759586' translation='-2 1 0'> |
31 | <Shape DEF='ModulatingBoxShape'> |
32 | <Box/> |
33 | <Appearance> |
34 |
<!-- ProtoInstance
MaterialModulatorInstance is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for MaterialModulatorInstance node: [from EventToggler.toggle to enabled ] --> <ProtoInstance name='MaterialModulator' DEF='MaterialModulatorInstance' containerField='material'> |
35 | <fieldValue name='enabled' value='true'/> |
36 | <fieldValue name='diffuseColor' value='0.5 0.1 0.1'/> |
37 | <!-- fieldValue declarations for other Material attributes can appear here --> |
38 | </ProtoInstance> |
39 | </Appearance> |
40 | </Shape> |
41 | </Transform> |
42 | <Transform rotation='1 0 0 0.523599' translation='2 1 0'> |
43 | <Shape> |
44 | <Cylinder/> |
45 | <Appearance> |
46 | <!-- note that ProtoInstance USE does not require name='MaterialModulator' --> |
47 | <ProtoInstance USE='MaterialModulatorInstance' containerField='material'/> |
48 | </Appearance> |
49 | </Shape> |
50 | </Transform> |
51 | <Transform translation='-2 3.5 0'> |
52 | <Shape> |
53 | <Text string='"DEF original"'> |
54 | <FontStyle family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='0.5' style='BOLD'/> |
55 | </Text> |
56 |
<!-- Appearance
TextAppearance is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
<Appearance DEF='TextAppearance'> |
57 | <Material diffuseColor='0.9 0.9 0.9'/> |
58 | </Appearance> |
59 | </Shape> |
60 | </Transform> |
61 | <Transform translation='2 3.5 0'> |
62 | <Shape> |
63 | <Text string='"USE copy"'> |
64 | <FontStyle family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='0.5' style='BOLD'/> |
65 | </Text> |
66 | <Appearance USE='TextAppearance'/> |
67 | </Shape> |
68 | </Transform> |
69 | <Transform translation='0 -2 0'> |
70 | <Shape> |
71 | <Text string=' "enable/disable" "MaterialModulator" '> |
72 | <FontStyle family='"SANS"' justify='"MIDDLE" "MIDDLE"' style='BOLD'/> |
73 | </Text> |
74 | <Appearance USE='TextAppearance'/> |
75 | </Shape> |
76 | <!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip --> |
77 | <Shape> |
78 | <Box size='8 2 .001'/> |
79 | <Appearance> |
80 | <Material transparency='1'/> |
81 | </Appearance> |
82 | </Shape> |
83 | <!-- Toggle text to enable/disable MaterialModulator --> |
84 |
<!-- ROUTE information for TouchTextInterface node:
[from isActive to EventToggler.set_boolean
]
-->
<TouchSensor DEF='TouchTextInterface' description='Select text to enable/disable MaterialModulator'/> |
85 |
<!-- ROUTE information for EventToggler node:
[from TouchTextInterface.isActive to set_boolean
]
[from toggle to MaterialModulatorInstance.enabled
]
-->
<BooleanToggle DEF='EventToggler' containerField='children'/> |
86 | < ROUTE fromNode='TouchTextInterface' fromField='isActive' toNode='EventToggler' toField='set_boolean'/> |
87 | < ROUTE fromNode='EventToggler' fromField='toggle' toNode='MaterialModulatorInstance' toField='enabled'/> |
88 | </Transform> |
89 | </Scene> |
90 | </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.
TouchTextInterface
TouchSensor isActive SFBool |
EventToggler
BooleanToggle set_boolean SFBool |
then
|
EventToggler
BooleanToggle toggle SFBool |
MaterialModulatorInstance
ProtoInstance enabled SFBool |
MaterialModulatorInstance
ProtoInstance MaterialModulator |
No ROUTE connection found for output events from this node. This ProtoInstance contains SFNode/MFNode fieldValue declarations with direct access to other nodes, and thus has potential to produce run-time animation. |
<!--
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>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->