TransformSensor
TransformSensor generates output events when its targetObject enters, exits, and moves within a region in space (defined by a box).
The TransformSensor node belongs to the EnvironmentalSensor component and its container field is children. It is available since X3D version 3.2 or later.
Fields
SFNode [in, out] metadata NULL [X3DMetadataObject]
Metadata are not part of the X3D world and not interpreted by the X3D browser, but they can be accessed via the ECMAScript interface.
SFBool [in, out] enabled TRUE
Enables/disables node operation.
SFVec3f [in, out] size 0 0 0 [0,∞)
Size of intersection box, measured from center in meters.
SFVec3f [in, out] center 0 0 0 (-∞,∞)
Translation offset from origin of local coordinate system.
SFTime [out] enterTime
Time event generated when targetObject enters the box region for sensor.
SFTime [out] exitTime
Time event generated when targetObject exits the box region for sensor.
SFBool [out] isActive
IsActive true/false events are sent when triggering the sensor. isActive=true when targetObject enters the box region, isActive=false when targetObject exits the box region.
SFVec3f [out] position_changed
Sends translation event relative to center whenever the target object is contained within the box region and results change.
SFRotation [out] orientation_changed
Sends rotation event relative to center whenever the target object is contained within the box region and results change.
SFNode [in, out] targetObject NULL [X3DGroupingNode|X3DShapeNode]
TargetObject is the movable geometry represented by any valid X3DGroupingNode or X3DShapeNode which may enter or exit the box.
Description
Hints
- Each TransformSensor node behaves independently of all other TransformSensor nodes, so that every enabled TransformSensor node affected by targetObject motion sends output events.
- Multiply instanced (DEF/USE) TransformSensor nodes in different locations use the union of all boxes to check for enter and exit, detecting enter and exit for all instances of the box, and sending enter/exit events appropriately. For non-overlapping bounding boxes, position_changed and orientation_changed events are calculated relative to the coordinate system associated with the bounding box in which the proximity was detected.
Warnings
- Results are undefined if boxes overlap for multiply instanced TransformSensor nodes.
- A TransformSensor node with a zero-volume box (i.e. any size dimension equal to 0.0) cannot generate events, equivalent to enabled=false.
- Unlike TouchSensor nodes, there is no notion of a TransformSensor node lower in the scene graph grabbing events.
Example
XML Encoding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd"> <X3D profile='Full' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.3.xsd'> <head> <meta name='comment' content='World of Titania'/> <meta name='created' content='Tue, 28 Oct 2014 06:07:32 GMT'/> <meta name='creator' content='Holger Seelig'/> <meta name='generator' content='Titania V4.0.2, http://titania.create3000.de'/> <meta name='identifier' content='file:///home/holger/Projekte/Server/create3000.de/media/htdocs/components/EnvironmentalSensor/TransformSensor/TransformSensor.x3d'/> <meta name='modified' content='Sun, 26 Nov 2017 08:13:03 GMT'/> </head> <Scene> <ExternProtoDeclare name='BooleanSwitch' url='"https://cdn.rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "http://cdn.rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "https://rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "http://rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d"'> <field accessType='inputOutput' type='SFBool' name='whichChoice'/> <field accessType='initializeOnly' type='SFVec3f' name='bboxSize'/> <field accessType='initializeOnly' type='SFVec3f' name='bboxCenter'/> <field accessType='inputOnly' type='MFNode' name='addChildren'/> <field accessType='inputOnly' type='MFNode' name='removeChildren'/> <field accessType='inputOutput' type='MFNode' name='children'/> </ExternProtoDeclare> <LayerSet activeLayer='2' order='0, 1, 2'> <Layer DEF='Background' isPickable='false'> <Background skyAngle='1.09223, 1.5708' skyColor='0.2 0.2 0.2, 0.2 0.2 0.2, 0.3 0.3 0.3' groundAngle='1.1248, 1.5708' groundColor='0.4 0.4 0.4, 0.4 0.4 0.4, 0.3 0.3 0.3'/> </Layer> <Layer DEF='Scene' isPickable='false'> <Viewpoint description='Initial View' position='-4.59626 4.70732 5.12322' orientation='-0.620224461947893 -0.750758176344024 -0.227340663881414 0.908381420499763' centerOfRotation='-0.201898 0.173507 -0.0657038'/> <Group DEF='Target'> <TimeSensor DEF='_1' cycleInterval='30' loop='true'/> <PositionInterpolator DEF='_2' key='0, 1' keyValue='-4 0 0, 5 0 0'/> <Transform DEF='TargetBox' translation='3.45693 0 0' rotation='0.75228999962235 -0.281997999858437 -0.595429999701094 1.12375' scale='4 2 1'> <Shape> <Appearance> <Material DEF='Rococo23' ambientIntensity='0.187004' diffuseColor='0.25829 0.534482 0.748016' specularColor='0.251984 0.251984 0.251984' shininess='0.25'/> </Appearance> <Box size='1 1 1'/> </Shape> </Transform> </Group> <TransformSensor DEF='_3' size='2 1 3'> <Transform USE='TargetBox' containerField='targetObject'/> </TransformSensor> <Transform DEF='TransformSensorBox' scale='2 1 3'> <ProtoInstance name='BooleanSwitch' DEF='_4'> <fieldValue name='children'> <Shape> <Appearance> <Material DEF='Rococo28' ambientIntensity='0.226102' diffuseColor='0.279645 0.904409 0.511589' specularColor='0.0955906 0.0955906 0.0955906' shininess='0.078125'/> </Appearance> <Box size='1 1 1'/> </Shape> <Shape> <Appearance> <Material DEF='Rococo12' ambientIntensity='0.226102' diffuseColor='0.904409 0.146366 0.208768' specularColor='0.0955906 0.0955906 0.0955906' shininess='0.078125'/> </Appearance> <Box size='1 1 1'/> </Shape> </fieldValue> </ProtoInstance> </Transform> <Transform DEF='Axes' translation='3.10964 0 0' rotation='0.75228999962235 -0.281997999858437 -0.595429999701094 1.12375' scale='2.39949 2.39949 2.39949' scaleOrientation='0.0836664398710557 0.100523939925264 0.991410542782961 3.90741376353791'> <Shape> <IndexedLineSet colorPerVertex='false' colorIndex='0, 1, 2' coordIndex='0, 1, -1, 2, 3, -1, 4, 5, -1'> <Color color='1 0 0, 0 1 0, 0 0 1'/> <Coordinate point='-1 0 0, 1 0 0, 0 -1 0, 0 1 0, 0 0 -1, 0 0 1'/> </IndexedLineSet> </Shape> </Transform> </Layer> </LayerSet> <ROUTE fromNode='_1' fromField='fraction_changed' toNode='_2' toField='set_fraction'/> <ROUTE fromNode='_2' fromField='value_changed' toNode='TargetBox' toField='set_translation'/> <ROUTE fromNode='_3' fromField='position_changed' toNode='Axes' toField='set_translation'/> <ROUTE fromNode='_3' fromField='orientation_changed' toNode='Axes' toField='set_rotation'/> <ROUTE fromNode='_3' fromField='isActive' toNode='_4' toField='set_whichChoice'/> </Scene> </X3D> |
Classic Encoding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
#X3D V3.3 utf8 Titania V4.0.6 PROFILE Full META "comment" "World of Titania" META "created" "Tue, 28 Oct 2014 06:07:32 GMT" META "creator" "Holger Seelig" META "generator" "Titania V4.0.2, http://titania.create3000.de" META "identifier" "file:///home/holger/Projekte/Server/create3000.de/media/htdocs/components/EnvironmentalSensor/TransformSensor/TransformSensor.x3d" META "modified" "Sun, 26 Nov 2017 08:13:03 GMT" EXTERNPROTO BooleanSwitch [ inputOutput SFBool whichChoice initializeOnly SFVec3f bboxSize initializeOnly SFVec3f bboxCenter inputOnly MFNode addChildren inputOnly MFNode removeChildren inputOutput MFNode children ] [ "https://cdn.rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "http://cdn.rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "https://rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "http://rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d" ] LayerSet { activeLayer 2 order [ 0, 1, 2 ] layers [ DEF Background Layer { isPickable FALSE children Background { skyAngle [ 1.09223, 1.5708 ] skyColor [ 0.2 0.2 0.2, 0.2 0.2 0.2, 0.3 0.3 0.3 ] groundAngle [ 1.1248, 1.5708 ] groundColor [ 0.4 0.4 0.4, 0.4 0.4 0.4, 0.3 0.3 0.3 ] } } DEF Scene Layer { isPickable FALSE children [ Viewpoint { description "Initial View" position -4.59626 4.70732 5.12322 orientation -0.620224461947893 -0.750758176344024 -0.227340663881414 0.908381420499763 centerOfRotation -0.201898 0.173507 -0.0657038 } DEF Target Group { children [ DEF _1 TimeSensor { cycleInterval 30 loop TRUE } DEF _2 PositionInterpolator { key [ 0, 1 ] keyValue [ -4 0 0, 5 0 0 ] } DEF TargetBox Transform { translation 3.45693 0 0 rotation 0.75228999962235 -0.281997999858437 -0.595429999701094 1.12375 scale 4 2 1 children Shape { appearance Appearance { material DEF Rococo23 Material { ambientIntensity 0.187004 diffuseColor 0.25829 0.534482 0.748016 specularColor 0.251984 0.251984 0.251984 shininess 0.25 } } geometry Box { size 1 1 1 } } } ] } DEF _3 TransformSensor { size 2 1 3 targetObject USE TargetBox } DEF TransformSensorBox Transform { scale 2 1 3 children DEF _4 BooleanSwitch { children [ Shape { appearance Appearance { material DEF Rococo28 Material { ambientIntensity 0.226102 diffuseColor 0.279645 0.904409 0.511589 specularColor 0.0955906 0.0955906 0.0955906 shininess 0.078125 } } geometry Box { size 1 1 1 } } Shape { appearance Appearance { material DEF Rococo12 Material { ambientIntensity 0.226102 diffuseColor 0.904409 0.146366 0.208768 specularColor 0.0955906 0.0955906 0.0955906 shininess 0.078125 } } geometry Box { size 1 1 1 } } ] } } DEF Axes Transform { translation 3.10964 0 0 rotation 0.75228999962235 -0.281997999858437 -0.595429999701094 1.12375 scale 2.39949 2.39949 2.39949 scaleOrientation 0.0836664398710557 0.100523939925264 0.991410542782961 3.90741376353791 children Shape { geometry IndexedLineSet { colorPerVertex FALSE colorIndex [ 0, 1, 2 ] coordIndex [ 0, 1, -1, 2, 3, -1, 4, 5, -1 ] color Color { color [ 1 0 0, 0 1 0, 0 0 1 ] } coord Coordinate { point [ -1 0 0, 1 0 0, 0 -1 0, 0 1 0, 0 0 -1, 0 0 1 ] } } } } ] } ] } ROUTE _1.fraction_changed TO _2.set_fraction ROUTE _2.value_changed TO TargetBox.set_translation ROUTE _3.position_changed TO Axes.set_translation ROUTE _3.orientation_changed TO Axes.set_rotation ROUTE _3.isActive TO _4.set_whichChoice |
JSON Encoding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
{ "X3D": { "encoding": "UTF-8", "@profile": "Full", "@version": "3.3", "@xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-3.3.xsd", "JSON schema": "http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json", "head": { "meta": [ { "@name": "comment", "@content": "World of Titania" }, { "@name": "created", "@content": "Tue, 28 Oct 2014 06:07:32 GMT" }, { "@name": "creator", "@content": "Holger Seelig" }, { "@name": "generator", "@content": "Titania V4.0.2, http://titania.create3000.de" }, { "@name": "identifier", "@content": "file:///home/holger/Projekte/Server/create3000.de/media/htdocs/components/EnvironmentalSensor/TransformSensor/TransformSensor.x3d" }, { "@name": "modified", "@content": "Sun, 26 Nov 2017 08:13:03 GMT" } ] }, "Scene": { "-children": [ { "ExternProtoDeclare": { "@name":"BooleanSwitch", "field": [ { "@accessType": "inputOutput", "@type": "SFBool", "@name": "whichChoice" }, { "@accessType": "initializeOnly", "@type": "SFVec3f", "@name": "bboxSize" }, { "@accessType": "initializeOnly", "@type": "SFVec3f", "@name": "bboxCenter" }, { "@accessType": "inputOnly", "@type": "MFNode", "@name": "addChildren" }, { "@accessType": "inputOnly", "@type": "MFNode", "@name": "removeChildren" }, { "@accessType": "inputOutput", "@type": "MFNode", "@name": "children" } ], "@url": [ "https://cdn.rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "http://cdn.rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "https://rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d", "http://rawgit.com/create3000/Library/1.0.3/Prototypes/Grouping/BooleanSwitch.x3d" ] } }, { "LayerSet": { "@activeLayer": 2, "@order": [ 0, 1, 2 ], "-layers": [ { "Layer": { "@DEF": "Background", "@isPickable": false, "-children": [ { "Background": { "@skyAngle": [ 1.09223, 1.5708 ], "@skyColor": [ 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3 ], "@groundAngle": [ 1.1248, 1.5708 ], "@groundColor": [ 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.3, 0.3, 0.3 ] } } ] } }, { "Layer": { "@DEF": "Scene", "@isPickable": false, "-children": [ { "Viewpoint": { "@description": "Initial View", "@position": [ -4.59626, 4.70732, 5.12322 ], "@orientation": [ -0.620224461947893, -0.750758176344024, -0.227340663881414, 0.908381420499763 ], "@centerOfRotation": [ -0.201898, 0.173507, -0.0657038 ] } }, { "Group": { "@DEF": "Target", "-children": [ { "TimeSensor": { "@DEF": "_1", "@cycleInterval": 30, "@loop": true } }, { "PositionInterpolator": { "@DEF": "_2", "@key": [ 0, 1 ], "@keyValue": [ -4, 0, 0, 5, 0, 0 ] } }, { "Transform": { "@DEF": "TargetBox", "@translation": [ 3.45693, 0, 0 ], "@rotation": [ 0.75228999962235, -0.281997999858437, -0.595429999701094, 1.12375 ], "@scale": [ 4, 2, 1 ], "-children": [ { "Shape": { "-appearance": { "Appearance": { "-material": { "Material": { "@DEF": "Rococo23", "@ambientIntensity": 0.187004, "@diffuseColor": [ 0.25829, 0.534482, 0.748016 ], "@specularColor": [ 0.251984, 0.251984, 0.251984 ], "@shininess": 0.25 } } } }, "-geometry": { "Box": { "@size": [ 1, 1, 1 ] } } } } ] } } ] } }, { "TransformSensor": { "@DEF": "_3", "@size": [ 2, 1, 3 ], "-targetObject": { "Transform": { "@USE": "TargetBox" } } } }, { "Transform": { "@DEF": "TransformSensorBox", "@scale": [ 2, 1, 3 ], "-children": [ { "ProtoInstance": { "@DEF": "_4", "@name": "BooleanSwitch", "fieldValue": [ { "@name": "children", "-children": [ { "Shape": { "-appearance": { "Appearance": { "-material": { "Material": { "@DEF": "Rococo28", "@ambientIntensity": 0.226102, "@diffuseColor": [ 0.279645, 0.904409, 0.511589 ], "@specularColor": [ 0.0955906, 0.0955906, 0.0955906 ], "@shininess": 0.078125 } } } }, "-geometry": { "Box": { "@size": [ 1, 1, 1 ] } } } }, { "Shape": { "-appearance": { "Appearance": { "-material": { "Material": { "@DEF": "Rococo12", "@ambientIntensity": 0.226102, "@diffuseColor": [ 0.904409, 0.146366, 0.208768 ], "@specularColor": [ 0.0955906, 0.0955906, 0.0955906 ], "@shininess": 0.078125 } } } }, "-geometry": { "Box": { "@size": [ 1, 1, 1 ] } } } } ] } ] } } ] } }, { "Transform": { "@DEF": "Axes", "@translation": [ 3.10964, 0, 0 ], "@rotation": [ 0.75228999962235, -0.281997999858437, -0.595429999701094, 1.12375 ], "@scale": [ 2.39949, 2.39949, 2.39949 ], "@scaleOrientation": [ 0.0836664398710557, 0.100523939925264, 0.991410542782961, 3.90741376353791 ], "-children": [ { "Shape": { "-geometry": { "IndexedLineSet": { "@colorPerVertex": false, "@colorIndex": [ 0, 1, 2 ], "@coordIndex": [ 0, 1, -1, 2, 3, -1, 4, 5, -1 ], "-color": { "Color": { "@color": [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ] } }, "-coord": { "Coordinate": { "@point": [ -1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1 ] } } } } } } ] } } ] } } ] } }, { "ROUTE": { "@fromNode": "_1", "@fromField": "fraction_changed", "@toNode": "_2", "@toField": "set_fraction" } }, { "ROUTE": { "@fromNode": "_2", "@fromField": "value_changed", "@toNode": "TargetBox", "@toField": "translation" } }, { "ROUTE": { "@fromNode": "_3", "@fromField": "position_changed", "@toNode": "Axes", "@toField": "translation" } }, { "ROUTE": { "@fromNode": "_3", "@fromField": "orientation_changed", "@toNode": "Axes", "@toField": "rotation" } }, { "ROUTE": { "@fromNode": "_3", "@fromField": "isActive", "@toNode": "_4", "@toField": "whichChoice" } } ] } } } |