<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<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 '>
<head>
<meta name='titlecontent='Example05.x3d'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='24 May 2000'/>
<meta name='modifiedcontent='28 October 2019'/>
<meta name='creatorcontent='X3D working group'/>
<meta name='descriptioncontent="VRML 97 specification example: This Script node decides whether or not to open a bank vault given openVault and combinationEntered messages. To do this, it remembers whether or not the correct combination has been entered. The Script node combined with a Sphere, a TouchSensor and a Sound node to show how is works. When the pointing device is over the sphere, the combinationEntered eventIn of the Script is sent. Then, when the Sphere is touched (typically when the mouse button is pressed) the Script is sent the openVault eventIn. This generates the vaultUnlocked eventOut which starts a 'click' sound."/>
<meta name='specificationUrlcontent='originals/exampleD_5.wrl'/>
<meta name='specificationSectioncontent=' VRML 97, ISO/IEC 14772-1, Part 1: Functional specification and UTF-8 encoding, D.5 Scripting example'/>
<meta name='specificationUrlcontent=' https://www.web3d.org/documents/specifications/14772/V2.0/part1/examples.html#D.5 '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/Example05.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

Index for DEF nodes : Click, OpenVault, TS
-->
<Scene>
<!-- Warning: VRML97-style scripting, not X3D Scene Authoring Interface (SAI) -->
<WorldInfo title='Example05.x3d'/>
<!-- ROUTE information for OpenVault node:  [from TS.isOver to combinationEntered ] [from TS.touchTime to openVault ] [from vaultUnlocked to Click.startTime ] -->
<Script DEF='OpenVault'>
<!-- field tags are declarations of what interfaces are in this Script node -->
<field name='openVaulttype='SFTimeaccessType='inputOnly'/>
<field name='combinationEnteredtype='SFBoolaccessType='inputOnly'/>
<field name='vaultUnlockedtype='SFTimeaccessType='outputOnly'/>
<field name='unlockedtype='SFBoolvalue='falseaccessType='initializeOnly'/>
<![CDATA[
      
ecmascript:
function combinationEntered (value)
{
	unlocked = value;
}
function openVault(value)
{
	if (unlocked) vaultUnlocked = value;
}

    
]]>
</Script>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Sphere/>
</Shape>
<Sound maxBack='1000maxFront='1000minBack='1000minFront='1000'>
<!-- ROUTE information for Click node:  [from OpenVault.vaultUnlocked to startTime ] -->
<AudioClip DEF='Clickdescription='clickstopTime='1'
  url=' "click.wav" "https://www.web3d.org/x3d/content/examples/Basic/Vrml97Specification/click.wav" '/>
</Sound>
<!-- ROUTE information for TS node:  [from isOver to OpenVault.combinationEntered ] [from touchTime to OpenVault.openVault ] -->
<TouchSensor DEF='TSdescription='touch ball to hear a click'/>
<ROUTE fromNode='TSfromField='isOvertoNode='OpenVaulttoField='combinationEntered'/>
<ROUTE fromNode='TSfromField='touchTimetoNode='OpenVaulttoField='openVault'/>
<ROUTE fromNode='OpenVaultfromField='vaultUnlockedtoNode='ClicktoField='startTime'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : Click, OpenVault, TS
-->

<!-- 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)
-->

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