<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd"><X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<![CDATA[
ecmascript:
function roundoff (value, digits) // for local use only
{
resolution = 1;
for (i = 1; i <= digits; i++ )
{
resolution *= 10;
}
return Math.round (value*resolution) / resolution; // round to resolution
}
function outputViewpoint ()
{
outputViewpointString[0] =
'<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 (outputViewpointString);
}
function set_position (value, timestamp)
{
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;
tracePrint ('traceEnabled=' + traceEnabled);
}
function forcePrint (text)
{
Browser.print ('[ViewPositionOrientation]' + text);
}
function tracePrint (text)
{
if (traceEnabled) Browser.print ('[ViewPositionOrientation]' + text);
}
]]>
<!-- Tag color codes: <Node DEF='idName' attribute='value'/> <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->