1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
|
3 | <X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'> |
4 | <head> |
5 | <meta name='title' content=' ViewPositionOrientationPrototype.x3d '/> |
6 | <meta name='creator' content='Leonard Daly and Don Brutzman'/> |
7 | <meta name='translator' content='Don Brutzman'/> |
8 | <meta name='created' content='1 November 2000'/> |
9 | <meta name='modified' content='28 November 2019'/> |
10 | <meta name='description' content='ViewPositionOrientation prototype provides local position and orientation as user navigates, with optional console output'/> |
11 | <meta name='info' content='Note fix: metadata is no longer an allowed ProtoDeclare field name, since ProtoInstance already includes a metadata field'/> |
12 | <meta name='reference' content=' ViewPositionOrientationExample.x3d '/> |
13 | <meta name='reference' content=' https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/WhereAmIExample.x3d '/> |
14 | <meta name='reference' content=' https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/WhereAmIPrototype.x3d '/> |
15 | <meta name='reference' content='http://www.realism.com/Web3D/Examples#WhereAmI'/> |
16 | <meta name='reference' content='http://www.realism.com/vrml/Example/WhereAmI/WhereAmI_Proto.wrl'/> |
17 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/ViewPositionOrientationPrototype.x3d '/> |
18 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
19 | <meta name='license' content='../../license.html'/> |
20 | </head> |
21 | <Scene> |
22 | <!-- Thanks to Leonard Daly for the original design of this prototype --> |
23 | <WorldInfo title='ViewPositionOrientationPrototype.x3d'/> |
24 | <ProtoDeclare name='ViewPositionOrientation' appinfo='ViewPositionOrientation provides provides console output of local position and orientation as user navigates'> |
25 | <ProtoInterface> |
26 |
<field name='enabled' type='SFBool' value='true' accessType='inputOutput'
appinfo='Whether or not ViewPositionOrientation sends output to console'/> |
27 |
<field name='traceEnabled' type='SFBool' value='true' accessType='initializeOnly'
appinfo='Output internal trace messages for debugging this node, intended for developer use only'/> |
28 |
<field name='set_traceEnabled' type='SFBool' accessType='inputOnly'
appinfo='Ability to turn output tracing on/off at runtime'/> |
29 |
<field name='position_changed' type='SFVec3f' accessType='outputOnly'
appinfo='Output local position'/> |
30 |
<field name='orientation_changed' type='SFRotation' accessType='outputOnly'
appinfo='Output local orientation'/> |
31 |
<field name='outputViewpointString' type='MFString' accessType='outputOnly'
appinfo='MFString value of new Viewpoint, suitable for use in string field of a Text node'/> |
32 | </ProtoInterface> |
33 | <ProtoBody> |
34 |
<!-- ROUTE information for WhereSensor node:
[from position_changed to OutputPositionOrientation.set_position
]
[from orientation_changed to OutputPositionOrientation.set_orientation
]
-->
<ProximitySensor DEF='WhereSensor' size='1000000000 1000000000 1000000000'> |
35 | <IS> |
36 | <connect nodeField='enabled' protoField='enabled'/> |
37 | </IS> |
38 | </ProximitySensor> |
39 | <!-- it's a big old world out there! large box likely handles most use cases. --> |
40 |
<!-- ROUTE information for OutputPositionOrientation node:
[from WhereSensor.position_changed to set_position
]
[from WhereSensor.orientation_changed to set_orientation
]
-->
<Script DEF='OutputPositionOrientation'> |
41 | <field name='traceEnabled' type='SFBool' accessType='initializeOnly'/> |
42 | <field name='set_traceEnabled' type='SFBool' accessType='inputOnly'/> |
43 | <field name='set_position' type='SFVec3f' accessType='inputOnly'/> |
44 | <field name='set_orientation' type='SFRotation' accessType='inputOnly'/> |
45 | <field name='position' type='SFVec3f' value='0 0 0' accessType='initializeOnly'/> |
46 | <field name='orientation' type='SFRotation' value='0 1 0 0' accessType='initializeOnly'/> |
47 | <field name='position_changed' type='SFVec3f' accessType='outputOnly'/> |
48 | <field name='orientation_changed' type='SFRotation' accessType='outputOnly'/> |
49 | <field name='outputViewpointString' type='MFString' accessType='outputOnly'/> |
50 | <IS> |
51 | <connect nodeField='traceEnabled' protoField='traceEnabled'/> |
52 | <connect nodeField='set_traceEnabled' protoField='set_traceEnabled'/> |
53 | <connect nodeField='position_changed' protoField='position_changed'/> |
54 | <connect nodeField='orientation_changed' protoField='orientation_changed'/> |
55 | <connect nodeField='outputViewpointString' protoField='outputViewpointString'/> |
56 | </IS> |
<![CDATA[
ecmascript: function roundoff (value, digits) // for local use only { var resolution = 1; for (i = 1; i <= digits; i++ ) { resolution *= 10; } return Math.round (value*resolution) / resolution; // round to resolution } function outputViewpoint () { var holdString = '<Viewpoint position=\"' + roundoff (position.x, 1) + ' ' + roundoff (position.y, 1) + ' ' + roundoff (position.z, 1) + '\" orientation=\"' + roundoff (orientation.x, 3) + ' ' + roundoff (orientation.y, 3) + ' ' + roundoff (orientation.z, 3) + ' ' + roundoff (orientation.angle, 4) + '\"/>' ; tracePrint (holdString); outputViewpointString = new MFString (holdString); } function set_position (value) { position = value; // save persistent value position_changed = position; // output event outputViewpoint (); } function set_orientation (value) { orientation = value; // save persistent value orientation_changed = orientation; // output event outputViewpoint (); } function set_traceEnabled (value) { traceEnabled = value; alwaysPrint ('traceEnabled=' + traceEnabled); } function alwaysPrint (text) { Browser.println ('[ViewPositionOrientation] ' + text); } function tracePrint (text) { if (traceEnabled) alwaysPrint (text); }
]]>
|
|
58 | </Script> |
59 | < ROUTE fromNode='WhereSensor' fromField='position_changed' toNode='OutputPositionOrientation' toField='set_position'/> |
60 | < ROUTE fromNode='WhereSensor' fromField='orientation_changed' toNode='OutputPositionOrientation' toField='set_orientation'/> |
61 | </ProtoBody> |
62 | </ProtoDeclare> |
63 | <!-- ==================== --> |
64 | <Viewpoint description='ViewPositionOrientation prototype' position='0 0 14'/> |
65 | <Anchor description='ViewPositionOrientation Example' parameter='"target=_blank"' url=' "ViewPositionOrientationExample.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/ViewPositionOrientationExample.x3d" "ViewPositionOrientationExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/ViewPositionOrientationExample.wrl" '> |
66 | <Shape> |
67 | <Text string='"ViewPositionOrientationPrototype" "is a prototype definition file" "" "Click this text to see" "ViewPositionOrientationExample"'> |
68 | <FontStyle justify='"MIDDLE" "MIDDLE"' size='1.2'/> |
69 | </Text> |
70 | <Appearance> |
71 | <Material diffuseColor='0.6 0.8 0.4'/> |
72 | </Appearance> |
73 | </Shape> |
74 | <!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip --> |
75 | <Shape> |
76 | <!-- Author TODO: to adjust transparent Box as text-selection assist, set width and height to match size, then set transparency='1' to make invisible. --> |
77 | <Box size='16 7 .001'/> |
78 | <Appearance> |
79 | <Material transparency='1'/> |
80 | </Appearance> |
81 | </Shape> |
82 | </Anchor> |
83 | </Scene> |
84 | </X3D> |
Event Graph ROUTE Table entries with 2 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.
WhereSensor
ProximitySensor position_changed SFVec3f |
OutputPositionOrientation
Script set_position SFVec3f |
|
WhereSensor
ProximitySensor orientation_changed SFRotation |
OutputPositionOrientation
Script set_orientation SFRotation |
line 65
Anchor |
description='ViewPositionOrientation Example' User-interaction hint for this node. |
<!--
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)
<ProtoDeclare name='ProtoName'>
<field
name='fieldName'/> </ProtoDeclare>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->