| 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='title' content=' Lamp2a.x3d '/> | 
| 6 | <meta name='description' content="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."/> | 
| 7 | <meta name='creator' content='David R. Nadeau'/> | 
| 8 | <meta name='translator' content='Don Brutzman'/> | 
| 9 | <meta name='created' content='1 July 1998'/> | 
| 10 | <meta name='translated' content='2 February 2014'/> | 
| 11 | <meta name='modified' content='3 September 2023'/> | 
| 12 | <meta name='reference' content='originals/lamp2a.wrl'/> | 
| 13 | <meta name='reference' content='http://www.siggraph.org/s98'/> | 
| 14 | <meta name='reference' content=' http://www.siggraph.org/s98/conference/courses/18.html '/> | 
| 15 | <meta name='reference' content=' http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0430.htm '/> | 
| 16 | <meta name='reference' content=' http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm '/> | 
| 17 | <meta name='reference' content=' https://www.web3d.org/x3d/content/examples/X3dResources.html '/> | 
| 18 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Lamp2a.x3d '/> | 
| 19 | <meta name='generator' content=' Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html '/> | 
| 20 | <meta name='generator' content='X3D-Edit, https://www.web3d.org/x3d/tools/X3D-Edit'/> | 
| 21 | <meta name='license' content='../license.html'/> | 
| 22 | </head> | 
 DEF nodes index: 
               
               BulbMaterial,
Entry,
FirstArm,
Lamp,
LampArm,
LampLight,
LampShade,
LightSwitch,
MoveFirstArm,
MoveLamp,
MoveLampShade,
MoveSecondArm,
Red,
SecondArm,
Toggle
               
               
                  DEF nodes index: 
               
               BulbMaterial,
Entry,
FirstArm,
Lamp,
LampArm,
LampLight,
LampShade,
LightSwitch,
MoveFirstArm,
MoveLamp,
MoveLampShade,
MoveSecondArm,
Red,
SecondArm,
Toggle
| 23 | <Scene> | 
| 24 | <!-- 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. --> | 
| 25 | <WorldInfo info='"Copyright (c) 1997, David R. Nadeau"' title='Desk lamp with light toggle switch'/> | 
| 26 | <Viewpoint DEF='Entry' description='Entry view' position='0.0 0.1 1.0'/> | 
| 27 | <NavigationInfo headlight='false'/> | 
| 28 | <Background/> | 
| 29 | <DirectionalLight direction='0.0 -1.0 -1.0' intensity='0.3'/> | 
| 30 | <Transform translation='-1.0 0.0 -1.0'> | 
| 31 | <Shape> | 
| 32 | <Appearance> | 
| 33 | <Material/> | 
| 34 | <ImageTexture
                                          
  url='  "wood.jpg  "  "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/wood.jpg  " '/> | 
| 35 | </Appearance> | 
| 36 | <ElevationGrid creaseAngle='3.14' xDimension='10' xSpacing='0.25' zDimension='10' zSpacing='0.25' height='0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0'/> | 
| 37 | </Shape> | 
| 38 | </Transform> | 
| 39 | <Transform rotation='1.0 0.0 0.0 1.571' translation='0.0 0.01 0.0'> | 
| 40 | 
               <!-- ROUTE information for MoveLamp node: 
[from translation_changed to Lamp.set_translation
                              ]
 --> <PlaneSensor DEF='MoveLamp'/> | 
| 41 | 
               <!-- ROUTE information for Lamp node: 
[from MoveLamp.translation_changed to set_translation
                              ]
 --> <Transform DEF='Lamp' rotation='1.0 0.0 0.0 -1.571'> | 
| 42 | <Shape> | 
| 43 | <Appearance> | 
| 44 | <Material diffuseColor='0.5 0.5 0.5'/> | 
| 45 | </Appearance> | 
| 46 | <Cylinder height='0.01' radius='0.1'/> | 
| 47 | </Shape> | 
| 48 | <Group> | 
| 49 | 
                         <!-- ROUTE information for MoveFirstArm node: 
[from rotation_changed to FirstArm.set_rotation
                                          ]
 --> <CylinderSensor DEF='MoveFirstArm'/> | 
| 50 | 
                         <!-- ROUTE information for FirstArm node: 
[from MoveFirstArm.rotation_changed to set_rotation
                                          ]
 --> <Transform DEF='FirstArm'> | 
| 51 | <Transform center='0.0 -0.15 0.0' rotation='1.0 0.0 0.0 -0.7' translation='0.0 0.15 0.0'> | 
| 52 | |
| 53 | |
| 54 | <Material diffuseColor='1.0 0.2 0.2'/> | 
| 55 | </Appearance> | 
| 56 | <Cylinder height='0.3' radius='0.01'/> | 
| 57 | </Shape> | 
| 58 | <Group> | 
| 59 | 
                                        <!-- ROUTE information for MoveSecondArm node: 
[from rotation_changed to SecondArm.set_rotation
                                                            ]
 --> <CylinderSensor DEF='MoveSecondArm'/> | 
| 60 | 
                                        <!-- ROUTE information for SecondArm node: 
[from MoveSecondArm.rotation_changed to set_rotation
                                                            ]
 --> <Transform DEF='SecondArm'> | 
