<?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='Lamp2.x3d'/>
<meta name='descriptioncontent="Desk lamp with light toggle switch: this file builds a desk lamp that can be moved about. Dragging on the lamp base slides the lamp back and forth. Dragging on the lamp arms turns the lamp arm. Dragging on the lamp shade turns the lamp shade. Touching the lamp's light switch (on the top of the lamp shade) turns the lamp on and off."/>
<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='referencecontent='originals/lamp2.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/mt0433.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/Lamp2.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>
<!-- -->
<Scene>
<!-- To make the lamp go on and off, a TouchSensor is routed into a 'toggle' script that alternates between TRUE and FALSE outputs, sending TRUE on the first TRUE input, then FALSE on the next TRUE input. These TRUE/FALSE values are routed into a SpotLight node within the lamp, turning it on and off. -->
<!-- A second script converts an incoming TRUE or FALSE in to one of two colors. Those colors are routed into the lamp's bulb to change it from an on color to an off color. -->
<!-- Note that .x3d XML syntax uses boolean constants true/false instead of VRML syntax TRUE/FALSE -->
<WorldInfo info='"Copyright (c) 1997, David R. Nadeau"title='Desk lamp with light toggle switch'/>
<Viewpoint DEF='Entrydescription='Entry viewposition='0.0 0.1 1.0'/>
<NavigationInfo headlight='false'/>
<Background/>
<DirectionalLight direction='0.0 -1.0 -1.0intensity='0.3'/>
<Transform translation='-1.0 0.0 -1.0'>
<Shape>
<Appearance> </Appearance>
<ElevationGrid creaseAngle='3.14xDimension='10xSpacing='0.25zDimension='10zSpacing='0.25height='0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0'/>
</Shape>
</Transform>
<Transform rotation='1.0 0.0 0.0 1.571translation='0.0 0.01 0.0'>
<!-- ROUTE information for MoveLamp node:  [from translation_changed to Lamp.set_translation ] -->
<PlaneSensor DEF='MoveLamp'/>
<!-- ROUTE information for Lamp node:  [from MoveLamp.translation_changed to set_translation ] -->
<Transform DEF='Lamprotation='1.0 0.0 0.0 -1.571'>
<Shape>
<Appearance>
<Material diffuseColor='0.5 0.5 0.5'/>
</Appearance>
<Cylinder height='0.01radius='0.1'/>
</Shape>
<Group>
<!-- ROUTE information for MoveFirstArm node:  [from rotation_changed to FirstArm.set_rotation ] -->
<CylinderSensor DEF='MoveFirstArm'/>
<!-- ROUTE information for FirstArm node:  [from MoveFirstArm.rotation_changed to set_rotation ] -->
<Transform DEF='FirstArm'>
<Transform center='0.0 -0.15 0.0rotation='1.0 0.0 0.0 -0.7translation='0.0 0.15 0.0'>
<Shape DEF='LampArm'>
<Appearance DEF='Red'>
<Material diffuseColor='1.0 0.2 0.2'/>
</Appearance>
<Cylinder height='0.3radius='0.01'/>
</Shape>
<Group>
<!-- ROUTE information for MoveSecondArm node:  [from rotation_changed to SecondArm.set_rotation ] -->
<CylinderSensor DEF='MoveSecondArm'/>
<!-- ROUTE information for SecondArm node:  [from MoveSecondArm.rotation_changed to set_rotation ] -->
<Transform DEF='SecondArm'>
<Transform center='0.0 -0.15 0.0rotation='1.0 0.0 0.0 1.9translation='0.0 0.3 0.0'>
<Shape USE='LampArm'/>
<Group>
<!-- ROUTE information for MoveLampShade node:  [from rotation_changed to LampShade.set_rotation ] -->
<SphereSensor DEF='MoveLampShadeoffset='1.0 0.0 0.0 -1.25'/>
<!-- ROUTE information for LampShade node:  [from MoveLampShade.rotation_changed to set_rotation ] -->
<Transform DEF='LampShadecenter='0.0 0.075 0.0rotation='1.0 0.0 0.0 -1.25translation='0.0 0.075 0.0'>
<Shape>
<Appearance USE='Red'/>
<Cone bottom='falsebottomRadius='0.12height='0.15'/>
</Shape>
<Transform translation='0.0 0.075 0.0'>
<!-- ROUTE information for LightSwitch node:  [from isActive to Toggle.set_active ] -->
<TouchSensor DEF='LightSwitchdescription='Click to toggle light on/off'/>
<Shape>
<Appearance>
<Material diffuseColor='1.0 1.0 1.0'/>
</Appearance>
<Cylinder height='0.03radius='0.007'/>
</Shape>
</Transform>
<Transform translation='0.0 -0.05 0.0'>
<!-- ROUTE information for LampLight node:  [from Toggle.on_changed to set_on ] -->
<SpotLight DEF='LampLightambientIntensity='0.2beamWidth='0.6direction='0.0 -1.0 0.0'/>
<Shape>
<Appearance>
<!-- ROUTE information for BulbMaterial node:  [from ColorSelector.color_changed to set_emissiveColor ] -->
<Material DEF='BulbMaterialdiffuseColor='0.0 0.0 0.0emissiveColor='1.0 1.0 1.0'/>
</Appearance>
<Sphere radius='0.05'/>
</Shape>
</Transform>
</Transform>
</Group>
</Transform>
</Transform>
</Group>
</Transform>
</Transform>
</Group>
</Transform>
</Transform>
<ROUTE fromNode='MoveLampfromField='translation_changedtoNode='LamptoField='set_translation'/>
<ROUTE fromNode='MoveFirstArmfromField='rotation_changedtoNode='FirstArmtoField='set_rotation'/>
<ROUTE fromNode='MoveSecondArmfromField='rotation_changedtoNode='SecondArmtoField='set_rotation'/>
<ROUTE fromNode='MoveLampShadefromField='rotation_changedtoNode='LampShadetoField='set_rotation'/>
<!-- ROUTE information for Toggle node:  [from LightSwitch.isActive to set_active ] [from on_changed to LampLight.set_on ] [from on_changed to ColorSelector.set_selection ] -->
<Script DEF='Toggle'>
<field name='ontype='SFBoolvalue='trueaccessType='initializeOnly'/>
<field name='set_activetype='SFBoolaccessType='inputOnly'/>
<field name='on_changedtype='SFBoolaccessType='outputOnly'/>
<![CDATA[
      
ecmascript:
		function set_active( b, tm ) {
			// ignore button releases
			if ( b == false ) return;

			// toggle on button presses
			if ( on == true ) on = false;
			else              on = true;
			on_changed = on;
		}

    
]]>
</Script>
<!-- ROUTE information for ColorSelector node:  [from Toggle.on_changed to set_selection ] [from color_changed to BulbMaterial.set_emissiveColor ] -->
<Script DEF='ColorSelector'>
<field name='offColortype='SFColorvalue='0.0 0.0 0.0accessType='initializeOnly'/>
<field name='onColortype='SFColorvalue='1.0 1.0 1.0accessType='initializeOnly'/>
<field name='color_changedtype='SFColoraccessType='outputOnly'/>
<field name='set_selectiontype='SFBoolaccessType='inputOnly'/>
<![CDATA[
      
ecmascript:
		function set_selection( b, tm ) {
			if ( b == true )
				color_changed = onColor;
			else
				color_changed = offColor;
		}

    
]]>
</Script>
<ROUTE fromNode='LightSwitchfromField='isActivetoNode='ToggletoField='set_active'/>
<ROUTE fromNode='TogglefromField='on_changedtoNode='LampLighttoField='set_on'/>
<ROUTE fromNode='TogglefromField='on_changedtoNode='ColorSelectortoField='set_selection'/>
<ROUTE fromNode='ColorSelectorfromField='color_changedtoNode='BulbMaterialtoField='set_emissiveColor'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : BulbMaterial, ColorSelector, Entry, FirstArm, Lamp, LampArm, LampLight, LampShade, LightSwitch, MoveFirstArm, MoveLamp, MoveLampShade, MoveSecondArm, Red, SecondArm, Toggle

Index for Viewpoint image : Entry
-->

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