X3D Model Documentation: Loader.x3d

  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='titlecontent='Loader.x3d'/>
  6            <meta name='descriptioncontent='This example illustrates use of JavaScript to load a scene from a file through use of the Browser object. When a button is selected to provide a new url for a file to load, the Script adds the new world, waits for the load to complete, then adds the loaded Shape into a rendered group.'/>
  7            <meta name='creatorcontent='David R. Nadeau'/>
  8            <meta name='translatorcontent='Don Brutzman'/>
  9            <meta name='createdcontent='1 July 1998'/>
 10            <meta name='translatedcontent='2 February 2014'/>
 11            <meta name='modifiedcontent='20 October 2019'/>
 12            <meta name='Imagecontent='Loader.png'/>
 13            <meta name='referencecontent='Button.x3d'/>
 14            <meta name='referencecontent='originals/loader.wrl'/>
 15            <meta name='referencecontent='http://www.siggraph.org/s98'/>
 16            <meta name='referencecontent='http://www.siggraph.org/s98/conference/courses/18.html'/>
 17            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0469.htm'/>
 18            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm'/>
 19            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 20            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Loader.x3d'/>
 21            <meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
 22            <meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
 23            <meta name='licensecontent='../license.html'/>
 24       </head>
<!--

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

<!-- to top Index for DEF nodes: Button1, Button2, Button3, Label, Loaded, Loader

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definition: Button
-->
<![CDATA[
      
ecmascript:

function loadUrl( str, ts )
{
        lastUrl = str;
        Browser.createVrmlFromURL( str, myself, 'vrmlLoaded' );
        string_changed[0] = 'Loading...';
}
function vrmlLoaded( nd, ts )
{
        node_changed = nd;
        string_changed[0] = lastUrl[0];
}

    
]]>
 25       <Scene>
 26            <WorldInfo info='"Copyright (c) 1998, David R. Nadeau"title='Load VRML using a script'/>
 27            <NavigationInfo/>
 28            <Viewpoint description='Entry view'/>
 29            <Background skyAngle='1.37 1.57 1.77skyColor='0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.8 0.2 0.0 0.0 0.0'/>
 30            <ExternProtoDeclare name='Button'   url=' "Button.x3d#Button" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Button.x3d#Button" "Button.wrl#Button" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Button.wrl#Button" '>
 31                 <field name='urltype='MFStringaccessType='inputOutput'/>
 32                 <field name='textureUrltype='MFStringaccessType='inputOutput'/>
 33                 <field name='url_changedtype='MFStringaccessType='outputOnly'/>
 34                 <field name='translationtype='SFVec3faccessType='initializeOnly'/>
 35            </ExternProtoDeclare>
 36 
          <!-- ROUTE information for Button1 node:  [from url_changed to Loader.loadUrl ] -->
          <ProtoInstance name='ButtonDEF='Button1'>
 37                 <fieldValue name='urlvalue=' "One.x3d" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/One.x3d"'/>
 38                 <fieldValue name='textureUrlvalue=' "one.jpg" '/>
 39                 <fieldValue name='translationvalue='-4.0 2.0 0.0'/>
 40            </ProtoInstance>
 41 
          <!-- ROUTE information for Button2 node:  [from url_changed to Loader.loadUrl ] -->
          <ProtoInstance name='ButtonDEF='Button2'>
 42                 <fieldValue name='urlvalue=' "Two.x3d" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Two.x3d"'/>
 43                 <fieldValue name='textureUrlvalue=' "two.jpg" '/>
 44                 <fieldValue name='translationvalue='-4.0 0.0 0.0'/>
 45            </ProtoInstance>
 46 
          <!-- ROUTE information for Button3 node:  [from url_changed to Loader.loadUrl ] -->
          <ProtoInstance name='ButtonDEF='Button3'>
 47                 <fieldValue name='urlvalue=' "Three.x3d" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Three.x3d"'/>
 48                 <fieldValue name='textureUrlvalue=' "three.jpg" '/>
 49                 <fieldValue name='translationvalue='-4.0 -2.0 0.0'/>
 50            </ProtoInstance>
 51            <Transform translation='-4.0 -3.5 0.0'>
 52                 <Shape>
 53                      <Appearance>
 54                           <Material/>
 55                      </Appearance>
 56 
                    <!-- ROUTE information for Label node:  [from Loader.string_changed to set_string ] -->
                    <Text DEF='Label'>
 57                           <FontStyle justify='"MIDDLE" "MIDDLE"size='0.75'/>
 58                      </Text>
 59                 </Shape>
 60            </Transform>
 61 
          <!-- ROUTE information for Loaded node:  [from Loader.node_changed to set_children ] -->
          <Transform DEF='Loadedtranslation='1.0 0.0 0.0'>
 62                 <!-- load result goes here -->
 63            </Transform>
 64 
          <!-- Script Loader is a DEF node that has 1 USE node: USE_1
          <!-- ROUTE information for Loader node:  [from Button1.url_changed to loadUrl ] [from Button2.url_changed to loadUrl ] [from Button3.url_changed to loadUrl ] [from node_changed to Loaded.set_children ] [from string_changed to Label.set_string ] -->
          <Script DEF='LoaderdirectOutput='true'>
 65                 <field name='lastUrltype='MFStringvalue=' "" ' accessType='initializeOnly'/>
 66                 <field name='loadUrltype='MFStringaccessType='inputOnly'/>
 67                 <field name='vrmlLoadedtype='MFNodeaccessType='inputOnly'/>
 68                 <field name='node_changedtype='MFNodeaccessType='outputOnly'/>
 69                 <field name='string_changedtype='MFStringaccessType='outputOnly'/>
 70                 <field name='myselftype='SFNodeaccessType='initializeOnly'>
 71                      <Script USE='Loader'>
 72                      </Script>
 72                 </field>
 74            </Script>
 75            < ROUTE  fromNode='Button1' fromField='url_changed' toNode='Loader' toField='loadUrl'/>
 76            < ROUTE  fromNode='Button2' fromField='url_changed' toNode='Loader' toField='loadUrl'/>
 77            < ROUTE  fromNode='Button3' fromField='url_changed' toNode='Loader' toField='loadUrl'/>
 78            < ROUTE  fromNode='Loader' fromField='node_changed' toNode='Loaded' toField='set_children'/>
 79            < ROUTE  fromNode='Loader' fromField='string_changed' toNode='Label' toField='set_string'/>
 80       </Scene>
 81  </X3D>
