<?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='Lamp2a.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='3 September 2023'/>
<meta name='referencecontent='originals/lamp2a.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/mt0430.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/Lamp2a.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>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BulbMaterial, Entry, FirstArm, Lamp, LampArm, LampLight, LampShade, LightSwitch, MoveFirstArm, MoveLamp, MoveLampShade, MoveSecondArm, Red, SecondArm, Toggle

Index for Viewpoint node: Entry
-->
<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. -->
<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='LightSwitch'/>

<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>
<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=' MoveLamp' fromField='translation_changed' toNode=' Lamp' toField='set_translation'/>
< ROUTE  fromNode=' MoveFirstArm' fromField='rotation_changed' toNode=' FirstArm' toField='set_rotation'/>
< ROUTE  fromNode=' MoveSecondArm' fromField='rotation_changed' toNode=' SecondArm' toField='set_rotation'/>
< ROUTE  fromNode=' MoveLampShade' fromField='rotation_changed' toNode=' LampShade' toField='set_rotation'/>
<!-- ROUTE information for Toggle node:  [from LightSwitch.isActive to set_active ] [from on_changed to LampLight.set_on ] -->
<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  fromNode=' LightSwitch' fromField='isActive' toNode=' Toggle' toField='set_active'/>
< ROUTE  fromNode=' Toggle' fromField='on_changed' toNode=' LampLight' toField='set_on'/>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BulbMaterial, Entry, FirstArm, Lamp, LampArm, LampLight, LampShade, LightSwitch, MoveFirstArm, MoveLamp, MoveLampShade, MoveSecondArm, Red, SecondArm, Toggle

Index for Viewpoint node: Entry
-->

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

LightSwitch
TouchSensor
isActive
SFBool

ROUTE
event to
(1)
Toggle
Script
set_active
SFBool

 
 
then
Toggle
Script
on_changed
SFBool

ROUTE
event to
(2)
LampLight
SpotLight
set_on
SFBool


MoveLampShade
SphereSensor
rotation_changed
SFRotation

ROUTE
event to
(1)
LampShade
Transform
set_rotation
SFRotation


MoveLamp
PlaneSensor
translation_changed
SFVec3f

ROUTE
event to
(1)
Lamp
Transform
set_translation
SFVec3f


MoveFirstArm
CylinderSensor
rotation_changed
SFRotation

ROUTE
event to
(1)
FirstArm
Transform
set_rotation
SFRotation


MoveSecondArm
CylinderSensor
rotation_changed
SFRotation

ROUTE
event to
(1)
SecondArm
Transform
set_rotation
SFRotation


-->

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

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