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='Lamp2.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='20 October 2019'/> |
12 | <meta name='reference' content='originals/lamp2.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/mt0433.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/Lamp2.x3d'/> |
19 | <meta name='generator' content='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/> |
20 | <meta name='generator' content='X3D-Edit, https://savage.nps.edu/X3D-Edit'/> |
21 | <meta name='license' content='../license.html'/> |
22 | </head> |
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 | <!-- 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. --> |
26 | <!-- Note that .x3d XML syntax uses boolean constants true/false instead of VRML syntax TRUE/FALSE --> |
27 | <WorldInfo info='"Copyright (c) 1997, David R. Nadeau"' title='Desk lamp with light toggle switch'/> |
28 | <Viewpoint DEF='Entry' description='Entry view' position='0.0 0.1 1.0'/> |
29 | <NavigationInfo headlight='false'/> |
30 | <Background/> |
31 | <DirectionalLight direction='0.0 -1.0 -1.0' intensity='0.3'/> |
32 | <Transform translation='-1.0 0.0 -1.0'> |
33 | <Shape> |
34 | <Appearance> |
35 | <Material/> |
36 | <ImageTexture url=' "wood.jpg " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/wood.jpg " '/> |
37 | </Appearance> |
38 | <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'/> |
39 | </Shape> |
40 | </Transform> |
41 | <Transform rotation='1.0 0.0 0.0 1.571' translation='0.0 0.01 0.0'> |
42 |
<!-- ROUTE information for MoveLamp node:
[from translation_changed to Lamp.set_translation
]
-->
<PlaneSensor DEF='MoveLamp'/> |
43 |
<!-- ROUTE information for Lamp node:
[from MoveLamp.translation_changed to set_translation
]
-->
<Transform DEF='Lamp' rotation='1.0 0.0 0.0 -1.571'> |
44 | <Shape> |
45 | <Appearance> |
46 | <Material diffuseColor='0.5 0.5 0.5'/> |
47 | </Appearance> |
48 | <Cylinder height='0.01' radius='0.1'/> |
49 | </Shape> |
50 | <Group> |
51 |
<!-- ROUTE information for MoveFirstArm node:
[from rotation_changed to FirstArm.set_rotation
]
-->
<CylinderSensor DEF='MoveFirstArm'/> |
52 |
<!-- ROUTE information for FirstArm node:
[from MoveFirstArm.rotation_changed to set_rotation
]
-->
<Transform DEF='FirstArm'> |
53 | <Transform center='0.0 -0.15 0.0' rotation='1.0 0.0 0.0 -0.7' translation='0.0 0.15 0.0'> |
54 | |
55 | |
56 | <Material diffuseColor='1.0 0.2 0.2'/> |
57 | </Appearance> |
58 | <Cylinder height='0.3' radius='0.01'/> |
59 | </Shape> |
60 | <Group> |
61 |
<!-- ROUTE information for MoveSecondArm node:
[from rotation_changed to SecondArm.set_rotation
]
-->
<CylinderSensor DEF='MoveSecondArm'/> |
62 |
<!-- ROUTE information for SecondArm node:
[from MoveSecondArm.rotation_changed to set_rotation
]
-->
<Transform DEF='SecondArm'> |
63 | <Transform center='0.0 -0.15 0.0' rotation='1.0 0.0 0.0 1.9' translation='0.0 0.3 0.0'> |
64 | <Shape USE='LampArm'/> |
65 | <Group> |
66 |
<!-- ROUTE information for MoveLampShade node:
[from rotation_changed to LampShade.set_rotation
]
-->
<SphereSensor DEF='MoveLampShade' offset='1.0 0.0 0.0 -1.25'/> |
67 |
<!-- 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'> |
68 | <Shape> |
69 | <Appearance USE='Red'/> |
70 | <Cone bottom='false' bottomRadius='0.12' height='0.15'/> |
71 | </Shape> |
72 | <Transform translation='0.0 0.075 0.0'> |
73 |
<!-- ROUTE information for LightSwitch node:
[from isActive to Toggle.set_active
]
-->
<TouchSensor DEF='LightSwitch' description='Click to toggle light on/off'/> |
74 | <Shape> |
75 | <Appearance> |
76 | <Material diffuseColor='1.0 1.0 1.0'/> |
77 | </Appearance> |
78 | <Cylinder height='0.03' radius='0.007'/> |
79 | </Shape> |
80 | </Transform> |
81 | <Transform translation='0.0 -0.05 0.0'> |
82 |
<!-- 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'/> |
83 | <Shape> |
84 | <Appearance> |
85 |
<!-- ROUTE information for BulbMaterial node:
[from ColorSelector.color_changed to set_emissiveColor
]
-->
<Material DEF='BulbMaterial' diffuseColor='0.0 0.0 0.0' emissiveColor='1.0 1.0 1.0'/> |
86 | </Appearance> |
87 | <Sphere radius='0.05'/> |
88 | </Shape> |
89 | </Transform> |
90 | </Transform> |
91 | </Group> |
92 | </Transform> |
93 | </Transform> |
94 | </Group> |
95 | </Transform> |
96 | </Transform> |
97 | </Group> |
98 | </Transform> |
99 | </Transform> |
100 | < ROUTE fromNode='MoveLamp' fromField='translation_changed' toNode='Lamp' toField='set_translation'/> |
101 | < ROUTE fromNode='MoveFirstArm' fromField='rotation_changed' toNode='FirstArm' toField='set_rotation'/> |
102 | < ROUTE fromNode='MoveSecondArm' fromField='rotation_changed' toNode='SecondArm' toField='set_rotation'/> |
103 | < ROUTE fromNode='MoveLampShade' fromField='rotation_changed' toNode='LampShade' toField='set_rotation'/> |
104 |
<!-- 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'> |
105 | <field name='on' type='SFBool' value='true' accessType='initializeOnly'/> |
106 | <field name='set_active' type='SFBool' accessType='inputOnly'/> |
107 | <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; }
]]>
|
|
109 | </Script> |
110 |
<!-- ROUTE information for ColorSelector node:
[from Toggle.on_changed to set_selection
]
[from color_changed to BulbMaterial.set_emissiveColor
]
-->
<Script DEF='ColorSelector'> |
111 | <field name='offColor' type='SFColor' value='0.0 0.0 0.0' accessType='initializeOnly'/> |
112 | <field name='onColor' type='SFColor' value='1.0 1.0 1.0' accessType='initializeOnly'/> |
113 | <field name='color_changed' type='SFColor' accessType='outputOnly'/> |
114 | <field name='set_selection' type='SFBool' accessType='inputOnly'/> |
<![CDATA[
ecmascript: function set_selection( b, tm ) { if ( b == true ) color_changed = onColor; else color_changed = offColor; }
]]>
|
|
116 | </Script> |
117 | < ROUTE fromNode='LightSwitch' fromField='isActive' toNode='Toggle' toField='set_active'/> |
118 | < ROUTE fromNode='Toggle' fromField='on_changed' toNode='LampLight' toField='set_on'/> |
119 | < ROUTE fromNode='Toggle' fromField='on_changed' toNode='ColorSelector' toField='set_selection'/> |
120 | < ROUTE fromNode='ColorSelector' fromField='color_changed' toNode='BulbMaterial' toField='set_emissiveColor'/> |
121 | </Scene> |
122 | </X3D> |
Event Graph ROUTE Table entries with 8 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 |
||||||
then
|
Toggle
Script on_changed SFBool |
ColorSelector
Script set_selection SFBool |
then
|
ColorSelector
Script color_changed SFColor |
BulbMaterial
Material set_emissiveColor SFColor |
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 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. -->