X3D Model Documentation: TestProtoInterfaceNodeScope.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='TestProtoInterfaceNodeScope.x3d'/>
  6            <meta name='descriptioncontent='Test override of color values in prototypes and scripts. Color code: red = left-most default prototype interface, yellow = middle ProtoInstance fieldValue, green = Script initialization of middle ProtoInstance, blue = right-side default prototype instance.'/>
  7            <meta name='creatorcontent='Alan Hudson, Don Brutzman'/>
  8            <meta name='translatorcontent='Xeena VRML importer, X3D-Edit 3.1, https://www.web3d.org/x3d/content/README.X3D-Edit.html'/>
  9            <meta name='createdcontent='4 January 2006'/>
 10            <meta name='translatedcontent='5 January 2006'/>
 11            <meta name='modifiedcontent='9 October 2023'/>
 12            <meta name='rightscontent='Copyright (c) Web3D Consortium Inc. 2006'/>
 13            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/development/TestProtoInterfaceNodeScope.x3d'/>
 14            <meta name='generatorcontent='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
 15            <meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
 16            <meta name='licensecontent='../license.html'/>
 17       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: LeftTransform, MiddleTransform, P1, P2, P3, ProtoBox, RightTransform, SC

Index for ProtoDeclare definition: MyProto
-->
 18       <Scene>
 19            <WorldInfo title='TestProtoInterfaceNodeScope.x3d'/>
 20            <ProtoDeclare name='MyProto'>
 21                 <ProtoInterface>
 22                      <field name='materialtype='SFNodeaccessType='inputOutput'>
 23                           <Material diffuseColor='1 0 0'/>
 24                      </field>
 25                 </ProtoInterface>
 26                 <ProtoBody>
 27                      <Shape>
 28                           <Appearance>
 29                                <IS>
 30                                     <connect nodeField='materialprotoField='material'/>
 31                                </IS>
 32                           </Appearance>
 33                           <Box DEF='ProtoBox'/>
 34                      </Shape>
 35                 </ProtoBody>
 36            </ProtoDeclare>
 37            <Transform DEF='LeftTransformtranslation='-2.5 0.0 0.0'>
 38                 <ProtoInstance name='MyProtoDEF='P1'/>
 39            </Transform>
 40            <Transform DEF='MiddleTransform'>
 41 
               <!-- ProtoInstance P2 is a DEF node that has 1 USE node: USE_1 -->
               <ProtoInstance name='MyProtoDEF='P2'>
 42                      <fieldValue name='material'>
 43                           <Material diffuseColor='0.7 0.7 0'/>
 44                      </fieldValue>
 45                 </ProtoInstance>
 46                 <Script DEF='SCdirectOutput='true'>
 47                      <field name='proto1type='SFNodeaccessType='initializeOnly'>
 48                           <ProtoInstance USE='P2'/>
 49                      </field>
  <![CDATA[
        
ecmascript:

function initialize() {
	Browser.println ('Changing color on middle box to green');
	proto1.material.diffuseColor = new SFColor(0,1,0);
}

      
]]>
 51                 </Script>
 52            </Transform>
 53            <Transform DEF='RightTransformtranslation='2.5 0.0 0.0'>
 54                 <ProtoInstance name='MyProtoDEF='P3'>
 55                      <fieldValue name='material'>
 56                           <Material diffuseColor='0 0 1'/>
 57                      </fieldValue>
 58                 </ProtoInstance>
 59            </Transform>
 60            <Switch whichChoice='-1'>
 61                 <Shape>
 62                      <!-- To test protected scope of nodes DEF'ed inside a prototype body, add: <Box USE="ProtoBox"/> -->
 63                 </Shape>
 64            </Switch>
 65       </Scene>
 66  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: LeftTransform, MiddleTransform, P1, P2, P3, ProtoBox, RightTransform, SC

Index for ProtoDeclare definition: MyProto
-->
X3D Tooltips element index: Appearance, Box, connect, field, fieldValue, head, IS, Material, meta, ProtoBody, ProtoDeclare, ProtoInstance, ProtoInterface, Scene, Script, Shape, Switch, Transform, WorldInfo, X3D, accessType and type, XML data types, field types

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

SC
Script
No ROUTE connection found for output events from this node.
Contains SFNode field with direct access to another node. 

P1
ProtoInstance
MyProto
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. 

P2
ProtoInstance
MyProto
No ROUTE connection found for output events from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declaration with
direct access to other nodes, and thus has potential to produce run-time animation. 

P3
ProtoInstance
MyProto
No ROUTE connection found for output events from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declaration with
direct access to other nodes, and thus has potential to produce run-time animation. 
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/Basic/development/TestProtoInterfaceNodeScopeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/TestProtoInterfaceNodeScope.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. -->