<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<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 '>
<head>
<meta name='titlecontent='Loader.x3d'/>
<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.'/>
<meta name='creatorcontent='David R. Nadeau'/>
<meta name='translatorcontent='Don Brutzman'/>
<meta name='createdcontent='1 July 1998'/>
<meta name='translatedcontent='2 February 2014'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='Imagecontent='Loader.png'/>
<meta name='referencecontent='Button.x3d'/>
<meta name='referencecontent='originals/loader.wrl'/>
<meta name='referencecontent=' http://www.siggraph.org/s98 '/>
<meta name='referencecontent=' http://www.siggraph.org/s98/conference/courses/18.html '/>
<meta name='referencecontent=' http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0469.htm '/>
<meta name='referencecontent=' http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/content/examples/X3dResources.html '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Loader.x3d '/>
<meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
<meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

Index for ExternProtoDeclare definition : Button

Index for DEF nodes : Button1, Button2, Button3, Label, Loaded, Loader

Index for Viewpoint image : Viewpoint_1
-->
<Scene>
<WorldInfo info='"Copyright (c) 1998, David R. Nadeau"title='Load VRML using a script'/>
<NavigationInfo/>
<Viewpoint description='Entry view'/>
<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'/>
<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" '>
<field name='urltype='MFStringaccessType='inputOutput'/>
<field name='textureUrltype='MFStringaccessType='inputOutput'/>
<field name='url_changedtype='MFStringaccessType='outputOnly'/>
<field name='translationtype='SFVec3faccessType='initializeOnly'/>
</ExternProtoDeclare>
<!-- ROUTE information for Button1 node:  [from url_changed to Loader.loadUrl ] -->
<ProtoInstance name='ButtonDEF='Button1'>
<fieldValue name='urlvalue=' "One.x3d"
"https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/One.x3d" '/>

<fieldValue name='textureUrlvalue=' "one.jpg"
'/>

<fieldValue name='translationvalue='-4.0 2.0 0.0'/>
</ProtoInstance>
<!-- ROUTE information for Button2 node:  [from url_changed to Loader.loadUrl ] -->
<ProtoInstance name='ButtonDEF='Button2'>
<fieldValue name='urlvalue=' "Two.x3d"
"https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Two.x3d" '/>

<fieldValue name='textureUrlvalue=' "two.jpg"
'/>

<fieldValue name='translationvalue='-4.0 0.0 0.0'/>
</ProtoInstance>
<!-- ROUTE information for Button3 node:  [from url_changed to Loader.loadUrl ] -->
<ProtoInstance name='ButtonDEF='Button3'>
<fieldValue name='urlvalue=' "Three.x3d"
"https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Three.x3d" '/>

<fieldValue name='textureUrlvalue=' "three.jpg"
'/>

<fieldValue name='translationvalue='-4.0 -2.0 0.0'/>
</ProtoInstance>
<Transform translation='-4.0 -3.5 0.0'>
<Shape>
<Appearance>
<Material/>
</Appearance>
<!-- ROUTE information for Label node:  [from Loader.string_changed to set_string ] -->
<Text DEF='Label'>
<FontStyle justify='"MIDDLE" "MIDDLE"size='0.75'/>
</Text>
</Shape>
</Transform>
<!-- ROUTE information for Loaded node:  [from Loader.node_changed to set_children ] -->
<Transform DEF='Loadedtranslation='1.0 0.0 0.0'>
<!-- load result goes here -->
</Transform>
<!-- 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'>
<field name='lastUrltype='MFStringvalue=' ""
accessType='initializeOnly'/>

<field name='loadUrltype='MFStringaccessType='inputOnly'/>
<field name='vrmlLoadedtype='MFNodeaccessType='inputOnly'/>
<field name='node_changedtype='MFNodeaccessType='outputOnly'/>
<field name='string_changedtype='MFStringaccessType='outputOnly'/>
<field name='myselftype='SFNodeaccessType='initializeOnly'>
<Script USE='Loader'>
</Script>
</field>
<![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];
}

    
]]>
</Script>
<ROUTE fromNode='Button1fromField='url_changedtoNode='LoadertoField='loadUrl'/>
<ROUTE fromNode='Button2fromField='url_changedtoNode='LoadertoField='loadUrl'/>
<ROUTE fromNode='Button3fromField='url_changedtoNode='LoadertoField='loadUrl'/>
<ROUTE fromNode='LoaderfromField='node_changedtoNode='LoadedtoField='set_children'/>
<ROUTE fromNode='LoaderfromField='string_changedtoNode='LabeltoField='set_string'/>
</Scene>
</X3D>
<!--

Index for ExternProtoDeclare definition : Button

Index for DEF nodes : Button1, Button2, Button3, Label, Loaded, Loader

Index for Viewpoint image : Viewpoint_1
-->

<!-- Online at https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/LoaderIndex.html -->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
    <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->

<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources and X3D Scene Authoring Hints. -->