| 61 | <Transform center='0.0 -0.15 0.0' rotation='1.0 0.0 0.0 1.9' translation='0.0 0.3 0.0'> | 
| 62 | <Shape USE='LampArm'/> | 
| 63 | <Group> | 
| 64 | 
                                                       <!-- ROUTE information for MoveLampShade node: 
[from rotation_changed to LampShade.set_rotation
                                                                              ]
 --> <SphereSensor DEF='MoveLampShade' offset='1.0 0.0 0.0 -1.25'/> | 
| 65 | 
                                                       <!-- ROUTE information for LampShade node: 
[from MoveLampShade.rotation_changed to set_rotation
                                                                              ]
 --> <Transform DEF='LampShade' center='0.0 0.075 0.0' rotation='1.0 0.0 0.0 -1.25' translation='0.0 0.075 0.0'> | 
| 66 | <Shape> | 
| 67 | <Appearance USE='Red'/> | 
| 68 | <Cone bottom='false' bottomRadius='0.12' height='0.15'/> | 
| 69 | </Shape> | 
| 70 | <Transform translation='0.0 0.075 0.0'> | 
| 71 | 
                                                                 <!-- ROUTE information for LightSwitch node: 
[from isActive to Toggle.set_active
                                                                                          ]
 --> <TouchSensor DEF='LightSwitch'/> | 
| 72 | <Shape> | 
| 73 | <Appearance> | 
| 74 | <Material diffuseColor='1.0 1.0 1.0'/> | 
| 75 | </Appearance> | 
| 76 | <Cylinder height='0.03' radius='0.007'/> | 
| 77 | </Shape> | 
| 78 | </Transform> | 
| 79 | <Transform translation='0.0 -0.05 0.0'> | 
| 80 | 
                                                                 <!-- ROUTE information for LampLight node: 
[from Toggle.on_changed to set_on
                                                                                          ]
 --> <SpotLight DEF='LampLight' ambientIntensity='0.2' beamWidth='0.6' direction='0.0 -1.0 0.0'/> | 
| 81 | <Shape> | 
| 82 | <Appearance> | 
| 83 | <Material DEF='BulbMaterial' diffuseColor='0.0 0.0 0.0' emissiveColor='1.0 1.0 1.0'/> | 
| 84 | </Appearance> | 
| 85 | <Sphere radius='0.05'/> | 
| 86 | </Shape> | 
| 87 | </Transform> | 
| 88 | </Transform> | 
| 89 | </Group> | 
| 90 | </Transform> | 
| 91 | </Transform> | 
| 92 | </Group> | 
| 93 | </Transform> | 
| 94 | </Transform> | 
| 95 | </Group> | 
| 96 | </Transform> | 
| 97 | </Transform> | 
| 98 | < ROUTE fromNode='MoveLamp' fromField='translation_changed' toNode='Lamp' toField='set_translation'/> | 
| 99 | < ROUTE fromNode='MoveFirstArm' fromField='rotation_changed' toNode='FirstArm' toField='set_rotation'/> | 
| 100 | < ROUTE fromNode='MoveSecondArm' fromField='rotation_changed' toNode='SecondArm' toField='set_rotation'/> | 
| 101 | < ROUTE fromNode='MoveLampShade' fromField='rotation_changed' toNode='LampShade' toField='set_rotation'/> | 
| 102 | 
          <!-- ROUTE information for Toggle node: 
[from LightSwitch.isActive to set_active
                        ]
[from on_changed to LampLight.set_on
                        ]
 --> <Script DEF='Toggle'> | 
| 103 | <field name='on' type='SFBool' value='true' accessType='initializeOnly'/> | 
| 104 | <field name='set_active' type='SFBool' accessType='inputOnly'/> | 
| 105 | <field name='on_changed' type='SFBool' accessType='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;
		}
    
                                 ]]>
                               | |
| 107 | </Script> | 
| 108 | < ROUTE fromNode='LightSwitch' fromField='isActive' toNode='Toggle' toField='set_active'/> | 
| 109 | < ROUTE fromNode='Toggle' fromField='on_changed' toNode='LampLight' toField='set_on'/> | 
| 110 | </Scene> | 
| 111 | </X3D> | 
 DEF nodes index: 
         
         BulbMaterial,
Entry,
FirstArm,
Lamp,
LampArm,
LampLight,
LampShade,
LightSwitch,
MoveFirstArm,
MoveLamp,
MoveLampShade,
MoveSecondArm,
Red,
SecondArm,
Toggle
         
         
            DEF nodes index: 
         
         BulbMaterial,
Entry,
FirstArm,
Lamp,
LampArm,
LampLight,
LampShade,
LightSwitch,
MoveFirstArm,
MoveLamp,
MoveLampShade,
MoveSecondArm,
Red,
SecondArm,
Toggle
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 | Toggle Script set_active SFBool | then | Toggle Script on_changed SFBool | LampLight SpotLight set_on SFBool | 
| MoveLampShade SphereSensor rotation_changed SFRotation | LampShade Transform set_rotation SFRotation | 
| MoveLamp PlaneSensor translation_changed SFVec3f | Lamp Transform set_translation SFVec3f | 
| MoveFirstArm CylinderSensor rotation_changed SFRotation | FirstArm Transform set_rotation SFRotation | 
| MoveSecondArm CylinderSensor rotation_changed SFRotation | SecondArm Transform set_rotation SFRotation | 
         <!--
Color-coding 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)
          -->
      
         
             <!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->
         
         <!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->