<!--

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

<!-- to top Index for DEF nodes: Button1, Button2, Button3, Label, Loaded, Loader

Index for Viewpoint node: Viewpoint_1

Index for ExternProtoDeclare definition: Button
-->
X3D Tooltips element index: Appearance, Background, ExternProtoDeclare, field, fieldValue, FontStyle, head, Material, meta, NavigationInfo, ProtoInstance, ROUTE, Scene, Script, Shape, Text, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

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

Button1
ProtoInstance
url_changed
MFString

ROUTE
event to
(1)
Loader
Script
loadUrl
MFString
then
 
 
 
Loader
Script
node_changed
MFNode

ROUTE
event to
(2)
Loaded
Transform
set_children
MFNode
  then
 
 
 
Loader
Script
string_changed
MFString

ROUTE
event to
(2)
Label
Text
set_string
MFString

Button2
ProtoInstance
url_changed
MFString

ROUTE
event to
(1)
Loader
Script
loadUrl
MFString
then
 
 
 
Loader
Script
node_changed
MFNode

ROUTE
event to
(2)
Loaded
Transform
set_children
MFNode
  then
 
 
 
Loader
Script
string_changed
MFString

ROUTE
event to
(2)
Label
Text
set_string
MFString

Button3
ProtoInstance
url_changed
MFString

ROUTE
event to
(1)
Loader
Script
loadUrl
MFString
then
 
 
 
Loader
Script
node_changed
MFNode

ROUTE
event to
(2)
Loaded
Transform
set_children
MFNode
  then
 
 
 
Loader
Script
string_changed
MFString

ROUTE
event to
(2)
Label
Text
set_string
MFString

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/LoaderIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Loader.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. -->